replace all text color helper methods
This commit is contained in:
parent
5ae5d3017a
commit
a7cb077cee
19 changed files with 96 additions and 96 deletions
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue