|
|
@ -26,6 +26,7 @@ import org.floens.chan.core.settings.ChanSettings; |
|
|
|
import org.floens.chan.utils.Logger; |
|
|
|
import org.floens.chan.utils.Logger; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
public class ThemeHelper { |
|
|
|
public class ThemeHelper { |
|
|
@ -53,17 +54,30 @@ public class ThemeHelper { |
|
|
|
themes.add(new Theme("Yotsuba B", "yotsuba_b", R.style.Chan_Theme_YotsubaB, PrimaryColor.RED)); |
|
|
|
themes.add(new Theme("Yotsuba B", "yotsuba_b", R.style.Chan_Theme_YotsubaB, PrimaryColor.RED)); |
|
|
|
themes.add(new Theme("Photon", "photon", R.style.Chan_Theme_Photon, PrimaryColor.ORANGE)); |
|
|
|
themes.add(new Theme("Photon", "photon", R.style.Chan_Theme_Photon, PrimaryColor.ORANGE)); |
|
|
|
themes.add(new DarkTheme("Tomorrow", "tomorrow", R.style.Chan_Theme_Tomorrow, PrimaryColor.DARK)); |
|
|
|
themes.add(new DarkTheme("Tomorrow", "tomorrow", R.style.Chan_Theme_Tomorrow, PrimaryColor.DARK)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ChanSettings.ThemeColor settingTheme = ChanSettings.getThemeAndColor(); |
|
|
|
|
|
|
|
if (settingTheme.color != null) { |
|
|
|
|
|
|
|
for (Theme theme : themes) { |
|
|
|
|
|
|
|
if (theme.name.equals(settingTheme.theme)) { |
|
|
|
|
|
|
|
theme.primaryColor = getColor(settingTheme.color); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
updateCurrentTheme(); |
|
|
|
updateCurrentTheme(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public List<Theme> getThemes() { |
|
|
|
public void changeTheme(Theme theme, PrimaryColor primaryColor) { |
|
|
|
return themes; |
|
|
|
ChanSettings.setThemeAndColor(new ChanSettings.ThemeColor(theme.name, primaryColor.name)); |
|
|
|
|
|
|
|
theme.primaryColor = primaryColor; |
|
|
|
|
|
|
|
updateCurrentTheme(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void updateCurrentTheme() { |
|
|
|
public void updateCurrentTheme() { |
|
|
|
String settingTheme = ChanSettings.theme.get(); |
|
|
|
ChanSettings.ThemeColor settingTheme = ChanSettings.getThemeAndColor(); |
|
|
|
for (Theme theme : themes) { |
|
|
|
for (Theme theme : themes) { |
|
|
|
if (theme.name.equals(settingTheme)) { |
|
|
|
if (theme.name.equals(settingTheme.theme)) { |
|
|
|
this.theme = theme; |
|
|
|
this.theme = theme; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -77,6 +91,10 @@ public class ThemeHelper { |
|
|
|
return theme; |
|
|
|
return theme; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<Theme> getThemes() { |
|
|
|
|
|
|
|
return themes; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setupContext(Activity context) { |
|
|
|
public void setupContext(Activity context) { |
|
|
|
updateCurrentTheme(); |
|
|
|
updateCurrentTheme(); |
|
|
|
context.setTheme(theme.resValue); |
|
|
|
context.setTheme(theme.resValue); |
|
|
@ -88,35 +106,52 @@ public class ThemeHelper { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public enum PrimaryColor { |
|
|
|
public PrimaryColor getColor(String name) { |
|
|
|
RED("red", 0xFFF44336, 0xFFD32F2F), |
|
|
|
for (PrimaryColor primaryColor : PrimaryColor.values()) { |
|
|
|
PINK("pink", 0xFFE91E63, 0xFFC2185B), |
|
|
|
if (primaryColor.name.equals(name)) { |
|
|
|
PURPLE("purple", 0xFF9C27B0, 0xFF7B1FA2), |
|
|
|
return primaryColor; |
|
|
|
DEEP_PURPLE("deep purple", 0xFF673AB7, 0xFF512DA8), |
|
|
|
} |
|
|
|
INDIGO("indigo", 0xFF3F51B5, 0xFF303F9F), |
|
|
|
} |
|
|
|
BLUE("blue", 0xFF2196F3, 0xFF1976D2), |
|
|
|
|
|
|
|
LIGHT_BLUE("light blue", 0xFF03A9F4, 0xFF0288D1), |
|
|
|
|
|
|
|
CYAN("cyan", 0xFF00BCD4, 0xFF0097A7), |
|
|
|
|
|
|
|
TEAL("teal", 0xFF009688, 0xFF00796B), |
|
|
|
|
|
|
|
GREEN("green", 0xFF4CAF50, 0xFF388E3C), |
|
|
|
|
|
|
|
LIGHT_GREEN("light green", 0xFF8BC34A, 0xFF689F38), |
|
|
|
|
|
|
|
LIME("lime", 0xFFCDDC39, 0xFFAFB42B), |
|
|
|
|
|
|
|
YELLOW("yellow", 0xFFFFEB3B, 0xFFFBC02D), |
|
|
|
|
|
|
|
AMBER("amber", 0xFFFFC107, 0xFFFFA000), |
|
|
|
|
|
|
|
ORANGE("orange", 0xFFFF9800, 0xFFF57C00), |
|
|
|
|
|
|
|
DEEP_ORANGE("deep orange", 0xFFFF5722, 0xFFE64A19), |
|
|
|
|
|
|
|
BROWN("brown", 0xFF795548, 0xFF5D4037), |
|
|
|
|
|
|
|
GREY("grey", 0xFF9E9E9E, 0xFF616161), |
|
|
|
|
|
|
|
BLUE_GREY("blue grey", 0xFF607D8B, 0xFF455A64), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DARK("dark", 0xff212121, 0xff000000), |
|
|
|
|
|
|
|
BLACK("black", 0xff000000, 0xff000000); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger.e(TAG, "No color found for setting " + name + ", using a default color"); |
|
|
|
|
|
|
|
return PrimaryColor.BLACK; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<PrimaryColor> getColors() { |
|
|
|
|
|
|
|
return Arrays.asList(PrimaryColor.values()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public enum PrimaryColor { |
|
|
|
|
|
|
|
RED("Red", "red", 0xFFF44336, 0xFFD32F2F), |
|
|
|
|
|
|
|
PINK("Pink", "pink", 0xFFE91E63, 0xFFC2185B), |
|
|
|
|
|
|
|
PURPLE("Purple", "purple", 0xFF9C27B0, 0xFF7B1FA2), |
|
|
|
|
|
|
|
DEEP_PURPLE("Deep purple", "deep_purple", 0xFF673AB7, 0xFF512DA8), |
|
|
|
|
|
|
|
INDIGO("Indigo", "indigo", 0xFF3F51B5, 0xFF303F9F), |
|
|
|
|
|
|
|
BLUE("Blue", "blue", 0xFF2196F3, 0xFF1976D2), |
|
|
|
|
|
|
|
LIGHT_BLUE("Light blue", "light_blue", 0xFF03A9F4, 0xFF0288D1), |
|
|
|
|
|
|
|
CYAN("Cyan", "cyan", 0xFF00BCD4, 0xFF0097A7), |
|
|
|
|
|
|
|
TEAL("Teal", "teal", 0xFF009688, 0xFF00796B), |
|
|
|
|
|
|
|
GREEN("Green", "green", 0xFF4CAF50, 0xFF388E3C), |
|
|
|
|
|
|
|
LIGHT_GREEN("Light green", "light_green", 0xFF8BC34A, 0xFF689F38), |
|
|
|
|
|
|
|
LIME("Lime", "lime", 0xFFCDDC39, 0xFFAFB42B), |
|
|
|
|
|
|
|
YELLOW("Yellow", "yellow", 0xFFFFEB3B, 0xFFFBC02D), |
|
|
|
|
|
|
|
AMBER("Amber", "amber", 0xFFFFC107, 0xFFFFA000), |
|
|
|
|
|
|
|
ORANGE("Orange", "orange", 0xFFFF9800, 0xFFF57C00), |
|
|
|
|
|
|
|
DEEP_ORANGE("Deep orange", "deep_orange", 0xFFFF5722, 0xFFE64A19), |
|
|
|
|
|
|
|
BROWN("Brown", "brown", 0xFF795548, 0xFF5D4037), |
|
|
|
|
|
|
|
GREY("Grey", "grey", 0xFF9E9E9E, 0xFF616161), |
|
|
|
|
|
|
|
BLUE_GREY("Blue grey", "blue_grey", 0xFF607D8B, 0xFF455A64), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DARK("Dark", "dark", 0xff212121, 0xff000000), |
|
|
|
|
|
|
|
BLACK("Black", "black", 0xff000000, 0xff000000); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public final String displayName; |
|
|
|
public final String name; |
|
|
|
public final String name; |
|
|
|
public final int color; |
|
|
|
public final int color; |
|
|
|
public final int dark; |
|
|
|
public final int dark; |
|
|
|
|
|
|
|
|
|
|
|
PrimaryColor(String name, int color, int dark) { |
|
|
|
PrimaryColor(String displayName, String name, int color, int dark) { |
|
|
|
|
|
|
|
this.displayName = displayName; |
|
|
|
this.name = name; |
|
|
|
this.name = name; |
|
|
|
this.color = color; |
|
|
|
this.color = color; |
|
|
|
this.dark = dark; |
|
|
|
this.dark = dark; |
|
|
|