mirror of
https://git.wetfence.xyz/RandyTheSilly/jellyPod.git
synced 2026-10-26 23:39:56 -04:00
Add on-watch artist listing
This commit is contained in:
1 parent
03bf39227c
commit
5507ef52ea
3 files changed
+68
-34
No files matched your search
+3
-2
@@ -39,8 +39,9 @@
|
|||||||
"PKJS_READY",
|
"PKJS_READY",
|
||||||
"IN_VANITY_LIST[2048]",
|
"IN_VANITY_LIST[2048]",
|
||||||
"IN_ID_LIST[2048]",
|
"IN_ID_LIST[2048]",
|
||||||
"OUT_MENU_NAV_SCOPE",
|
"BIDIR_MENU_NAV_SCOPE",
|
||||||
"OUT_JFID",
|
"OUT_MENU_NAV_SUBSCOPE",
|
||||||
|
"OUT_PLAY_SEQ_ID",
|
||||||
"OUT_SHUFFLE_MODE"
|
"OUT_SHUFFLE_MODE"
|
||||||
],
|
],
|
||||||
"resources": {
|
"resources": {
|
||||||
|
|||||||
+25
-16
@@ -53,27 +53,31 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
|||||||
Tuple *t_ready = dict_find(iter, MESSAGE_KEY_PKJS_READY);
|
Tuple *t_ready = dict_find(iter, MESSAGE_KEY_PKJS_READY);
|
||||||
if (t_ready) {
|
if (t_ready) {
|
||||||
s_pkjs_ready = true;
|
s_pkjs_ready = true;
|
||||||
|
APP_LOG(APP_LOG_LEVEL_DEBUG, "PKJS READY RECEIVED");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle incoming menu list items
|
// handle incoming menu list items
|
||||||
for (uint16_t i = 0; i < MAX_MENU_ITEMS; i++) {
|
Tuple *t_new_scope = dict_find(iter, MESSAGE_KEY_BIDIR_MENU_NAV_SCOPE);
|
||||||
Tuple *t_vanity = dict_find(iter, MESSAGE_KEY_IN_VANITY_LIST + i);
|
if (t_new_scope) {
|
||||||
if (t_vanity) {
|
for (uint16_t i = 0; i < MAX_MENU_ITEMS; i++) {
|
||||||
s_current_menu_vanity[i] = t_vanity->value->cstring;
|
Tuple *t_vanity = dict_find(iter, MESSAGE_KEY_IN_VANITY_LIST + i);
|
||||||
} else {
|
if (t_vanity) {
|
||||||
s_menu_items_count = i;
|
s_current_menu_vanity[i] = t_vanity->value->cstring;
|
||||||
break;
|
} else {
|
||||||
|
s_menu_items_count = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
s_current_menu_scope = t_new_scope->value->uint8;
|
||||||
|
menu_layer_reload_data(s_menu_layer);
|
||||||
|
menu_layer_set_selected_index(s_menu_layer, MenuIndex(0, 0), MenuRowAlignTop, false);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
s_current_menu_scope = NAV_SCOPE_SEARCH;
|
|
||||||
menu_layer_reload_data(s_menu_layer);
|
|
||||||
menu_layer_set_selected_index(s_menu_layer, MenuIndex(0, 0), MenuRowAlignTop, false);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// request a new menu scope from the PKJS side
|
// request a new menu scope from the PKJS side
|
||||||
static void to_pkjs_scope_change(NavScope scope) {
|
static void to_pkjs_scope_change(NavScope scope, uint16_t *subscope_index) {
|
||||||
if (!s_pkjs_ready) {
|
if (!s_pkjs_ready) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -83,7 +87,10 @@ static void to_pkjs_scope_change(NavScope scope) {
|
|||||||
if (result != APP_MSG_OK) {
|
if (result != APP_MSG_OK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dict_write_uint8(out, MESSAGE_KEY_OUT_MENU_NAV_SCOPE, scope);
|
if (subscope_index) {
|
||||||
|
dict_write_cstring(out, MESSAGE_KEY_OUT_MENU_NAV_SUBSCOPE, s_current_menu_vanity[*subscope_index]);
|
||||||
|
}
|
||||||
|
dict_write_uint8(out, MESSAGE_KEY_BIDIR_MENU_NAV_SCOPE, scope);
|
||||||
|
|
||||||
result = app_message_outbox_send();
|
result = app_message_outbox_send();
|
||||||
if (result != APP_MSG_OK) {
|
if (result != APP_MSG_OK) {
|
||||||
@@ -119,13 +126,15 @@ static void menu_select_click(struct MenuLayer *menu_layer, MenuIndex *clicked_i
|
|||||||
case 1:
|
case 1:
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
to_pkjs_scope_change(NAV_SCOPE_ARTISTS);
|
to_pkjs_scope_change(NAV_SCOPE_ARTISTS, NULL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
to_pkjs_scope_change(NAV_SCOPE_SEARCH);
|
to_pkjs_scope_change(NAV_SCOPE_SEARCH, NULL);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case NAV_SCOPE_SEARCH:
|
case NAV_SCOPE_SEARCH:
|
||||||
|
to_pkjs_scope_change(NAV_SCOPE_ARTISTS, &clicked_index->row);
|
||||||
|
break;
|
||||||
case NAV_SCOPE_ARTISTS:
|
case NAV_SCOPE_ARTISTS:
|
||||||
case NAV_SCOPE_ALBUMS:
|
case NAV_SCOPE_ALBUMS:
|
||||||
case NAV_SCOPE_ALBUM_TRACKS:
|
case NAV_SCOPE_ALBUM_TRACKS:
|
||||||
@@ -179,7 +188,7 @@ static void init() {
|
|||||||
// initialize pkjs
|
// initialize pkjs
|
||||||
app_message_register_inbox_received(inbox_received_handler);
|
app_message_register_inbox_received(inbox_received_handler);
|
||||||
app_message_register_outbox_failed(outbox_failed_handler);
|
app_message_register_outbox_failed(outbox_failed_handler);
|
||||||
app_message_open(app_message_inbox_size_maximum(), 512);
|
app_message_open(app_message_inbox_size_maximum(), 255);
|
||||||
|
|
||||||
// load font
|
// load font
|
||||||
s_font_chicago = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CHICAGO_16));
|
s_font_chicago = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CHICAGO_16));
|
||||||
|
|||||||
+40
-16
@@ -3,6 +3,14 @@ var clayConfig = require('./config');
|
|||||||
var keys = require('message_keys');
|
var keys = require('message_keys');
|
||||||
new Clay(clayConfig);
|
new Clay(clayConfig);
|
||||||
|
|
||||||
|
var NavScope = Object.freeze({
|
||||||
|
NAV_SCOPE_MAIN: 0,
|
||||||
|
NAV_SCOPE_SEARCH: 1,
|
||||||
|
NAV_SCOPE_ARTISTS: 2,
|
||||||
|
NAV_SCOPE_ALBUMS: 3,
|
||||||
|
NAV_SCOPE_ALBUM_TRACKS: 4,
|
||||||
|
});
|
||||||
|
|
||||||
var cfg = JSON.parse(localStorage.getItem('clay-settings'));
|
var cfg = JSON.parse(localStorage.getItem('clay-settings'));
|
||||||
var lookupMap = new Map();
|
var lookupMap = new Map();
|
||||||
|
|
||||||
@@ -78,21 +86,44 @@ Pebble.addEventListener("ready", function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// PKJS seems to change its mind on how to index message keys, so this is necessary... :/
|
||||||
|
function payloadGet(payload, name) {
|
||||||
|
if (payload[name] !== undefined) return payload[name];
|
||||||
|
if (payload[keys[name]] !== undefined) return payload[keys[name]];
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
Pebble.addEventListener("appmessage", function (dict) {
|
Pebble.addEventListener("appmessage", function (dict) {
|
||||||
if (dict.payload[keys.OUT_MENU_NAV_SCOPE]) {
|
//console.log("payload", JSON.stringify(dict.payload));
|
||||||
switch (dict.payload[keys.OUT_MENU_NAV_SCOPE]) {
|
//console.log("expected NAV_SCOPE key", keys.BIDIR_MENU_NAV_SCOPE);
|
||||||
case 1: { // search
|
|
||||||
const vanityList = Array.from(lookupMap.keys());
|
const scope = payloadGet(dict.payload, "BIDIR_MENU_NAV_SCOPE");
|
||||||
const outDict = {};
|
if (scope) {
|
||||||
for (let i = 0; i < vanityList.length; i++) {
|
let vanityList;
|
||||||
outDict[keys.IN_VANITY_LIST + i] = vanityList[i];
|
switch (scope) {
|
||||||
|
case NavScope.NAV_SCOPE_SEARCH: { // search
|
||||||
|
vanityList = Array.from(lookupMap.keys());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NavScope.NAV_SCOPE_ARTISTS: { // artists
|
||||||
|
const subscope = payloadGet(dict.payload, "OUT_MENU_NAV_SUBSCOPE");
|
||||||
|
if (subscope) {
|
||||||
|
// allow filtering by starting character
|
||||||
|
vanityList = Array.from(lookupMap.get(subscope).keys());
|
||||||
|
} else {
|
||||||
|
vanityList = Array.from(lookupMap.values()).flatMap((artistMap) => Array.from(artistMap.keys()));
|
||||||
}
|
}
|
||||||
Pebble.sendAppMessage(outDict);
|
break;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const outDict = {};
|
||||||
|
for (let i = 0; i < vanityList.length; i++) {
|
||||||
|
outDict[keys.IN_VANITY_LIST + i] = vanityList[i];
|
||||||
|
outDict[keys.BIDIR_MENU_NAV_SCOPE] = scope;
|
||||||
|
}
|
||||||
|
Pebble.sendAppMessage(outDict);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -126,13 +157,6 @@ function callAPI(method, endpoint, callback) {
|
|||||||
xhr.send();
|
xhr.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
// On Settings Save/Sync Button Press
|
|
||||||
//// Get User ID
|
|
||||||
|
|
||||||
//curl -H "Authorization: MediaBrowser Token=\"TOKEN\"" -X GET 'BASEURL/Users'
|
|
||||||
|
|
||||||
// Get Track List Using Logic From JellyPod Server
|
|
||||||
|
|
||||||
// On Every Startup
|
// On Every Startup
|
||||||
//// Get Session ID
|
//// Get Session ID
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user