Browse Source

Cleanup the Android related code

Translate the action button for Push Notifications
Update the dependencies
pull/1058/head
Timothée Jaussoin 4 years ago
parent
commit
b26e7c3abd
  1. 2
      app/widgets/Chat/Chat.php
  2. 12
      app/widgets/Login/login.tpl
  3. 21
      app/widgets/Notification/Notification.php
  4. 15
      app/widgets/Notification/notification.js
  5. 6
      app/widgets/Toast/toast.js
  6. 8
      app/widgets/Visio/visio.js
  7. 6
      app/widgets/VisioLink/visiolink.js
  8. 46
      composer.lock
  9. 1
      locales/locales.ini
  10. 2
      public/sw.js

2
app/widgets/Chat/Chat.php

@ -357,7 +357,6 @@ class Chat extends \Movim\Widget\Base
$this->rpc('Chat.setObservers');
$this->prepareMessages($jid);
$this->rpc('Notification.current', 'chat|'.$jid);
Notification::clearAndroid($this->route('chat', [$jid]));
$this->rpc('Chat.scrollToSeparator');
// OMEMO
@ -407,7 +406,6 @@ class Chat extends \Movim\Widget\Base
$this->rpc('Chat.setObservers');
$this->prepareMessages($room, true);
$this->rpc('Notification.current', 'chat|'.$room);
Notification::clearAndroid($this->route('chat', [$room, 'room']));
$this->rpc('Chat.scrollToSeparator');
// OMEMO

12
app/widgets/Login/login.tpl

@ -190,22 +190,10 @@
<footer>
<a href="https://movim.eu" target="_blank" class="on_desktop"></a>
<!--<a class="button flat color green" href="https://play.google.com/store/apps/details?id=com.movim.movim" target="_blank">
<i class="material-icons">android</i> Play Store
</a>
<a class="button flat color purple on_desktop" href="https://movim.eu/#apps" target="_blank">
<i class="material-icons">computer</i> Apps
</a>-->
<a class="button flat color transparent on_android" href="movim://changepod">
<i class="material-icons">dns</i>
{$c->__('global.change_pod')}
</a>
<br />
</footer>
<script type="text/javascript">
if (typeof Android !== 'undefined') {
MovimTpl.remove('#login_widget footer');
}
</script>
</div>

21
app/widgets/Notification/Notification.php

