summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2020-01-14 16:49:36 +0100
committerMichael Meeks <michael.meeks@collabora.com>2020-01-14 17:44:28 +0100
commit0a35e432ff17b1a80065c36d56069393bfba6bea (patch)
tree8d9b58b9c1f3fbd3fd7ae3e0921faebac531d82a
parent4da29f64227098fcbea3f01c7d701bdfd2aae049 (diff)
android: When the mobile-wizard is open, the Back button should go a level up.
Without this, we were closing the document, which was very annoying. Change-Id: I1e841da28c92c0e01284c2d7e2d4dbc6762bfffd Reviewed-on: https://gerrit.libreoffice.org/c/online/+/86779 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java26
-rw-r--r--loleaflet/src/control/Control.MobileWizard.js5
-rw-r--r--loleaflet/src/core/Socket.js5
-rw-r--r--wsd/protocol.txt6
4 files changed, 42 insertions, 0 deletions
diff --git a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java
index 713032122..030f35357 100644
--- a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java
+++ b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java
@@ -99,6 +99,9 @@ public class LOActivity extends AppCompatActivity {
private Handler nativeHandler;
private Looper nativeLooper;
+ /** In case the mobile-wizard is visible, we have to intercept the Android's Back button. */
+ private boolean mMobileWizardVisible = false;
+
private ValueCallback<Uri[]> valueCallback;
public static final int REQUEST_SELECT_FILE = 555;
@@ -448,6 +451,18 @@ public class LOActivity extends AppCompatActivity {
}
}
+ @Override
+ public void onBackPressed() {
+ if (mMobileWizardVisible)
+ {
+ // just return one level up in the mobile-wizard (or close it)
+ callFakeWebsocketOnMessage("'mobile: mobilewizardback'");
+ return;
+ }
+
+ super.onBackPressed();
+ }
+
private void loadDocument() {
// setup the LOOLWSD
ApplicationInfo applicationInfo = getApplicationInfo();
@@ -596,6 +611,17 @@ public class LOActivity extends AppCompatActivity {
});
return false;
}
+ case "MOBILEWIZARD": {
+ switch (messageAndParam[1]) {
+ case "show":
+ mMobileWizardVisible = true;
+ break;
+ case "hide":
+ mMobileWizardVisible = false;
+ break;
+ }
+ return false;
+ }
}
return true;
}
diff --git a/loleaflet/src/control/Control.MobileWizard.js b/loleaflet/src/control/Control.MobileWizard.js
index f186a2412..7b91d1a94 100644
--- a/loleaflet/src/control/Control.MobileWizard.js
+++ b/loleaflet/src/control/Control.MobileWizard.js
@@ -27,6 +27,7 @@ L.Control.MobileWizard = L.Control.extend({
map.on('mobilewizard', this._onMobileWizard, this);
map.on('closemobilewizard', this._hideWizard, this);
map.on('showwizardsidebar', this._showWizardSidebar, this);
+ map.on('mobilewizardback', this.goLevelUp, this);
this._setupBackButton();
},
@@ -58,6 +59,8 @@ L.Control.MobileWizard = L.Control.extend({
_showWizard: function() {
$('#mobile-wizard').show();
$('#toolbar-down').hide();
+ if (window.ThisIsTheAndroidApp)
+ window.postMobileMessage('MOBILEWIZARD show');
},
_showWizardSidebar: function() {
@@ -72,6 +75,8 @@ L.Control.MobileWizard = L.Control.extend({
if (this.map._permission === 'edit') {
$('#toolbar-down').show();
}
+ if (window.ThisIsTheAndroidApp)
+ window.postMobileMessage('MOBILEWIZARD hide');
this.map.showSidebar = false;
this._isActive = false;
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 653b71366..a65133d4c 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -755,6 +755,11 @@ L.Socket = L.Class.extend({
vex.closeAll();
}
}
+ else if (window.ThisIsAMobileApp && textMsg.startsWith('mobile:')) {
+ // allow passing some events easily from the mobile app
+ var mobileEvent = textMsg.substring('mobile: '.length);
+ this._map.fire(mobileEvent);
+ }
else if (!textMsg.startsWith('tile:') && !textMsg.startsWith('renderfont:') && !textMsg.startsWith('windowpaint:')) {
// log the tile msg separately as we need the tile coordinates
L.Log.log(textMsg, L.INCOMING);
diff --git a/wsd/protocol.txt b/wsd/protocol.txt
index 6e097587b..fd94c741f 100644
--- a/wsd/protocol.txt
+++ b/wsd/protocol.txt
@@ -544,6 +544,12 @@ shapeselectioncontent: <content>
Current selection's content
+mobile: <event>
+
+ Available only in the mobile (Android and iOS) apps. When you send
+ 'mobile: eventname', the socket code will fire a 'eventname' event on the
+ map.
+
child -> parent
===============