diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-02-18 20:38:55 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-02-18 20:38:55 +0100 |
commit | 757bbed1da3e0ab8a5fa2dc32d8f82b7ba9993dc (patch) | |
tree | 11527680efb368adac68ed278cec869b6f3fc3c2 /src/main/java/de/pixart/messenger/utils | |
parent | 6eef46c4f61dd7eb8843f8dc4e49baa6d393bfc7 (diff) |
show notification when backup is done or failed
show success notification only if backup was started manually
Diffstat (limited to 'src/main/java/de/pixart/messenger/utils')
-rw-r--r-- | src/main/java/de/pixart/messenger/utils/Compatibility.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/Compatibility.java b/src/main/java/de/pixart/messenger/utils/Compatibility.java index c8922e18b..728c6298a 100644 --- a/src/main/java/de/pixart/messenger/utils/Compatibility.java +++ b/src/main/java/de/pixart/messenger/utils/Compatibility.java @@ -42,6 +42,10 @@ public class Compatibility { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O; } + public static boolean runsTwentyFour() { + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N; + } + public static boolean twentyEight() { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.P; } @@ -66,10 +70,24 @@ public class Compatibility { } } + private static boolean targetsTwentyFour(Context context) { + try { + final PackageManager packageManager = context.getPackageManager(); + final ApplicationInfo applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0); + return applicationInfo == null || applicationInfo.targetSdkVersion >= 24; + } catch (PackageManager.NameNotFoundException | RuntimeException e) { + return true; //when in doubt… + } + } + public static boolean runsAndTargetsTwentySix(Context context) { return runsTwentySix() && targetsTwentySix(context); } + public static boolean runsAndTargetsTwentyFour(Context context) { + return runsTwentyFour() && targetsTwentyFour(context); + } + public static boolean keepForegroundService(Context context) { return runsTwentySix() || getBooleanPreference(context, SettingsActivity.SHOW_FOREGROUND_SERVICE, R.bool.show_foreground_service); } |