From fd97ba2bb4948eb910e85331dff6542bfe63f1bb Mon Sep 17 00:00:00 2001 From: Jannis Mattheis Date: Fri, 9 Nov 2018 17:18:58 +0100 Subject: [PATCH 1/6] Move encrypting key to before deploy With PRs from forked repositories the release key can't be decrypted because the secured variables are hidden. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9c598a4..98d6c0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,13 +29,13 @@ android: before_install: - yes | sdkmanager "platforms;android-28" -- openssl aes-256-cbc -K $encrypted_f6e0f94759d3_key -iv $encrypted_f6e0f94759d3_iv - -in gotify-release-key.jks.enc -out gotify-release-key.jks -d script: - ./gradlew clean build --stacktrace before_deploy: +- openssl aes-256-cbc -K $encrypted_f6e0f94759d3_key -iv $encrypted_f6e0f94759d3_iv + -in gotify-release-key.jks.enc -out gotify-release-key.jks -d - cp $TRAVIS_BUILD_DIR/gotify-release-key.jks $HOME - cd app/build/outputs/apk/release - jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore $HOME/gotify-release-key.jks From 619662602004ef0b7bf289277da4d8a2b14b531e Mon Sep 17 00:00:00 2001 From: schwma <37244550+schwma@users.noreply.github.com> Date: Thu, 8 Nov 2018 14:23:21 +0100 Subject: [PATCH 2/6] Adjust notification channel importances --- .../main/java/com/github/gotify/NotificationSupport.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/gotify/NotificationSupport.java b/app/src/main/java/com/github/gotify/NotificationSupport.java index 47d709f..b497b11 100644 --- a/app/src/main/java/com/github/gotify/NotificationSupport.java +++ b/app/src/main/java/com/github/gotify/NotificationSupport.java @@ -24,16 +24,20 @@ public class NotificationSupport { @RequiresApi(Build.VERSION_CODES.O) public static void createChannels(NotificationManager notificationManager) { try { + // Low importance so that persistent notification can be sorted towards bottom of + // notification shade. Also prevents vibrations caused by persistent notification NotificationChannel foreground = new NotificationChannel( Channel.FOREGROUND, "Gotify foreground notification", - NotificationManager.IMPORTANCE_DEFAULT); + NotificationManager.IMPORTANCE_LOW); + // High importance for message notifications so that they are shown as heads-up + // notifications and sorted towards the top of the notification shade NotificationChannel messages = new NotificationChannel( Channel.MESSAGES, "Gotify messages", - NotificationManager.IMPORTANCE_DEFAULT); + NotificationManager.IMPORTANCE_HIGH); notificationManager.createNotificationChannel(foreground); notificationManager.createNotificationChannel(messages); } catch (Exception e) { From 9a1ffa91df1932a54cd0a8c4729c561e804bf50c Mon Sep 17 00:00:00 2001 From: schwma <37244550+schwma@users.noreply.github.com> Date: Thu, 8 Nov 2018 15:30:31 +0100 Subject: [PATCH 3/6] Add LED light for message notifications --- app/src/main/java/com/github/gotify/NotificationSupport.java | 3 +++ .../main/java/com/github/gotify/service/WebSocketService.java | 2 ++ 2 files changed, 5 insertions(+) diff --git a/app/src/main/java/com/github/gotify/NotificationSupport.java b/app/src/main/java/com/github/gotify/NotificationSupport.java index b497b11..9037cad 100644 --- a/app/src/main/java/com/github/gotify/NotificationSupport.java +++ b/app/src/main/java/com/github/gotify/NotificationSupport.java @@ -2,6 +2,7 @@ package com.github.gotify; import android.app.NotificationChannel; import android.app.NotificationManager; +import android.graphics.Color; import android.os.Build; import androidx.annotation.RequiresApi; import com.github.gotify.log.Log; @@ -38,6 +39,8 @@ public class NotificationSupport { Channel.MESSAGES, "Gotify messages", NotificationManager.IMPORTANCE_HIGH); + messages.enableLights(true); + messages.setLightColor(Color.CYAN); notificationManager.createNotificationChannel(foreground); notificationManager.createNotificationChannel(messages); } catch (Exception e) { diff --git a/app/src/main/java/com/github/gotify/service/WebSocketService.java b/app/src/main/java/com/github/gotify/service/WebSocketService.java index 8feb227..333e847 100644 --- a/app/src/main/java/com/github/gotify/service/WebSocketService.java +++ b/app/src/main/java/com/github/gotify/service/WebSocketService.java @@ -6,6 +6,7 @@ import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; +import android.graphics.Color; import android.os.Build; import android.os.IBinder; import androidx.annotation.Nullable; @@ -189,6 +190,7 @@ public class WebSocketService extends Service { .setContentText(message) .setStyle(new NotificationCompat.BigTextStyle().bigText(message)) .setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND) + .setLights(Color.CYAN, 1000, 5000) .setContentIntent(contentIntent); NotificationManager notificationManager = From 0c2620b79897d8ea8a0001fa70647b449018e2cf Mon Sep 17 00:00:00 2001 From: schwma <37244550+schwma@users.noreply.github.com> Date: Thu, 8 Nov 2018 15:36:48 +0100 Subject: [PATCH 4/6] Set message notification accent color to colorPrimary --- .../main/java/com/github/gotify/service/WebSocketService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/com/github/gotify/service/WebSocketService.java b/app/src/main/java/com/github/gotify/service/WebSocketService.java index 333e847..bd2888d 100644 --- a/app/src/main/java/com/github/gotify/service/WebSocketService.java +++ b/app/src/main/java/com/github/gotify/service/WebSocketService.java @@ -12,6 +12,7 @@ import android.os.IBinder; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.core.app.NotificationCompat; +import androidx.core.content.ContextCompat; import com.github.gotify.MissedMessageUtil; import com.github.gotify.NotificationSupport; import com.github.gotify.R; @@ -191,6 +192,7 @@ public class WebSocketService extends Service { .setStyle(new NotificationCompat.BigTextStyle().bigText(message)) .setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND) .setLights(Color.CYAN, 1000, 5000) + .setColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary)) .setContentIntent(contentIntent); NotificationManager notificationManager = @@ -216,6 +218,7 @@ public class WebSocketService extends Service { .setContentTitle(getString(R.string.grouped_notification_text)) .setGroupSummary(true) .setContentText(getString(R.string.grouped_notification_text)) + .setColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary)) .setContentIntent(contentIntent); NotificationManager notificationManager = From 3c8b50090681372f57c6a0f665ae84295ebaf24e Mon Sep 17 00:00:00 2001 From: schwma <37244550+schwma@users.noreply.github.com> Date: Thu, 8 Nov 2018 15:56:48 +0100 Subject: [PATCH 5/6] Prevent duplicate notification sounds from message group notification --- .../main/java/com/github/gotify/service/WebSocketService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/com/github/gotify/service/WebSocketService.java b/app/src/main/java/com/github/gotify/service/WebSocketService.java index bd2888d..d4ef2e7 100644 --- a/app/src/main/java/com/github/gotify/service/WebSocketService.java +++ b/app/src/main/java/com/github/gotify/service/WebSocketService.java @@ -215,6 +215,7 @@ public class WebSocketService extends Service { .setSmallIcon(R.drawable.ic_gotify) .setTicker(getString(R.string.app_name)) .setGroup(NotificationSupport.Group.MESSAGES) + .setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN) .setContentTitle(getString(R.string.grouped_notification_text)) .setGroupSummary(true) .setContentText(getString(R.string.grouped_notification_text)) From b306c319e73c11e20fbd96e7198c6663283f0b30 Mon Sep 17 00:00:00 2001 From: Jannis Mattheis Date: Fri, 9 Nov 2018 19:01:09 +0100 Subject: [PATCH 6/6] Set color on foreground notification --- .../main/java/com/github/gotify/service/WebSocketService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/com/github/gotify/service/WebSocketService.java b/app/src/main/java/com/github/gotify/service/WebSocketService.java index d4ef2e7..92426f3 100644 --- a/app/src/main/java/com/github/gotify/service/WebSocketService.java +++ b/app/src/main/java/com/github/gotify/service/WebSocketService.java @@ -164,6 +164,9 @@ public class WebSocketService extends Service { .setContentText(message) .setStyle(new NotificationCompat.BigTextStyle().bigText(message)) .setContentIntent(pendingIntent) + .setColor( + ContextCompat.getColor( + getApplicationContext(), R.color.colorPrimary)) .build(); startForeground(NotificationSupport.ID.FOREGROUND, notification);