Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/apphist/ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0.01: New App! (Break out from Fastload Utils app)
0.02: Don't use settings.
18 changes: 18 additions & 0 deletions apps/apphist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# App history

* Lets you navigate back trough the series of apps since last you were on the clock face. Works with the software back button and hardware button.

# Notes

* Quick Launch app does not get remarked in history.

TODO:
* Long press of hardware button clears the app history and loads the clock face (Sometimes triggered if your not very quickly releasing the button. Commented out for now.)

# Creator

[thyttan](https://github.com/thyttan)
[halemmerich](https://github.com/halemmerich) (Fastload Utils)

# Contributors

56 changes: 56 additions & 0 deletions apps/apphist/boot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
// Things that use `eval` instead of `load` or `Bangle.load` (e.g. auto displaying new messages - `messagegui.new.js`) can affect the app history record unexpectedly. They don't themselves get added to the history (since we don't override `eval`) and if they use one of the other two mentioned load functions they may remove the last recorded entry.

// Seems like `apphist` must be placed before `Fastload Utils` in execution order at boot for compatibility. Otherwise the Bangle.js 2 craps out, freezed up and soon reboots extra hard before loading the clock face again. This is ensured by metadata placing apphist at order 4 and Fastload Utils at order 5 in the boot sequence.

//Commented out calling the settings object. Seemed like a waste of resources.

const s = require("Storage");
//const SETTINGS = s.readJSON("apphist.settings.json") || {};

global._load = global.load;
Bangle._load = Bangle.load;

let appHistory = s.readJSON("apphist.json",true)||[];
const resetHistory = ()=>{appHistory=[];s.writeJSON("apphist.json",appHistory);};
const recordHistory = ()=>{s.writeJSON("apphist.json",appHistory);};

const traverseHistory = (name)=>{
if (name && name!=".bootcde" && !(name=="quicklaunch.app.js"/* && SETTINGS.disregardQuicklaunch*/)) {
// store the name of the app to launch
appHistory.push(name);
} else if (name==".bootcde") { // when Bangle.showClock is called
resetHistory();
} else if (name=="quicklaunch.app.js"/* && SETTINGS.disregardQuicklaunch*/) {
// do nothing with history
} else {
// go back in history
appHistory.pop();
name = appHistory[appHistory.length-1];
}
return name;
};

const addHistoryTraversal = (loadFn => (name) => {
name = traverseHistory(name);
loadFn(name);
});

const addHistoryTraversalFastload = (loadFn => (name) => {
global.load = global._load; // Only run through traverseHistory once, not both for Bangle.load and global.load.
name = traverseHistory(name);
loadFn(name);
global.load = globalLoadWithHistory;
});

const globalLoadWithHistory = addHistoryTraversal(global.load);
global.load = globalLoadWithHistory;
Bangle.load = addHistoryTraversalFastload(Bangle._load);

E.on('kill', ()=>{
// Usually record history, but reset it if long press of HW button was used.
// FIXME: May be tricky for user to release button quickly enough to not trigger resetHistory. Commented out for now.
// if (!BTN.read()) recordHistory(); else resetHistory();
recordHistory();
});
}
Binary file added apps/apphist/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions apps/apphist/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{ "id": "apphist",
"name": "App History",
"version": "0.02",
"icon": "icon.png",
"description": "Lets you navigate back trough the series of apps since last you were on the clock face. Works with the software back button and hardware button.",
"type":"bootloader",
"tags": "system",
"supports": ["BANGLEJS2"],
"readme": "README.md",
"storage": [
{"name":"apphist.4.boot.js","url":"boot.js"}
],
"data": [
{"name":"apphist.json"}
]
}
38 changes: 38 additions & 0 deletions apps/apphist/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//Settings has been disabled for apphist. But we leave this file for potential future use.

(function(back) {
var FILE="apphist.settings.json";
var settings;
var isQuicklaunchPresent = !!require('Storage').read("quicklaunch.app.js", 0, 1);

function writeSettings(key, value) {
var s = require('Storage').readJSON(FILE, true) || {};
s[key] = value;
require('Storage').writeJSON(FILE, s);
readSettings();
}

function readSettings(){
settings = require('Storage').readJSON(FILE, true) || {};
}

readSettings();

function buildMainMenu(){
var mainmenu = {};

mainmenu[''] = { 'title': 'App History', back: back };

if (isQuicklaunchPresent) {
mainmenu['Exclude Quick Launch from history'] = {
value: !!settings.disregardQuicklaunch,
onchange: v => {
writeSettings("disregardQuicklaunch",v);
}
};
}
return mainmenu;
}

E.showMenu(buildMainMenu());
})
2 changes: 2 additions & 0 deletions apps/confthyttan/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
0.08: hide bt indicator when connected (`widbt_notify`). Add "Message Twist to
Scroll". Add "Big Clock Info app".
Auto open messages if locked.
0.09: remove fastload utils as it's functionality is more or less included in
firmware now. Fix to handle the new widget theme colors.
6 changes: 2 additions & 4 deletions apps/confthyttan/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "id": "confthyttan",
"name": "Thyttan's Default Config",
"version":"0.08",
"version":"0.09",
"author": "thyttan",
"description": "A different default set of apps and configurations. Makes many quality of life changes. Opinionated based on the creators taste. Read more below before installing.",
"icon": "app.png",
Expand Down Expand Up @@ -39,10 +39,10 @@
"autoreset":"app",
"chargent":"app",
"setting":"app",
"fastload":"app",
"boot":"app",
"ateatimer":"app",
"bigclkinfo":"app",
"apphist":"app",
"drained":"app"
},
"storage": [
Expand All @@ -52,8 +52,6 @@
"url":"autoreset.json"},
{"name":"dtlaunch.json",
"url":"dtlaunch.json"},
{"name":"fastload.json",
"url":"fastload.json"},
{"name":"quicklaunch.json",
"url":"quicklaunch.json"},
{"name":"messages.settings.json",
Expand Down
2 changes: 1 addition & 1 deletion apps/confthyttan/setting.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ble:true,blerepl:true,log:false,quiet:0,timeout:10,vibrate:true,beep:true,timezone:2,HID:false,clock:"edgeclk.app.js","12hour":false,firstDayOfWeek:1,brightness:0.5,options:{wakeOnBTN1:true,wakeOnBTN2:true,wakeOnBTN3:true,wakeOnFaceUp:false,wakeOnTouch:false,wakeOnTwist:false,twistThreshold:819.2,twistMaxY:-800,twistTimeout:1000,btnLoadTimeout:700},theme:{fg:65535,bg:0,fg2:65535,bg2:8,fgH:65535,bgH:31,dark:true},clockHasWidgets:true,launcher:"dtlaunch.app.js",touch:{x1:6,y1:14,x2:197,y2:178}}
{ble:true,blerepl:true,log:false,quiet:0,timeout:10,vibrate:true,beep:true,timezone:2,HID:false,clock:"edgeclk.app.js","12hour":false,firstDayOfWeek:1,brightness:0.5,options:{wakeOnBTN1:true,wakeOnBTN2:true,wakeOnBTN3:true,wakeOnFaceUp:false,wakeOnTouch:false,wakeOnTwist:false,twistThreshold:819.2,twistMaxY:-800,twistTimeout:1000,btnLoadTimeout:700},theme:{fg:65535,bg:0,fg2:65535,bg2:8,fgH:65535,bgH:31,fgW:65535,bgW:0,dark:true},clockHasWidgets:true,launcher:"dtlaunch.app.js",touch:{x1:6,y1:14,x2:197,y2:178}}
1 change: 1 addition & 0 deletions apps/fastload/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
0.04: (WIP) Allow use of app history when going back (`load()` or `Bangle.load()` calls without specified app).
0.05: Check for changes in setting.js and force real reload if needed
0.06: Fix caching whether an app is fastloadable
0.07: Break out app history to a separate app: App History, `apphist`.
11 changes: 3 additions & 8 deletions apps/fastload/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#### ⚠️EXPERIMENTAL⚠️
#### ⚠️DEPRECATED⚠️ ⚠️EXPERIMENTAL⚠️

