From a94fd3547b86b812762681e5f3a7888d5509524c Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Wed, 13 Apr 2022 14:09:17 -0700 Subject: [PATCH] add popup about disable battery unoptimized; fix mute policy loading --- lib/l10n/intl_cy.arb | 6 ++++-- lib/l10n/intl_da.arb | 6 ++++-- lib/l10n/intl_de.arb | 6 ++++-- lib/l10n/intl_el.arb | 6 ++++-- lib/l10n/intl_en.arb | 6 ++++-- lib/l10n/intl_es.arb | 6 ++++-- lib/l10n/intl_fr.arb | 10 ++++++---- lib/l10n/intl_it.arb | 6 ++++-- lib/l10n/intl_lb.arb | 6 ++++-- lib/l10n/intl_no.arb | 6 ++++-- lib/l10n/intl_pl.arb | 6 ++++-- lib/l10n/intl_pt.arb | 6 ++++-- lib/l10n/intl_ro.arb | 6 ++++-- lib/l10n/intl_ru.arb | 5 ++++- lib/settings.dart | 4 ++-- lib/views/globalsettingsview.dart | 29 ++++++++++++++++++++++++++++- 16 files changed, 88 insertions(+), 32 deletions(-) diff --git a/lib/l10n/intl_cy.arb b/lib/l10n/intl_cy.arb index c86e8d76..9141ef3f 100644 --- a/lib/l10n/intl_cy.arb +++ b/lib/l10n/intl_cy.arb @@ -1,7 +1,9 @@ { "@@locale": "cy", - "@@last_modified": "2022-04-13T02:54:41+02:00", - "settingAndroidPowerExemptionDescription": "Android by default applies an \"optimized\" power management profile to apps which can result in them being stopped or killed. Request Android to exempt Cwtch from this for better stability but more power use.", + "@@last_modified": "2022-04-13T22:56:39+02:00", + "okButton": "OK", + "settingsAndroidPowerReenablePopup": "Cannot re-enable Battery Optimization from within Cwtch. Please go to Android \/ Settings \/ Apps \/ Cwtch \/ Battery and set Usage to 'Optimized'", + "settingAndroidPowerExemptionDescription": "Optional: Request Android to exempt Cwtch from optimized power management. This will result in better stability at the cost of greater battery use.", "settingAndroidPowerExemption": "Android Ignore Battery Optimizations", "thisFeatureRequiresGroupExpermientsToBeEnabled": "This feature requires the Groups Experiment to be enabled in Settings", "messageFormattingDescription": "Enable rich text formatting in displayed messages e.g. **bold** and *italic*", diff --git a/lib/l10n/intl_da.arb b/lib/l10n/intl_da.arb index 6036f30a..9233afea 100644 --- a/lib/l10n/intl_da.arb +++ b/lib/l10n/intl_da.arb @@ -1,7 +1,9 @@ { "@@locale": "da", - "@@last_modified": "2022-04-13T02:54:41+02:00", - "settingAndroidPowerExemptionDescription": "Android by default applies an \"optimized\" power management profile to apps which can result in them being stopped or killed. Request Android to exempt Cwtch from this for better stability but more power use.", + "@@last_modified": "2022-04-13T22:56:39+02:00", + "okButton": "OK", + "settingsAndroidPowerReenablePopup": "Cannot re-enable Battery Optimization from within Cwtch. Please go to Android \/ Settings \/ Apps \/ Cwtch \/ Battery and set Usage to 'Optimized'", + "settingAndroidPowerExemptionDescription": "Optional: Request Android to exempt Cwtch from optimized power management. This will result in better stability at the cost of greater battery use.", "settingAndroidPowerExemption": "Android Ignore Battery Optimizations", "thisFeatureRequiresGroupExpermientsToBeEnabled": "This feature requires the Groups Experiment to be enabled in Settings", "messageFormattingDescription": "Enable rich text formatting in displayed messages e.g. **bold** and *italic*", diff --git a/lib/l10n/intl_de.arb b/lib/l10n/intl_de.arb index 25789c91..f8e57bde 100644 --- a/lib/l10n/intl_de.arb +++ b/lib/l10n/intl_de.arb @@ -1,7 +1,9 @@ { "@@locale": "de", - "@@last_modified": "2022-04-13T02:54:41+02:00", - "settingAndroidPowerExemptionDescription": "Android by default applies an \"optimized\" power management profile to apps which can result in them being stopped or killed. Request Android to exempt Cwtch from this for better stability but more power use.", + "@@last_modified": "2022-04-13T22:56:39+02:00", + "okButton": "OK", + "settingsAndroidPowerReenablePopup": "Cannot re-enable Battery Optimization from within Cwtch. Please go to Android \/ Settings \/ Apps \/ Cwtch \/ Battery and set Usage to 'Optimized'", + "settingAndroidPowerExemptionDescription": "Optional: Request Android to exempt Cwtch from optimized power management. This will result in better stability at the cost of greater battery use.", "settingAndroidPowerExemption": "Android Ignore Battery Optimizations", "thisFeatureRequiresGroupExpermientsToBeEnabled": "This feature requires the Groups Experiment to be enabled in Settings", "messageFormattingDescription": "Enable rich text formatting in displayed messages e.g. **bold** and *italic*", diff --git a/lib/l10n/intl_el.arb b/lib/l10n/intl_el.arb index 99cf5bc4..76e27a32 100644 --- a/lib/l10n/intl_el.arb +++ b/lib/l10n/intl_el.arb @@ -1,7 +1,9 @@ { "@@locale": "el", - "@@last_modified": "2022-04-13T02:54:41+02:00", - "settingAndroidPowerExemptionDescription": "Android by default applies an \"optimized\" power management profile to apps which can result in them being stopped or killed. Request Android to exempt Cwtch from this for better stability but more power use.", + "@@last_modified": "2022-04-13T22:56:39+02:00", + "okButton": "OK", + "settingsAndroidPowerReenablePopup": "Cannot re-enable Battery Optimization from within Cwtch. Please go to Android \/ Settings \/ Apps \/ Cwtch \/ Battery and set Usage to 'Optimized'", + "settingAndroidPowerExemptionDescription": "Optional: Request Android to exempt Cwtch from optimized power management. This will result in better stability at the cost of greater battery use.", "settingAndroidPowerExemption": "Android Ignore Battery Optimizations", "thisFeatureRequiresGroupExpermientsToBeEnabled": "This feature requires the Groups Experiment to be enabled in Settings", "messageFormattingDescription": "Enable rich text formatting in displayed messages e.g. **bold** and *italic*", diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 0693616b..f851335a 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -1,7 +1,9 @@ { "@@locale": "en", - "@@last_modified": "2022-04-13T02:54:41+02:00", - "settingAndroidPowerExemptionDescription": "Android by default applies an \"optimized\" power management profile to apps which can result in them being stopped or killed. Request Android to exempt Cwtch from this for better stability but more power use.", + "@@last_modified": "2022-04-13T22:56:39+02:00", + "okButton": "OK", + "settingsAndroidPowerReenablePopup": "Cannot re-enable Battery Optimization from within Cwtch. Please go to Android \/ Settings \/ Apps \/ Cwtch \/ Battery and set Usage to 'Optimized'", + "settingAndroidPowerExemptionDescription": "Optional: Request Android to exempt Cwtch from optimized power management. This will result in better stability at the cost of greater battery use.", "settingAndroidPowerExemption": "Android Ignore Battery Optimizations", "thisFeatureRequiresGroupExpermientsToBeEnabled": "This feature requires the Groups Experiment to be enabled in Settings", "messageFormattingDescription": "Enable rich text formatting in displayed messages e.g. **bold** and *italic*", diff --git a/lib/l10n/intl_es.arb b/lib/l10n/intl_es.arb index 8e37b1d3..d2265f57 100644 --- a/lib/l10n/intl_es.arb +++ b/lib/l10n/intl_es.arb @@ -1,7 +1,9 @@ { "@@locale": "es", - "@@last_modified": "2022-04-13T02:54:41+02:00", - "settingAndroidPowerExemptionDescription": "Android by default applies an \"optimized\" power management profile to apps which can result in them being stopped or killed. Request Android to exempt Cwtch from this for better stability but more power use.", + "@@last_modified": "2022-04-13T22:56:39+02:00", + "okButton": "OK", + "settingsAndroidPowerReenablePopup": "Cannot re-enable Battery Optimization from within Cwtch. Please go to Android \/ Settings \/ Apps \/ Cwtch \/ Battery and set Usage to 'Optimized'", + "settingAndroidPowerExemptionDescription": "Optional: Request Android to exempt Cwtch from optimized power management. This will result in better stability at the cost of greater battery use.", "settingAndroidPowerExemption": "Android Ignore Battery Optimizations", "thisFeatureRequiresGroupExpermientsToBeEnabled": "This feature requires the Groups Experiment to be enabled in Settings", "messageFormattingDescription": "Enable rich text formatting in displayed messages e.g. **bold** and *italic*", diff --git a/lib/l10n/intl_fr.arb b/lib/l10n/intl_fr.arb index b98cadee..53279427 100644 --- a/lib/l10n/intl_fr.arb +++ b/lib/l10n/intl_fr.arb @@ -1,9 +1,11 @@ { "@@locale": "fr", - "@@last_modified": "2022-04-13T02:54:41+02:00", - "settingAndroidPowerExemptionDescription": "Android by default applies an \"optimized\" power management profile to apps which can result in them being stopped or killed. Request Android to exempt Cwtch from this for better stability but more power use.", - "settingAndroidPowerExemption": "Android Ignore Battery Optimizations", - "thisFeatureRequiresGroupExpermientsToBeEnabled": "This feature requires the Groups Experiment to be enabled in Settings", + "@@last_modified": "2022-04-13T22:56:39+02:00", + "okButton": "OK", + "settingsAndroidPowerReenablePopup": "Cannot re-enable Battery Optimization from within Cwtch. Please go to Android \/ Settings \/ Apps \/ Cwtch \/ Battery and set Usage to 'Optimized'", + "thisFeatureRequiresGroupExpermientsToBeEnabled": "Cette fonctionnalité nécessite que l’expérience Groupes soit activée dans Paramètres", + "settingAndroidPowerExemptionDescription": "Android applique par défaut un profil de gestion de l'énergie \"optimisé\" aux applications, ce qui peut entraîner leur arrêt ou leur suppression. Demandez à Android d'exempter Cwtch de ce profil pour une meilleure stabilité mais une plus grande consommation d'énergie.", + "settingAndroidPowerExemption": "Android ignore les optimisations de la batterie", "messageFormattingDescription": "Activer la mise en forme de texte enrichi dans les messages affichés, par exemple **gras** et *italique*", "formattingExperiment": "Mise en forme des messages", "clickableLinksWarning": "L'ouverture de cette URL lancera une application en dehors de Cwtch et peut révéler des métadonnées ou compromettre la sécurité de Cwtch. N'ouvrez que les URLs de personnes en qui vous avez confiance. Êtes-vous sûr de vouloir continuer ?", diff --git a/lib/l10n/intl_it.arb b/lib/l10n/intl_it.arb index 1bce64ea..de4e527e 100644 --- a/lib/l10n/intl_it.arb +++ b/lib/l10n/intl_it.arb @@ -1,7 +1,9 @@ { "@@locale": "it", - "@@last_modified": "2022-04-13T02:54:41+02:00", - "settingAndroidPowerExemptionDescription": "Android by default applies an \"optimized\" power management profile to apps which can result in them being stopped or killed. Request Android to exempt Cwtch from this for better stability but more power use.", + "@@last_modified": "2022-04-13T22:56:39+02:00", + "okButton": "OK", + "settingsAndroidPowerReenablePopup": "Cannot re-enable Battery Optimization from within Cwtch. Please go to Android \/ Settings \/ Apps \/ Cwtch \/ Battery and set Usage to 'Optimized'", + "settingAndroidPowerExemptionDescription": "Optional: Request Android to exempt Cwtch from optimized power management. This will result in better stability at the cost of greater battery use.", "settingAndroidPowerExemption": "Android Ignore Battery Optimizations", "thisFeatureRequiresGroupExpermientsToBeEnabled": "This feature requires the Groups Experiment to be enabled in Settings", "messageFormattingDescription": "Enable rich text formatting in displayed messages e.g. **bold** and *italic*", diff --git a/lib/l10n/intl_lb.arb b/lib/l10n/intl_lb.arb index 50ca5fe4..d6ea7a72 100644 --- a/lib/l10n/intl_lb.arb +++ b/lib/l10n/intl_lb.arb @@ -1,7 +1,9 @@ { "@@locale": "lb", - "@@last_modified": "2022-04-13T02:54:41+02:00", - "settingAndroidPowerExemptionDescription": "Android by default applies an \"optimized\" power management profile to apps which can result in them being stopped or killed. Request Android to exempt Cwtch from this for better stability but more power use.", + "@@last_modified": "2022-04-13T22:56:39+02:00", + "okButton": "OK", + "settingsAndroidPowerReenablePopup": "Cannot re-enable Battery Optimization from within Cwtch. Please go to Android \/ Settings \/ Apps \/ Cwtch \/ Battery and set Usage to 'Optimized'", + "settingAndroidPowerExemptionDescription": "Optional: Request Android to exempt Cwtch from optimized power management. This will result in better stability at the cost of greater battery use.", "settingAndroidPowerExemption": "Android Ignore Battery Optimizations", "thisFeatureRequiresGroupExpermientsToBeEnabled": "This feature requires the Groups Experiment to be enabled in Settings", "messageFormattingDescription": "Enable rich text formatting in displayed messages e.g. **bold** and *italic*", diff --git a/lib/l10n/intl_no.arb b/lib/l10n/intl_no.arb index 20614bb1..5c3afe11 100644 --- a/lib/l10n/intl_no.arb +++ b/lib/l10n/intl_no.arb @@ -1,7 +1,9 @@ { "@@locale": "no", - "@@last_modified": "2022-04-13T02:54:41+02:00", - "settingAndroidPowerExemptionDescription": "Android by default applies an \"optimized\" power management profile to apps which can result in them being stopped or killed. Request Android to exempt Cwtch from this for better stability but more power use.", + "@@last_modified": "2022-04-13T22:56:39+02:00", + "okButton": "OK", + "settingsAndroidPowerReenablePopup": "Cannot re-enable Battery Optimization from within Cwtch. Please go to Android \/ Settings \/ Apps \/ Cwtch \/ Battery and set Usage to 'Optimized'", + "settingAndroidPowerExemptionDescription": "Optional: Request Android to exempt Cwtch from optimized power management. This will result in better stability at the cost of greater battery use.", "settingAndroidPowerExemption": "Android Ignore Battery Optimizations", "thisFeatureRequiresGroupExpermientsToBeEnabled": "This feature requires the Groups Experiment to be enabled in Settings", "messageFormattingDescription": "Enable rich text formatting in displayed messages e.g. **bold** and *italic*", diff --git a/lib/l10n/intl_pl.arb b/lib/l10n/intl_pl.arb index 9122f2e4..0c7dc602 100644 --- a/lib/l10n/intl_pl.arb +++ b/lib/l10n/intl_pl.arb @@ -1,7 +1,9 @@ { "@@locale": "pl", - "@@last_modified": "2022-04-13T02:54:41+02:00", - "settingAndroidPowerExemptionDescription": "Android by default applies an \"optimized\" power management profile to apps which can result in them being stopped or killed. Request Android to exempt Cwtch from this for better stability but more power use.", + "@@last_modified": "2022-04-13T22:56:39+02:00", + "okButton": "OK", + "settingsAndroidPowerReenablePopup": "Cannot re-enable Battery Optimization from within Cwtch. Please go to Android \/ Settings \/ Apps \/ Cwtch \/ Battery and set Usage to 'Optimized'", + "settingAndroidPowerExemptionDescription": "Optional: Request Android to exempt Cwtch from optimized power management. This will result in better stability at the cost of greater battery use.", "settingAndroidPowerExemption": "Android Ignore Battery Optimizations", "thisFeatureRequiresGroupExpermientsToBeEnabled": "This feature requires the Groups Experiment to be enabled in Settings", "messageFormattingDescription": "Enable rich text formatting in displayed messages e.g. **bold** and *italic*", diff --git a/lib/l10n/intl_pt.arb b/lib/l10n/intl_pt.arb index a03c616b..2fa865c7 100644 --- a/lib/l10n/intl_pt.arb +++ b/lib/l10n/intl_pt.arb @@ -1,7 +1,9 @@ { "@@locale": "pt", - "@@last_modified": "2022-04-13T02:54:41+02:00", - "settingAndroidPowerExemptionDescription": "Android by default applies an \"optimized\" power management profile to apps which can result in them being stopped or killed. Request Android to exempt Cwtch from this for better stability but more power use.", + "@@last_modified": "2022-04-13T22:56:39+02:00", + "okButton": "OK", + "settingsAndroidPowerReenablePopup": "Cannot re-enable Battery Optimization from within Cwtch. Please go to Android \/ Settings \/ Apps \/ Cwtch \/ Battery and set Usage to 'Optimized'", + "settingAndroidPowerExemptionDescription": "Optional: Request Android to exempt Cwtch from optimized power management. This will result in better stability at the cost of greater battery use.", "settingAndroidPowerExemption": "Android Ignore Battery Optimizations", "thisFeatureRequiresGroupExpermientsToBeEnabled": "This feature requires the Groups Experiment to be enabled in Settings", "messageFormattingDescription": "Enable rich text formatting in displayed messages e.g. **bold** and *italic*", diff --git a/lib/l10n/intl_ro.arb b/lib/l10n/intl_ro.arb index 7a135e5d..5ec35e92 100644 --- a/lib/l10n/intl_ro.arb +++ b/lib/l10n/intl_ro.arb @@ -1,7 +1,9 @@ { "@@locale": "ro", - "@@last_modified": "2022-04-13T02:54:41+02:00", - "settingAndroidPowerExemptionDescription": "Android by default applies an \"optimized\" power management profile to apps which can result in them being stopped or killed. Request Android to exempt Cwtch from this for better stability but more power use.", + "@@last_modified": "2022-04-13T22:56:39+02:00", + "okButton": "OK", + "settingsAndroidPowerReenablePopup": "Cannot re-enable Battery Optimization from within Cwtch. Please go to Android \/ Settings \/ Apps \/ Cwtch \/ Battery and set Usage to 'Optimized'", + "settingAndroidPowerExemptionDescription": "Optional: Request Android to exempt Cwtch from optimized power management. This will result in better stability at the cost of greater battery use.", "settingAndroidPowerExemption": "Android Ignore Battery Optimizations", "thisFeatureRequiresGroupExpermientsToBeEnabled": "This feature requires the Groups Experiment to be enabled in Settings", "messageFormattingDescription": "Enable rich text formatting in displayed messages e.g. **bold** and *italic*", diff --git a/lib/l10n/intl_ru.arb b/lib/l10n/intl_ru.arb index bc7e8cd5..a877b4ce 100644 --- a/lib/l10n/intl_ru.arb +++ b/lib/l10n/intl_ru.arb @@ -1,6 +1,9 @@ { "@@locale": "ru", - "settingAndroidPowerExemptionDescription": "Android by default applies an \"optimized\" power management profile to apps which can result in them being stopped or killed. Request Android to exempt Cwtch from this for better stability but more power use.", + "@@last_modified": "2022-04-13T22:56:39+02:00", + "okButton": "OK", + "settingsAndroidPowerReenablePopup": "Cannot re-enable Battery Optimization from within Cwtch. Please go to Android \/ Settings \/ Apps \/ Cwtch \/ Battery and set Usage to 'Optimized'", + "settingAndroidPowerExemptionDescription": "Optional: Request Android to exempt Cwtch from optimized power management. This will result in better stability at the cost of greater battery use.", "settingAndroidPowerExemption": "Android Ignore Battery Optimizations", "thisFeatureRequiresGroupExpermientsToBeEnabled": "This feature requires the Groups Experiment to be enabled in Settings", "messageFormattingDescription": "Enable rich text formatting in displayed messages e.g. **bold** and *italic*", diff --git a/lib/settings.dart b/lib/settings.dart index 749a9649..4ca0d341 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -109,8 +109,8 @@ class Settings extends ChangeNotifier { // single pane vs dual pane preferences _uiColumnModePortrait = uiColumnModeFromString(settings["UIColumnModePortrait"]); _uiColumnModeLandscape = uiColumnModeFromString(settings["UIColumnModeLandscape"]); - _notificationPolicy = notificationPolicyFromString(settings["NotificationPolicy"]); + _notificationContent = notificationContentFromString(settings["NotificationContent"]); // auto-download folder @@ -275,7 +275,7 @@ class Settings extends ChangeNotifier { static NotificationPolicy notificationPolicyFromString(String? np) { switch (np) { - case "NotificationPolicy.None": + case "NotificationPolicy.Mute": return NotificationPolicy.Mute; case "NotificationPolicy.OptIn": return NotificationPolicy.OptIn; diff --git a/lib/views/globalsettingsview.dart b/lib/views/globalsettingsview.dart index 964db812..75ad7187 100644 --- a/lib/views/globalsettingsview.dart +++ b/lib/views/globalsettingsview.dart @@ -227,7 +227,8 @@ class _GlobalSettingsViewState extends State { if (value) { requestBatteryExemption(); } else { - // We don't ask for it to be turned off, user has to manually in android settings, so this is a NOP + // We can't ask for it to be turned off, show an informational popup + showBatteryDialog(context); } }, activeTrackColor: settings.theme.defaultButtonColor, @@ -467,6 +468,32 @@ class _GlobalSettingsViewState extends State { }); }); } + + showBatteryDialog(BuildContext context) { + Widget okButton = ElevatedButton( + child: Text(AppLocalizations.of(context)!.okButton), + onPressed: () { + Navigator.of(context).pop(); + }, + ); + + + // set up the AlertDialog + AlertDialog alert = AlertDialog( + title: Text(AppLocalizations.of(context)!.settingsAndroidPowerReenablePopup), + actions: [ + okButton, + ], + ); + + // show the dialog + showDialog( + context: context, + builder: (BuildContext context) { + return alert; + }, + ); + } } /// Construct a version string from Package Info