replace all text color helper methods
This commit is contained in:
parent
5ae5d3017a
commit
a7cb077cee
19 changed files with 96 additions and 96 deletions
|
|
@ -15,9 +15,9 @@ import com.afollestad.materialdialogs.util.DialogUtils;
|
|||
import com.dkanada.gramophone.BuildConfig;
|
||||
import com.dkanada.gramophone.activities.base.AbsMusicContentActivity;
|
||||
import com.dkanada.gramophone.databinding.ActivityAlbumDetailBinding;
|
||||
import com.dkanada.gramophone.util.ThemeUtil;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
||||
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
|
||||
import com.dkanada.gramophone.R;
|
||||
import com.dkanada.gramophone.adapter.song.AlbumSongAdapter;
|
||||
import com.dkanada.gramophone.dialogs.AddToPlaylistDialog;
|
||||
|
|
@ -124,13 +124,13 @@ public class AlbumDetailActivity extends AbsMusicContentActivity implements Pale
|
|||
// needed to auto readjust the toolbar content color
|
||||
setSupportActionBar(binding.toolbar);
|
||||
|
||||
int secondaryTextColor = MaterialValueHelper.getSecondaryTextColor(this, ColorUtil.isColorLight(color));
|
||||
int secondaryTextColor = ThemeUtil.getSecondaryTextColor(this, ColorUtil.isColorLight(color));
|
||||
binding.artistIcon.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
|
||||
binding.durationIcon.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
|
||||
binding.songCountIcon.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
|
||||
binding.albumYearIcon.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
|
||||
|
||||
binding.artistText.setTextColor(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(color)));
|
||||
binding.artistText.setTextColor(ThemeUtil.getPrimaryTextColor(this, ColorUtil.isColorLight(color)));
|
||||
binding.durationText.setTextColor(secondaryTextColor);
|
||||
binding.songCountText.setTextColor(secondaryTextColor);
|
||||
binding.albumYearText.setTextColor(secondaryTextColor);
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ import com.dkanada.gramophone.activities.base.AbsMusicContentActivity;
|
|||
import com.dkanada.gramophone.adapter.song.SongAdapter;
|
||||
import com.dkanada.gramophone.databinding.ActivityArtistDetailBinding;
|
||||
import com.dkanada.gramophone.util.NavigationUtil;
|
||||
import com.dkanada.gramophone.util.ThemeUtil;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
||||
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
|
||||
import com.dkanada.gramophone.R;
|
||||
import com.dkanada.gramophone.adapter.album.HorizontalAlbumAdapter;
|
||||
import com.dkanada.gramophone.dialogs.AddToPlaylistDialog;
|
||||
|
|
@ -174,7 +174,7 @@ public class ArtistDetailActivity extends AbsMusicContentActivity implements Pal
|
|||
// needed to auto readjust the toolbar content color
|
||||
setSupportActionBar(binding.toolbar);
|
||||
|
||||
int secondaryTextColor = MaterialValueHelper.getSecondaryTextColor(this, ColorUtil.isColorLight(color));
|
||||
int secondaryTextColor = ThemeUtil.getSecondaryTextColor(this, ColorUtil.isColorLight(color));
|
||||
binding.durationIcon.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
|
||||
binding.songCountIcon.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
|
||||
binding.albumCountIcon.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import androidx.core.util.Pair;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.dkanada.gramophone.util.QueryUtil;
|
||||
import com.dkanada.gramophone.util.ThemeUtil;
|
||||
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
||||
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
|
||||
import com.dkanada.gramophone.R;
|
||||
import com.dkanada.gramophone.adapter.base.AbsMultiSelectAdapter;
|
||||
import com.dkanada.gramophone.adapter.base.MediaEntryViewHolder;
|
||||
|
|
@ -116,11 +116,11 @@ public class AlbumAdapter extends AbsMultiSelectAdapter<AlbumAdapter.ViewHolder,
|
|||
if (holder.paletteColorContainer != null) {
|
||||
holder.paletteColorContainer.setBackgroundColor(color);
|
||||
if (holder.title != null) {
|
||||
holder.title.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||
holder.title.setTextColor(ThemeUtil.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||
}
|
||||
|
||||
if (holder.text != null) {
|
||||
holder.text.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||
holder.text.setTextColor(ThemeUtil.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import androidx.annotation.Nullable;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.cardview.widget.CardView;
|
||||
|
||||
import com.dkanada.gramophone.util.ThemeUtil;
|
||||
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
||||
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
|
||||
import com.dkanada.gramophone.glide.CustomGlideRequest;
|
||||
import com.dkanada.gramophone.glide.CustomPaletteTarget;
|
||||
import com.dkanada.gramophone.helper.HorizontalAdapterHelper;
|
||||
|
|
@ -39,11 +39,11 @@ public class HorizontalAlbumAdapter extends AlbumAdapter {
|
|||
card.setCardBackgroundColor(color);
|
||||
|
||||
if (holder.title != null) {
|
||||
holder.title.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||
holder.title.setTextColor(ThemeUtil.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||
}
|
||||
|
||||
if (holder.text != null) {
|
||||
holder.text.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||
holder.text.setTextColor(ThemeUtil.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import androidx.core.util.Pair;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.dkanada.gramophone.util.QueryUtil;
|
||||
import com.dkanada.gramophone.util.ThemeUtil;
|
||||
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
||||
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
|
||||
import com.dkanada.gramophone.R;
|
||||
import com.dkanada.gramophone.adapter.base.AbsMultiSelectAdapter;
|
||||
import com.dkanada.gramophone.adapter.base.MediaEntryViewHolder;
|
||||
|
|
@ -109,11 +109,11 @@ public class ArtistAdapter extends AbsMultiSelectAdapter<ArtistAdapter.ViewHolde
|
|||
if (holder.paletteColorContainer != null) {
|
||||
holder.paletteColorContainer.setBackgroundColor(color);
|
||||
if (holder.title != null) {
|
||||
holder.title.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||
holder.title.setTextColor(ThemeUtil.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||
}
|
||||
|
||||
if (holder.text != null) {
|
||||
holder.text.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||
holder.text.setTextColor(ThemeUtil.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import androidx.core.util.Pair;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.afollestad.materialcab.MaterialCab;
|
||||
import com.dkanada.gramophone.util.ThemeUtil;
|
||||
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
||||
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
|
||||
import com.dkanada.gramophone.R;
|
||||
import com.dkanada.gramophone.adapter.base.AbsMultiSelectAdapter;
|
||||
import com.dkanada.gramophone.adapter.base.MediaEntryViewHolder;
|
||||
|
|
@ -120,11 +120,11 @@ public class SongAdapter extends AbsMultiSelectAdapter<SongAdapter.ViewHolder, S
|
|||
if (holder.paletteColorContainer != null) {
|
||||
holder.paletteColorContainer.setBackgroundColor(color);
|
||||
if (holder.title != null) {
|
||||
holder.title.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||
holder.title.setTextColor(ThemeUtil.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||
}
|
||||
|
||||
if (holder.text != null) {
|
||||
holder.text.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||
holder.text.setTextColor(ThemeUtil.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ import androidx.annotation.Nullable;
|
|||
import com.dkanada.gramophone.databinding.FragmentLibraryBinding;
|
||||
import com.dkanada.gramophone.helper.MusicPlayerRemote;
|
||||
import com.dkanada.gramophone.util.ShortcutUtil;
|
||||
import com.dkanada.gramophone.util.ThemeUtil;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.afollestad.materialcab.MaterialCab;
|
||||
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
||||
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
|
||||
import com.dkanada.gramophone.R;
|
||||
import com.dkanada.gramophone.adapter.MusicLibraryPagerAdapter;
|
||||
import com.dkanada.gramophone.dialogs.CreatePlaylistDialog;
|
||||
|
|
@ -104,8 +104,8 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
binding.tabs.setupWithViewPager(binding.pager);
|
||||
|
||||
int primaryColor = PreferenceUtil.getInstance(requireActivity()).getPrimaryColor();
|
||||
int normalColor = MaterialValueHelper.getSecondaryTextColor(requireActivity(), ColorUtil.isColorLight(primaryColor));
|
||||
int selectedColor = MaterialValueHelper.getPrimaryTextColor(requireActivity(), ColorUtil.isColorLight(primaryColor));
|
||||
int normalColor = ThemeUtil.getSecondaryTextColor(requireActivity(), ColorUtil.isColorLight(primaryColor));
|
||||
int selectedColor = ThemeUtil.getPrimaryTextColor(requireActivity(), ColorUtil.isColorLight(primaryColor));
|
||||
binding.tabs.setTabTextColors(normalColor, selectedColor);
|
||||
binding.tabs.setSelectedTabIndicatorColor(PreferenceUtil.getInstance(requireActivity()).getAccentColor());
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ import android.widget.SeekBar;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.dkanada.gramophone.util.ThemeUtil;
|
||||
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
||||
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
|
||||
import com.kabouzeid.appthemehelper.util.TintHelper;
|
||||
import com.dkanada.gramophone.R;
|
||||
import com.dkanada.gramophone.helper.MusicPlayerRemote;
|
||||
|
|
@ -98,11 +98,11 @@ public class CardPlayerPlaybackControlsFragment extends AbsMusicServiceFragment
|
|||
|
||||
public void setDark(boolean dark) {
|
||||
if (dark) {
|
||||
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(requireActivity(), true);
|
||||
lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(requireActivity(), true);
|
||||
lastPlaybackControlsColor = ThemeUtil.getSecondaryTextColor(requireActivity(), true);
|
||||
lastDisabledPlaybackControlsColor = ThemeUtil.getDisabledTextColor(ThemeUtil.getSecondaryTextColor(requireActivity(), true));
|
||||
} else {
|
||||
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(requireActivity(), false);
|
||||
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(requireActivity(), false);
|
||||
lastPlaybackControlsColor = ThemeUtil.getPrimaryTextColor(requireActivity(), false);
|
||||
lastDisabledPlaybackControlsColor = ThemeUtil.getDisabledTextColor(ThemeUtil.getPrimaryTextColor(requireActivity(), false));
|
||||
}
|
||||
|
||||
updateRepeatState();
|
||||
|
|
@ -118,7 +118,7 @@ public class CardPlayerPlaybackControlsFragment extends AbsMusicServiceFragment
|
|||
playerFabPlayPauseDrawable = new PlayPauseDrawable(requireActivity());
|
||||
|
||||
binding.playerPlayPauseFab.setImageDrawable(playerFabPlayPauseDrawable); // Note: set the drawable AFTER TintHelper.setTintAuto() was called
|
||||
binding.playerPlayPauseFab.setColorFilter(MaterialValueHelper.getPrimaryTextColor(requireContext(), ColorUtil.isColorLight(fabColor)), PorterDuff.Mode.SRC_IN);
|
||||
binding.playerPlayPauseFab.setColorFilter(ThemeUtil.getPrimaryTextColor(requireContext(), ColorUtil.isColorLight(fabColor)), PorterDuff.Mode.SRC_IN);
|
||||
binding.playerPlayPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler());
|
||||
binding.playerPlayPauseFab.post(() -> {
|
||||
binding.playerPlayPauseFab.setPivotX(binding.playerPlayPauseFab.getWidth() / 2f);
|
||||
|
|
@ -154,7 +154,7 @@ public class CardPlayerPlaybackControlsFragment extends AbsMusicServiceFragment
|
|||
}
|
||||
|
||||
private void updateProgressTextColor() {
|
||||
int color = MaterialValueHelper.getPrimaryTextColor(requireContext(), false);
|
||||
int color = ThemeUtil.getPrimaryTextColor(requireContext(), false);
|
||||
binding.playerSongTotalTime.setTextColor(color);
|
||||
binding.playerSongCurrentProgress.setTextColor(color);
|
||||
}
|
||||
|
|
@ -217,7 +217,7 @@ public class CardPlayerPlaybackControlsFragment extends AbsMusicServiceFragment
|
|||
}
|
||||
|
||||
private void setUpProgressSlider() {
|
||||
int color = MaterialValueHelper.getPrimaryTextColor(requireContext(), false);
|
||||
int color = ThemeUtil.getPrimaryTextColor(requireContext(), false);
|
||||
binding.playerProgressSlider.getThumb().mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
binding.playerProgressSlider.getProgressDrawable().mutate().setColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_IN);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import androidx.annotation.NonNull;
|
|||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
|
||||
|
||||
import com.dkanada.gramophone.databinding.FragmentFlatPlayerPlaybackControlsBinding;
|
||||
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
|
||||
import com.dkanada.gramophone.util.ThemeUtil;
|
||||
import com.dkanada.gramophone.R;
|
||||
import com.dkanada.gramophone.helper.MusicPlayerRemote;
|
||||
import com.dkanada.gramophone.helper.MusicProgressViewUpdateHelper;
|
||||
|
|
@ -106,11 +106,11 @@ public class FlatPlayerPlaybackControlsFragment extends AbsMusicServiceFragment
|
|||
|
||||
public void setDark(boolean dark) {
|
||||
if (dark) {
|
||||
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(requireActivity(), true);
|
||||
lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(requireActivity(), true);
|
||||
lastPlaybackControlsColor = ThemeUtil.getSecondaryTextColor(requireActivity(), true);
|
||||
lastDisabledPlaybackControlsColor = ThemeUtil.getDisabledTextColor(ThemeUtil.getSecondaryTextColor(requireActivity(), true));
|
||||
} else {
|
||||
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(requireActivity(), false);
|
||||
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(requireActivity(), false);
|
||||
lastPlaybackControlsColor = ThemeUtil.getPrimaryTextColor(requireActivity(), false);
|
||||
lastDisabledPlaybackControlsColor = ThemeUtil.getDisabledTextColor(ThemeUtil.getPrimaryTextColor(requireActivity(), false));
|
||||
}
|
||||
|
||||
updateRepeatState();
|
||||
|
|
@ -159,7 +159,7 @@ public class FlatPlayerPlaybackControlsFragment extends AbsMusicServiceFragment
|
|||
}
|
||||
|
||||
private void updateProgressTextColor() {
|
||||
int color = MaterialValueHelper.getPrimaryTextColor(requireContext(), false);
|
||||
int color = ThemeUtil.getPrimaryTextColor(requireContext(), false);
|
||||
binding.playerSongTotalTime.setTextColor(color);
|
||||
binding.playerSongCurrentProgress.setTextColor(color);
|
||||
}
|
||||
|
|
@ -272,7 +272,7 @@ public class FlatPlayerPlaybackControlsFragment extends AbsMusicServiceFragment
|
|||
}
|
||||
|
||||
private void setUpProgressSlider() {
|
||||
int color = MaterialValueHelper.getPrimaryTextColor(requireContext(), false);
|
||||
int color = ThemeUtil.getPrimaryTextColor(requireContext(), false);
|
||||
binding.playerProgressSlider.getThumb().mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
binding.playerProgressSlider.getProgressDrawable().mutate().setColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_IN);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ package com.dkanada.gramophone.glide.palette;
|
|||
import android.graphics.Bitmap;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.palette.graphics.Palette;
|
||||
|
||||
import com.bumptech.glide.load.Options;
|
||||
import com.bumptech.glide.load.engine.Resource;
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||
import com.bumptech.glide.load.resource.transcode.ResourceTranscoder;
|
||||
import com.dkanada.gramophone.util.ThemeUtil;
|
||||
|
||||
public class BitmapPaletteTranscoder implements ResourceTranscoder<Bitmap, BitmapPaletteWrapper> {
|
||||
private final BitmapPool bitmapPool;
|
||||
|
|
@ -19,7 +19,7 @@ public class BitmapPaletteTranscoder implements ResourceTranscoder<Bitmap, Bitma
|
|||
|
||||
@Override
|
||||
public Resource<BitmapPaletteWrapper> transcode(@NonNull Resource<Bitmap> resource, @NonNull Options options) {
|
||||
BitmapPaletteWrapper bitmapPaletteWrapper = new BitmapPaletteWrapper(resource.get(), ThemeUtil.generatePalette(resource.get()));
|
||||
BitmapPaletteWrapper bitmapPaletteWrapper = new BitmapPaletteWrapper(resource.get(), Palette.from(resource.get()).generate());
|
||||
return new BitmapPaletteResource(bitmapPaletteWrapper, bitmapPool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import com.bumptech.glide.request.target.CustomTarget;
|
|||
import com.bumptech.glide.request.target.Target;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
||||
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
|
||||
import com.dkanada.gramophone.R;
|
||||
import com.dkanada.gramophone.glide.CustomGlideRequest;
|
||||
import com.dkanada.gramophone.glide.palette.BitmapPaletteWrapper;
|
||||
|
|
@ -139,8 +138,8 @@ public class PlayingNotificationMarshmallow extends PlayingNotification {
|
|||
}
|
||||
|
||||
private void setNotificationContent(boolean dark) {
|
||||
int primary = MaterialValueHelper.getPrimaryTextColor(service, dark);
|
||||
int secondary = MaterialValueHelper.getSecondaryTextColor(service, dark);
|
||||
int primary = ThemeUtil.getPrimaryTextColor(service, dark);
|
||||
int secondary = ThemeUtil.getSecondaryTextColor(service, dark);
|
||||
|
||||
Bitmap prev = ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp, primary), 1.5f);
|
||||
Bitmap next = ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp, primary), 1.5f);
|
||||
|
|
|
|||
|
|
@ -1,25 +1,20 @@
|
|||
package com.dkanada.gramophone.util;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Bitmap;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.palette.graphics.Palette;
|
||||
|
||||
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
||||
import com.dkanada.gramophone.R;
|
||||
import com.google.android.material.color.MaterialColors;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class ThemeUtil {
|
||||
@Nullable
|
||||
public static Palette generatePalette(Bitmap bitmap) {
|
||||
if (bitmap == null) return null;
|
||||
|
||||
return Palette.from(bitmap).generate();
|
||||
}
|
||||
|
||||
public static ColorStateList getColorStateList(int normal, int active) {
|
||||
int[][] states = new int[][]{
|
||||
new int[]{-android.R.attr.state_checked},
|
||||
|
|
@ -57,6 +52,25 @@ public class ThemeUtil {
|
|||
return fallback;
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int getPrimaryTextColor(Context context, boolean light) {
|
||||
return light
|
||||
? ContextCompat.getColor(context, R.color.color_text_primary_light)
|
||||
: ContextCompat.getColor(context, R.color.color_text_primary_dark);
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int getSecondaryTextColor(Context context, boolean light) {
|
||||
return light
|
||||
? ContextCompat.getColor(context, R.color.color_text_secondary_light)
|
||||
: ContextCompat.getColor(context, R.color.color_text_secondary_dark);
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int getDisabledTextColor(int color) {
|
||||
return MaterialColors.compositeARGBWithAlpha(color, 140);
|
||||
}
|
||||
|
||||
private static class SwatchComparator implements Comparator<Palette.Swatch> {
|
||||
private static SwatchComparator sInstance;
|
||||
|
||||
|
|
@ -73,22 +87,4 @@ public class ThemeUtil {
|
|||
return lhs.getPopulation() - rhs.getPopulation();
|
||||
}
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int shiftBackgroundColorForLightText(@ColorInt int backgroundColor) {
|
||||
while (ColorUtil.isColorLight(backgroundColor)) {
|
||||
backgroundColor = ColorUtil.darkenColor(backgroundColor);
|
||||
}
|
||||
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int shiftBackgroundColorForDarkText(@ColorInt int backgroundColor) {
|
||||
while (!ColorUtil.isColorLight(backgroundColor)) {
|
||||
backgroundColor = ColorUtil.lightenColor(backgroundColor);
|
||||
}
|
||||
|
||||
return backgroundColor;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import androidx.annotation.ColorInt;
|
|||
|
||||
import com.kabouzeid.appthemehelper.util.ATHUtil;
|
||||
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
||||
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
|
||||
import com.dkanada.gramophone.R;
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView;
|
||||
|
||||
|
|
@ -79,7 +78,7 @@ public class ViewUtil {
|
|||
|
||||
public static void setUpFastScrollRecyclerViewColor(Context context, FastScrollRecyclerView recyclerView, int accentColor) {
|
||||
recyclerView.setPopupBgColor(accentColor);
|
||||
recyclerView.setPopupTextColor(MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(accentColor)));
|
||||
recyclerView.setPopupTextColor(ThemeUtil.getPrimaryTextColor(context, ColorUtil.isColorLight(accentColor)));
|
||||
recyclerView.setThumbColor(accentColor);
|
||||
recyclerView.setTrackColor(ColorUtil.withAlpha(ATHUtil.resolveColor(context, R.attr.colorControlNormal), 0.12f));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ public class ColorCircleDrawable extends View {
|
|||
super(context, attrs);
|
||||
|
||||
TypedArray attributes = getContext().obtainStyledAttributes(new int[]{android.R.attr.divider});
|
||||
int colorCircle = getContext().getResources().getColor(android.R.color.black);
|
||||
int colorBorder = getContext().getResources().getColor(android.R.color.darker_gray);
|
||||
int colorCircle = getContext().getResources().getColor(android.R.color.white);
|
||||
int colorBorder = getContext().getResources().getColor(android.R.color.black);
|
||||
|
||||
circle.setAntiAlias(true);
|
||||
circle.setColor(colorCircle);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import com.bumptech.glide.Glide;
|
|||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
|
||||
import com.dkanada.gramophone.util.ThemeUtil;
|
||||
import com.dkanada.gramophone.R;
|
||||
import com.dkanada.gramophone.glide.CustomGlideRequest;
|
||||
import com.dkanada.gramophone.model.Song;
|
||||
|
|
@ -55,9 +55,9 @@ public class AppWidgetAlbum extends BaseAppWidget {
|
|||
|
||||
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE);
|
||||
appWidgetView.setImageViewBitmap(R.id.image, createRoundedBitmap(BitmapFactory.decodeResource(context.getResources(), R.drawable.default_album_art), imageSize, imageSize, cardRadius, cardRadius, cardRadius, cardRadius));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_next, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, MaterialValueHelper.getPrimaryTextColor(context, false))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_prev, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, MaterialValueHelper.getPrimaryTextColor(context, false))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp, MaterialValueHelper.getPrimaryTextColor(context, false))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_next, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, ThemeUtil.getPrimaryTextColor(context, false))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_prev, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, ThemeUtil.getPrimaryTextColor(context, false))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp, ThemeUtil.getPrimaryTextColor(context, false))));
|
||||
|
||||
linkButtons(context, appWidgetView, R.id.clickable_area);
|
||||
pushUpdate(context, appWidgetIds, appWidgetView);
|
||||
|
|
@ -79,10 +79,10 @@ public class AppWidgetAlbum extends BaseAppWidget {
|
|||
}
|
||||
|
||||
int playPauseRes = isPlaying ? R.drawable.ic_pause_white_24dp : R.drawable.ic_play_arrow_white_24dp;
|
||||
appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(service, playPauseRes, MaterialValueHelper.getPrimaryTextColor(service, false))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(service, playPauseRes, ThemeUtil.getPrimaryTextColor(service, false))));
|
||||
|
||||
appWidgetView.setImageViewBitmap(R.id.button_next, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp, MaterialValueHelper.getPrimaryTextColor(service, false))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_prev, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp, MaterialValueHelper.getPrimaryTextColor(service, false))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_next, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp, ThemeUtil.getPrimaryTextColor(service, false))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_prev, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp, ThemeUtil.getPrimaryTextColor(service, false))));
|
||||
|
||||
linkButtons(service, appWidgetView, R.id.clickable_area);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import com.bumptech.glide.Glide;
|
|||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
|
||||
import com.dkanada.gramophone.util.ThemeUtil;
|
||||
import com.dkanada.gramophone.R;
|
||||
import com.dkanada.gramophone.glide.CustomGlideRequest;
|
||||
import com.dkanada.gramophone.glide.palette.BitmapPaletteWrapper;
|
||||
|
|
@ -53,9 +53,9 @@ public class AppWidgetCard extends BaseAppWidget {
|
|||
|
||||
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE);
|
||||
appWidgetView.setImageViewBitmap(R.id.image, createRoundedBitmap(BitmapFactory.decodeResource(context.getResources(), R.drawable.default_album_art), imageSize, imageSize, cardRadius, 0, cardRadius, 0));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_next, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_prev, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_next, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, ThemeUtil.getSecondaryTextColor(context, true))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_prev, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, ThemeUtil.getSecondaryTextColor(context, true))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp, ThemeUtil.getSecondaryTextColor(context, true))));
|
||||
|
||||
linkButtons(context, appWidgetView, R.id.image, R.id.media_titles);
|
||||
pushUpdate(context, appWidgetIds, appWidgetView);
|
||||
|
|
@ -77,10 +77,10 @@ public class AppWidgetCard extends BaseAppWidget {
|
|||
}
|
||||
|
||||
int playPauseRes = isPlaying ? R.drawable.ic_pause_white_24dp : R.drawable.ic_play_arrow_white_24dp;
|
||||
appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(service, playPauseRes, MaterialValueHelper.getSecondaryTextColor(service, true))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(service, playPauseRes, ThemeUtil.getSecondaryTextColor(service, true))));
|
||||
|
||||
appWidgetView.setImageViewBitmap(R.id.button_next, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp, MaterialValueHelper.getSecondaryTextColor(service, true))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_prev, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp, MaterialValueHelper.getSecondaryTextColor(service, true))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_next, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp, ThemeUtil.getSecondaryTextColor(service, true))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_prev, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp, ThemeUtil.getSecondaryTextColor(service, true))));
|
||||
|
||||
linkButtons(service, appWidgetView, R.id.image, R.id.media_titles);
|
||||
|
||||
|
|
@ -101,19 +101,19 @@ public class AppWidgetCard extends BaseAppWidget {
|
|||
@Override
|
||||
public void onResourceReady(@NonNull BitmapPaletteWrapper resource, Transition<? super BitmapPaletteWrapper> glideAnimation) {
|
||||
Palette palette = resource.getPalette();
|
||||
update(resource.getBitmap(), palette.getVibrantColor(palette.getMutedColor(MaterialValueHelper.getSecondaryTextColor(service, true))));
|
||||
update(resource.getBitmap(), palette.getVibrantColor(palette.getMutedColor(ThemeUtil.getSecondaryTextColor(service, true))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(Drawable drawable) {
|
||||
super.onLoadFailed(drawable);
|
||||
update(null, MaterialValueHelper.getSecondaryTextColor(service, true));
|
||||
update(null, ThemeUtil.getSecondaryTextColor(service, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(Drawable drawable) {
|
||||
super.onLoadFailed(drawable);
|
||||
update(null, MaterialValueHelper.getSecondaryTextColor(service, true));
|
||||
update(null, ThemeUtil.getSecondaryTextColor(service, true));
|
||||
}
|
||||
|
||||
private void update(@Nullable Bitmap bitmap, int color) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import com.bumptech.glide.Glide;
|
|||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
|
||||
import com.dkanada.gramophone.util.ThemeUtil;
|
||||
import com.dkanada.gramophone.R;
|
||||
import com.dkanada.gramophone.glide.CustomGlideRequest;
|
||||
import com.dkanada.gramophone.glide.palette.BitmapPaletteWrapper;
|
||||
|
|
@ -53,9 +53,9 @@ public class AppWidgetClassic extends BaseAppWidget {
|
|||
|
||||
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE);
|
||||
appWidgetView.setImageViewBitmap(R.id.image, createRoundedBitmap(BitmapFactory.decodeResource(context.getResources(), R.drawable.default_album_art), imageSize, imageSize, cardRadius, 0, cardRadius, 0));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_next, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_prev, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_next, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, ThemeUtil.getSecondaryTextColor(context, true))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_prev, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, ThemeUtil.getSecondaryTextColor(context, true))));
|
||||
appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp, ThemeUtil.getSecondaryTextColor(context, true))));
|
||||
|
||||
linkButtons(context, appWidgetView, R.id.image, R.id.media_titles);
|
||||
pushUpdate(context, appWidgetIds, appWidgetView);
|
||||
|
|
@ -95,19 +95,19 @@ public class AppWidgetClassic extends BaseAppWidget {
|
|||
@Override
|
||||
public void onResourceReady(@NonNull BitmapPaletteWrapper resource, Transition<? super BitmapPaletteWrapper> glideAnimation) {
|
||||
Palette palette = resource.getPalette();
|
||||
update(resource.getBitmap(), palette.getVibrantColor(palette.getMutedColor(MaterialValueHelper.getSecondaryTextColor(service, true))));
|
||||
update(resource.getBitmap(), palette.getVibrantColor(palette.getMutedColor(ThemeUtil.getSecondaryTextColor(service, true))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(Drawable drawable) {
|
||||
super.onLoadFailed(drawable);
|
||||
update(null, MaterialValueHelper.getSecondaryTextColor(service, true));
|
||||
update(null, ThemeUtil.getSecondaryTextColor(service, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(Drawable drawable) {
|
||||
super.onLoadFailed(drawable);
|
||||
update(null, MaterialValueHelper.getSecondaryTextColor(service, true));
|
||||
update(null, ThemeUtil.getSecondaryTextColor(service, true));
|
||||
}
|
||||
|
||||
private void update(@Nullable Bitmap bitmap, int color) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<attr name="rectSelector" format="reference" />
|
||||
<attr name="rectSelectorStrong" format="reference" />
|
||||
|
||||
<attr name="cardBackgroundColor" format="color" />
|
||||
<attr name="defaultFooterColor" format="color" />
|
||||
|
||||
<attr name="toolbarPopupTheme" format="reference" />
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@
|
|||
<color name="color_shortcut_foreground">#607D8B</color>
|
||||
<color name="color_shortcut_background">#F5F5F5</color>
|
||||
|
||||
<color name="color_text_primary_light">#DE000000</color>
|
||||
<color name="color_text_secondary_light">#8A000000</color>
|
||||
<color name="color_text_primary_dark">#FFFFFFFF</color>
|
||||
<color name="color_text_secondary_dark">#B3FFFFFF</color>
|
||||
|
||||
<color name="overlay_text">#FFFFFFFF</color>
|
||||
<color name="overlay_dark">#80000000</color>
|
||||
<color name="overlay_light">#40000000</color>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue