diff --git a/apps/keymaps/keymap-h1x0_h3x0.c b/apps/keymaps/keymap-h1x0_h3x0.c index b31ce6e6db..8413d09ce6 100644 --- a/apps/keymaps/keymap-h1x0_h3x0.c +++ b/apps/keymaps/keymap-h1x0_h3x0.c @@ -106,7 +106,6 @@ static const struct button_mapping button_context_list[] = { static const struct button_mapping button_context_tree[] = { { ACTION_TREE_WPS, BUTTON_ON|BUTTON_REL, BUTTON_ON }, { ACTION_TREE_STOP, BUTTON_OFF, BUTTON_NONE }, - { ACTION_TREE_STOP, BUTTON_OFF|BUTTON_REL, BUTTON_OFF }, { ACTION_TREE_STOP, BUTTON_OFF|BUTTON_REPEAT, BUTTON_NONE }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST) diff --git a/apps/menu.c b/apps/menu.c index 8d4464808c..26edbb040c 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -476,13 +476,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected) } else if (action == ACTION_TREE_STOP) { - if (audio_status() && !global_settings.party_mode) - { - if (global_settings.fade_on_stop) - fade(0); - bookmark_autobookmark(); - audio_stop(); - } + list_stop_handler(); } else if (action == ACTION_STD_MENU) { diff --git a/apps/misc.c b/apps/misc.c index e3b94340de..8004589732 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -58,6 +58,7 @@ #include "icons.h" #endif /* End HAVE_LCD_BITMAP */ #include "gui/gwps-common.h" +#include "bookmark.h" #include "misc.h" @@ -676,6 +677,52 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter) return false; } +bool list_stop_handler(void) +{ + bool ret = false; + + /* Stop the music if it is playing */ + if(audio_status()) + { + if (!global_settings.party_mode) + { + if (global_settings.fade_on_stop) + fade(0); + bookmark_autobookmark(); + audio_stop(); + } + } +#if CONFIG_CHARGING +#if (CONFIG_KEYPAD == RECORDER_PAD) && !defined(HAVE_SW_POWEROFF) + else + { + if (charger_inserted()) + charging_splash(); + else + shutdown_screen(); /* won't return if shutdown actually happens */ + + ret = true; /* screen is dirty, caller needs to refresh */ + } +#endif +#ifndef HAVE_POWEROFF_WHILE_CHARGING + { + static long last_off = 0; + + if (TIME_BEFORE(current_tick, last_off + HZ/2)) + { + if (charger_inserted()) + { + charging_splash(); + ret = true; /* screen is dirty, caller needs to refresh */ + } + } + last_off = current_tick; + } +#endif +#endif /* CONFIG_CHARGING */ + return ret; +} + #if CONFIG_CHARGING static bool waiting_to_resume_play = false; static long play_resume_tick; diff --git a/apps/misc.h b/apps/misc.h index b30942f47e..959674fefd 100644 --- a/apps/misc.h +++ b/apps/misc.h @@ -88,6 +88,7 @@ void screen_dump_set_hook(void (*hook)(int fh)); bool settings_parseline(char* line, char** name, char** value); long default_event_handler_ex(long event, void (*callback)(void *), void *parameter); long default_event_handler(long event); +bool list_stop_handler(void); void car_adapter_mode_init(void); extern int show_logo(void); diff --git a/apps/root_menu.c b/apps/root_menu.c index 1fc330941c..1b97cdef42 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c @@ -25,11 +25,13 @@ #include "root_menu.h" #include "lang.h" #include "settings.h" +#include "screens.h" #include "kernel.h" #include "debug.h" #include "misc.h" #include "rolo.h" #include "powermgmt.h" +#include "power.h" #if LCD_DEPTH > 1 #include "backdrop.h" @@ -304,7 +306,10 @@ MENUITEM_RETURNVALUE(bookmarks, ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS), #ifdef HAVE_LCD_CHARCELLS static int do_shutdown(void) { - sys_poweroff(); + if (charger_inserted()) + charging_splash(); + else + sys_poweroff(); return 0; } MENUITEM_FUNCTION(do_shutdown_item, 0, ID2P(LANG_SHUTDOWN), diff --git a/apps/tree.c b/apps/tree.c index 5f5cb1137a..723c003ca9 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -665,43 +665,10 @@ static int dirbrowse() break; case ACTION_TREE_STOP: - if (*tc.dirfilter < NUM_FILTER_MODES) - { - /* Stop the music if it is playing */ - if(audio_status()) { - if (!global_settings.party_mode) { - if (global_settings.fade_on_stop) - fade(0); - bookmark_autobookmark(); - audio_stop(); - } - } -#if CONFIG_CHARGING && \ - (CONFIG_KEYPAD == RECORDER_PAD) && !defined(HAVE_SW_POWEROFF) - else { - if (!charger_inserted()) { - if(shutdown_screen()) - reload_dir = true; - } else { - charging_splash(); - } - restore = true; - } -#endif - } -#if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING) -{ - static int last_off = 0; - if (current_tick - last_off < 50) { - if (charger_inserted()) { - charging_splash(); - restore = true; - } - } - last_off = current_tick; -} -#endif - break; /* case ACTION_TREE_STOP: */ + if (list_stop_handler()) + restore = true; + break; + case ACTION_STD_MENU: return GO_TO_ROOT; break;