diff --git a/app/build.gradle b/app/build.gradle index fa5ad27f08..929a74e789 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 21 targetSdkVersion 34 - versionCode 1152 - versionName "0.11.52" + versionCode 1153 + versionName "0.11.53" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt b/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt index f7f6b077bf..05aadd06ba 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt @@ -1,14 +1,11 @@ package org.ole.planet.myplanet.base -import android.app.Activity import android.content.Context import android.content.DialogInterface import android.content.Intent import android.content.SharedPreferences import android.net.Uri -import android.os.Build import android.os.Bundle -import android.provider.Settings import android.text.TextUtils import android.util.Log import android.view.LayoutInflater @@ -19,7 +16,6 @@ import android.widget.ArrayAdapter import android.widget.Button import android.widget.TextView import android.widget.Toast -import androidx.annotation.RequiresApi import androidx.appcompat.app.AlertDialog import androidx.appcompat.widget.AppCompatRatingBar import androidx.core.content.FileProvider @@ -27,7 +23,6 @@ import com.google.gson.JsonObject import io.realm.RealmResults import org.ole.planet.myplanet.MainApplication import org.ole.planet.myplanet.R -import org.ole.planet.myplanet.base.PermissionActivity.hasInstallPermission import org.ole.planet.myplanet.callback.OnHomeItemClickListener import org.ole.planet.myplanet.callback.OnRatingChangeListener import org.ole.planet.myplanet.model.RealmMyLibrary @@ -35,7 +30,13 @@ import org.ole.planet.myplanet.service.UserProfileDbHandler import org.ole.planet.myplanet.service.UserProfileDbHandler.KEY_RESOURCE_DOWNLOAD import org.ole.planet.myplanet.service.UserProfileDbHandler.KEY_RESOURCE_OPEN import org.ole.planet.myplanet.ui.course.AdapterCourses -import org.ole.planet.myplanet.ui.viewer.* +import org.ole.planet.myplanet.ui.viewer.AudioPlayerActivity +import org.ole.planet.myplanet.ui.viewer.CSVViewerActivity +import org.ole.planet.myplanet.ui.viewer.ImageViewerActivity +import org.ole.planet.myplanet.ui.viewer.MarkdownViewerActivity +import org.ole.planet.myplanet.ui.viewer.PDFReaderActivity +import org.ole.planet.myplanet.ui.viewer.TextFileViewerActivity +import org.ole.planet.myplanet.ui.viewer.VideoPlayerActivity import org.ole.planet.myplanet.utilities.FileUtils import org.ole.planet.myplanet.utilities.Utilities import java.io.File @@ -45,9 +46,9 @@ abstract class BaseContainerFragment : BaseResourceFragment() { var rating: TextView? = null var ratingBar: AppCompatRatingBar? = null lateinit var profileDbHandler: UserProfileDbHandler - private val INSTALL_UNKNOWN_SOURCES_REQUEST_CODE = 112 - var hasInstallPermission = hasInstallPermission(MainApplication.context) - private var currentLibrary: RealmMyLibrary? = null +// private val INSTALL_UNKNOWN_SOURCES_REQUEST_CODE = 112 +// var hasInstallPermission = hasInstallPermission(MainApplication.context) +// private var currentLibrary: RealmMyLibrary? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -145,7 +146,6 @@ abstract class BaseContainerFragment : BaseResourceFragment() { } } - @RequiresApi(Build.VERSION_CODES.O) fun checkMoreFileExtensions(extension: String?, items: RealmMyLibrary) { when (extension) { "txt" -> openIntent(items, TextFileViewerActivity::class.java) @@ -158,9 +158,8 @@ abstract class BaseContainerFragment : BaseResourceFragment() { } } - @RequiresApi(Build.VERSION_CODES.O) private fun installApk(items: RealmMyLibrary) { - currentLibrary = items +// currentLibrary = items val directory = File(MainApplication.context.getExternalFilesDir(null).toString() + "/ole" + "/" + items.id) if (!directory.exists()) { if (!directory.mkdirs()) { @@ -184,22 +183,22 @@ abstract class BaseContainerFragment : BaseResourceFragment() { intent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_ACTIVITY_NEW_TASK if (intent.resolveActivity(requireActivity().packageManager) != null) { - if (hasInstallPermission(MainApplication.context)) { +// if (hasInstallPermission(MainApplication.context)) { startActivity(intent) - } else { - requestInstallPermission() - } +// } else { +// requestInstallPermission() +// } } else { Utilities.toast(activity,"No app to handle the installation") } } - @RequiresApi(Build.VERSION_CODES.O) - private fun requestInstallPermission() { - val intent = Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES) - intent.data = Uri.parse("package:" + MainApplication.context.packageName) - startActivityForResult(intent, INSTALL_UNKNOWN_SOURCES_REQUEST_CODE) - } +// @RequiresApi(Build.VERSION_CODES.O) +// private fun requestInstallPermission() { +// val intent = Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES) +// intent.data = Uri.parse("package:" + MainApplication.context.packageName) +// startActivityForResult(intent, INSTALL_UNKNOWN_SOURCES_REQUEST_CODE) +// } fun openFileType(items: RealmMyLibrary, videotype: String) { val mimetype = Utilities.getMimeType(items.resourceLocalAddress) @@ -299,22 +298,22 @@ abstract class BaseContainerFragment : BaseResourceFragment() { } } - @RequiresApi(Build.VERSION_CODES.O) - override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - super.onActivityResult(requestCode, resultCode, data) - if (requestCode == INSTALL_UNKNOWN_SOURCES_REQUEST_CODE) { - if (resultCode == Activity.RESULT_OK) { - if (currentLibrary != null) { - installApk(currentLibrary!!) - currentLibrary = null - } - } else { - Utilities.toast(requireActivity(), getString(R.string.permissions_denied)) - } - } - } +// @RequiresApi(Build.VERSION_CODES.O) +// override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { +// super.onActivityResult(requestCode, resultCode, data) +// if (requestCode == INSTALL_UNKNOWN_SOURCES_REQUEST_CODE) { +// if (resultCode == Activity.RESULT_OK) { +// if (currentLibrary != null) { +// installApk(currentLibrary!!) +// currentLibrary = null +// } +// } else { +// Utilities.toast(requireActivity(), getString(R.string.permissions_denied)) +// } +// } +// } - open fun handleBackPressed() { - requireActivity().onBackPressed() - } +// open fun handleBackPressed() { +// requireActivity().onBackPressed() +// } } diff --git a/app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.java b/app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.java index 2d85f3fcfa..d66d72b49e 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.java +++ b/app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.java @@ -28,12 +28,12 @@ public boolean checkPermission(String strPermission) { return result == PackageManager.PERMISSION_GRANTED; } - public static boolean hasInstallPermission(android.content.Context context) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - return context.getPackageManager().canRequestPackageInstalls(); - } - return true; - } +// public static boolean hasInstallPermission(android.content.Context context) { +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { +// return context.getPackageManager().canRequestPackageInstalls(); +// } +// return true; +// } public void checkUsagesPermission() { if (!getUsagesPermission(this)) { diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.java b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.java index 5c550230ae..5b47bf5530 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.java @@ -35,7 +35,6 @@ import com.mikepenz.materialdrawer.model.interfaces.Nameable; import org.ole.planet.myplanet.R; -import org.ole.planet.myplanet.base.BaseContainerFragment; import org.ole.planet.myplanet.callback.OnHomeItemClickListener; import org.ole.planet.myplanet.databinding.ActivityDashboardBinding; import org.ole.planet.myplanet.databinding.CustomTabBinding; @@ -429,12 +428,12 @@ public void onBackPressed() { super.onBackPressed(); } - Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container); - if (fragment instanceof BaseContainerFragment) { - ((BaseContainerFragment) fragment).handleBackPressed(); - } else { - super.onBackPressed(); - } +// Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container); +// if (fragment instanceof BaseContainerFragment) { +// ((BaseContainerFragment) fragment).handleBackPressed(); +// } else { +// super.onBackPressed(); +// } } @Override