1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 11:21:29 +00:00

Don't show battery optimization dialog more than once

This commit is contained in:
Felix Ableitner 2016-11-10 23:46:40 +09:00
parent a3c30f4ac6
commit d9c2442a14

View file

@ -67,6 +67,7 @@ public class MainActivity extends SyncthingActivity
private static final long USAGE_REPORTING_DIALOG_DELAY = TimeUnit.DAYS.toMillis(3);
private AlertDialog mDisabledDialog;
private AlertDialog mBatteryOptimizationsDialog;
private ViewPager mViewPager;
@ -112,12 +113,13 @@ public class MainActivity extends SyncthingActivity
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
boolean dontShowAgain = sp.getBoolean("battery_optimization_dont_show_again", false);
if (dontShowAgain || Build.VERSION.SDK_INT < Build.VERSION_CODES.M ||
if (dontShowAgain || mBatteryOptimizationsDialog != null ||
Build.VERSION.SDK_INT < Build.VERSION_CODES.M ||
pm.isIgnoringBatteryOptimizations(getPackageName())) {
return;
}
new AlertDialog.Builder(this)
mBatteryOptimizationsDialog = new AlertDialog.Builder(this)
.setTitle(R.string.dialog_disable_battery_optimization_title)
.setMessage(R.string.dialog_disable_battery_optimization_message)
.setPositiveButton(R.string.dialog_disable_battery_optimization_turn_off, (d, i) -> {