From ae3b67a5ba6c6f4ef2495b9b9a55b06726800720 Mon Sep 17 00:00:00 2001 From: IndusAryan Date: Sun, 17 Mar 2024 18:38:46 +0530 Subject: [PATCH] merge with upstream --- .../lagradost/cloudstream3/ui/settings/SettingsGeneral.kt | 6 ++++++ .../com/lagradost/cloudstream3/utils/PowerManagerAPI.kt | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) 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 d0047d87..200ce31a 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 @@ -27,7 +27,9 @@ import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.mvvm.normalSafeApiCall import com.lagradost.cloudstream3.network.initClient import com.lagradost.cloudstream3.ui.EasterEggMonke +import com.lagradost.cloudstream3.ui.settings.Globals.PHONE import com.lagradost.cloudstream3.ui.settings.Globals.beneneCount +import com.lagradost.cloudstream3.ui.settings.Globals.isLayout 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 @@ -208,6 +210,10 @@ class SettingsGeneral : PreferenceFragmentCompat() { return@setOnPreferenceClickListener true } + // hide preference on tvs and emulators + if (!isLayout(PHONE)) { + getPref(R.string.battery_optimisation_key)?.isEnabled = false + } getPref(R.string.battery_optimisation_key)?.setOnPreferenceClickListener { val ctx = context ?: return@setOnPreferenceClickListener false 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 3bea9fa4..18810b5b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/PowerManagerAPI.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/PowerManagerAPI.kt @@ -14,7 +14,8 @@ import androidx.preference.PreferenceManager import com.lagradost.cloudstream3.BuildConfig import com.lagradost.cloudstream3.CommonActivity.showToast import com.lagradost.cloudstream3.R -import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTruePhone +import com.lagradost.cloudstream3.ui.settings.Globals.PHONE +import com.lagradost.cloudstream3.ui.settings.Globals.isLayout const val packageName = BuildConfig.APPLICATION_ID const val TAG = "PowerManagerAPI" @@ -64,7 +65,7 @@ object BatteryOptimizationChecker { val isRestricted = isAppRestricted(context) val isOptimizedShown = PreferenceManager.getDefaultSharedPreferences(context) .getBoolean(context.getString(R.string.battery_optimisation_key), true) - return isRestricted && isOptimizedShown && isTruePhone() + return isRestricted && isOptimizedShown && isLayout(PHONE) } fun intentOpenAppInfo(context: Context) {