1 package org.coolreader.crengine;
2 
3 import org.coolreader.R;
4 
5 public class InterfaceTheme {
6 
7 	public final static InterfaceTheme BLACK = new InterfaceTheme("BLACK", R.style.Theme_Black, R.style.Theme_Black_Dialog_Normal, R.style.Theme_Black_Dialog_Fullscreen, R.string.options_app_ui_theme_black, 0xFF000000)
8 			.setRootDelimiter(R.drawable.divider_black_tiled, 2)
9 			.setBackgrounds(
10 					R.drawable.ui_status_background_browser_black,
11 					R.drawable.ui_toolbar_background_browser_black,
12 					R.drawable.ui_toolbar_background_browser_vertical_black,
13 					0, 0xFF000000)
14 			.setToolbarButtonAlpha(DeviceInfo.EINK_SCREEN ? 0xFF : 0x80);
15 
16 	public final static InterfaceTheme WHITE = new InterfaceTheme("WHITE", R.style.Theme_White, R.style.Theme_White_Dialog_Normal, R.style.Theme_White_Dialog_Fullscreen, R.string.options_app_ui_theme_white, 0xFFFFFFFF)
17 			.setRootDelimiter(R.drawable.divider_white_tiled, 2)
18 			.setBackgrounds(
19 					R.drawable.ui_status_background_browser_white,
20 					R.drawable.ui_toolbar_background_browser_white,
21 					R.drawable.ui_toolbar_background_browser_vertical_white,
22 					0, 0xFFFFFFFF)
23 			.setToolbarButtonAlpha(DeviceInfo.EINK_SCREEN ? 0xFF : 0xE0);
24 
25 	public final static InterfaceTheme LIGHT = new InterfaceTheme("LIGHT", R.style.Theme_Light, R.style.Theme_Light_Dialog_Normal, R.style.Theme_Light_Dialog_Fullscreen, R.string.options_app_ui_theme_light, 0xFF000000)
26 			.setRootDelimiter(R.drawable.divider_light_tiled_v3, 16)
27 			.setBackgrounds(
28 					R.drawable.ui_status_background_browser_light,
29 					R.drawable.ui_toolbar_background_browser_light,
30 					R.drawable.ui_toolbar_background_browser_vertical_light,
31 					R.drawable.background_tiled_light, 0)
32 			.setToolbarButtonAlpha(DeviceInfo.EINK_SCREEN ? 0xFF : 0xC0);
33 //			.setBackgrounds(
34 //					R.drawable.ui_status_background_browser_light,
35 //					R.drawable.ui_toolbar_background_browser_light,
36 //					R.drawable.ui_toolbar_background_browser_vertical_light,
37 //					R.drawable.ui_status_background_reader_light,
38 //					R.drawable.ui_toolbar_background_reader_light,
39 //					R.drawable.ui_toolbar_background_reader_vertical_light,
40 //					0x404040, 0xC0);
41 
42 	public final static InterfaceTheme DARK = new InterfaceTheme("DARK", R.style.Theme_Dark, R.style.Theme_Dark_Dialog_Normal, R.style.Theme_Dark_Dialog_Fullscreen, R.string.options_app_ui_theme_dark, 0xFF000000)
43 			.setRootDelimiter(R.drawable.divider_dark_tiled_v3, 16)
44 			.setBackgrounds(
45 					R.drawable.ui_status_background_browser_dark,
46 					R.drawable.ui_toolbar_background_browser_dark,
47 					R.drawable.ui_toolbar_background_browser_vertical_dark,
48 					R.drawable.background_tiled_dark, 0)
49 			.setToolbarButtonAlpha(DeviceInfo.EINK_SCREEN ? 0xFF : 0x90);
50 //			.setBackgrounds(
51 //					R.drawable.ui_status_background_browser_dark,
52 //					R.drawable.ui_toolbar_background_browser_dark,
53 //					R.drawable.ui_toolbar_background_browser_vertical_dark,
54 //					R.drawable.ui_status_background_reader_dark,
55 //					R.drawable.ui_toolbar_background_reader_dark,
56 //					R.drawable.ui_toolbar_background_reader_vertical_dark,
57 //					0xE0E0E0, 0x90);
58 
59 	public final static InterfaceTheme GRAY1 = new InterfaceTheme("GRAY1", R.style.Theme_Gray1, R.style.Theme_Gray1_Dialog_Normal, R.style.Theme_Gray1_Dialog_Fullscreen, R.string.options_app_ui_theme_gray1, 0xFF555555)
60 			.setRootDelimiter(R.drawable.divider_black_tiled, 2)
61 			.setBackgrounds(
62 					R.drawable.ui_status_background_browser_gray1,
63 					R.drawable.ui_toolbar_background_browser_gray1,
64 					R.drawable.ui_toolbar_background_browser_vertical_gray1,
65 					0, 0xFF555555)
66 			.setToolbarButtonAlpha(DeviceInfo.EINK_SCREEN ? 0xFF : 0x80);
67 
68 	public final static InterfaceTheme GRAY2 = new InterfaceTheme("GRAY2", R.style.Theme_Gray2, R.style.Theme_Gray2_Dialog_Normal, R.style.Theme_Gray2_Dialog_Fullscreen, R.string.options_app_ui_theme_gray2, 0xFFCCCCCC)
69 			.setRootDelimiter(R.drawable.divider_white_tiled, 2)
70 			.setBackgrounds(
71 					R.drawable.ui_status_background_browser_gray2,
72 					R.drawable.ui_toolbar_background_browser_gray2,
73 					R.drawable.ui_toolbar_background_browser_vertical_gray2,
74 					0, 0xFFCCCCCC)
75 			.setToolbarButtonAlpha(DeviceInfo.EINK_SCREEN ? 0xFF : 0xE0);
76 	public final static InterfaceTheme HICONTRAST1 = new InterfaceTheme("HICONTRAST1", R.style.Theme_HiContrast1, R.style.Theme_HiContrast1_Dialog_Normal, R.style.Theme_HiContrast1_Dialog_Fullscreen, R.string.options_app_ui_theme_hicontrast1, 0xFFFFFFFF)
77 			.setRootDelimiter(R.drawable.divider_white_tiled, 2)
78 			.setBackgrounds(
79 					R.drawable.ui_status_background_browser_white,
80 					R.drawable.ui_toolbar_background_browser_white,
81 					R.drawable.ui_toolbar_background_browser_vertical_white,
82 					0, 0xFFFFFFFF)
83 			.setToolbarButtonAlpha(0xFF);
84 	public final static InterfaceTheme HICONTRAST2 = new InterfaceTheme("HICONTRAST2", R.style.Theme_HiContrast2, R.style.Theme_HiContrast2_Dialog_Normal, R.style.Theme_HiContrast2_Dialog_Fullscreen, R.string.options_app_ui_theme_hicontrast2, 0xFFFFFFFF)
85 			.setRootDelimiter(R.drawable.divider_black_tiled, 2)
86 			.setBackgrounds(
87 					R.drawable.ui_status_background_browser_black,
88 					R.drawable.ui_toolbar_background_browser_black,
89 					R.drawable.ui_toolbar_background_browser_vertical_black,
90 					0, 0xFF000000)
91 			.setToolbarButtonAlpha(0xFF);
92 
getCode()93 	public String getCode() {
94 		return code;
95 	}
96 
getThemeId()97 	public int getThemeId() {
98 		return themeId;
99 	}
100 
getDialogThemeId()101 	public int getDialogThemeId() {
102 		return dialogThemeId;
103 	}
104 
getFullscreenDialogThemeId()105 	public int getFullscreenDialogThemeId() {
106 		return fsDialogThemeId;
107 	}
108 
getDisplayNameResourceId()109 	public int getDisplayNameResourceId() {
110 		return displayNameResourceId;
111 	}
112 
getActionBarBackgroundColorReading()113 	public int getActionBarBackgroundColorReading() {
114 		return actionBarBackgroundColorReading;
115 	}
116 
117 //	public Drawable getActionBarBackgroundDrawableReading() {
118 //		return Utils.solidColorDrawable(actionBarBackgroundColorReading);
119 //	}
120 //
121 //	public Drawable getActionBarBackgroundDrawableBrowser() {
122 //		return Utils.solidColorDrawable(0);
123 //	}
124 
getRootDelimiterResourceId()125 	public int getRootDelimiterResourceId() {
126 		return rootDelimiterResourceId;
127 	}
128 
getRootDelimiterHeight()129 	public int getRootDelimiterHeight() {
130 		return rootDelimiterHeight;
131 	}
132 
getBrowserStatusBackground()133 	public int getBrowserStatusBackground() {
134 		return browserStatusBackground;
135 	}
136 
getBrowserToolbarBackground(boolean vertical)137 	public int getBrowserToolbarBackground(boolean vertical) {
138 		return !vertical ? browserToolbarBackground : browserToolbarBackgroundVertical;
139 	}
140 
141 //	public int getReaderStatusBackground() {
142 //		return readerStatusBackground;
143 //	}
144 //
145 //	public int getReaderToolbarBackground(boolean vertical) {
146 //		return !vertical ? readerToolbarBackground : readerToolbarBackgroundVertical;
147 //	}
148 
149 //	public int getStatusTextColor() {
150 //		return statusTextColor;
151 //	}
152 
getToolbarButtonAlpha()153 	public int getToolbarButtonAlpha() {
154 		return toolbarButtonAlpha;
155 	}
156 
getPopupToolbarBackground()157 	public int getPopupToolbarBackground() {
158 		return popupToolbarBackground;
159 	}
160 
getPopupToolbarBackgroundColor()161 	public int getPopupToolbarBackgroundColor() {
162 		return popupToolbarBackgroundColor;
163 	}
164 
165 
166 	public final static InterfaceTheme[] allThemes = {
167 		BLACK, WHITE, DARK, LIGHT, GRAY1, GRAY2, HICONTRAST1, HICONTRAST2
168 	};
169 
findByCode(String code)170 	public static InterfaceTheme findByCode(String code) {
171 		if (code == null)
172 			return null;
173 		for (InterfaceTheme t : allThemes)
174 			if (t.getCode().equals(code))
175 				return t;
176 		return null;
177 	}
178 
179 	private final String code;
180 	private final int themeId;
181 	private final int dialogThemeId;
182 	private final int fsDialogThemeId;
183 	private final int displayNameResourceId;
184 	private final int actionBarBackgroundColorReading;
185 	private int rootDelimiterResourceId;
186 	private int rootDelimiterHeight;
187 
188 	private int browserStatusBackground;
189 	private int browserToolbarBackground;
190 	private int browserToolbarBackgroundVertical;
191 	private int popupToolbarBackground;
192 	private int popupToolbarBackgroundColor;
193 //	private int readerStatusBackground;
194 //	private int readerToolbarBackground;
195 //	private int readerToolbarBackgroundVertical;
196 //	private int statusTextColor;
197 	private int toolbarButtonAlpha;
198 
setToolbarButtonAlpha(int toolbarButtonAlpha)199 	private InterfaceTheme setToolbarButtonAlpha(int toolbarButtonAlpha) {
200 		this.toolbarButtonAlpha = toolbarButtonAlpha;
201 		return this;
202 	}
203 //	private InterfaceTheme setBackgrounds(int browserStatusBackground, int browserToolbarBackground,
204 //			int browserToolbarBackgroundVertical, int readerStatusBackground,
205 //			int readerToolbarBackground, int readerToolbarBackgroundVertical,
206 //			int statusTextColor, int toolbarButtonAlpha) {
207 //		this.browserStatusBackground = browserStatusBackground;
208 //		this.browserToolbarBackground = browserToolbarBackground;
209 //		this.browserToolbarBackgroundVertical = browserToolbarBackgroundVertical;
210 //		this.readerStatusBackground = readerStatusBackground;
211 //		this.readerToolbarBackground = readerToolbarBackground;
212 //		this.readerToolbarBackgroundVertical = readerToolbarBackgroundVertical;
213 //		this.statusTextColor = statusTextColor;
214 //		this.toolbarButtonAlpha = toolbarButtonAlpha;
215 //		return this;
216 //	}
217 
setBackgrounds(int browserStatusBackground, int browserToolbarBackground, int browserToolbarBackgroundVertical, int popupToolbarBackground, int browserToolbarBackgroundColor)218 	private InterfaceTheme setBackgrounds(int browserStatusBackground,
219 			int browserToolbarBackground, int browserToolbarBackgroundVertical,
220 			int popupToolbarBackground, int browserToolbarBackgroundColor) {
221 		this.browserStatusBackground = browserStatusBackground;
222 		this.browserToolbarBackground = browserToolbarBackground;
223 		this.browserToolbarBackgroundVertical = browserToolbarBackgroundVertical;
224 		this.popupToolbarBackground = popupToolbarBackground;
225 		this.popupToolbarBackgroundColor = browserToolbarBackgroundColor;
226 		return this;
227 	}
228 
InterfaceTheme(String code, int themeId, int dialogThemeId, int fsDialogThemeId, int displayNameResourceId, int actionBarBackgroundColorReading)229 	private InterfaceTheme(String code, int themeId, int dialogThemeId, int fsDialogThemeId, int displayNameResourceId, int actionBarBackgroundColorReading) {
230 		this.code = code;
231 		this.themeId = themeId;
232 		this.dialogThemeId = dialogThemeId;
233 		this.fsDialogThemeId = fsDialogThemeId;
234 		this.displayNameResourceId = displayNameResourceId;
235 		this.actionBarBackgroundColorReading = actionBarBackgroundColorReading;
236 	}
237 
setRootDelimiter(int resourceId, int height)238 	private InterfaceTheme setRootDelimiter(int resourceId, int height) {
239 		this.rootDelimiterResourceId = resourceId;
240 		this.rootDelimiterHeight = height;
241 		return this;
242 	}
243 
244 	@Override
toString()245 	public String toString() {
246 		return "Theme[code=" + code + ", themeId=" + themeId + "]";
247 	}
248 
applyActionIcons()249 	public final void applyActionIcons() {
250 
251 	}
252 }
253