Fix battery prompt #160

Merged
s416204 merged 1 commits from fix-battery-prompt into develop 2019-01-12 21:16:40 +01:00
4 changed files with 8 additions and 18 deletions

View File

@ -13,7 +13,6 @@
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<uses-feature android:name="android.hardware.location.gps" />

View File

@ -107,27 +107,18 @@ public class MapUtils {
}
public static void BatteryOptimizationsExceptionCheck(Context context) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!pm.isIgnoringBatteryOptimizations(context.getPackageName())) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.batter_exclusions_title);
builder.setMessage(R.string.batter_exclusions_message)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
intent.setData(Uri.parse("package:" + getApplicationContext().getPackageName()));
context.startActivity(intent);
}
.setPositiveButton(R.string.ok, (dialog, id) -> {
Intent intentBatteryUsage = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
context.startActivity(intentBatteryUsage);
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog
}
.setNegativeButton(R.string.cancel, (dialog, id) -> {
// User cancelled the dialog
}).show();
}
}
}
}

View File

@ -289,7 +289,7 @@
<string name="available_now">Dostępny teraz</string>
<string name="profile_activity_title">Profil użytkownika</string>
<string name="batter_exclusions_title">Uwaga</string>
<string name="batter_exclusions_message">Aby aplikacja była w pełni funkcjonalna, dodaj FMT do wyjątku w oszczędzaniu baterii</string>
<string name="batter_exclusions_message">Aby aplikacja była w pełni funkcjonalna, dodaj FMT do wyjątków w oszczędzaniu baterii. Po wciśnięciu przycisku "ok" zostaniesz przeniesiony do opcji zarządzania baterią. W panelu "optymalizacja użycia baterii" upewnij się, że opcja optymalizacji jest wyłączona.</string>
<string name="never_logged_in">Nigdy</string>

View File

@ -456,7 +456,7 @@
<string name="user_status_label" translatable="false">Status</string>
<string name="available_now">Available now</string>
<string name="last_sign">Last seen</string>
<string name="batter_exclusions_message">To make app fully functional, add FMT to battery saving exclusions</string>
<string name="batter_exclusions_message">To make app fully functional, add FMT to battery saving exclusions. You can change battery options in "Optimise battery usage". Unfortunately, you have to do it manually. Click "ok" to open battery settings and make sure that the application is not optimised.</string>
<string name="batter_exclusions_title">Please note</string>
<string name="never_logged_in">Never</string>
</resources>