# Fastload Utils

**Deprecated.** This app's functionality has to a large extent been integrated into firmware, with slight adjustments.

**Use this with caution.** When you find something misbehaving please check if the problem actually persists without Fastload Utils
before filing an issue.

Expand All @@ -18,17 +20,10 @@ Bangle will just end up with a memory leak or undefined behaviour**

## Settings

* Activate app history and navigate back through recent apps instead of immediately loading the clock face
* If Quick Launch is installed it can be excluded from app history
* Allows to redirect all loads usually loading the clock to the launcher instead
* The "Fastloading..." screen can be switched off
* Enable checking `setting.json` and force a complete load on changes

## App history

* Long press of hardware button clears the app history and loads the clock face
* Installing the 'Fast Reset' app allows doing fastloads directly to the clock face by pressing the hardware button just a little longer than a click. Useful if there are many apps in the history and the user want to access the clock quickly.

## Technical Notes

Fastload uses the same mechanism as `.bootcde` does to check the app to be loaded for widget use and stores the result of that and a hash of the js in a cache.
Expand Down
23 changes: 0 additions & 23 deletions apps/fastload/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,8 @@ let fastload = function(n){
};
global.load = fastload;

let appHistory, resetHistory, recordHistory;
if (SETTINGS.useAppHistory){
appHistory = s.readJSON("fastload.history.json",true)||[];
resetHistory = ()=>{appHistory=[];s.writeJSON("fastload.history.json",appHistory);};
recordHistory = ()=>{s.writeJSON("fastload.history.json",appHistory);};
}

