Slightly updated the appwidget appearance, use smaller bitmap size for palette.
This commit is contained in:
parent
a238d6564e
commit
bd69dc1d43
13 changed files with 111 additions and 87 deletions
|
|
@ -205,6 +205,7 @@ public class AlbumAdapter extends AbsMultiSelectAdapter<AlbumAdapter.ViewHolder,
|
|||
private void applyPalette(Bitmap bitmap, final TextView title, final TextView artist, final View footer) {
|
||||
if (bitmap != null) {
|
||||
Palette.from(bitmap)
|
||||
.resizeBitmapSize(100)
|
||||
.generate(new Palette.PaletteAsyncListener() {
|
||||
@Override
|
||||
public void onGenerated(Palette palette) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import com.nostra13.universalimageloader.core.assist.ViewScaleType;
|
|||
import com.nostra13.universalimageloader.core.imageaware.NonViewAware;
|
||||
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
|
||||
|
||||
public class MusicPlayerWidget extends AppWidgetProvider {
|
||||
public class WidgetMedium extends AppWidgetProvider {
|
||||
private static RemoteViews widgetLayout;
|
||||
private static String currentAlbumArtUri;
|
||||
|
||||
|
|
@ -37,16 +37,17 @@ public class MusicPlayerWidget extends AppWidgetProvider {
|
|||
|
||||
public static void updateWidgets(final Context context, final Song song, boolean isPlaying) {
|
||||
if (song.id == -1) return;
|
||||
widgetLayout = new RemoteViews(context.getPackageName(), R.layout.music_player_widget);
|
||||
widgetLayout = new RemoteViews(context.getPackageName(), R.layout.widget_medium);
|
||||
linkButtons(context, widgetLayout);
|
||||
widgetLayout.setTextViewText(R.id.song_title, song.title);
|
||||
widgetLayout.setTextViewText(R.id.song_secondary_information, song.artistName + " | " + song.albumName);
|
||||
updateWidgetsPlayState(context, isPlaying);
|
||||
loadAlbumArt(context, song);
|
||||
}
|
||||
|
||||
public static void updateWidgetsPlayState(final Context context, boolean isPlaying) {
|
||||
if (widgetLayout == null)
|
||||
widgetLayout = new RemoteViews(context.getPackageName(), R.layout.music_player_widget);
|
||||
widgetLayout = new RemoteViews(context.getPackageName(), R.layout.widget_medium);
|
||||
int playPauseRes = isPlaying ? R.drawable.ic_pause_black_36dp : R.drawable.ic_play_arrow_black_36dp;
|
||||
widgetLayout.setImageViewResource(R.id.button_toggle_play_pause, playPauseRes);
|
||||
updateWidgets(context);
|
||||
|
|
@ -55,7 +56,7 @@ public class MusicPlayerWidget extends AppWidgetProvider {
|
|||
private static void updateWidgets(final Context context) {
|
||||
AppWidgetManager man = AppWidgetManager.getInstance(context);
|
||||
int[] ids = man.getAppWidgetIds(
|
||||
new ComponentName(context, MusicPlayerWidget.class));
|
||||
new ComponentName(context, WidgetMedium.class));
|
||||
for (int widgetId : ids) {
|
||||
man.updateAppWidget(widgetId, widgetLayout);
|
||||
}
|
||||
|
|
@ -230,7 +230,7 @@ public class PlayingNotificationHelper {
|
|||
notificationLayoutExpanded.setImageViewBitmap(R.id.icon, albumArt);
|
||||
if (isColored) {
|
||||
int defaultColor = service.getResources().getColor(R.color.default_colored_notification_color);
|
||||
int newColor = Palette.from(albumArt).generate().getVibrantColor(defaultColor);
|
||||
int newColor = Palette.from(albumArt).resizeBitmapSize(100).generate().getVibrantColor(defaultColor);
|
||||
setBackgroundColor(newColor);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import android.view.View;
|
|||
import android.widget.Toast;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.appwidget.MusicPlayerWidget;
|
||||
import com.kabouzeid.gramophone.appwidget.WidgetMedium;
|
||||
import com.kabouzeid.gramophone.helper.PlayingNotificationHelper;
|
||||
import com.kabouzeid.gramophone.helper.ShuffleHelper;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
|
|
@ -469,7 +469,7 @@ public class MusicService extends Service {
|
|||
}
|
||||
|
||||
private void updateWidgets() {
|
||||
MusicPlayerWidget.updateWidgets(this, getCurrentSong(), isPlaying());
|
||||
WidgetMedium.updateWidgets(this, getCurrentSong(), isPlaying());
|
||||
}
|
||||
|
||||
private static String getTrackUri(Song song) {
|
||||
|
|
@ -794,7 +794,7 @@ public class MusicService extends Service {
|
|||
if (what.equals(PLAY_STATE_CHANGED)) {
|
||||
final boolean isPlaying = isPlaying();
|
||||
playingNotificationHelper.updatePlayState(isPlaying);
|
||||
MusicPlayerWidget.updateWidgetsPlayState(this, isPlaying);
|
||||
WidgetMedium.updateWidgetsPlayState(this, isPlaying);
|
||||
//noinspection deprecation
|
||||
remoteControlClient.setPlaybackState(isPlaying ? RemoteControlClient.PLAYSTATE_PLAYING : RemoteControlClient.PLAYSTATE_PAUSED);
|
||||
if (!isPlaying && getSongProgressMillis() > 0) {
|
||||
|
|
|
|||
|
|
@ -238,8 +238,8 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
private void applyPalette(Bitmap bitmap) {
|
||||
if (bitmap != null) {
|
||||
Palette.from(bitmap)
|
||||
.resizeBitmapSize(100)
|
||||
.generate(new Palette.PaletteAsyncListener() {
|
||||
|
||||
@Override
|
||||
public void onGenerated(Palette palette) {
|
||||
final Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
|
||||
|
|
|
|||
|
|
@ -375,6 +375,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
private void applyPalette(Bitmap bitmap) {
|
||||
if (bitmap != null) {
|
||||
Palette.from(bitmap)
|
||||
.resizeBitmapSize(100)
|
||||
.generate(new Palette.PaletteAsyncListener() {
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -455,6 +455,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
private void applyPalette(Bitmap bitmap) {
|
||||
if (bitmap != null) {
|
||||
Palette.from(bitmap)
|
||||
.resizeBitmapSize(100)
|
||||
.generate(new Palette.PaletteAsyncListener() {
|
||||
@Override
|
||||
public void onGenerated(Palette palette) {
|
||||
|
|
|
|||
|
|
@ -292,6 +292,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
|
||||
private void applyPalette(final Bitmap bitmap) {
|
||||
Palette.from(bitmap)
|
||||
.resizeBitmapSize(100)
|
||||
.generate(new Palette.PaletteAsyncListener() {
|
||||
@Override
|
||||
public void onGenerated(Palette palette) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue