6.6.2 - Alpha4 - 优化部分控件主题色与背景色对比度过低时的视觉体验

This commit is contained in:
SuperMonster003
2025-03-19 01:01:13 +08:00
parent 603eef9243
commit 7e8fe4379f
5 changed files with 13 additions and 5 deletions

View File

@@ -6,9 +6,11 @@ import androidx.annotation.NonNull;
import com.afollestad.materialdialogs.MaterialDialog; import com.afollestad.materialdialogs.MaterialDialog;
import com.afollestad.materialdialogs.Theme;
import org.autojs.autojs.theme.ThemeColor; import org.autojs.autojs.theme.ThemeColor;
import org.autojs.autojs.theme.ThemeColorManager; import org.autojs.autojs.theme.ThemeColorManager;
import org.autojs.autojs.theme.ThemeColorMutable; import org.autojs.autojs.theme.ThemeColorMutable;
import org.autojs.autojs.util.ColorUtils;
/** /**
* Created by Stardust on Mar 5, 2017. * Created by Stardust on Mar 5, 2017.
@@ -21,7 +23,7 @@ public class ThemeColorMaterialDialogBuilder extends MaterialDialog.Builder impl
@Override @Override
public void setThemeColor(ThemeColor themeColor) { public void setThemeColor(ThemeColor themeColor) {
int color = themeColor.colorPrimary; int color = ColorUtils.adjustColorForContrast(backgroundColor, themeColor.colorPrimary, 2.3);
positiveColor(color); positiveColor(color);
negativeColor(color); negativeColor(color);
neutralColor(color); neutralColor(color);

View File

@@ -8,6 +8,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import org.autojs.autojs.theme.ThemeColor; import org.autojs.autojs.theme.ThemeColor;
import org.autojs.autojs.theme.ThemeColorManager; import org.autojs.autojs.theme.ThemeColorManager;
import org.autojs.autojs.theme.ThemeColorMutable; import org.autojs.autojs.theme.ThemeColorMutable;
import org.autojs.autojs.util.ColorUtils;
import org.autojs.autojs6.R; import org.autojs.autojs6.R;
/** /**
@@ -32,7 +33,9 @@ public class ThemeColorSwipeRefreshLayout extends SwipeRefreshLayout implements
@Override @Override
public void setThemeColor(ThemeColor themeColor) { public void setThemeColor(ThemeColor themeColor) {
setColorSchemeColors(themeColor.colorPrimary); int backgroundColor = getContext().getColor(R.color.swipe_refresh_background);
int adjustedColor = ColorUtils.adjustColorForContrast(backgroundColor, themeColor.colorPrimary, 2.3);
setColorSchemeColors(adjustedColor);
} }
} }

View File

@@ -14,6 +14,7 @@ import org.autojs.autojs.theme.ThemeColorMutable;
* Created by Stardust on Aug 7, 2016. * Created by Stardust on Aug 7, 2016.
*/ */
public class ThemeColorSwitch extends SwitchCompat implements ThemeColorMutable { public class ThemeColorSwitch extends SwitchCompat implements ThemeColorMutable {
public ThemeColorSwitch(Context context) { public ThemeColorSwitch(Context context) {
super(context); super(context);
init(); init();
@@ -35,6 +36,7 @@ public class ThemeColorSwitch extends SwitchCompat implements ThemeColorMutable
@Override @Override
public void setThemeColor(ThemeColor color) { public void setThemeColor(ThemeColor color) {
ThemeColorHelper.setColorPrimary(this, color.colorPrimary); ThemeColorHelper.setColorPrimary(this, color.colorPrimary, true);
} }
} }

View File

@@ -653,6 +653,7 @@ object ColorUtils {
* @return The adjusted color. (zh-CN: 调整后的颜色.) * @return The adjusted color. (zh-CN: 调整后的颜色.)
*/ */
@JvmStatic @JvmStatic
@JvmOverloads
fun adjustColorForContrast( fun adjustColorForContrast(
@ColorInt background: Int, @ColorInt background: Int,
@ColorInt reference: Int, @ColorInt reference: Int,

View File

@@ -1,5 +1,5 @@
#Wed Mar 19 00:38:56 CST 2025 #Wed Mar 19 00:50:23 CST 2025
BUILD_TIME=1742315936702 BUILD_TIME=1742316623695
COMPILE_SDK_VERSION=35 COMPILE_SDK_VERSION=35
JAVA_VERSION=23 JAVA_VERSION=23
JAVA_VERSION_MIN_RADICAL=0 JAVA_VERSION_MIN_RADICAL=0