aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrashant Malani2016-03-11 12:00:55 -0600
committerPrashant Malani2016-03-11 17:22:20 -0600
commit7a491225bbbb24593a4eda5dabe2fc1850d60dd1 (patch)
tree79758ad1e9fdeeb36f287460131a224fcd79ea90 /wear_ui.cpp
parent0ba21cff07ceafeaa43e17aa26e341d961f6f29f (diff)
downloadplatform-bootable-recovery-7a491225bbbb24593a4eda5dabe2fc1850d60dd1.tar.gz
platform-bootable-recovery-7a491225bbbb24593a4eda5dabe2fc1850d60dd1.tar.xz
platform-bootable-recovery-7a491225bbbb24593a4eda5dabe2fc1850d60dd1.zip
recovery: Remove SetColor, and other refactoring for WearUI
The only difference from SetColor in ScreenRecoveryUI is the that the LOG messages have slightly different colors. That's not enough to warrant a duplicate function. So this patch removes SetColor and uses the parent class version. This patch also moves the DrawTextLine* functions into ScreenRecoveryUI since they're mostly the same. It also moves char_width and char_height into the class instead of keeping them as static variables. Bug: 27407422 Change-Id: I30428c9433baab8410cf710a01c9b1c44c217bf1
Diffstat (limited to 'wear_ui.cpp')
-rw-r--r--wear_ui.cpp56
1 files changed, 9 insertions, 47 deletions
diff --git a/wear_ui.cpp b/wear_ui.cpp
index e76af8d6..2502313f 100644
--- a/wear_ui.cpp
+++ b/wear_ui.cpp
@@ -34,9 +34,6 @@
34#include "android-base/strings.h" 34#include "android-base/strings.h"
35#include "android-base/stringprintf.h" 35#include "android-base/stringprintf.h"
36 36
37static int char_width;
38static int char_height;
39
40// There's only (at most) one of these objects, and global callbacks 37// There's only (at most) one of these objects, and global callbacks
41// (for pthread_create, and the input event system) need to find it, 38// (for pthread_create, and the input event system) need to find it,
42// so use a global variable. 39// so use a global variable.
@@ -143,41 +140,6 @@ void WearRecoveryUI::draw_progress_locked()
143 } 140 }
144} 141}
145 142
146void WearRecoveryUI::SetColor(UIElement e) {
147 switch (e) {
148 case HEADER:
149 gr_color(247, 0, 6, 255);
150 break;
151 case MENU:
152 case MENU_SEL_BG:
153 gr_color(0, 106, 157, 255);
154 break;
155 case MENU_SEL_FG:
156 gr_color(255, 255, 255, 255);
157 break;
158 case LOG:
159 gr_color(249, 194, 0, 255);
160 break;
161 case TEXT_FILL:
162 gr_color(0, 0, 0, 160);
163 break;
164 default:
165 gr_color(255, 255, 255, 255);
166 break;
167 }
168}
169
170void WearRecoveryUI::DrawTextLine(int x, int* y, const char* line, bool bold) {
171 gr_text(x, *y, line, bold);
172 *y += char_height + 4;
173}
174
175void WearRecoveryUI::DrawTextLines(int x, int* y, const char* const* lines) {
176 for (size_t i = 0; lines != nullptr && lines[i] != nullptr; ++i) {
177 DrawTextLine(x, y, lines[i], false);
178 }
179}
180
181static const char* HEADERS[] = { 143static const char* HEADERS[] = {
182 "Swipe up/down to move.", 144 "Swipe up/down to move.",
183 "Swipe left/right to select.", 145 "Swipe left/right to select.",
@@ -216,7 +178,7 @@ void WearRecoveryUI::draw_screen_locked()
216 if (menu_items > menu_end - menu_start) { 178 if (menu_items > menu_end - menu_start) {
217 sprintf(cur_selection_str, "Current item: %d/%d", menu_sel + 1, menu_items); 179 sprintf(cur_selection_str, "Current item: %d/%d", menu_sel + 1, menu_items);
218 gr_text(x+4, y, cur_selection_str, 1); 180 gr_text(x+4, y, cur_selection_str, 1);
219 y += char_height+4; 181 y += char_height_+4;
220 } 182 }
221 183
222 // Menu begins here 184 // Menu begins here
@@ -227,7 +189,7 @@ void WearRecoveryUI::draw_screen_locked()
227 if (i == menu_sel) { 189 if (i == menu_sel) {
228 // draw the highlight bar 190 // draw the highlight bar
229 SetColor(MENU_SEL_BG); 191 SetColor(MENU_SEL_BG);
230 gr_fill(x, y-2, gr_fb_width()-x, y+char_height+2); 192 gr_fill(x, y-2, gr_fb_width()-x, y+char_height_+2);
231 // white text of selected item 193 // white text of selected item
232 SetColor(MENU_SEL_FG); 194 SetColor(MENU_SEL_FG);
233 if (menu[i][0]) gr_text(x+4, y, menu[i], 1); 195 if (menu[i][0]) gr_text(x+4, y, menu[i], 1);
@@ -235,7 +197,7 @@ void WearRecoveryUI::draw_screen_locked()
235 } else { 197 } else {
236 if (menu[i][0]) gr_text(x+4, y, menu[i], 0); 198 if (menu[i][0]) gr_text(x+4, y, menu[i], 0);
237 } 199 }
238 y += char_height+4; 200 y += char_height_+4;
239 } 201 }
240 SetColor(MENU); 202 SetColor(MENU);
241 y += 4; 203 y += 4;
@@ -251,9 +213,9 @@ void WearRecoveryUI::draw_screen_locked()
251 int ty; 213 int ty;
252 int row = (text_top+text_rows-1) % text_rows; 214 int row = (text_top+text_rows-1) % text_rows;
253 size_t count = 0; 215 size_t count = 0;
254 for (int ty = gr_fb_height() - char_height - outer_height; 216 for (int ty = gr_fb_height() - char_height_ - outer_height;
255 ty > y+2 && count < text_rows; 217 ty > y+2 && count < text_rows;
256 ty -= char_height, ++count) { 218 ty -= char_height_, ++count) {
257 gr_text(x+4, ty, text[row], 0); 219 gr_text(x+4, ty, text[row], 0);
258 --row; 220 --row;
259 if (row < 0) row = text_rows-1; 221 if (row < 0) row = text_rows-1;
@@ -323,15 +285,15 @@ void WearRecoveryUI::Init()
323{ 285{
324 gr_init(); 286 gr_init();
325 287
326 gr_font_size(&char_width, &char_height); 288 gr_font_size(&char_width_, &char_height_);
327 289
328 text_col = text_row = 0; 290 text_col = text_row = 0;
329 text_rows = (gr_fb_height()) / char_height; 291 text_rows = (gr_fb_height()) / char_height_;
330 visible_text_rows = (gr_fb_height() - (outer_height * 2)) / char_height; 292 visible_text_rows = (gr_fb_height() - (outer_height * 2)) / char_height_;
331 if (text_rows > kMaxRows) text_rows = kMaxRows; 293 if (text_rows > kMaxRows) text_rows = kMaxRows;
332 text_top = 1; 294 text_top = 1;
333 295
334 text_cols = (gr_fb_width() - (outer_width * 2)) / char_width; 296 text_cols = (gr_fb_width() - (outer_width * 2)) / char_width_;
335 if (text_cols > kMaxCols - 1) text_cols = kMaxCols - 1; 297 if (text_cols > kMaxCols - 1) text_cols = kMaxCols - 1;
336 298
337 LoadBitmap("icon_installing", &backgroundIcon[INSTALLING_UPDATE]); 299 LoadBitmap("icon_installing", &backgroundIcon[INSTALLING_UPDATE]);