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
|
|
@ -122,14 +122,14 @@
|
||||||
android:name=".ui.activities.SearchActivity"
|
android:name=".ui.activities.SearchActivity"
|
||||||
android:label="@string/title_activity_search" />
|
android:label="@string/title_activity_search" />
|
||||||
|
|
||||||
<receiver android:name=".appwidget.MusicPlayerWidget">
|
<receiver android:name=".appwidget.WidgetMedium">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.appwidget.provider"
|
android:name="android.appwidget.provider"
|
||||||
android:resource="@xml/music_player_widget_info" />
|
android:resource="@xml/widget_medium_info" />
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
private void applyPalette(Bitmap bitmap, final TextView title, final TextView artist, final View footer) {
|
||||||
if (bitmap != null) {
|
if (bitmap != null) {
|
||||||
Palette.from(bitmap)
|
Palette.from(bitmap)
|
||||||
|
.resizeBitmapSize(100)
|
||||||
.generate(new Palette.PaletteAsyncListener() {
|
.generate(new Palette.PaletteAsyncListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onGenerated(Palette palette) {
|
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.imageaware.NonViewAware;
|
||||||
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
|
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
|
||||||
|
|
||||||
public class MusicPlayerWidget extends AppWidgetProvider {
|
public class WidgetMedium extends AppWidgetProvider {
|
||||||
private static RemoteViews widgetLayout;
|
private static RemoteViews widgetLayout;
|
||||||
private static String currentAlbumArtUri;
|
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) {
|
public static void updateWidgets(final Context context, final Song song, boolean isPlaying) {
|
||||||
if (song.id == -1) return;
|
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);
|
linkButtons(context, widgetLayout);
|
||||||
widgetLayout.setTextViewText(R.id.song_title, song.title);
|
widgetLayout.setTextViewText(R.id.song_title, song.title);
|
||||||
|
widgetLayout.setTextViewText(R.id.song_secondary_information, song.artistName + " | " + song.albumName);
|
||||||
updateWidgetsPlayState(context, isPlaying);
|
updateWidgetsPlayState(context, isPlaying);
|
||||||
loadAlbumArt(context, song);
|
loadAlbumArt(context, song);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateWidgetsPlayState(final Context context, boolean isPlaying) {
|
public static void updateWidgetsPlayState(final Context context, boolean isPlaying) {
|
||||||
if (widgetLayout == null)
|
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;
|
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);
|
widgetLayout.setImageViewResource(R.id.button_toggle_play_pause, playPauseRes);
|
||||||
updateWidgets(context);
|
updateWidgets(context);
|
||||||
|
|
@ -55,7 +56,7 @@ public class MusicPlayerWidget extends AppWidgetProvider {
|
||||||
private static void updateWidgets(final Context context) {
|
private static void updateWidgets(final Context context) {
|
||||||
AppWidgetManager man = AppWidgetManager.getInstance(context);
|
AppWidgetManager man = AppWidgetManager.getInstance(context);
|
||||||
int[] ids = man.getAppWidgetIds(
|
int[] ids = man.getAppWidgetIds(
|
||||||
new ComponentName(context, MusicPlayerWidget.class));
|
new ComponentName(context, WidgetMedium.class));
|
||||||
for (int widgetId : ids) {
|
for (int widgetId : ids) {
|
||||||
man.updateAppWidget(widgetId, widgetLayout);
|
man.updateAppWidget(widgetId, widgetLayout);
|
||||||
}
|
}
|
||||||
|
|
@ -230,7 +230,7 @@ public class PlayingNotificationHelper {
|
||||||
notificationLayoutExpanded.setImageViewBitmap(R.id.icon, albumArt);
|
notificationLayoutExpanded.setImageViewBitmap(R.id.icon, albumArt);
|
||||||
if (isColored) {
|
if (isColored) {
|
||||||
int defaultColor = service.getResources().getColor(R.color.default_colored_notification_color);
|
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);
|
setBackgroundColor(newColor);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import android.view.View;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.R;
|
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.PlayingNotificationHelper;
|
||||||
import com.kabouzeid.gramophone.helper.ShuffleHelper;
|
import com.kabouzeid.gramophone.helper.ShuffleHelper;
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
import com.kabouzeid.gramophone.model.Song;
|
||||||
|
|
@ -469,7 +469,7 @@ public class MusicService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateWidgets() {
|
private void updateWidgets() {
|
||||||
MusicPlayerWidget.updateWidgets(this, getCurrentSong(), isPlaying());
|
WidgetMedium.updateWidgets(this, getCurrentSong(), isPlaying());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getTrackUri(Song song) {
|
private static String getTrackUri(Song song) {
|
||||||
|
|
@ -794,7 +794,7 @@ public class MusicService extends Service {
|
||||||
if (what.equals(PLAY_STATE_CHANGED)) {
|
if (what.equals(PLAY_STATE_CHANGED)) {
|
||||||
final boolean isPlaying = isPlaying();
|
final boolean isPlaying = isPlaying();
|
||||||
playingNotificationHelper.updatePlayState(isPlaying);
|
playingNotificationHelper.updatePlayState(isPlaying);
|
||||||
MusicPlayerWidget.updateWidgetsPlayState(this, isPlaying);
|
WidgetMedium.updateWidgetsPlayState(this, isPlaying);
|
||||||
//noinspection deprecation
|
//noinspection deprecation
|
||||||
remoteControlClient.setPlaybackState(isPlaying ? RemoteControlClient.PLAYSTATE_PLAYING : RemoteControlClient.PLAYSTATE_PAUSED);
|
remoteControlClient.setPlaybackState(isPlaying ? RemoteControlClient.PLAYSTATE_PLAYING : RemoteControlClient.PLAYSTATE_PAUSED);
|
||||||
if (!isPlaying && getSongProgressMillis() > 0) {
|
if (!isPlaying && getSongProgressMillis() > 0) {
|
||||||
|
|
|
||||||
|
|
@ -238,8 +238,8 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
||||||
private void applyPalette(Bitmap bitmap) {
|
private void applyPalette(Bitmap bitmap) {
|
||||||
if (bitmap != null) {
|
if (bitmap != null) {
|
||||||
Palette.from(bitmap)
|
Palette.from(bitmap)
|
||||||
|
.resizeBitmapSize(100)
|
||||||
.generate(new Palette.PaletteAsyncListener() {
|
.generate(new Palette.PaletteAsyncListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGenerated(Palette palette) {
|
public void onGenerated(Palette palette) {
|
||||||
final Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
|
final Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
|
||||||
|
|
|
||||||
|
|
@ -375,6 +375,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
||||||
private void applyPalette(Bitmap bitmap) {
|
private void applyPalette(Bitmap bitmap) {
|
||||||
if (bitmap != null) {
|
if (bitmap != null) {
|
||||||
Palette.from(bitmap)
|
Palette.from(bitmap)
|
||||||
|
.resizeBitmapSize(100)
|
||||||
.generate(new Palette.PaletteAsyncListener() {
|
.generate(new Palette.PaletteAsyncListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -455,6 +455,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
private void applyPalette(Bitmap bitmap) {
|
private void applyPalette(Bitmap bitmap) {
|
||||||
if (bitmap != null) {
|
if (bitmap != null) {
|
||||||
Palette.from(bitmap)
|
Palette.from(bitmap)
|
||||||
|
.resizeBitmapSize(100)
|
||||||
.generate(new Palette.PaletteAsyncListener() {
|
.generate(new Palette.PaletteAsyncListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onGenerated(Palette palette) {
|
public void onGenerated(Palette palette) {
|
||||||
|
|
|
||||||
|
|
@ -292,6 +292,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
||||||
|
|
||||||
private void applyPalette(final Bitmap bitmap) {
|
private void applyPalette(final Bitmap bitmap) {
|
||||||
Palette.from(bitmap)
|
Palette.from(bitmap)
|
||||||
|
.resizeBitmapSize(100)
|
||||||
.generate(new Palette.PaletteAsyncListener() {
|
.generate(new Palette.PaletteAsyncListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onGenerated(Palette palette) {
|
public void onGenerated(Palette palette) {
|
||||||
|
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/app_widget_small_artwork_height"
|
|
||||||
android:background="#FFFFFF"
|
|
||||||
tools:ignore="ContentDescription">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:src="@drawable/default_album_art"
|
|
||||||
android:id="@+id/album_art"
|
|
||||||
android:layout_width="@dimen/app_widget_small_artwork_height"
|
|
||||||
android:layout_height="@dimen/app_widget_small_artwork_height"
|
|
||||||
android:scaleType="centerCrop" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:gravity="center"
|
|
||||||
android:id="@+id/song_title"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:textAppearance="@style/Theme.MaterialMusic.Notification.Title"
|
|
||||||
android:layout_margin="4dp"
|
|
||||||
android:text="@string/nothing_playing" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/media_actions"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="@drawable/notification_selector"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:id="@+id/button_prev"
|
|
||||||
android:src="@drawable/ic_skip_previous_black_36dp" />
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="@drawable/notification_selector"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:id="@+id/button_toggle_play_pause"
|
|
||||||
android:src="@drawable/ic_play_arrow_black_36dp" />
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="@drawable/notification_selector"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:id="@+id/button_next"
|
|
||||||
android:src="@drawable/ic_skip_next_black_36dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
85
app/src/main/res/layout/widget_medium.xml
Normal file
85
app/src/main/res/layout/widget_medium.xml
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="96dp"
|
||||||
|
android:background="#AAFFFFFF"
|
||||||
|
tools:ignore="ContentDescription">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/album_art"
|
||||||
|
android:layout_width="96dp"
|
||||||
|
android:layout_height="96dp"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:src="@drawable/default_album_art" />
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/media_actions"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/button_prev"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/notification_selector"
|
||||||
|
android:src="@drawable/ic_skip_previous_black_36dp" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/button_toggle_play_pause"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/notification_selector"
|
||||||
|
android:src="@drawable/ic_play_arrow_black_36dp" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/button_next"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/notification_selector"
|
||||||
|
android:src="@drawable/ic_skip_next_black_36dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/media_titles"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_above="@+id/media_actions"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/song_title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="@string/nothing_playing"
|
||||||
|
android:textAppearance="@style/Theme.MaterialMusic.Notification.Title" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/song_secondary_information"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textAppearance="@style/Theme.MaterialMusic.Notification" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:minWidth="180dp"
|
|
||||||
android:minHeight="40dp"
|
|
||||||
android:updatePeriodMillis="86400000"
|
|
||||||
android:previewImage="@drawable/example_appwidget_preview"
|
|
||||||
android:initialLayout="@layout/music_player_widget"
|
|
||||||
android:resizeMode="horizontal|vertical"
|
|
||||||
android:widgetCategory="home_screen|keyguard"
|
|
||||||
android:initialKeyguardLayout="@layout/music_player_widget">
|
|
||||||
</appwidget-provider>
|
|
||||||
10
app/src/main/res/xml/widget_medium_info.xml
Normal file
10
app/src/main/res/xml/widget_medium_info.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:initialLayout="@layout/widget_medium"
|
||||||
|
android:minHeight="40dp"
|
||||||
|
android:minWidth="250dp"
|
||||||
|
android:resizeMode="none"
|
||||||
|
android:updatePeriodMillis="0"
|
||||||
|
android:widgetCategory="home_screen|keyguard"
|
||||||
|
tools:ignore="UnusedAttribute" />
|
||||||
Loading…
Add table
Add a link
Reference in a new issue