improved notification style

This commit is contained in:
h4h13 2018-07-29 23:05:44 +05:30
parent 29e2a3958f
commit d8fc32ff30
3 changed files with 295 additions and 295 deletions

View file

@ -14,6 +14,7 @@ import code.name.monkey.retromusic.service.MusicService;
public abstract class PlayingNotification { public abstract class PlayingNotification {
protected static final float NOTIFICATION_CONTROLS_SIZE_MULTIPLIER = 1.0f;
static final String NOTIFICATION_CHANNEL_ID = "playing_notification"; static final String NOTIFICATION_CHANNEL_ID = "playing_notification";
private static final int NOTIFICATION_ID = 1; private static final int NOTIFICATION_ID = 1;
private static final int NOTIFY_MODE_FOREGROUND = 1; private static final int NOTIFY_MODE_FOREGROUND = 1;

View file

@ -1,5 +1,10 @@
package code.name.monkey.retromusic.service.notification; 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.app.PendingIntent;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Intent; import android.content.Intent;
@ -11,11 +16,6 @@ import android.os.Build;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
import android.support.v4.media.app.NotificationCompat.MediaStyle; import android.support.v4.media.app.NotificationCompat.MediaStyle;
import android.text.Html; 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.Constants;
import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.RetroApplication; 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.ui.activities.MainActivity;
import code.name.monkey.retromusic.util.PreferenceUtil; import code.name.monkey.retromusic.util.PreferenceUtil;
import code.name.monkey.retromusic.util.RetroColorUtil; import code.name.monkey.retromusic.util.RetroColorUtil;
import com.bumptech.glide.Glide;
import static code.name.monkey.retromusic.Constants.ACTION_QUIT; import com.bumptech.glide.request.animation.GlideAnimation;
import static code.name.monkey.retromusic.Constants.ACTION_REWIND; import com.bumptech.glide.request.target.SimpleTarget;
import static code.name.monkey.retromusic.Constants.ACTION_SKIP;
import static code.name.monkey.retromusic.Constants.ACTION_TOGGLE_PAUSE;
public class PlayingNotificationImpl24 extends PlayingNotification { public class PlayingNotificationImpl24 extends PlayingNotification {
@ -41,7 +39,6 @@ public class PlayingNotificationImpl24 extends PlayingNotification {
final Song song = service.getCurrentSong(); final Song song = service.getCurrentSong();
final boolean isPlaying = service.isPlaying(); final boolean isPlaying = service.isPlaying();
final int playButtonResId = isPlaying ? R.drawable.ic_pause_white_24dp : final int playButtonResId = isPlaying ? R.drawable.ic_pause_white_24dp :
R.drawable.ic_play_arrow_white_24dp; R.drawable.ic_play_arrow_white_24dp;

View file

@ -1,5 +1,11 @@
package code.name.monkey.retromusic.service.notification; 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.app.PendingIntent;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
@ -11,12 +17,6 @@ import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
import android.widget.RemoteViews; 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.ColorUtil;
import code.name.monkey.appthemehelper.util.MaterialValueHelper; import code.name.monkey.appthemehelper.util.MaterialValueHelper;
import code.name.monkey.retromusic.R; 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.PreferenceUtil;
import code.name.monkey.retromusic.util.RetroUtil; import code.name.monkey.retromusic.util.RetroUtil;
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor; import code.name.monkey.retromusic.util.color.MediaNotificationProcessor;
import com.bumptech.glide.Glide;
import static code.name.monkey.retromusic.Constants.ACTION_QUIT; import com.bumptech.glide.request.animation.GlideAnimation;
import static code.name.monkey.retromusic.Constants.ACTION_REWIND; import com.bumptech.glide.request.target.SimpleTarget;
import static code.name.monkey.retromusic.Constants.ACTION_SKIP; import com.bumptech.glide.request.target.Target;
import static code.name.monkey.retromusic.Constants.ACTION_TOGGLE_PAUSE;
import static code.name.monkey.retromusic.util.RetroUtil.createBitmap;
/** /**
* @author Hemanth S (h4h13). * @author Hemanth S (h4h13).
@ -46,7 +44,8 @@ public class PlayingNotificationOreo extends PlayingNotification {
RemoteViews remoteViews = new RemoteViews(service.getPackageName(), RemoteViews remoteViews = new RemoteViews(service.getPackageName(),
collapsed ? R.layout.layout_notification_collapsed : R.layout.layout_notification_expanded); 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.title, song.title);
remoteViews.setTextViewText(R.id.subtitle, song.artistName); remoteViews.setTextViewText(R.id.subtitle, song.artistName);
@ -109,12 +108,8 @@ public class PlayingNotificationOreo extends PlayingNotification {
public void onResourceReady(BitmapPaletteWrapper resource, public void onResourceReady(BitmapPaletteWrapper resource,
GlideAnimation<? super BitmapPaletteWrapper> glideAnimation) { GlideAnimation<? super BitmapPaletteWrapper> glideAnimation) {
MediaNotificationProcessor mediaNotificationProcessor = new MediaNotificationProcessor(service, service, new MediaNotificationProcessor.onColorThing() { MediaNotificationProcessor mediaNotificationProcessor = new MediaNotificationProcessor(
@Override service, service, (i, i2) -> update(resource.getBitmap(), i, i2));
public void bothColor(int i, int i2) {
update(resource.getBitmap(), i, i2);
}
});
mediaNotificationProcessor.processNotification(resource.getBitmap()); mediaNotificationProcessor.processNotification(resource.getBitmap());
} }
@ -162,17 +157,20 @@ public class PlayingNotificationOreo extends PlayingNotification {
int secondary = MaterialValueHelper.getSecondaryTextColor(service, dark); int secondary = MaterialValueHelper.getSecondaryTextColor(service, dark);
Bitmap close = createBitmap( Bitmap close = createBitmap(
RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_close_white_24dp, primary), RetroUtil
1.3f); .getTintedVectorDrawable(service, R.drawable.ic_close_white_24dp, primary),
NOTIFICATION_CONTROLS_SIZE_MULTIPLIER);
Bitmap prev = createBitmap( Bitmap prev = createBitmap(
RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp, RetroUtil
primary), 1.3f); .getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp,
primary), NOTIFICATION_CONTROLS_SIZE_MULTIPLIER);
Bitmap next = createBitmap( Bitmap next = createBitmap(
RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp, RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp,
primary), 1.3f); primary), NOTIFICATION_CONTROLS_SIZE_MULTIPLIER);
Bitmap playPause = createBitmap(RetroUtil.getTintedVectorDrawable(service, Bitmap playPause = createBitmap(RetroUtil.getTintedVectorDrawable(service,
isPlaying ? R.drawable.ic_pause_white_24dp 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.title, primary);
notificationLayout.setTextColor(R.id.subtitle, secondary); notificationLayout.setTextColor(R.id.subtitle, secondary);
@ -192,9 +190,13 @@ public class PlayingNotificationOreo extends PlayingNotification {
notificationLayoutBig.setImageViewBitmap(R.id.action_play_pause, playPause); notificationLayoutBig.setImageViewBitmap(R.id.action_play_pause, playPause);
notificationLayout.setImageViewBitmap(R.id.smallIcon, 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, 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); notificationLayout.setInt(R.id.arrow, "setColorFilter", secondary);
notificationLayoutBig.setInt(R.id.arrow, "setColorFilter", secondary); notificationLayoutBig.setInt(R.id.arrow, "setColorFilter", secondary);