diff --git a/apps/root_menu.c b/apps/root_menu.c index 5a8d40f..a65ceb5 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c @@ -639,7 +639,15 @@ void root_menu(void) case GO_TO_ROOT: if (last_screen != GO_TO_ROOT) selected = get_selection(last_screen); +#if (CONFIG_PLATFORM&PLATFORM_ANDROID) + /* When we are in the main menu we want the hardware BACK + * button to be handled by Android instead of rockbox */ + android_ignore_back_button(true); +#endif next_screen = do_menu(&root_menu_, &selected, NULL, false); +#if (CONFIG_PLATFORM&PLATFORM_ANDROID) + android_ignore_back_button(false); +#endif if (next_screen != GO_TO_PREVIOUS) last_screen = GO_TO_ROOT; break; diff --git a/firmware/target/hosted/android/app/button-application.c b/firmware/target/hosted/android/app/button-application.c index a7d75ef..5cbf6c7 100644 --- a/firmware/target/hosted/android/app/button-application.c +++ b/firmware/target/hosted/android/app/button-application.c @@ -23,6 +23,12 @@ #include "button.h" #include "android_keyevents.h" +static bool ignore_back_button = false; +void android_ignore_back_button(bool yes) +{ + ignore_back_button = yes; +} + int key_to_button(int keyboard_key) { switch (keyboard_key) @@ -30,7 +36,7 @@ int key_to_button(int keyboard_key) default: return BUTTON_NONE; case KEYCODE_BACK: - return BUTTON_BACK; + return ignore_back_button ? BUTTON_NONE : BUTTON_BACK; case KEYCODE_DPAD_UP: return BUTTON_DPAD_UP; case KEYCODE_DPAD_DOWN: diff --git a/firmware/target/hosted/android/app/button-target.h b/firmware/target/hosted/android/app/button-target.h index ca306d4..191f6e4 100644 --- a/firmware/target/hosted/android/app/button-target.h +++ b/firmware/target/hosted/android/app/button-target.h @@ -29,6 +29,7 @@ void button_init_device(void); int button_read_device(int *data); unsigned multimedia_to_button(int keyboard_key); +void android_ignore_back_button(bool yes); /* Main unit's buttons */ #define BUTTON_MENU 0x00000001