mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-05-05 23:52:13 +00:00
ui improvements to ignore battery optimization popup
This commit is contained in:
parent
c5ed175944
commit
f8a2ce8ea2
1 changed files with 19 additions and 22 deletions
|
@ -29,33 +29,30 @@ class BackgroundSyncPage extends BasePage {
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Observer(builder: (context) {
|
|
||||||
if (dashboardViewModel.hasBatteryOptimization && dashboardViewModel.batteryOptimizationEnabled) {
|
|
||||||
return SettingsSwitcherCell(
|
|
||||||
title: S.current.unrestricted_background_service,
|
|
||||||
value: !dashboardViewModel.batteryOptimizationEnabled,
|
|
||||||
onValueChange: (_, bool value) {
|
|
||||||
dashboardViewModel.disableBatteryOptimization();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return Container();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
Observer(builder: (context) {
|
Observer(builder: (context) {
|
||||||
return SettingsSwitcherCell(
|
return SettingsSwitcherCell(
|
||||||
title: S.current.background_sync,
|
title: S.current.background_sync,
|
||||||
value: dashboardViewModel.backgroundSyncEnabled,
|
value: dashboardViewModel.backgroundSyncEnabled,
|
||||||
onValueChange: (dashboardViewModel.batteryOptimizationEnabled && dashboardViewModel.hasBatteryOptimization) ? (_, bool value) {
|
onValueChange: (_, bool value) async {
|
||||||
unawaited(showPopUp(context: context, builder: (context) => AlertWithOneAction(
|
|
||||||
alertTitle: S.current.background_sync,
|
|
||||||
alertContent: S.current.unrestricted_background_service_notice,
|
|
||||||
buttonText: S.current.ok,
|
|
||||||
buttonAction: () => Navigator.of(context).pop(),
|
|
||||||
)));
|
|
||||||
} : (_, bool value) {
|
|
||||||
if (value) {
|
if (value) {
|
||||||
dashboardViewModel.enableBackgroundSync();
|
if (dashboardViewModel.batteryOptimizationEnabled) {
|
||||||
|
await showPopUp(context: context, builder: (context) => AlertWithOneAction(
|
||||||
|
alertTitle: S.current.background_sync,
|
||||||
|
alertContent: S.current.unrestricted_background_service_notice,
|
||||||
|
buttonText: S.current.ok,
|
||||||
|
buttonAction: () => Navigator.of(context).pop(),
|
||||||
|
));
|
||||||
|
await dashboardViewModel.disableBatteryOptimization();
|
||||||
|
for (var i = 0; i < 4 * 60; i++) {
|
||||||
|
await Future.delayed(Duration(milliseconds: 250));
|
||||||
|
if (!dashboardViewModel.batteryOptimizationEnabled) {
|
||||||
|
await dashboardViewModel.enableBackgroundSync();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dashboardViewModel.enableBackgroundSync();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dashboardViewModel.disableBackgroundSync();
|
dashboardViewModel.disableBackgroundSync();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue