mirror of
https://github.com/cmclark00/RetroMusicPlayer.git
synced 2025-05-19 08:35:20 +01:00
Dialog corner and Filter song duration
This commit is contained in:
parent
a5a27e62aa
commit
fc868e1c2e
75 changed files with 1409 additions and 1294 deletions
|
@ -1,64 +0,0 @@
|
|||
package code.name.monkey.retromusic.util;
|
||||
|
||||
import android.graphics.Color;
|
||||
import androidx.annotation.ColorInt;
|
||||
|
||||
public class ColorUtils {
|
||||
|
||||
public static boolean isColorLight(@ColorInt int color) {
|
||||
return getColorDarkness(color) < 0.5;
|
||||
}
|
||||
|
||||
private static double getColorDarkness(@ColorInt int color) {
|
||||
if (color == Color.BLACK)
|
||||
return 1.0;
|
||||
else if (color == Color.WHITE || color == Color.TRANSPARENT)
|
||||
return 0.0;
|
||||
else
|
||||
return (1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255);
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int getInverseColor(@ColorInt int color) {
|
||||
return (0xFFFFFF - color) | 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
public static boolean isColorSaturated(@ColorInt int color) {
|
||||
double max = Math.max(0.299 * Color.red(color), Math.max(0.587 * Color.green(color), 0.114 * Color.blue(color)));
|
||||
double min = Math.min(0.299 * Color.red(color), Math.min(0.587 * Color.green(color), 0.114 * Color.blue(color)));
|
||||
double diff = Math.abs(max - min);
|
||||
return diff > 20;
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int getMixedColor(@ColorInt int color1, @ColorInt int color2) {
|
||||
return Color.rgb(
|
||||
(Color.red(color1) + Color.red(color2)) / 2,
|
||||
(Color.green(color1) + Color.green(color2)) / 2,
|
||||
(Color.blue(color1) + Color.blue(color2)) / 2
|
||||
);
|
||||
}
|
||||
|
||||
public static double getDifference(@ColorInt int color1, @ColorInt int color2) {
|
||||
double diff = Math.abs(0.299 * (Color.red(color1) - Color.red(color2)));
|
||||
diff += Math.abs(0.587 * (Color.green(color1) - Color.green(color2)));
|
||||
diff += Math.abs(0.114 * (Color.blue(color1) - Color.blue(color2)));
|
||||
return diff;
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int getReadableText(@ColorInt int textColor, @ColorInt int backgroundColor) {
|
||||
return getReadableText(textColor, backgroundColor, 100);
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int getReadableText(@ColorInt int textColor, @ColorInt int backgroundColor, int difference) {
|
||||
boolean isLight = isColorLight(backgroundColor);
|
||||
for (int i = 0; getDifference(textColor, backgroundColor) < difference && i < 100; i++) {
|
||||
textColor = getMixedColor(textColor, isLight ? Color.BLACK : Color.WHITE);
|
||||
}
|
||||
|
||||
return textColor;
|
||||
}
|
||||
|
||||
}
|
|
@ -7,16 +7,15 @@ import android.content.SharedPreferences.Editor;
|
|||
import android.content.res.TypedArray;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.material.bottomnavigation.LabelVisibilityMode;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import code.name.monkey.retromusic.App;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.helper.SortOrder;
|
||||
|
@ -61,7 +60,7 @@ public final class PreferenceUtil {
|
|||
public static final String HOME_ARTIST_GRID_STYLE = "home_artist_grid_style";
|
||||
public static final String ARTIST_GRID_STYLE = "artist_grid_style";
|
||||
public static final String TOGGLE_ADD_CONTROLS = "toggle_add_controls";
|
||||
public static final String ALBUM_COVER_STYLE = "album_cover_style";
|
||||
public static final String ALBUM_COVER_STYLE = "album_cover_style_id";
|
||||
public static final String ALBUM_COVER_TRANSFORM = "album_cover_transform";
|
||||
public static final String TAB_TEXT_MODE = "tab_text_mode";
|
||||
private static final String GENRE_SORT_ORDER = "genre_sort_order";
|
||||
|
@ -109,6 +108,7 @@ public final class PreferenceUtil {
|
|||
private static final String PAUSE_ON_ZERO_VOLUME = "pause_on_zero_volume";
|
||||
private static final String NOW_PLAYING_SCREEN = "now_playing_screen";
|
||||
private static final String SNOW_FALL_EFFECT = "snow_fall_effect";
|
||||
private static final String FILTER_SONG = "filter_song";
|
||||
private static PreferenceUtil sInstance;
|
||||
private final SharedPreferences mPreferences;
|
||||
|
||||
|
@ -140,6 +140,10 @@ public final class PreferenceUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public int getFilterLength() {
|
||||
return mPreferences.getInt(FILTER_SONG, 20);
|
||||
}
|
||||
|
||||
public boolean isSnowFall() {
|
||||
return mPreferences.getBoolean(SNOW_FALL_EFFECT, false);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class RetroColorUtil {
|
|||
int background = getSwatch(palette).getRgb();
|
||||
|
||||
if (inverse != -1) {
|
||||
return ColorUtils.getReadableText(inverse, background, 150);
|
||||
return ColorUtil.INSTANCE.getReadableText(inverse, background, 150);
|
||||
}
|
||||
return ColorUtil.INSTANCE.stripAlpha(getSwatch(palette).getTitleTextColor());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue