mylocation 0.07: Move mylocation app into 'Settings -> Apps'

pull/1893/head
Gordon Williams 2022-05-26 12:50:44 +01:00
parent 6b8cf13f6c
commit 3a3a01136b
7 changed files with 24 additions and 22 deletions

View File

@ -256,6 +256,7 @@ and which gives information about the app for the Launcher.
// 'clock' - a clock - required for clocks to automatically start // 'clock' - a clock - required for clocks to automatically start
// 'widget' - a widget // 'widget' - a widget
// 'bootloader' - an app that at startup (app.boot.js) but doesn't have a launcher entry for 'app.js' // 'bootloader' - an app that at startup (app.boot.js) but doesn't have a launcher entry for 'app.js'
// 'settings' - apps that appear in Settings->Apps (with appname.settings.js) but that have no 'app.js'
// 'RAM' - code that runs and doesn't upload anything to storage // 'RAM' - code that runs and doesn't upload anything to storage
// 'launch' - replacement 'Launcher' // 'launch' - replacement 'Launcher'
// 'textinput' - provides a 'textinput' library that allows text to be input on the Bangle // 'textinput' - provides a 'textinput' library that allows text to be input on the Bangle

View File

@ -4,3 +4,4 @@
0.04: Fixed issue selecting Frankfurt not saved 0.04: Fixed issue selecting Frankfurt not saved
0.05: Fixed issue with back option 0.05: Fixed issue with back option
0.06: renamed source files to match standard 0.06: renamed source files to match standard
0.07: Move mylocation app into 'Settings -> Apps'

View File

@ -2,6 +2,8 @@
*Sets and stores GPS lat and lon of your preferred city* *Sets and stores GPS lat and lon of your preferred city*
To access, go to `Settings -> Apps -> My Location`
* Select one of the preset Cities or setup through the GPS * Select one of the preset Cities or setup through the GPS
* Other Apps can read this information to do calculations based on location * Other Apps can read this information to do calculations based on location
* When the City shows ??? it means the location has been set through the GPS * When the City shows ??? it means the location has been set through the GPS

View File

@ -1 +0,0 @@
require("heatshrink").decompress(atob("mEw4UA///gH4AYPO/QPDgNVqtADY/1BYNfBQ0PBQIAB+ALFmoLDrgLF6oLDq4KEgYKDBYPABYcNBYlVuAuIGAwuEAANUBYYKFHgg6Bq4ZCr4DBHgQLBvWq2te1WlBYZGBBYOr1Wq1qSDBYNqBIILDKgQLLgoLHqBqDBfJHLBZBrOgKPCBYiPCU4NaBYe1WYrABBQLCCfgYGCrwVBa4kAirvKNgIAErgLDKgIAEKQQ8EAAY6DBZhIDIww8GHQg8GHQgwGFwowEFwx5EOog8GHQ0AlWpBYNq1AKFWIILBAYOgBYbICytWAgQKCgTgDcwYXGAAgvGAAY8EEgYWGBgoVEA=="))

View File

