diff options
author | Tom Marshall <tdm@cyngn.com> | 2016-02-15 15:36:06 -0800 |
---|---|---|
committer | Tom Marshall <tdm@cyngn.com> | 2016-03-07 15:16:25 -0800 |
commit | 6c20b00105e405823aa3ec12479e52cc30c0df9c (patch) | |
tree | 607a9223c74ea58e8d62bce4874ebc281846c134 /recovery.cpp | |
parent | d66f66eb72fc72c17d1a292cfbeaf2ec08721327 (diff) | |
download | bootable_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 'recovery.cpp')
-rw-r--r-- | recovery.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/recovery.cpp b/recovery.cpp index 35c6830..c13a689 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -662,7 +662,10 @@ get_menu_selection(const char* const * headers, const char* const * items, int selected = initial_selection; int chosen_item = -1; - while (chosen_item < 0 && chosen_item != Device::kGoBack && chosen_item != Device::kRefresh) { + while (chosen_item < 0 && + chosen_item != Device::kGoBack && + chosen_item != Device::kGoHome && + chosen_item != Device::kRefresh) { int key = ui->WaitKey(); int visible = ui->IsTextVisible(); @@ -713,6 +716,9 @@ get_menu_selection(const char* const * headers, const char* const * items, case Device::kGoBack: chosen_item = Device::kGoBack; break; + case Device::kGoHome: + chosen_item = Device::kGoHome; + break; case Device::kRefresh: chosen_item = Device::kRefresh; break; @@ -723,6 +729,9 @@ get_menu_selection(const char* const * headers, const char* const * items, } ui->EndMenu(); + if (chosen_item == Device::kGoHome) { + device->GoHome(); + } return chosen_item; } @@ -796,6 +805,11 @@ static char* browse_directory(const char* path, Device* device) { int chosen_item = 0; while (true) { chosen_item = get_menu_selection(headers, zips, 1, chosen_item, device); + if (chosen_item == Device::kGoHome) { + // go up and stop browsing + result = strdup(""); + break; + } if (chosen_item == 0 || chosen_item == Device::kGoBack) { // go up but continue browsing (if the caller is update_directory) result = NULL; @@ -936,6 +950,7 @@ static void choose_recovery_file(Device* device) { while (true) { int chosen_item = get_menu_selection(headers, entries, 1, 0, device); + if (chosen_item == Device::kGoHome) break; if (chosen_item == Device::kGoBack) break; if (chosen_item >= 0 && strcmp(entries[chosen_item], "Back") == 0) break; @@ -959,9 +974,10 @@ static int apply_from_storage(Device* device, const std::string& id, bool* wipe_ VolumeInfo vi = vdc->getVolume(id); char* path = browse_directory(vi.mInternalPath.c_str(), device); - if (path == NULL) { + if (path == NULL || *path == '\0') { ui->Print("\n-- No package file selected.\n"); vdc->volumeUnmount(vi.mId); + free(path); return INSTALL_NONE; } @@ -1013,6 +1029,9 @@ refresh: if (chosen == Device::kRefresh) { goto refresh; } + if (chosen == Device::kGoHome) { + return INSTALL_NONE; + } if (chosen == Device::kGoBack) { return INSTALL_NONE; } |