Merge pull request #3372 from ByteHamster/notification-default-icon
Updated default notification icon
This commit is contained in:
commit
1d12f414e4
|
@ -1,13 +1,19 @@
|
|||
package de.danoeh.antennapod.core.service.playback;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.VectorDrawable;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.media.session.MediaSessionCompat;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
|
@ -99,12 +105,32 @@ public class PlaybackServiceNotificationBuilder extends NotificationCompat.Build
|
|||
|
||||
public void loadDefaultIcon() {
|
||||
if (defaultIcon == null) {
|
||||
defaultIcon = BitmapFactory.decodeResource(context.getResources(),
|
||||
ClientConfig.playbackServiceCallbacks.getNotificationIconResource(context));
|
||||
defaultIcon = getBitmap(context, R.drawable.notification_default_large_icon);
|
||||
}
|
||||
setLargeIcon(defaultIcon);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private static Bitmap getBitmap(VectorDrawable vectorDrawable) {
|
||||
Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(),
|
||||
vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
vectorDrawable.draw(canvas);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private static Bitmap getBitmap(Context context, int drawableId) {
|
||||
Drawable drawable = ContextCompat.getDrawable(context, drawableId);
|
||||
if (drawable instanceof BitmapDrawable) {
|
||||
return ((BitmapDrawable) drawable).getBitmap();
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && drawable instanceof VectorDrawable) {
|
||||
return getBitmap((VectorDrawable) drawable);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void addActions(MediaSessionCompat.Token mediaSessionToken, PlayerStatus playerStatus, boolean isCasting) {
|
||||
IntList compactActionList = new IntList();
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:viewportHeight="12.7"
|
||||
android:viewportWidth="12.7"
|
||||
android:height="64dp"
|
||||
android:width="64dp">
|
||||
|
||||
<path
|
||||
android:fillColor="#ff007DBA"
|
||||
android:pathData="M 0,0 L 12.7,0 12.7,12.7 0,12.7 z"/>
|
||||
|
||||
<path
|
||||
android:fillColor="#ffffffff"
|
||||
android:pathData="m5.7552,2.2412l0,0.2651c0.9377,0.0202 1.5471,0.342 2.1043,0.9059 0.5571,0.5639 0.8845,1.3798 0.9007,2.3678l0.2599,0C9.0264,4.6634 8.5918,3.7637 8.0502,3.2236 7.5085,2.6834 6.7902,2.2418 5.7552,2.2412ZM5.7552,3.0148l0,0.2796c0.6954,0.0292 1.0901,0.1719 1.5704,0.6542 0.4803,0.4823 0.6825,1.1066 0.6961,1.8314l0.2754,0c-0.0071,-0.9985 -0.4383,-1.6927 -0.7746,-2.0278 -0.3363,-0.3351 -0.8054,-0.734 -1.7673,-0.7374zM5.7547,3.8277 L5.7552,4.0845c0.3213,0.006 0.6726,0.1129 0.9788,0.4568 0.3061,0.3439 0.4008,0.8294 0.4129,1.2387l0.2635,0C7.4091,5.2384 7.1848,4.6554 6.9122,4.3656 6.6397,4.0758 6.3157,3.8296 5.7547,3.8277ZM5.7774,4.916c-0.3286,0.0001 -0.595,0.2667 -0.5948,0.5953 0.0001,0.2168 0.1181,0.4163 0.308,0.5209l-2.4371,5.0379 0.417,0.2713 0.4914,-1.0108 4.3574,1.2511 0.0672,0.1302 0.4641,-0.2031L6.0229,6.0523c0.2124,-0.0963 0.349,-0.3078 0.3493,-0.5411 0.0002,-0.3286 -0.2661,-0.5952 -0.5948,-0.5953zM5.7567,6.6053 L6.1841,7.4352 5.1278,7.9111zM6.2689,7.6001 L7.0047,9.0284 5.0054,8.1747zM4.9154,8.3514 L7.0083,9.2408 4.1103,10.0237zM7.1934,9.3948 L8.1985,11.3471 4.2054,10.203Z" />
|
||||
|
||||
</vector>
|
Loading…
Reference in New Issue