move pref-string 'DOZE_ASKED_DIRECTLY' to the other pref-strings

This commit is contained in:
B. Petersen 2020-09-06 16:07:42 +02:00
parent 954ca9b2d1
commit 94cda3f81f
No known key found for this signature in database
GPG key ID: 3B88E92DEA8E9AFC
2 changed files with 6 additions and 6 deletions

View file

@ -24,8 +24,6 @@ import org.thoughtcrime.securesms.util.Prefs;
@SuppressLint("BatteryLife") @SuppressLint("BatteryLife")
public class DozeReminder { public class DozeReminder {
private static final String ALREADY_ASKED_DIRECTLY = "DOZE_ALREADY_ASKED_DIRECTLY";
public static boolean isEligible(Context context) { public static boolean isEligible(Context context) {
if(context==null) { if(context==null) {
return false; return false;
@ -40,7 +38,7 @@ public class DozeReminder {
} }
// If we did never ask directly, we do not want to add a device message yet. First we want to try to ask directly. // If we did never ask directly, we do not want to add a device message yet. First we want to try to ask directly.
if (!Prefs.getBooleanPreference(context, DozeReminder.ALREADY_ASKED_DIRECTLY, false)) { if (!Prefs.getBooleanPreference(context, Prefs.DOZE_ASKED_DIRECTLY, false)) {
return false; return false;
} }
@ -108,7 +106,7 @@ public class DozeReminder {
public static void maybeAskDirectly(Context context) { public static void maybeAskDirectly(Context context) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M
&& !Prefs.getBooleanPreference(context, DozeReminder.ALREADY_ASKED_DIRECTLY, false) && !Prefs.getBooleanPreference(context, Prefs.DOZE_ASKED_DIRECTLY, false)
&& ContextCompat.checkSelfPermission(context, Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)==PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission(context, Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)==PackageManager.PERMISSION_GRANTED
&& !((PowerManager)context.getSystemService(Context.POWER_SERVICE)).isIgnoringBatteryOptimizations(context.getPackageName())) { && !((PowerManager)context.getSystemService(Context.POWER_SERVICE)).isIgnoringBatteryOptimizations(context.getPackageName())) {
@ -116,8 +114,9 @@ public class DozeReminder {
Uri.parse("package:" + context.getPackageName())); Uri.parse("package:" + context.getPackageName()));
context.startActivity(intent); context.startActivity(intent);
} }
Prefs.setBooleanPreference(context, DozeReminder.ALREADY_ASKED_DIRECTLY, true); Prefs.setBooleanPreference(context, Prefs.DOZE_ASKED_DIRECTLY, true);
// ALREADY_ASKED_DIRECTLY is also used above in isEligible(). As long as ALREADY_ASKED_DIRECTLY is false, isEligible() will return false // Prefs.DOZE_ASKED_DIRECTLY is also used above in isEligible().
// As long as Prefs.DOZE_ASKED_DIRECTLY is false, isEligible() will return false
// and no device message will be added. // and no device message will be added.
} }
} }

View file

@ -49,6 +49,7 @@ public class Prefs {
public static final String SCREEN_SECURITY_PREF = "pref_screen_security"; public static final String SCREEN_SECURITY_PREF = "pref_screen_security";
private static final String ENTER_SENDS_PREF = "pref_enter_sends"; private static final String ENTER_SENDS_PREF = "pref_enter_sends";
private static final String PROMPTED_DOZE_MSG_ID_PREF = "pref_prompted_doze_msg_id"; private static final String PROMPTED_DOZE_MSG_ID_PREF = "pref_prompted_doze_msg_id";
public static final String DOZE_ASKED_DIRECTLY = "pref_doze_asked_directly";
private static final String IN_THREAD_NOTIFICATION_PREF = "pref_key_inthread_notifications"; private static final String IN_THREAD_NOTIFICATION_PREF = "pref_key_inthread_notifications";
public static final String MESSAGE_BODY_TEXT_SIZE_PREF = "pref_message_body_text_size"; public static final String MESSAGE_BODY_TEXT_SIZE_PREF = "pref_message_body_text_size";
public static final String EPHEMERAL_MESSAGES_PREF = "pref_ephemeral_messages"; public static final String EPHEMERAL_MESSAGES_PREF = "pref_ephemeral_messages";