diff options
author | Christian Soffke <christian.soffke@gmail.com> | 2021-04-11 01:32:53 +0200 |
---|---|---|
committer | Christian Soffke <christian.soffke@gmail.com> | 2022-11-19 10:01:23 +0100 |
commit | 3d34140cfbd63910654fd20e3e90e30de114f5d9 (patch) | |
tree | 34c5094e290d5425401c11401d350cbd049555b7 | |
parent | 3b1230b36592c1f16c8ceb101e7dc1cf263bd260 (diff) | |
download | rockbox-3d34140cfbd63910654fd20e3e90e30de114f5d9.tar.gz rockbox-3d34140cfbd63910654fd20e3e90e30de114f5d9.zip |
Fix return to root after selecting items from playlist viewer
When selecting an item, Rockbox only checked that
playback was stopped before entering the viewer and
went to the WPS if music had started playing afterwards,
but returned to the root menu otherwise
The WPS will now be displayed whenever a new item has been
selected, even if audio was paused or playing before.
boomark_autoload required slight adjustments to its return values,
so that the WPS would not be opened after a user cancels out of
the bookmark selection screen for a playlist, since it previously
returned true in that case, too.
Change-Id: I231ea788e2f80fdda5fe4ad4d2420450931f686f
-rw-r--r-- | apps/bookmark.c | 20 | ||||
-rw-r--r-- | apps/bookmark.h | 8 | ||||
-rw-r--r-- | apps/filetree.c | 9 | ||||
-rw-r--r-- | apps/onplay.c | 3 | ||||
-rw-r--r-- | apps/playlist_catalog.c | 25 | ||||
-rw-r--r-- | apps/playlist_catalog.h | 2 | ||||
-rw-r--r-- | apps/playlist_viewer.c | 25 | ||||
-rw-r--r-- | apps/root_menu.c | 6 |
8 files changed, 70 insertions, 28 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c index 0cc2807609..20841b4940 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c | |||
@@ -441,27 +441,31 @@ static char* create_bookmark() | |||
441 | /* ----------------------------------------------------------------------- */ | 441 | /* ----------------------------------------------------------------------- */ |
442 | /* This function will determine if an autoload is necessary. This is an */ | 442 | /* This function will determine if an autoload is necessary. This is an */ |
443 | /* interface function. */ | 443 | /* interface function. */ |
444 | /* Returns true on bookmark load or bookmark selection. */ | 444 | /* Returns */ |
445 | /* BOOKMARK_DO_RESUME on bookmark load or bookmark selection. */ | ||
446 | /* BOOKMARK_DONT_RESUME if we're not going to resume */ | ||
447 | /* BOOKMARK_CANCEL if user canceled */ | ||
445 | /* ------------------------------------------------------------------------*/ | 448 | /* ------------------------------------------------------------------------*/ |
446 | bool bookmark_autoload(const char* file) | 449 | int bookmark_autoload(const char* file) |
447 | { | 450 | { |
448 | char* bookmark; | 451 | char* bookmark; |
449 | 452 | ||
450 | if(global_settings.autoloadbookmark == BOOKMARK_NO) | 453 | if(global_settings.autoloadbookmark == BOOKMARK_NO) |
451 | return false; | 454 | return BOOKMARK_DONT_RESUME; |
452 | 455 | ||
453 | /*Checking to see if a bookmark file exists.*/ | 456 | /*Checking to see if a bookmark file exists.*/ |
454 | if(!generate_bookmark_file_name(file)) | 457 | if(!generate_bookmark_file_name(file)) |
455 | { | 458 | { |
456 | return false; | 459 | return BOOKMARK_DONT_RESUME; |
457 | } | 460 | } |
458 | 461 | ||
459 | if(!file_exists(global_bookmark_file_name)) | 462 | if(!file_exists(global_bookmark_file_name)) |
460 | return false; | 463 | return BOOKMARK_DONT_RESUME; |
461 | 464 | ||
462 | if(global_settings.autoloadbookmark == BOOKMARK_YES) | 465 | if(global_settings.autoloadbookmark == BOOKMARK_YES) |
463 | { | 466 | { |
464 | return bookmark_load(global_bookmark_file_name, true); | 467 | return bookmark_load(global_bookmark_file_name, true) ? BOOKMARK_DO_RESUME : |
468 | BOOKMARK_DONT_RESUME; | ||
465 | } | 469 | } |
466 | else | 470 | else |
467 | { | 471 | { |
@@ -478,10 +482,10 @@ bool bookmark_autoload(const char* file) | |||
478 | /* Act as if autoload was done even if it failed, since the | 482 | /* Act as if autoload was done even if it failed, since the |
479 | * user did make an active selection. | 483 | * user did make an active selection. |
480 | */ | 484 | */ |
481 | return true; | 485 | return BOOKMARK_DO_RESUME; |
482 | } | 486 | } |
483 | 487 | ||
484 | return ret != BOOKMARK_SUCCESS; | 488 | return ret != BOOKMARK_SUCCESS ? BOOKMARK_CANCEL : BOOKMARK_DONT_RESUME; |
485 | } | 489 | } |
486 | } | 490 | } |
487 | 491 | ||
diff --git a/apps/bookmark.h b/apps/bookmark.h index ff7b87c1bf..192e577ce6 100644 --- a/apps/bookmark.h +++ b/apps/bookmark.h | |||
@@ -29,11 +29,17 @@ enum { | |||
29 | BOOKMARK_USB_CONNECTED = 1 | 29 | BOOKMARK_USB_CONNECTED = 1 |
30 | }; | 30 | }; |
31 | 31 | ||
32 | enum { | ||
33 | BOOKMARK_CANCEL, | ||
34 | BOOKMARK_DONT_RESUME, | ||
35 | BOOKMARK_DO_RESUME | ||
36 | }; | ||
37 | |||
32 | int bookmark_load_menu(void); | 38 | int bookmark_load_menu(void); |
33 | bool bookmark_autobookmark(bool prompt_ok); | 39 | bool bookmark_autobookmark(bool prompt_ok); |
34 | bool bookmark_create_menu(void); | 40 | bool bookmark_create_menu(void); |
35 | bool bookmark_mrb_load(void); | 41 | bool bookmark_mrb_load(void); |
36 | bool bookmark_autoload(const char* file); | 42 | int bookmark_autoload(const char* file); |
37 | bool bookmark_load(const char* file, bool autoload); | 43 | bool bookmark_load(const char* file, bool autoload); |
38 | bool bookmark_exists(void); | 44 | bool bookmark_exists(void); |
39 | bool bookmark_is_bookmarkable_state(void); | 45 | bool bookmark_is_bookmarkable_state(void); |
diff --git a/apps/filetree.c b/apps/filetree.c index 06d92bc944..dbdcef6820 100644 --- a/apps/filetree.c +++ b/apps/filetree.c | |||
@@ -100,7 +100,8 @@ bool ft_play_playlist(char* pathname, char* dirname, | |||
100 | 100 | ||
101 | if (!skip_warn_and_bookmarks) | 101 | if (!skip_warn_and_bookmarks) |
102 | { | 102 | { |
103 | if (bookmark_autoload(pathname) || !warn_on_pl_erase()) | 103 | int res = bookmark_autoload(pathname); |
104 | if (res == BOOKMARK_CANCEL || res == BOOKMARK_DO_RESUME || !warn_on_pl_erase()) | ||
104 | return false; | 105 | return false; |
105 | } | 106 | } |
106 | 107 | ||
@@ -481,7 +482,9 @@ int ft_enter(struct tree_context* c) | |||
481 | break; | 482 | break; |
482 | 483 | ||
483 | case FILE_ATTR_AUDIO: | 484 | case FILE_ATTR_AUDIO: |
484 | if (bookmark_autoload(c->currdir)) | 485 | { |
486 | int res = bookmark_autoload(c->currdir); | ||
487 | if (res == BOOKMARK_CANCEL || res == BOOKMARK_DO_RESUME) | ||
485 | break; | 488 | break; |
486 | 489 | ||
487 | splash(0, ID2P(LANG_WAIT)); | 490 | splash(0, ID2P(LANG_WAIT)); |
@@ -515,7 +518,7 @@ int ft_enter(struct tree_context* c) | |||
515 | play = true; | 518 | play = true; |
516 | } | 519 | } |
517 | break; | 520 | break; |
518 | 521 | } | |
519 | #if CONFIG_TUNER | 522 | #if CONFIG_TUNER |
520 | /* fmr preset file */ | 523 | /* fmr preset file */ |
521 | case FILE_ATTR_FMR: | 524 | case FILE_ATTR_FMR: |
diff --git a/apps/onplay.c b/apps/onplay.c index 8507699bd3..0bb3b6ae3c 100644 --- a/apps/onplay.c +++ b/apps/onplay.c | |||
@@ -588,12 +588,11 @@ static int add_to_playlist(void* arg) | |||
588 | 588 | ||
589 | static bool view_playlist(void) | 589 | static bool view_playlist(void) |
590 | { | 590 | { |
591 | bool was_playing = audio_status() & AUDIO_STATUS_PLAY; | ||
592 | bool result; | 591 | bool result; |
593 | 592 | ||
594 | result = playlist_viewer_ex(selected_file); | 593 | result = playlist_viewer_ex(selected_file); |
595 | 594 | ||
596 | if (!was_playing && (audio_status() & AUDIO_STATUS_PLAY) && | 595 | if (result == PLAYLIST_VIEWER_OK && |
597 | onplay_result == ONPLAY_OK) | 596 | onplay_result == ONPLAY_OK) |
598 | /* playlist was started from viewer */ | 597 | /* playlist was started from viewer */ |
599 | onplay_result = ONPLAY_START_PLAY; | 598 | onplay_result = ONPLAY_START_PLAY; |
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c index 0813db11c6..65a48611c0 100644 --- a/apps/playlist_catalog.c +++ b/apps/playlist_catalog.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include "talk.h" | 46 | #include "talk.h" |
47 | #include "playlist_viewer.h" | 47 | #include "playlist_viewer.h" |
48 | #include "bookmark.h" | 48 | #include "bookmark.h" |
49 | #include "root_menu.h" | ||
49 | 50 | ||
50 | /* Use for recursive directory search */ | 51 | /* Use for recursive directory search */ |
51 | struct add_track_context { | 52 | struct add_track_context { |
@@ -160,7 +161,8 @@ static int display_playlists(char* playlist, bool view) | |||
160 | 161 | ||
161 | restart: | 162 | restart: |
162 | browse.flags &= ~BROWSE_SELECTED; | 163 | browse.flags &= ~BROWSE_SELECTED; |
163 | rockbox_browse(&browse); | 164 | if (rockbox_browse(&browse) == GO_TO_WPS) |
165 | result = 0; | ||
164 | 166 | ||
165 | if (browse.flags & BROWSE_SELECTED) | 167 | if (browse.flags & BROWSE_SELECTED) |
166 | { | 168 | { |
@@ -169,13 +171,24 @@ restart: | |||
169 | 171 | ||
170 | if (view) | 172 | if (view) |
171 | { | 173 | { |
172 | 174 | ||
173 | if (!bookmark_autoload(selected_playlist)) | 175 | int res = bookmark_autoload(selected_playlist); |
176 | if (res == BOOKMARK_DO_RESUME) | ||
177 | result = 0; | ||
178 | else | ||
174 | { | 179 | { |
175 | if (playlist_viewer_ex(selected_playlist) == PLAYLIST_VIEWER_CANCEL) | 180 | switch (playlist_viewer_ex(selected_playlist)) { |
176 | goto restart; | 181 | case PLAYLIST_VIEWER_OK: |
182 | result = 0; | ||
183 | break; | ||
184 | case PLAYLIST_VIEWER_CANCEL: | ||
185 | goto restart; | ||
186 | case PLAYLIST_VIEWER_USB: | ||
187 | case PLAYLIST_VIEWER_MAINMENU: | ||
188 | default: | ||
189 | break; | ||
190 | } | ||
177 | } | 191 | } |
178 | result = 0; | ||
179 | } | 192 | } |
180 | else | 193 | else |
181 | { | 194 | { |
diff --git a/apps/playlist_catalog.h b/apps/playlist_catalog.h index 2e317128b7..17efd0ea7e 100644 --- a/apps/playlist_catalog.h +++ b/apps/playlist_catalog.h | |||
@@ -29,7 +29,7 @@ void catalog_set_directory(const char* directory); | |||
29 | 29 | ||
30 | /* | 30 | /* |
31 | * View list of playlists in catalog. | 31 | * View list of playlists in catalog. |
32 | * ret : true if no error | 32 | * ret : true if item was selected |
33 | */ | 33 | */ |
34 | bool catalog_view_playlists(void); | 34 | bool catalog_view_playlists(void); |
35 | 35 | ||
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index 6c80b373a9..e3faf4b68f 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c | |||
@@ -820,7 +820,10 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename) | |||
820 | struct gui_synclist playlist_lists; | 820 | struct gui_synclist playlist_lists; |
821 | 821 | ||
822 | if (!open_playlist_viewer(filename, &playlist_lists, false)) | 822 | if (!open_playlist_viewer(filename, &playlist_lists, false)) |
823 | { | ||
824 | ret = PLAYLIST_VIEWER_CANCEL; | ||
823 | goto exit; | 825 | goto exit; |
826 | } | ||
824 | 827 | ||
825 | while (!exit) | 828 | while (!exit) |
826 | { | 829 | { |
@@ -958,10 +961,17 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename) | |||
958 | else if (pv_onplay_result == PV_ONPLAY_CLOSED) | 961 | else if (pv_onplay_result == PV_ONPLAY_CLOSED) |
959 | { | 962 | { |
960 | if (!open_playlist_viewer(filename, &playlist_lists, true)) | 963 | if (!open_playlist_viewer(filename, &playlist_lists, true)) |
964 | { | ||
965 | ret = PLAYLIST_VIEWER_CANCEL; | ||
961 | goto exit; | 966 | goto exit; |
967 | } | ||
962 | break; | 968 | break; |
963 | } | 969 | } |
964 | exit = update_viewer_with_changes(&playlist_lists, pv_onplay_result); | 970 | if (update_viewer_with_changes(&playlist_lists, pv_onplay_result)) |
971 | { | ||
972 | exit = true; | ||
973 | ret = PLAYLIST_VIEWER_CANCEL; | ||
974 | } | ||
965 | break; | 975 | break; |
966 | } | 976 | } |
967 | case ACTION_STD_MENU: | 977 | case ACTION_STD_MENU: |
@@ -996,7 +1006,10 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename) | |||
996 | if (do_plugin(current_track) == PV_ONPLAY_USB_CLOSED) | 1006 | if (do_plugin(current_track) == PV_ONPLAY_USB_CLOSED) |
997 | return PLAYLIST_VIEWER_USB; | 1007 | return PLAYLIST_VIEWER_USB; |
998 | else if (!open_playlist_viewer(filename, &playlist_lists, true)) | 1008 | else if (!open_playlist_viewer(filename, &playlist_lists, true)) |
1009 | { | ||
1010 | ret = PLAYLIST_VIEWER_CANCEL; | ||
999 | goto exit; | 1011 | goto exit; |
1012 | } | ||
1000 | } | 1013 | } |
1001 | else if (global_settings.hotkey_tree == HOTKEY_PROPERTIES) | 1014 | else if (global_settings.hotkey_tree == HOTKEY_PROPERTIES) |
1002 | { | 1015 | { |
@@ -1008,10 +1021,16 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename) | |||
1008 | update_lists(&playlist_lists); | 1021 | update_lists(&playlist_lists); |
1009 | } | 1022 | } |
1010 | else if (global_settings.hotkey_tree == HOTKEY_DELETE) | 1023 | else if (global_settings.hotkey_tree == HOTKEY_DELETE) |
1011 | exit = update_viewer_with_changes(&playlist_lists, | 1024 | { |
1025 | if (update_viewer_with_changes(&playlist_lists, | ||
1012 | delete_track(current_track->index, | 1026 | delete_track(current_track->index, |
1013 | viewer.selected_track, | 1027 | viewer.selected_track, |
1014 | (current_track->index == viewer.current_playing_track))); | 1028 | (current_track->index == viewer.current_playing_track)))) |
1029 | { | ||
1030 | ret = PLAYLIST_VIEWER_CANCEL; | ||
1031 | exit = true; | ||
1032 | } | ||
1033 | } | ||
1015 | else | 1034 | else |
1016 | onplay(current_track->name, FILE_ATTR_AUDIO, CONTEXT_STD, true); | 1035 | onplay(current_track->name, FILE_ATTR_AUDIO, CONTEXT_STD, true); |
1017 | break; | 1036 | break; |
diff --git a/apps/root_menu.c b/apps/root_menu.c index c70237fdf7..895d5a667b 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c | |||
@@ -366,13 +366,11 @@ static int miscscrn(void * param) | |||
366 | 366 | ||
367 | static int playlist_view_catalog(void * param) | 367 | static int playlist_view_catalog(void * param) |
368 | { | 368 | { |
369 | /* kludge untill catalog_view_playlists() returns something useful */ | ||
370 | int old_playstatus = audio_status(); | ||
371 | (void)param; | 369 | (void)param; |
372 | push_current_activity(ACTIVITY_PLAYLISTBROWSER); | 370 | push_current_activity(ACTIVITY_PLAYLISTBROWSER); |
373 | catalog_view_playlists(); | 371 | bool item_was_selected = catalog_view_playlists(); |
374 | pop_current_activity(); | 372 | pop_current_activity(); |
375 | if (!old_playstatus && audio_status()) | 373 | if (item_was_selected) |
376 | return GO_TO_WPS; | 374 | return GO_TO_WPS; |
377 | return GO_TO_PREVIOUS; | 375 | return GO_TO_PREVIOUS; |
378 | } | 376 | } |