Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Reloader App #3717

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions apps/reloader/ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.01: New App!
36 changes: 36 additions & 0 deletions apps/reloader/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Reloader

Automatically reloads your watch every N hours if no activity to prevent crashing.

## Usage

Install the app and enjoy.

OPTIONAL:

You can go into settings and change how long the watch has to sit before being reloaded.
Default is 2 hours.
Setting the value to 0 disables the app.

## Settings

| Name | Description |
| ---- | ----------- |
| Reload Delay in Hours | How long the watch has to sit idle before being reloaded. |

## Features

Reloads your watch automatically to prevent crashing and memory leaks.

## Credits
Icons: [Icons8](https://icons8.com)

JS Minifier: [Minify-js](https://minify-js.com)

## Requests

Features/Bug requests can be submitted on my fork. Fork [Issues](https://github.com/Sleuth56/BangleApps/issues) page.

## Creator

Stephan Burns
Binary file added apps/reloader/app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions apps/reloader/boot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
let reloader = (function () {
let settings = Object.assign({
reload_delay_in_hours: 2,
}, require("Storage").readJSON("reloader.json", true) || {});

let reload = function () {
if (!Bangle.isLocked()) {
console.log("Reloader: Device maybe in use. Waiting...");
setTimeout(reload, 600000);
}
else {
console.log("Reloader: Idle for to long reloading...");
load();
}
};

if (settings.reload_delay_in_hours != 0) {
setInterval(reload, settings.reload_delay_in_hours * 3600000);
}
});

reloader();
18 changes: 18 additions & 0 deletions apps/reloader/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ "id": "reloader",
"name": "Reloader",
"shortName":"Reloader",
"version":"0.01",
"description": "Automatically reloads your watch every N hours if no activity to prevent crashing.",
"icon": "app.png",
"tags": "tool,system",
"type": "bootloader",
"supports" : ["BANGLEJS2"],
"readme": "README.md",
"storage": [
{"name":"reloader.settings.js","url":"settings.js"},
{"name":"reloader.boot.js","url":"boot.js"}
],
"data": [
{"name": "reloader.json"}
]
}
26 changes: 26 additions & 0 deletions apps/reloader/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(function (back) {
let settings = Object.assign({
reload_delay_in_hours: 2,
}, require("Storage").readJSON("reloader.json", true) || {});

function setSettings() {
require("Storage").writeJSON("reloader.json", settings);
}

E.showMenu({
"": { title: /*LANG*/"Reloader" },

/*LANG*/"< Back": () => back(),

/*LANG*/"Reload Delay in Hours": {
value: settings.reload_delay_in_hours,
min: 0,
max: 24,
step: 1,
onchange: v => {
settings.reload_delay_in_hours = v;
setSettings();
}
}
});
});