Skip to content

Commit 2117fe0

Browse files
committed
fixed an error with notifications in Android 9
1 parent aca95b9 commit 2117fe0

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

app/build.gradle

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ android {
88
targetSdkVersion 26
99
flavorDimensions "default"
1010

11-
versionName "v6.10"
12-
13-
manifestPlaceholders = [playstore:"false"]
11+
versionName "v6.11"
1412
}
1513

1614
buildTypes {
@@ -28,10 +26,10 @@ android {
2826
// odd is fdroid, otherwise playstore
2927
// !!!!!!!!!!!!!
3028
fdroid {
31-
versionCode 198
29+
versionCode 200
3230
}
3331
playstore {
34-
versionCode 195
32+
versionCode 197
3533
}
3634
}
3735

app/src/main/java/ohi/andre/consolelauncher/managers/notifications/KeeperService.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,12 @@ private int lastNull() {
135135
@Override
136136
public boolean onUnbind(Intent intent) {
137137
lastCommands = null;
138-
139138
return true;
140139
}
141140

142141
public static Notification buildNotification(Context c, String title, String subtitle, String cmdLabel, String clickCmd, boolean showHome, CharSequence[] lastCommands, boolean upDown, int priority) {
142+
if(priority < -2 || priority > 2) priority = NotificationCompat.PRIORITY_DEFAULT;
143+
143144
PendingIntent pendingIntent;
144145
if(showHome) {
145146
Intent startMain = new Intent(Intent.ACTION_MAIN);
@@ -172,7 +173,10 @@ public static Notification buildNotification(Context c, String title, String sub
172173

173174
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
174175
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
175-
NotificationChannel notificationChannel = new NotificationChannel(BuildConfig.APPLICATION_ID, c.getString(R.string.app_name), priority);
176+
int oPriority = Tuils.scale(new int[] {0, 4}, new int[] {2,4}, priority + 2);
177+
if(oPriority < 2 || oPriority > 4) oPriority = NotificationManager.IMPORTANCE_UNSPECIFIED;
178+
179+
NotificationChannel notificationChannel = new NotificationChannel(BuildConfig.APPLICATION_ID, c.getString(R.string.app_name), oPriority);
176180
((NotificationManager) c.getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(notificationChannel);
177181
}
178182

app/src/main/java/ohi/andre/consolelauncher/managers/xml/options/Behavior.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ public String defaultValue() {
765765

766766
@Override
767767
public String info() {
768-
return "The priority of the T-UI notification (-2 maximum priority, 2 minimum)";
768+
return "The priority of the T-UI notification (min: -2, max: 2)";
769769
}
770770

771771
@Override

app/src/main/java/ohi/andre/consolelauncher/tuils/Tuils.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,10 @@ public static List<String> getClassesInPackage(String packageName, Context c) th
941941
return classes;
942942
}
943943

944+
public static int scale(int[] from, int[] to, int n) {
945+
return (to[1] - to[0])*(n - from[0])/(from[1] - from[0]) + to[0];
946+
}
947+
944948
public static String[] toString(Enum[] enums) {
945949
String[] arr = new String[enums.length];
946950
for(int count = 0; count < enums.length; count++) arr[count] = enums[count].name();

0 commit comments

Comments
 (0)