From 6c20b00105e405823aa3ec12479e52cc30c0df9c Mon Sep 17 00:00:00 2001 From: Tom Marshall Date: Mon, 15 Feb 2016 15:36:06 -0800 Subject: recovery: Implement sysbar Add a system bar (navigation bar) similar to the main Android system with back and home buttons. This makes it easier for users to figure out how to go back on devices that lack hardware buttons, and also provides a quick way to get back to the main menu. Note only buttons that do not have a hardware equivalent are shown, in order to prevent redundancy and confusion. Change-Id: I7538749978837571a8c250c3c8e54ac127b39d84 --- device.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'device.cpp') diff --git a/device.cpp b/device.cpp index 7f579cf..95608d6 100644 --- a/device.cpp +++ b/device.cpp @@ -139,6 +139,12 @@ Device::BuiltinAction Device::InvokeMenuItem(int menu_position) { return entry->action.action; } +void Device::GoHome() { + while (menu_stack.size() > 1) { + menu_stack.pop(); + } +} + int Device::HandleMenuKey(int key, int visible) { if (!visible) { return kNoAction; @@ -164,8 +170,6 @@ int Device::HandleMenuKey(int key, int visible) { case KEY_ENTER: case KEY_POWER: case BTN_MOUSE: - case KEY_HOME: - case KEY_HOMEPAGE: case KEY_SEND: return kInvokeItem; @@ -173,6 +177,10 @@ int Device::HandleMenuKey(int key, int visible) { case KEY_BACK: return kGoBack; + case KEY_HOME: + case KEY_HOMEPAGE: + return kGoHome; + default: // If you have all of the above buttons, any other buttons // are ignored. Otherwise, any button cycles the highlight. -- cgit v1.1