Merge branch 'espruino:master' into master

master
sir-indy 2022-03-30 20:50:48 +01:00 committed by GitHub
commit 75eadb66a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 58 additions and 28 deletions

View File

@ -28,4 +28,5 @@
0.24: Better support for Bangle.js 2, avoid widget area for Graphs, smooth graphs more
0.25: Fix issue where if Bangle.js 2 got a GPS fix but no reported time, errors could be caused by the widget (fix #935)
0.26: Multiple bugfixes
0.27: Map drawing with light theme (fix #1023)
0.27: Map drawing with light theme (fix #1023)
0.28: Show distance more accurately in conjunction with new locale app (fix #1523)

View File

@ -248,7 +248,7 @@ function plotTrack(info) {
g.fillCircle(ox,oy,5);
if (info.qOSTM) g.setColor(0, 0, 0);
else g.setColor(g.theme.fg);
g.drawString(require("locale").distance(dist),g.getWidth() / 2, g.getHeight() - 20);
g.drawString(require("locale").distance(dist,2),g.getWidth() / 2, g.getHeight() - 20);
g.setFont("6x8",2);
g.setFontAlign(0,0,3);
g.drawString("Back",g.getWidth() - 10, g.getHeight()/2);

View File

@ -1,7 +1,7 @@
{
"id": "gpsrec",
"name": "GPS Recorder",
"version": "0.27",
"version": "0.28",
"description": "Application that allows you to record a GPS track. Can run in background",
"icon": "app.png",
"tags": "tool,outdoors,gps,widget",

View File

@ -15,4 +15,6 @@
0.13: Now use shorter de_DE date format to more closely match other languages for size
0.14: Added some first translations for Messages in nl_NL
0.15: Fixed sv_SE formatting, long date does not work well for Bangle.js2
Added Swedish localisation with English text
Added Swedish localisation with English text
0.16: Remove global variables that used RAM
Add second 'dp' argument for decimal places in distance/speed/temp (fix #1523)

View File

@ -158,10 +158,10 @@ exports = { name : "en_GB", currencySym:"£",
"%HH": "('0'+getHours(d)).slice(-2)",
"%MM": "('0'+d.getMinutes()).slice(-2)",
"%SS": "('0'+d.getSeconds()).slice(-2)",
"%A": "day.split(',')[d.getDay()]",
"%a": "day.split(',')[d.getDay() + 7]",
"%B": "month.split(',')[d.getMonth()]",
"%b": "month.split(',')[d.getMonth() + 12]",
"%A": `${js(locale.day)}.split(',')[d.getDay()]`,
"%a": `${js(locale.abday)}.split(',')[d.getDay()]`,
"%B": `${js(locale.month)}.split(',')[d.getMonth()]`,
"%b": `${js(locale.abmonth)}.split(',')[d.getMonth() + 12]`,
"%p": `d.getHours()<12?${js(locale.ampm[0].toUpperCase())}:${js(locale.ampm[1].toUpperCase())}`,
"%P": `d.getHours()<12?${js(locale.ampm[0].toLowerCase())}:${js(locale.ampm[1].toLowerCase())}`
};
@ -182,10 +182,10 @@ exports = { name : "en_GB", currencySym:"£",
var temperature = locale.temperature=='°F' ? '(t*9/5)+32' : 't';
var localeModule = `
var day = ${js(locale.day + ',' + locale.abday)};
var month = ${js(locale.month + ',' + locale.abmonth)};
function round(n) {
return n < 10 ? Math.round(n * 10) / 10 : Math.round(n);
function round(n, dp) {
if (dp===undefined) dp=0;
var p = Math.min(dp,dp - Math.floor(Math.log(n)/Math.log(10)));
return n.toFixed(p);
}
var is12;
function getHours(d) {
@ -197,8 +197,8 @@ function getHours(d) {
exports = {
name: ${js(locale.lang)},
currencySym: ${js(locale.currency_symbol)},
dow: (d,short) => day.split(',')[d.getDay() + (short ? 7 : 0)],
month: (d,short) => month.split(',')[d.getMonth() + (short ? 12 : 0)],
dow: (d,short) => ${js(locale.day + ',' + locale.abday)}.split(',')[d.getDay() + (short ? 7 : 0)],
month: (d,short) => ${js(locale.month + ',' + locale.abmonth)}.split(',')[d.getMonth() + (short ? 12 : 0)],
number: (n, dec) => {
if (dec == null) dec = 2;
var w = n.toFixed(dec),
@ -215,9 +215,9 @@ exports = {
return s.substr(0, i + 3) + r + (d ? '${locale.decimal_point}' + d: '');
},
currency: n => ${currency},
distance: n => n < ${distanceUnits[locale.distance[1]]} ? round(${unitConv(distanceUnits[locale.distance[0]])}) + ${js(locale.distance[0])} : round(${unitConv(distanceUnits[locale.distance[1]])}) + ${js(locale.distance[1])},
speed: n => round(${unitConv(speedUnits[locale.speed])}) + ${js(locale.speed)},
temp: t => Math.round(${temperature}) + ${js(locale.temperature)},
distance: (n,dp) => n < ${distanceUnits[locale.distance[1]]} ? round(${unitConv(distanceUnits[locale.distance[0]])},dp) + ${js(locale.distance[0])} : round(${unitConv(distanceUnits[locale.distance[1]])},dp) + ${js(locale.distance[1])},
speed: (n,dp) => round(${unitConv(speedUnits[locale.speed])},dp) + ${js(locale.speed)},
temp: (t,dp) => round(${temperature},dp) + ${js(locale.temperature)},
translate: s => ${locale.trans?`{var t=${js(locale.trans)};s=''+s;return t[s]||t[s.toLowerCase()]||s;}`:`s`},
date: (d,short) => short ? \`${dateS}\` : \`${dateN}\`,
time: (d,short) => short ? \`${timeS}\` : \`${timeN}\`,

View File

@ -1,7 +1,7 @@
{
"id": "locale",
"name": "Languages",
"version": "0.15",
"version": "0.16",
"description": "Translations for different countries",
"icon": "locale.png",
"type": "locale",

View File

@ -17,4 +17,5 @@
0.11: Fix KML and GPX export when there is no GPS data
0.12: Fix 'Back' label positioning on track/graph display, make translateable
0.13: Fix for when widget is used before app
0.14: Remove unneeded variable assignment
0.14: Remove unneeded variable assignment
0.15: Show distance more accurately in conjunction with new locale app (fix #1523)

View File

@ -307,7 +307,7 @@ function viewTrack(filename, info) {
g.fillCircle(ox,oy,5);
if (info.qOSTM) g.setColor("#000");
else g.setColor(g.theme.fg);
g.drawString(require("locale").distance(dist),g.getWidth() / 2, g.getHeight() - 20);
g.drawString(require("locale").distance(dist,2),g.getWidth() / 2, g.getHeight() - 20);
g.setFont("6x8",2);
g.setFontAlign(0,0,3);
var isBTN3 = "BTN3" in global;

View File

@ -2,7 +2,7 @@
"id": "recorder",
"name": "Recorder",
"shortName": "Recorder",
"version": "0.14",
"version": "0.15",
"description": "Record GPS position, heart rate and more in the background, then download to your PC.",
"icon": "app.png",
"tags": "tool,outdoors,gps,widget",

View File

@ -79,7 +79,9 @@ function bangleUpload() {
.then(() => file.async("string"))
.then(data => {
console.log("decoded", path);
if (path.startsWith(BACKUP_STORAGEFILE_DIR)) {
if (data.length==0) { // https://github.com/espruino/BangleApps/issues/1593
console.log("Can't restore files of length 0, ignoring "+path);
} else if (path.startsWith(BACKUP_STORAGEFILE_DIR)) {
path = path.substr(BACKUP_STORAGEFILE_DIR.length+1);
cmds += AppInfo.getStorageFileUploadCommands(path, data)+"\n";
} else if (!path.includes("/")) {

2
core

@ -1 +1 @@
Subproject commit 27c7db6035832837ca3909ea52939f60803df72f
Subproject commit e9097fa680182069a5814c3e566a0bcbcb5e72a1

View File

@ -128,9 +128,10 @@
<h3>Utilities</h3>
<p><button class="btn" id="settime">Set Bangle.js Time</button>
<button class="btn" id="removeall">Remove all Apps</button>
<button class="btn" id="removeall" data-tooltip="Delete everything from your Bangle, leaving it blank">Remove all Apps</button>
<button class="btn" id="reinstallall" data-tooltip="Remove and re-install every app, leaving all other data intact">Reinstall apps</button>
<button class="btn" id="installdefault">Install default apps</button>
<button class="btn" id="installfavourite">Install favourite apps</button></p>
<button class="btn" id="installfavourite" data-tooltip="Delete everything, install apps you've marked as favourites">Install favourite apps</button></p>
<p><button class="btn tooltip tooltip-right" id="downloadallapps" data-tooltip="Download all Bangle.js files to a ZIP file">Backup</button>
<button class="btn tooltip tooltip-right" id="uploadallapps" data-tooltip="Restore Bangle.js from a ZIP file">Restore</button></p>
<h3>Settings</h3>
@ -179,6 +180,6 @@
<script src="core/js/appinfo.js"></script>
<script src="core/js/index.js"></script>
<script src="core/js/pwa.js" defer></script>
<script src="gadgetbridge.js"></script>
<script src="gadgetbridge.js"></script>
</body>
</html>

View File

@ -155,6 +155,29 @@ window.addEventListener('load', (event) => {
});
});
// Button to install all default apps in one go
document.getElementById("reinstallall").addEventListener("click",event=>{
var promise = showPrompt("Reinstall","Really re-install all apps?").then(() => {
getInstalledApps().then(installedapps => {
console.log(installedapps);
var promise = Promise.resolve();
installedapps.forEach(app => {
if (app.custom)
return console.log(`Ignoring ${app.id} as customised`);
var oldApp = app;
app = appJSON.find(a => a.id==oldApp.id);
if (!app)
return console.log(`Ignoring ${oldApp.id} as not found`);
promise = promise.then(() => updateApp(app));
});
return promise;
}).catch(err=>{
Progress.hide({sticky:true});
showToast("App re-install failed, "+err,"error");
});
});
});
// Button to install all default apps in one go
document.getElementById("installdefault").addEventListener("click",event=>{
getInstalledApps().then(() => {

View File

@ -212,7 +212,7 @@ exports.getStats = function(statIDs, options) {
stats["dist"]={
title : "Dist",
getValue : function() { return state.distance; },
getString : function() { return require("locale").distance(state.distance); },
getString : function() { return require("locale").distance(state.distance,2); },
};
}
if (statIDs.includes("step")) {
@ -251,7 +251,7 @@ exports.getStats = function(statIDs, options) {
stats["speed"]={
title : "Speed",
getValue : function() { return state.curSpeed*3.6; }, // in kph
getString : function() { return require("locale").speed(state.curSpeed*3.6); },
getString : function() { return require("locale").speed(state.curSpeed*3.6,2); },
};
}
if (statIDs.includes("caden")) {