mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-05-01 14:34:24 +02:00
fix: remove battery optimization notification if user grants the permission
This commit is contained in:
parent
5d3a81f4b9
commit
cf3866f892
@ -109,7 +109,6 @@ fun DashboardScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val context = LocalContext.current
|
|
||||||
var showAndroid11Dialog by rememberSaveable { mutableStateOf(false) }
|
var showAndroid11Dialog by rememberSaveable { mutableStateOf(false) }
|
||||||
val installAppsPermissionLauncher =
|
val installAppsPermissionLauncher =
|
||||||
rememberLauncherForActivityResult(RequestInstallAppsContract) { granted ->
|
rememberLauncherForActivityResult(RequestInstallAppsContract) { granted ->
|
||||||
@ -121,7 +120,7 @@ fun DashboardScreen(
|
|||||||
showAndroid11Dialog = false
|
showAndroid11Dialog = false
|
||||||
},
|
},
|
||||||
onContinue = {
|
onContinue = {
|
||||||
installAppsPermissionLauncher.launch(context.packageName)
|
installAppsPermissionLauncher.launch(androidContext.packageName)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -239,6 +238,7 @@ fun DashboardScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val showBatteryOptimizationsWarning by vm.showBatteryOptimizationsWarningFlow.collectAsStateWithLifecycle(false)
|
||||||
Notifications(
|
Notifications(
|
||||||
if (!Aapt.supportsDevice()) {
|
if (!Aapt.supportsDevice()) {
|
||||||
{
|
{
|
||||||
@ -250,7 +250,7 @@ fun DashboardScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else null,
|
} else null,
|
||||||
if (vm.showBatteryOptimizationsWarning) {
|
if (showBatteryOptimizationsWarning) {
|
||||||
{
|
{
|
||||||
NotificationCard(
|
NotificationCard(
|
||||||
isWarning = true,
|
isWarning = true,
|
||||||
|
@ -24,7 +24,9 @@ import app.revanced.manager.network.api.ReVancedAPI
|
|||||||
import app.revanced.manager.util.PM
|
import app.revanced.manager.util.PM
|
||||||
import app.revanced.manager.util.toast
|
import app.revanced.manager.util.toast
|
||||||
import app.revanced.manager.util.uiSafe
|
import app.revanced.manager.util.uiSafe
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
|
import kotlinx.coroutines.flow.flow
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@ -56,14 +58,19 @@ class DashboardViewModel(
|
|||||||
|
|
||||||
var updatedManagerVersion: String? by mutableStateOf(null)
|
var updatedManagerVersion: String? by mutableStateOf(null)
|
||||||
private set
|
private set
|
||||||
var showBatteryOptimizationsWarning by mutableStateOf(false)
|
val showBatteryOptimizationsWarningFlow = flow {
|
||||||
private set
|
while (true) {
|
||||||
|
// There is no callback for this, so we have to poll it.
|
||||||
|
val result = !powerManager.isIgnoringBatteryOptimizations(app.packageName)
|
||||||
|
emit(result)
|
||||||
|
if (!result) return@flow
|
||||||
|
delay(500L)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
checkForManagerUpdates()
|
checkForManagerUpdates()
|
||||||
showBatteryOptimizationsWarning =
|
|
||||||
!powerManager.isIgnoringBatteryOptimizations(app.packageName)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user