From 0470ceea381775b09eee931858c3320be88cc637 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 2 Aug 2017 17:11:04 -0700 Subject: Allow customizing WearRecoveryUI via Makefile variables. With the following Makefile variables, we can reduce the work of writing (copy/pasting) device-specific WearRecoveryUI classes. The list of Makefile variables (the ones useful for Wear devices): - TARGET_RECOVERY_UI_MARGIN_HEIGHT (default: 0) - TARGET_RECOVERY_UI_MARGIN_WIDTH (default: 0) Specify the margin space that we don't want to display texts. They replace the former outer_width and outer_height. - TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD (default: 50) - TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD (default: 90) Specify the sensitivity of recognizing a swipe. Devices give absolute positions, so for some devices we need to adjust the thresholds. - TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE Specify the progress bar vertical position, which should be adjusted to the actual height of a device. It replaces the former progress_bar_y. - TARGET_RECOVERY_UI_ANIMATION_FPS (default: 30) Specify the animation FPS if using device-specific animation images. It replaces the former animation_fps. Devices can specify "TARGET_RECOVERY_UI_LIB := librecovery_ui_wear", with optionally defined Makefile vars above, in BoardConfig.mk to customize their WearRecoveryUI. Also remove the obsolete wear_touch.{cpp,h}, which has been merged into ui.cpp in commit 5f8dd9951d986b65d98d6a9ea38003427e9e46df. Bug: 64307776 Test: Change the device BoardConfig.mk and test recovery image. Change-Id: Id0fb2d4e3977ab5ddd31e71f9535470cab70e41b --- screen_ui.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index 8402fac00..1f40164af 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -84,6 +84,9 @@ class ScreenRecoveryUI : public RecoveryUI { const int kMarginWidth; const int kMarginHeight; + // Number of frames per sec (default: 30) for both parts of the animation. + const int kAnimationFps; + // The scale factor from dp to pixels. 1.0 for mdpi, 4.0 for xxxhdpi. const float density_; @@ -141,9 +144,6 @@ class ScreenRecoveryUI : public RecoveryUI { size_t current_frame; bool intro_done; - // Number of frames per sec (default: 30) for both parts of the animation. - int animation_fps; - int stage, max_stage; int char_width_; -- cgit v1.2.3 From 2bbc6d642d1fbfb007905d95b629fe5f833b2a1b Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Sun, 13 Aug 2017 23:48:55 -0700 Subject: screen_ui: Word-wrap menu headers. This CL adds ScreenRecoveryUI::DrawWrappedTextLines() to better handle long menu header texts. It does a word wrap at spaces, if available. This avoids fixed-length menu headers being truncated on small screens. Bug: 64293520 Test: On bullhead, boot into recovery with --prompt_and_wipe_data, and check the prompt texts. Change-Id: Ia22746583516dd230567a267584aca558429395e --- screen_ui.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index 8402fac00..df7cc25b3 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -187,6 +187,9 @@ class ScreenRecoveryUI : public RecoveryUI { virtual int DrawTextLine(int x, int y, const char* line, bool bold) const; // Draws multiple text lines. Returns the offset it should be moving along Y-axis. int DrawTextLines(int x, int y, const char* const* lines) const; + // Similar to DrawTextLines() to draw multiple text lines, but additionally wraps long lines. + // Returns the offset it should be moving along Y-axis. + int DrawWrappedTextLines(int x, int y, const char* const* lines) const; }; #endif // RECOVERY_UI_H -- cgit v1.2.3 From e15d7a5104978cd8399501636aec0df9c1a4823c Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Thu, 7 Sep 2017 13:38:51 -0700 Subject: ui: Manage menu_ with std::vector. Prior to this CL, menu_ is allocated with a fixed length of text_rows_. However, because we support scrollable menu in wear_ui, there might be more menu entries than text_rows_, which would lead to out-of-bounds array access. This CL addresses the issue by switching to std::vector. Bug: 65416558 Test: Run 'View recovery logs' on angler. Test: Set large margin height that leaves text_rows less than 21. Then run 'View recovery logs' with 21 menu entries. Change-Id: I5d4e3a0a097039e1104eda7d494c6269053dc894 --- screen_ui.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index 62dda7558..8231a2ba0 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -21,6 +21,7 @@ #include #include +#include #include "ui.h" @@ -127,7 +128,7 @@ class ScreenRecoveryUI : public RecoveryUI { bool show_text; bool show_text_ever; // has show_text ever been true? - char** menu_; + std::vector menu_; const char* const* menu_headers_; bool show_menu; int menu_items, menu_sel; -- cgit v1.2.3 From cb5524c23a761e37e8326edb95c8d1b684af352a Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 8 Sep 2017 21:25:32 -0700 Subject: ui: Remove text_top_. After the cleanup to WearRecoveryUI, text_top_ now always equals to ((text_row_ + 1) % text_rows_). Test: Check the recovery UI and 'View recovery logs'. Change-Id: I69a7f377bbd990db2194f9d3efae257c323c06a8 --- screen_ui.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index 8231a2ba0..44ae6926b 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -123,7 +123,7 @@ class ScreenRecoveryUI : public RecoveryUI { // Log text overlay, displayed when a magic key is pressed. char** text_; - size_t text_col_, text_row_, text_top_; + size_t text_col_, text_row_; bool show_text; bool show_text_ever; // has show_text ever been true? -- cgit v1.2.3 From 7577965ba12ec2ea0df2e523cf335c9c8e5cfd16 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Sun, 10 Sep 2017 11:28:32 -0700 Subject: ui: Refactor the declaration orders. By grouping similar kinds together, in an order of types, constants, ctor/dtor, all other methods and data members. Also rename ScreenRecoveryUI::density_ to ScreenRecoveryUI::kDensity to align with others. Test: mmma bootable/recovery Change-Id: I1ba2d15c05ba7be8c39762f3d9dadf1fb2130de4 --- screen_ui.h | 103 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 52 insertions(+), 51 deletions(-) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index 8231a2ba0..9bbdbf5df 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -32,6 +32,17 @@ struct GRSurface; // (shows an icon + a progress bar, text logging, menu, etc.) class ScreenRecoveryUI : public RecoveryUI { public: + enum UIElement { + HEADER, + MENU, + MENU_SEL_BG, + MENU_SEL_BG_ACTIVE, + MENU_SEL_FG, + LOG, + TEXT_FILL, + INFO + }; + ScreenRecoveryUI(); bool Init(const std::string& locale) override; @@ -67,16 +78,6 @@ class ScreenRecoveryUI : public RecoveryUI { void Redraw(); - enum UIElement { - HEADER, - MENU, - MENU_SEL_BG, - MENU_SEL_BG_ACTIVE, - MENU_SEL_FG, - LOG, - TEXT_FILL, - INFO - }; void SetColor(UIElement e) const; protected: @@ -89,7 +90,47 @@ class ScreenRecoveryUI : public RecoveryUI { const int kAnimationFps; // The scale factor from dp to pixels. 1.0 for mdpi, 4.0 for xxxhdpi. - const float density_; + const float kDensity; + + virtual bool InitTextParams(); + + virtual void draw_background_locked(); + virtual void draw_foreground_locked(); + virtual void draw_screen_locked(); + virtual void update_screen_locked(); + virtual void update_progress_locked(); + + GRSurface* GetCurrentFrame() const; + GRSurface* GetCurrentText() const; + + static void* ProgressThreadStartRoutine(void* data); + void ProgressThreadLoop(); + + virtual void ShowFile(FILE*); + virtual void PrintV(const char*, bool, va_list); + void PutChar(char); + void ClearText(); + + void LoadAnimation(); + void LoadBitmap(const char* filename, GRSurface** surface); + void LoadLocalizedBitmap(const char* filename, GRSurface** surface); + + int PixelsFromDp(int dp) const; + virtual int GetAnimationBaseline() const; + virtual int GetProgressBaseline() const; + virtual int GetTextBaseline() const; + + // Draws a highlight bar at (x, y) - (x + width, y + height). + virtual void DrawHighlightBar(int x, int y, int width, int height) const; + // Draws a horizontal rule at Y. Returns the offset it should be moving along Y-axis. + virtual int DrawHorizontalRule(int y) const; + // Draws a line of text. Returns the offset it should be moving along Y-axis. + virtual int DrawTextLine(int x, int y, const char* line, bool bold) const; + // Draws multiple text lines. Returns the offset it should be moving along Y-axis. + int DrawTextLines(int x, int y, const char* const* lines) const; + // Similar to DrawTextLines() to draw multiple text lines, but additionally wraps long lines. + // Returns the offset it should be moving along Y-axis. + int DrawWrappedTextLines(int x, int y, const char* const* lines) const; Icon currentIcon; @@ -151,46 +192,6 @@ class ScreenRecoveryUI : public RecoveryUI { int char_height_; pthread_mutex_t updateMutex; - - virtual bool InitTextParams(); - - virtual void draw_background_locked(); - virtual void draw_foreground_locked(); - virtual void draw_screen_locked(); - virtual void update_screen_locked(); - virtual void update_progress_locked(); - - GRSurface* GetCurrentFrame() const; - GRSurface* GetCurrentText() const; - - static void* ProgressThreadStartRoutine(void* data); - void ProgressThreadLoop(); - - virtual void ShowFile(FILE*); - virtual void PrintV(const char*, bool, va_list); - void PutChar(char); - void ClearText(); - - void LoadAnimation(); - void LoadBitmap(const char* filename, GRSurface** surface); - void LoadLocalizedBitmap(const char* filename, GRSurface** surface); - - int PixelsFromDp(int dp) const; - virtual int GetAnimationBaseline() const; - virtual int GetProgressBaseline() const; - virtual int GetTextBaseline() const; - - // Draws a highlight bar at (x, y) - (x + width, y + height). - virtual void DrawHighlightBar(int x, int y, int width, int height) const; - // Draws a horizontal rule at Y. Returns the offset it should be moving along Y-axis. - virtual int DrawHorizontalRule(int y) const; - // Draws a line of text. Returns the offset it should be moving along Y-axis. - virtual int DrawTextLine(int x, int y, const char* line, bool bold) const; - // Draws multiple text lines. Returns the offset it should be moving along Y-axis. - int DrawTextLines(int x, int y, const char* const* lines) const; - // Similar to DrawTextLines() to draw multiple text lines, but additionally wraps long lines. - // Returns the offset it should be moving along Y-axis. - int DrawWrappedTextLines(int x, int y, const char* const* lines) const; }; #endif // RECOVERY_UI_H -- cgit v1.2.3 From efb49add97cfda58c417ea4052cb6afb84c16c03 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Tue, 31 Jan 2017 23:03:10 -0800 Subject: ui: Move locale and friends into ScreenRecoveryUI class. Localized texts only make sense on devices with screens. Test: Run fake OTA on angler; check the on-screen texts. Change-Id: I3a644294c8b1f2056cfb78b2d61a598b8ddf2acf --- screen_ui.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index 0d7b9e86e..eaac2a6e8 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -191,7 +191,14 @@ class ScreenRecoveryUI : public RecoveryUI { int char_width_; int char_height_; + // The locale that's used to show the rendered texts. + std::string locale_; + bool rtl_locale_; + pthread_mutex_t updateMutex; + + private: + void SetLocale(const std::string&); }; #endif // RECOVERY_UI_H -- cgit v1.2.3 From 29d5575fa877770f6387420294d9dc184a84a115 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Wed, 20 Sep 2017 17:53:46 -0700 Subject: Add a new option in recovery menu to test the background texts Add a new option "Run locale test" to check the background text images (i.e. texts for "erasing", "error", "no_command" and "installing" with different locales.) Use volume up/down button to cycle through all the locales embedded in the png file, and power button to go back to recovery main menu. Test: Run locale test with bullhead. Change-Id: Ib16e119f372110cdb5e611ef497b0f9b9b418f51 --- screen_ui.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index eaac2a6e8..3a28a09de 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -80,6 +80,10 @@ class ScreenRecoveryUI : public RecoveryUI { void SetColor(UIElement e) const; + // Check the background text image. Use volume up/down button to cycle through the locales + // embedded in the png file, and power button to go back to recovery main menu. + void CheckBackgroundTextImages(const std::string& saved_locale); + protected: // The margin that we don't want to use for showing texts (e.g. round screen, or screen with // rounded corners). @@ -199,6 +203,10 @@ class ScreenRecoveryUI : public RecoveryUI { private: void SetLocale(const std::string&); + + // Display the background texts for "erasing", "error", "no_command" and "installing" for the + // selected locale. + void SelectAndShowBackgroundText(const std::vector& locales_entries, size_t sel); }; #endif // RECOVERY_UI_H -- cgit v1.2.3 From 92eda4db6cf6aae9fb9954c2555742ad7d1cd96a Mon Sep 17 00:00:00 2001 From: Luke Song Date: Tue, 19 Sep 2017 10:51:35 -0700 Subject: vr_ui: drawing changes Change drawing of horizontal bars. Implement image and background drawing. Bug: 65556996 Test: Viewed graphics test Change-Id: I68ddd997123607dbebf972af5a455ce8ef0c7075 --- screen_ui.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index 3a28a09de..f05761c42 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -124,12 +124,23 @@ class ScreenRecoveryUI : public RecoveryUI { virtual int GetProgressBaseline() const; virtual int GetTextBaseline() const; + // Returns pixel width of draw buffer. + virtual int ScreenWidth() const; + // Returns pixel height of draw buffer. + virtual int ScreenHeight() const; + // Draws a highlight bar at (x, y) - (x + width, y + height). virtual void DrawHighlightBar(int x, int y, int width, int height) const; // Draws a horizontal rule at Y. Returns the offset it should be moving along Y-axis. virtual int DrawHorizontalRule(int y) const; // Draws a line of text. Returns the offset it should be moving along Y-axis. virtual int DrawTextLine(int x, int y, const char* line, bool bold) const; + // Draws surface portion (sx, sy, w, h) at screen location (dx, dy). + virtual void DrawSurface(GRSurface* surface, int sx, int sy, int w, int h, int dx, int dy) const; + // Draws rectangle at (x, y) - (x + w, y + h). + virtual void DrawFill(int x, int y, int w, int h) const; + // Draws given surface (surface->pixel_bytes = 1) as text at (x, y). + virtual void DrawTextIcon(int x, int y, GRSurface* surface) const; // Draws multiple text lines. Returns the offset it should be moving along Y-axis. int DrawTextLines(int x, int y, const char* const* lines) const; // Similar to DrawTextLines() to draw multiple text lines, but additionally wraps long lines. -- cgit v1.2.3