mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-23 04:41:16 +00:00
Don't show battery optimization dialog more than once
This commit is contained in:
parent
a3c30f4ac6
commit
d9c2442a14
1 changed files with 4 additions and 2 deletions
|
@ -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) -> {
|
||||
|
|
Loading…
Reference in a new issue