Skip to content

Commit

Permalink
Fix issues with notification
Browse files Browse the repository at this point in the history
Signed-off-by: Mario Danic <[email protected]>
  • Loading branch information
mario committed Jan 14, 2018
1 parent d4f1012 commit e20e391
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ public static NextcloudTalkApplication getSharedApplication() {
//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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
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;

Expand All @@ -43,6 +44,7 @@
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;
Expand Down Expand Up @@ -130,11 +132,9 @@ public void onMessageReceived(RemoteMessage remoteMessage) {
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())
Expand All @@ -144,6 +144,14 @@ public void onMessageReceived(RemoteMessage remoteMessage) {
.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
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/nextcloud/talk/utils/ColorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
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);
Expand Down

0 comments on commit e20e391

Please sign in to comment.