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.

plugins: properties: use UI viewport for displaying progress

Prevent switching to a fullscreen view when scanning
a directory, which could be a bit jarring, depending
on your theme of choice.

Also pop context menu activity immediately, without
refreshing, so it isn't redrawn when returning from
plugin.

Change-Id: I021e5880505e7f121163851ae732eb47509cc5d8

+86 -78
+7 -3
apps/onplay.c
··· 138 138 static int bookmark_load_menu_wrapper(void) 139 139 { 140 140 if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* get rid of parent activity */ 141 - pop_current_activity_without_refresh(); /* when called from ctxt menu */ 141 + pop_current_activity_without_refresh(); /* when called from ctxt menu */ 142 142 143 143 return bookmark_load_menu(); 144 144 } ··· 689 689 static int browse_id3_wrapper(void) 690 690 { 691 691 if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* get rid of parent activity */ 692 - pop_current_activity_without_refresh(); /* when called from ctxt menu */ 692 + pop_current_activity_without_refresh(); /* when called from ctxt menu */ 693 693 694 694 if (browse_id3(audio_current_track(), 695 695 playlist_get_display_index(), ··· 806 806 if (!prepare_database_sel(param)) 807 807 return false; 808 808 #endif 809 + 810 + if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* get rid of parent activity */ 811 + pop_current_activity_without_refresh(); /* when called from ctxt menu */ 812 + 809 813 int ret = filetype_load_plugin((const char*)param, selected_file.path); 810 814 if (ret == PLUGIN_USB_CONNECTED) 811 815 onplay_result = ONPLAY_RELOAD_DIR; ··· 1299 1303 menu_selection = do_menu(menu, NULL, NULL, false); 1300 1304 1301 1305 if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* Activity may have been */ 1302 - pop_current_activity(); /* popped already by menu item */ 1306 + pop_current_activity(); /* popped already by menu item */ 1303 1307 1304 1308 1305 1309 if (menu_selection == GO_TO_WPS)
+32 -40
apps/plugins/lib/mul_id3.c
··· 196 196 /* and videos */ 197 197 static const char *video_exts[] = {"mpg","mpeg","mpv","m2v"}; 198 198 199 - static void prn(const char *str, int y) 200 - { 201 - rb->lcd_puts(0, y, str); 202 - #ifdef HAVE_REMOTE_LCD 203 - rb->lcd_remote_puts(0, y, str); 204 - #endif 205 - } 206 - 207 - void display_dir_stats(struct dir_stats *stats) 199 + static void display_dir_stats_vp(struct dir_stats *stats, struct viewport *vp, 200 + struct screen *display) 208 201 { 209 - char buf[32]; 202 + static bool initialized; 210 203 int32_t lang_size_unit; 211 204 unsigned long display_size = human_size(stats->byte_count, &lang_size_unit); 212 - rb->lcd_clear_display(); 213 - #ifdef HAVE_REMOTE_LCD 214 - rb->lcd_remote_clear_display(); 215 - #endif 216 - rb->snprintf(buf, sizeof(buf), "Files: %d (%lu %s)", stats->file_count, 217 - display_size, rb->str(lang_size_unit)); 218 - prn(buf, 0); 219 - rb->snprintf(buf, sizeof(buf), "Audio: %d", stats->audio_file_count); 220 - prn(buf, 1); 221 - if (stats->count_all) 205 + struct viewport *last_vp = display->set_viewport(vp); 206 + display->clear_viewport(); 207 + if (initialized) 222 208 { 223 - rb->snprintf(buf, sizeof(buf), "Playlists: %d", stats->m3u_file_count); 224 - prn(buf, 2); 225 - rb->snprintf(buf, sizeof(buf), "Images: %d", stats->img_file_count); 226 - prn(buf, 3); 227 - rb->snprintf(buf, sizeof(buf), "Videos: %d", stats->vid_file_count); 228 - prn(buf, 4); 229 - rb->snprintf(buf, sizeof(buf), "Directories: %d", stats->dir_count); 230 - prn(buf, 5); 231 - rb->snprintf(buf, sizeof(buf), "Max files in Dir: %d", 232 - stats->max_files_in_dir); 233 - prn(buf, 6); 209 + display->putsf(0, 0, "Files: %d (%lu %s)", stats->file_count, 210 + display_size, rb->str(lang_size_unit)); 211 + display->putsf(0, 1, "Audio: %d", stats->audio_file_count); 212 + if (stats->count_all) 213 + { 214 + display->putsf(0, 2, "Playlists: %d", stats->m3u_file_count); 215 + display->putsf(0, 3, "Images: %d", stats->img_file_count); 216 + display->putsf(0, 4, "Videos: %d", stats->vid_file_count); 217 + display->putsf(0, 5, "Directories: %d", stats->dir_count); 218 + display->putsf(0, 6, "Max files in Dir: %d", stats->max_files_in_dir); 219 + } 220 + else 221 + display->putsf(0, 2, "Directories: %d", stats->dir_count); 234 222 } 235 223 else 224 + initialized = true; 225 + 226 + display->update_viewport(); 227 + display->set_viewport(last_vp); 228 + } 229 + 230 + void display_dir_stats(struct dir_stats *stats) 231 + { 232 + struct viewport vps[NB_SCREENS]; 233 + FOR_NB_SCREENS(i) 236 234 { 237 - rb->snprintf(buf, sizeof(buf), "Directories: %d", stats->dir_count); 238 - prn(buf, 2); 235 + rb->viewport_set_defaults(&vps[i], i); 236 + display_dir_stats_vp(stats, &vps[i], rb->screens[i]); 239 237 } 240 - rb->lcd_update(); 241 - #ifdef HAVE_REMOTE_LCD 242 - rb->lcd_remote_update(); 243 - #endif 244 - 245 238 } 246 239 247 240 /* Recursively scans directories in search of files ··· 281 274 stats->dir_count++; /* new directory */ 282 275 if (*rb->current_tick - last_displayed > (HZ/2)) 283 276 { 284 - if (last_displayed) 285 - display_dir_stats(stats); 277 + display_dir_stats(stats); 286 278 last_displayed = *(rb->current_tick); 287 279 } 288 280 }
+47 -35
apps/plugins/properties.c
··· 35 35 36 36 static int props_type; 37 37 38 + static struct gui_synclist properties_lists; 38 39 static struct mp3entry id3; 39 40 static int mul_id3_count; 40 41 static int skipped_count; ··· 53 54 static struct tm tm; 54 55 55 56 #define NUM_FILE_PROPERTIES 5 56 - #define NUM_PLAYLIST_PROPERTIES 1 + NUM_FILE_PROPERTIES 57 + #define NUM_PLAYLIST_PROPERTIES (1 + NUM_FILE_PROPERTIES) 57 58 static const unsigned char* const props_file[] = 58 59 { 59 60 ID2P(LANG_PROPERTIES_PATH), str_dirname, ··· 66 67 }; 67 68 68 69 #define NUM_DIR_PROPERTIES 4 69 - #define NUM_AUDIODIR_PROPERTIES 1 + NUM_DIR_PROPERTIES 70 + #define NUM_AUDIODIR_PROPERTIES (1 + NUM_DIR_PROPERTIES) 70 71 static const unsigned char* const props_dir[] = 71 72 { 72 73 ID2P(LANG_PROPERTIES_PATH), str_dirname, ··· 220 221 return 0; 221 222 } 222 223 223 - static int browse_file_or_dir(struct dir_stats *stats) 224 + static void setup_properties_list(struct dir_stats *stats) 224 225 { 225 - struct gui_synclist properties_lists; 226 - int button, nb_items; 227 - 226 + int nb_props; 228 227 if (props_type == PROPS_FILE) 229 - nb_items = NUM_FILE_PROPERTIES; 228 + nb_props = NUM_FILE_PROPERTIES; 230 229 else if (props_type == PROPS_PLAYLIST) 231 - nb_items = NUM_PLAYLIST_PROPERTIES; 232 - else if (stats->audio_file_count) 233 - nb_items = NUM_AUDIODIR_PROPERTIES; 230 + nb_props = NUM_PLAYLIST_PROPERTIES; 234 231 else 235 - nb_items = NUM_DIR_PROPERTIES; 236 - 237 - nb_items *= 2; 238 - 232 + nb_props = NUM_DIR_PROPERTIES; 233 + 239 234 rb->gui_synclist_init(&properties_lists, &get_props, stats, false, 2, NULL); 240 235 rb->gui_synclist_set_title(&properties_lists, 241 236 rb->str(props_type == PROPS_DIR ? 242 - LANG_PROPERTIES_DIRECTORY_PROPERTIES : 243 - LANG_PROPERTIES_FILE_PROPERTIES), 237 + LANG_PROPERTIES_DIRECTORY_PROPERTIES : 238 + LANG_PROPERTIES_FILE_PROPERTIES), 244 239 NOICON); 245 - rb->gui_synclist_set_icon_callback(&properties_lists, NULL); 246 240 if (rb->global_settings->talk_menu) 247 241 rb->gui_synclist_set_voice_callback(&properties_lists, speak_property_selection); 248 - rb->gui_synclist_set_nb_items(&properties_lists, nb_items); 249 - rb->gui_synclist_select_item(&properties_lists, 0); 242 + rb->gui_synclist_set_nb_items(&properties_lists, nb_props*2); 243 + } 244 + 245 + static int browse_file_or_dir(struct dir_stats *stats) 246 + { 247 + int button; 248 + 249 + if (props_type == PROPS_DIR && stats->audio_file_count) 250 + rb->gui_synclist_set_nb_items(&properties_lists, NUM_AUDIODIR_PROPERTIES*2); 250 251 rb->gui_synclist_draw(&properties_lists); 251 252 rb->gui_synclist_speak_item(&properties_lists); 252 - 253 253 while(true) 254 254 { 255 255 button = rb->get_action(CONTEXT_LIST, HZ); 256 256 /* HZ so the status bar redraws corectly */ 257 - if (rb->gui_synclist_do_button(&properties_lists,&button)) 257 + if (rb->gui_synclist_do_button(&properties_lists, &button)) 258 258 continue; 259 259 switch(button) 260 260 { ··· 356 356 357 357 enum plugin_status plugin_start(const void* parameter) 358 358 { 359 - int ret; 359 + int ret = 0; 360 360 static struct dir_stats stats; 361 361 const char *file = parameter; 362 362 if(!parameter) 363 363 return PLUGIN_ERROR; 364 364 365 + FOR_NB_SCREENS(i) 366 + rb->viewportmanager_theme_enable(i, true, NULL); 365 367 #ifdef HAVE_TOUCHSCREEN 366 368 rb->touchscreen_set_mode(rb->global_settings->touch_mode); 367 369 #endif ··· 374 376 375 377 if(!determine_file_or_dir()) 376 378 { 377 - /* weird: we couldn't find the entry. This Should Never Happen (TM) */ 378 379 rb->splashf(0, "File/Dir not found: %s", file); 379 380 rb->action_userabort(TIMEOUT_BLOCK); 380 - return PLUGIN_OK; 381 + goto exit; 381 382 } 382 383 383 - if (props_type == PROPS_FILE && has_pl_extension(file)) 384 - props_type = PROPS_PLAYLIST; 384 + if (props_type == PROPS_FILE) 385 + { 386 + if (has_pl_extension(file)) 387 + props_type = PROPS_PLAYLIST; 385 388 386 - if(!(props_type == PROPS_DIR ? 387 - dir_properties(file, &stats, NULL) : file_properties(file))) 389 + ret = !file_properties(file); 390 + } 391 + 392 + if (props_type != PROPS_ID3) /* i.e. not handled by browse_id3 */ 388 393 { 394 + setup_properties_list(&stats); /* Show title during dir scan */ 395 + if (props_type == PROPS_DIR) 396 + ret = !dir_properties(file, &stats, NULL); 397 + } 398 + if (ret) 399 + { 400 + ret = 0; 389 401 if (!stats.canceled) 390 402 { 391 - /* something went wrong (to do: tell user what it was (nesting,...) */ 403 + /* TODO: describe error */ 392 404 rb->splash(0, ID2P(LANG_PROPERTIES_FAIL)); 393 405 rb->action_userabort(TIMEOUT_BLOCK); 394 406 } 395 - return PLUGIN_OK; 407 + goto exit; 396 408 } 397 409 } 398 410 /* database table selected */ 399 411 else if (rb->strcmp(file, MAKE_ACT_STR(ACTIVITY_DATABASEBROWSER)) 400 412 || !assemble_track_info(NULL, NULL)) 401 - return PLUGIN_ERROR; 402 - 403 - FOR_NB_SCREENS(i) 404 - rb->viewportmanager_theme_enable(i, true, NULL); 413 + { 414 + ret = -1; 415 + goto exit; 416 + } 405 417 406 418 if (props_type == PROPS_ID3) 407 419 ret = rb->browse_id3(&id3, 0, 0, &tm, 1); /* Track Info for single file */ ··· 411 423 ret = assemble_track_info(file, &stats) ? /* playlist or folder tracks */ 412 424 rb->browse_id3(&id3, 0, 0, NULL, mul_id3_count) : 413 425 (stats.canceled ? 0 : -1); 414 - 426 + exit: 415 427 FOR_NB_SCREENS(i) 416 428 rb->viewportmanager_theme_undo(i, false); 417 429