6.6.2 - Alpha5 - 本地化 Color Picker 库; 主题色设置页面新旧布局分离 (初步)

This commit is contained in:
SuperMonster003
2025-03-25 22:54:40 +08:00
parent 1b3ff3bb5a
commit 124dea0c0e
284 changed files with 6919 additions and 537 deletions

View File

@@ -0,0 +1,758 @@
package org.autojs.autojs.core.image
import org.autojs.autojs6.R
/**
* Created by SuperMonster003 on Mar 25, 2025.
*/
object ColorItems {
@JvmField
val MATERIAL_COLORS: List<Pair</* colorRes */ Int, /* colorNameRes */ Int>> = listOf(
/* reds */
R.color.md_red_50 to R.string.md_red_50,
R.color.md_red_100 to R.string.md_red_100,
R.color.md_red_200 to R.string.md_red_200,
R.color.md_red_300 to R.string.md_red_300,
R.color.md_red_400 to R.string.md_red_400,
R.color.md_red_500 to R.string.md_red_500,
R.color.md_red_600 to R.string.md_red_600,
R.color.md_red_700 to R.string.md_red_700,
R.color.md_red_800 to R.string.md_red_800,
R.color.md_red_900 to R.string.md_red_900,
R.color.md_red_a100 to R.string.md_red_a100,
R.color.md_red_a200 to R.string.md_red_a200,
R.color.md_red_a400 to R.string.md_red_a400,
R.color.md_red_a700 to R.string.md_red_a700,
/* pinks */
R.color.md_pink_50 to R.string.md_pink_50,
R.color.md_pink_100 to R.string.md_pink_100,
R.color.md_pink_200 to R.string.md_pink_200,
R.color.md_pink_300 to R.string.md_pink_300,
R.color.md_pink_400 to R.string.md_pink_400,
R.color.md_pink_500 to R.string.md_pink_500,
R.color.md_pink_600 to R.string.md_pink_600,
R.color.md_pink_700 to R.string.md_pink_700,
R.color.md_pink_800 to R.string.md_pink_800,
R.color.md_pink_900 to R.string.md_pink_900,
R.color.md_pink_a100 to R.string.md_pink_a100,
R.color.md_pink_a200 to R.string.md_pink_a200,
R.color.md_pink_a400 to R.string.md_pink_a400,
R.color.md_pink_a700 to R.string.md_pink_a700,
/* purples */
R.color.md_purple_50 to R.string.md_purple_50,
R.color.md_purple_100 to R.string.md_purple_100,
R.color.md_purple_200 to R.string.md_purple_200,
R.color.md_purple_300 to R.string.md_purple_300,
R.color.md_purple_400 to R.string.md_purple_400,
R.color.md_purple_500 to R.string.md_purple_500,
R.color.md_purple_600 to R.string.md_purple_600,
R.color.md_purple_700 to R.string.md_purple_700,
R.color.md_purple_800 to R.string.md_purple_800,
R.color.md_purple_900 to R.string.md_purple_900,
R.color.md_purple_a100 to R.string.md_purple_a100,
R.color.md_purple_a200 to R.string.md_purple_a200,
R.color.md_purple_a400 to R.string.md_purple_a400,
R.color.md_purple_a700 to R.string.md_purple_a700,
/* deep purples */
R.color.md_deep_purple_50 to R.string.md_deep_purple_50,
R.color.md_deep_purple_100 to R.string.md_deep_purple_100,
R.color.md_deep_purple_200 to R.string.md_deep_purple_200,
R.color.md_deep_purple_300 to R.string.md_deep_purple_300,
R.color.md_deep_purple_400 to R.string.md_deep_purple_400,
R.color.md_deep_purple_500 to R.string.md_deep_purple_500,
R.color.md_deep_purple_600 to R.string.md_deep_purple_600,
R.color.md_deep_purple_700 to R.string.md_deep_purple_700,
R.color.md_deep_purple_800 to R.string.md_deep_purple_800,
R.color.md_deep_purple_900 to R.string.md_deep_purple_900,
R.color.md_deep_purple_a100 to R.string.md_deep_purple_a100,
R.color.md_deep_purple_a200 to R.string.md_deep_purple_a200,
R.color.md_deep_purple_a400 to R.string.md_deep_purple_a400,
R.color.md_deep_purple_a700 to R.string.md_deep_purple_a700,
/* indigo */
R.color.md_indigo_50 to R.string.md_indigo_50,
R.color.md_indigo_100 to R.string.md_indigo_100,
R.color.md_indigo_200 to R.string.md_indigo_200,
R.color.md_indigo_300 to R.string.md_indigo_300,
R.color.md_indigo_400 to R.string.md_indigo_400,
R.color.md_indigo_500 to R.string.md_indigo_500,
R.color.md_indigo_600 to R.string.md_indigo_600,
R.color.md_indigo_700 to R.string.md_indigo_700,
R.color.md_indigo_800 to R.string.md_indigo_800,
R.color.md_indigo_900 to R.string.md_indigo_900,
R.color.md_indigo_a100 to R.string.md_indigo_a100,
R.color.md_indigo_a200 to R.string.md_indigo_a200,
R.color.md_indigo_a400 to R.string.md_indigo_a400,
R.color.md_indigo_a700 to R.string.md_indigo_a700,
/* blue */
R.color.md_blue_50 to R.string.md_blue_50,
R.color.md_blue_100 to R.string.md_blue_100,
R.color.md_blue_200 to R.string.md_blue_200,
R.color.md_blue_300 to R.string.md_blue_300,
R.color.md_blue_400 to R.string.md_blue_400,
R.color.md_blue_500 to R.string.md_blue_500,
R.color.md_blue_600 to R.string.md_blue_600,
R.color.md_blue_700 to R.string.md_blue_700,
R.color.md_blue_800 to R.string.md_blue_800,
R.color.md_blue_900 to R.string.md_blue_900,
R.color.md_blue_a100 to R.string.md_blue_a100,
R.color.md_blue_a200 to R.string.md_blue_a200,
R.color.md_blue_a400 to R.string.md_blue_a400,
R.color.md_blue_a700 to R.string.md_blue_a700,
/* light blue */
R.color.md_light_blue_50 to R.string.md_light_blue_50,
R.color.md_light_blue_100 to R.string.md_light_blue_100,
R.color.md_light_blue_200 to R.string.md_light_blue_200,
R.color.md_light_blue_300 to R.string.md_light_blue_300,
R.color.md_light_blue_400 to R.string.md_light_blue_400,
R.color.md_light_blue_500 to R.string.md_light_blue_500,
R.color.md_light_blue_600 to R.string.md_light_blue_600,
R.color.md_light_blue_700 to R.string.md_light_blue_700,
R.color.md_light_blue_800 to R.string.md_light_blue_800,
R.color.md_light_blue_900 to R.string.md_light_blue_900,
R.color.md_light_blue_a100 to R.string.md_light_blue_a100,
R.color.md_light_blue_a200 to R.string.md_light_blue_a200,
R.color.md_light_blue_a400 to R.string.md_light_blue_a400,
R.color.md_light_blue_a700 to R.string.md_light_blue_a700,
/* cyan */
R.color.md_cyan_50 to R.string.md_cyan_50,
R.color.md_cyan_100 to R.string.md_cyan_100,
R.color.md_cyan_200 to R.string.md_cyan_200,
R.color.md_cyan_300 to R.string.md_cyan_300,
R.color.md_cyan_400 to R.string.md_cyan_400,
R.color.md_cyan_500 to R.string.md_cyan_500,
R.color.md_cyan_600 to R.string.md_cyan_600,
R.color.md_cyan_700 to R.string.md_cyan_700,
R.color.md_cyan_800 to R.string.md_cyan_800,
R.color.md_cyan_900 to R.string.md_cyan_900,
R.color.md_cyan_a100 to R.string.md_cyan_a100,
R.color.md_cyan_a200 to R.string.md_cyan_a200,
R.color.md_cyan_a400 to R.string.md_cyan_a400,
R.color.md_cyan_a700 to R.string.md_cyan_a700,
/* teal */
R.color.md_teal_50 to R.string.md_teal_50,
R.color.md_teal_100 to R.string.md_teal_100,
R.color.md_teal_200 to R.string.md_teal_200,
R.color.md_teal_300 to R.string.md_teal_300,
R.color.md_teal_400 to R.string.md_teal_400,
R.color.md_teal_500 to R.string.md_teal_500,
R.color.md_teal_600 to R.string.md_teal_600,
R.color.md_teal_700 to R.string.md_teal_700,
R.color.md_teal_800 to R.string.md_teal_800,
R.color.md_teal_900 to R.string.md_teal_900,
R.color.md_teal_a100 to R.string.md_teal_a100,
R.color.md_teal_a200 to R.string.md_teal_a200,
R.color.md_teal_a400 to R.string.md_teal_a400,
R.color.md_teal_a700 to R.string.md_teal_a700,
/* green */
R.color.md_green_50 to R.string.md_green_50,
R.color.md_green_100 to R.string.md_green_100,
R.color.md_green_200 to R.string.md_green_200,
R.color.md_green_300 to R.string.md_green_300,
R.color.md_green_400 to R.string.md_green_400,
R.color.md_green_500 to R.string.md_green_500,
R.color.md_green_600 to R.string.md_green_600,
R.color.md_green_700 to R.string.md_green_700,
R.color.md_green_800 to R.string.md_green_800,
R.color.md_green_900 to R.string.md_green_900,
R.color.md_green_a100 to R.string.md_green_a100,
R.color.md_green_a200 to R.string.md_green_a200,
R.color.md_green_a400 to R.string.md_green_a400,
R.color.md_green_a700 to R.string.md_green_a700,
/* light green */
R.color.md_light_green_50 to R.string.md_light_green_50,
R.color.md_light_green_100 to R.string.md_light_green_100,
R.color.md_light_green_200 to R.string.md_light_green_200,
R.color.md_light_green_300 to R.string.md_light_green_300,
R.color.md_light_green_400 to R.string.md_light_green_400,
R.color.md_light_green_500 to R.string.md_light_green_500,
R.color.md_light_green_600 to R.string.md_light_green_600,
R.color.md_light_green_700 to R.string.md_light_green_700,
R.color.md_light_green_800 to R.string.md_light_green_800,
R.color.md_light_green_900 to R.string.md_light_green_900,
R.color.md_light_green_a100 to R.string.md_light_green_a100,
R.color.md_light_green_a200 to R.string.md_light_green_a200,
R.color.md_light_green_a400 to R.string.md_light_green_a400,
R.color.md_light_green_a700 to R.string.md_light_green_a700,
/* lime */
R.color.md_lime_50 to R.string.md_lime_50,
R.color.md_lime_100 to R.string.md_lime_100,
R.color.md_lime_200 to R.string.md_lime_200,
R.color.md_lime_300 to R.string.md_lime_300,
R.color.md_lime_400 to R.string.md_lime_400,
R.color.md_lime_500 to R.string.md_lime_500,
R.color.md_lime_600 to R.string.md_lime_600,
R.color.md_lime_700 to R.string.md_lime_700,
R.color.md_lime_800 to R.string.md_lime_800,
R.color.md_lime_900 to R.string.md_lime_900,
R.color.md_lime_a100 to R.string.md_lime_a100,
R.color.md_lime_a200 to R.string.md_lime_a200,
R.color.md_lime_a400 to R.string.md_lime_a400,
R.color.md_lime_a700 to R.string.md_lime_a700,
/* yellow */
R.color.md_yellow_50 to R.string.md_yellow_50,
R.color.md_yellow_100 to R.string.md_yellow_100,
R.color.md_yellow_200 to R.string.md_yellow_200,
R.color.md_yellow_300 to R.string.md_yellow_300,
R.color.md_yellow_400 to R.string.md_yellow_400,
R.color.md_yellow_500 to R.string.md_yellow_500,
R.color.md_yellow_600 to R.string.md_yellow_600,
R.color.md_yellow_700 to R.string.md_yellow_700,
R.color.md_yellow_800 to R.string.md_yellow_800,
R.color.md_yellow_900 to R.string.md_yellow_900,
R.color.md_yellow_a100 to R.string.md_yellow_a100,
R.color.md_yellow_a200 to R.string.md_yellow_a200,
R.color.md_yellow_a400 to R.string.md_yellow_a400,
R.color.md_yellow_a700 to R.string.md_yellow_a700,
/* amber */
R.color.md_amber_50 to R.string.md_amber_50,
R.color.md_amber_100 to R.string.md_amber_100,
R.color.md_amber_200 to R.string.md_amber_200,
R.color.md_amber_300 to R.string.md_amber_300,
R.color.md_amber_400 to R.string.md_amber_400,
R.color.md_amber_500 to R.string.md_amber_500,
R.color.md_amber_600 to R.string.md_amber_600,
R.color.md_amber_700 to R.string.md_amber_700,
R.color.md_amber_800 to R.string.md_amber_800,
R.color.md_amber_900 to R.string.md_amber_900,
R.color.md_amber_a100 to R.string.md_amber_a100,
R.color.md_amber_a200 to R.string.md_amber_a200,
R.color.md_amber_a400 to R.string.md_amber_a400,
R.color.md_amber_a700 to R.string.md_amber_a700,
/* orange */
R.color.md_orange_50 to R.string.md_orange_50,
R.color.md_orange_100 to R.string.md_orange_100,
R.color.md_orange_200 to R.string.md_orange_200,
R.color.md_orange_300 to R.string.md_orange_300,
R.color.md_orange_400 to R.string.md_orange_400,
R.color.md_orange_500 to R.string.md_orange_500,
R.color.md_orange_600 to R.string.md_orange_600,
R.color.md_orange_700 to R.string.md_orange_700,
R.color.md_orange_800 to R.string.md_orange_800,
R.color.md_orange_900 to R.string.md_orange_900,
R.color.md_orange_a100 to R.string.md_orange_a100,
R.color.md_orange_a200 to R.string.md_orange_a200,
R.color.md_orange_a400 to R.string.md_orange_a400,
R.color.md_orange_a700 to R.string.md_orange_a700,
/* deep orange */
R.color.md_deep_orange_50 to R.string.md_deep_orange_50,
R.color.md_deep_orange_100 to R.string.md_deep_orange_100,
R.color.md_deep_orange_200 to R.string.md_deep_orange_200,
R.color.md_deep_orange_300 to R.string.md_deep_orange_300,
R.color.md_deep_orange_400 to R.string.md_deep_orange_400,
R.color.md_deep_orange_500 to R.string.md_deep_orange_500,
R.color.md_deep_orange_600 to R.string.md_deep_orange_600,
R.color.md_deep_orange_700 to R.string.md_deep_orange_700,
R.color.md_deep_orange_800 to R.string.md_deep_orange_800,
R.color.md_deep_orange_900 to R.string.md_deep_orange_900,
R.color.md_deep_orange_a100 to R.string.md_deep_orange_a100,
R.color.md_deep_orange_a200 to R.string.md_deep_orange_a200,
R.color.md_deep_orange_a400 to R.string.md_deep_orange_a400,
R.color.md_deep_orange_a700 to R.string.md_deep_orange_a700,
/* brown */
R.color.md_brown_50 to R.string.md_brown_50,
R.color.md_brown_100 to R.string.md_brown_100,
R.color.md_brown_200 to R.string.md_brown_200,
R.color.md_brown_300 to R.string.md_brown_300,
R.color.md_brown_400 to R.string.md_brown_400,
R.color.md_brown_500 to R.string.md_brown_500,
R.color.md_brown_600 to R.string.md_brown_600,
R.color.md_brown_700 to R.string.md_brown_700,
R.color.md_brown_800 to R.string.md_brown_800,
R.color.md_brown_900 to R.string.md_brown_900,
/* grey */
R.color.md_grey_50 to R.string.md_grey_50,
R.color.md_grey_100 to R.string.md_grey_100,
R.color.md_grey_200 to R.string.md_grey_200,
R.color.md_grey_300 to R.string.md_grey_300,
R.color.md_grey_400 to R.string.md_grey_400,
R.color.md_grey_500 to R.string.md_grey_500,
R.color.md_grey_600 to R.string.md_grey_600,
R.color.md_grey_700 to R.string.md_grey_700,
R.color.md_grey_800 to R.string.md_grey_800,
R.color.md_grey_900 to R.string.md_grey_900,
R.color.md_black_1000 to R.string.md_black_1000,
R.color.md_white_1000 to R.string.md_white_1000,
/* blue grey */
R.color.md_blue_grey_50 to R.string.md_blue_grey_50,
R.color.md_blue_grey_100 to R.string.md_blue_grey_100,
R.color.md_blue_grey_200 to R.string.md_blue_grey_200,
R.color.md_blue_grey_300 to R.string.md_blue_grey_300,
R.color.md_blue_grey_400 to R.string.md_blue_grey_400,
R.color.md_blue_grey_500 to R.string.md_blue_grey_500,
R.color.md_blue_grey_600 to R.string.md_blue_grey_600,
R.color.md_blue_grey_700 to R.string.md_blue_grey_700,
R.color.md_blue_grey_800 to R.string.md_blue_grey_800,
R.color.md_blue_grey_900 to R.string.md_blue_grey_900,
)
@JvmField
val ANDROID_COLORS: List<Pair</* colorRes */ Int, /* colorNameRes */ Int>> = listOf(
R.color.android_black to R.string.android_black,
R.color.android_blue to R.string.android_blue,
R.color.android_cyan to R.string.android_cyan,
R.color.android_aqua to R.string.android_aqua,
R.color.android_dark_gray to R.string.android_dark_gray,
R.color.android_dark_grey to R.string.android_dark_grey,
R.color.android_gray to R.string.android_gray,
R.color.android_grey to R.string.android_grey,
R.color.android_green to R.string.android_green,
R.color.android_lime to R.string.android_lime,
R.color.android_light_gray to R.string.android_light_gray,
R.color.android_light_grey to R.string.android_light_grey,
R.color.android_magenta to R.string.android_magenta,
R.color.android_fuchsia to R.string.android_fuchsia,
R.color.android_maroon to R.string.android_maroon,
R.color.android_navy to R.string.android_navy,
R.color.android_olive to R.string.android_olive,
R.color.android_purple to R.string.android_purple,
R.color.android_red to R.string.android_red,
R.color.android_silver to R.string.android_silver,
R.color.android_teal to R.string.android_teal,
R.color.android_white to R.string.android_white,
R.color.android_yellow to R.string.android_yellow,
)
@JvmField
val CSS_COLORS: List<Pair</* colorRes */ Int, /* colorNameRes */ Int>> = listOf(
R.color.css_alice_blue to R.string.css_alice_blue,
R.color.css_antique_white to R.string.css_antique_white,
R.color.css_aquamarine to R.string.css_aquamarine,
R.color.css_azure to R.string.css_azure,
R.color.css_beige to R.string.css_beige,
R.color.css_bisque to R.string.css_bisque,
R.color.css_black to R.string.css_black,
R.color.css_blanched_almond to R.string.css_blanched_almond,
R.color.css_blue to R.string.css_blue,
R.color.css_blue_violet to R.string.css_blue_violet,
R.color.css_brown to R.string.css_brown,
R.color.css_burly_wood to R.string.css_burly_wood,
R.color.css_cadet_blue to R.string.css_cadet_blue,
R.color.css_chartreuse to R.string.css_chartreuse,
R.color.css_chocolate to R.string.css_chocolate,
R.color.css_coral to R.string.css_coral,
R.color.css_cornflower_blue to R.string.css_cornflower_blue,
R.color.css_corn_silk to R.string.css_corn_silk,
R.color.css_crimson to R.string.css_crimson,
R.color.css_cyan to R.string.css_cyan,
R.color.css_aqua to R.string.css_aqua,
R.color.css_dark_blue to R.string.css_dark_blue,
R.color.css_dark_cyan to R.string.css_dark_cyan,
R.color.css_dark_goldenrod to R.string.css_dark_goldenrod,
R.color.css_dark_gray to R.string.css_dark_gray,
R.color.css_dark_grey to R.string.css_dark_grey,
R.color.css_dark_green to R.string.css_dark_green,
R.color.css_dark_khaki to R.string.css_dark_khaki,
R.color.css_dark_magenta to R.string.css_dark_magenta,
R.color.css_dark_olive_green to R.string.css_dark_olive_green,
R.color.css_dark_orange to R.string.css_dark_orange,
R.color.css_dark_orchid to R.string.css_dark_orchid,
R.color.css_dark_red to R.string.css_dark_red,
R.color.css_dark_salmon to R.string.css_dark_salmon,
R.color.css_dark_sea_green to R.string.css_dark_sea_green,
R.color.css_dark_slate_blue to R.string.css_dark_slate_blue,
R.color.css_dark_slate_gray to R.string.css_dark_slate_gray,
R.color.css_dark_slate_grey to R.string.css_dark_slate_grey,
R.color.css_dark_turquoise to R.string.css_dark_turquoise,
R.color.css_dark_violet to R.string.css_dark_violet,
R.color.css_deep_pink to R.string.css_deep_pink,
R.color.css_deep_sky_blue to R.string.css_deep_sky_blue,
R.color.css_dim_gray to R.string.css_dim_gray,
R.color.css_dim_grey to R.string.css_dim_grey,
R.color.css_dodger_blue to R.string.css_dodger_blue,
R.color.css_fire_brick to R.string.css_fire_brick,
R.color.css_floral_white to R.string.css_floral_white,
R.color.css_forest_green to R.string.css_forest_green,
R.color.css_gainsboro to R.string.css_gainsboro,
R.color.css_ghost_white to R.string.css_ghost_white,
R.color.css_gold to R.string.css_gold,
R.color.css_goldenrod to R.string.css_goldenrod,
R.color.css_gray to R.string.css_gray,
R.color.css_grey to R.string.css_grey,
R.color.css_green to R.string.css_green,
R.color.css_green_yellow to R.string.css_green_yellow,
R.color.css_honeydew to R.string.css_honeydew,
R.color.css_hot_pink to R.string.css_hot_pink,
R.color.css_indian_red to R.string.css_indian_red,
R.color.css_indigo to R.string.css_indigo,
R.color.css_ivory to R.string.css_ivory,
R.color.css_khaki to R.string.css_khaki,
R.color.css_lavender to R.string.css_lavender,
R.color.css_lavender_blush to R.string.css_lavender_blush,
R.color.css_lawn_green to R.string.css_lawn_green,
R.color.css_lemon_chiffon to R.string.css_lemon_chiffon,
R.color.css_light_blue to R.string.css_light_blue,
R.color.css_light_coral to R.string.css_light_coral,
R.color.css_light_cyan to R.string.css_light_cyan,
R.color.css_light_goldenrod_yellow to R.string.css_light_goldenrod_yellow,
R.color.css_light_gray to R.string.css_light_gray,
R.color.css_light_grey to R.string.css_light_grey,
R.color.css_light_green to R.string.css_light_green,
R.color.css_light_pink to R.string.css_light_pink,
R.color.css_light_salmon to R.string.css_light_salmon,
R.color.css_light_sea_green to R.string.css_light_sea_green,
R.color.css_light_sky_blue to R.string.css_light_sky_blue,
R.color.css_light_slate_gray to R.string.css_light_slate_gray,
R.color.css_light_slate_grey to R.string.css_light_slate_grey,
R.color.css_light_steel_blue to R.string.css_light_steel_blue,
R.color.css_light_yellow to R.string.css_light_yellow,
R.color.css_lime to R.string.css_lime,
R.color.css_lime_green to R.string.css_lime_green,
R.color.css_linen to R.string.css_linen,
R.color.css_magenta to R.string.css_magenta,
R.color.css_fuchsia to R.string.css_fuchsia,
R.color.css_maroon to R.string.css_maroon,
R.color.css_medium_aquamarine to R.string.css_medium_aquamarine,
R.color.css_medium_blue to R.string.css_medium_blue,
R.color.css_medium_lavender_magenta to R.string.css_medium_lavender_magenta,
R.color.css_medium_orchid to R.string.css_medium_orchid,
R.color.css_medium_purple to R.string.css_medium_purple,
R.color.css_medium_sea_green to R.string.css_medium_sea_green,
R.color.css_medium_slate_blue to R.string.css_medium_slate_blue,
R.color.css_medium_spring_green to R.string.css_medium_spring_green,
R.color.css_medium_turquoise to R.string.css_medium_turquoise,
R.color.css_medium_violet_red to R.string.css_medium_violet_red,
R.color.css_midnight_blue to R.string.css_midnight_blue,
R.color.css_mint_cream to R.string.css_mint_cream,
R.color.css_misty_rose to R.string.css_misty_rose,
R.color.css_moccasin to R.string.css_moccasin,
R.color.css_navajo_white to R.string.css_navajo_white,
R.color.css_navy to R.string.css_navy,
R.color.css_old_lace to R.string.css_old_lace,
R.color.css_olive to R.string.css_olive,
R.color.css_olive_drab to R.string.css_olive_drab,
R.color.css_orange to R.string.css_orange,
R.color.css_orange_red to R.string.css_orange_red,
R.color.css_orchid to R.string.css_orchid,
R.color.css_pale_goldenrod to R.string.css_pale_goldenrod,
R.color.css_pale_green to R.string.css_pale_green,
R.color.css_pale_turquoise to R.string.css_pale_turquoise,
R.color.css_pale_violet_red to R.string.css_pale_violet_red,
R.color.css_papaya_whip to R.string.css_papaya_whip,
R.color.css_patriarch to R.string.css_patriarch,
R.color.css_peach_puff to R.string.css_peach_puff,
R.color.css_peru to R.string.css_peru,
R.color.css_pink to R.string.css_pink,
R.color.css_powder_blue to R.string.css_powder_blue,
R.color.css_rebecca_purple to R.string.css_rebecca_purple,
R.color.css_red to R.string.css_red,
R.color.css_rosy_brown to R.string.css_rosy_brown,
R.color.css_royal_blue to R.string.css_royal_blue,
R.color.css_saddle_brown to R.string.css_saddle_brown,
R.color.css_salmon to R.string.css_salmon,
R.color.css_sand_brown to R.string.css_sand_brown,
R.color.css_seashell to R.string.css_seashell,
R.color.css_sea_green to R.string.css_sea_green,
R.color.css_sienna to R.string.css_sienna,
R.color.css_silver to R.string.css_silver,
R.color.css_sky_blue to R.string.css_sky_blue,
R.color.css_slate_blue to R.string.css_slate_blue,
R.color.css_slate_gray to R.string.css_slate_gray,
R.color.css_slate_grey to R.string.css_slate_grey,
R.color.css_snow to R.string.css_snow,
R.color.css_spring_green to R.string.css_spring_green,
R.color.css_steel_blue to R.string.css_steel_blue,
R.color.css_tan to R.string.css_tan,
R.color.css_teal to R.string.css_teal,
R.color.css_thistle to R.string.css_thistle,
R.color.css_tomato to R.string.css_tomato,
R.color.css_turquoise to R.string.css_turquoise,
R.color.css_violet to R.string.css_violet,
R.color.css_wheat to R.string.css_wheat,
R.color.css_white to R.string.css_white,
R.color.css_white_smoke to R.string.css_white_smoke,
R.color.css_yellow to R.string.css_yellow,
R.color.css_yellow_green to R.string.css_yellow_green,
)
@JvmField
val WEB_COLORS: List<Pair</* colorRes */ Int, /* colorNameRes */ Int>> = listOf(
R.color.web_alice_blue to R.string.web_alice_blue,
R.color.web_alizarin_crimson to R.string.web_alizarin_crimson,
R.color.web_amber to R.string.web_amber,
R.color.web_amethyst to R.string.web_amethyst,
R.color.web_antique_white to R.string.web_antique_white,
R.color.web_apple_green to R.string.web_apple_green,
R.color.web_apricot to R.string.web_apricot,
R.color.web_aqua to R.string.web_aqua,
R.color.web_aquamarine to R.string.web_aquamarine,
R.color.web_aqua_blue to R.string.web_aqua_blue,
R.color.web_azure to R.string.web_azure,
R.color.web_baby_blue to R.string.web_baby_blue,
R.color.web_baby_pink to R.string.web_baby_pink,
R.color.web_beige to R.string.web_beige,
R.color.web_bisque to R.string.web_bisque,
R.color.web_black to R.string.web_black,
R.color.web_blanched_almond to R.string.web_blanched_almond,
R.color.web_blue to R.string.web_blue,
R.color.web_blue_violet to R.string.web_blue_violet,
R.color.web_bright_green to R.string.web_bright_green,
R.color.web_bronze to R.string.web_bronze,
R.color.web_brown to R.string.web_brown,
R.color.web_burgundy to R.string.web_burgundy,
R.color.web_burly_wood to R.string.web_burly_wood,
R.color.web_burnt_orange to R.string.web_burnt_orange,
R.color.web_cadet_blue to R.string.web_cadet_blue,
R.color.web_camel to R.string.web_camel,
R.color.web_camellia to R.string.web_camellia,
R.color.web_canary_yellow to R.string.web_canary_yellow,
R.color.web_cardinal_red to R.string.web_cardinal_red,
R.color.web_carmine to R.string.web_carmine,
R.color.web_celadon to R.string.web_celadon,
R.color.web_cerise to R.string.web_cerise,
R.color.web_cerulean_blue to R.string.web_cerulean_blue,
R.color.web_champagne_yellow to R.string.web_champagne_yellow,
R.color.web_chartreuse to R.string.web_chartreuse,
R.color.web_chocolate to R.string.web_chocolate,
R.color.web_chrome_yellow to R.string.web_chrome_yellow,
R.color.web_clematis to R.string.web_clematis,
R.color.web_cobalt_blue to R.string.web_cobalt_blue,
R.color.web_cobalt_green to R.string.web_cobalt_green,
R.color.web_coconut_brown to R.string.web_coconut_brown,
R.color.web_coffee to R.string.web_coffee,
R.color.web_coral to R.string.web_coral,
R.color.web_coral_pink to R.string.web_coral_pink,
R.color.web_cornflower_blue to R.string.web_cornflower_blue,
R.color.web_corn_silk to R.string.web_corn_silk,
R.color.web_cream to R.string.web_cream,
R.color.web_crimson to R.string.web_crimson,
R.color.web_cyan to R.string.web_cyan,
R.color.web_cyan_blue to R.string.web_cyan_blue,
R.color.web_dark_blue to R.string.web_dark_blue,
R.color.web_dark_cyan to R.string.web_dark_cyan,
R.color.web_dark_goldenrod to R.string.web_dark_goldenrod,
R.color.web_dark_gray to R.string.web_dark_gray,
R.color.web_dark_green to R.string.web_dark_green,
R.color.web_dark_khaki to R.string.web_dark_khaki,
R.color.web_dark_magenta to R.string.web_dark_magenta,
R.color.web_dark_mineral_blue to R.string.web_dark_mineral_blue,
R.color.web_dark_olive_green to R.string.web_dark_olive_green,
R.color.web_dark_orange to R.string.web_dark_orange,
R.color.web_dark_orchid to R.string.web_dark_orchid,
R.color.web_dark_powder_blue to R.string.web_dark_powder_blue,
R.color.web_dark_red to R.string.web_dark_red,
R.color.web_dark_salmon to R.string.web_dark_salmon,
R.color.web_dark_sea_green to R.string.web_dark_sea_green,
R.color.web_dark_slate_blue to R.string.web_dark_slate_blue,
R.color.web_dark_slate_gray to R.string.web_dark_slate_gray,
R.color.web_dark_turquoise to R.string.web_dark_turquoise,
R.color.web_dark_violet to R.string.web_dark_violet,
R.color.web_deep_pink to R.string.web_deep_pink,
R.color.web_deep_sky_blue to R.string.web_deep_sky_blue,
R.color.web_dim_gray to R.string.web_dim_gray,
R.color.web_dodger_blue to R.string.web_dodger_blue,
R.color.web_emerald to R.string.web_emerald,
R.color.web_fire_brick to R.string.web_fire_brick,
R.color.web_flamingo to R.string.web_flamingo,
R.color.web_floral_white to R.string.web_floral_white,
R.color.web_foliage_green to R.string.web_foliage_green,
R.color.web_forest_green to R.string.web_forest_green,
R.color.web_fresh_leaves to R.string.web_fresh_leaves,
R.color.web_fuchsia to R.string.web_fuchsia,
R.color.web_gainsboro to R.string.web_gainsboro,
R.color.web_ghost_white to R.string.web_ghost_white,
R.color.web_golden to R.string.web_golden,
R.color.web_goldenrod to R.string.web_goldenrod,
R.color.web_grass_green to R.string.web_grass_green,
R.color.web_gray to R.string.web_gray,
R.color.web_grayish_purple to R.string.web_grayish_purple,
R.color.web_green to R.string.web_green,
R.color.web_green_yellow to R.string.web_green_yellow,
R.color.web_heliotrope to R.string.web_heliotrope,
R.color.web_honeydew to R.string.web_honeydew,
R.color.web_honey_orange to R.string.web_honey_orange,
R.color.web_horizon_blue to R.string.web_horizon_blue,
R.color.web_hot_pink to R.string.web_hot_pink,
R.color.web_indian_red to R.string.web_indian_red,
R.color.web_indigo to R.string.web_indigo,
R.color.web_international_klein_blue to R.string.web_international_klein_blue,
R.color.web_iron_gray to R.string.web_iron_gray,
R.color.web_ivory to R.string.web_ivory,
R.color.web_ivy_green to R.string.web_ivy_green,
R.color.web_jasmine to R.string.web_jasmine,
R.color.web_khaki to R.string.web_khaki,
R.color.web_lapis_lazuli to R.string.web_lapis_lazuli,
R.color.web_lavender to R.string.web_lavender,
R.color.web_lavender_blue to R.string.web_lavender_blue,
R.color.web_lavender_blush to R.string.web_lavender_blush,
R.color.web_lavender_magenta to R.string.web_lavender_magenta,
R.color.web_lavender_mist to R.string.web_lavender_mist,
R.color.web_lawn_green to R.string.web_lawn_green,
R.color.web_lemon_chiffon to R.string.web_lemon_chiffon,
R.color.web_light_blue to R.string.web_light_blue,
R.color.web_light_coral to R.string.web_light_coral,
R.color.web_light_cyan to R.string.web_light_cyan,
R.color.web_light_goldenrod_yellow to R.string.web_light_goldenrod_yellow,
R.color.web_light_gray to R.string.web_light_gray,
R.color.web_light_green to R.string.web_light_green,
R.color.web_light_khaki to R.string.web_light_khaki,
R.color.web_light_pink to R.string.web_light_pink,
R.color.web_light_salmon to R.string.web_light_salmon,
R.color.web_light_sea_green to R.string.web_light_sea_green,
R.color.web_light_sky_blue to R.string.web_light_sky_blue,
R.color.web_light_slate_gray to R.string.web_light_slate_gray,
R.color.web_light_steel_blue to R.string.web_light_steel_blue,
R.color.web_light_violet to R.string.web_light_violet,
R.color.web_light_yellow to R.string.web_light_yellow,
R.color.web_lilac to R.string.web_lilac,
R.color.web_lime to R.string.web_lime,
R.color.web_lime_green to R.string.web_lime_green,
R.color.web_linen to R.string.web_linen,
R.color.web_magenta to R.string.web_magenta,
R.color.web_magenta_rose to R.string.web_magenta_rose,
R.color.web_malachite to R.string.web_malachite,
R.color.web_mallow to R.string.web_mallow,
R.color.web_marigold to R.string.web_marigold,
R.color.web_marine_blue to R.string.web_marine_blue,
R.color.web_maroon to R.string.web_maroon,
R.color.web_mauve to R.string.web_mauve,
R.color.web_medium_aquamarine to R.string.web_medium_aquamarine,
R.color.web_medium_blue to R.string.web_medium_blue,
R.color.web_medium_lavender_magenta to R.string.web_medium_lavender_magenta,
R.color.web_medium_orchid to R.string.web_medium_orchid,
R.color.web_medium_purple to R.string.web_medium_purple,
R.color.web_medium_sea_green to R.string.web_medium_sea_green,
R.color.web_medium_slate_blue to R.string.web_medium_slate_blue,
R.color.web_medium_spring_green to R.string.web_medium_spring_green,
R.color.web_medium_turquoise to R.string.web_medium_turquoise,
R.color.web_medium_violet_red to R.string.web_medium_violet_red,
R.color.web_midnight_blue to R.string.web_midnight_blue,
R.color.web_mimosa to R.string.web_mimosa,
R.color.web_mineral_blue to R.string.web_mineral_blue,
R.color.web_mineral_violet to R.string.web_mineral_violet,
R.color.web_mint to R.string.web_mint,
R.color.web_mint_cream to R.string.web_mint_cream,
R.color.web_misty_rose to R.string.web_misty_rose,
R.color.web_moccasin to R.string.web_moccasin,
R.color.web_moon_yellow to R.string.web_moon_yellow,
R.color.web_moss_green to R.string.web_moss_green,
R.color.web_mustard to R.string.web_mustard,
R.color.web_navajo_white to R.string.web_navajo_white,
R.color.web_navy to R.string.web_navy,
R.color.web_ocher to R.string.web_ocher,
R.color.web_old_lace to R.string.web_old_lace,
R.color.web_old_rose to R.string.web_old_rose,
R.color.web_olive to R.string.web_olive,
R.color.web_olive_drab to R.string.web_olive_drab,
R.color.web_opera_mauve to R.string.web_opera_mauve,
R.color.web_orange to R.string.web_orange,
R.color.web_orange_red to R.string.web_orange_red,
R.color.web_orchid to R.string.web_orchid,
R.color.web_pail_lilac to R.string.web_pail_lilac,
R.color.web_pale_blue to R.string.web_pale_blue,
R.color.web_pale_denim to R.string.web_pale_denim,
R.color.web_pale_goldenrod to R.string.web_pale_goldenrod,
R.color.web_pale_green to R.string.web_pale_green,
R.color.web_pale_ochre to R.string.web_pale_ochre,
R.color.web_pale_turquoise to R.string.web_pale_turquoise,
R.color.web_pale_violet_red to R.string.web_pale_violet_red,
R.color.web_pansy to R.string.web_pansy,
R.color.web_papaya_whip to R.string.web_papaya_whip,
R.color.web_patriarch to R.string.web_patriarch,
R.color.web_peach to R.string.web_peach,
R.color.web_peach_pearl to R.string.web_peach_pearl,
R.color.web_peach_puff to R.string.web_peach_puff,
R.color.web_peacock_blue to R.string.web_peacock_blue,
R.color.web_peacock_green to R.string.web_peacock_green,
R.color.web_pearl_pink to R.string.web_pearl_pink,
R.color.web_persimmon to R.string.web_persimmon,
R.color.web_peru to R.string.web_peru,
R.color.web_pink to R.string.web_pink,
R.color.web_plum to R.string.web_plum,
R.color.web_powder_blue to R.string.web_powder_blue,
R.color.web_prussian_blue to R.string.web_prussian_blue,
R.color.web_purple to R.string.web_purple,
R.color.web_red to R.string.web_red,
R.color.web_rose to R.string.web_rose,
R.color.web_rose_pink to R.string.web_rose_pink,
R.color.web_rosy_brown to R.string.web_rosy_brown,
R.color.web_royal_blue to R.string.web_royal_blue,
R.color.web_ruby to R.string.web_ruby,
R.color.web_saddle_brown to R.string.web_saddle_brown,
R.color.web_salmon to R.string.web_salmon,
R.color.web_salmon_pink to R.string.web_salmon_pink,
R.color.web_salvia_blue to R.string.web_salvia_blue,
R.color.web_sand_beige to R.string.web_sand_beige,
R.color.web_sand_brown to R.string.web_sand_brown,
R.color.web_sapphire to R.string.web_sapphire,
R.color.web_saxe_blue to R.string.web_saxe_blue,
R.color.web_scarlet to R.string.web_scarlet,
R.color.web_seashell to R.string.web_seashell,
R.color.web_sea_green to R.string.web_sea_green,
R.color.web_sepia to R.string.web_sepia,
R.color.web_shell_pink to R.string.web_shell_pink,
R.color.web_sienna to R.string.web_sienna,
R.color.web_silver to R.string.web_silver,
R.color.web_sky_blue to R.string.web_sky_blue,
R.color.web_slate_blue to R.string.web_slate_blue,
R.color.web_slate_gray to R.string.web_slate_gray,
R.color.web_snow to R.string.web_snow,
R.color.web_spinel_red to R.string.web_spinel_red,
R.color.web_spring_green to R.string.web_spring_green,
R.color.web_steel_blue to R.string.web_steel_blue,
R.color.web_strong_blue to R.string.web_strong_blue,
R.color.web_strong_red to R.string.web_strong_red,
R.color.web_sun_orange to R.string.web_sun_orange,
R.color.web_tan to R.string.web_tan,
R.color.web_tangerine to R.string.web_tangerine,
R.color.web_tangerine_yellow to R.string.web_tangerine_yellow,
R.color.web_teal to R.string.web_teal,
R.color.web_thistle to R.string.web_thistle,
R.color.web_tomato to R.string.web_tomato,
R.color.web_tropical_orange to R.string.web_tropical_orange,
R.color.web_turquoise to R.string.web_turquoise,
R.color.web_turquoise_blue to R.string.web_turquoise_blue,
R.color.web_turquoise_green to R.string.web_turquoise_green,
R.color.web_ultramarine to R.string.web_ultramarine,
R.color.web_vermilion to R.string.web_vermilion,
R.color.web_very_light_malachite_green to R.string.web_very_light_malachite_green,
R.color.web_violet to R.string.web_violet,
R.color.web_viridian to R.string.web_viridian,
R.color.web_wedgwood_blue to R.string.web_wedgwood_blue,
R.color.web_wheat to R.string.web_wheat,
R.color.web_white to R.string.web_white,
R.color.web_white_smoke to R.string.web_white_smoke,
R.color.web_wisteria to R.string.web_wisteria,
R.color.web_yellow to R.string.web_yellow,
R.color.web_yellow_green to R.string.web_yellow_green,
)
}

