From 6de8bdc41a51ddce6e787563b805ba2ce0121e2b Mon Sep 17 00:00:00 2001 From: Alice Jenkinson Date: Fri, 17 Mar 2017 21:45:44 +1300 Subject: [PATCH 01/10] Initial rework of Cordova branch --- bower.json | 13 +++++++++++-- js/app.js | 5 +++++ js/glowingbear.js | 18 +++++++++++++++--- js/notifications.js | 39 +++++++++++++++++++++++++++++++++++++-- manifest.webapp | 10 +++++----- 5 files changed, 73 insertions(+), 12 deletions(-) create mode 100644 js/app.js diff --git a/bower.json b/bower.json index 06d8ae5..b0979c1 100644 --- a/bower.json +++ b/bower.json @@ -14,7 +14,16 @@ "angular-mocks": "1.5.x", "html5-boilerplate": "~4.3.0", "underscore": "~1.8", - "bootstrap": "~3.1", + "bootstrap": "~3.3", "emojione": "~2.2" - } + }, + "keywords": [ + "weechat", + "irc" + ], + "ignore": [ + "**/.*", + "node_modules", + "bower_components" + ] } diff --git a/js/app.js b/js/app.js new file mode 100644 index 0000000..8455e56 --- /dev/null +++ b/js/app.js @@ -0,0 +1,5 @@ +document.addEventListener("deviceready", function () { + if (navigator.splashscreen !== undefined) { + navigator.splashscreen.hide(); + } +}, false); \ No newline at end of file diff --git a/js/glowingbear.js b/js/glowingbear.js index 3bbce1e..caaed46 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -234,7 +234,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $scope.notifications = notifications.unreadCount('notification'); $scope.unread = notifications.unreadCount('unread'); - if (settings.useFavico && $rootScope.favico) { + if (cordova === undefined && settings.useFavico && $rootScope.favico) { notifications.updateFavico(); } }); @@ -250,6 +250,10 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $scope.connectbutton = 'Connect'; $scope.connectbuttonicon = 'glyphicon-chevron-right'; bufferResume.reset(); + + if (window.plugin !== undefined && window.plugin.notification !== undefined && window.plugin.notification.local !== undefined) { + window.plugin.notification.local.cancelAll(); + } }); $scope.connectbutton = 'Connect'; $scope.connectbuttonicon = 'glyphicon-chevron-right'; @@ -369,6 +373,11 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', if (!$rootScope.connected) { return; } + + if (cordova !== undefined) { + return; + } + if (useFavico) { notifications.updateFavico(); } else { @@ -382,7 +391,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', // This also fires when the page is loaded if enabled. // Note that this says MathJax but we switched to KaTeX settings.addCallback('enableMathjax', function(enabled) { - if (enabled && !$rootScope.mathjax_init) { + if (cordova === undefined && enabled && !$rootScope.mathjax_init) { // Load MathJax only once $rootScope.mathjax_init = true; @@ -803,7 +812,10 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', if ($rootScope.connected) { $scope.disconnect(); } - $scope.favico.reset(); + + if (cordova !== undefined) { + $scope.favico.reset(); + } } }; diff --git a/js/notifications.js b/js/notifications.js index 2f9752f..487aed8 100644 --- a/js/notifications.js +++ b/js/notifications.js @@ -34,6 +34,21 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', fu $log.info('Service Worker err:', err); }); } + + document.addEventListener('deviceready', function() { + // Add cordova local notification click handler + if (cordova !== null && cordova.plugins !== undefined && cordova.plugins.notification !== undefined && + cordova.plugins.notification.local !== undefined) { + cordova.plugins.notification.local.on("click", function (notification) { + // go to buffer + var data = JSON.parse(notification.data); + models.setActiveBuffer(data.buffer); + window.focus(); + // clear this notification + cordova.plugins.notification.local.clear(notification.id); + }); + } + }); }; var showNotification = function(buffer, title, body) { @@ -66,7 +81,7 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', fu toastNotifier.show(toast); - } else { + } else if (typeof Notification !== 'undefined') { var notification = new Notification(title, { body: body, @@ -97,6 +112,22 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', fu delete notifications[this.id]; }; + } else if (cordova !== undefined && cordova.plugins !== undefined && cordova.plugins.notification !== undefined && cordova.plugins.notification.local !== undefined) { + // Cordova local notification + // Calculate notification id from buffer ID + // Needs to be unique number, but we'll only ever have one per buffer + var id = parseInt(buffer.id, 16); + + // Cancel previous notification for buffer (if there was one) + cordova.plugins.notification.local.clear(id); + + // Send new notification + cordova.plugins.notification.local.schedule({ + id: id, + text: body, + title: title, + data: { buffer: buffer.id } // remember buffer id for when the notification is clicked + }); } }; @@ -135,6 +166,10 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', fu }; var updateFavico = function() { + if (cordova !== undefined) { + return; + } + var notifications = unreadCount('notification'); if (notifications > 0) { $rootScope.favico.badge(notifications, { @@ -200,7 +235,7 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', fu showNotification(buffer, title, body); - if (settings.soundnotification) { + if (cordova === undefined && settings.soundnotification) { // TODO fill in a sound file var audioFile = "assets/audio/sonar"; var soundHTML = ''; diff --git a/manifest.webapp b/manifest.webapp index d324eda..3bb8b1c 100644 --- a/manifest.webapp +++ b/manifest.webapp @@ -1,12 +1,12 @@ { "name": "Glowing Bear", "description": "WeeChat Web frontend", - "launch_path": "/glowing-bear/index.html", + "launch_path": "/index.html", "icons": { - "128": "/glowing-bear/assets/img/glowing_bear_128x128.png", - "60": "/glowing-bear/assets/img/glowing_bear_60x60.png", - "90": "/glowing-bear/assets/img/glowing_bear_90x90.png", - "32": "/glowing-bear/assets/img/favicon.png" + "128": "/assets/img/glowing_bear_128x128.png", + "60": "/assets/img/glowing_bear_60x60.png", + "90": "/assets/img/glowing_bear_90x90.png", + "32": "/assets/img/favicon.png" }, "installs_allowed_from": [ "*" From 8a1f02241f537c0d2af7947577be1c93c539c8c7 Mon Sep 17 00:00:00 2001 From: Alice Jenkinson Date: Fri, 17 Mar 2017 22:55:18 +1300 Subject: [PATCH 02/10] Move splashscreen logic out of app.js into glowingbear.js --- index.html | 1 + js/app.js | 5 ----- js/glowingbear.js | 6 ++++++ 3 files changed, 7 insertions(+), 5 deletions(-) delete mode 100644 js/app.js diff --git a/index.html b/index.html index 64b45b6..a7f2c0d 100644 --- a/index.html +++ b/index.html @@ -47,6 +47,7 @@ +
diff --git a/js/app.js b/js/app.js deleted file mode 100644 index 8455e56..0000000 --- a/js/app.js +++ /dev/null @@ -1,5 +0,0 @@ -document.addEventListener("deviceready", function () { - if (navigator.splashscreen !== undefined) { - navigator.splashscreen.hide(); - } -}, false); \ No newline at end of file diff --git a/js/glowingbear.js b/js/glowingbear.js index caaed46..0d15ef1 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -1,6 +1,12 @@ (function() { 'use strict'; +document.addEventListener("deviceready", function () { + if (navigator.splashscreen !== undefined) { + navigator.splashscreen.hide(); + } +}, false); + var weechat = angular.module('weechat', ['ngRoute', 'localStorage', 'weechatModels', 'bufferResume', 'plugins', 'IrcUtils', 'ngSanitize', 'ngWebsockets', 'ngTouch'], ['$compileProvider', function($compileProvider) { // hacky way to be able to find out if we're in debug mode weechat.compileProvider = $compileProvider; From d87f274c73372ebd47e3436a36b6d97e7f094ed4 Mon Sep 17 00:00:00 2001 From: Alice Jenkinson Date: Sat, 18 Mar 2017 18:58:15 +1300 Subject: [PATCH 03/10] Hide some things on Cordova, fix links --- index.html | 55 +++++++++++++++++++++++++---------------------- js/filters.js | 10 +++++++++ js/glowingbear.js | 1 + js/utils.js | 5 +++++ 4 files changed, 45 insertions(+), 26 deletions(-) diff --git a/index.html b/index.html index a7f2c0d..68808ca 100644 --- a/index.html +++ b/index.html @@ -102,7 +102,7 @@
@@ -163,22 +163,24 @@ chown -R username:username ~username
-

Shortcuts

- Glowing Bear has a few shortcuts: -
    -
  • ALT-n: Toggle nicklist
  • -
  • ALT-l: Focus on input bar
  • -
  • ALT-[0-9]: Switch to buffer number N
  • -
  • ALT-↑/↓: Switch to buffer above/below
  • -
  • ALT-a: Focus on next buffer with activity
  • -
  • ALT-<: Switch to previous active buffer
  • -
  • ALT-g: Focus on buffer list filter
  • -
  • ALT-h: Clear unread counters in every buffer (locally)
  • -
  • Esc-Esc: Disconnect (double-tap)
  • -
  • Arrow keys: Navigate history, or navigate quick search buffer results.
  • -
  • Tab: Complete nick
  • -
  • The following readline/emacs style keybindings can be enabled with a setting: Ctrl-a, Ctrl-e, Ctrl-u, Ctrl-k, Ctrl-w
  • -
+
+

Shortcuts

+ Glowing Bear has a few shortcuts: +
    +
  • ALT-n: Toggle nicklist
  • +
  • ALT-l: Focus on input bar
  • +
  • ALT-[0-9]: Switch to buffer number N
  • +
  • ALT-↑/↓: Switch to buffer above/below
  • +
  • ALT-a: Focus on next buffer with activity
  • +
  • ALT-<: Switch to previous active buffer
  • +
  • ALT-g: Focus on buffer list filter
  • +
  • ALT-h: Clear unread counters in every buffer (locally)
  • +
  • Esc-Esc: Disconnect (double-tap)
  • +
  • Arrow keys: Navigate history, or navigate quick search buffer results.
  • +
  • Tab: Complete nick
  • +
  • The following readline/emacs style keybindings can be enabled with a setting: Ctrl-a, Ctrl-e, Ctrl-u, Ctrl-k, Ctrl-w
  • +
+

Pinning buffers

The option "Only show buffers with unread messages" is useful when you have a lot of buffers and can't meaningfully look at all of them at the same time. However, often you have a select few buffers that you use more frequently and would like to have displayed permanently. @@ -192,7 +194,7 @@ chown -R username:username ~username

-
+
-

Glowing bear is built by a small group of developers in their free time. As we're always trying to improve it, we would love getting your feedback and help. If that sounds like something you might enjoy, check out our project page on GitHub!

+

Glowing bear is built by a small group of developers in their free time. As we're always trying to improve it, we would love getting your feedback and help. If that sounds like something you might enjoy, check out our main project page and its mobile app spin-off on GitHub!

If you're interested in contributing or simply want to say hello, head over to #glowing-bear on freenode! We won't bite, promise :)

@@ -249,7 +251,7 @@ npm run build-electron-{windows, darwin, linux}
- + {{ activeBuffer().trimmedName || activeBuffer().fullName }}
@@ -315,7 +317,7 @@ npm run build-electron-{windows, darwin, linux} <>
+ --> @@ -344,7 +346,8 @@ npm run build-electron-{windows, darwin, linux} Glowing Bear version 0.7.0 -

Settings will be stored in your browser.

+

Settings will be stored in your browser.

+

Settings will be stored on your device.

-
  • +
  • -
  • +
  • -
  • +
  • -
  • +
  • -
  • +
  • -
  • +
  • -
  • +
  • -
  • +
  • -
  • +