mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 17:59:39 +02:00
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.
This commit is contained in:
parent
742ce78c9c
commit
14dc59d78c
2 changed files with 13 additions and 4 deletions
|
@ -718,6 +718,7 @@
|
|||
<!-- android specific strings, developers: please take care to remove strings that are no longer used! -->
|
||||
<string name="pref_background_notifications">Background notifications</string>
|
||||
<string name="pref_background_notifications_explain">Uses a background connection to your server and requires ignored battery optimizations.</string>
|
||||
<string name="pref_background_notifications_ask">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.</string>
|
||||
<!-- disabling "Reliable service" will hide a the maybe annoying permanent-notification with the drawback that new-message-notifications get potentially unreliable -->
|
||||
<string name="pref_reliable_service">Reliable background connection</string>
|
||||
<string name="pref_reliable_service_explain">Requires a permanent notification</string>
|
||||
|
|
|
@ -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())) {
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue