improve theme utilities and fix issue with color drawable

This commit is contained in:
dkanada 2021-06-16 13:13:47 +09:00
commit 2c7113ecb9
17 changed files with 72 additions and 85 deletions

View file

@ -64,7 +64,7 @@ dependencies {
implementation 'com.github.jellyfin.jellyfin-apiclient-java:android:0.7.3'
implementation 'com.github.woltapp:blurhash:f41a23cc50'
implementation 'com.google.android.exoplayer:exoplayer:2.12.2'
implementation 'com.google.android.material:material:1.3.0'
implementation 'com.google.android.material:material:1.4.0-rc01'
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.media:media:1.3.1'

View file

@ -8,10 +8,11 @@ import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import com.kabouzeid.appthemehelper.util.ColorUtil;
import com.dkanada.gramophone.util.ThemeUtil;
import com.dkanada.gramophone.R;
import com.dkanada.gramophone.util.PreferenceUtil;
import com.dkanada.gramophone.util.Util;
import com.google.android.material.color.MaterialColors;
public abstract class AbsThemeActivity extends AppCompatActivity {
private int currentTheme;
@ -41,7 +42,7 @@ public abstract class AbsThemeActivity extends AppCompatActivity {
}
public void setColor(int color) {
boolean light = ColorUtil.isColorLight(color);
boolean light = MaterialColors.isColorLight(color);
setLightStatusBar(light);
setLightNavigationBar(light);
@ -62,7 +63,7 @@ public abstract class AbsThemeActivity extends AppCompatActivity {
public void setStatusBarColor(int color) {
View statusBar = getWindow().getDecorView().getRootView().findViewById(R.id.status_bar);
int dark = ColorUtil.darkenColor(color);
int dark = ThemeUtil.getColorDark(color);
// KitKat through Lollipop will do this automatically
if (statusBar != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
@ -76,7 +77,7 @@ public abstract class AbsThemeActivity extends AppCompatActivity {
}
public void setTaskDescriptionColor(int color) {
int solid = ColorUtil.stripAlpha(color);
int solid = MaterialColors.compositeARGBWithAlpha(color, 255);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setTaskDescription(new ActivityManager.TaskDescription(getTitle().toString(), null, solid));

View file

@ -17,7 +17,6 @@ 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.dkanada.gramophone.R;
import com.dkanada.gramophone.adapter.song.AlbumSongAdapter;
import com.dkanada.gramophone.dialogs.AddToPlaylistDialog;
@ -124,13 +123,13 @@ public class AlbumDetailActivity extends AbsMusicContentActivity implements Pale
// needed to auto readjust the toolbar content color
setSupportActionBar(binding.toolbar);
int secondaryTextColor = ThemeUtil.getSecondaryTextColor(this, ColorUtil.isColorLight(color));
int secondaryTextColor = ThemeUtil.getSecondaryTextColor(this, 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(ThemeUtil.getPrimaryTextColor(this, ColorUtil.isColorLight(color)));
binding.artistText.setTextColor(ThemeUtil.getPrimaryTextColor(this, color));
binding.durationText.setTextColor(secondaryTextColor);
binding.songCountText.setTextColor(secondaryTextColor);
binding.albumYearText.setTextColor(secondaryTextColor);

View file

@ -20,7 +20,6 @@ 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.dkanada.gramophone.R;
import com.dkanada.gramophone.adapter.album.HorizontalAlbumAdapter;
import com.dkanada.gramophone.dialogs.AddToPlaylistDialog;
@ -174,7 +173,7 @@ public class ArtistDetailActivity extends AbsMusicContentActivity implements Pal
// needed to auto readjust the toolbar content color
setSupportActionBar(binding.toolbar);
int secondaryTextColor = ThemeUtil.getSecondaryTextColor(this, ColorUtil.isColorLight(color));
int secondaryTextColor = ThemeUtil.getSecondaryTextColor(this, 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);

View file

@ -14,7 +14,6 @@ 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.dkanada.gramophone.R;
import com.dkanada.gramophone.adapter.base.AbsMultiSelectAdapter;
import com.dkanada.gramophone.adapter.base.MediaEntryViewHolder;
@ -116,11 +115,11 @@ public class AlbumAdapter extends AbsMultiSelectAdapter<AlbumAdapter.ViewHolder,
if (holder.paletteColorContainer != null) {
holder.paletteColorContainer.setBackgroundColor(color);
if (holder.title != null) {
holder.title.setTextColor(ThemeUtil.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
holder.title.setTextColor(ThemeUtil.getPrimaryTextColor(activity, color));
}
if (holder.text != null) {
holder.text.setTextColor(ThemeUtil.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
holder.text.setTextColor(ThemeUtil.getSecondaryTextColor(activity, color));
}
}
}

View file

@ -10,7 +10,6 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import com.dkanada.gramophone.util.ThemeUtil;
import com.kabouzeid.appthemehelper.util.ColorUtil;
import com.dkanada.gramophone.glide.CustomGlideRequest;
import com.dkanada.gramophone.glide.CustomPaletteTarget;
import com.dkanada.gramophone.helper.HorizontalAdapterHelper;
@ -39,11 +38,11 @@ public class HorizontalAlbumAdapter extends AlbumAdapter {
card.setCardBackgroundColor(color);
if (holder.title != null) {
holder.title.setTextColor(ThemeUtil.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
holder.title.setTextColor(ThemeUtil.getPrimaryTextColor(activity, color));
}
if (holder.text != null) {
holder.text.setTextColor(ThemeUtil.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
holder.text.setTextColor(ThemeUtil.getSecondaryTextColor(activity, color));
}
}

View file

@ -14,7 +14,6 @@ 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.dkanada.gramophone.R;
import com.dkanada.gramophone.adapter.base.AbsMultiSelectAdapter;
import com.dkanada.gramophone.adapter.base.MediaEntryViewHolder;
@ -109,11 +108,11 @@ public class ArtistAdapter extends AbsMultiSelectAdapter<ArtistAdapter.ViewHolde
if (holder.paletteColorContainer != null) {
holder.paletteColorContainer.setBackgroundColor(color);
if (holder.title != null) {
holder.title.setTextColor(ThemeUtil.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
holder.title.setTextColor(ThemeUtil.getPrimaryTextColor(activity, color));
}
if (holder.text != null) {
holder.text.setTextColor(ThemeUtil.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
holder.text.setTextColor(ThemeUtil.getSecondaryTextColor(activity, color));
}
}
}

View file

@ -14,7 +14,6 @@ import androidx.appcompat.app.AppCompatActivity;
import com.afollestad.materialcab.MaterialCab;
import com.dkanada.gramophone.util.ThemeUtil;
import com.kabouzeid.appthemehelper.util.ColorUtil;
import com.dkanada.gramophone.R;
import com.dkanada.gramophone.adapter.base.AbsMultiSelectAdapter;
import com.dkanada.gramophone.adapter.base.MediaEntryViewHolder;
@ -120,11 +119,11 @@ public class SongAdapter extends AbsMultiSelectAdapter<SongAdapter.ViewHolder, S
if (holder.paletteColorContainer != null) {
holder.paletteColorContainer.setBackgroundColor(color);
if (holder.title != null) {
holder.title.setTextColor(ThemeUtil.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
holder.title.setTextColor(ThemeUtil.getPrimaryTextColor(activity, color));
}
if (holder.text != null) {
holder.text.setTextColor(ThemeUtil.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
holder.text.setTextColor(ThemeUtil.getSecondaryTextColor(activity, color));
}
}
}

View file

@ -22,7 +22,6 @@ 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.dkanada.gramophone.R;
import com.dkanada.gramophone.adapter.MusicLibraryPagerAdapter;
import com.dkanada.gramophone.dialogs.CreatePlaylistDialog;
@ -104,8 +103,8 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
binding.tabs.setupWithViewPager(binding.pager);
int primaryColor = PreferenceUtil.getInstance(requireActivity()).getPrimaryColor();
int normalColor = ThemeUtil.getSecondaryTextColor(requireActivity(), ColorUtil.isColorLight(primaryColor));
int selectedColor = ThemeUtil.getPrimaryTextColor(requireActivity(), ColorUtil.isColorLight(primaryColor));
int normalColor = ThemeUtil.getSecondaryTextColor(requireActivity(), primaryColor);
int selectedColor = ThemeUtil.getPrimaryTextColor(requireActivity(), primaryColor);
binding.tabs.setTabTextColors(normalColor, selectedColor);
binding.tabs.setSelectedTabIndicatorColor(PreferenceUtil.getInstance(requireActivity()).getAccentColor());

View file

@ -17,18 +17,17 @@ import android.widget.ImageView;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.dkanada.gramophone.databinding.FragmentCardPlayerBinding;
import com.dkanada.gramophone.util.ThemeUtil;
import com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator;
import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator;
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
import com.kabouzeid.appthemehelper.ThemeStore;
import com.kabouzeid.appthemehelper.util.ATHUtil;
import com.kabouzeid.appthemehelper.util.ColorUtil;
import com.dkanada.gramophone.R;
import com.dkanada.gramophone.adapter.base.MediaEntryViewHolder;
import com.dkanada.gramophone.adapter.song.PlayingQueueAdapter;
@ -44,6 +43,7 @@ import com.dkanada.gramophone.util.MusicUtil;
import com.dkanada.gramophone.util.Util;
import com.dkanada.gramophone.util.ViewUtil;
import com.dkanada.gramophone.views.WidthFitSquareLayout;
import com.google.android.material.color.MaterialColors;
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbumCoverFragment.Callbacks, SlidingUpPanelLayout.PanelSlideListener {
@ -224,7 +224,7 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
private void updateIsFavorite() {
boolean favorite = MusicPlayerRemote.getCurrentSong().favorite;
int res = favorite ? R.drawable.ic_favorite_white_24dp : R.drawable.ic_favorite_border_white_24dp;
int color = ContextCompat.getColor(requireContext(), android.R.color.white);
int color = ThemeUtil.getColorResource(requireContext(), android.R.color.white, 255);
Drawable drawable = ImageUtil.getTintedVectorDrawable(getActivity(), res, color);
binding.playerToolbar.getMenu().findItem(R.id.action_toggle_favorite)
@ -277,7 +277,7 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
@Override
public void onColorChanged(int color) {
animateColorChange(color);
playbackControlsFragment.setDark(ColorUtil.isColorLight(color));
playbackControlsFragment.setDark(MaterialColors.isColorLight(color));
playbackControlsFragment.updateBufferingIndicatorColor(color);
getCallbacks().onPaletteColorChanged();
}
@ -359,23 +359,9 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
animatorSet.play(backgroundAnimator);
if (!ATHUtil.isWindowBackgroundDark(fragment.getActivity())) {
int adjustedLastColor = ColorUtil.isColorLight(fragment.lastColor) ? ColorUtil.darkenColor(fragment.lastColor) : fragment.lastColor;
int adjustedNewColor = ColorUtil.isColorLight(newColor) ? ColorUtil.darkenColor(newColor) : newColor;
Animator subHeaderAnimator = ViewUtil.createTextColorTransition(binding.playerQueueSubHeader, adjustedLastColor, adjustedNewColor);
animatorSet.play(subHeaderAnimator);
}
animatorSet.setDuration(ViewUtil.PHONOGRAPH_ANIM_TIME);
return animatorSet;
}
@Override
public void animateColorChange(int newColor) {
if (ATHUtil.isWindowBackgroundDark(fragment.getActivity())) {
binding.playerQueueSubHeader.setTextColor(ThemeStore.textColorSecondary(fragment.getActivity()));
}
}
}
@SuppressWarnings("ConstantConditions")
@ -454,8 +440,6 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
@Override
public void animateColorChange(int newColor) {
super.animateColorChange(newColor);
binding.playerSlidingLayout.setBackgroundColor(fragment.lastColor);
createDefaultColorChangeAnimatorSet(newColor).start();
}
@ -487,13 +471,11 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
@Override
public void animateColorChange(int newColor) {
super.animateColorChange(newColor);
binding.playerSlidingLayout.setBackgroundColor(fragment.lastColor);
AnimatorSet animatorSet = createDefaultColorChangeAnimatorSet(newColor);
animatorSet.play(ViewUtil.createBackgroundColorTransition(binding.playerToolbar, fragment.lastColor, newColor))
.with(ViewUtil.createBackgroundColorTransition(fragment.getView().findViewById(R.id.status_bar), ColorUtil.darkenColor(fragment.lastColor), ColorUtil.darkenColor(newColor)));
.with(ViewUtil.createBackgroundColorTransition(fragment.getView().findViewById(R.id.status_bar), ThemeUtil.getColorDark(fragment.lastColor), ThemeUtil.getColorDark(newColor)));
animatorSet.start();
}

View file

@ -13,7 +13,6 @@ 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.TintHelper;
import com.dkanada.gramophone.R;
import com.dkanada.gramophone.helper.MusicPlayerRemote;
@ -99,10 +98,10 @@ public class CardPlayerPlaybackControlsFragment extends AbsMusicServiceFragment
public void setDark(boolean dark) {
if (dark) {
lastPlaybackControlsColor = ThemeUtil.getSecondaryTextColor(requireActivity(), true);
lastDisabledPlaybackControlsColor = ThemeUtil.getDisabledTextColor(ThemeUtil.getSecondaryTextColor(requireActivity(), true));
lastDisabledPlaybackControlsColor = ThemeUtil.getColorAlpha(requireActivity(), R.color.color_text_secondary_light, 180);
} else {
lastPlaybackControlsColor = ThemeUtil.getPrimaryTextColor(requireActivity(), false);
lastDisabledPlaybackControlsColor = ThemeUtil.getDisabledTextColor(ThemeUtil.getPrimaryTextColor(requireActivity(), false));
lastDisabledPlaybackControlsColor = ThemeUtil.getColorAlpha(requireActivity(), R.color.color_text_primary_dark, 180);
}
updateRepeatState();
@ -117,8 +116,8 @@ 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(ThemeUtil.getPrimaryTextColor(requireContext(), ColorUtil.isColorLight(fabColor)), PorterDuff.Mode.SRC_IN);
binding.playerPlayPauseFab.setImageDrawable(playerFabPlayPauseDrawable);
binding.playerPlayPauseFab.setColorFilter(ThemeUtil.getPrimaryTextColor(requireContext(), fabColor), PorterDuff.Mode.SRC_IN);
binding.playerPlayPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler());
binding.playerPlayPauseFab.post(() -> {
binding.playerPlayPauseFab.setPivotX(binding.playerPlayPauseFab.getWidth() / 2f);

View file

@ -15,18 +15,17 @@ import android.widget.ImageView;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.dkanada.gramophone.databinding.FragmentFlatPlayerBinding;
import com.dkanada.gramophone.util.ThemeUtil;
import com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator;
import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator;
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
import com.kabouzeid.appthemehelper.ThemeStore;
import com.kabouzeid.appthemehelper.util.ATHUtil;
import com.kabouzeid.appthemehelper.util.ColorUtil;
import com.dkanada.gramophone.R;
import com.dkanada.gramophone.adapter.base.MediaEntryViewHolder;
import com.dkanada.gramophone.adapter.song.PlayingQueueAdapter;
@ -42,6 +41,7 @@ import com.dkanada.gramophone.util.MusicUtil;
import com.dkanada.gramophone.util.Util;
import com.dkanada.gramophone.util.ViewUtil;
import com.dkanada.gramophone.views.WidthFitSquareLayout;
import com.google.android.material.color.MaterialColors;
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbumCoverFragment.Callbacks, SlidingUpPanelLayout.PanelSlideListener {
@ -224,7 +224,7 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
private void updateIsFavorite() {
boolean favorite = MusicPlayerRemote.getCurrentSong().favorite;
int res = favorite ? R.drawable.ic_favorite_white_24dp : R.drawable.ic_favorite_border_white_24dp;
int color = ContextCompat.getColor(requireContext(), android.R.color.white);
int color = ThemeUtil.getColorResource(requireContext(), android.R.color.white, 255);
Drawable drawable = ImageUtil.getTintedVectorDrawable(requireActivity(), res, color);
binding.playerToolbar.getMenu().findItem(R.id.action_toggle_favorite)
@ -280,7 +280,7 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
@Override
public void onColorChanged(int color) {
animateColorChange(color);
playbackControlsFragment.setDark(ColorUtil.isColorLight(color));
playbackControlsFragment.setDark(MaterialColors.isColorLight(color));
playbackControlsFragment.updateBufferingIndicatorColor(color);
getCallbacks().onPaletteColorChanged();
}
@ -347,23 +347,9 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(backgroundAnimator, statusBarAnimator);
if (!ATHUtil.isWindowBackgroundDark(fragment.requireActivity())) {
int adjustedLastColor = ColorUtil.isColorLight(fragment.lastColor) ? ColorUtil.darkenColor(fragment.lastColor) : fragment.lastColor;
int adjustedNewColor = ColorUtil.isColorLight(newColor) ? ColorUtil.darkenColor(newColor) : newColor;
Animator subHeaderAnimator = ViewUtil.createTextColorTransition(binding.playerQueueSubHeader, adjustedLastColor, adjustedNewColor);
animatorSet.play(subHeaderAnimator);
}
animatorSet.setDuration(ViewUtil.PHONOGRAPH_ANIM_TIME);
return animatorSet;
}
@Override
public void animateColorChange(int newColor) {
if (ATHUtil.isWindowBackgroundDark(fragment.requireActivity())) {
binding.playerQueueSubHeader.setTextColor(ThemeStore.textColorSecondary(fragment.requireActivity()));
}
}
}
@SuppressWarnings("ConstantConditions")
@ -443,7 +429,6 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
@Override
public void animateColorChange(int newColor) {
super.animateColorChange(newColor);
createDefaultColorChangeAnimatorSet(newColor).start();
}
}
@ -471,8 +456,6 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
@Override
public void animateColorChange(int newColor) {
super.animateColorChange(newColor);
AnimatorSet animatorSet = createDefaultColorChangeAnimatorSet(newColor);
animatorSet.play(ViewUtil.createBackgroundColorTransition(binding.playerToolbar, fragment.lastColor, newColor));
animatorSet.start();

View file

@ -107,10 +107,10 @@ public class FlatPlayerPlaybackControlsFragment extends AbsMusicServiceFragment
public void setDark(boolean dark) {
if (dark) {
lastPlaybackControlsColor = ThemeUtil.getSecondaryTextColor(requireActivity(), true);
lastDisabledPlaybackControlsColor = ThemeUtil.getDisabledTextColor(ThemeUtil.getSecondaryTextColor(requireActivity(), true));
lastDisabledPlaybackControlsColor = ThemeUtil.getColorAlpha(requireActivity(), R.color.color_text_secondary_light, 180);
} else {
lastPlaybackControlsColor = ThemeUtil.getPrimaryTextColor(requireActivity(), false);
lastDisabledPlaybackControlsColor = ThemeUtil.getDisabledTextColor(ThemeUtil.getPrimaryTextColor(requireActivity(), false));
lastDisabledPlaybackControlsColor = ThemeUtil.getColorAlpha(requireActivity(), R.color.color_text_primary_dark, 180);
}
updateRepeatState();

View file

@ -20,7 +20,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.ColorUtil;
import com.google.android.material.color.MaterialColors;
import com.dkanada.gramophone.R;
import com.dkanada.gramophone.glide.CustomGlideRequest;
import com.dkanada.gramophone.glide.palette.BitmapPaletteWrapper;
@ -124,7 +124,7 @@ public class PlayingNotificationMarshmallow extends PlayingNotification {
}
setBackgroundColor(bgColor);
setNotificationContent(ColorUtil.isColorLight(bgColor));
setNotificationContent(MaterialColors.isColorLight(bgColor));
// notification has been stopped before loading was finished
if (stopped) return;

View file

@ -2,6 +2,8 @@ package com.dkanada.gramophone.util;
import android.content.res.ColorStateList;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import androidx.annotation.ColorInt;
import androidx.annotation.Nullable;
@ -67,8 +69,37 @@ public class ThemeUtil {
}
@ColorInt
public static int getDisabledTextColor(int color) {
return MaterialColors.compositeARGBWithAlpha(color, 140);
public static int getPrimaryTextColor(Context context, int color) {
return getPrimaryTextColor(context, MaterialColors.isColorLight(color));
}
@ColorInt
public static int getSecondaryTextColor(Context context, int color) {
return getSecondaryTextColor(context, MaterialColors.isColorLight(color));
}
@ColorInt
public static int getColorResource(Context context, int resource, int alpha) {
TypedArray array = context.obtainStyledAttributes(new int[]{resource});
int color = array.getColor(0, ContextCompat.getColor(context, android.R.color.white));
array.recycle();
return MaterialColors.compositeARGBWithAlpha(color, alpha);
}
@ColorInt
public static int getColorAlpha(Context context, int color, int alpha) {
return MaterialColors.compositeARGBWithAlpha(ContextCompat.getColor(context, color), alpha);
}
@ColorInt
public static int getColorDark(int color) {
float[] hsv = new float[3];
Color.colorToHSV(color, hsv);
hsv[2] *= 0.8f;
return Color.HSVToColor(hsv);
}
private static class SwatchComparator implements Comparator<Palette.Swatch> {

View file

@ -19,8 +19,6 @@ import android.widget.TextView;
import androidx.annotation.ColorInt;
import com.kabouzeid.appthemehelper.util.ATHUtil;
import com.kabouzeid.appthemehelper.util.ColorUtil;
import com.dkanada.gramophone.R;
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView;
@ -78,9 +76,9 @@ public class ViewUtil {
public static void setUpFastScrollRecyclerViewColor(Context context, FastScrollRecyclerView recyclerView, int accentColor) {
recyclerView.setPopupBgColor(accentColor);
recyclerView.setPopupTextColor(ThemeUtil.getPrimaryTextColor(context, ColorUtil.isColorLight(accentColor)));
recyclerView.setPopupTextColor(ThemeUtil.getPrimaryTextColor(context, accentColor));
recyclerView.setThumbColor(accentColor);
recyclerView.setTrackColor(ColorUtil.withAlpha(ATHUtil.resolveColor(context, R.attr.colorControlNormal), 0.12f));
recyclerView.setTrackColor(ThemeUtil.getColorResource(context, R.attr.colorControlNormal, 40));
}
public static float convertDpToPixel(float dp, Resources resources) {

View file

@ -19,7 +19,7 @@ public class ColorCircleDrawable extends View {
TypedArray attributes = getContext().obtainStyledAttributes(new int[]{android.R.attr.divider});
int colorCircle = getContext().getResources().getColor(android.R.color.white);
int colorBorder = getContext().getResources().getColor(android.R.color.black);
int colorBorder = getContext().getResources().getColor(android.R.color.darker_gray);
circle.setAntiAlias(true);
circle.setColor(colorCircle);