summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2019-07-26 20:33:27 +0200
committerandroid-build-merger <android-build-merger@google.com>2019-07-26 20:33:27 +0200
commita89bb37a4c95060c55ca6e4330dd219149b93d7c (patch)
treeb7bd71c01529152b1d2789bcb8358fcf6fe8f428
parentMerge "Clean up some global variables in common.h" am: 80c405f692 am: 168ce56022 (diff)
parentMerge "Create a new function to return the help message for menu" am: 5d9f963e4e (diff)
downloadandroid_bootable_recovery-a89bb37a4c95060c55ca6e4330dd219149b93d7c.tar
android_bootable_recovery-a89bb37a4c95060c55ca6e4330dd219149b93d7c.tar.gz
android_bootable_recovery-a89bb37a4c95060c55ca6e4330dd219149b93d7c.tar.bz2
android_bootable_recovery-a89bb37a4c95060c55ca6e4330dd219149b93d7c.tar.lz
android_bootable_recovery-a89bb37a4c95060c55ca6e4330dd219149b93d7c.tar.xz
android_bootable_recovery-a89bb37a4c95060c55ca6e4330dd219149b93d7c.tar.zst
android_bootable_recovery-a89bb37a4c95060c55ca6e4330dd219149b93d7c.zip
-rw-r--r--recovery_ui/include/recovery_ui/screen_ui.h3
-rw-r--r--recovery_ui/include/recovery_ui/ui.h2
-rw-r--r--recovery_ui/screen_ui.cpp24
-rw-r--r--recovery_ui/ui.cpp2
4 files changed, 19 insertions, 12 deletions
diff --git a/recovery_ui/include/recovery_ui/screen_ui.h b/recovery_ui/include/recovery_ui/screen_ui.h
index 5cda2a2e5..92b3c2546 100644
--- a/recovery_ui/include/recovery_ui/screen_ui.h
+++ b/recovery_ui/include/recovery_ui/screen_ui.h
@@ -286,6 +286,9 @@ class ScreenRecoveryUI : public RecoveryUI, public DrawInterface {
// selected.
virtual int SelectMenu(int sel);
+ // Returns the help message displayed on top of the menu.
+ virtual std::vector<std::string> GetMenuHelpMessage() const;
+
virtual void draw_background_locked();
virtual void draw_foreground_locked();
virtual void draw_screen_locked();
diff --git a/recovery_ui/include/recovery_ui/ui.h b/recovery_ui/include/recovery_ui/ui.h
index a95f935e4..08ec1d76a 100644
--- a/recovery_ui/include/recovery_ui/ui.h
+++ b/recovery_ui/include/recovery_ui/ui.h
@@ -118,7 +118,7 @@ class RecoveryUI {
// Returns true if you have the volume up/down and power trio typical of phones and tablets, false
// otherwise.
- virtual bool HasThreeButtons();
+ virtual bool HasThreeButtons() const;
// Returns true if it has a power key.
virtual bool HasPowerKey() const;
diff --git a/recovery_ui/screen_ui.cpp b/recovery_ui/screen_ui.cpp
index f2af66c45..087fc0e84 100644
--- a/recovery_ui/screen_ui.cpp
+++ b/recovery_ui/screen_ui.cpp
@@ -673,6 +673,19 @@ void ScreenRecoveryUI::SetTitle(const std::vector<std::string>& lines) {
title_lines_ = lines;
}
+std::vector<std::string> ScreenRecoveryUI::GetMenuHelpMessage() const {
+ // clang-format off
+ static std::vector<std::string> REGULAR_HELP{
+ "Use volume up/down and power.",
+ };
+ static std::vector<std::string> LONG_PRESS_HELP{
+ "Any button cycles highlight.",
+ "Long-press activates.",
+ };
+ // clang-format on
+ return HasThreeButtons() ? REGULAR_HELP : LONG_PRESS_HELP;
+}
+
// Redraws everything on the screen. Does not flip pages. Should only be called with updateMutex
// locked.
void ScreenRecoveryUI::draw_screen_locked() {
@@ -685,16 +698,7 @@ void ScreenRecoveryUI::draw_screen_locked() {
gr_color(0, 0, 0, 255);
gr_clear();
- // clang-format off
- static std::vector<std::string> REGULAR_HELP{
- "Use volume up/down and power.",
- };
- static std::vector<std::string> LONG_PRESS_HELP{
- "Any button cycles highlight.",
- "Long-press activates.",
- };
- // clang-format on
- draw_menu_and_text_buffer_locked(HasThreeButtons() ? REGULAR_HELP : LONG_PRESS_HELP);
+ draw_menu_and_text_buffer_locked(GetMenuHelpMessage());
}
// Draws the menu and text buffer on the screen. Should only be called with updateMutex locked.
diff --git a/recovery_ui/ui.cpp b/recovery_ui/ui.cpp
index 98c654ddb..6f5cbbca6 100644
--- a/recovery_ui/ui.cpp
+++ b/recovery_ui/ui.cpp
@@ -528,7 +528,7 @@ bool RecoveryUI::IsLongPress() {
return result;
}
-bool RecoveryUI::HasThreeButtons() {
+bool RecoveryUI::HasThreeButtons() const {
return has_power_key && has_up_key && has_down_key;
}