diff --git a/app/src/main/java/com/besome/sketch/editor/view/ViewEditor.java b/app/src/main/java/com/besome/sketch/editor/view/ViewEditor.java index 9b61ce39b5..d18c44ecf8 100644 --- a/app/src/main/java/com/besome/sketch/editor/view/ViewEditor.java +++ b/app/src/main/java/com/besome/sketch/editor/view/ViewEditor.java @@ -734,6 +734,7 @@ private void setPreviewColors(String str) { k.setBackgroundColor(ProjectFile.getColor(str, ProjectFile.COLOR_PRIMARY_DARK)); imgPhoneTopBg.setBackgroundColor(ProjectFile.getColor(str, ProjectFile.COLOR_PRIMARY_DARK)); toolbar.setBackgroundColor(ProjectFile.getColor(str, ProjectFile.COLOR_PRIMARY)); + viewPane.setRootBackgroundColor(ProjectFile.getColor(str, ProjectFile.COLOR_BACKGROUND)); } private void b(boolean z) { diff --git a/app/src/main/java/com/besome/sketch/editor/view/ViewPane.java b/app/src/main/java/com/besome/sketch/editor/view/ViewPane.java index c425d8b597..7ab3b41d3a 100644 --- a/app/src/main/java/com/besome/sketch/editor/view/ViewPane.java +++ b/app/src/main/java/com/besome/sketch/editor/view/ViewPane.java @@ -30,6 +30,8 @@ import android.widget.SeekBar; import android.widget.TextView; +import androidx.annotation.ColorInt; + import com.besome.sketch.beans.ImageBean; import com.besome.sketch.beans.LayoutBean; import com.besome.sketch.beans.ProjectResourceBean; @@ -322,6 +324,10 @@ private void addRootLayout() { addView(rootView); } + public void setRootBackgroundColor(@ColorInt int backgroundColor) { + rootLayout.setBackgroundColor(backgroundColor); + } + private void updateItemView(View view, ViewBean viewBean) { ImageBean imageBean; String str; 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 ccc0e91cb9..6eb4588a31 100644 --- a/app/src/main/java/mod/hey/studios/util/ProjectFile.java +++ b/app/src/main/java/mod/hey/studios/util/ProjectFile.java @@ -1,5 +1,8 @@ package mod.hey.studios.util; +import static mod.remaker.util.CamUtils.modulateColorWithLStar; + +import android.content.Context; import android.graphics.Color; import android.os.Build; @@ -15,6 +18,9 @@ public class ProjectFile { public static final String COLOR_CONTROL_HIGHLIGHT = "color_control_highlight"; public static final String COLOR_CONTROL_NORMAL = "color_control_normal"; + // Android Framework + public static final String COLOR_BACKGROUND = "color_background"; + public static int getColor(String sc_id, String color) { return yB.a(lC.b(sc_id), color, getDefaultColor(color)); /* @@ -42,19 +48,23 @@ public static int a(Map paramMap, String paramString, int paramI */ public static int getDefaultColor(String color) { - // Check if the device is running Android 12 or above + final Context ctx = SketchApplication.getContext(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - // Android 12+ (API level 31): Use Material 3 dynamic colors + 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_PRIMARY_DARK -> SketchApplication.getContext().getColor(android.R.color.system_accent1_500); - case COLOR_CONTROL_HIGHLIGHT -> SketchApplication.getContext().getColor(android.R.color.system_accent1_100); - default -> SketchApplication.getContext().getColor(android.R.color.system_accent1_500); + case COLOR_CONTROL_HIGHLIGHT -> ctx.getColor(android.R.color.system_accent1_100); + case COLOR_BACKGROUND -> colorBackground; + default -> defaultColor; }; } else { - // For Android versions below 12: use static fallback colors return switch (color) { - case COLOR_PRIMARY_DARK -> Color.parseColor("#ff1976d2"); case COLOR_CONTROL_HIGHLIGHT -> Color.parseColor("#202196f3"); + case COLOR_BACKGROUND -> Color.parseColor("#fffafafa"); default -> Color.parseColor("#ff2196f3"); }; }