Skip to content

Commit

Permalink
fixed an error with notifications in Android 9
Browse files Browse the repository at this point in the history
  • Loading branch information
fandreuz committed Feb 8, 2019
1 parent aca95b9 commit 2117fe0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
8 changes: 3 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ android {
targetSdkVersion 26
flavorDimensions "default"

versionName "v6.10"

manifestPlaceholders = [playstore:"false"]
versionName "v6.11"
}

buildTypes {
Expand All @@ -28,10 +26,10 @@ android {
// odd is fdroid, otherwise playstore
// !!!!!!!!!!!!!
fdroid {
versionCode 198
versionCode 200
}
playstore {
versionCode 195
versionCode 197
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,12 @@ private int lastNull() {
@Override
public boolean onUnbind(Intent intent) {
lastCommands = null;

return true;
}

public static Notification buildNotification(Context c, String title, String subtitle, String cmdLabel, String clickCmd, boolean showHome, CharSequence[] lastCommands, boolean upDown, int priority) {
if(priority < -2 || priority > 2) priority = NotificationCompat.PRIORITY_DEFAULT;

PendingIntent pendingIntent;
if(showHome) {
Intent startMain = new Intent(Intent.ACTION_MAIN);
Expand Down Expand Up @@ -172,7 +173,10 @@ public static Notification buildNotification(Context c, String title, String sub

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationChannel notificationChannel = new NotificationChannel(BuildConfig.APPLICATION_ID, c.getString(R.string.app_name), priority);
int oPriority = Tuils.scale(new int[] {0, 4}, new int[] {2,4}, priority + 2);
if(oPriority < 2 || oPriority > 4) oPriority = NotificationManager.IMPORTANCE_UNSPECIFIED;

NotificationChannel notificationChannel = new NotificationChannel(BuildConfig.APPLICATION_ID, c.getString(R.string.app_name), oPriority);
((NotificationManager) c.getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(notificationChannel);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ public String defaultValue() {

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

@Override
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/ohi/andre/consolelauncher/tuils/Tuils.java
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,10 @@ public static List<String> getClassesInPackage(String packageName, Context c) th
return classes;
}

public static int scale(int[] from, int[] to, int n) {
return (to[1] - to[0])*(n - from[0])/(from[1] - from[0]) + to[0];
}

public static String[] toString(Enum[] enums) {
String[] arr = new String[enums.length];
for(int count = 0; count < enums.length; count++) arr[count] = enums[count].name();
Expand Down

0 comments on commit 2117fe0

Please sign in to comment.