Bangle.load = (o => (name) => {
if (Bangle.uiRemove && !SETTINGS.hideLoading) loadingScreen();
if (SETTINGS.useAppHistory){
if (name && name!=".bootcde" && !(name=="quicklaunch.app.js" && SETTINGS.disregardQuicklaunch)) {
// store the name of the app to launch
appHistory.push(name);
} else if (name==".bootcde") { // when Bangle.showClock is called
resetHistory();
} else if (name=="quicklaunch.app.js" && SETTINGS.disregardQuicklaunch) {
// do nothing with history
} else {
// go back in history
appHistory.pop();
name = appHistory[appHistory.length-1];
}
}
if (SETTINGS.autoloadLauncher && !name){
let orig = Bangle.load;
Bangle.load = (n)=>{
Expand All @@ -94,6 +73,4 @@ Bangle.load = (o => (name) => {
} else
o(name);
})(Bangle.load);

if (SETTINGS.useAppHistory) E.on('kill', ()=>{if (!BTN.read()) recordHistory(); else resetHistory();}); // Usually record history, but reset it if long press of HW button was used.
}
4 changes: 2 additions & 2 deletions apps/fastload/metadata.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{ "id": "fastload",
"name": "Fastload Utils",
"shortName" : "Fastload Utils",
"version": "0.06",
"version": "0.07",
"icon": "icon.png",
"description": "Enable experimental fastloading for more apps. ⚠️ Use with extreme caution - many apps are not compatible with fastload and will cause memory leaks and instability.",
"description": "Deprecated. Enable experimental fastloading for more apps. ⚠️ Use with extreme caution - many apps are not compatible with fastload and will cause memory leaks and instability.",
"type":"bootloader",
"tags": "system",
"supports": ["BANGLEJS2"],
Expand Down
25 changes: 0 additions & 25 deletions apps/fastload/settings.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(function(back) {
var FILE="fastload.json";
var settings;
var isQuicklaunchPresent = !!require('Storage').read("quicklaunch.app.js", 0, 1);

function writeSettings(key, value) {
var s = require('Storage').readJSON(FILE, true) || {};
Expand All @@ -21,34 +20,10 @@

mainmenu[''] = { 'title': 'Fastload', back: back };

mainmenu['Activate app history'] = {
value: !!settings.useAppHistory,
onchange: v => {
writeSettings("useAppHistory",v);
if (v && settings.autoloadLauncher) {
writeSettings("autoloadLauncher",!v); // Don't use app history and load to launcher together.
setTimeout(()=>E.showMenu(buildMainMenu()), 0); // Update the menu so it can be seen if a value was automatically set to false (app history vs load launcher).
}
}
};

if (isQuicklaunchPresent) {
mainmenu['Exclude Quick Launch from history'] = {
value: !!settings.disregardQuicklaunch,
onchange: v => {
writeSettings("disregardQuicklaunch",v);
}
};
}

mainmenu['Force load to launcher'] = {
value: !!settings.autoloadLauncher,
onchange: v => {
writeSettings("autoloadLauncher",v);
if (v && settings.useAppHistory) {
writeSettings("useAppHistory",!v);
setTimeout(()=>E.showMenu(buildMainMenu()), 0); // Update the menu so it can be seen if a value was automatically set to false (app history vs load launcher).
} // Don't use app history and load to launcher together.
}
};

Expand Down
Loading