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
This commit is contained in:
Christian Soffke 2021-04-11 01:32:53 +02:00
parent 3b1230b365
commit 3d34140cfb
8 changed files with 70 additions and 28 deletions

View file

@ -441,27 +441,31 @@ static char* create_bookmark()
/* ----------------------------------------------------------------------- */
/* This function will determine if an autoload is necessary. This is an */
/* interface function. */
/* Returns true on bookmark load or bookmark selection. */
/* Returns */
/* BOOKMARK_DO_RESUME on bookmark load or bookmark selection. */
/* BOOKMARK_DONT_RESUME if we're not going to resume */
/* BOOKMARK_CANCEL if user canceled */
/* ------------------------------------------------------------------------*/
bool bookmark_autoload(const char* file)
int bookmark_autoload(const char* file)
{
char* bookmark;
if(global_settings.autoloadbookmark == BOOKMARK_NO)
return false;
return BOOKMARK_DONT_RESUME;
/*Checking to see if a bookmark file exists.*/
if(!generate_bookmark_file_name(file))
{
return false;
return BOOKMARK_DONT_RESUME;
}
if(!file_exists(global_bookmark_file_name))
return false;
return BOOKMARK_DONT_RESUME;
if(global_settings.autoloadbookmark == BOOKMARK_YES)
{
return bookmark_load(global_bookmark_file_name, true);
return bookmark_load(global_bookmark_file_name, true) ? BOOKMARK_DO_RESUME :
BOOKMARK_DONT_RESUME;
}
else
{
@ -478,10 +482,10 @@ bool bookmark_autoload(const char* file)
/* Act as if autoload was done even if it failed, since the
* user did make an active selection.
*/
return true;
return BOOKMARK_DO_RESUME;
}
return ret != BOOKMARK_SUCCESS;
return ret != BOOKMARK_SUCCESS ? BOOKMARK_CANCEL : BOOKMARK_DONT_RESUME;
}
}

View file

@ -29,11 +29,17 @@ enum {
BOOKMARK_USB_CONNECTED = 1
};
enum {
BOOKMARK_CANCEL,
BOOKMARK_DONT_RESUME,
BOOKMARK_DO_RESUME
};
int bookmark_load_menu(void);
bool bookmark_autobookmark(bool prompt_ok);
bool bookmark_create_menu(void);
bool bookmark_mrb_load(void);
bool bookmark_autoload(const char* file);
int bookmark_autoload(const char* file);
bool bookmark_load(const char* file, bool autoload);
bool bookmark_exists(void);
bool bookmark_is_bookmarkable_state(void);

View file

@ -100,7 +100,8 @@ bool ft_play_playlist(char* pathname, char* dirname,
if (!skip_warn_and_bookmarks)
{
if (bookmark_autoload(pathname) || !warn_on_pl_erase())
int res = bookmark_autoload(pathname);
if (res == BOOKMARK_CANCEL || res == BOOKMARK_DO_RESUME || !warn_on_pl_erase())
return false;
}
@ -481,7 +482,9 @@ int ft_enter(struct tree_context* c)
break;
case FILE_ATTR_AUDIO:
if (bookmark_autoload(c->currdir))
{
int res = bookmark_autoload(c->currdir);
if (res == BOOKMARK_CANCEL || res == BOOKMARK_DO_RESUME)
break;
splash(0, ID2P(LANG_WAIT));
@ -515,7 +518,7 @@ int ft_enter(struct tree_context* c)
play = true;
}
break;
}
#if CONFIG_TUNER
/* fmr preset file */
case FILE_ATTR_FMR:

View file

