mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
android: show info for Xiaomi users about autostart restrictions (#5295)
* android: show info for Xiaomi users about autostart restrictions * text and placement * update strings --------- Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
This commit is contained in:
committed by
GitHub
parent
a62ce9168e
commit
665501026d
@@ -332,6 +332,8 @@ class SimplexApp: Application(), LifecycleEventObserver {
|
||||
NetworkObserver.shared.restartNetworkObserver()
|
||||
}
|
||||
|
||||
override fun androidIsXiaomiDevice(): Boolean = setOf("xiaomi", "redmi", "poco").contains(Build.BRAND.lowercase())
|
||||
|
||||
@SuppressLint("SourceLockedOrientationActivity")
|
||||
@Composable
|
||||
override fun androidLockPortraitOrientation() {
|
||||
|
||||
@@ -497,6 +497,12 @@ class SimplexService: Service() {
|
||||
Modifier.padding(bottom = 8.dp)
|
||||
)
|
||||
Text(annotatedStringResource(MR.strings.turn_off_battery_optimization))
|
||||
|
||||
if (platform.androidIsXiaomiDevice() && (mode == NotificationsMode.PERIODIC || mode == NotificationsMode.SERVICE)) {
|
||||
Text(annotatedStringResource(MR.strings.xiaomi_ignore_battery_optimization),
|
||||
Modifier.padding(top = 8.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
@@ -623,7 +629,7 @@ class SimplexService: Service() {
|
||||
|
||||
fun isBackgroundAllowed(): Boolean = isIgnoringBatteryOptimizations() && !isBackgroundRestricted()
|
||||
|
||||
fun isIgnoringBatteryOptimizations(): Boolean {
|
||||
private fun isIgnoringBatteryOptimizations(): Boolean {
|
||||
val powerManager = androidAppContext.getSystemService(Application.POWER_SERVICE) as PowerManager
|
||||
return powerManager.isIgnoringBatteryOptimizations(androidAppContext.packageName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user