diff --git a/app/src/main/java/mod/hey/studios/util/ProjectFile.java b/app/src/main/java/mod/hey/studios/util/ProjectFile.java index c67322b6ff..89c3e49253 100644 --- a/app/src/main/java/mod/hey/studios/util/ProjectFile.java +++ b/app/src/main/java/mod/hey/studios/util/ProjectFile.java @@ -6,11 +6,15 @@ import android.graphics.Color; import android.os.Build; +import androidx.core.content.res.ColorStateListInflaterCompat; + import pro.sketchware.SketchApplication; import a.a.a.lC; import a.a.a.yB; +import java.lang.reflect.Method; + public class ProjectFile { public static final String COLOR_ACCENT = "color_accent"; public static final String COLOR_PRIMARY = "color_primary"; @@ -51,15 +55,10 @@ public static int getDefaultColor(String color) { final Context ctx = SketchApplication.getContext(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - // final int defaultColor = modulateColorWithLStar( - // ctx.getColor(android.R.color.system_accentl1_600), 90.0f); - // final int colorBackground = modulateColorWithLStar( - // ctx.getColor(android.R.color.system_neutral2_600), 98.0f); - return switch (color) { case COLOR_CONTROL_HIGHLIGHT -> ctx.getColor(android.R.color.system_accent1_100); - case COLOR_BACKGROUND -> ctx.getColor(android.R.color.system_neutral1_0); - default -> ctx.getColor(android.R.color.system_accent1_600); + case COLOR_BACKGROUND -> getLStaredColor(ctx, android.R.color.system_neutral2_600, 98.0f); + default -> getLStaredColor(ctx, android.R.color.system_accent1_600, 90.0f); }; } else { return switch (color) { @@ -69,4 +68,10 @@ public static int getDefaultColor(String color) { }; } } + + private static int getLStaredColor(Context ctx, int colorId, float lStar) { + Method method = ColorStateListInflaterCompat.class.getDeclaredMethod("modulateColorAlpha", int.class, float.class, float.class); + method.setAccessible(true); + return (int) method.invoke(ColorStateListInflaterCompat.class, ctx.getColor(colorId), 1.0f, lStar); + } }