@ -588,12 +588,11 @@ static int add_to_playlist(void* arg)
static bool view_playlist(void)
{
bool was_playing = audio_status() & AUDIO_STATUS_PLAY;
bool result;
result = playlist_viewer_ex(selected_file);
if (!was_playing && (audio_status() & AUDIO_STATUS_PLAY) &&
if (result == PLAYLIST_VIEWER_OK &&
onplay_result == ONPLAY_OK)
/* playlist was started from viewer */
onplay_result = ONPLAY_START_PLAY;

View file

@ -46,6 +46,7 @@
#include "talk.h"
#include "playlist_viewer.h"
#include "bookmark.h"
#include "root_menu.h"
/* Use for recursive directory search */
struct add_track_context {
@ -160,7 +161,8 @@ static int display_playlists(char* playlist, bool view)
restart:
browse.flags &= ~BROWSE_SELECTED;
rockbox_browse(&browse);
if (rockbox_browse(&browse) == GO_TO_WPS)
result = 0;
if (browse.flags & BROWSE_SELECTED)
{
@ -169,13 +171,24 @@ restart:
if (view)
{
if (!bookmark_autoload(selected_playlist))
int res = bookmark_autoload(selected_playlist);
if (res == BOOKMARK_DO_RESUME)
result = 0;
else
{
if (playlist_viewer_ex(selected_playlist) == PLAYLIST_VIEWER_CANCEL)
goto restart;
switch (playlist_viewer_ex(selected_playlist)) {
case PLAYLIST_VIEWER_OK:
result = 0;
break;
case PLAYLIST_VIEWER_CANCEL:
goto restart;
case PLAYLIST_VIEWER_USB:
case PLAYLIST_VIEWER_MAINMENU:
default:
break;
}
}
result = 0;
}
else
{

View file

@ -29,7 +29,7 @@ void catalog_set_directory(const char* directory);
/*
* View list of playlists in catalog.
* ret : true if no error
* ret : true if item was selected
*/
bool catalog_view_playlists(void);

View file

@ -820,7 +820,10 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename)
struct gui_synclist playlist_lists;
if (!open_playlist_viewer(filename, &playlist_lists, false))
{
ret = PLAYLIST_VIEWER_CANCEL;
goto exit;
}
while (!exit)
{
@ -958,10 +961,17 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename)
else if (pv_onplay_result == PV_ONPLAY_CLOSED)
{
if (!open_playlist_viewer(filename, &playlist_lists, true))
{
ret = PLAYLIST_VIEWER_CANCEL;
goto exit;
}
break;
}
exit = update_viewer_with_changes(&playlist_lists, pv_onplay_result);
if (update_viewer_with_changes(&playlist_lists, pv_onplay_result))
{
exit = true;
ret = PLAYLIST_VIEWER_CANCEL;
}
break;
}
case ACTION_STD_MENU:
@ -996,7 +1006,10 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename)
if (do_plugin(current_track) == PV_ONPLAY_USB_CLOSED)
return PLAYLIST_VIEWER_USB;
else if (!open_playlist_viewer(filename, &playlist_lists, true))
{
ret = PLAYLIST_VIEWER_CANCEL;
goto exit;
}
}
else if (global_settings.hotkey_tree == HOTKEY_PROPERTIES)
{
@ -1008,10 +1021,16 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename)
update_lists(&playlist_lists);
}
else if (global_settings.hotkey_tree == HOTKEY_DELETE)
exit = update_viewer_with_changes(&playlist_lists,
{
if (update_viewer_with_changes(&playlist_lists,
delete_track(current_track->index,
viewer.selected_track,
(current_track->index == viewer.current_playing_track)));
(current_track->index == viewer.current_playing_track))))
{
ret = PLAYLIST_VIEWER_CANCEL;
exit = true;
}
}
else
onplay(current_track->name, FILE_ATTR_AUDIO, CONTEXT_STD, true);
break;

View file

@ -366,13 +366,11 @@ static int miscscrn(void * param)
static int playlist_view_catalog(void * param)
{
/* kludge untill catalog_view_playlists() returns something useful */
int old_playstatus = audio_status();
(void)param;
push_current_activity(ACTIVITY_PLAYLISTBROWSER);
catalog_view_playlists();
bool item_was_selected = catalog_view_playlists();
pop_current_activity();
if (!old_playstatus && audio_status())
if (item_was_selected)
return GO_TO_WPS;
return GO_TO_PREVIOUS;
}