1
1
package com .jorge .boats .xkcd .util ;
2
2
3
3
import android .content .Context ;
4
+ import android .support .annotation .ColorRes ;
4
5
import android .support .annotation .NonNull ;
5
6
import android .support .annotation .StyleRes ;
6
7
@@ -50,21 +51,21 @@ public static int getSettingsTheme(final @NonNull Context context) {
50
51
.theme_4_name ), theme5Name = context .getString (R .string .theme_5_name );
51
52
52
53
if ((themeName = P .themeName .get ()).contentEquals (theme0Name )) {
53
- return R .style .SettingsStandard ;
54
- } else if (themeName .contentEquals (theme1Name )) {
55
- return R .style .SettingsNegative ;
56
- } else if (themeName .contentEquals (theme2Name )) {
57
- return R .style .SettingsWeb ;
58
- } else if (themeName .contentEquals (theme3Name )) {
59
- return R .style .SettingsWarm ;
60
- } else if (themeName .contentEquals (theme4Name )) {
61
- return R .style .SettingsMaterialLight ;
62
- } else if (themeName .contentEquals (theme5Name )) {
63
- return R .style .SettingsMaterialDark ;
64
- } else {
65
- throw new IllegalStateException (
66
- String .format (Locale .ENGLISH , "Unrecognized theme name %s" , themeName ));
67
- }
54
+ return R .style .SettingsStandard ;
55
+ } else if (themeName .contentEquals (theme1Name )) {
56
+ return R .style .SettingsNegative ;
57
+ } else if (themeName .contentEquals (theme2Name )) {
58
+ return R .style .SettingsWeb ;
59
+ } else if (themeName .contentEquals (theme3Name )) {
60
+ return R .style .SettingsWarm ;
61
+ } else if (themeName .contentEquals (theme4Name )) {
62
+ return R .style .SettingsMaterialLight ;
63
+ } else if (themeName .contentEquals (theme5Name )) {
64
+ return R .style .SettingsMaterialDark ;
65
+ } else {
66
+ throw new IllegalStateException (
67
+ String .format (Locale .ENGLISH , "Unrecognized theme name %s" , themeName ));
68
+ }
68
69
}
69
70
70
71
public static boolean isAppThemeLight (final @ NonNull Context context ) {
@@ -79,4 +80,24 @@ public static boolean isAppThemeLight(final @NonNull Context context) {
79
80
public static boolean isSettingsThemeDark (final @ NonNull Context context ) {
80
81
return !isAppThemeLight (context );
81
82
}
83
+
84
+ @ ColorRes
85
+ public static int getAppColor (@ NonNull final Context context ) {
86
+ switch (getAppTheme (context )) {
87
+ case R .style .AppStandard :
88
+ return R .color .standard_primary_light ;
89
+ case R .style .AppWeb :
90
+ return R .color .web_primary_light ;
91
+ case R .style .AppWarm :
92
+ return R .color .warm_primary_light ;
93
+ case R .style .AppNegative :
94
+ return R .color .negative_primary_light ;
95
+ case R .style .AppMaterialLight :
96
+ return R .color .material_light_primary_light ;
97
+ case R .style .AppMaterialDark :
98
+ return R .color .material_dark_primary_light ;
99
+ default :
100
+ throw new IllegalStateException ("Theme not recognized." );
101
+ }
102
+ }
82
103
}
0 commit comments