summaryrefslogtreecommitdiffstats
path: root/screen_ui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'screen_ui.cpp')
-rw-r--r--screen_ui.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp
index 10e56dec4..d21a64890 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -51,7 +51,9 @@ static double now() {
}
ScreenRecoveryUI::ScreenRecoveryUI()
- : density_(static_cast<float>(android::base::GetIntProperty("ro.sf.lcd_density", 160)) / 160.f),
+ : kMarginWidth(RECOVERY_UI_MARGIN_WIDTH),
+ kMarginHeight(RECOVERY_UI_MARGIN_HEIGHT),
+ density_(static_cast<float>(android::base::GetIntProperty("ro.sf.lcd_density", 160)) / 160.f),
currentIcon(NONE),
progressBarType(EMPTY),
progressScopeStart(0),
@@ -78,8 +80,6 @@ ScreenRecoveryUI::ScreenRecoveryUI()
animation_fps(30), // TODO: there's currently no way to infer this.
stage(-1),
max_stage(-1),
- margin_width_(0),
- margin_height_(0),
updateMutex(PTHREAD_MUTEX_INITIALIZER) {}
GRSurface* ScreenRecoveryUI::GetCurrentFrame() {
@@ -257,6 +257,10 @@ void ScreenRecoveryUI::DrawHorizontalRule(int* y) {
*y += 4;
}
+void ScreenRecoveryUI::DrawHighlightBar(int x, int y, int width, int height) const {
+ gr_fill(x, y, x + width, y + height);
+}
+
void ScreenRecoveryUI::DrawTextLine(int x, int* y, const char* line, bool bold) const {
gr_text(gr_sys_font(), x, *y, line, bold);
*y += char_height_ + 4;
@@ -292,8 +296,8 @@ void ScreenRecoveryUI::draw_screen_locked() {
gr_clear();
static constexpr int TEXT_INDENT = 4;
- int x = TEXT_INDENT + margin_width_;
- int y = margin_height_;
+ int x = TEXT_INDENT + kMarginWidth;
+ int y = kMarginHeight;
if (show_menu) {
std::string recovery_fingerprint =
android::base::GetProperty("ro.bootimage.build.fingerprint", "");
@@ -315,15 +319,14 @@ void ScreenRecoveryUI::draw_screen_locked() {
if (i == menu_sel) {
// Draw the highlight bar.
SetColor(IsLongPress() ? MENU_SEL_BG_ACTIVE : MENU_SEL_BG);
- gr_fill(0, y - 2, gr_fb_width(), y + char_height_ + 2);
+ DrawHighlightBar(0, y - 2, gr_fb_width(), char_height_ + 4);
// Bold white text for the selected item.
SetColor(MENU_SEL_FG);
- gr_text(gr_sys_font(), 4, y, menu_[i], true);
+ DrawTextLine(x, &y, menu_[i], true);
SetColor(MENU);
} else {
- gr_text(gr_sys_font(), 4, y, menu_[i], false);
+ DrawTextLine(x, &y, menu_[i], false);
}
- y += char_height_ + 4;
}
DrawHorizontalRule(&y);
}
@@ -333,9 +336,10 @@ void ScreenRecoveryUI::draw_screen_locked() {
SetColor(LOG);
int row = (text_top_ + text_rows_ - 1) % text_rows_;
size_t count = 0;
- for (int ty = gr_fb_height() - margin_height_ - char_height_;
+ for (int ty = gr_fb_height() - kMarginHeight - char_height_ - log_bottom_offset_;
ty >= y && count < text_rows_; ty -= char_height_, ++count) {
- gr_text(gr_sys_font(), 0, ty, text_[row], false);
+ int temp_y = ty;
+ DrawTextLine(x, &temp_y, text_[row], false);
--row;
if (row < 0) row = text_rows_ - 1;
}
@@ -453,8 +457,9 @@ bool ScreenRecoveryUI::InitTextParams() {
}
gr_font_size(gr_sys_font(), &char_width_, &char_height_);
- text_rows_ = (gr_fb_height() - margin_height_ * 2) / char_height_;
- text_cols_ = (gr_fb_width() - margin_width_ * 2) / char_width_;
+ text_rows_ = (gr_fb_height() - kMarginHeight * 2) / char_height_;
+ text_cols_ = (gr_fb_width() - kMarginWidth * 2) / char_width_;
+ log_bottom_offset_ = 0;
return true;
}