View File

@@ -20,6 +20,7 @@ import androidx.core.graphics.drawable.DrawableCompat;
import org.autojs.autojs.theme.internal.ScrollingViewEdgeGlowColorHelper;
import org.autojs.autojs.util.ColorUtils;
import org.autojs.autojs.util.ViewUtils;
import org.autojs.autojs6.R;
/**
@@ -116,7 +117,7 @@ public class ThemeColorHelper {
public static void setStatusBarColor(Activity activity, int color) {
Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(color);
ViewUtils.setStatusBarBackgroundColor(activity, color);
}
public static void setBackgroundColor(View view, int color) {

View File

@@ -3,6 +3,12 @@ package org.autojs.autojs.theme.app
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.View
import org.autojs.autojs.core.pref.Pref
import org.autojs.autojs.theme.ThemeChangeNotifier
import org.autojs.autojs.theme.ThemeColorManager
import org.autojs.autojs.util.StringUtils.key
import org.autojs.autojs.util.ViewUtils
import org.autojs.autojs6.R
import org.autojs.autojs6.databinding.MtActivityColorSelectBinding
@@ -13,6 +19,16 @@ class ColorSelectActivity : ColorSelectBaseActivity() {
private lateinit var binding: MtActivityColorSelectBinding
private lateinit var mColorSettingRecyclerView: ColorSettingRecyclerView
private val mOnItemClickListener = object : OnItemClickListener {
override fun onItemClick(v: View?, position: Int) {
mColorSettingRecyclerView.selectedThemeColor?.let {
setColorWithAnimation(it.colorPrimary)
}
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
MtActivityColorSelectBinding.inflate(layoutInflater).also {
@@ -24,6 +40,23 @@ class ColorSelectActivity : ColorSelectBaseActivity() {
}
}
private fun setUpColorSettingRecyclerView(colorSettingRecyclerView: ColorSettingRecyclerView) {
mColorSettingRecyclerView = colorSettingRecyclerView.apply {
setSelectedColor(currentColor)
setOnItemClickListener(mOnItemClickListener)
ViewUtils.excludePaddingClippableViewFromNavigationBar(this)
}
}
override fun finish() {
mColorSettingRecyclerView.selectedThemeColor?.let {
ThemeColorManager.setThemeColor(it.colorPrimary)
Pref.putString(key(R.string.key_theme_color), getCurrentColorSummary(this))
ThemeChangeNotifier.notifyThemeChanged()
}
super.finish()
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_color_select, menu)
return super.onCreateOptionsMenu(menu)
@@ -31,18 +64,26 @@ class ColorSelectActivity : ColorSelectBaseActivity() {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.action_color_palette -> {
ViewUtils.showToast(this, R.string.text_under_development_title)
}
R.id.action_search_color -> {
ViewUtils.showToast(this, R.string.text_under_development_title)
}
R.id.action_new_color_library -> {
ViewUtils.showToast(this, R.string.text_under_development_title)
}
R.id.action_locate_current_color -> {
ViewUtils.showToast(this, R.string.text_under_development_title)
}
R.id.action_toggle_color_select_layout -> {
isLegacyLayout = true
startActivity(this)
}
R.id.action_locate_current_color -> {
}
R.id.action_search_color -> {
}
}
return true
}
override fun getSubtitle() = getCurrentColorSummary(this)
}

View File

@@ -9,13 +9,12 @@ import android.view.ViewAnimationUtils
import androidx.appcompat.widget.Toolbar
import com.google.android.material.appbar.AppBarLayout
import io.codetail.widget.RevealFrameLayout
import org.autojs.autojs.core.image.ColorItems
import org.autojs.autojs.core.pref.Pref
import org.autojs.autojs.theme.ThemeChangeNotifier
import org.autojs.autojs.theme.ThemeColor
import org.autojs.autojs.theme.ThemeColorManager
import org.autojs.autojs.ui.BaseActivity
import org.autojs.autojs.util.ColorUtils
import org.autojs.autojs.util.StringUtils.key
import org.autojs.autojs.util.ViewUtils
import org.autojs.autojs.util.ViewUtils.setMenuIconsColorByColorLuminance
import org.autojs.autojs.util.ViewUtils.setNavigationIconColorByColorLuminance
@@ -36,59 +35,36 @@ abstract class ColorSelectBaseActivity : BaseActivity() {
private lateinit var mToolbar: Toolbar
private lateinit var mAppBarLayout: AppBarLayout
private lateinit var mAppBarContainer: RevealFrameLayout
private lateinit var mColorSettingRecyclerView: ColorSettingRecyclerView
private lateinit var mTitle: String
private val mOnItemClickListener = object : OnItemClickListener {
override fun onItemClick(v: View?, position: Int) {
mColorSettingRecyclerView.selectedThemeColor?.let {
setColorWithAnimation(mAppBarLayout, it.colorPrimary)
}
}
}
private var currentColor by Delegates.notNull<Int>()
protected var currentColor by Delegates.notNull<Int>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mTitle = this.intent.getStringExtra("title") ?: this.getString(R.string.mt_color_picker_title)
currentColor = this.intent.getIntExtra("currentColor", ThemeColorManager.colorPrimary)
mTitle = intent.getStringExtra("title") ?: getString(R.string.text_theme_color)
currentColor = intent.getIntExtra("currentColor", ThemeColorManager.colorPrimary)
}
protected fun setUpToolbar(toolbar: Toolbar) {
toolbar.apply {
title = mTitle
subtitle = this@ColorSelectBaseActivity.getSubtitle()
setSupportActionBar(this)
setNavigationOnClickListener { finish() }
setTitleTextAppearance(this@ColorSelectBaseActivity, R.style.TextAppearanceMainTitle)
setSubtitleTextAppearance(this@ColorSelectBaseActivity, R.style.TextAppearanceMainSubtitle)
mToolbar = this
}
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}
protected fun setUpColorSettingRecyclerView(colorSettingRecyclerView: ColorSettingRecyclerView) {
mColorSettingRecyclerView = colorSettingRecyclerView.apply {
setCustomColor()
setSelectedColor(currentColor)
setOnItemClickListener(mOnItemClickListener)
ViewUtils.excludePaddingClippableViewFromNavigationBar(this)
}
}
override fun finish() {
mColorSettingRecyclerView.selectedThemeColor?.let {
ThemeColorManager.setThemeColor(it.colorPrimary)
Pref.putString(key(R.string.key_theme_color), getColorString(this))
ThemeChangeNotifier.notifyThemeChanged()
}
super.finish()
}
protected fun finishWithoutSaving() {
super.finish()
}
protected open fun getSubtitle(): String? = null
override fun initThemeColors() {
super.initThemeColors()
mToolbar.setTitlesTextColorByColorLuminance(this, currentColor)
@@ -105,20 +81,22 @@ abstract class ColorSelectBaseActivity : BaseActivity() {
mToolbar.setMenuIconsColorByColorLuminance(this, currentColor)
}
private fun setColorWithAnimation(view: View, colorTo: Int) {
protected fun setColorWithAnimation(colorTo: Int) {
val view = mAppBarLayout
mAppBarContainer.setBackgroundColor(currentColor)
view.setBackgroundColor(colorTo)
currentColor = colorTo
initThemeColors()
updateToolbarIconsColor()
mToolbar.subtitle = getSubtitle()
ViewAnimationUtils.createCircularReveal(
/* view = */ view,
/* centerX = */ view.left,
/* centerY = */ view.bottom,
/* startRadius = */ 0f,
/* endRadius = */ hypot(view.width.toDouble(), view.height.toDouble()).toFloat()
/* endRadius = */ hypot(view.width.toDouble(), view.height.toDouble()).toFloat(),
).apply {
duration = 500L
start()
@@ -155,14 +133,26 @@ abstract class ColorSelectBaseActivity : BaseActivity() {
get() = Pref.getBoolean(R.string.key_color_select_activity_legacy_layout, false)
set(value) = Pref.putBoolean(R.string.key_color_select_activity_legacy_layout, value)
val colorItems by lazy {
mutableListOf<Pair</* colorRes */ Int, /* nameRes */ Int>>().apply {
add(customColorPosition, 0 to R.string.mt_custom)
add(defaultColorPosition, R.color.theme_color_default to R.string.theme_color_default)
addAll(ColorItems.MATERIAL_COLORS)
}
}
@JvmStatic
fun startActivity(context: Context) {
val cls = when (isLegacyLayout) {
true -> ColorSelectLegacyActivity::class.java
else -> ColorSelectActivity::class.java
}
val titleRes = when (isLegacyLayout) {
true -> R.string.mt_color_picker_title
else -> R.string.text_theme_color
}
val intent = Intent(context, cls).apply {
putExtra("title", context.getString(R.string.mt_color_picker_title))
putExtra("title", context.getString(titleRes))
}
if (context is ColorSelectBaseActivity) {
intent.putExtra("currentColor", context.currentColor)
@@ -171,19 +161,18 @@ abstract class ColorSelectBaseActivity : BaseActivity() {
context.startActivity(intent)
}
fun getColorString(context: Context): String {
@JvmStatic
fun getCurrentColorSummary(context: Context): String {
val index = Pref.getInt(KEY_SELECTED_COLOR_INDEX, defaultColorPosition)
val colorItem = getColorItems(context)[index]
return "${colorItem.name} [${ColorUtils.toString(colorItem.themeColor.colorPrimary).uppercase()}]"
}
internal fun getColorItems(context: Context): List<ColorItem> = ArrayList<Pair</* nameRes */ Int, /* colorInt */ Int>>()
.apply {
add(customColorPosition, Pair(Pref.getInt(KEY_CUSTOM_COLOR, context.getColor(R.color.md_blue_grey_800)), R.string.mt_custom))
add(defaultColorPosition, Pair(context.getColor(R.color.theme_color_default), R.string.theme_color_default))
addAll(ColorUtils.MATERIAL_COLOR_ITEMS.map { pair -> Pair(context.getColor(pair.first), pair.second) })
val colorItem = colorItems[index]
val (colorRes, nameRes) = colorItem
val name = context.getString(nameRes)
val colorInt = when (index) {
customColorPosition -> Pref.getInt(KEY_CUSTOM_COLOR, context.getColor(R.color.md_blue_grey_800))
else -> context.getColor(colorRes)
}
.map { (colorInt, nameRes) -> ColorItem(context.getString(nameRes), colorInt) }
return "$name [${ColorUtils.toString(colorInt).uppercase()}]"
}
}

View File

@@ -3,6 +3,12 @@ package org.autojs.autojs.theme.app
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.View
import org.autojs.autojs.core.pref.Pref
import org.autojs.autojs.theme.ThemeChangeNotifier
import org.autojs.autojs.theme.ThemeColorManager
import org.autojs.autojs.util.StringUtils.key
import org.autojs.autojs.util.ViewUtils
import org.autojs.autojs6.R
import org.autojs.autojs6.databinding.MtActivityColorSelectLegacyBinding
@@ -13,6 +19,16 @@ class ColorSelectLegacyActivity : ColorSelectBaseActivity() {
private lateinit var binding: MtActivityColorSelectLegacyBinding
private lateinit var mColorSettingRecyclerView: ColorSettingRecyclerViewLegacy
private val mOnItemClickListener = object : OnItemClickListener {
override fun onItemClick(v: View?, position: Int) {
mColorSettingRecyclerView.selectedThemeColor?.let {
setColorWithAnimation(it.colorPrimary)
}
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
MtActivityColorSelectLegacyBinding.inflate(layoutInflater).also {
@@ -24,6 +40,23 @@ class ColorSelectLegacyActivity : ColorSelectBaseActivity() {
}
}
private fun setUpColorSettingRecyclerView(colorSettingRecyclerView: ColorSettingRecyclerViewLegacy) {
mColorSettingRecyclerView = colorSettingRecyclerView.apply {
setSelectedColor(currentColor)
setOnItemClickListener(mOnItemClickListener)
ViewUtils.excludePaddingClippableViewFromNavigationBar(this)
}
}
override fun finish() {
mColorSettingRecyclerView.selectedThemeColor?.let {
ThemeColorManager.setThemeColor(it.colorPrimary)
Pref.putString(key(R.string.key_theme_color), getCurrentColorSummary(this))
ThemeChangeNotifier.notifyThemeChanged()
}
super.finish()
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_color_select_legacy, menu)
return super.onCreateOptionsMenu(menu)

View File

@@ -9,17 +9,15 @@ import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.ColorInt
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.ThemeColorRecyclerView
import com.jaredrummler.android.colorpicker.ColorPickerDialog
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener
import org.autojs.autojs.core.pref.Pref
import org.autojs.autojs.theme.ThemeColor
import org.autojs.autojs.theme.ThemeColorHelper
import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.customColorPosition
import org.autojs.autojs.util.ColorUtils
import org.autojs.autojs6.R
@@ -36,19 +34,23 @@ class ColorSettingRecyclerView : ThemeColorRecyclerView {
private var mSelectedPosition = ColorSelectBaseActivity.SELECT_NONE
val selectedThemeColor: ThemeColor?
get() = ColorSelectBaseActivity.getColorItems(context)[mSelectedPosition].themeColor.takeUnless { mSelectedPosition < 0 }
get() = when {
mSelectedPosition < 0 -> null
mSelectedPosition == customColorPosition -> customColor
else -> context.getColor(ColorSelectBaseActivity.colorItems[mSelectedPosition].first)
}?.let { ThemeColor(it) }
private val customColor: Int
get() = Pref.getInt(ColorSelectBaseActivity.KEY_CUSTOM_COLOR, context.getColor(R.color.md_blue_grey_800))
private val mActualOnItemClickListener = OnClickListener { v ->
getChildViewHolder(v)?.let { holder ->
val pos = holder.bindingAdapterPosition
if (pos == ColorSelectBaseActivity.customColorPosition) {
showColorPicker(v)
} else {
setSelectedPosition(pos)
mOnItemClickListener?.onItemClick(v, pos)
when (val pos = holder.bindingAdapterPosition) {
customColorPosition -> showColorPicker(v)
else -> {
setSelectedPosition(pos)
mOnItemClickListener?.onItemClick(v, pos)
}
}
}
}
@@ -73,8 +75,12 @@ class ColorSettingRecyclerView : ThemeColorRecyclerView {
}
fun setSelectedColor(colorPrimary: Int) {
for ((i, colorItem) in ColorSelectBaseActivity.getColorItems(context).withIndex()) {
if (colorItem.themeColor.colorPrimary == colorPrimary) {
for ((i, colorItem) in ColorSelectBaseActivity.colorItems.withIndex()) {
val color = when (i) {
customColorPosition -> customColor
else -> context.getColor(colorItem.first)
}
if (color == colorPrimary) {
setSelectedPosition(i)
return
}
@@ -82,14 +88,6 @@ class ColorSettingRecyclerView : ThemeColorRecyclerView {
mSelectedPosition = ColorSelectBaseActivity.SELECT_NONE
}
private fun setCustomColor(color: Int) {
ColorSelectBaseActivity.getColorItems(context)[ColorSelectBaseActivity.customColorPosition].themeColor.colorPrimary = color
}
fun setCustomColor() {
setCustomColor(customColor)
}
private fun showColorPicker(v: View) {
ColorPickerDialog.newBuilder()
.setAllowCustom(true)
@@ -99,20 +97,13 @@ class ColorSettingRecyclerView : ThemeColorRecyclerView {
.setDialogTitle(R.string.mt_color_picker_title)
.setColor(customColor)
.create()
.apply {
setColorPickerDialogListener(object : ColorPickerDialogListener {
override fun onColorSelected(dialogId: Int, @ColorInt color: Int) {
val c = color or -0x1000000
Pref.putInt(ColorSelectBaseActivity.KEY_CUSTOM_COLOR, c)
setCustomColor(c)
setSelectedPosition(ColorSelectBaseActivity.customColorPosition)
mOnItemClickListener?.onItemClick(v, ColorSelectBaseActivity.customColorPosition)
}
override fun onDialogDismissed(dialogId: Int) {}
})
.setColorPickerDialogListener { _: Int, color: Int ->
val customColor = color or -0x1000000
Pref.putInt(ColorSelectBaseActivity.KEY_CUSTOM_COLOR, customColor)
setSelectedPosition(customColorPosition)
mOnItemClickListener?.onItemClick(v, customColorPosition)
}
.show((context as FragmentActivity).supportFragmentManager, "Tag")
.show((context as ColorSelectBaseActivity).supportFragmentManager, "ColorPickerTag")
}
fun setOnItemClickListener(onItemClickListener: ColorSelectBaseActivity.OnItemClickListener?) {
@@ -126,16 +117,21 @@ class ColorSettingRecyclerView : ThemeColorRecyclerView {
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val item = ColorSelectBaseActivity.getColorItems(context)[position]
val colorItem = ColorSelectBaseActivity.colorItems[position]
val (colorRes, nameRes) = colorItem
val color = when (position) {
customColorPosition -> customColor
else -> context.getColor(colorRes)
}
holder.apply {
setColor(item.themeColor.colorPrimary)
nameView.text = item.name
setColor(color)
nameView.text = context.getString(nameRes)
nameView.setTextColor(context.getColor(R.color.color_selector_item_text))
setChecked(mSelectedPosition == position)
}
}
override fun getItemCount() = ColorSelectBaseActivity.getColorItems(context).size
override fun getItemCount() = ColorSelectBaseActivity.colorItems.size
}

View File

@@ -0,0 +1,174 @@
package org.autojs.autojs.theme.app
import android.annotation.SuppressLint
import android.content.Context
import android.content.res.ColorStateList
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.ColorInt
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.ThemeColorRecyclerView
import com.jaredrummler.android.colorpicker.ColorPickerDialog
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener
import org.autojs.autojs.core.pref.Pref
import org.autojs.autojs.theme.ThemeColor
import org.autojs.autojs.theme.ThemeColorHelper
import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.customColorPosition
import org.autojs.autojs.util.ColorUtils
import org.autojs.autojs6.R
class ColorSettingRecyclerViewLegacy : ThemeColorRecyclerView {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle)
private var mOnItemClickListener: ColorSelectBaseActivity.OnItemClickListener? = null
private var mSelectedPosition = ColorSelectBaseActivity.SELECT_NONE
val selectedThemeColor: ThemeColor?
get() = when {
mSelectedPosition < 0 -> null
mSelectedPosition == customColorPosition -> customColor
else -> context.getColor(ColorSelectBaseActivity.colorItems[mSelectedPosition].first)
}?.let { ThemeColor(it) }
private val customColor: Int
get() = Pref.getInt(ColorSelectBaseActivity.KEY_CUSTOM_COLOR, context.getColor(R.color.md_blue_grey_800))
private val mActualOnItemClickListener = OnClickListener { v ->
getChildViewHolder(v)?.let { holder ->
when (val pos = holder.bindingAdapterPosition) {
customColorPosition -> showColorPicker(v)
else -> {
setSelectedPosition(pos)
mOnItemClickListener?.onItemClick(v, pos)
}
}
}
}
init {
adapter = Adapter()
layoutManager = LinearLayoutManager(context)
addItemDecoration(DividerItemDecoration(context, VERTICAL))
}
@SuppressLint("NotifyDataSetChanged")
fun setSelectedPosition(currentPosition: Int) {
if (mSelectedPosition != ColorSelectBaseActivity.SELECT_NONE) {
adapter!!.notifyItemChanged(mSelectedPosition)
mSelectedPosition = currentPosition
adapter!!.notifyItemChanged(currentPosition)
} else {
mSelectedPosition = currentPosition
adapter!!.notifyDataSetChanged()
}
Pref.putInt(ColorSelectBaseActivity.KEY_SELECTED_COLOR_INDEX, mSelectedPosition)
}
fun setSelectedColor(colorPrimary: Int) {
for ((i, colorItem) in ColorSelectBaseActivity.colorItems.withIndex()) {
val color = when (i) {
customColorPosition -> customColor
else -> context.getColor(colorItem.first)
}
if (color == colorPrimary) {
setSelectedPosition(i)
return
}
}
mSelectedPosition = ColorSelectBaseActivity.SELECT_NONE
}
private fun showColorPicker(v: View) {
ColorPickerDialog.newBuilder()
.setAllowCustom(true)
.setAllowPresets(false)
.setDialogType(ColorPickerDialog.TYPE_CUSTOM)
.setShowAlphaSlider(false)
.setDialogTitle(R.string.mt_color_picker_title)
.setColor(customColor)
.create()
.apply {
setColorPickerDialogListener(object : ColorPickerDialogListener {
override fun onColorSelected(dialogId: Int, @ColorInt color: Int) {
val c = color or -0x1000000
Pref.putInt(ColorSelectBaseActivity.KEY_CUSTOM_COLOR, c)
setSelectedPosition(customColorPosition)
mOnItemClickListener?.onItemClick(v, customColorPosition)
}
override fun onDialogDismissed(dialogId: Int) {}
})
}
.show((context as FragmentActivity).supportFragmentManager, "Tag")
}
fun setOnItemClickListener(onItemClickListener: ColorSelectBaseActivity.OnItemClickListener?) {
mOnItemClickListener = onItemClickListener
}
private inner class Adapter : RecyclerView.Adapter<ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(LayoutInflater.from(context).inflate(R.layout.mt_color_setting_recycler_view_item, parent, false))
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val colorItem = ColorSelectBaseActivity.colorItems[position]
val (colorRes, nameRes) = colorItem
val color = when (position) {
customColorPosition -> customColor
else -> context.getColor(colorRes)
}
holder.apply {
setColor(color)
nameView.text = context.getString(nameRes)
nameView.setTextColor(context.getColor(R.color.color_selector_item_text))
setChecked(mSelectedPosition == position)
}
}
override fun getItemCount() = ColorSelectBaseActivity.colorItems.size
}
private inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var colorView: ImageView
var nameView: TextView
init {
itemView.setOnClickListener(mActualOnItemClickListener)
colorView = itemView.findViewById(R.id.color)
nameView = itemView.findViewById(R.id.name)
}
fun setChecked(checked: Boolean) {
if (checked) {
colorView.setImageResource(R.drawable.mt_ic_check_white_36dp)
val selectedThemeColorRes = selectedThemeColor?.colorPrimary?.let {
if (ColorUtils.isLuminanceLight(it)) R.color.day else R.color.night
} ?: R.color.night_day
colorView.imageTintList = ColorStateList.valueOf(context.getColor(selectedThemeColorRes))
} else {
colorView.setImageDrawable(null)
}
}
fun setColor(c: Int) = ThemeColorHelper.setBackgroundColor(colorView, c)
}
}

View File

@@ -2,7 +2,6 @@ package org.autojs.autojs.theme.widget
import android.content.Context
import android.util.AttributeSet
import android.view.ViewTreeObserver.OnGlobalLayoutListener
import androidx.appcompat.widget.Toolbar
import org.autojs.autojs.theme.ThemeColor
import org.autojs.autojs.theme.ThemeColorManager.add
@@ -10,6 +9,7 @@ import org.autojs.autojs.theme.ThemeColorManager.getDayOrNightColorByLuminance
import org.autojs.autojs.theme.ThemeColorManager.isThemeColorLuminanceLight
import org.autojs.autojs.theme.ThemeColorMutable
import org.autojs.autojs.util.ViewUtils.applyColorFilterWith
import org.autojs.autojs.util.ViewUtils.onceGlobalLayout
import org.autojs.autojs6.R
/**
@@ -37,7 +37,7 @@ open class ThemeColorToolbar : Toolbar, ThemeColorMutable {
}
override fun setThemeColor(color: ThemeColor) {
viewTreeObserver.addOnGlobalLayoutListener(OnGlobalLayoutListener { applyThemeColor(color) })
onceGlobalLayout { applyThemeColor(color) }
}
private fun applyThemeColor(color: ThemeColor) {

View File

@@ -1,5 +1,6 @@
package org.autojs.autojs.ui.edit
import android.animation.ValueAnimator
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
@@ -14,7 +15,6 @@ import android.util.TypedValue
import android.view.ActionMode
import android.view.Menu
import android.view.MenuItem
import android.view.ViewTreeObserver
import android.widget.TextView
import androidx.appcompat.widget.Toolbar
import com.afollestad.materialdialogs.MaterialDialog
@@ -32,6 +32,7 @@ import org.autojs.autojs.theme.widget.ThemeColorToolbar
import org.autojs.autojs.ui.BaseActivity
import org.autojs.autojs.ui.main.MainActivity
import org.autojs.autojs.util.Observers
import org.autojs.autojs.util.ViewUtils.onceGlobalLayout
import org.autojs.autojs.util.ViewUtils.setMenuIconsColorByThemeColorLuminance
import org.autojs.autojs6.R
import org.autojs.autojs6.databinding.ActivityEditBinding
@@ -71,99 +72,6 @@ open class EditActivity : BaseActivity(), DelegateHost, PermissionRequestProxyAc
setUpToolbar()
}
// @Created by JetBrains AI Assistant on Mar 24, 2025.
private fun adjustTitleTextView(textView: TextView) {
textView.post {
// 可用宽度, 排除内边距
val availableWidth = textView.width - textView.paddingLeft - textView.paddingRight
if (availableWidth <= 0) return@post
val textStr = textView.text.toString()
val isNonAscii = textStr.any { it.code >= 0x80 }
val paint: TextPaint = textView.paint
val originTextSizePx = textView.textSize
val step = resources.getDimension(R.dimen.editor_title_text_size_step)
/* ---------- 尝试一行显示 (单行) ---------- */
textView.isSingleLine = true
textView.maxLines = 1
var oneLineTextSizePx = originTextSizePx
val minOneLineSizePx = resources.getDimension(R.dimen.editor_title_min_text_size_single_line)
// 测量一行文字宽度
paint.textSize = oneLineTextSizePx
var measuredWidth = paint.measureText(textStr)
// 当文字宽度超出可用宽度并且字号还高于下限的时候逐步降低字号
while (measuredWidth > availableWidth && oneLineTextSizePx > minOneLineSizePx) {
oneLineTextSizePx -= step
paint.textSize = oneLineTextSizePx
measuredWidth = paint.measureText(textStr)
}
// 如果一行能够显示文字, 则直接应用修改
if (measuredWidth <= availableWidth) {
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, oneLineTextSizePx)
return@post
}
/* ---------- 切换为两行显示 ---------- */
textView.isSingleLine = false
textView.maxLines = 2
// 重置字号
var twoLineTextSize = when (isNonAscii) {
true -> resources.getDimension(R.dimen.editor_title_text_size_double_line_non_ascii)
else -> resources.getDimension(R.dimen.editor_title_text_size_double_line_ascii)
}
val minTwoLineSize = resources.getDimension(R.dimen.editor_title_min_text_size_double_line)
paint.textSize = twoLineTextSize
// 检查两行显示是否足够: 利用 StaticLayout 测量文字显示效果
fun createStaticLayout(textSize: Float): StaticLayout {
paint.textSize = textSize
return StaticLayout.Builder
.obtain(textStr, 0, textStr.length, paint, availableWidth)
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
.setLineSpacing(0f, 1f)
.build()
}
var layout = createStaticLayout(twoLineTextSize)
// 当行数超出了两行且字号尚未到达最低要求, 则逐步降低字号
while (layout.lineCount > 2 && twoLineTextSize > minTwoLineSize) {
twoLineTextSize -= step
layout = createStaticLayout(twoLineTextSize)
}
if (layout.lineCount <= 2) {
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, twoLineTextSize)
return@post
}
/* ---------- 切换为三行显示 ---------- */
textView.maxLines = 3
var threeLineSize = when (isNonAscii) {
true -> resources.getDimension(R.dimen.editor_title_text_size_triple_line_non_ascii)
else -> resources.getDimension(R.dimen.editor_title_text_size_triple_line_ascii)
}
val minThreeLineSize = resources.getDimension(R.dimen.editor_title_min_text_size_triple_line)
paint.textSize = threeLineSize
layout = createStaticLayout(threeLineSize)
while (layout.lineCount > 3 && threeLineSize > minThreeLineSize) {
threeLineSize -= step
layout = createStaticLayout(threeLineSize)
}
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, threeLineSize)
}
}
private fun onLoadFileError(message: String?) {
MaterialDialog.Builder(this)
.title(getString(R.string.text_cannot_read_file))
@@ -182,19 +90,112 @@ open class EditActivity : BaseActivity(), DelegateHost, PermissionRequestProxyAc
menuInflater.inflate(R.menu.menu_editor, menu)
mToolbar?.let { toolbar ->
toolbar.setMenuIconsColorByThemeColorLuminance(this)
toolbar.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
val titleView = toolbar.findViewById(com.google.android.material.R.id.action_bar_title) ?: run {
Toolbar::class.java.getDeclaredField("mTitleTextView").apply { isAccessible = true }.get(toolbar) as TextView?
}
titleView?.let { adjustTitleTextView(it) }
toolbar.viewTreeObserver.removeOnGlobalLayoutListener(this)
toolbar.onceGlobalLayout {
val titleView = toolbar.findViewById(com.google.android.material.R.id.action_bar_title) ?: run {
Toolbar::class.java.getDeclaredField("mTitleTextView").apply { isAccessible = true }.get(toolbar) as TextView?
}
})
titleView?.adjustTitleTextView()
}
}
return true
}
private fun TextView.adjustTitleTextView() = this.post {
ValueAnimator.ofFloat(this.textSize, calculatedTextSize(this) ?: return@post).let {
it.duration = 120L
it.addUpdateListener { this.setTextSize(TypedValue.COMPLEX_UNIT_PX, it.animatedValue as Float) }
it.start()
}
}
// @Created by JetBrains AI Assistant on Mar 24, 2025.
private fun calculatedTextSize(textView: TextView): Float? {
// 可用宽度, 排除内边距
val availableWidth = textView.width - textView.paddingLeft - textView.paddingRight
if (availableWidth <= 0) return null
val textStr = textView.text.toString()
val isNonAscii = textStr.any { it.code >= 0x80 }
val paint: TextPaint = textView.paint
val step = resources.getDimension(R.dimen.editor_title_text_size_step)
/* ---------- 尝试一行显示 (单行) ---------- */
textView.isSingleLine = true
textView.maxLines = 1
var oneLineTextSizePx = textView.textSize
val minOneLineSizePx = resources.getDimension(R.dimen.editor_title_min_text_size_single_line)
// 测量一行文字宽度
paint.textSize = oneLineTextSizePx
var measuredWidth = paint.measureText(textStr)
// 当文字宽度超出可用宽度并且字号还高于下限的时候逐步降低字号
while (measuredWidth > availableWidth && oneLineTextSizePx > minOneLineSizePx) {
oneLineTextSizePx -= step
paint.textSize = oneLineTextSizePx
measuredWidth = paint.measureText(textStr)
}
// 如果一行能够显示文字, 则直接应用修改
if (measuredWidth <= availableWidth) {
return oneLineTextSizePx
}
/* ---------- 切换为两行显示 ---------- */
textView.isSingleLine = false
textView.maxLines = 2
// 重置字号
var twoLineTextSize = when (isNonAscii) {
true -> resources.getDimension(R.dimen.editor_title_text_size_double_line_non_ascii)
else -> resources.getDimension(R.dimen.editor_title_text_size_double_line_ascii)
}
val minTwoLineSize = resources.getDimension(R.dimen.editor_title_min_text_size_double_line)
paint.textSize = twoLineTextSize
// 检查两行显示是否足够: 利用 StaticLayout 测量文字显示效果
fun createStaticLayout(textSize: Float): StaticLayout {
paint.textSize = textSize
return StaticLayout.Builder
.obtain(textStr, 0, textStr.length, paint, availableWidth)
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
.setLineSpacing(0f, 1f)
.build()
}
var layout = createStaticLayout(twoLineTextSize)
// 当行数超出了两行且字号尚未到达最低要求, 则逐步降低字号
while (layout.lineCount > 2 && twoLineTextSize > minTwoLineSize) {
twoLineTextSize -= step
layout = createStaticLayout(twoLineTextSize)
}
if (layout.lineCount <= 2) {
return twoLineTextSize
}
/* ---------- 切换为三行显示 ---------- */
textView.maxLines = 3
var threeLineSize = when (isNonAscii) {
true -> resources.getDimension(R.dimen.editor_title_text_size_triple_line_non_ascii)
else -> resources.getDimension(R.dimen.editor_title_text_size_triple_line_ascii)
}
val minThreeLineSize = resources.getDimension(R.dimen.editor_title_min_text_size_triple_line)
paint.textSize = threeLineSize
layout = createStaticLayout(threeLineSize)
while (layout.lineCount > 3 && threeLineSize > minThreeLineSize) {
threeLineSize -= step
layout = createStaticLayout(threeLineSize)
}
return threeLineSize
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return mEditorMenu.onOptionsItemSelected(item)
}

View File

@@ -367,6 +367,7 @@ open class DrawerFragment : Fragment() {
mThemeColorItem = DrawerMenuShortcutItem(R.drawable.ic_personalize, R.string.text_theme_color)
.setAction(Runnable { ColorSelectBaseActivity.startActivity(mContext) })
.apply { subtitle = ColorSelectBaseActivity.getCurrentColorSummary(mContext) }
mAboutAppAndDevItem = DrawerMenuShortcutItem(R.drawable.ic_about, R.string.text_about_app_and_developer)
.setAction(Runnable { AboutActivity.startActivity(mContext) })

View File

@@ -78,7 +78,6 @@ object MediaInfoDialogManager {
launch(Dispatchers.IO) {
mediaInfo(filePath, AUDIO, "BitRate/String").let { binding.bitRateForAudioValue.bindWith(it) }
}
launch(Dispatchers.IO) {
mediaInfo(filePath, VIDEO, "BitRate/String").let { binding.bitRateForVideoValue.bindWith(it) }
}

View File

@@ -19,7 +19,7 @@ class ThemeColorPreference : MaterialPreference, SharedPreferences.OnSharedPrefe
init {
Pref.registerOnSharedPreferenceChangeListener(this)
summaryProvider = SummaryProvider<ThemeColorPreference> { ColorSelectBaseActivity.getColorString(prefContext) }
summaryProvider = SummaryProvider<ThemeColorPreference> { ColorSelectBaseActivity.getCurrentColorSummary(prefContext) }
}
override fun onClick() {

View File

@@ -7,12 +7,11 @@ import android.content.res.Configuration;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.ViewTreeObserver;
import android.view.Window;
import androidx.annotation.Nullable;
import com.google.android.material.appbar.AppBarLayout;
import kotlin.Unit;
import org.autojs.autojs.util.ViewUtils;
/**
* Created by Stardust on Aug 22, 2017.
@@ -42,12 +41,9 @@ public class AppWithStatusBarLayout extends AppBarLayout {
}
private void setPadding() {
getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
setPadding(getPaddingLeft(), getStatusBarHeight(), getPaddingRight(), getPaddingBottom());
getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
ViewUtils.onceViewGlobalLayout(this, () -> {
setPadding(getPaddingLeft(), getStatusBarHeight(), getPaddingRight(), getPaddingBottom());
return Unit.INSTANCE;
});
}

View File

@@ -22,323 +22,6 @@ import kotlin.text.RegexOption.IGNORE_CASE
@Suppress("FunctionName")
object ColorUtils {
@JvmField
val MATERIAL_COLOR_ITEMS: List<Pair</* colorRes */ Int, /* colorNameRes */ Int>> = listOf(
/* reds */
R.color.md_red_50 to R.string.md_red_50,
R.color.md_red_100 to R.string.md_red_100,
R.color.md_red_200 to R.string.md_red_200,
R.color.md_red_300 to R.string.md_red_300,
R.color.md_red_400 to R.string.md_red_400,
R.color.md_red_500 to R.string.md_red_500,
R.color.md_red_600 to R.string.md_red_600,
R.color.md_red_700 to R.string.md_red_700,
R.color.md_red_800 to R.string.md_red_800,
R.color.md_red_900 to R.string.md_red_900,
R.color.md_red_a100 to R.string.md_red_a100,
R.color.md_red_a200 to R.string.md_red_a200,
R.color.md_red_a400 to R.string.md_red_a400,
R.color.md_red_a700 to R.string.md_red_a700,
/* pinks */
R.color.md_pink_50 to R.string.md_pink_50,
R.color.md_pink_100 to R.string.md_pink_100,
R.color.md_pink_200 to R.string.md_pink_200,
R.color.md_pink_300 to R.string.md_pink_300,
R.color.md_pink_400 to R.string.md_pink_400,
R.color.md_pink_500 to R.string.md_pink_500,
R.color.md_pink_600 to R.string.md_pink_600,
R.color.md_pink_700 to R.string.md_pink_700,
R.color.md_pink_800 to R.string.md_pink_800,
R.color.md_pink_900 to R.string.md_pink_900,
R.color.md_pink_a100 to R.string.md_pink_a100,
R.color.md_pink_a200 to R.string.md_pink_a200,
R.color.md_pink_a400 to R.string.md_pink_a400,
R.color.md_pink_a700 to R.string.md_pink_a700,
/* purples */
R.color.md_purple_50 to R.string.md_purple_50,
R.color.md_purple_100 to R.string.md_purple_100,
R.color.md_purple_200 to R.string.md_purple_200,
R.color.md_purple_300 to R.string.md_purple_300,
R.color.md_purple_400 to R.string.md_purple_400,
R.color.md_purple_500 to R.string.md_purple_500,
R.color.md_purple_600 to R.string.md_purple_600,
R.color.md_purple_700 to R.string.md_purple_700,
R.color.md_purple_800 to R.string.md_purple_800,
R.color.md_purple_900 to R.string.md_purple_900,
R.color.md_purple_a100 to R.string.md_purple_a100,
R.color.md_purple_a200 to R.string.md_purple_a200,
R.color.md_purple_a400 to R.string.md_purple_a400,
R.color.md_purple_a700 to R.string.md_purple_a700,
/* deep purples */
R.color.md_deep_purple_50 to R.string.md_deep_purple_50,
R.color.md_deep_purple_100 to R.string.md_deep_purple_100,
R.color.md_deep_purple_200 to R.string.md_deep_purple_200,
R.color.md_deep_purple_300 to R.string.md_deep_purple_300,
R.color.md_deep_purple_400 to R.string.md_deep_purple_400,
R.color.md_deep_purple_500 to R.string.md_deep_purple_500,
R.color.md_deep_purple_600 to R.string.md_deep_purple_600,
R.color.md_deep_purple_700 to R.string.md_deep_purple_700,
R.color.md_deep_purple_800 to R.string.md_deep_purple_800,
R.color.md_deep_purple_900 to R.string.md_deep_purple_900,
R.color.md_deep_purple_a100 to R.string.md_deep_purple_a100,
R.color.md_deep_purple_a200 to R.string.md_deep_purple_a200,
R.color.md_deep_purple_a400 to R.string.md_deep_purple_a400,
R.color.md_deep_purple_a700 to R.string.md_deep_purple_a700,
/* indigo */
R.color.md_indigo_50 to R.string.md_indigo_50,
R.color.md_indigo_100 to R.string.md_indigo_100,
R.color.md_indigo_200 to R.string.md_indigo_200,
R.color.md_indigo_300 to R.string.md_indigo_300,
R.color.md_indigo_400 to R.string.md_indigo_400,
R.color.md_indigo_500 to R.string.md_indigo_500,
R.color.md_indigo_600 to R.string.md_indigo_600,
R.color.md_indigo_700 to R.string.md_indigo_700,
R.color.md_indigo_800 to R.string.md_indigo_800,
R.color.md_indigo_900 to R.string.md_indigo_900,
R.color.md_indigo_a100 to R.string.md_indigo_a100,
R.color.md_indigo_a200 to R.string.md_indigo_a200,
R.color.md_indigo_a400 to R.string.md_indigo_a400,
R.color.md_indigo_a700 to R.string.md_indigo_a700,
/* blue */
R.color.md_blue_50 to R.string.md_blue_50,
R.color.md_blue_100 to R.string.md_blue_100,
R.color.md_blue_200 to R.string.md_blue_200,
R.color.md_blue_300 to R.string.md_blue_300,
R.color.md_blue_400 to R.string.md_blue_400,
R.color.md_blue_500 to R.string.md_blue_500,
R.color.md_blue_600 to R.string.md_blue_600,
R.color.md_blue_700 to R.string.md_blue_700,
R.color.md_blue_800 to R.string.md_blue_800,
R.color.md_blue_900 to R.string.md_blue_900,
R.color.md_blue_a100 to R.string.md_blue_a100,
R.color.md_blue_a200 to R.string.md_blue_a200,
R.color.md_blue_a400 to R.string.md_blue_a400,
R.color.md_blue_a700 to R.string.md_blue_a700,
/* light blue */
R.color.md_light_blue_50 to R.string.md_light_blue_50,
R.color.md_light_blue_100 to R.string.md_light_blue_100,
R.color.md_light_blue_200 to R.string.md_light_blue_200,
R.color.md_light_blue_300 to R.string.md_light_blue_300,
R.color.md_light_blue_400 to R.string.md_light_blue_400,
R.color.md_light_blue_500 to R.string.md_light_blue_500,
R.color.md_light_blue_600 to R.string.md_light_blue_600,
R.color.md_light_blue_700 to R.string.md_light_blue_700,
R.color.md_light_blue_800 to R.string.md_light_blue_800,
R.color.md_light_blue_900 to R.string.md_light_blue_900,
R.color.md_light_blue_a100 to R.string.md_light_blue_a100,
R.color.md_light_blue_a200 to R.string.md_light_blue_a200,
R.color.md_light_blue_a400 to R.string.md_light_blue_a400,
R.color.md_light_blue_a700 to R.string.md_light_blue_a700,
/* cyan */
R.color.md_cyan_50 to R.string.md_cyan_50,
R.color.md_cyan_100 to R.string.md_cyan_100,
R.color.md_cyan_200 to R.string.md_cyan_200,
R.color.md_cyan_300 to R.string.md_cyan_300,
R.color.md_cyan_400 to R.string.md_cyan_400,
R.color.md_cyan_500 to R.string.md_cyan_500,
R.color.md_cyan_600 to R.string.md_cyan_600,
R.color.md_cyan_700 to R.string.md_cyan_700,
R.color.md_cyan_800 to R.string.md_cyan_800,
R.color.md_cyan_900 to R.string.md_cyan_900,
R.color.md_cyan_a100 to R.string.md_cyan_a100,
R.color.md_cyan_a200 to R.string.md_cyan_a200,
R.color.md_cyan_a400 to R.string.md_cyan_a400,
R.color.md_cyan_a700 to R.string.md_cyan_a700,
/* teal */
R.color.md_teal_50 to R.string.md_teal_50,
R.color.md_teal_100 to R.string.md_teal_100,
R.color.md_teal_200 to R.string.md_teal_200,
R.color.md_teal_300 to R.string.md_teal_300,
R.color.md_teal_400 to R.string.md_teal_400,
R.color.md_teal_500 to R.string.md_teal_500,
R.color.md_teal_600 to R.string.md_teal_600,
R.color.md_teal_700 to R.string.md_teal_700,
R.color.md_teal_800 to R.string.md_teal_800,
R.color.md_teal_900 to R.string.md_teal_900,
R.color.md_teal_a100 to R.string.md_teal_a100,
R.color.md_teal_a200 to R.string.md_teal_a200,
R.color.md_teal_a400 to R.string.md_teal_a400,
R.color.md_teal_a700 to R.string.md_teal_a700,
/* green */
R.color.md_green_50 to R.string.md_green_50,
R.color.md_green_100 to R.string.md_green_100,
R.color.md_green_200 to R.string.md_green_200,
R.color.md_green_300 to R.string.md_green_300,
R.color.md_green_400 to R.string.md_green_400,
R.color.md_green_500 to R.string.md_green_500,
R.color.md_green_600 to R.string.md_green_600,
R.color.md_green_700 to R.string.md_green_700,
R.color.md_green_800 to R.string.md_green_800,
R.color.md_green_900 to R.string.md_green_900,
R.color.md_green_a100 to R.string.md_green_a100,
R.color.md_green_a200 to R.string.md_green_a200,
R.color.md_green_a400 to R.string.md_green_a400,
R.color.md_green_a700 to R.string.md_green_a700,
/* light green */
R.color.md_light_green_50 to R.string.md_light_green_50,
R.color.md_light_green_100 to R.string.md_light_green_100,
R.color.md_light_green_200 to R.string.md_light_green_200,
R.color.md_light_green_300 to R.string.md_light_green_300,
R.color.md_light_green_400 to R.string.md_light_green_400,
R.color.md_light_green_500 to R.string.md_light_green_500,
R.color.md_light_green_600 to R.string.md_light_green_600,
R.color.md_light_green_700 to R.string.md_light_green_700,
R.color.md_light_green_800 to R.string.md_light_green_800,
R.color.md_light_green_900 to R.string.md_light_green_900,
R.color.md_light_green_a100 to R.string.md_light_green_a100,
R.color.md_light_green_a200 to R.string.md_light_green_a200,
R.color.md_light_green_a400 to R.string.md_light_green_a400,
R.color.md_light_green_a700 to R.string.md_light_green_a700,
/* lime */
R.color.md_lime_50 to R.string.md_lime_50,
R.color.md_lime_100 to R.string.md_lime_100,
R.color.md_lime_200 to R.string.md_lime_200,
R.color.md_lime_300 to R.string.md_lime_300,
R.color.md_lime_400 to R.string.md_lime_400,
R.color.md_lime_500 to R.string.md_lime_500,
R.color.md_lime_600 to R.string.md_lime_600,
R.color.md_lime_700 to R.string.md_lime_700,
R.color.md_lime_800 to R.string.md_lime_800,
R.color.md_lime_900 to R.string.md_lime_900,
R.color.md_lime_a100 to R.string.md_lime_a100,
R.color.md_lime_a200 to R.string.md_lime_a200,
R.color.md_lime_a400 to R.string.md_lime_a400,
R.color.md_lime_a700 to R.string.md_lime_a700,
/* yellow */
R.color.md_yellow_50 to R.string.md_yellow_50,
R.color.md_yellow_100 to R.string.md_yellow_100,
R.color.md_yellow_200 to R.string.md_yellow_200,
R.color.md_yellow_300 to R.string.md_yellow_300,
R.color.md_yellow_400 to R.string.md_yellow_400,
R.color.md_yellow_500 to R.string.md_yellow_500,
R.color.md_yellow_600 to R.string.md_yellow_600,
R.color.md_yellow_700 to R.string.md_yellow_700,
R.color.md_yellow_800 to R.string.md_yellow_800,
R.color.md_yellow_900 to R.string.md_yellow_900,
R.color.md_yellow_a100 to R.string.md_yellow_a100,
R.color.md_yellow_a200 to R.string.md_yellow_a200,
R.color.md_yellow_a400 to R.string.md_yellow_a400,
R.color.md_yellow_a700 to R.string.md_yellow_a700,
/* amber */
R.color.md_amber_50 to R.string.md_amber_50,
R.color.md_amber_100 to R.string.md_amber_100,
R.color.md_amber_200 to R.string.md_amber_200,
R.color.md_amber_300 to R.string.md_amber_300,
R.color.md_amber_400 to R.string.md_amber_400,
R.color.md_amber_500 to R.string.md_amber_500,
R.color.md_amber_600 to R.string.md_amber_600,
R.color.md_amber_700 to R.string.md_amber_700,
R.color.md_amber_800 to R.string.md_amber_800,
R.color.md_amber_900 to R.string.md_amber_900,
R.color.md_amber_a100 to R.string.md_amber_a100,
R.color.md_amber_a200 to R.string.md_amber_a200,
R.color.md_amber_a400 to R.string.md_amber_a400,
R.color.md_amber_a700 to R.string.md_amber_a700,
/* orange */
R.color.md_orange_50 to R.string.md_orange_50,
R.color.md_orange_100 to R.string.md_orange_100,
R.color.md_orange_200 to R.string.md_orange_200,
R.color.md_orange_300 to R.string.md_orange_300,
R.color.md_orange_400 to R.string.md_orange_400,
R.color.md_orange_500 to R.string.md_orange_500,
R.color.md_orange_600 to R.string.md_orange_600,
R.color.md_orange_700 to R.string.md_orange_700,
R.color.md_orange_800 to R.string.md_orange_800,
R.color.md_orange_900 to R.string.md_orange_900,
R.color.md_orange_a100 to R.string.md_orange_a100,
R.color.md_orange_a200 to R.string.md_orange_a200,
R.color.md_orange_a400 to R.string.md_orange_a400,
R.color.md_orange_a700 to R.string.md_orange_a700,
/* deep orange */
R.color.md_deep_orange_50 to R.string.md_deep_orange_50,
R.color.md_deep_orange_100 to R.string.md_deep_orange_100,
R.color.md_deep_orange_200 to R.string.md_deep_orange_200,
R.color.md_deep_orange_300 to R.string.md_deep_orange_300,
R.color.md_deep_orange_400 to R.string.md_deep_orange_400,
R.color.md_deep_orange_500 to R.string.md_deep_orange_500,
R.color.md_deep_orange_600 to R.string.md_deep_orange_600,
R.color.md_deep_orange_700 to R.string.md_deep_orange_700,
R.color.md_deep_orange_800 to R.string.md_deep_orange_800,
R.color.md_deep_orange_900 to R.string.md_deep_orange_900,
R.color.md_deep_orange_a100 to R.string.md_deep_orange_a100,
R.color.md_deep_orange_a200 to R.string.md_deep_orange_a200,
R.color.md_deep_orange_a400 to R.string.md_deep_orange_a400,
R.color.md_deep_orange_a700 to R.string.md_deep_orange_a700,
/* brown */
R.color.md_brown_50 to R.string.md_brown_50,
R.color.md_brown_100 to R.string.md_brown_100,
R.color.md_brown_200 to R.string.md_brown_200,
R.color.md_brown_300 to R.string.md_brown_300,
R.color.md_brown_400 to R.string.md_brown_400,
R.color.md_brown_500 to R.string.md_brown_500,
R.color.md_brown_600 to R.string.md_brown_600,
R.color.md_brown_700 to R.string.md_brown_700,
R.color.md_brown_800 to R.string.md_brown_800,
R.color.md_brown_900 to R.string.md_brown_900,
/* grey */
R.color.md_grey_50 to R.string.md_grey_50,
R.color.md_grey_100 to R.string.md_grey_100,
R.color.md_grey_200 to R.string.md_grey_200,
R.color.md_grey_300 to R.string.md_grey_300,
R.color.md_grey_400 to R.string.md_grey_400,
R.color.md_grey_500 to R.string.md_grey_500,
R.color.md_grey_600 to R.string.md_grey_600,
R.color.md_grey_700 to R.string.md_grey_700,
R.color.md_grey_800 to R.string.md_grey_800,
R.color.md_grey_900 to R.string.md_grey_900,
R.color.md_black_1000 to R.string.md_black_1000,
R.color.md_white_1000 to R.string.md_white_1000,
/* blue grey */
R.color.md_blue_grey_50 to R.string.md_blue_grey_50,
R.color.md_blue_grey_100 to R.string.md_blue_grey_100,
R.color.md_blue_grey_200 to R.string.md_blue_grey_200,
R.color.md_blue_grey_300 to R.string.md_blue_grey_300,
R.color.md_blue_grey_400 to R.string.md_blue_grey_400,
R.color.md_blue_grey_500 to R.string.md_blue_grey_500,
R.color.md_blue_grey_600 to R.string.md_blue_grey_600,
R.color.md_blue_grey_700 to R.string.md_blue_grey_700,
R.color.md_blue_grey_800 to R.string.md_blue_grey_800,
R.color.md_blue_grey_900 to R.string.md_blue_grey_900,
)
@JvmStatic
fun toString(color: Int): String {

View File

@@ -22,6 +22,7 @@ import android.util.TypedValue
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.view.Window
import android.view.WindowInsets
import android.view.WindowManager
@@ -194,6 +195,7 @@ object ViewUtils {
setStatusBarAppearanceLight(activity, shouldBeLight)
}
@JvmStatic
fun setStatusBarBackgroundColor(activity: Activity, color: Int) {
val window = activity.window
val decorView = window.decorView
@@ -408,6 +410,44 @@ object ViewUtils {
this.navigationIcon?.let { this.navigationIcon = it.applyColorFilterWith(color) }
}
@JvmStatic
fun onceViewGlobalLayout(view: View, listener: () -> Unit) {
view.onceGlobalLayout(listener)
}
fun View.onceGlobalLayout(listener: () -> Unit) {
val view = this
val viewTreeObserver = view.viewTreeObserver
if (viewTreeObserver.isAlive) {
viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
listener.invoke()
val viewTreeObserver = view.viewTreeObserver
if (viewTreeObserver.isAlive) {
viewTreeObserver.removeOnGlobalLayoutListener(this)
}
}
})
}
}
@JvmStatic
fun onViewGlobalLayout(view: View, listener: () -> Unit) {
view.onGlobalLayout(listener)
}
fun View.onGlobalLayout(listener: () -> Unit) {
val view = this
val viewTreeObserver = view.viewTreeObserver
if (viewTreeObserver.isAlive) {
viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
listener.invoke()
}
})
}
}
fun Drawable.applyColorFilterWith(color: Int): Drawable {
return this.applyColorFilterWith(PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN))
}