aboutsummaryrefslogtreecommitdiffstats
path: root/ui.cpp
diff options
context:
space:
mode:
authorTom Marshall <tdm@cyngn.com>2016-02-15 15:36:06 -0800
committerTom Marshall <tdm@cyngn.com>2016-03-07 15:16:25 -0800
commit6c20b00105e405823aa3ec12479e52cc30c0df9c (patch)
tree607a9223c74ea58e8d62bce4874ebc281846c134 /ui.cpp
parentd66f66eb72fc72c17d1a292cfbeaf2ec08721327 (diff)
downloadbootable_recovery-6c20b00105e405823aa3ec12479e52cc30c0df9c.zip
bootable_recovery-6c20b00105e405823aa3ec12479e52cc30c0df9c.tar.gz
bootable_recovery-6c20b00105e405823aa3ec12479e52cc30c0df9c.tar.bz2
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
Diffstat (limited to 'ui.cpp')
-rw-r--r--ui.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/ui.cpp b/ui.cpp
index 1594580..14f92b4 100644
--- a/ui.cpp
+++ b/ui.cpp
@@ -144,7 +144,9 @@ RecoveryUI::RecoveryUI()
last_key(-1),
has_power_key(false),
has_up_key(false),
- has_down_key(false) {
+ has_down_key(false),
+ has_back_key(false),
+ has_home_key(false) {
pthread_mutex_init(&key_queue_mutex, nullptr);
pthread_cond_init(&key_queue_cond, nullptr);
memset(key_pressed, 0, sizeof(key_pressed));
@@ -157,6 +159,12 @@ void RecoveryUI::OnKeyDetected(int key_code) {
has_down_key = true;
} else if (key_code == KEY_UP || key_code == KEY_VOLUMEUP) {
has_up_key = true;
+ } else if (key_code == KEY_BACK) {
+ has_back_key = true;
+ LOGI("Detected back key, disabling virtual back button\n");
+ } else if (key_code == KEY_HOMEPAGE) {
+ has_home_key = true;
+ LOGI("Detected home key, disabling virtual home button\n");
}
}
@@ -566,6 +574,12 @@ void RecoveryUI::handle_press(input_device* dev) {
dev->touch_start = dev->touch_track = dev->touch_pos;
dev->in_touch = true;
dev->in_swipe = false;
+ if (dev->touch_pos.y >= gr_fb_height() - GetSysbarHeight()) {
+ SetSysbarState(1 << (3 * dev->touch_pos.x / gr_fb_width()));
+ }
+ else {
+ SetSysbarState(0);
+ }
}
void RecoveryUI::handle_release(input_device* dev) {
@@ -588,6 +602,19 @@ void RecoveryUI::handle_release(input_device* dev) {
return;
}
}
+
+ int sysbar_state = GetSysbarState();
+ SetSysbarState(0);
+ if (sysbar_state == 0x01) {
+ ProcessKey(dev, KEY_BACK, 1);
+ ProcessKey(dev, KEY_BACK, 0);
+ return;
+ }
+ if (sysbar_state == 0x02) {
+ ProcessKey(dev, KEY_HOME, 1);
+ ProcessKey(dev, KEY_HOME, 0);
+ return;
+ }
}
if (DialogShowing()) {