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.Theme;
import org.autojs.autojs.theme.ThemeColor;
import org.autojs.autojs.theme.ThemeColorManager;
import org.autojs.autojs.theme.ThemeColorMutable;
import org.autojs.autojs.util.ColorUtils;
/**
* Created by Stardust on Mar 5, 2017.
@@ -21,7 +23,7 @@ public class ThemeColorMaterialDialogBuilder extends MaterialDialog.Builder impl
@Override
public void setThemeColor(ThemeColor themeColor) {
int color = themeColor.colorPrimary;
int color = ColorUtils.adjustColorForContrast(backgroundColor, themeColor.colorPrimary, 2.3);
positiveColor(color);
negativeColor(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.ThemeColorManager;
import org.autojs.autojs.theme.ThemeColorMutable;
import org.autojs.autojs.util.ColorUtils;
import org.autojs.autojs6.R;
/**
@@ -32,7 +33,9 @@ public class ThemeColorSwipeRefreshLayout extends SwipeRefreshLayout implements
@Override
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.
*/
public class ThemeColorSwitch extends SwitchCompat implements ThemeColorMutable {
public ThemeColorSwitch(Context context) {
super(context);
init();
@@ -35,6 +36,7 @@ public class ThemeColorSwitch extends SwitchCompat implements ThemeColorMutable
@Override
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: 调整后的颜色.)
*/
@JvmStatic
@JvmOverloads
fun adjustColorForContrast(
@ColorInt background: Int,
@ColorInt reference: Int,