Massive clean up of attrs, colors and styles. Also icon and divider colors matching better the guidelines now.
This commit is contained in:
parent
060c8867ea
commit
7fd4226685
94 changed files with 160 additions and 233 deletions
|
|
@ -48,7 +48,7 @@ public class PlayingQueueAdapter extends ArrayAdapter<Song> {
|
|||
if (MusicPlayerRemote.getPosition() == position) {
|
||||
int iconPadding = activity.getResources().getDimensionPixelSize(R.dimen.list_item_image_icon_padding);
|
||||
playingIndicator.setPadding(iconPadding, iconPadding, iconPadding, iconPadding);
|
||||
playingIndicator.setImageDrawable(Util.getTintedDrawable(getContext(), R.drawable.ic_volume_up_white_24dp, DialogUtils.resolveColor(getContext(), R.attr.themed_drawable_color)));
|
||||
playingIndicator.setImageDrawable(Util.getTintedDrawable(getContext(), R.drawable.ic_volume_up_white_24dp, DialogUtils.resolveColor(getContext(), android.R.attr.textColorSecondary)));
|
||||
playingIndicator.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
playingIndicator.setVisibility(View.GONE);
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public class PlaylistAdapter extends AbsMultiSelectAdapter<PlaylistAdapter.ViewH
|
|||
holder.image.setImageDrawable(Util.getTintedDrawable(
|
||||
activity,
|
||||
getIconRes(playlist),
|
||||
ColorUtil.resolveColor(activity, R.attr.themed_drawable_color)
|
||||
ColorUtil.resolveColor(activity, android.R.attr.textColorSecondary)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -172,7 +172,7 @@ public class PlaylistAdapter extends AbsMultiSelectAdapter<PlaylistAdapter.ViewH
|
|||
if (shortSeparator != null) {
|
||||
shortSeparator.setVisibility(View.GONE);
|
||||
}
|
||||
itemView.setBackgroundColor(ColorUtil.resolveColor(activity, R.attr.card_color));
|
||||
itemView.setBackgroundColor(ColorUtil.resolveColor(activity, R.attr.cardBackgroundColor));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
itemView.setElevation(activity.getResources().getDimensionPixelSize(R.dimen.card_elevation));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
|
|
@ -143,14 +141,16 @@ public class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.ViewHolder
|
|||
public class ViewHolder extends MediaEntryViewHolder {
|
||||
public ViewHolder(@NonNull View itemView, int itemViewType) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
itemView.setOnLongClickListener(null);
|
||||
|
||||
if (itemViewType != HEADER) {
|
||||
itemView.setBackgroundColor(ColorUtil.resolveColor(activity, R.attr.card_color));
|
||||
itemView.setBackgroundColor(ColorUtil.resolveColor(activity, R.attr.cardBackgroundColor));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
itemView.setElevation(activity.getResources().getDimensionPixelSize(R.dimen.card_elevation));
|
||||
}
|
||||
if (shortSeparator != null) {
|
||||
shortSeparator.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (menu != null) {
|
||||
|
|
|
|||
|
|
@ -31,14 +31,6 @@ public class WidgetMedium extends AppWidgetProvider {
|
|||
private static RemoteViews widgetLayout;
|
||||
private static String currentAlbumArtUri;
|
||||
|
||||
@Override
|
||||
public void onUpdate(@NonNull Context context, @NonNull AppWidgetManager appWidgetManager, @NonNull int[] appWidgetIds) {
|
||||
updateWidgets(context, MusicPlayerRemote.getCurrentSong(), MusicPlayerRemote.isPlaying());
|
||||
for (int widgetId : appWidgetIds) {
|
||||
appWidgetManager.updateAppWidget(widgetId, widgetLayout);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateWidgets(@NonNull final Context context, @NonNull final Song song, boolean isPlaying) {
|
||||
if (song.id == -1) return;
|
||||
widgetLayout = new RemoteViews(context.getPackageName(), R.layout.widget_medium);
|
||||
|
|
@ -53,7 +45,7 @@ public class WidgetMedium extends AppWidgetProvider {
|
|||
public static void updateWidgetsPlayState(@NonNull final Context context, boolean isPlaying) {
|
||||
if (widgetLayout == null)
|
||||
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_dark_36dp : R.drawable.ic_play_arrow_dark_36dp;
|
||||
widgetLayout.setImageViewResource(R.id.button_toggle_play_pause, playPauseRes);
|
||||
updateWidgets(context);
|
||||
}
|
||||
|
|
@ -145,6 +137,14 @@ public class WidgetMedium extends AppWidgetProvider {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(@NonNull Context context, @NonNull AppWidgetManager appWidgetManager, @NonNull int[] appWidgetIds) {
|
||||
updateWidgets(context, MusicPlayerRemote.getCurrentSong(), MusicPlayerRemote.isPlaying());
|
||||
for (int widgetId : appWidgetIds) {
|
||||
appWidgetManager.updateAppWidget(widgetId, widgetLayout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -272,30 +272,30 @@ public class PlayingNotificationHelper {
|
|||
isDark = setDark;
|
||||
|
||||
if (notificationLayout != null && notificationLayoutBig != null) {
|
||||
int darkContentColor = service.getResources().getColor(R.color.notification_dark_text_content_color);
|
||||
int darkContentSecondaryColor = service.getResources().getColor(R.color.notification_dark_text_secondary_content_color);
|
||||
int contentColor = service.getResources().getColor(R.color.notification_content_color);
|
||||
int contentSecondaryColor = service.getResources().getColor(R.color.notification_secondary_content_color);
|
||||
int darkContentColor = service.getResources().getColor(R.color.primary_text_default_material_light);
|
||||
int darkContentSecondaryColor = service.getResources().getColor(R.color.secondary_text_default_material_light);
|
||||
int contentColor = service.getResources().getColor(R.color.primary_text_default_material_dark);
|
||||
int contentSecondaryColor = service.getResources().getColor(R.color.secondary_text_default_material_dark);
|
||||
|
||||
notificationLayout.setTextColor(R.id.title, setDark ? darkContentColor : contentColor);
|
||||
notificationLayout.setTextColor(R.id.text, setDark ? darkContentSecondaryColor : contentSecondaryColor);
|
||||
notificationLayout.setImageViewResource(R.id.action_prev, setDark ? R.drawable.ic_skip_previous_black_36dp : R.drawable.ic_skip_previous_white_36dp);
|
||||
notificationLayout.setImageViewResource(R.id.action_prev, setDark ? R.drawable.ic_skip_previous_dark_36dp : R.drawable.ic_skip_previous_white_36dp);
|
||||
notificationLayout.setImageViewResource(R.id.action_play_pause, getPlayPauseRes());
|
||||
notificationLayout.setImageViewResource(R.id.action_next, setDark ? R.drawable.ic_skip_next_black_36dp : R.drawable.ic_skip_next_white_36dp);
|
||||
notificationLayout.setImageViewResource(R.id.action_next, setDark ? R.drawable.ic_skip_next_dark_36dp : R.drawable.ic_skip_next_white_36dp);
|
||||
|
||||
notificationLayoutBig.setTextColor(R.id.title, setDark ? darkContentColor : contentColor);
|
||||
notificationLayoutBig.setTextColor(R.id.text, setDark ? darkContentSecondaryColor : contentSecondaryColor);
|
||||
notificationLayoutBig.setTextColor(R.id.text2, setDark ? darkContentSecondaryColor : contentSecondaryColor);
|
||||
notificationLayoutBig.setImageViewResource(R.id.action_prev, setDark ? R.drawable.ic_skip_previous_black_36dp : R.drawable.ic_skip_previous_white_36dp);
|
||||
notificationLayoutBig.setImageViewResource(R.id.action_prev, setDark ? R.drawable.ic_skip_previous_dark_36dp : R.drawable.ic_skip_previous_white_36dp);
|
||||
notificationLayoutBig.setImageViewResource(R.id.action_play_pause, getPlayPauseRes());
|
||||
notificationLayoutBig.setImageViewResource(R.id.action_next, setDark ? R.drawable.ic_skip_next_black_36dp : R.drawable.ic_skip_next_white_36dp);
|
||||
notificationLayoutBig.setImageViewResource(R.id.action_quit, setDark ? R.drawable.ic_close_black_24dp : R.drawable.ic_close_white_24dp);
|
||||
notificationLayoutBig.setImageViewResource(R.id.action_next, setDark ? R.drawable.ic_skip_next_dark_36dp : R.drawable.ic_skip_next_white_36dp);
|
||||
notificationLayoutBig.setImageViewResource(R.id.action_quit, setDark ? R.drawable.ic_close_dark_24dp : R.drawable.ic_close_white_24dp);
|
||||
}
|
||||
}
|
||||
|
||||
private int getPlayPauseRes() {
|
||||
return isPlaying ?
|
||||
(isDark ? R.drawable.ic_pause_black_36dp : R.drawable.ic_pause_white_36dp) :
|
||||
(isDark ? R.drawable.ic_play_arrow_black_36dp : R.drawable.ic_play_arrow_white_36dp);
|
||||
(isDark ? R.drawable.ic_pause_dark_36dp : R.drawable.ic_pause_white_36dp) :
|
||||
(isDark ? R.drawable.ic_play_arrow_dark_36dp : R.drawable.ic_play_arrow_white_36dp);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,10 +46,9 @@ public class SearchActivity extends AbsMusicServiceActivity {
|
|||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setStatusBarTransparent();
|
||||
setTitle(null);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_search);
|
||||
setStatusBarTransparent();
|
||||
ButterKnife.bind(this);
|
||||
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
|
|
|
|||
|
|
@ -281,10 +281,10 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
|||
}
|
||||
});
|
||||
|
||||
setMiniPlayerColor(ColorUtil.resolveColor(this, R.attr.card_color));
|
||||
setMiniPlayerColor(ColorUtil.resolveColor(this, R.attr.cardBackgroundColor));
|
||||
|
||||
miniPlayerImage.setImageResource(R.drawable.ic_equalizer_white_24dp);
|
||||
miniPlayerImage.setColorFilter(ColorUtil.resolveColor(this, R.attr.themed_drawable_color));
|
||||
miniPlayerImage.setImageDrawable(Util.getTintedDrawable(this, R.drawable.ic_equalizer_white_24dp,
|
||||
ColorUtil.resolveColor(this, android.R.attr.textColorSecondary)));
|
||||
}
|
||||
|
||||
public void setMiniPlayerColor(int color) {
|
||||
|
|
@ -500,7 +500,7 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
|||
}
|
||||
|
||||
private void setUpPrevNext() {
|
||||
int themedDrawableColor = ColorUtil.resolveColor(this, R.attr.themed_drawable_color);
|
||||
int themedDrawableColor = ColorUtil.resolveColor(this, android.R.attr.textColorSecondary);
|
||||
nextButton.setImageDrawable(Util.getTintedDrawable(this,
|
||||
R.drawable.ic_skip_next_white_36dp, themedDrawableColor));
|
||||
prevButton.setImageDrawable(Util.getTintedDrawable(this,
|
||||
|
|
@ -537,7 +537,7 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
|||
break;
|
||||
default:
|
||||
shuffleButton.setImageDrawable(Util.getTintedDrawable(this, R.drawable.ic_shuffle_white_36dp,
|
||||
ColorUtil.resolveColor(this, R.attr.themed_drawable_color)));
|
||||
ColorUtil.resolveColor(this, android.R.attr.textColorSecondary)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -556,7 +556,7 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
|||
switch (MusicPlayerRemote.getRepeatMode()) {
|
||||
case MusicService.REPEAT_MODE_NONE:
|
||||
repeatButton.setImageDrawable(Util.getTintedDrawable(this, R.drawable.ic_repeat_white_36dp,
|
||||
DialogUtils.resolveColor(this, R.attr.themed_drawable_color)));
|
||||
DialogUtils.resolveColor(this, android.R.attr.textColorSecondary)));
|
||||
break;
|
||||
case MusicService.REPEAT_MODE_ALL:
|
||||
repeatButton.setImageDrawable(Util.getTintedDrawable(this, R.drawable.ic_repeat_white_36dp,
|
||||
|
|
@ -671,18 +671,17 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
|||
}
|
||||
|
||||
private void applyPalette(@Nullable Bitmap bitmap) {
|
||||
final int defaultBarColor = ColorUtil.resolveColor(this, R.attr.default_bar_color);
|
||||
if (bitmap != null) {
|
||||
Palette.from(bitmap)
|
||||
.resizeBitmapSize(100)
|
||||
.resizeBitmapSize(ColorUtil.PALETTE_BITMAP_SIZE)
|
||||
.generate(new Palette.PaletteAsyncListener() {
|
||||
@Override
|
||||
public void onGenerated(@NonNull Palette palette) {
|
||||
setColors(palette.getVibrantColor(defaultBarColor));
|
||||
setColors(ColorUtil.getColor(AbsSlidingMusicPanelActivity.this, palette));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
setColors(defaultBarColor);
|
||||
setColors(ColorUtil.getColor(AbsSlidingMusicPanelActivity.this, null));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import android.graphics.Color;
|
|||
import android.support.annotation.AttrRes;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.graphics.Palette;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
|
|
@ -15,12 +16,35 @@ import com.kabouzeid.gramophone.R;
|
|||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class ColorUtil {
|
||||
public static final int PALETTE_BITMAP_SIZE = 100;
|
||||
|
||||
public static int generateColor(Context context, Bitmap bitmap) {
|
||||
return getColor(context, generatePalette(bitmap));
|
||||
}
|
||||
|
||||
public static Palette generatePalette(Bitmap bitmap) {
|
||||
return Palette.from(bitmap)
|
||||
.resizeBitmapSize(100)
|
||||
.generate()
|
||||
.getVibrantColor(ColorUtil.resolveColor(context, R.attr.default_bar_color));
|
||||
.resizeBitmapSize(PALETTE_BITMAP_SIZE)
|
||||
.generate();
|
||||
}
|
||||
|
||||
public static int getColor(Context context, @Nullable Palette palette) {
|
||||
if (palette != null) {
|
||||
if (palette.getVibrantSwatch() != null) {
|
||||
return palette.getVibrantSwatch().getRgb();
|
||||
} else if (palette.getMutedSwatch() != null) {
|
||||
return palette.getMutedSwatch().getRgb();
|
||||
} else if (palette.getDarkVibrantSwatch() != null) {
|
||||
return palette.getDarkVibrantSwatch().getRgb();
|
||||
} else if (palette.getDarkMutedSwatch() != null) {
|
||||
return palette.getDarkMutedSwatch().getRgb();
|
||||
} else if (palette.getLightVibrantSwatch() != null) {
|
||||
return palette.getLightVibrantSwatch().getRgb();
|
||||
} else if (palette.getLightMutedSwatch() != null) {
|
||||
return palette.getLightMutedSwatch().getRgb();
|
||||
}
|
||||
}
|
||||
return ColorUtil.resolveColor(context, R.attr.default_bar_color);
|
||||
}
|
||||
|
||||
public static int resolveColor(@NonNull Context context, @AttrRes int colorAttr) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue