diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentPhone.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentPhone.kt index 913f44c4..fb5160a7 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentPhone.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentPhone.kt @@ -31,7 +31,6 @@ import com.google.android.material.bottomsheet.BottomSheetDialog import com.lagradost.cloudstream3.APIHolder import com.lagradost.cloudstream3.APIHolder.updateHasTrailers import com.lagradost.cloudstream3.CommonActivity.showToast -import com.lagradost.cloudstream3.CommonActivity import com.lagradost.cloudstream3.DubStatus import com.lagradost.cloudstream3.LoadResponse import com.lagradost.cloudstream3.MainActivity.Companion.afterPluginsLoadedEvent diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsGeneral.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsGeneral.kt index 200ce31a..c3d84867 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsGeneral.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsGeneral.kt @@ -34,10 +34,7 @@ import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setPaddingBottom import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setToolBarScrollFlags import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar -import com.lagradost.cloudstream3.utils.BatteryOptimizationChecker -import com.lagradost.cloudstream3.utils.BatteryOptimizationChecker.intentOpenAppInfo import com.lagradost.cloudstream3.utils.BatteryOptimizationChecker.isAppRestricted -import com.lagradost.cloudstream3.utils.BatteryOptimizationChecker.openBatteryOptimizationSettings import com.lagradost.cloudstream3.utils.BatteryOptimizationChecker.showBatteryOptimizationDialog import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog @@ -210,10 +207,8 @@ class SettingsGeneral : PreferenceFragmentCompat() { return@setOnPreferenceClickListener true } - // hide preference on tvs and emulators - if (!isLayout(PHONE)) { - getPref(R.string.battery_optimisation_key)?.isEnabled = false - } + // disable preference on tvs and emulators + getPref(R.string.battery_optimisation_key)?.isEnabled = isLayout(PHONE) getPref(R.string.battery_optimisation_key)?.setOnPreferenceClickListener { val ctx = context ?: return@setOnPreferenceClickListener false @@ -222,6 +217,7 @@ class SettingsGeneral : PreferenceFragmentCompat() { } else { showToast(R.string.app_unrestricted_toast) } + true } diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/PowerManagerAPI.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/PowerManagerAPI.kt index 18810b5b..27609730 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/PowerManagerAPI.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/PowerManagerAPI.kt @@ -56,30 +56,28 @@ object BatteryOptimizationChecker { } .show() } - } catch (e: Exception) { - Log.e(TAG, "Error showing battery optimization dialog", e) + } catch (t: Throwable) { + Log.e(TAG, "Error showing battery optimization dialog", t) } } private fun shouldShowBatteryOptimizationDialog(context: Context): Boolean { val isRestricted = isAppRestricted(context) - val isOptimizedShown = PreferenceManager.getDefaultSharedPreferences(context) + val isOptimizedNotShown = PreferenceManager.getDefaultSharedPreferences(context) .getBoolean(context.getString(R.string.battery_optimisation_key), true) - return isRestricted && isOptimizedShown && isLayout(PHONE) + return isRestricted && isOptimizedNotShown && isLayout(PHONE) } - fun intentOpenAppInfo(context: Context) { + private fun intentOpenAppInfo(context: Context) { val intent = Intent() - try { - intent - .setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) + intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) .setData(Uri.fromParts("package", packageName, null)) context.startActivity(intent, Bundle()) } catch (t: Throwable) { Log.e(TAG, "Unable to invoke any intent", t) if (t is ActivityNotFoundException) { - showToast("ActivityNotFoundException") + showToast("Exception: Activity Not Found") } else { showToast(R.string.app_info_intent_error) }