Browse Source

Fix issues with notification

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 7 years ago
parent
commit
e20e3914be

+ 2 - 2
app/build.gradle

@@ -12,8 +12,8 @@ android {
         targetSdkVersion 27
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
 
-        versionCode 14
-        versionName "1.0.5"
+        versionCode 15
+        versionName "1.0.6"
 
         // Enabling multidex support.
         multiDexEnabled true

+ 1 - 2
app/src/main/java/com/nextcloud/talk/application/NextcloudTalkApplication.java

@@ -91,8 +91,7 @@ public class NextcloudTalkApplication extends MultiDexApplication {
     //region private methods
     // Solution inspired by https://stackoverflow.com/questions/34936590/why-isnt-my-vector-drawable-scaling-as-expected
     private void useCompatVectorIfNeeded() {
-        int sdkInt = Build.VERSION.SDK_INT;
-        if (sdkInt == 21 || sdkInt == 22) {
+        if (Build.VERSION.SDK_INT < 23) {
             try {
                 @SuppressLint("RestrictedApi") AppCompatDrawableManager drawableManager = AppCompatDrawableManager.get();
                 Class<?> inflateDelegateClass = Class.forName("android.support.v7.widget.AppCompatDrawableManager$InflateDelegate");

+ 12 - 4
app/src/main/java/com/nextcloud/talk/services/firebase/MagicFirebaseMessagingService.java

@@ -28,10 +28,11 @@ import android.content.Context;
 import android.content.Intent;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
+import android.graphics.drawable.BitmapDrawable;
 import android.media.RingtoneManager;
 import android.net.Uri;
+import android.os.Build;
 import android.os.Bundle;
-import android.support.v4.app.NotificationCompat;
 import android.util.Base64;
 import android.util.Log;
 
@@ -43,6 +44,7 @@ import com.nextcloud.talk.activities.CallActivity;
 import com.nextcloud.talk.api.models.json.push.DecryptedPushMessage;
 import com.nextcloud.talk.api.models.json.push.PushMessage;
 import com.nextcloud.talk.models.SignatureVerification;
+import com.nextcloud.talk.utils.ColorUtils;
 import com.nextcloud.talk.utils.NotificationUtils;
 import com.nextcloud.talk.utils.PushUtils;
 import com.nextcloud.talk.utils.bundle.BundleBuilder;
@@ -130,11 +132,9 @@ public class MagicFirebaseMessagingService extends FirebaseMessagingService {
                             largeIcon = BitmapFactory.decodeResource(getResources(), smallIcon);
                             CRC32 crc32 = new CRC32();
 
-
-                            NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
+                            Notification.Builder notificationBuilder = new Notification.Builder(this)
                                     .setLargeIcon(largeIcon)
                                     .setSmallIcon(smallIcon)
-                                    .setColor(getColor(R.color.colorPrimary))
                                     .setCategory(category)
                                     .setPriority(priority)
                                     .setWhen(Calendar.getInstance().getTimeInMillis())
@@ -144,6 +144,14 @@ public class MagicFirebaseMessagingService extends FirebaseMessagingService {
                                     .setSound(soundUri)
                                     .setAutoCancel(true);
 
+                            if (Build.VERSION.SDK_INT >= 23) {
+                                notificationBuilder.setColor(getResources().getColor(R.color.colorPrimary));
+                            } else {
+                                BitmapDrawable tintedDrawable = (BitmapDrawable) ColorUtils.getTintedDrawable(getResources(), smallIcon,
+                                        R.color.colorPrimary);
+                                notificationBuilder.setLargeIcon(tintedDrawable.getBitmap());
+                            }
+
                             if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
 
                                 String groupName = String.format(getResources().getString(R.string

+ 0 - 2
app/src/main/java/com/nextcloud/talk/utils/ColorUtils.java

@@ -27,8 +27,6 @@ import android.support.annotation.ColorRes;
 import android.support.annotation.DrawableRes;
 
 public class ColorUtils {
-    public static String colorSeed = "ballast butte permute doxy graham rummage grateful songbook pledge escapade";
-
     public static Drawable getTintedDrawable(Resources res, @DrawableRes int drawableResId, @ColorRes int colorResId) {
         Drawable drawable = res.getDrawable(drawableResId);
         int color = res.getColor(colorResId);