diff options
author | Tao Bao <tbao@google.com> | 2018-08-04 01:02:17 +0200 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-08-04 01:02:17 +0200 |
commit | 17bf8d0518b336adfbab90d8cd14fc00d1b7a62e (patch) | |
tree | f6ede4d70751e7a17f7729f2a5823ae5c488a4e4 /screen_ui.cpp | |
parent | Merge "Remove non-A/B mention from README." (diff) | |
parent | Merge "ui: Read custom recovery UI values via system property." (diff) | |
download | android_bootable_recovery-17bf8d0518b336adfbab90d8cd14fc00d1b7a62e.tar android_bootable_recovery-17bf8d0518b336adfbab90d8cd14fc00d1b7a62e.tar.gz android_bootable_recovery-17bf8d0518b336adfbab90d8cd14fc00d1b7a62e.tar.bz2 android_bootable_recovery-17bf8d0518b336adfbab90d8cd14fc00d1b7a62e.tar.lz android_bootable_recovery-17bf8d0518b336adfbab90d8cd14fc00d1b7a62e.tar.xz android_bootable_recovery-17bf8d0518b336adfbab90d8cd14fc00d1b7a62e.tar.zst android_bootable_recovery-17bf8d0518b336adfbab90d8cd14fc00d1b7a62e.zip |
Diffstat (limited to '')
-rw-r--r-- | screen_ui.cpp | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp index c14f29d49..391dedb00 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -142,11 +142,18 @@ int Menu::Select(int sel) { ScreenRecoveryUI::ScreenRecoveryUI() : ScreenRecoveryUI(false) {} +constexpr int kDefaultMarginHeight = 0; +constexpr int kDefaultMarginWidth = 0; +constexpr int kDefaultAnimationFps = 30; + ScreenRecoveryUI::ScreenRecoveryUI(bool scrollable_menu) - : kMarginWidth(RECOVERY_UI_MARGIN_WIDTH), - kMarginHeight(RECOVERY_UI_MARGIN_HEIGHT), - kAnimationFps(RECOVERY_UI_ANIMATION_FPS), - kDensity(static_cast<float>(android::base::GetIntProperty("ro.sf.lcd_density", 160)) / 160.f), + : margin_width_( + android::base::GetIntProperty("ro.recovery.ui.margin_width", kDefaultMarginWidth)), + margin_height_( + android::base::GetIntProperty("ro.recovery.ui.margin_height", kDefaultMarginHeight)), + animation_fps_( + android::base::GetIntProperty("ro.recovery.ui.animation_fps", kDefaultAnimationFps)), + density_(static_cast<float>(android::base::GetIntProperty("ro.sf.lcd_density", 160)) / 160.f), currentIcon(NONE), progressBarType(EMPTY), progressScopeStart(0), @@ -203,7 +210,7 @@ GRSurface* ScreenRecoveryUI::GetCurrentText() const { } int ScreenRecoveryUI::PixelsFromDp(int dp) const { - return dp * kDensity; + return dp * density_; } // Here's the intended layout: @@ -258,7 +265,7 @@ void ScreenRecoveryUI::draw_background_locked() { int stage_height = gr_get_height(stageMarkerEmpty); int stage_width = gr_get_width(stageMarkerEmpty); int x = (ScreenWidth() - max_stage * gr_get_width(stageMarkerEmpty)) / 2; - int y = ScreenHeight() - stage_height - kMarginHeight; + int y = ScreenHeight() - stage_height - margin_height_; for (int i = 0; i < max_stage; ++i) { GRSurface* stage_surface = (i < stage) ? stageMarkerFill : stageMarkerEmpty; DrawSurface(stage_surface, 0, 0, stage_width, stage_height, x, y); @@ -373,8 +380,8 @@ void ScreenRecoveryUI::SelectAndShowBackgroundText(const std::vector<std::string gr_color(0, 0, 0, 255); gr_clear(); - int text_y = kMarginHeight; - int text_x = kMarginWidth; + int text_y = margin_height_; + int text_x = margin_width_; int line_spacing = gr_sys_font()->char_height; // Put some extra space between images. // Write the header and descriptive texts. SetColor(INFO); @@ -535,10 +542,10 @@ void ScreenRecoveryUI::draw_screen_locked() { // Draws the menu and text buffer on the screen. Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_menu_and_text_buffer_locked( const std::vector<std::string>& help_message) { - int y = kMarginHeight; + int y = margin_height_; if (menu_) { static constexpr int kMenuIndent = 4; - int x = kMarginWidth + kMenuIndent; + int x = margin_width_ + kMenuIndent; SetColor(INFO); @@ -594,9 +601,9 @@ void ScreenRecoveryUI::draw_menu_and_text_buffer_locked( SetColor(LOG); int row = text_row_; size_t count = 0; - for (int ty = ScreenHeight() - kMarginHeight - char_height_; ty >= y && count < text_rows_; + for (int ty = ScreenHeight() - margin_height_ - char_height_; ty >= y && count < text_rows_; ty -= char_height_, ++count) { - DrawTextLine(kMarginWidth, ty, text_[row], false); + DrawTextLine(margin_width_, ty, text_[row], false); --row; if (row < 0) row = text_rows_ - 1; } @@ -622,7 +629,7 @@ void ScreenRecoveryUI::update_progress_locked() { } void ScreenRecoveryUI::ProgressThreadLoop() { - double interval = 1.0 / kAnimationFps; + double interval = 1.0 / animation_fps_; while (!progress_thread_stopped_) { double start = now(); bool redraw = false; @@ -708,8 +715,8 @@ bool ScreenRecoveryUI::InitTextParams() { return false; } gr_font_size(gr_sys_font(), &char_width_, &char_height_); - text_rows_ = (ScreenHeight() - kMarginHeight * 2) / char_height_; - text_cols_ = (ScreenWidth() - kMarginWidth * 2) / char_width_; + text_rows_ = (ScreenHeight() - margin_height_ * 2) / char_height_; + text_cols_ = (ScreenWidth() - margin_width_ * 2) / char_width_; return true; } |