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

View file

@ -13,7 +13,7 @@ buildscript {
}
}
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}"
// 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
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-all.zip
distributionSha256Sum=f177768e7a032727e4338c8fd047f8f263e5bd283f67a7766c1ba4182c8455a6
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip