From 14dc59d78cb6edd7c7fefc96a12ce101f99a0db5 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sun, 6 Sep 2020 23:44:34 +0200 Subject: [PATCH 1/4] add rationale to ignore-battery-optimization request while it is more straight-forward to let the system ask the user directly - as we do for most other permissions - this is probably not favorable for requesting ignore-battery-optimization: - other permissions requests are preceded by a clear user intention - tap on the camera, record voice etc. so it is clear to the user why a permission is needed. this is not true at the moment after installation (maybe the moment can be improved, btw) - different systems have completely different text, partly focusing on "battery drain" - it is not clear to the user what would be the advantage of that - some guidelines say, user interaction is needed before querying permission. there is room for interpretation, of couse, however, adding a rational with a "continue" button seems to fit better to these guidelines. --- res/values/strings.xml | 1 + .../components/reminder/DozeReminder.java | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 9372738dc..779e97796 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -718,6 +718,7 @@ Background notifications Uses a background connection to your server and requires ignored battery optimizations. + Do you want to receive messages in the background?\n\nThis requires ignored battery optimizations, however, Delta Chat uses few resources and takes care not to drain your battery. Reliable background connection Requires a permanent notification diff --git a/src/org/thoughtcrime/securesms/components/reminder/DozeReminder.java b/src/org/thoughtcrime/securesms/components/reminder/DozeReminder.java index 1905d6156..1aa3b681b 100644 --- a/src/org/thoughtcrime/securesms/components/reminder/DozeReminder.java +++ b/src/org/thoughtcrime/securesms/components/reminder/DozeReminder.java @@ -10,6 +10,7 @@ import android.net.Uri; import android.os.Build; import android.os.PowerManager; import android.provider.Settings; +import android.widget.Toast; import androidx.appcompat.app.AlertDialog; import androidx.core.content.ContextCompat; @@ -110,10 +111,17 @@ public class DozeReminder { && !Prefs.getBooleanPreference(context, Prefs.DOZE_ASKED_DIRECTLY, false) && ContextCompat.checkSelfPermission(context, Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS) == PackageManager.PERMISSION_GRANTED && !((PowerManager) context.getSystemService(Context.POWER_SERVICE)).isIgnoringBatteryOptimizations(context.getPackageName())) { - - Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, - Uri.parse("package:" + context.getPackageName())); - context.startActivity(intent); + new AlertDialog.Builder(context) + .setTitle(R.string.pref_background_notifications) + .setMessage(R.string.pref_background_notifications_ask) + .setPositiveButton(R.string.perm_continue, (dialog, which) -> { + Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, + Uri.parse("package:" + context.getPackageName())); + context.startActivity(intent); + }) + .setNegativeButton(R.string.not_now, null) + .setCancelable(false) + .show(); } // Prefs.DOZE_ASKED_DIRECTLY is also used above in isEligible(). // As long as Prefs.DOZE_ASKED_DIRECTLY is false, isEligible() will return false From 34c217576e3815ccb2474d849e7e0e163359c1df Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Mon, 7 Sep 2020 13:56:37 +0200 Subject: [PATCH 2/4] reword rationale dialog, remove 'cancel' button --- res/values/strings.xml | 2 +- .../securesms/components/reminder/DozeReminder.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 779e97796..367c29b50 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -718,7 +718,7 @@ Background notifications Uses a background connection to your server and requires ignored battery optimizations. - Do you want to receive messages in the background?\n\nThis requires ignored battery optimizations, however, Delta Chat uses few resources and takes care not to drain your battery. + To maintain connection to your server and receive messages in the background, ignore battery optimizations in the next step.\n\nDelta Chat uses few resources and takes care not to drain your battery. Reliable background connection Requires a permanent notification diff --git a/src/org/thoughtcrime/securesms/components/reminder/DozeReminder.java b/src/org/thoughtcrime/securesms/components/reminder/DozeReminder.java index 1aa3b681b..06eac7445 100644 --- a/src/org/thoughtcrime/securesms/components/reminder/DozeReminder.java +++ b/src/org/thoughtcrime/securesms/components/reminder/DozeReminder.java @@ -114,12 +114,11 @@ public class DozeReminder { new AlertDialog.Builder(context) .setTitle(R.string.pref_background_notifications) .setMessage(R.string.pref_background_notifications_ask) - .setPositiveButton(R.string.perm_continue, (dialog, which) -> { + .setPositiveButton(R.string.ok, (dialog, which) -> { Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, Uri.parse("package:" + context.getPackageName())); context.startActivity(intent); }) - .setNegativeButton(R.string.not_now, null) .setCancelable(false) .show(); } From fa214e01636cee0a4c3a2a41093b0b3daf817b5d Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Mon, 7 Sep 2020 15:50:46 +0200 Subject: [PATCH 3/4] reword, use 'continue' instead of 'ok' --- res/values/strings.xml | 2 +- .../securesms/components/reminder/DozeReminder.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 367c29b50..c31b0c665 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -718,7 +718,7 @@ Background notifications Uses a background connection to your server and requires ignored battery optimizations. - To maintain connection to your server and receive messages in the background, ignore battery optimizations in the next step.\n\nDelta Chat uses few resources and takes care not to drain your battery. + To maintain connection to your email server and receive messages in the background, ignore battery optimizations in the next step.\n\nDelta Chat uses few resources and takes care not to drain your battery. Reliable background connection Requires a permanent notification diff --git a/src/org/thoughtcrime/securesms/components/reminder/DozeReminder.java b/src/org/thoughtcrime/securesms/components/reminder/DozeReminder.java index 06eac7445..30474e6e4 100644 --- a/src/org/thoughtcrime/securesms/components/reminder/DozeReminder.java +++ b/src/org/thoughtcrime/securesms/components/reminder/DozeReminder.java @@ -113,8 +113,8 @@ public class DozeReminder { && !((PowerManager) context.getSystemService(Context.POWER_SERVICE)).isIgnoringBatteryOptimizations(context.getPackageName())) { new AlertDialog.Builder(context) .setTitle(R.string.pref_background_notifications) - .setMessage(R.string.pref_background_notifications_ask) - .setPositiveButton(R.string.ok, (dialog, which) -> { + .setMessage(R.string.pref_background_notifications_rationale) + .setPositiveButton(R.string.perm_continue, (dialog, which) -> { Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, Uri.parse("package:" + context.getPackageName())); context.startActivity(intent); From 5ab682f2ab01a84bd687bfae682eccfd6dc9c6b8 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Tue, 8 Sep 2020 12:41:02 +0200 Subject: [PATCH 4/4] use same rationale in device message (the device message is only added when the direct-ask was cancelled) --- .../securesms/components/reminder/DozeReminder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/components/reminder/DozeReminder.java b/src/org/thoughtcrime/securesms/components/reminder/DozeReminder.java index 30474e6e4..2925f9bdf 100644 --- a/src/org/thoughtcrime/securesms/components/reminder/DozeReminder.java +++ b/src/org/thoughtcrime/securesms/components/reminder/DozeReminder.java @@ -66,8 +66,8 @@ public class DozeReminder { public static void addDozeReminderDeviceMsg(Context context) { DcContext dcContext = DcHelper.getContext(context); DcMsg msg = new DcMsg(dcContext, DcMsg.DC_MSG_TEXT); - msg.setText(context.getString(R.string.perm_enable_bg_reminder_title)+"\n\n" - +context.getString(R.string.perm_enable_bg_reminder_text)); + msg.setText("\uD83D\uDC49 "+context.getString(R.string.perm_enable_bg_reminder_title)+" \uD83D\uDC48\n\n" + +context.getString(R.string.pref_background_notifications_rationale)); int msgId = dcContext.addDeviceMsg("android.doze-reminder", msg); if(msgId!=0) { Prefs.setPromptedDozeMsgId(context, msgId);