forked from len0rd/rockbox
Improved voice feedback in bookmark selection.
Accept FS#6240 (with minor changes). Speak directory or playlist name in recent bookmarks. Speak shuffle status, and filename. Simplify the button loop by using a voice list callback. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18051 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
91bfc4ca95
commit
bd06769ba2
1 changed files with 70 additions and 42 deletions
108
apps/bookmark.c
108
apps/bookmark.c
|
|
@ -68,7 +68,7 @@ static bool check_bookmark(const char* bookmark);
|
||||||
static char* create_bookmark(void);
|
static char* create_bookmark(void);
|
||||||
static bool delete_bookmark(const char* bookmark_file_name, int bookmark_id);
|
static bool delete_bookmark(const char* bookmark_file_name, int bookmark_id);
|
||||||
static void say_bookmark(const char* bookmark,
|
static void say_bookmark(const char* bookmark,
|
||||||
int bookmark_id);
|
int bookmark_id, bool show_playlist_name);
|
||||||
static bool play_bookmark(const char* bookmark);
|
static bool play_bookmark(const char* bookmark);
|
||||||
static bool generate_bookmark_file_name(const char *in);
|
static bool generate_bookmark_file_name(const char *in);
|
||||||
static const char* skip_token(const char* s);
|
static const char* skip_token(const char* s);
|
||||||
|
|
@ -634,6 +634,22 @@ static char* get_bookmark_info(int list_index,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int bookmark_list_voice_cb(int list_index, void* data)
|
||||||
|
{
|
||||||
|
struct bookmark_list* bookmarks = (struct bookmark_list*) data;
|
||||||
|
int index = list_index / 2;
|
||||||
|
|
||||||
|
if (bookmarks->show_dont_resume)
|
||||||
|
{
|
||||||
|
if (index == 0)
|
||||||
|
return talk_id(LANG_BOOKMARK_DONT_RESUME, false);
|
||||||
|
index--;
|
||||||
|
}
|
||||||
|
say_bookmark(bookmarks->items[index - bookmarks->start], index,
|
||||||
|
bookmarks->show_playlist_name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* This displays a the bookmarks in a file and allows the user to */
|
/* This displays a the bookmarks in a file and allows the user to */
|
||||||
/* select one to play. */
|
/* select one to play. */
|
||||||
|
|
@ -642,7 +658,6 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu
|
||||||
{
|
{
|
||||||
struct bookmark_list* bookmarks;
|
struct bookmark_list* bookmarks;
|
||||||
struct gui_synclist list;
|
struct gui_synclist list;
|
||||||
int last_item = -2;
|
|
||||||
int item = 0;
|
int item = 0;
|
||||||
int action;
|
int action;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
@ -657,6 +672,8 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu
|
||||||
bookmarks->show_playlist_name
|
bookmarks->show_playlist_name
|
||||||
= strcmp(bookmark_file_name, RECENT_BOOKMARK_FILE) == 0;
|
= strcmp(bookmark_file_name, RECENT_BOOKMARK_FILE) == 0;
|
||||||
gui_synclist_init(&list, &get_bookmark_info, (void*) bookmarks, false, 2, NULL);
|
gui_synclist_init(&list, &get_bookmark_info, (void*) bookmarks, false, 2, NULL);
|
||||||
|
if(global_settings.talk_menu)
|
||||||
|
gui_synclist_set_voice_callback(&list, bookmark_list_voice_cb);
|
||||||
gui_synclist_set_title(&list, str(LANG_BOOKMARK_SELECT_BOOKMARK),
|
gui_synclist_set_title(&list, str(LANG_BOOKMARK_SELECT_BOOKMARK),
|
||||||
Icon_Bookmark);
|
Icon_Bookmark);
|
||||||
gui_syncstatusbar_draw(&statusbars, true);
|
gui_syncstatusbar_draw(&statusbars, true);
|
||||||
|
|
@ -695,11 +712,13 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu
|
||||||
|
|
||||||
buffer_bookmarks(bookmarks, bookmarks->start);
|
buffer_bookmarks(bookmarks, bookmarks->start);
|
||||||
gui_synclist_draw(&list);
|
gui_synclist_draw(&list);
|
||||||
|
cond_talk_ids_fq(VOICE_EXT_BMARK);
|
||||||
|
gui_synclist_speak_item(&list);
|
||||||
refresh = false;
|
refresh = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
action = get_action(CONTEXT_BOOKMARKSCREEN, HZ / 2);
|
list_do_action(CONTEXT_BOOKMARKSCREEN, HZ / 2,
|
||||||
gui_synclist_do_button(&list, &action, LIST_WRAP_UNLESS_HELD);
|
&list, &action, LIST_WRAP_UNLESS_HELD);
|
||||||
item = gui_synclist_get_sel_pos(&list) / 2;
|
item = gui_synclist_get_sel_pos(&list) / 2;
|
||||||
|
|
||||||
if (bookmarks->show_dont_resume)
|
if (bookmarks->show_dont_resume)
|
||||||
|
|
@ -707,20 +726,6 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu
|
||||||
item--;
|
item--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item != last_item && global_settings.talk_menu)
|
|
||||||
{
|
|
||||||
last_item = item;
|
|
||||||
|
|
||||||
if (item == -1)
|
|
||||||
{
|
|
||||||
talk_id(LANG_BOOKMARK_DONT_RESUME, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
say_bookmark(bookmarks->items[item - bookmarks->start], item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (action == ACTION_STD_CONTEXT)
|
if (action == ACTION_STD_CONTEXT)
|
||||||
{
|
{
|
||||||
MENUITEM_STRINGLIST(menu_items, ID2P(LANG_BOOKMARK_CONTEXT_MENU),
|
MENUITEM_STRINGLIST(menu_items, ID2P(LANG_BOOKMARK_CONTEXT_MENU),
|
||||||
|
|
@ -746,6 +751,7 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu
|
||||||
case ACTION_STD_OK:
|
case ACTION_STD_OK:
|
||||||
if (item >= 0)
|
if (item >= 0)
|
||||||
{
|
{
|
||||||
|
talk_shutup();
|
||||||
return bookmarks->items[item - bookmarks->start];
|
return bookmarks->items[item - bookmarks->start];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -762,7 +768,6 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu
|
||||||
delete_bookmark(bookmark_file_name, item);
|
delete_bookmark(bookmark_file_name, item);
|
||||||
bookmarks->reload = true;
|
bookmarks->reload = true;
|
||||||
refresh = true;
|
refresh = true;
|
||||||
last_item = -2;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -776,6 +781,7 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
talk_shutup();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -827,41 +833,63 @@ static bool delete_bookmark(const char* bookmark_file_name, int bookmark_id)
|
||||||
/* This function parses a bookmark, says the voice UI part of it. */
|
/* This function parses a bookmark, says the voice UI part of it. */
|
||||||
/* ------------------------------------------------------------------------*/
|
/* ------------------------------------------------------------------------*/
|
||||||
static void say_bookmark(const char* bookmark,
|
static void say_bookmark(const char* bookmark,
|
||||||
int bookmark_id)
|
int bookmark_id, bool show_playlist_name)
|
||||||
{
|
{
|
||||||
int resume_index;
|
int resume_index;
|
||||||
long ms;
|
long ms;
|
||||||
bool enqueue = false; /* only the first voice is not queued */
|
bool playlist_shuffle = false;
|
||||||
|
bool is_dir;
|
||||||
|
|
||||||
if (!parse_bookmark(bookmark, &resume_index, NULL, NULL, NULL,
|
if (!parse_bookmark(bookmark, &resume_index, NULL, NULL, NULL,
|
||||||
global_temp_buffer, sizeof(global_temp_buffer), &ms, NULL, NULL, NULL))
|
global_temp_buffer,sizeof(global_temp_buffer),
|
||||||
|
&ms, NULL, &playlist_shuffle,
|
||||||
|
global_filename))
|
||||||
{
|
{
|
||||||
talk_id(LANG_BOOKMARK_INVALID, true);
|
talk_id(LANG_BOOKMARK_INVALID, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* disabled, because transition between talkbox and voice UI clip is not nice */
|
talk_number(bookmark_id + 1, false);
|
||||||
#if 0
|
|
||||||
if (global_settings.talk_dir >= 3)
|
is_dir = (global_temp_buffer[0]
|
||||||
{ /* "talkbox" enabled */
|
&& global_temp_buffer[strlen(global_temp_buffer)-1] == '/');
|
||||||
char* last = strrchr(global_temp_buffer, '/');
|
#if CONFIG_CODEC == SWCODEC
|
||||||
if (last)
|
/* HWCODEC cannot enqueue voice file entries and .talk thumbnails
|
||||||
{ /* compose filename for talkbox */
|
together, because there is no guarantee that the same mp3
|
||||||
strncpy(last + 1, dir_thumbnail_name,
|
parameters are used. */
|
||||||
sizeof(global_temp_buffer) - (last - global_temp_buffer) - 1);
|
if(show_playlist_name)
|
||||||
talk_file(global_temp_buffer, enqueue);
|
{ /* It's useful to know which playlist this is */
|
||||||
enqueue = true;
|
if(is_dir)
|
||||||
}
|
talk_dir_or_spell(global_temp_buffer,
|
||||||
|
TALK_IDARRAY(VOICE_DIR), true);
|
||||||
|
else talk_file_or_spell(NULL, global_temp_buffer,
|
||||||
|
TALK_IDARRAY(LANG_PLAYLIST), true);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
(void)show_playlist_name;
|
||||||
#endif
|
#endif
|
||||||
talk_id(VOICE_EXT_BMARK, enqueue);
|
|
||||||
talk_number(bookmark_id + 1, true);
|
if(playlist_shuffle)
|
||||||
|
talk_id(LANG_SHUFFLE, true);
|
||||||
|
|
||||||
talk_id(VOICE_BOOKMARK_SELECT_INDEX_TEXT, true);
|
talk_id(VOICE_BOOKMARK_SELECT_INDEX_TEXT, true);
|
||||||
talk_number(resume_index + 1, true);
|
talk_number(resume_index + 1, true);
|
||||||
talk_id(LANG_TIME, true);
|
talk_id(LANG_TIME, true);
|
||||||
if (ms / 60000)
|
talk_value(ms / 1000, UNIT_TIME, true);
|
||||||
talk_value(ms / 60000, UNIT_MIN, true);
|
|
||||||
talk_value((ms % 60000) / 1000, UNIT_SEC, true);
|
#if CONFIG_CODEC == SWCODEC
|
||||||
|
/* Track filename */
|
||||||
|
if(is_dir)
|
||||||
|
talk_file_or_spell(global_temp_buffer, global_filename,
|
||||||
|
TALK_IDARRAY(VOICE_FILE), true);
|
||||||
|
else
|
||||||
|
{ /* Unfortunately if this is a playlist, we do not know in which
|
||||||
|
directory the file is and therefore cannot find the track's
|
||||||
|
.talk file. */
|
||||||
|
talk_id(VOICE_FILE, true);
|
||||||
|
talk_spell(global_filename, true);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue