improved notification style
This commit is contained in:
parent
29e2a3958f
commit
d8fc32ff30
3 changed files with 295 additions and 295 deletions
|
@ -14,6 +14,7 @@ import code.name.monkey.retromusic.service.MusicService;
|
|||
|
||||
public abstract class PlayingNotification {
|
||||
|
||||
protected static final float NOTIFICATION_CONTROLS_SIZE_MULTIPLIER = 1.0f;
|
||||
static final String NOTIFICATION_CHANNEL_ID = "playing_notification";
|
||||
private static final int NOTIFICATION_ID = 1;
|
||||
private static final int NOTIFY_MODE_FOREGROUND = 1;
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package code.name.monkey.retromusic.service.notification;
|
||||
|
||||
import static code.name.monkey.retromusic.Constants.ACTION_QUIT;
|
||||
import static code.name.monkey.retromusic.Constants.ACTION_REWIND;
|
||||
import static code.name.monkey.retromusic.Constants.ACTION_SKIP;
|
||||
import static code.name.monkey.retromusic.Constants.ACTION_TOGGLE_PAUSE;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
|
@ -11,11 +16,6 @@ import android.os.Build;
|
|||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.media.app.NotificationCompat.MediaStyle;
|
||||
import android.text.Html;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.animation.GlideAnimation;
|
||||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
|
||||
import code.name.monkey.retromusic.Constants;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.RetroApplication;
|
||||
|
@ -26,11 +26,9 @@ import code.name.monkey.retromusic.service.MusicService;
|
|||
import code.name.monkey.retromusic.ui.activities.MainActivity;
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil;
|
||||
|
||||
import static code.name.monkey.retromusic.Constants.ACTION_QUIT;
|
||||
import static code.name.monkey.retromusic.Constants.ACTION_REWIND;
|
||||
import static code.name.monkey.retromusic.Constants.ACTION_SKIP;
|
||||
import static code.name.monkey.retromusic.Constants.ACTION_TOGGLE_PAUSE;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.animation.GlideAnimation;
|
||||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
|
||||
public class PlayingNotificationImpl24 extends PlayingNotification {
|
||||
|
||||
|
@ -41,7 +39,6 @@ public class PlayingNotificationImpl24 extends PlayingNotification {
|
|||
final Song song = service.getCurrentSong();
|
||||
final boolean isPlaying = service.isPlaying();
|
||||
|
||||
|
||||
final int playButtonResId = isPlaying ? R.drawable.ic_pause_white_24dp :
|
||||
R.drawable.ic_play_arrow_white_24dp;
|
||||
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package code.name.monkey.retromusic.service.notification;
|
||||
|
||||
import static code.name.monkey.retromusic.Constants.ACTION_QUIT;
|
||||
import static code.name.monkey.retromusic.Constants.ACTION_REWIND;
|
||||
import static code.name.monkey.retromusic.Constants.ACTION_SKIP;
|
||||
import static code.name.monkey.retromusic.Constants.ACTION_TOGGLE_PAUSE;
|
||||
import static code.name.monkey.retromusic.util.RetroUtil.createBitmap;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
|
@ -11,12 +17,6 @@ import android.graphics.drawable.Drawable;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.animation.GlideAnimation;
|
||||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil;
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper;
|
||||
import code.name.monkey.retromusic.R;
|
||||
|
@ -28,12 +28,10 @@ import code.name.monkey.retromusic.ui.activities.MainActivity;
|
|||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
||||
import code.name.monkey.retromusic.util.RetroUtil;
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor;
|
||||
|
||||
import static code.name.monkey.retromusic.Constants.ACTION_QUIT;
|
||||
import static code.name.monkey.retromusic.Constants.ACTION_REWIND;
|
||||
import static code.name.monkey.retromusic.Constants.ACTION_SKIP;
|
||||
import static code.name.monkey.retromusic.Constants.ACTION_TOGGLE_PAUSE;
|
||||
import static code.name.monkey.retromusic.util.RetroUtil.createBitmap;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.animation.GlideAnimation;
|
||||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
|
@ -46,7 +44,8 @@ public class PlayingNotificationOreo extends PlayingNotification {
|
|||
RemoteViews remoteViews = new RemoteViews(service.getPackageName(),
|
||||
collapsed ? R.layout.layout_notification_collapsed : R.layout.layout_notification_expanded);
|
||||
|
||||
remoteViews.setTextViewText(R.id.appName, service.getString(R.string.app_name) + " • " + song.albumName);
|
||||
remoteViews.setTextViewText(R.id.appName,
|
||||
service.getString(R.string.app_name) + " • " + song.albumName);
|
||||
remoteViews.setTextViewText(R.id.title, song.title);
|
||||
remoteViews.setTextViewText(R.id.subtitle, song.artistName);
|
||||
|
||||
|
@ -109,12 +108,8 @@ public class PlayingNotificationOreo extends PlayingNotification {
|
|||
public void onResourceReady(BitmapPaletteWrapper resource,
|
||||
GlideAnimation<? super BitmapPaletteWrapper> glideAnimation) {
|
||||
|
||||
MediaNotificationProcessor mediaNotificationProcessor = new MediaNotificationProcessor(service, service, new MediaNotificationProcessor.onColorThing() {
|
||||
@Override
|
||||
public void bothColor(int i, int i2) {
|
||||
update(resource.getBitmap(), i, i2);
|
||||
}
|
||||
});
|
||||
MediaNotificationProcessor mediaNotificationProcessor = new MediaNotificationProcessor(
|
||||
service, service, (i, i2) -> update(resource.getBitmap(), i, i2));
|
||||
mediaNotificationProcessor.processNotification(resource.getBitmap());
|
||||
|
||||
}
|
||||
|
@ -162,17 +157,20 @@ public class PlayingNotificationOreo extends PlayingNotification {
|
|||
int secondary = MaterialValueHelper.getSecondaryTextColor(service, dark);
|
||||
|
||||
Bitmap close = createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_close_white_24dp, primary),
|
||||
1.3f);
|
||||
RetroUtil
|
||||
.getTintedVectorDrawable(service, R.drawable.ic_close_white_24dp, primary),
|
||||
NOTIFICATION_CONTROLS_SIZE_MULTIPLIER);
|
||||
Bitmap prev = createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp,
|
||||
primary), 1.3f);
|
||||
RetroUtil
|
||||
.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp,
|
||||
primary), NOTIFICATION_CONTROLS_SIZE_MULTIPLIER);
|
||||
Bitmap next = createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp,
|
||||
primary), 1.3f);
|
||||
primary), NOTIFICATION_CONTROLS_SIZE_MULTIPLIER);
|
||||
Bitmap playPause = createBitmap(RetroUtil.getTintedVectorDrawable(service,
|
||||
isPlaying ? R.drawable.ic_pause_white_24dp
|
||||
: R.drawable.ic_play_arrow_white_24dp, primary), 1.3f);
|
||||
: R.drawable.ic_play_arrow_white_24dp, primary),
|
||||
NOTIFICATION_CONTROLS_SIZE_MULTIPLIER);
|
||||
|
||||
notificationLayout.setTextColor(R.id.title, primary);
|
||||
notificationLayout.setTextColor(R.id.subtitle, secondary);
|
||||
|
@ -192,9 +190,13 @@ public class PlayingNotificationOreo extends PlayingNotification {
|
|||
notificationLayoutBig.setImageViewBitmap(R.id.action_play_pause, playPause);
|
||||
|
||||
notificationLayout.setImageViewBitmap(R.id.smallIcon,
|
||||
createBitmap(RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_notification, secondary), 0.6f));
|
||||
createBitmap(RetroUtil
|
||||
.getTintedVectorDrawable(service, R.drawable.ic_notification, secondary),
|
||||
0.6f));
|
||||
notificationLayoutBig.setImageViewBitmap(R.id.smallIcon,
|
||||
createBitmap(RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_notification, secondary), 0.6f));
|
||||
createBitmap(RetroUtil
|
||||
.getTintedVectorDrawable(service, R.drawable.ic_notification, secondary),
|
||||
0.6f));
|
||||
|
||||
notificationLayout.setInt(R.id.arrow, "setColorFilter", secondary);
|
||||
notificationLayoutBig.setInt(R.id.arrow, "setColorFilter", secondary);
|
||||
|
|
Loading…
Reference in a new issue