mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
fix some issues
This commit is contained in:
parent
2c6c5cdc03
commit
c560246b8c
3 changed files with 10 additions and 17 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue