Merge pull request #1243 from torhve/removecordova

Remove all corodova stuff
This commit is contained in:
Tor Hveem 2023-02-16 19:16:02 +01:00 committed by GitHub
commit c6d4613aea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 74 deletions

View File

@ -71,4 +71,4 @@ If you wish to submit code, we try to make the contribution process as simple as
We'd also like to ask you to join our IRC channel, #glowing-bear on libera, so we can discuss your ideas and changes. We'd also like to ask you to join our IRC channel, #glowing-bear on libera, so we can discuss your ideas and changes.
If you're curious about the projects we're using, here's a list: [AngularJS](https://angularjs.org/), [Bootstrap](http://getbootstrap.com/), [Underscore](http://underscorejs.org/), [favico.js](http://lab.ejci.net/favico.js/), Emoji provided free by [Emoji One](http://emojione.com/), and [zlib.js](https://github.com/imaya/zlib.js). Technology-wise, [WebSockets](https://en.wikipedia.org/wiki/WebSocket) are the most important part, but we also use [local storage](https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage#localStorage), the [Notification Web API](https://developer.mozilla.org/en/docs/Web/API/notification), and last (but not least) [Apache Cordova](https://cordova.apache.org/) for our mobile app (currently unmaintained and unavailable). If you're curious about the projects we're using, here's a list: [AngularJS](https://angularjs.org/), [Bootstrap](http://getbootstrap.com/), [Underscore](http://underscorejs.org/), [favico.js](http://lab.ejci.net/favico.js/), Emoji provided free by [Emoji One](http://emojione.com/), and [zlib.js](https://github.com/imaya/zlib.js). Technology-wise, [WebSockets](https://en.wikipedia.org/wiki/WebSocket) are the most important part, but we also use [local storage](https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage#localStorage), the [Notification Web API](https://developer.mozilla.org/en/docs/Web/API/notification), and last (but not least) [Tauri](https://tauri.app/) for our standalone apps for different platforms.

View File

@ -306,8 +306,6 @@ npm install electron-packager
npm run build-electron-{windows, darwin, linux}</pre> npm run build-electron-{windows, darwin, linux}</pre>
<h3>Chrome</h3> <h3>Chrome</h3>
<p>To install Glowing Bear as an app in Chrome for Android, select <kbd>Menu - Add to home screen</kbd>. In the desktop version of Chrome, click <kbd>Menu - More tools - Create application shortcuts</kbd>.</p> <p>To install Glowing Bear as an app in Chrome for Android, select <kbd>Menu - Add to home screen</kbd>. In the desktop version of Chrome, click <kbd>Menu - More tools - Create application shortcuts</kbd>.</p>
<h3>Android App</h3>
<p>We used to have an Android app, but discontinued it for lack of maintainers. You can still build it for yourself, see <a href="https://github.com/glowing-bear/glowing-bear-cordova">the app repository</a> for instructions. Sorry!</p>
<h3>Firefox Browser</h3> <h3>Firefox Browser</h3>
<p>Firefox used to support apps, but this was removed from Firefox. There&apos;s nothing we can do about it. Sorry!</p> <p>Firefox used to support apps, but this was removed from Firefox. There&apos;s nothing we can do about it. Sorry!</p>
</div> </div>

View File

@ -5,13 +5,6 @@ import * as _ from "underscore";
import { connectionFactory } from './connection'; import { connectionFactory } from './connection';
// cordova splash screen
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) { 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 // hacky way to be able to find out if we're in debug mode
weechat.compileProvider = $compileProvider; weechat.compileProvider = $compileProvider;
@ -59,7 +52,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
'onlyUnread': false, 'onlyUnread': false,
'hotlistsync': true, 'hotlistsync': true,
'orderbyserver': true, 'orderbyserver': true,
'useFavico': !utils.isCordova(), 'useFavico': true,
'soundnotification': true, 'soundnotification': true,
'fontsize': '14px', 'fontsize': '14px',
'fontfamily': (utils.isMobileUi() ? 'sans-serif' : 'Inconsolata, Consolas, Monaco, Ubuntu Mono, monospace'), 'fontfamily': (utils.isMobileUi() ? 'sans-serif' : 'Inconsolata, Consolas, Monaco, Ubuntu Mono, monospace'),
@ -118,10 +111,10 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
})(); })();
// Show a TLS warning if GB was loaded over an unencrypted connection, // Show a TLS warning if GB was loaded over an unencrypted connection,
// except for local instances (local files, testing, cordova, or electron) // except for local instances (local files, testing)
$scope.show_tls_warning = (["https:", "file:"].indexOf(window.location.protocol) === -1) && $scope.show_tls_warning = (["https:", "file:"].indexOf(window.location.protocol) === -1) &&
(["localhost", "127.0.0.1", "::1"].indexOf(window.location.hostname) === -1) && (["localhost", "127.0.0.1", "::1"].indexOf(window.location.hostname) === -1) &&
!window.is_electron && !utils.isCordova(); !window.is_electron;
$rootScope.isWindowFocused = function() { $rootScope.isWindowFocused = function() {
if (typeof $scope.documentHidden === "undefined") { if (typeof $scope.documentHidden === "undefined") {
@ -253,9 +246,8 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
} }
}); });
if (!utils.isCordova()) { $rootScope.favico = new Favico({animation: 'none'});
$rootScope.favico = new Favico({animation: 'none'});
}
$scope.notifications = notifications.unreadCount('notification'); $scope.notifications = notifications.unreadCount('notification');
$scope.unread = notifications.unreadCount('unread'); $scope.unread = notifications.unreadCount('unread');
@ -264,7 +256,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$scope.notifications = notifications.unreadCount('notification'); $scope.notifications = notifications.unreadCount('notification');
$scope.unread = notifications.unreadCount('unread'); $scope.unread = notifications.unreadCount('unread');
if (!utils.isCordova() && settings.useFavico && $rootScope.favico) { if (settings.useFavico && $rootScope.favico) {
notifications.updateFavico(); notifications.updateFavico();
} }
}); });
@ -274,11 +266,8 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$rootScope.pageTitle = ''; $rootScope.pageTitle = '';
$rootScope.notificationStatus = ''; $rootScope.notificationStatus = '';
// cancel outstanding notifications (incl cordova) // cancel outstanding notifications
notifications.cancelAll(); notifications.cancelAll();
if (window.plugin !== undefined && window.plugin.notification !== undefined && window.plugin.notification.local !== undefined) {
window.plugin.notification.local.cancelAll();
}
models.reinitialize(); models.reinitialize();
$rootScope.$emit('notificationChanged'); $rootScope.$emit('notificationChanged');
@ -436,10 +425,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
return; return;
} }
if (utils.isCordova()) {
return; // cordova doesn't have a favicon
}
if (useFavico) { if (useFavico) {
notifications.updateFavico(); notifications.updateFavico();
} else { } else {
@ -453,8 +438,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// This also fires when the page is loaded if enabled. // This also fires when the page is loaded if enabled.
// Note that this says MathJax but we switched to KaTeX // Note that this says MathJax but we switched to KaTeX
settings.addCallback('enableMathjax', function(enabled) { settings.addCallback('enableMathjax', function(enabled) {
// no latex math support for cordova right now if (enabled && !$rootScope.mathjax_init) {
if (!utils.isCordova() && enabled && !$rootScope.mathjax_init) {
// Load MathJax only once // Load MathJax only once
$rootScope.mathjax_init = true; $rootScope.mathjax_init = true;
@ -1012,10 +996,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
if ($rootScope.connected) { if ($rootScope.connected) {
$scope.disconnect(); $scope.disconnect();
} }
if (!utils.isCordova()) {
$scope.favico.reset();
}
} }
}; };

View File

@ -34,21 +34,6 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', 'u
$log.info('Service Worker err:', err); $log.info('Service Worker err:', err);
}); });
} }
document.addEventListener('deviceready', function() {
// Add cordova local notification click handler
if (utils.isCordova() && window.cordova.plugins !== undefined && window.cordova.plugins.notification !== undefined &&
window.cordova.plugins.notification.local !== undefined) {
window.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
window.cordova.plugins.notification.local.clear(notification.id);
});
}
});
}; };
var showNotification = function(buffer, title, body) { var showNotification = function(buffer, title, body) {
@ -114,25 +99,7 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', 'u
notification.onclose = function() { notification.onclose = function() {
delete notifications[this.id]; delete notifications[this.id];
}; };
} else if (utils.isCordova() && window.cordova.plugins !== undefined && window.cordova.plugins.notification !== undefined && window.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)
window.cordova.plugins.notification.local.clear(id);
// Send new notification
window.cordova.plugins.notification.local.schedule({
id: id,
text: body,
title: title,
data: { buffer: buffer.id } // remember buffer id for when the notification is clicked
});
} }
}; };
@ -175,10 +142,6 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', 'u
}; };
var updateFavico = function() { var updateFavico = function() {
if (utils.isCordova()) {
return; // cordova doesn't have a favicon
}
var notifications = unreadCount('notification'); var notifications = unreadCount('notification');
if (notifications > 0) { if (notifications > 0) {
$rootScope.favico.badge(notifications, { $rootScope.favico.badge(notifications, {
@ -244,7 +207,7 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', 'u
showNotification(buffer, title, body); showNotification(buffer, title, body);
if (!utils.isCordova() && settings.soundnotification) { if (settings.soundnotification) {
var audioFile = "assets/audio/sonar"; var audioFile = "assets/audio/sonar";
var soundHTML = '<audio autoplay="autoplay"><source src="' + audioFile + '.ogg" type="audio/ogg" /><source src="' + audioFile + '.mp3" type="audio/mpeg" /></audio>'; var soundHTML = '<audio autoplay="autoplay"><source src="' + audioFile + '.ogg" type="audio/ogg" /><source src="' + audioFile + '.mp3" type="audio/mpeg" /></audio>';
document.getElementById("soundNotification").innerHTML = soundHTML; document.getElementById("soundNotification").innerHTML = soundHTML;

View File

@ -24,10 +24,6 @@ weechat.factory('utils', function() {
return (document.body.clientWidth < mobile_cutoff); return (document.body.clientWidth < mobile_cutoff);
}; };
var isCordova = function() {
return window.cordova !== undefined;
};
const _isTauri = window.__TAURI__ !== undefined; const _isTauri = window.__TAURI__ !== undefined;
var isTauri = function() { var isTauri = function() {
return _isTauri; return _isTauri;
@ -90,7 +86,6 @@ weechat.factory('utils', function() {
changeClassStyle: changeClassStyle, changeClassStyle: changeClassStyle,
getClassStyle: getClassStyle, getClassStyle: getClassStyle,
isMobileUi: isMobileUi, isMobileUi: isMobileUi,
isCordova: isCordova,
isTauri: isTauri, isTauri: isTauri,
inject_script: inject_script, inject_script: inject_script,
inject_css: inject_css, inject_css: inject_css,