@ -46,15 +46,6 @@ class Notification extends Base
self::rpcCall(null);
}
/**
* Clear the notification for Android using a local event and
* push notification event
*/
public static function clearAndroid(string $action)
{
RPC::call('Notification.clearAndroid', $action);
}
/**
* @brief Notify something
*
@ -117,7 +108,9 @@ class Notification extends Base
'body' => $body,
'picture' => $picture,
'action' => $action,
'group' => $group,
'execute' => $execute,
'button' => __('button.open')
])
);
}
@ -138,16 +131,6 @@ class Notification extends Base
$explode = explode('|', $key);
$first = reset($explode);
// What we receive is not what it's on the screen on Android
if ($key != null && $key != $notifsKey && $title != null) {
if ($group != null) {
$action = $group;
}
// We try to deliver it trough the WebSocket
RPC::call('Notification.android', $title, $body, $picture, $action);
}
if (array_key_exists($first, $notifs)) {
$notifs[$first]++;
} else {

15
app/widgets/Notification/notification.js

@ -129,8 +129,7 @@ var Notification = {
Notification_ajaxCurrent(Notification.notifs_key);
},
snackbar : function(html, time) {
if (typeof Android !== 'undefined'
|| Notification.inhibed == true) return;
if (Notification.inhibed == true) return;
target = document.getElementById('snackbar');
@ -191,18 +190,6 @@ var Notification = {
DesktopNotification.requestPermission();
}
},
android : function(title, body, picture, action) {
if (typeof Android !== 'undefined') {
Android.showNotification(title, body, picture, action);
return;
}
},
clearAndroid : function(action) {
if (typeof Android !== 'undefined') {
Android.clearNotifications(action);
return;
}
},
focus : function() {
if (Notification.focused == false) {
Notification.focused = true;

6
app/widgets/Toast/toast.js

@ -1,11 +1,5 @@
var Toast = {
send : function(title) {
// Android notification
if (typeof Android !== 'undefined') {
Android.showToast(title);
return;
}
target = document.getElementById('toast');
if (target) {

8
app/widgets/Visio/visio.js

@ -324,19 +324,11 @@ var Visio = {
button.onclick = () => {
window.close();
if (typeof Android !== 'undefined') {
Android.closePopUpWebview();
}
}
// And we force close the window after 2sec
window.setTimeout(() => {
window.close();
if (typeof Android !== 'undefined') {
Android.closePopUpWebview();
}
}, 2000);
},

6
app/widgets/VisioLink/visiolink.js

@ -4,10 +4,6 @@ var VisioLink = {
var idUrl = id ? '/' + id : '';
var page = withVideo ? 'visio' : 'visioaudio';
if (typeof Android !== 'undefined') {
Android.openVisio(BASE_HOST + '/' + '?' + page + '/' + from + idUrl);
} else {
VisioLink.window = window.open('?' + page + '/' + from + idUrl, '', 'width=600,height=400,status=0,titlebar=0,toolbar=0,menubar=0');
}
VisioLink.window = window.open('?' + page + '/' + from + idUrl, '', 'width=600,height=400,status=0,titlebar=0,toolbar=0,menubar=0');
}
}

46
composer.lock

@ -1828,7 +1828,7 @@
},
{
"name": "illuminate/bus",
"version": "v8.83.7",
"version": "v8.83.8",
"source": {
"type": "git",
"url": "https://github.com/illuminate/bus.git",
@ -1881,7 +1881,7 @@
},
{
"name": "illuminate/collections",
"version": "v8.83.7",
"version": "v8.83.8",
"source": {
"type": "git",
"url": "https://github.com/illuminate/collections.git",
@ -1935,7 +1935,7 @@
},
{
"name": "illuminate/container",
"version": "v8.83.7",
"version": "v8.83.8",
"source": {
"type": "git",
"url": "https://github.com/illuminate/container.git",
@ -1986,7 +1986,7 @@
},
{
"name": "illuminate/contracts",
"version": "v8.83.7",
"version": "v8.83.8",
"source": {
"type": "git",
"url": "https://github.com/illuminate/contracts.git",
@ -2034,16 +2034,16 @@
},
{
"name": "illuminate/database",
"version": "v8.83.7",
"version": "v8.83.8",
"source": {
"type": "git",
"url": "https://github.com/illuminate/database.git",
"reference": "ab8052c033036383fc2811fc9a518b5984e040a9"
"reference": "5a09b780d86613127cddbeb05e4dde22aeccbedf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/database/zipball/ab8052c033036383fc2811fc9a518b5984e040a9",
"reference": "ab8052c033036383fc2811fc9a518b5984e040a9",
"url": "https://api.github.com/repos/illuminate/database/zipball/5a09b780d86613127cddbeb05e4dde22aeccbedf",
"reference": "5a09b780d86613127cddbeb05e4dde22aeccbedf",
"shasum": ""
},
"require": {
@ -2098,11 +2098,11 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2022-03-21T16:13:31+00:00"
"time": "2022-04-07T15:04:12+00:00"
},
{
"name": "illuminate/events",
"version": "v8.83.7",
"version": "v8.83.8",
"source": {
"type": "git",
"url": "https://github.com/illuminate/events.git",
@ -2157,7 +2157,7 @@
},
{
"name": "illuminate/macroable",
"version": "v8.83.7",
"version": "v8.83.8",
"source": {
"type": "git",
"url": "https://github.com/illuminate/macroable.git",
@ -2203,7 +2203,7 @@
},
{
"name": "illuminate/pipeline",
"version": "v8.83.7",
"version": "v8.83.8",
"source": {
"type": "git",
"url": "https://github.com/illuminate/pipeline.git",
@ -2251,16 +2251,16 @@
},
{
"name": "illuminate/support",
"version": "v8.83.7",
"version": "v8.83.8",
"source": {
"type": "git",
"url": "https://github.com/illuminate/support.git",
"reference": "5dd2ffb98c6169f8fcf84c065da3c27289e737af"
"reference": "3f1de19528fc235d666f73d540d13a684da6bf3a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/support/zipball/5dd2ffb98c6169f8fcf84c065da3c27289e737af",
"reference": "5dd2ffb98c6169f8fcf84c065da3c27289e737af",
"url": "https://api.github.com/repos/illuminate/support/zipball/3f1de19528fc235d666f73d540d13a684da6bf3a",
"reference": "3f1de19528fc235d666f73d540d13a684da6bf3a",
"shasum": ""
},
"require": {
@ -2315,7 +2315,7 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2022-04-04T15:14:19+00:00"
"time": "2022-04-11T14:26:37+00:00"
},
{
"name": "league/commonmark",
@ -2568,16 +2568,16 @@
},
{
"name": "monolog/monolog",
"version": "2.4.0",
"version": "2.5.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "d7fd7450628561ba697b7097d86db72662f54aef"
"reference": "4192345e260f1d51b365536199744b987e160edc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/d7fd7450628561ba697b7097d86db72662f54aef",
"reference": "d7fd7450628561ba697b7097d86db72662f54aef",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/4192345e260f1d51b365536199744b987e160edc",
"reference": "4192345e260f1d51b365536199744b987e160edc",
"shasum": ""
},
"require": {
@ -2651,7 +2651,7 @@
],
"support": {
"issues": "https://github.com/Seldaek/monolog/issues",
"source": "https://github.com/Seldaek/monolog/tree/2.4.0"
"source": "https://github.com/Seldaek/monolog/tree/2.5.0"
},
"funding": [
{
@ -2663,7 +2663,7 @@
"type": "tidelift"
}
],
"time": "2022-03-14T12:44:37+00:00"
"time": "2022-04-08T15:43:54+00:00"
},
{
"name": "nesbot/carbon",

1
locales/locales.ini

@ -86,6 +86,7 @@ sign_up = Sign Up
send_to = Send to
more = More
copy_link = Copy Link
open = Open
[input]
username = Username

2
public/sw.js

@ -48,7 +48,7 @@ self.addEventListener('push', function(e) {
icon: json.picture,
vibrate: [100, 50, 100],
data: { url: json.action },
actions: [{action: "action", title: 'Open chat'}]
actions: [{action: "action", title: json.button}]
};
e.waitUntil(
self.registration.showNotification(json.title, options)

Loading…
Cancel
Save