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-4ecf3970a6b71923d7b3fe51f72960cdda594fa4.tar.gz rockbox-4ecf3970a6b71923d7b3fe51f72960cdda594fa4.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) | |||
147 | If "view" mode is set then we're not adding anything into playlist. */ | 147 | If "view" mode is set then we're not adding anything into playlist. */ |
148 | static int display_playlists(char* playlist, bool view) | 148 | static int display_playlists(char* playlist, bool view) |
149 | { | 149 | { |
150 | static bool reopen_last_playlist = false; | ||
150 | static int most_recent_selection = 0; | 151 | static int most_recent_selection = 0; |
151 | struct browse_context browse; | 152 | struct browse_context browse; |
152 | char selected_playlist[MAX_PATH]; | 153 | char selected_playlist[MAX_PATH]; |
@@ -162,21 +163,42 @@ static int display_playlists(char* playlist, bool view) | |||
162 | 163 | ||
163 | restart: | 164 | restart: |
164 | browse.flags &= ~BROWSE_SELECTED; | 165 | browse.flags &= ~BROWSE_SELECTED; |
165 | int browse_ret = rockbox_browse(&browse); | ||
166 | if (browse_ret == GO_TO_WPS | ||
167 | || (view && browse_ret == GO_TO_PREVIOUS_MUSIC)) | ||
168 | result = 0; | ||
169 | 166 | ||
170 | if (browse.flags & BROWSE_SELECTED) | 167 | if (view && reopen_last_playlist) |
168 | { | ||
169 | switch (playlist_viewer_ex(most_recent_playlist, &most_recent_selection)) | ||
170 | { | ||
171 | case PLAYLIST_VIEWER_OK: | ||
172 | result = 0; | ||
173 | break; | ||
174 | case PLAYLIST_VIEWER_CANCEL: | ||
175 | reopen_last_playlist = false; | ||
176 | goto restart; | ||
177 | case PLAYLIST_VIEWER_USB: | ||
178 | case PLAYLIST_VIEWER_MAINMENU: | ||
179 | default: | ||
180 | break; | ||
181 | } | ||
182 | } | ||
183 | else /* browse playlist dir */ | ||
184 | { | ||
185 | int browse_ret = rockbox_browse(&browse); | ||
186 | if (browse_ret == GO_TO_WPS | ||
187 | || (view && browse_ret == GO_TO_PREVIOUS_MUSIC)) | ||
188 | result = 0; | ||
189 | } | ||
190 | |||
191 | if (browse.flags & BROWSE_SELECTED) /* User picked a playlist */ | ||
171 | { | 192 | { |
172 | if (strcmp(most_recent_playlist, selected_playlist)) /* isn't most recent one */ | 193 | if (strcmp(most_recent_playlist, selected_playlist)) /* isn't most recent one */ |
173 | { | 194 | { |
174 | strmemccpy(most_recent_playlist, selected_playlist, | 195 | strmemccpy(most_recent_playlist, selected_playlist, |
175 | sizeof(most_recent_playlist)); | 196 | sizeof(most_recent_playlist)); |
176 | most_recent_selection = 0; | 197 | most_recent_selection = 0; |
198 | reopen_last_playlist = false; | ||
177 | } | 199 | } |
178 | 200 | ||
179 | if (view) | 201 | if (view) /* display playlist contents or resume bookmark */ |
180 | { | 202 | { |
181 | 203 | ||
182 | int res = bookmark_autoload(selected_playlist); | 204 | int res = bookmark_autoload(selected_playlist); |
@@ -186,6 +208,7 @@ restart: | |||
186 | { | 208 | { |
187 | switch (playlist_viewer_ex(selected_playlist, &most_recent_selection)) { | 209 | switch (playlist_viewer_ex(selected_playlist, &most_recent_selection)) { |
188 | case PLAYLIST_VIEWER_OK: | 210 | case PLAYLIST_VIEWER_OK: |
211 | reopen_last_playlist = true; | ||
189 | result = 0; | 212 | result = 0; |
190 | break; | 213 | break; |
191 | case PLAYLIST_VIEWER_CANCEL: | 214 | case PLAYLIST_VIEWER_CANCEL: |
@@ -193,11 +216,12 @@ restart: | |||
193 | case PLAYLIST_VIEWER_USB: | 216 | case PLAYLIST_VIEWER_USB: |
194 | case PLAYLIST_VIEWER_MAINMENU: | 217 | case PLAYLIST_VIEWER_MAINMENU: |
195 | default: | 218 | default: |
219 | reopen_last_playlist = true; | ||
196 | break; | 220 | break; |
197 | } | 221 | } |
198 | } | 222 | } |
199 | } | 223 | } |
200 | else | 224 | else /* we're just adding something to a playlist */ |
201 | { | 225 | { |
202 | result = 0; | 226 | result = 0; |
203 | strmemccpy(playlist, selected_playlist, MAX_PATH); | 227 | strmemccpy(playlist, selected_playlist, MAX_PATH); |
@@ -212,7 +236,7 @@ restart: | |||
212 | static void display_insert_count(int count) | 236 | static void display_insert_count(int count) |
213 | { | 237 | { |
214 | static long talked_tick = 0; | 238 | static long talked_tick = 0; |
215 | if(global_settings.talk_menu && count && | 239 | if(global_settings.talk_menu && count && |
216 | (talked_tick == 0 || TIME_AFTER(current_tick, talked_tick+5*HZ))) | 240 | (talked_tick == 0 || TIME_AFTER(current_tick, talked_tick+5*HZ))) |
217 | { | 241 | { |
218 | talked_tick = current_tick; | 242 | talked_tick = current_tick; |