|
26 | 26 | public class ColorHeaderItem implements ColorAdapterItem { |
27 | 27 |
|
28 | 28 | public static final String SYSTEM_PREFIX = "system_"; |
| 29 | + public static final String MATERIAL_CUSTOM_PALETTE_NAME_SEARCH_WORD = "_ref_palette_dynamic_"; |
| 30 | + public static final String MATERIAL_CUSTOM_PALETTE_TITLE_PREFIX = "Material custom "; |
29 | 31 | private static final String COLOR_600 = "600"; |
30 | 32 |
|
31 | 33 | @ColorRes private final int backgroundColorRes; |
@@ -54,13 +56,21 @@ public String getDisplayName() { |
54 | 56 | String name; |
55 | 57 | int splitIndex = description.lastIndexOf("_"); |
56 | 58 | if (description.startsWith(SYSTEM_PREFIX)) { |
57 | | - // Split the resource name into the color name and value, ie. system_accent1_500 to |
| 59 | + // Split the resource name into the color name and value, i.e., system_accent1_500 to |
58 | 60 | // system_accent1 and 500. |
59 | 61 | name = description.substring(0, splitIndex); |
| 62 | + } else if (description.contains(MATERIAL_CUSTOM_PALETTE_NAME_SEARCH_WORD)) { |
| 63 | + // Get the name of the color and value without the search word. |
| 64 | + splitIndex = description.lastIndexOf(MATERIAL_CUSTOM_PALETTE_NAME_SEARCH_WORD); |
| 65 | + String trimmedResName = |
| 66 | + description.substring(splitIndex + MATERIAL_CUSTOM_PALETTE_NAME_SEARCH_WORD.length()); |
| 67 | + // Split the resource name into the color name and value, i.e., neutral92 to neutral and 92. |
| 68 | + List<String> parts = Arrays.asList(trimmedResName.split("(?<=\\D)(?=\\d)", -1)); |
| 69 | + name = MATERIAL_CUSTOM_PALETTE_TITLE_PREFIX + parts.get(0); |
60 | 70 | } else { |
61 | | - // Get the name of the color an value without prefixes |
| 71 | + // Get the name of the color and value without prefixes |
62 | 72 | String trimmedResName = description.substring(splitIndex + 1); |
63 | | - // Split the resource name into the color name and value, ie. blue500 to blue and 500. |
| 73 | + // Split the resource name into the color name and value, i.e., blue500 to blue and 500. |
64 | 74 | List<String> parts = Arrays.asList(trimmedResName.split("(?<=\\D)(?=\\d)", -1)); |
65 | 75 | name = parts.get(0); |
66 | 76 | } |
|
0 commit comments