Add on-watch search alpha listing
This commit is contained in:
1 parent
ba4edccb15
commit
03bf39227c
3 files changed
+64
-34
No files matched your search
+2
-2
@@ -37,8 +37,8 @@
|
|||||||
},
|
},
|
||||||
"messageKeys": [
|
"messageKeys": [
|
||||||
"PKJS_READY",
|
"PKJS_READY",
|
||||||
"IN_VANITY_LIST",
|
"IN_VANITY_LIST[2048]",
|
||||||
"IN_ID_LIST",
|
"IN_ID_LIST[2048]",
|
||||||
"OUT_MENU_NAV_SCOPE",
|
"OUT_MENU_NAV_SCOPE",
|
||||||
"OUT_JFID",
|
"OUT_JFID",
|
||||||
"OUT_SHUFFLE_MODE"
|
"OUT_SHUFFLE_MODE"
|
||||||
|
|||||||
+43
-27
@@ -10,20 +10,8 @@ typedef enum {
|
|||||||
NAV_SCOPE_ALBUM_TRACKS = 4,
|
NAV_SCOPE_ALBUM_TRACKS = 4,
|
||||||
} NavScope;
|
} NavScope;
|
||||||
|
|
||||||
// layer-age
|
|
||||||
static Window *s_main_window;
|
|
||||||
static CustomStatusBarLayer *s_status_bar_layer;
|
|
||||||
static Layer *s_divider_layer;
|
|
||||||
static MenuLayer *s_menu_layer;
|
|
||||||
|
|
||||||
// globals
|
|
||||||
static bool s_pkjs_ready = false;
|
|
||||||
static NavScope s_current_menu_scope = NAV_SCOPE_MAIN;
|
|
||||||
|
|
||||||
// resources
|
|
||||||
static GFont s_font_chicago;
|
|
||||||
|
|
||||||
// constants
|
// constants
|
||||||
|
#define MAX_MENU_ITEMS 2048
|
||||||
#define BAR_HEIGHT 20
|
#define BAR_HEIGHT 20
|
||||||
#ifdef PBL_RECT
|
#ifdef PBL_RECT
|
||||||
#define MARGIN_X 4
|
#define MARGIN_X 4
|
||||||
@@ -39,22 +27,57 @@ static GFont s_font_chicago;
|
|||||||
static const GRect s_menu_grect = GRect(MARGIN_X, BAR_HEIGHT + MARGIN_Y, PBL_DISPLAY_WIDTH - (MARGIN_X * 2), PBL_DISPLAY_HEIGHT - (MARGIN_Y * 2));
|
static const GRect s_menu_grect = GRect(MARGIN_X, BAR_HEIGHT + MARGIN_Y, PBL_DISPLAY_WIDTH - (MARGIN_X * 2), PBL_DISPLAY_HEIGHT - (MARGIN_Y * 2));
|
||||||
static const char *s_main_menu_options[4] = {"Shuffle Songs", "Shuffle Artists", "> All Artists", "> Search Artists"};
|
static const char *s_main_menu_options[4] = {"Shuffle Songs", "Shuffle Artists", "> All Artists", "> Search Artists"};
|
||||||
|
|
||||||
|
// layer-age
|
||||||
|
static Window *s_main_window;
|
||||||
|
static CustomStatusBarLayer *s_status_bar_layer;
|
||||||
|
static Layer *s_divider_layer;
|
||||||
|
static MenuLayer *s_menu_layer;
|
||||||
|
|
||||||
|
// globals
|
||||||
|
static bool s_pkjs_ready = false;
|
||||||
|
static NavScope s_current_menu_scope = NAV_SCOPE_MAIN;
|
||||||
|
static const char *s_current_menu_vanity[MAX_MENU_ITEMS];
|
||||||
|
// static uint16_t s_current_menu_seq_ids[MAX_MENU_ITEMS];
|
||||||
|
static uint16_t s_menu_items_count = 0;
|
||||||
|
|
||||||
|
// resources
|
||||||
|
static GFont s_font_chicago;
|
||||||
|
|
||||||
////////////////////// PKJS //////////////////////
|
////////////////////// PKJS //////////////////////
|
||||||
|
|
||||||
|
static void outbox_failed_handler(DictionaryIterator *iter, AppMessageResult reason, void *context) {
|
||||||
|
APP_LOG(APP_LOG_LEVEL_ERROR, "outbox failed: %d", (int)reason);
|
||||||
|
}
|
||||||
|
|
||||||
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
||||||
Tuple *ready_tuple = dict_find(iter, MESSAGE_KEY_PKJS_READY);
|
Tuple *t_ready = dict_find(iter, MESSAGE_KEY_PKJS_READY);
|
||||||
if (ready_tuple) {
|
if (t_ready) {
|
||||||
s_pkjs_ready = true;
|
s_pkjs_ready = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handle incoming menu list items
|
||||||
|
for (uint16_t i = 0; i < MAX_MENU_ITEMS; i++) {
|
||||||
|
Tuple *t_vanity = dict_find(iter, MESSAGE_KEY_IN_VANITY_LIST + i);
|
||||||
|
if (t_vanity) {
|
||||||
|
s_current_menu_vanity[i] = t_vanity->value->cstring;
|
||||||
|
} else {
|
||||||
|
s_menu_items_count = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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
|
||||||
static void to_pkjs_scope_change(NavScope scope) {
|
static void to_pkjs_scope_change(NavScope scope) {
|
||||||
if (!s_pkjs_ready) {
|
if (!s_pkjs_ready) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send scope to return data for (PKJS side should track last scope and only send new data if the new scope differs)
|
|
||||||
DictionaryIterator *out;
|
DictionaryIterator *out;
|
||||||
AppMessageResult result = app_message_outbox_begin(&out);
|
AppMessageResult result = app_message_outbox_begin(&out);
|
||||||
if (result != APP_MSG_OK) {
|
if (result != APP_MSG_OK) {
|
||||||
@@ -72,12 +95,8 @@ static uint16_t menu_get_num_rows(MenuLayer *menu_layer, uint16_t section_index,
|
|||||||
switch (s_current_menu_scope) {
|
switch (s_current_menu_scope) {
|
||||||
case NAV_SCOPE_MAIN:
|
case NAV_SCOPE_MAIN:
|
||||||
return 4;
|
return 4;
|
||||||
case NAV_SCOPE_SEARCH:
|
|
||||||
case NAV_SCOPE_ARTISTS:
|
|
||||||
case NAV_SCOPE_ALBUMS:
|
|
||||||
case NAV_SCOPE_ALBUM_TRACKS:
|
|
||||||
default:
|
default:
|
||||||
return 99;
|
return s_menu_items_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,12 +105,8 @@ static void menu_draw_row(GContext *ctx, const Layer *cell_layer, MenuIndex *cel
|
|||||||
case NAV_SCOPE_MAIN:
|
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);
|
custom_menu_cell_title_draw(ctx, cell_layer, s_main_menu_options[cell_index->row], NULL, s_font_chicago, MARGIN_X);
|
||||||
break;
|
break;
|
||||||
case NAV_SCOPE_SEARCH:
|
|
||||||
case NAV_SCOPE_ARTISTS:
|
|
||||||
case NAV_SCOPE_ALBUMS:
|
|
||||||
case NAV_SCOPE_ALBUM_TRACKS:
|
|
||||||
default:
|
default:
|
||||||
return;
|
custom_menu_cell_title_draw(ctx, cell_layer, s_current_menu_vanity[cell_index->row], NULL, s_font_chicago, MARGIN_X);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +178,8 @@ static void main_window_unload() {
|
|||||||
static void init() {
|
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_open(4096, 1024); // TODO adjust sizes
|
app_message_register_outbox_failed(outbox_failed_handler);
|
||||||
|
app_message_open(app_message_inbox_size_maximum(), 512);
|
||||||
|
|
||||||
// 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));
|
||||||
|
|||||||
+19
-5
@@ -1,8 +1,10 @@
|
|||||||
var Clay = require('@rebble/clay');
|
var Clay = require('@rebble/clay');
|
||||||
var clayConfig = require('./config');
|
var clayConfig = require('./config');
|
||||||
|
var keys = require('message_keys');
|
||||||
new Clay(clayConfig);
|
new Clay(clayConfig);
|
||||||
|
|
||||||
var cfg = JSON.parse(localStorage.getItem('clay-settings'));
|
var cfg = JSON.parse(localStorage.getItem('clay-settings'));
|
||||||
|
var lookupMap = new Map();
|
||||||
|
|
||||||
Pebble.addEventListener("ready", function () {
|
Pebble.addEventListener("ready", function () {
|
||||||
// store cache of library info from Jellyfin
|
// store cache of library info from Jellyfin
|
||||||
@@ -26,7 +28,6 @@ Pebble.addEventListener("ready", function () {
|
|||||||
|
|
||||||
// format response for jellyPod
|
// format response for jellyPod
|
||||||
//// build lookupMap
|
//// build lookupMap
|
||||||
const lookupMap = new Map();
|
|
||||||
let lastAlbumInfo = {AlbumArtist: "", AlbumName: "", AlbumYear: 0};
|
let lastAlbumInfo = {AlbumArtist: "", AlbumName: "", AlbumYear: 0};
|
||||||
for (const track of libObj.Items) {
|
for (const track of libObj.Items) {
|
||||||
if (!track.Name) continue;
|
if (!track.Name) continue;
|
||||||
@@ -69,16 +70,29 @@ Pebble.addEventListener("ready", function () {
|
|||||||
|
|
||||||
//console.log(JSON.stringify(lookupMap, (k, v) => v instanceof Map ? Object.fromEntries(v) : v));
|
//console.log(JSON.stringify(lookupMap, (k, v) => v instanceof Map ? Object.fromEntries(v) : v));
|
||||||
|
|
||||||
Pebble.sendAppMessage({ PKJS_READY: 1 });
|
const readyDict = {};
|
||||||
|
readyDict[keys.PKJS_READY] = 1;
|
||||||
|
Pebble.sendAppMessage(readyDict);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Pebble.addEventListener("appmessage", function (dict) {
|
Pebble.addEventListener("appmessage", function (dict) {
|
||||||
if (dict.payload["OUT_MENU_NAV_SCOPE"]) {
|
if (dict.payload[keys.OUT_MENU_NAV_SCOPE]) {
|
||||||
//const cfg = JSON.parse(localStorage.getItem('clay-settings'));
|
switch (dict.payload[keys.OUT_MENU_NAV_SCOPE]) {
|
||||||
//callAPI(cfg.PKJS_PAVLOK_API_KEY, parseInt(dict.payload["PKJS_PAVLOK_ZAP"]));
|
case 1: { // search
|
||||||
|
const vanityList = Array.from(lookupMap.keys());
|
||||||
|
const outDict = {};
|
||||||
|
for (let i = 0; i < vanityList.length; i++) {
|
||||||
|
outDict[keys.IN_VANITY_LIST + i] = vanityList[i];
|
||||||
|
}
|
||||||
|
Pebble.sendAppMessage(outDict);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user