aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes2015-04-10 17:00:34 -0500
committerElliott Hughes2015-04-10 17:14:35 -0500
commit4af215b2c35b41e983753256ad6dbebbf879c982 (patch)
treef327758d07cdb58a8e4a06f236f82f8df9515992 /device.cpp
parent51697d2781501c30d8db6d2a8e6c2becebcffad8 (diff)
downloadplatform-bootable-recovery-4af215b2c35b41e983753256ad6dbebbf879c982.tar.gz
platform-bootable-recovery-4af215b2c35b41e983753256ad6dbebbf879c982.tar.xz
platform-bootable-recovery-4af215b2c35b41e983753256ad6dbebbf879c982.zip
Auto-detect whether to use the long-press UI.
Change-Id: Ie77a5584e301467c6a5e164d2c62d6f036b2c0c0
Diffstat (limited to 'device.cpp')
-rw-r--r--device.cpp50
1 files changed, 43 insertions, 7 deletions
diff --git a/device.cpp b/device.cpp
index af92b15b..024fc346 100644
--- a/device.cpp
+++ b/device.cpp
@@ -16,15 +16,21 @@
16 16
17#include "device.h" 17#include "device.h"
18 18
19// TODO: this is a lie for, say, fugu. 19static const char* REGULAR_HEADERS[] = {
20static const char* HEADERS[] = { 20 "Volume up/down move highlight.",
21 "Volume up/down to move highlight.", 21 "Power button activates.",
22 "Power button to select.",
23 "", 22 "",
24 NULL 23 NULL
25}; 24};
26 25
27static const char* ITEMS[] = { 26static const char* LONG_PRESS_HEADERS[] = {
27 "Any button cycles highlight.",
28 "Long-press activates.",
29 "",
30 NULL
31};
32
33static const char* MENU_ITEMS[] = {
28 "Reboot system now", 34 "Reboot system now",
29 "Reboot to bootloader", 35 "Reboot to bootloader",
30 "Apply update from ADB", 36 "Apply update from ADB",
@@ -37,8 +43,13 @@ static const char* ITEMS[] = {
37 NULL 43 NULL
38}; 44};
39 45
40const char* const* Device::GetMenuHeaders() { return HEADERS; } 46const char* const* Device::GetMenuHeaders() {
41const char* const* Device::GetMenuItems() { return ITEMS; } 47 return ui_->HasThreeButtons() ? REGULAR_HEADERS : LONG_PRESS_HEADERS;
48}
49
50const char* const* Device::GetMenuItems() {
51 return MENU_ITEMS;
52}
42 53
43Device::BuiltinAction Device::InvokeMenuItem(int menu_position) { 54Device::BuiltinAction Device::InvokeMenuItem(int menu_position) {
44 switch (menu_position) { 55 switch (menu_position) {
@@ -54,3 +65,28 @@ Device::BuiltinAction Device::InvokeMenuItem(int menu_position) {
54 default: return NO_ACTION; 65 default: return NO_ACTION;
55 } 66 }
56} 67}
68
69int Device::HandleMenuKey(int key, int visible) {
70 if (!visible) {
71 return kNoAction;
72 }
73
74 switch (key) {
75 case KEY_DOWN:
76 case KEY_VOLUMEDOWN:
77 return kHighlightDown;
78
79 case KEY_UP:
80 case KEY_VOLUMEUP:
81 return kHighlightUp;
82
83 case KEY_ENTER:
84 case KEY_POWER:
85 return kInvokeItem;
86
87 default:
88 // If you have all of the above buttons, any other buttons
89 // are ignored. Otherwise, any button cycles the highlight.
90 return ui_->HasThreeButtons() ? kNoAction : kHighlightDown;
91 }
92}