@ -2,16 +2,15 @@
"name": "My Location", "name": "My Location",
"shortName":"My Location", "shortName":"My Location",
"icon": "app.png", "icon": "app.png",
"type": "app", "type": "settings",
"screenshots": [{"url":"screenshot_1.png"}], "screenshots": [{"url":"screenshot_1.png"}],
"version":"0.06", "version":"0.07",
"description": "Sets and stores the lat and long of your preferred City or it can be set from the GPS. mylocation.json can be used by other apps that need your main location lat and lon. See README", "description": "Sets and stores the lat and long of your preferred City or it can be set from the GPS. mylocation.json can be used by other apps that need your main location lat and lon. See README",
"readme": "README.md", "readme": "README.md",
"tags": "tool,utility", "tags": "tool,utility",
"supports": ["BANGLEJS", "BANGLEJS2"], "supports": ["BANGLEJS", "BANGLEJS2"],
"storage": [ "storage": [
{"name":"mylocation.app.js","url":"app.js"}, {"name":"mylocation.settings.js","url":"settings.js"}
{"name":"mylocation.img","url":"icon.js","evaluate": true }
], ],
"data": [ "data": [
{"name":"mylocation.json"} {"name":"mylocation.json"}

View File

@ -1,5 +1,4 @@
Bangle.loadWidgets(); (function(back) {
Bangle.drawWidgets();
const SETTINGS_FILE = "mylocation.json"; const SETTINGS_FILE = "mylocation.json";
let settings; let settings;
@ -18,7 +17,7 @@ function loadSettings() {
} }
} }
function save() { function saveSettings() {
settings = s; settings = s;
require('Storage').write(SETTINGS_FILE, settings); require('Storage').write(SETTINGS_FILE, settings);
} }
@ -34,29 +33,29 @@ function setFromGPS() {
//console.log("fix from GPS"); //console.log("fix from GPS");
s = {'lat': gps.lat, 'lon': gps.lon, 'location': '???' }; s = {'lat': gps.lat, 'lon': gps.lon, 'location': '???' };
Bangle.buzz(1500); // buzz on first position Bangle.buzz(1500); // buzz on first position
Bangle.setGPSPower(0); Bangle.setGPSPower(0, "mylocation");
save(); saveSettings();
Bangle.setUI("updown", ()=>{ load(); }); Bangle.setUI("updown", ()=>{ load(); });
E.showPrompt("Location has been saved from the GPS fix",{ E.showPrompt(/*LANG*/"Location has been saved from the GPS fix",{
title:"Location Saved", title:/*LANG*/"Location Saved",
buttons : {"OK":1} buttons : {/*LANG*/"OK":1}
}).then(function(v) { }).then(function(v) {
load(); // load default clock load(); // load default clock
}); });
}); });
Bangle.setGPSPower(1); Bangle.setGPSPower(1, "mylocation");
E.showMessage("Waiting for GPS fix. Place watch in the open. Could take 10 minutes. Long press to abort", "GPS Running"); E.showMessage(/*LANG*/"Waiting for GPS fix. Place watch in the open. Could take 10 minutes. Long press to abort", "GPS Running");
Bangle.setUI("updown", undefined); Bangle.setUI("updown", undefined);
} }
function showMainMenu() { function showMainMenu() {
//console.log("showMainMenu"); //console.log("showMainMenu");
const mainmenu = { const mainmenu = {
'': { 'title': 'My Location' }, '': { 'title': /*LANG*/'My Location' },
'< Back': ()=>{ load(); }, '< Back': ()=>{ back(); },
'City': { /*LANG*/'City': {
value: 0 | locations.indexOf(s.location), value: 0 | locations.indexOf(s.location),
min: 0, max: locations.length - 1, min: 0, max: locations.length - 1,
format: v => locations[v], format: v => locations[v],
@ -65,14 +64,15 @@ function showMainMenu() {
s.location = locations[v]; s.location = locations[v];
s.lat = lats[v]; s.lat = lats[v];
s.lon = lons[v]; s.lon = lons[v];
save(); saveSettings();
} }
} }
}, },
'Set From GPS': ()=>{ setFromGPS(); } /*LANG*/'Set From GPS': ()=>{ setFromGPS(); }
}; };
return E.showMenu(mainmenu); return E.showMenu(mainmenu);
} }
loadSettings(); loadSettings();
showMainMenu(); showMainMenu();
})

View File

@ -65,7 +65,7 @@ const APP_KEYS = [
const STORAGE_KEYS = ['name', 'url', 'content', 'evaluate', 'noOverwite', 'supports']; const STORAGE_KEYS = ['name', 'url', 'content', 'evaluate', 'noOverwite', 'supports'];
const DATA_KEYS = ['name', 'wildcard', 'storageFile', 'url', 'content', 'evaluate']; const DATA_KEYS = ['name', 'wildcard', 'storageFile', 'url', 'content', 'evaluate'];
const SUPPORTS_DEVICES = ["BANGLEJS","BANGLEJS2"]; // device IDs allowed for 'supports' const SUPPORTS_DEVICES = ["BANGLEJS","BANGLEJS2"]; // device IDs allowed for 'supports'
const METADATA_TYPES = ["app","clock","widget","bootloader","RAM","launch","textinput","scheduler","notify","locale"]; // values allowed for "type" field const METADATA_TYPES = ["app","clock","widget","bootloader","RAM","launch","textinput","scheduler","notify","locale","settings"]; // values allowed for "type" field
const FORBIDDEN_FILE_NAME_CHARS = /[,;]/; // used as separators in appid.info const FORBIDDEN_FILE_NAME_CHARS = /[,;]/; // used as separators in appid.info
const VALID_DUPLICATES = [ '.tfmodel', '.tfnames' ]; const VALID_DUPLICATES = [ '.tfmodel', '.tfnames' ];
const GRANDFATHERED_ICONS = ["s7clk", "snek", "astral", "alpinenav", "slomoclock", "arrow", "pebble", "rebble"]; const GRANDFATHERED_ICONS = ["s7clk", "snek", "astral", "alpinenav", "slomoclock", "arrow", "pebble", "rebble"];
@ -140,7 +140,7 @@ apps.forEach((app,appIdx) => {
ERROR(`App ${app.id} 'dependencies' must all be tagged 'type' or 'app' right now`); ERROR(`App ${app.id} 'dependencies' must all be tagged 'type' or 'app' right now`);
if (app.dependencies[dependency]=="type" && !METADATA_TYPES.includes(dependency)) if (app.dependencies[dependency]=="type" && !METADATA_TYPES.includes(dependency))
ERROR(`App ${app.id} 'type' dependency must be one of `+METADATA_TYPES); ERROR(`App ${app.id} 'type' dependency must be one of `+METADATA_TYPES);
}); });
} else } else
ERROR(`App ${app.id} 'dependencies' must be an object`); ERROR(`App ${app.id} 'dependencies' must be an object`);