diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationActivity.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java index c859264a9..002162041 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java @@ -1709,14 +1709,19 @@ public class ConversationActivity extends XmppActivity return connection == null ? -1 : connection.getFeatures().getMaxHttpUploadSize(); } + private String getBatteryOptimizationPreferenceKey() { + @SuppressLint("HardwareIds") String device = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID); + return "show_battery_optimization" + (device == null ? "" : device); + } + private void setNeverAskForBatteryOptimizationsAgain() { - getPreferences().edit().putBoolean("show_battery_optimization", false).apply(); + getPreferences().edit().putBoolean(getBatteryOptimizationPreferenceKey(), false).apply(); } private void openBatteryOptimizationDialogIfNeeded() { if (hasAccountWithoutPush() && isOptimizingBattery() - && getPreferences().getBoolean("show_battery_optimization", true)) { + && getPreferences().getBoolean(getBatteryOptimizationPreferenceKey(), true)) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.battery_optimizations_enabled); builder.setMessage(R.string.battery_optimizations_enabled_dialog); @@ -1747,7 +1752,7 @@ public class ConversationActivity extends XmppActivity private boolean hasAccountWithoutPush() { for (Account account : xmppConnectionService.getAccounts()) { - if (account.getStatus() != Account.State.DISABLED && !xmppConnectionService.getPushManagementService().available(account)) { + if (account.getStatus() == Account.State.ONLINE && !xmppConnectionService.getPushManagementService().available(account)) { return true; } } |