diff options
author | Christian Soffke <christian.soffke@gmail.com> | 2022-11-22 20:39:35 +0100 |
---|---|---|
committer | Christian Soffke <christian.soffke@gmail.com> | 2022-11-26 17:20:06 +0100 |
commit | 4ecf3970a6b71923d7b3fe51f72960cdda594fa4 (patch) | |
tree | 0c9439baa08b717394bfc88b920d18cb6ca13717 | |
parent | 098a8fd334df342b7e0af94e465997177e74b78b (diff) | |
download | rockbox-4ecf3970a6.tar.gz rockbox-4ecf3970a6.zip |
Playlist Catalogue: Return to opened playlists
The playlist catalogue now remembers when you left
a playlist open and will return to it automatically.
Change-Id: I5b725a776b0a524139588c86e38150e5e25cb7d7
-rw-r--r-- | apps/playlist_catalog.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c index a20600b268..619293377c 100644 --- a/apps/playlist_catalog.c +++ b/apps/playlist_catalog.c @@ -147,6 +147,7 @@ const char* catalog_get_directory(void) If "view" mode is set then we're not adding anything into playlist. */ static int display_playlists(char* playlist, bool view) { + static bool reopen_last_playlist = false; static int most_recent_selection = 0; struct browse_context browse; char selected_playlist[MAX_PATH]; @@ -162,21 +163,42 @@ static int display_playlists(char* playlist, bool view) restart: browse.flags &= ~BROWSE_SELECTED; - int browse_ret = rockbox_browse(&browse); - if (browse_ret == GO_TO_WPS - || (view && browse_ret == GO_TO_PREVIOUS_MUSIC)) - result = 0; - if (browse.flags & BROWSE_SELECTED) + if (view && reopen_last_playlist) + { + switch (playlist_viewer_ex(most_recent_playlist, &most_recent_selection)) + { + case PLAYLIST_VIEWER_OK: + result = 0; + break; + case PLAYLIST_VIEWER_CANCEL: + reopen_last_playlist = false; + goto restart; + case PLAYLIST_VIEWER_USB: + case PLAYLIST_VIEWER_MAINMENU: + default: + break; + } + } + else /* browse playlist dir */ + { + int browse_ret = rockbox_browse(&browse); + if (browse_ret == GO_TO_WPS + || (view && browse_ret == GO_TO_PREVIOUS_MUSIC)) + result = 0; + } + + if (browse.flags & BROWSE_SELECTED) /* User picked a playlist */ { if (strcmp(most_recent_playlist, selected_playlist)) /* isn't most recent one */ { strmemccpy(most_recent_playlist, selected_playlist, sizeof(most_recent_playlist)); most_recent_selection = 0; + reopen_last_playlist = false; } - if (view) + if (view) /* display playlist contents or resume bookmark */ { int res = bookmark_autoload(selected_playlist); @@ -186,6 +208,7 @@ restart: { switch (playlist_viewer_ex(selected_playlist, &most_recent_selection)) { case PLAYLIST_VIEWER_OK: + reopen_last_playlist = true; result = 0; break; case PLAYLIST_VIEWER_CANCEL: @@ -193,11 +216,12 @@ restart: case PLAYLIST_VIEWER_USB: case PLAYLIST_VIEWER_MAINMENU: default: + reopen_last_playlist = true; break; } } } - else + else /* we're just adding something to a playlist */ { result = 0; strmemccpy(playlist, selected_playlist, MAX_PATH); @@ -212,7 +236,7 @@ restart: static void display_insert_count(int count) { static long talked_tick = 0; - if(global_settings.talk_menu && count && + if(global_settings.talk_menu && count && (talked_tick == 0 || TIME_AFTER(current_tick, talked_tick+5*HZ))) { talked_tick = current_tick; |