From 3aec6965bff19ae34ea036c5416c9106c1bd9340 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 20 Apr 2018 09:24:58 -0700 Subject: Add ScreenRecoveryUI::ShowMenu(). From caller's PoV, RecoveryUI::{Start,Select,End}Menu should always be used together, i.e. to show a menu and get user's selection. This CL provides ShowMenu() as one-stop service (which is based on get_menu_selection() from recovery.cpp). Also move RecoveryUI::{Start,Select,End}Menu into ScreenRecoveryUI, with a dropped access level from public to protected. Due to the dependency on recovery / librecovery refactoring, will add testcases in follow-up CLs. Test: Build and boot into recovery image. Check the menus (main menu, 'View recovery logs', 'Wipe data/factory reset'). Change-Id: Ie17aa78144871a12affd6f9075e045f76608a0ba --- screen_ui.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index c1222a576..837d346a2 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -135,10 +136,8 @@ class ScreenRecoveryUI : public RecoveryUI { void ShowFile(const char* filename) override; // menu display - void StartMenu(const char* const* headers, const char* const* items, - int initial_selection) override; - int SelectMenu(int sel) override; - void EndMenu() override; + int ShowMenu(const char* const* headers, const char* const* items, int initial_selection, + bool menu_only, const std::function& key_handler) override; void KeyLongPress(int) override; @@ -164,6 +163,18 @@ class ScreenRecoveryUI : public RecoveryUI { virtual bool InitTextParams(); + // Displays some header text followed by a menu of items, which appears at the top of the screen + // (in place of any scrolling ui_print() output, if necessary). + virtual void StartMenu(const char* const* headers, const char* const* items, + int initial_selection); + + // Sets the menu highlight to the given index, wrapping if necessary. Returns the actual item + // selected. + virtual int SelectMenu(int sel); + + // Ends menu mode, resetting the text overlay so that ui_print() statements will be displayed. + virtual void EndMenu(); + virtual void draw_background_locked(); virtual void draw_foreground_locked(); virtual void draw_screen_locked(); -- cgit v1.2.3