diff --git a/res/values/strings.xml b/res/values/strings.xml index 9372738dc..c31b0c665 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. + 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 1905d6156..2925f9bdf 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; @@ -65,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); @@ -110,10 +111,16 @@ 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_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); + }) + .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