Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

PictureFlow: Fix some annoyances

- Skip superfluous "Wait" splash before displaying
index progress

- Display current step that the progress bar pertains to

- Exiting the "Confirm Quit" screen in order to continue
indexing was *extremely* fiddly because of picked-up
button events that would often immediately return you
to the same screen instead of getting you out of it.
This should behave more sanely now. Plus, you should
only see the Quit confirmation screen as a result of
pressing Menu or Cancel now (instead of touching the
scroll wheel for example).

- PictureFlow was unresponsive while removing duplicates

- A Cancel action initiated by the user isn't treated
as an error anymore, nor is a message displayed after
user has already confirmed their intention to quit.

- The plugin doesn't return errors anymore if the user
has already been presented with an error message, to
eliminate redundant splashes, delays, and an unwanted
return to the main menu

Change-Id: I255b8f760ccb0acdfddcacbc7d8a1b17b063e53e

authored by

Christian Soffke and committed by
Solomon Peachy
dec8d410 7693ecc2

+56 -84
+56 -84
apps/plugins/pictureflow/pictureflow.c
··· 662 662 return true; 663 663 } 664 664 665 - static bool confirm_quit(void) 665 + static bool progress_cancel(int step, int count, char *msg) 666 666 { 667 - const struct text_message prompt = 668 - { (const char*[]) {"Quit?", "Progress will be lost"}, 2}; 669 - enum yesno_res response = rb->gui_syncyesno_run(&prompt, NULL, NULL); 670 - while (rb->button_get(false) == BUTTON_NONE) 671 - {;;} 667 + const struct text_message prompt = { 668 + (const char*[]) {"Quit?", "Progress will be lost"}, 2}; 672 669 673 - if(response == YESNO_NO) 674 - return false; 670 + int action = rb->get_action(CONTEXT_STD,TIMEOUT_NOBLOCK); 671 + if (action == ACTION_STD_CANCEL || action == ACTION_STD_MENU) 672 + { 673 + if (rb->gui_syncyesno_run(&prompt, NULL, NULL) == YESNO_YES) 674 + return true; 675 + rb->lcd_clear_display(); 676 + } 675 677 else 676 - return true; 678 + msg = NULL; 679 + 680 + if (count) 681 + draw_progressbar(step, count, msg); 682 + 683 + return false; 677 684 } 678 685 679 686 static void config_save(int cache_version, bool update_albumart) ··· 1160 1167 1161 1168 while (rb->tagcache_get_next(tcs, tcs_buf, tcs_bufsz)) 1162 1169 { 1163 - if (rb->button_get(false) > BUTTON_NONE) 1170 + if (progress_cancel(0, 0, NULL)) 1164 1171 { 1165 - if (confirm_quit()) 1166 - { 1167 - ret = ERROR_USER_ABORT; 1168 - break; 1169 - } else 1170 - rb->lcd_clear_display(); 1172 + ret = ERROR_USER_ABORT; 1173 + break; 1171 1174 } 1172 1175 1173 1176 *bufsz -= data_size; ··· 1194 1197 return ret; 1195 1198 } 1196 1199 1200 + #define STR_STEP_INDEXING_UNTAGGED "1/5 Find " UNTAGGED 1201 + #define STR_STEP_ASSIGNING_ALBUMS "2/5 Find Albums" 1202 + #define STR_STEP_ASSIGNING_ALBUM_YEAR "3/5 Check Album Year" 1203 + #define STR_STEP_REMOVING_DUPLICATES "4/5 Remove Duplicates" 1204 + #define STR_STEP_PREPARING_ARTWORK "5/5 Prepare Artwork" 1205 + 1197 1206 /*adds <untagged> albums/artist to existing album index */ 1198 1207 static int create_album_untagged(struct tagcache_search *tcs, 1199 1208 void **buf, size_t *bufsz) ··· 1207 1216 int last, final, retry; 1208 1217 int i, j; 1209 1218 draw_splashscreen(*buf, *bufsz); 1210 - draw_progressbar(0, total_count, "Searching " UNTAGGED); 1219 + draw_progressbar(0, total_count, STR_STEP_INDEXING_UNTAGGED); 1211 1220 1212 1221 /* search tagcache for all <untagged> albums & save the albumartist seek pos */ 1213 1222 if (rb->tagcache_search(tcs, tag_albumartist)) ··· 1216 1225 1217 1226 while (rb->tagcache_get_next(tcs, tcs_buf, tcs_bufsz)) 1218 1227 { 1219 - if (rb->button_get(false) > BUTTON_NONE) { 1220 - if (confirm_quit()) 1221 - { 1222 - rb->tagcache_search_finish(tcs); 1223 - return ERROR_USER_ABORT; 1224 - } 1225 - else 1226 - { 1227 - rb->lcd_clear_display(); 1228 - draw_progressbar(pf_idx.album_ct, total_count, 1229 - "Searching " UNTAGGED); 1230 - } 1228 + if (progress_cancel(pf_idx.album_ct, total_count, STR_STEP_INDEXING_UNTAGGED)) 1229 + { 1230 + rb->tagcache_search_finish(tcs); 1231 + return ERROR_USER_ABORT; 1231 1232 } 1232 1233 1233 1234 if (tcs->result_seek == ··· 1246 1247 pf_idx.album_untagged_seek, -1, tcs->result_seek); 1247 1248 1248 1249 pf_idx.album_ct++; 1249 - draw_progressbar(pf_idx.album_ct, total_count, NULL); 1250 1250 } 1251 1251 rb->tagcache_search_finish(tcs); 1252 1252 1253 1253 if (ret == SUCCESS) { 1254 1254 draw_splashscreen(*buf, *bufsz); 1255 - draw_progressbar(0, pf_idx.album_ct, "Finalizing " UNTAGGED); 1255 + draw_progressbar(0, pf_idx.album_ct, STR_STEP_INDEXING_UNTAGGED); 1256 1256 1257 1257 last = 0; 1258 1258 final = pf_idx.artist_ct; ··· 1261 1261 /* map the artist_seek position to the artist name index */ 1262 1262 for (j = album_count; j < pf_idx.album_ct; j++) 1263 1263 { 1264 - if (rb->button_get(false) > BUTTON_NONE) { 1265 - if (confirm_quit()) 1266 - return ERROR_USER_ABORT; 1267 - else 1268 - { 1269 - rb->lcd_clear_display(); 1270 - draw_progressbar(j, pf_idx.album_ct, "Finalizing " UNTAGGED); 1271 - } 1272 - } 1264 + if (progress_cancel(j, pf_idx.album_ct, STR_STEP_INDEXING_UNTAGGED)) 1265 + return ERROR_USER_ABORT; 1273 1266 1274 - draw_progressbar(j, pf_idx.album_ct, NULL); 1275 1267 seek = pf_idx.album_index[-j].artist_seek; 1276 1268 1277 1269 retry_artist_lookup: ··· 1343 1335 return res; 1344 1336 } 1345 1337 1346 - 1347 1338 static int assign_album_year(void) 1348 1339 { 1349 1340 char tcs_buf[TAGCACHE_BUFSZ]; 1350 1341 const long tcs_bufsz = sizeof(tcs_buf); 1351 - draw_progressbar(0, pf_idx.album_ct, "Assigning Album Year"); 1342 + draw_progressbar(0, pf_idx.album_ct, STR_STEP_ASSIGNING_ALBUM_YEAR); 1352 1343 for (int album_idx = 0; album_idx < pf_idx.album_ct; album_idx++) 1353 1344 { 1354 1345 /* Prevent idle poweroff */ 1355 1346 rb->reset_poweroff_timer(); 1356 1347 1357 - if (rb->button_get(false) > BUTTON_NONE) 1358 - { 1359 - if (confirm_quit()) 1360 - return ERROR_USER_ABORT; 1361 - else 1362 - { 1363 - rb->lcd_clear_display(); 1364 - draw_progressbar(album_idx, pf_idx.album_ct, "Assigning Album Year"); 1365 - } 1366 - } 1367 - draw_progressbar(album_idx, pf_idx.album_ct, NULL); 1348 + if (progress_cancel(album_idx, pf_idx.album_ct, STR_STEP_ASSIGNING_ALBUM_YEAR)) 1349 + return ERROR_USER_ABORT; 1350 + 1368 1351 int album_year = 0; 1369 1352 1370 1353 if (rb->tagcache_search(&tcs, tag_year)) ··· 1447 1430 1448 1431 /* Assign indices */ 1449 1432 draw_splashscreen(buf, buf_size); 1450 - draw_progressbar(0, pf_idx.album_ct, "Assigning Albums"); 1433 + draw_progressbar(0, pf_idx.album_ct, STR_STEP_ASSIGNING_ALBUMS); 1451 1434 for (j = 0; j < pf_idx.album_ct; j++) 1452 1435 { 1453 1436 /* Prevent idle poweroff */ 1454 1437 rb->reset_poweroff_timer(); 1455 1438 1456 - if (rb->button_get(false) > BUTTON_NONE) 1457 - { 1458 - if (confirm_quit()) 1459 - return ERROR_USER_ABORT; 1460 - else 1461 - { 1462 - rb->lcd_clear_display(); 1463 - draw_progressbar(j, pf_idx.album_ct, "Assigning Albums"); 1464 - } 1439 + if (progress_cancel(j, pf_idx.album_ct, STR_STEP_ASSIGNING_ALBUMS)) 1440 + return ERROR_USER_ABORT; 1465 1441 1466 - } 1467 - 1468 - draw_progressbar(j, pf_idx.album_ct, NULL); 1469 1442 if (pf_idx.album_index[j].artist_seek >= 0) { continue; } 1470 1443 1471 1444 rb->tagcache_search(&tcs, tag_albumartist); ··· 1515 1488 sizeof(struct album_data), compare_album_artists); 1516 1489 1517 1490 draw_splashscreen(buf, buf_size); 1518 - draw_progressbar(0, pf_idx.album_ct, "Removing duplicates"); 1491 + draw_progressbar(0, pf_idx.album_ct, STR_STEP_REMOVING_DUPLICATES); 1519 1492 /* mark duplicate albums for deletion */ 1520 1493 for (i = 0; i < pf_idx.album_ct - 1; i++) /* -1 don't check last entry */ 1521 1494 { 1522 1495 /* Prevent idle poweroff */ 1523 1496 rb->reset_poweroff_timer(); 1524 1497 1498 + if (progress_cancel(i, pf_idx.album_ct, STR_STEP_REMOVING_DUPLICATES)) 1499 + return ERROR_USER_ABORT; 1500 + 1525 1501 int idxi = pf_idx.album_index[i].artist_idx; 1526 1502 int seeki = pf_idx.album_index[i].seek; 1527 1503 1528 - draw_progressbar(i, pf_idx.album_ct, NULL); 1529 1504 for (j = i + 1; j < pf_idx.album_ct; j++) 1530 1505 { 1531 1506 if (idxi > 0 && ··· 2343 2318 static bool create_albumart_cache(void) 2344 2319 { 2345 2320 draw_splashscreen(pf_idx.buf, pf_idx.buf_sz); 2346 - draw_progressbar(0, pf_idx.album_ct, "Preparing artwork"); 2321 + draw_progressbar(0, pf_idx.album_ct, STR_STEP_PREPARING_ARTWORK); 2347 2322 aa_cache.inspected = 0; 2348 2323 for (int i=0; i < pf_idx.album_ct; i++) 2349 2324 { ··· 4453 4428 if ( ! rb->dir_exists( CACHE_PREFIX ) ) { 4454 4429 if ( rb->mkdir( CACHE_PREFIX ) < 0 ) { 4455 4430 error_wait("Could not create directory " CACHE_PREFIX); 4456 - return PLUGIN_ERROR; 4431 + return PLUGIN_OK; 4457 4432 } 4458 4433 } 4459 4434 ··· 4474 4449 4475 4450 /*Scan will trigger when no file is found or the option was activated*/ 4476 4451 if ((pf_cfg.cache_version != CACHE_VERSION)||(load_album_index() < 0)){ 4477 - rb->splash(HZ/2,"Creating index, please wait"); 4478 4452 ret = create_album_index(); 4479 4453 4480 4454 if (ret == 0){ ··· 4487 4461 4488 4462 if (ret == ERROR_BUFFER_FULL) { 4489 4463 error_wait("Not enough memory for album names"); 4490 - return PLUGIN_ERROR; 4464 + return PLUGIN_OK; 4491 4465 } else if (ret == ERROR_NO_ALBUMS) { 4492 4466 error_wait("No albums found. Please enable database"); 4493 - return PLUGIN_ERROR; 4494 - } else if (ret == ERROR_USER_ABORT) { 4495 - error_wait("User aborted."); 4496 - return PLUGIN_ERROR; 4497 - } 4467 + return PLUGIN_OK; 4468 + } else if (ret == ERROR_USER_ABORT) 4469 + return PLUGIN_OK; 4498 4470 4499 4471 number_of_slides = pf_idx.album_ct; 4500 4472 ··· 4502 4474 if (aa_bufsz < DISPLAY_WIDTH * DISPLAY_HEIGHT * sizeof(pix_t)) 4503 4475 { 4504 4476 error_wait("Not enough memory for album art cache"); 4505 - return PLUGIN_ERROR; 4477 + return PLUGIN_OK; 4506 4478 } 4507 4479 4508 4480 ALIGN_BUFFER(pf_idx.buf, pf_idx.buf_sz, sizeof(long)); ··· 4515 4487 if (!create_empty_slide(pf_cfg.cache_version != CACHE_VERSION)) { 4516 4488 config_save(CACHE_REBUILD, false); 4517 4489 error_wait("Could not load the empty slide"); 4518 - return PLUGIN_ERROR; 4490 + return PLUGIN_OK; 4519 4491 } 4520 4492 4521 4493 if ((pf_cfg.cache_version != CACHE_VERSION) && !create_albumart_cache()) { ··· 4535 4507 if ((empty_slide_hid = read_pfraw(EMPTY_SLIDE, 0)) < 0) 4536 4508 { 4537 4509 error_wait("Unable to load empty slide image"); 4538 - return PLUGIN_ERROR; 4510 + return PLUGIN_OK; 4539 4511 } 4540 4512 4541 4513 if (!create_pf_thread()) { 4542 4514 error_wait("Cannot create thread!"); 4543 - return PLUGIN_ERROR; 4515 + return PLUGIN_OK; 4544 4516 } 4545 4517 4546 4518 initialize_slide_cache(); ··· 4885 4857 LCD_WIDTH, LCD_HEIGHT, &grey_buf_used)) 4886 4858 { 4887 4859 error_wait("Greylib init failed!"); 4888 - return PLUGIN_ERROR; 4860 + return PLUGIN_OK; 4889 4861 } 4890 4862 grey_setfont(FONT_UI); 4891 4863 buf_size -= grey_buf_used; ··· 4909 4881 grey_show(false); 4910 4882 #endif 4911 4883 rb->splash(HZ, ID2P(LANG_ERROR_WRITING_CONFIG)); 4912 - ret = PLUGIN_ERROR; 4884 + ret = PLUGIN_OK; 4913 4885 } 4914 4886 } 4915 4887 return ret;