Improve on the notifications

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2019-08-22 13:07:33 +02:00
parent 750218febd
commit 8f311ae3bc
3 changed files with 18 additions and 20 deletions

View file

@ -118,7 +118,7 @@ public class NotificationWorker extends Worker {
private DecryptedPushMessage decryptedPushMessage; private DecryptedPushMessage decryptedPushMessage;
private Context context; private Context context;
private SignatureVerification signatureVerification; private SignatureVerification signatureVerification;
private String conversationType = ""; private String conversationType = "one2one";
private String credentials; private String credentials;
@ -161,7 +161,7 @@ public class NotificationWorker extends Worker {
} else { } else {
conversationType = "public"; conversationType = "public";
} }
showNotification(intent); showMessageNotificationWithObjectData(intent);
} }
} }
@ -203,14 +203,20 @@ public class NotificationWorker extends Worker {
HashMap<String, HashMap<String, String>> subjectRichParameters = notification HashMap<String, HashMap<String, String>> subjectRichParameters = notification
.getSubjectRichParameters(); .getSubjectRichParameters();
if (subjectRichParameters != null && subjectRichParameters if (subjectRichParameters != null && subjectRichParameters.size() > 0) {
.size() > 0 && subjectRichParameters.containsKey("call")
&& subjectRichParameters.containsKey("user")) {
HashMap<String, String> callHashMap = subjectRichParameters.get("call"); HashMap<String, String> callHashMap = subjectRichParameters.get("call");
HashMap<String, String> userHashMap = subjectRichParameters.get("user"); HashMap<String, String> userHashMap = subjectRichParameters.get("user");
if (callHashMap != null && callHashMap.size() > 0 && callHashMap.containsKey("name")) { if (callHashMap != null && callHashMap.size() > 0 && callHashMap.containsKey("name")) {
if (notification.getObjectType().equals("chat")) {
decryptedPushMessage.setSubject(callHashMap.get("name")); decryptedPushMessage.setSubject(callHashMap.get("name"));
} else {
decryptedPushMessage.setSubject(notification.getSubject());
}
if (callHashMap.containsKey("call-type")) {
conversationType = callHashMap.get("call-type");
}
} }
if (userHashMap != null && !userHashMap.isEmpty()) { if (userHashMap != null && !userHashMap.isEmpty()) {
@ -251,13 +257,6 @@ public class NotificationWorker extends Worker {
} }
switch (conversationType) { switch (conversationType) {
case "one2one":
if (decryptedPushMessage.getType().equals("chat") || decryptedPushMessage.getType().equals("room")) {
largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_chat_black_24dp);
} else {
largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_call_black_24dp);
}
break;
case "group": case "group":
largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_people_group_black_24px); largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_people_group_black_24px);
break; break;
@ -265,6 +264,7 @@ public class NotificationWorker extends Worker {
largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_link_black_24px); largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_link_black_24px);
break; break;
default: default:
// assuming one2one
if (decryptedPushMessage.getType().equals("chat") || decryptedPushMessage.getType().equals("room")) { if (decryptedPushMessage.getType().equals("chat") || decryptedPushMessage.getType().equals("room")) {
largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_chat_black_24dp); largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_chat_black_24dp);
} else { } else {
@ -285,9 +285,9 @@ public class NotificationWorker extends Worker {
.setSmallIcon(smallIcon) .setSmallIcon(smallIcon)
.setCategory(category) .setCategory(category)
.setPriority(priority) .setPriority(priority)
.setSubText(baseUrl)
.setWhen(Calendar.getInstance().getTimeInMillis()) .setWhen(Calendar.getInstance().getTimeInMillis())
.setShowWhen(true) .setShowWhen(true)
.setSubText(baseUrl)
.setContentTitle(decryptedPushMessage.getSubject()) .setContentTitle(decryptedPushMessage.getSubject())
.setContentIntent(pendingIntent) .setContentIntent(pendingIntent)
.setAutoCancel(true); .setAutoCancel(true);
@ -347,7 +347,6 @@ public class NotificationWorker extends Worker {
crc32.update(groupName.getBytes()); crc32.update(groupName.getBytes());
notificationBuilder.setGroup(Long.toString(crc32.getValue())); notificationBuilder.setGroup(Long.toString(crc32.getValue()));
// notificationId // notificationId
crc32 = new CRC32(); crc32 = new CRC32();
String stringForCrc = String.valueOf(System.currentTimeMillis()); String stringForCrc = String.valueOf(System.currentTimeMillis());
@ -365,7 +364,7 @@ public class NotificationWorker extends Worker {
notificationId = (int) crc32.getValue(); notificationId = (int) crc32.getValue();
} }
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N && decryptedPushMessage.getNotificationUser() != null && decryptedPushMessage.getType().equals("chat")) {
NotificationCompat.MessagingStyle style = null; NotificationCompat.MessagingStyle style = null;
if (activeStatusBarNotification != null) { if (activeStatusBarNotification != null) {
Notification activeNotification = activeStatusBarNotification.getNotification(); Notification activeNotification = activeStatusBarNotification.getNotification();

View file

@ -13,7 +13,7 @@ buildscript {
} }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.4.2' classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong

View file

@ -1,7 +1,6 @@
#Thu Apr 18 00:35:28 CEST 2019 #Thu Aug 22 11:56:51 CEST 2019
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionSha256Sum=f177768e7a032727e4338c8fd047f8f263e5bd283f67a7766c1ba4182c8455a6