Implement artist-scope (individual tracks or grouped by album) shuffle
This commit is contained in:
1 parent
0bf16cda63
commit
edd6c8fec3
2 files changed
+34
-7
No files matched your search
+33
-7
@@ -142,7 +142,7 @@ static void to_pkjs_play_from_track(uint16_t seqId) {
|
||||
}
|
||||
}
|
||||
|
||||
static void to_pkjs_shuffle_in_scope(NavScope scope, uint16_t *subscope_index, bool use_groups) {
|
||||
static void to_pkjs_shuffle_in_scope(NavScope scope, bool use_subscope, bool use_groups) {
|
||||
if (!s_pkjs_ready) {
|
||||
return;
|
||||
}
|
||||
@@ -152,9 +152,8 @@ static void to_pkjs_shuffle_in_scope(NavScope scope, uint16_t *subscope_index, b
|
||||
if (result != APP_MSG_OK) {
|
||||
return;
|
||||
}
|
||||
const char *subscope = subscope_index ? s_current_menu_vanity[*subscope_index] : "";
|
||||
if (subscope_index) {
|
||||
dict_write_cstring(out, MESSAGE_KEY_OUT_MENU_NAV_SUBSCOPE, subscope);
|
||||
if (use_subscope) {
|
||||
dict_write_cstring(out, MESSAGE_KEY_OUT_MENU_NAV_SUBSCOPE, s_nav_history.last_subscope[scope]);
|
||||
}
|
||||
dict_write_uint8(out, MESSAGE_KEY_BIDIR_MENU_NAV_SCOPE, scope);
|
||||
dict_write_uint8(out, MESSAGE_KEY_OUT_SHUFFLE_MODE, use_groups ? 2 : 1);
|
||||
@@ -238,6 +237,8 @@ static uint16_t menu_get_num_rows(MenuLayer *menu_layer, uint16_t section_index,
|
||||
switch (s_current_menu_scope) {
|
||||
case NAV_SCOPE_MAIN:
|
||||
return 4;
|
||||
case NAV_SCOPE_ALBUMS:
|
||||
return s_menu_items_count + 2;
|
||||
default:
|
||||
return s_menu_items_count;
|
||||
}
|
||||
@@ -248,6 +249,18 @@ static void menu_draw_row(GContext *ctx, const Layer *cell_layer, MenuIndex *cel
|
||||
case NAV_SCOPE_MAIN:
|
||||
custom_menu_cell_title_draw(ctx, cell_layer, s_main_menu_options[cell_index->row], NULL, s_font_chicago, MARGIN_X);
|
||||
break;
|
||||
case NAV_SCOPE_ALBUMS:
|
||||
switch (cell_index->row) {
|
||||
case 0:
|
||||
custom_menu_cell_title_draw(ctx, cell_layer, "Shuffle Songs", NULL, s_font_chicago, MARGIN_X);
|
||||
break;
|
||||
case 1:
|
||||
custom_menu_cell_title_draw(ctx, cell_layer, "Shuffle Albums", NULL, s_font_chicago, MARGIN_X);
|
||||
break;
|
||||
default:
|
||||
custom_menu_cell_title_draw(ctx, cell_layer, s_current_menu_vanity[cell_index->row - 2], NULL, s_font_chicago, MARGIN_X);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
custom_menu_cell_title_draw(ctx, cell_layer, s_current_menu_vanity[cell_index->row], NULL, s_font_chicago, MARGIN_X);
|
||||
}
|
||||
@@ -259,10 +272,10 @@ static void menu_select_click(struct MenuLayer *menu_layer, MenuIndex *clicked_i
|
||||
case NAV_SCOPE_MAIN:
|
||||
switch (clicked_index->row) {
|
||||
case 0:
|
||||
to_pkjs_shuffle_in_scope(s_current_menu_scope, NULL, false);
|
||||
to_pkjs_shuffle_in_scope(s_current_menu_scope, false, false);
|
||||
break;
|
||||
case 1:
|
||||
to_pkjs_shuffle_in_scope(s_current_menu_scope, NULL, true);
|
||||
to_pkjs_shuffle_in_scope(s_current_menu_scope, false, true);
|
||||
break;
|
||||
case 2:
|
||||
to_pkjs_move_deeper(NAV_SCOPE_ARTISTS, NULL);
|
||||
@@ -273,9 +286,22 @@ static void menu_select_click(struct MenuLayer *menu_layer, MenuIndex *clicked_i
|
||||
return;
|
||||
case NAV_SCOPE_SEARCH:
|
||||
case NAV_SCOPE_ARTISTS:
|
||||
case NAV_SCOPE_ALBUMS: // TODO insert shuffle buttons in artist and album scopes
|
||||
to_pkjs_move_deeper(s_current_menu_scope + 1, &clicked_index->row);
|
||||
break;
|
||||
case NAV_SCOPE_ALBUMS:
|
||||
switch (clicked_index->row) {
|
||||
case 0:
|
||||
to_pkjs_shuffle_in_scope(s_current_menu_scope, true, false);
|
||||
break;
|
||||
case 1:
|
||||
to_pkjs_shuffle_in_scope(s_current_menu_scope, true, true);
|
||||
break;
|
||||
default: {
|
||||
uint16_t album_row = clicked_index->row - 2;
|
||||
to_pkjs_move_deeper(s_current_menu_scope + 1, &album_row);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NAV_SCOPE_ALBUM_TRACKS:
|
||||
to_pkjs_play_from_track(s_current_menu_seq_ids[clicked_index->row]);
|
||||
break;
|
||||
|
||||
@@ -393,6 +393,7 @@ function callAPI(method, endpoint, callback) {
|
||||
xhr.onload = function () {
|
||||
switch (xhr.status) {
|
||||
case 200:
|
||||
case 204:
|
||||
if (callback) {
|
||||
callback(this.responseText);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user