mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
dialog to ask ignore battery optimisation for cs3
This commit is contained in:
parent
3dcf7076d0
commit
2729d60460
3 changed files with 31 additions and 3 deletions
|
@ -14,7 +14,7 @@
|
||||||
<uses-permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA" /> <!-- Used for Android TV watch next -->
|
<uses-permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA" /> <!-- Used for Android TV watch next -->
|
||||||
<uses-permission android:name="android.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION" /> <!-- Used for updates without prompt -->
|
<uses-permission android:name="android.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION" /> <!-- Used for updates without prompt -->
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <!-- Used for update service -->
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <!-- Used for update service -->
|
||||||
|
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||||
|
|
||||||
<!-- Required for getting arbitrary Aniyomi packages -->
|
<!-- Required for getting arbitrary Aniyomi packages -->
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.graphics.Rect
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.provider.Settings
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
|
@ -23,6 +24,7 @@ import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.result.ActivityResultLauncher
|
import androidx.activity.result.ActivityResultLauncher
|
||||||
import androidx.annotation.IdRes
|
import androidx.annotation.IdRes
|
||||||
import androidx.annotation.MainThread
|
import androidx.annotation.MainThread
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
@ -150,6 +152,7 @@ import com.lagradost.cloudstream3.utils.UIHelper.requestRW
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.toPx
|
import com.lagradost.cloudstream3.utils.UIHelper.toPx
|
||||||
import com.lagradost.cloudstream3.utils.USER_PROVIDER_API
|
import com.lagradost.cloudstream3.utils.USER_PROVIDER_API
|
||||||
import com.lagradost.cloudstream3.utils.USER_SELECTED_HOMEPAGE_API
|
import com.lagradost.cloudstream3.utils.USER_SELECTED_HOMEPAGE_API
|
||||||
|
import com.lagradost.cloudstream3.utils.UserPreferenceDelegate
|
||||||
import com.lagradost.nicehttp.Requests
|
import com.lagradost.nicehttp.Requests
|
||||||
import com.lagradost.nicehttp.ResponseParser
|
import com.lagradost.nicehttp.ResponseParser
|
||||||
import com.lagradost.safefile.SafeFile
|
import com.lagradost.safefile.SafeFile
|
||||||
|
@ -165,7 +168,6 @@ import kotlin.math.absoluteValue
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
|
|
||||||
//https://github.com/videolan/vlc-android/blob/3706c4be2da6800b3d26344fc04fab03ffa4b860/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt#L1898
|
//https://github.com/videolan/vlc-android/blob/3706c4be2da6800b3d26344fc04fab03ffa4b860/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt#L1898
|
||||||
//https://wiki.videolan.org/Android_Player_Intents/
|
//https://wiki.videolan.org/Android_Player_Intents/
|
||||||
|
|
||||||
|
@ -321,6 +323,9 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
||||||
*/
|
*/
|
||||||
val reloadLibraryEvent = Event<Boolean>()
|
val reloadLibraryEvent = Event<Boolean>()
|
||||||
|
|
||||||
|
/** For battery optimisation **/
|
||||||
|
private var isAppOptimised : Boolean by UserPreferenceDelegate("iAppOptimised", false)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if the str has launched an app task (be it successful or not)
|
* @return true if the str has launched an app task (be it successful or not)
|
||||||
|
@ -1174,8 +1179,12 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
changeStatusBarState(isEmulatorSettings())
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !isAppOptimised && !isTrueTvSettings()
|
||||||
|
&& !isTvSettings() && !isEmulatorSettings()) {
|
||||||
|
showBatteryOptimizationDialog()
|
||||||
|
}
|
||||||
|
|
||||||
|
changeStatusBarState(isEmulatorSettings())
|
||||||
// Automatically enable jsdelivr if cant connect to raw.githubusercontent.com
|
// Automatically enable jsdelivr if cant connect to raw.githubusercontent.com
|
||||||
if (this.getKey<Boolean>(getString(R.string.jsdelivr_proxy_key)) == null && isNetworkAvailable()) {
|
if (this.getKey<Boolean>(getString(R.string.jsdelivr_proxy_key)) == null && isNetworkAvailable()) {
|
||||||
main {
|
main {
|
||||||
|
@ -1747,4 +1756,20 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.M)
|
||||||
|
private fun showBatteryOptimizationDialog() {
|
||||||
|
AlertDialog.Builder(this)
|
||||||
|
.setTitle(R.string.battery_dialog_title)
|
||||||
|
.setMessage(R.string.battery_dialog_message)
|
||||||
|
.setPositiveButton(R.string.ok) { _, _ ->
|
||||||
|
isAppOptimised = true
|
||||||
|
val intent = Intent()
|
||||||
|
intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
|
||||||
|
intent.data = Uri.fromParts("package", packageName, null)
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -646,6 +646,9 @@
|
||||||
<string name="confirm_exit_dialog">Are you sure you want to exit\?</string>
|
<string name="confirm_exit_dialog">Are you sure you want to exit\?</string>
|
||||||
<string name="yes">Yes</string>
|
<string name="yes">Yes</string>
|
||||||
<string name="no">No</string>
|
<string name="no">No</string>
|
||||||
|
<string name="ok">OK</string>
|
||||||
|
<string name="battery_dialog_title">Battery Optimization</string>
|
||||||
|
<string name="battery_dialog_message">To ensure proper Downloads and Notifications, please set Battery Optimization for CloudStream app to Unrestricted.</string>
|
||||||
<string name="update_notification_downloading">Downloading app update…</string>
|
<string name="update_notification_downloading">Downloading app update…</string>
|
||||||
<string name="update_notification_installing">Installing app update…</string>
|
<string name="update_notification_installing">Installing app update…</string>
|
||||||
<string name="update_notification_failed">Could not install the new version of the app</string>
|
<string name="update_notification_failed">Could not install the new version of the app</string>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue