[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2' - android/lib loleaflet/css loleaflet/src
mert (via logerrit)
logerrit at kemper.freedesktop.org
Fri Aug 14 19:54:05 UTC 2020
android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java | 15 +++++++
loleaflet/css/toolbar.css | 1
loleaflet/src/control/Control.MobileTopBar.js | 2
loleaflet/src/control/Control.Toolbar.js | 8 +++
loleaflet/src/control/Control.UIManager.js | 21 +++++++++-
loleaflet/src/control/Permission.js | 6 ++
loleaflet/src/map/Map.js | 5 ++
7 files changed, 55 insertions(+), 3 deletions(-)
New commits:
commit 2e591af0322535e08bd4c2f3ad459e4e471f772a
Author: mert <mert.tumer at collabora.com>
AuthorDate: Wed Feb 12 20:53:34 2020 +0300
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Fri Aug 14 21:53:46 2020 +0200
android: back button switches to readonly mode instead of closing
Currently pressing back button on edit mode closes the document,
this patch may prevent unintentional touches
Change-Id: Ic7061186fa8794203fd4614c07a11b219d3a10d9
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100666
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Mert Tumer <mert.tumer at collabora.com>
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
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 24319e215..c131a983f 100644
--- a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java
+++ b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java
@@ -122,6 +122,7 @@ public class LOActivity extends AppCompatActivity {
/** In case the mobile-wizard is visible, we have to intercept the Android's Back button. */
private boolean mMobileWizardVisible = false;
+ private boolean mIsEditModeActive = false;
private ValueCallback<Uri[]> valueCallback;
@@ -693,6 +694,9 @@ public class LOActivity extends AppCompatActivity {
// just return one level up in the mobile-wizard (or close it)
callFakeWebsocketOnMessage("'mobile: mobilewizardback'");
return;
+ } else if (mIsEditModeActive) {
+ callFakeWebsocketOnMessage("'mobile: readonlymode'");
+ return;
}
finishWithProgress();
@@ -924,6 +928,17 @@ public class LOActivity extends AppCompatActivity {
startActivity(intent);
return false;
}
+ case "EDITMODE": {
+ switch (messageAndParam[1]) {
+ case "on":
+ mIsEditModeActive = true;
+ break;
+ case "off":
+ mIsEditModeActive = false;
+ break;
+ }
+ return false;
+ }
}
return true;
}
diff --git a/loleaflet/css/toolbar.css b/loleaflet/css/toolbar.css
index 604120e54..aed7e7e2b 100644
--- a/loleaflet/css/toolbar.css
+++ b/loleaflet/css/toolbar.css
@@ -710,6 +710,7 @@ button.leaflet-control-search-next
.w2ui-icon.users{ background: url('images/contacts-dark.svg') no-repeat center; }
.w2ui-icon.fullscreen{ background: url('images/lc_fullscreen.svg') no-repeat center !important; }
.w2ui-icon.closemobile{ background: url('images/lc_closedocmobile.svg') no-repeat center !important; }
+.w2ui-icon.editmode { background: url("images/lc_listitem-selected.svg") no-repeat center / 28px !important; }
.w2ui-icon.closetoolbar{ background: url('images/close_toolbar.svg') no-repeat center !important; }
.w2ui-icon.sidebar_modify_page{ background: url('images/lc_formproperties.svg') no-repeat center !important; }
.w2ui-icon.sidebar_slide_change{ background: url('images/sidebar-transition-large.svg') no-repeat center !important; }
diff --git a/loleaflet/src/control/Control.MobileTopBar.js b/loleaflet/src/control/Control.MobileTopBar.js
index d754f0a19..d7f259893 100644
--- a/loleaflet/src/control/Control.MobileTopBar.js
+++ b/loleaflet/src/control/Control.MobileTopBar.js
@@ -193,6 +193,7 @@ L.Control.MobileTopBar = L.Control.extend({
toolbarDownButtons.forEach(function(id) {
toolbar.enable(id);
});
+ toolbar.set('closemobile', {img: 'editmode'});
}
} else {
toolbar = w2ui['actionbar'];
@@ -200,6 +201,7 @@ L.Control.MobileTopBar = L.Control.extend({
toolbarDownButtons.forEach(function(id) {
toolbar.disable(id);
});
+ toolbar.set('closemobile', {img: 'closemobile'});
}
}
},
diff --git a/loleaflet/src/control/Control.Toolbar.js b/loleaflet/src/control/Control.Toolbar.js
index c1580f8d4..bc2f590ed 100644
--- a/loleaflet/src/control/Control.Toolbar.js
+++ b/loleaflet/src/control/Control.Toolbar.js
@@ -142,7 +142,7 @@ function onClick(e, id, item) {
map.uiManager.toggleMenubar();
}
else if (id === 'close' || id === 'closemobile') {
- onClose();
+ map.uiManager.enterReadonlyOrClose();
}
else if (id === 'link') {
map.showHyperlinkDialog();
@@ -971,6 +971,12 @@ function onUpdatePermission(e) {
toolbar.disable(items[idx].id);
}
}
+ if (e.perm === 'edit') {
+ toolbar.set('closemobile', {img: 'editmode'});
+ } else {
+ toolbar.set('closemobile', {img: 'closemobile'});
+ }
+
}
}
diff --git a/loleaflet/src/control/Control.UIManager.js b/loleaflet/src/control/Control.UIManager.js
index a379e2a8f..018f65661 100644
--- a/loleaflet/src/control/Control.UIManager.js
+++ b/loleaflet/src/control/Control.UIManager.js
@@ -187,9 +187,11 @@ L.Control.UIManager = L.Control.extend({
onUpdatePermission: function(e) {
if (window.mode.isMobile()) {
if (e.perm === 'edit') {
+ history.pushState({context: 'app-started'}, 'edit-mode');
$('#toolbar-down').show();
}
else {
+ history.pushState({context: 'app-started'}, 'readonly-mode');
$('#toolbar-down').hide();
}
}
@@ -198,16 +200,31 @@ L.Control.UIManager = L.Control.extend({
this.map.invalidateSize();
},
+ enterReadonlyOrClose: function() {
+ if (this.map.isPermissionEdit()) {
+ // in edit mode, passing 'edit' actually enters readonly mode
+ // and bring the blue circle editmode button back
+ this.map.setPermission('edit');
+ var toolbar = w2ui['actionbar'];
+ if (toolbar) {
+ toolbar.uncheck('closemobile');
+ toolbar.uncheck('close');
+ }
+ } else {
+ window.onClose();
+ }
+ },
+
onGoBack: function(popStateEvent) {
if (popStateEvent.state && popStateEvent.state.context) {
if (popStateEvent.state.context === 'mobile-wizard' && this.mobileWizard) {
if (this.mobileWizard.isOpen()) {
this.mobileWizard.goLevelUp(true);
} else {
- window.onClose();
+ this.enterReadonlyOrClose();
}
} else if (popStateEvent.state.context === 'app-started') {
- window.onClose();
+ this.enterReadonlyOrClose();
}
}
},
diff --git a/loleaflet/src/control/Permission.js b/loleaflet/src/control/Permission.js
index abccd8d06..16ffe7742 100644
--- a/loleaflet/src/control/Permission.js
+++ b/loleaflet/src/control/Permission.js
@@ -100,6 +100,8 @@ L.Map.include({
this.setZoom(10);
}
+ if (window.ThisIsTheAndroidApp)
+ window.postMobileMessage('EDITMODE on');
},
_enterReadOnlyMode: function (perm) {
@@ -112,6 +114,10 @@ L.Map.include({
this._docLayer._onUpdateTextSelection();
this.fire('updatepermission', {perm : perm});
+ this.fire('closemobilewizard');
+
+ if (window.ThisIsTheAndroidApp)
+ window.postMobileMessage('EDITMODE off');
},
enableSelection: function () {
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 37e703de9..d6ce7741a 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -226,6 +226,11 @@ L.Map = L.Evented.extend({
this._fireInitComplete('CharFontName');
}
});
+ if (window.ThisIsTheAndroidApp) {
+ this.on('readonlymode', function() {
+ this.setPermission('edit');
+ });
+ }
this.showBusy(_('Initializing...'), false);
this.on('statusindicator', this._onUpdateProgress, this);
More information about the Libreoffice-commits
mailing list