From 084ffae5e83f5dbce61600ef70b67dcd3d8b6846 Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Sat, 4 Apr 2020 12:00:59 +0200 Subject: [PATCH 01/13] Add start_url to site.webmanifest Signed-off-by: OmegaRogue --- site.webmanifest | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/site.webmanifest b/site.webmanifest index 75d92a84a..2798f7f98 100644 --- a/site.webmanifest +++ b/site.webmanifest @@ -15,5 +15,6 @@ ], "theme_color": "#5755d9", "background_color": "#5755d9", - "display": "standalone" + "display": "standalone", + "start_url": "/" } From 65d3539383b82878857f35a3c78e3406dd0dd937 Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Sat, 4 Apr 2020 12:12:11 +0200 Subject: [PATCH 02/13] added service-worker.js Signed-off-by: OmegaRogue --- index.html | 1 + js/pwa.js | 21 +++++++++++++++++++++ js/service-worker.js | 14 ++++++++++++++ site.webmanifest | 4 +++- 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 js/pwa.js create mode 100644 js/service-worker.js diff --git a/index.html b/index.html index b3e78d848..300fb017d 100644 --- a/index.html +++ b/index.html @@ -142,5 +142,6 @@ + diff --git a/js/pwa.js b/js/pwa.js new file mode 100644 index 000000000..4f497b173 --- /dev/null +++ b/js/pwa.js @@ -0,0 +1,21 @@ +const divInstall = document.getElementById('installContainer'); +const butInstall = document.getElementById('butInstall'); + + +/* Only register a service worker if it's supported */ +if ('serviceWorker' in navigator) { + navigator.serviceWorker.register('/service-worker.js'); +} + +/** + * Warn the page must be served over HTTPS + * The `beforeinstallprompt` event won't fire if the page is served over HTTP. + * Installability requires a service worker with a fetch event handler, and + * if the page isn't served over HTTPS, the service worker won't load. + */ +if (window.location.protocol === 'http:') { + const requireHTTPS = document.getElementById('requireHTTPS'); + const link = requireHTTPS.querySelector('a'); + link.href = window.location.href.replace('http://', 'https://'); + requireHTTPS.classList.remove('hidden'); +} \ No newline at end of file diff --git a/js/service-worker.js b/js/service-worker.js new file mode 100644 index 000000000..2581bc9d1 --- /dev/null +++ b/js/service-worker.js @@ -0,0 +1,14 @@ +self.addEventListener('install', (event) => { + console.log('👷', 'install', event); + self.skipWaiting(); +}); + +self.addEventListener('activate', (event) => { + console.log('👷', 'activate', event); + return self.clients.claim(); +}); + +self.addEventListener('fetch', function(event) { + // console.log('👷', 'fetch', event); + event.respondWith(fetch(event.request)); +}); \ No newline at end of file diff --git a/site.webmanifest b/site.webmanifest index 2798f7f98..cf4d186f6 100644 --- a/site.webmanifest +++ b/site.webmanifest @@ -1,6 +1,7 @@ { "name": "BangleApps", "short_name": "BangleApps", + "description": "Banglejs App Store", "icons": [ { "src": "/android-chrome-192x192.png", @@ -16,5 +17,6 @@ "theme_color": "#5755d9", "background_color": "#5755d9", "display": "standalone", - "start_url": "/" + "start_url": "/", + "scope": "/" } From 507327f9a1575f0071f765d0cac982155e99cac9 Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Sat, 4 Apr 2020 12:18:33 +0200 Subject: [PATCH 03/13] tried getting pwa to work Signed-off-by: OmegaRogue --- css/pwa.css | 19 +++++++++++++++++++ index.html | 12 ++++++++++++ site.webmanifest | 3 +-- 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 css/pwa.css diff --git a/css/pwa.css b/css/pwa.css new file mode 100644 index 000000000..6c2a4411d --- /dev/null +++ b/css/pwa.css @@ -0,0 +1,19 @@ +.hidden { + display: none !important; +} + +#installContainer { + position: absolute; + bottom: 1em; + display: flex; + justify-content: center; + width: 100%; +} + +#installContainer button { + background-color: inherit; + border: 1px solid white; + color: white; + font-size: 1em; + padding: 0.75em; +} \ No newline at end of file diff --git a/index.html b/index.html index 300fb017d..36ed0081f 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,7 @@ + @@ -62,8 +63,19 @@ --> + + + +

Note: If you have a version of Bangle.js firmware before 2v04, please update to the latest firmware or use the legacy app loader. diff --git a/site.webmanifest b/site.webmanifest index cf4d186f6..4fec65c4a 100644 --- a/site.webmanifest +++ b/site.webmanifest @@ -17,6 +17,5 @@ "theme_color": "#5755d9", "background_color": "#5755d9", "display": "standalone", - "start_url": "/", - "scope": "/" + "start_url": "https://omegavoid.github.io/" } From 50ff8cfbb2b4b71f97cba0da0cd545cbc119ec9c Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Sat, 4 Apr 2020 12:21:14 +0200 Subject: [PATCH 04/13] move icons to img/ Signed-off-by: OmegaRogue --- html_code.html | 8 ++++---- .../android-chrome-192x192.png | Bin .../android-chrome-512x512.png | Bin apple-touch-icon.png => img/apple-touch-icon.png | Bin favicon-16x16.png => img/favicon-16x16.png | Bin favicon-32x32.png => img/favicon-32x32.png | Bin mstile-150x150.png => img/mstile-150x150.png | Bin safari-pinned-tab.svg => img/safari-pinned-tab.svg | 0 index.html | 8 ++++---- site.webmanifest | 4 ++-- 10 files changed, 10 insertions(+), 10 deletions(-) rename android-chrome-192x192.png => img/android-chrome-192x192.png (100%) rename android-chrome-512x512.png => img/android-chrome-512x512.png (100%) rename apple-touch-icon.png => img/apple-touch-icon.png (100%) rename favicon-16x16.png => img/favicon-16x16.png (100%) rename favicon-32x32.png => img/favicon-32x32.png (100%) rename mstile-150x150.png => img/mstile-150x150.png (100%) rename safari-pinned-tab.svg => img/safari-pinned-tab.svg (100%) diff --git a/html_code.html b/html_code.html index d940fbd95..f4b4e566d 100644 --- a/html_code.html +++ b/html_code.html @@ -1,8 +1,8 @@ - - - + + + - + diff --git a/android-chrome-192x192.png b/img/android-chrome-192x192.png similarity index 100% rename from android-chrome-192x192.png rename to img/android-chrome-192x192.png diff --git a/android-chrome-512x512.png b/img/android-chrome-512x512.png similarity index 100% rename from android-chrome-512x512.png rename to img/android-chrome-512x512.png diff --git a/apple-touch-icon.png b/img/apple-touch-icon.png similarity index 100% rename from apple-touch-icon.png rename to img/apple-touch-icon.png diff --git a/favicon-16x16.png b/img/favicon-16x16.png similarity index 100% rename from favicon-16x16.png rename to img/favicon-16x16.png diff --git a/favicon-32x32.png b/img/favicon-32x32.png similarity index 100% rename from favicon-32x32.png rename to img/favicon-32x32.png diff --git a/mstile-150x150.png b/img/mstile-150x150.png similarity index 100% rename from mstile-150x150.png rename to img/mstile-150x150.png diff --git a/safari-pinned-tab.svg b/img/safari-pinned-tab.svg similarity index 100% rename from safari-pinned-tab.svg rename to img/safari-pinned-tab.svg diff --git a/index.html b/index.html index 36ed0081f..20bc24477 100644 --- a/index.html +++ b/index.html @@ -7,11 +7,11 @@ - - - + + + - + diff --git a/site.webmanifest b/site.webmanifest index 4fec65c4a..7bbfaba99 100644 --- a/site.webmanifest +++ b/site.webmanifest @@ -4,12 +4,12 @@ "description": "Banglejs App Store", "icons": [ { - "src": "/android-chrome-192x192.png", + "src": "img/android-chrome-192x192.png", "sizes": "192x192", "type": "image/png" }, { - "src": "/android-chrome-512x512.png", + "src": "img/android-chrome-512x512.png", "sizes": "512x512", "type": "image/png" } From dfd98b2d3fa012a11e7552d150c374fb86b20073 Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Sat, 4 Apr 2020 12:23:53 +0200 Subject: [PATCH 05/13] fixed paths Signed-off-by: OmegaRogue --- browserconfig.xml | 2 +- html_code.html | 10 +++++----- index.html | 2 +- js/pwa.js | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/browserconfig.xml b/browserconfig.xml index 3b40787e9..13b6c7911 100644 --- a/browserconfig.xml +++ b/browserconfig.xml @@ -2,7 +2,7 @@ - + #5755d9 diff --git a/html_code.html b/html_code.html index f4b4e566d..ea4b8aa9b 100644 --- a/html_code.html +++ b/html_code.html @@ -1,8 +1,8 @@ - - - - - + + + + + diff --git a/index.html b/index.html index 20bc24477..1e01ce53a 100644 --- a/index.html +++ b/index.html @@ -10,7 +10,7 @@ - + diff --git a/js/pwa.js b/js/pwa.js index 4f497b173..b0852f3ae 100644 --- a/js/pwa.js +++ b/js/pwa.js @@ -4,7 +4,7 @@ const butInstall = document.getElementById('butInstall'); /* Only register a service worker if it's supported */ if ('serviceWorker' in navigator) { - navigator.serviceWorker.register('/service-worker.js'); + navigator.serviceWorker.register('js/service-worker.js'); } /** From 0ef308df025c7da39a46031f6810849cd05c7bfc Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Sat, 4 Apr 2020 12:25:40 +0200 Subject: [PATCH 06/13] fix start_url Signed-off-by: OmegaRogue --- site.webmanifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site.webmanifest b/site.webmanifest index 7bbfaba99..d83a0a4a4 100644 --- a/site.webmanifest +++ b/site.webmanifest @@ -17,5 +17,5 @@ "theme_color": "#5755d9", "background_color": "#5755d9", "display": "standalone", - "start_url": "https://omegavoid.github.io/" + "start_url": "https://omegavoid.github.io/BangleApps" } From 8565d61c43c89b22ffed066e7a9330068af67925 Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Sat, 4 Apr 2020 12:35:55 +0200 Subject: [PATCH 07/13] Made http warning and install footer floating Signed-off-by: OmegaRogue --- css/pwa.css | 15 +++++++++++++++ index.html | 19 +++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/css/pwa.css b/css/pwa.css index 6c2a4411d..6035157fa 100644 --- a/css/pwa.css +++ b/css/pwa.css @@ -16,4 +16,19 @@ color: white; font-size: 1em; padding: 0.75em; +} + +.floating header { + position: fixed; + top: 0; + left: 0; + right: 0; +} + +.floating footer { + position: fixed; + padding: .6em; + bottom: 0; + left: 0; + right: 0; } \ No newline at end of file diff --git a/index.html b/index.html index 1e01ce53a..4fc12c17b 100644 --- a/index.html +++ b/index.html @@ -63,18 +63,16 @@

--> + + - - + +

Note: If you have a version of Bangle.js firmware before 2v04, please update to the latest firmware or @@ -148,6 +146,15 @@

+
+ + +
+ From 923dbe71e45e0a1e9173133163c4fdae5d55504d Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Sat, 4 Apr 2020 12:37:43 +0200 Subject: [PATCH 08/13] Switch second header to div Signed-off-by: OmegaRogue --- css/pwa.css | 14 ++------------ index.html | 6 ++++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/css/pwa.css b/css/pwa.css index 6035157fa..8e78581bf 100644 --- a/css/pwa.css +++ b/css/pwa.css @@ -18,17 +18,7 @@ padding: 0.75em; } -.floating header { +.floating { position: fixed; - top: 0; - left: 0; - right: 0; -} -.floating footer { - position: fixed; - padding: .6em; - bottom: 0; - left: 0; - right: 0; -} \ No newline at end of file +} diff --git a/index.html b/index.html index 4fc12c17b..37a3389a6 100644 --- a/index.html +++ b/index.html @@ -64,12 +64,14 @@ --> - + + From e0a148efd9e2beefdb513ee2f35a3e99ec623cdc Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Sat, 4 Apr 2020 12:49:04 +0200 Subject: [PATCH 09/13] Scope for testing Signed-off-by: OmegaRogue --- site.webmanifest | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/site.webmanifest b/site.webmanifest index d83a0a4a4..65bae96b9 100644 --- a/site.webmanifest +++ b/site.webmanifest @@ -17,5 +17,6 @@ "theme_color": "#5755d9", "background_color": "#5755d9", "display": "standalone", - "start_url": "https://omegavoid.github.io/BangleApps" + "start_url": "https://omegavoid.github.io/BangleApps", + "scope": "/BangleApps" } From 1358283f6b141d31409f07800f1dbd6fca5aea42 Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Sat, 4 Apr 2020 12:52:38 +0200 Subject: [PATCH 10/13] Scope for testing Signed-off-by: OmegaRogue --- site.webmanifest | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/site.webmanifest b/site.webmanifest index 65bae96b9..d83a0a4a4 100644 --- a/site.webmanifest +++ b/site.webmanifest @@ -17,6 +17,5 @@ "theme_color": "#5755d9", "background_color": "#5755d9", "display": "standalone", - "start_url": "https://omegavoid.github.io/BangleApps", - "scope": "/BangleApps" + "start_url": "https://omegavoid.github.io/BangleApps" } From 68cd71344b515b4bf75c6f101ccbc0b1ce3db5dd Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Sat, 4 Apr 2020 12:57:10 +0200 Subject: [PATCH 11/13] Scope for testing Signed-off-by: OmegaRogue --- js/pwa.js | 32 ++++++++++++++++++++++++++++++++ site.webmanifest | 3 ++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/js/pwa.js b/js/pwa.js index b0852f3ae..388e855e0 100644 --- a/js/pwa.js +++ b/js/pwa.js @@ -1,6 +1,38 @@ const divInstall = document.getElementById('installContainer'); const butInstall = document.getElementById('butInstall'); +window.addEventListener('beforeinstallprompt', (event) => { + console.log('👍', 'beforeinstallprompt', event); + // Stash the event so it can be triggered later. + window.deferredPrompt = event; + // Remove the 'hidden' class from the install button container + divInstall.classList.toggle('hidden', false); +}); + +butInstall.addEventListener('click', () => { + console.log('👍', 'butInstall-clicked'); + const promptEvent = window.deferredPrompt; + if (!promptEvent) { + // The deferred prompt isn't available. + return; + } + // Show the install prompt. + promptEvent.prompt(); + // Log the result + promptEvent.userChoice.then((result) => { + console.log('👍', 'userChoice', result); + // Reset the deferred prompt variable, since + // prompt() can only be called once. + window.deferredPrompt = null; + // Hide the install button. + divInstall.classList.toggle('hidden', true); + }); +}); + +window.addEventListener('appinstalled', (event) => { + console.log('👍', 'appinstalled', event); +}); + /* Only register a service worker if it's supported */ if ('serviceWorker' in navigator) { diff --git a/site.webmanifest b/site.webmanifest index d83a0a4a4..57afdea76 100644 --- a/site.webmanifest +++ b/site.webmanifest @@ -17,5 +17,6 @@ "theme_color": "#5755d9", "background_color": "#5755d9", "display": "standalone", - "start_url": "https://omegavoid.github.io/BangleApps" + "start_url": "/BangleApps", + "scope": "/BangleApps" } From 75acfab792ecf4c912ef42765f297467ebe0f7ab Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Sat, 4 Apr 2020 12:59:02 +0200 Subject: [PATCH 12/13] Scope for testing Signed-off-by: OmegaRogue --- site.webmanifest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site.webmanifest b/site.webmanifest index 57afdea76..bf33489fb 100644 --- a/site.webmanifest +++ b/site.webmanifest @@ -17,6 +17,6 @@ "theme_color": "#5755d9", "background_color": "#5755d9", "display": "standalone", - "start_url": "/BangleApps", - "scope": "/BangleApps" + "start_url": "https://omegavoid.github.io/BangleApps", + "scope": "https://omegavoid.github.io/BangleApps" } From 9f5484dd9e68f9497aea84d057eb3cf5d4af64c2 Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Sat, 4 Apr 2020 16:40:20 +0200 Subject: [PATCH 13/13] Scope for testing Signed-off-by: OmegaRogue --- site.webmanifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site.webmanifest b/site.webmanifest index bf33489fb..5b0df458c 100644 --- a/site.webmanifest +++ b/site.webmanifest @@ -18,5 +18,5 @@ "background_color": "#5755d9", "display": "standalone", "start_url": "https://omegavoid.github.io/BangleApps", - "scope": "https://omegavoid.github.io/BangleApps" + "scope": "/BangleApps/" }