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@gmail.com> Reviewed-by: Mert Tumer <mert.tumer@collabora.com> Reviewed-by: Jan Holesovsky <kendy@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88555
This commit is contained in:
parent
661852ab6f
commit
4cd1baa02d
7 changed files with 56 additions and 3 deletions
|
@ -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;
|
||||
|
||||
|
@ -697,6 +698,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();
|
||||
|
@ -928,6 +932,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;
|
||||
}
|
||||
|
|
|
@ -753,6 +753,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; }
|
||||
|
|
|
@ -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'});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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();
|
||||
|
@ -979,6 +979,12 @@ function onUpdatePermission(e) {
|
|||
toolbar.disable(items[idx].id);
|
||||
}
|
||||
}
|
||||
if (e.perm === 'edit') {
|
||||
toolbar.set('closemobile', {img: 'editmode'});
|
||||
} else {
|
||||
toolbar.set('closemobile', {img: 'closemobile'});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -265,9 +265,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();
|
||||
}
|
||||
}
|
||||
|
@ -292,16 +294,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();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -99,6 +99,9 @@ L.Map.include({
|
|||
if (this._docLayer._docType === 'text') {
|
||||
this.setZoom(10);
|
||||
}
|
||||
|
||||
if (window.ThisIsTheAndroidApp)
|
||||
window.postMobileMessage('EDITMODE on');
|
||||
},
|
||||
|
||||
_enterReadOnlyMode: function (perm) {
|
||||
|
@ -112,6 +115,10 @@ L.Map.include({
|
|||
this._docLayer._onUpdateTextSelection();
|
||||
}
|
||||
this.fire('updatepermission', {perm : perm});
|
||||
this.fire('closemobilewizard');
|
||||
|
||||
if (window.ThisIsTheAndroidApp)
|
||||
window.postMobileMessage('EDITMODE off');
|
||||
},
|
||||
|
||||
enableSelection: function () {
|
||||
|
|
|
@ -215,6 +215,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);
|
||||
|
|
Loading…
Reference in a new issue