diff --git a/app/build.gradle b/app/build.gradle index d105609a..34700ef1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -17,14 +17,15 @@ android { minSdkVersion 14 targetSdkVersion 24 - versionCode 110 + versionCode 111 buildConfigField "long", "buildTime", System.currentTimeMillis() + "L" + buildConfigField "boolean", "useMTM", "true" } productFlavors { standard { - versionName "1.2.1-ose" + versionName "1.2.2-ose" } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f66723cc..215c06ed 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,6 +19,7 @@ + = Build.VERSION_CODES.M && settings.getBoolean(HINT_BATTERY_OPTIMIZATIONS, true)) { + PowerManager powerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); + if (!powerManager.isIgnoringBatteryOptimizations(BuildConfig.APPLICATION_ID)) + dialogs.add(StartupDialogFragment.instantiate(Mode.BATTERY_OPTIMIZATIONS)); + } + // OpenTasks information - if (!LocalTaskList.tasksProviderAvailable(context) && - settings.getBoolean(HINT_OPENTASKS_NOT_INSTALLED, true)) + if (!LocalTaskList.tasksProviderAvailable(context) && settings.getBoolean(HINT_OPENTASKS_NOT_INSTALLED, true)) dialogs.add(StartupDialogFragment.instantiate(Mode.OPENTASKS_NOT_INSTALLED)); Collections.reverse(dialogs); @@ -84,6 +95,32 @@ public class StartupDialogFragment extends DialogFragment { Mode mode = Mode.valueOf(getArguments().getString(ARGS_MODE)); switch (mode) { + case BATTERY_OPTIMIZATIONS: + return new AlertDialog.Builder(getActivity()) + .setTitle(R.string.startup_battery_optimization) + .setMessage(R.string.startup_battery_optimization_message) + .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + } + }) + .setNeutralButton(R.string.startup_battery_optimization_disable, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + Intent intent = new Intent(android.provider.Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, + Uri.parse("package:" + BuildConfig.APPLICATION_ID)); + getContext().startActivity(intent); + } + }) + .setNegativeButton(R.string.startup_dont_show_again, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + Settings settings = new Settings(dbHelper.getWritableDatabase()); + settings.putBoolean(HINT_BATTERY_OPTIMIZATIONS, false); + } + }) + .create(); + case DEVELOPMENT_VERSION: return new AlertDialog.Builder(getActivity()) .setIcon(R.drawable.ic_launcher) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 66ec3af0..dcffa1fa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -17,6 +17,9 @@ Send + Battery Optimization + Android may disable/reduce DAVdroid synchronization after a few days. To prevent this, turn off battery optimization. + Turn off for DAVdroid Don\'t show again DAVdroid Preview Release This is a development version of DAVdroid. Be aware that things may not work as expected. Please give us constructive feedback to improve DAVdroid.