From a0437e9dbcefdb431382f338af171662fab4e09f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 20 Apr 2022 23:44:59 +0300 Subject: [PATCH] [Mobile] Add live viewer, check license --- .../collaboration/Collaboration.jsx | 5 ++++ .../mobile/src/controller/Main.jsx | 24 +++++++++++++------ .../mobile/src/store/appOptions.js | 2 ++ .../mobile/src/controller/Main.jsx | 21 +++++++++++----- .../mobile/src/store/appOptions.js | 2 ++ .../mobile/src/controller/Main.jsx | 20 +++++++++++----- .../mobile/src/store/appOptions.js | 2 ++ 7 files changed, 57 insertions(+), 19 deletions(-) diff --git a/apps/common/mobile/lib/controller/collaboration/Collaboration.jsx b/apps/common/mobile/lib/controller/collaboration/Collaboration.jsx index 6cb82db7c..31e8b7b5f 100644 --- a/apps/common/mobile/lib/controller/collaboration/Collaboration.jsx +++ b/apps/common/mobile/lib/controller/collaboration/Collaboration.jsx @@ -46,6 +46,11 @@ class CollaborationController extends Component { api.asc_SetFastCollaborative(isFastCoauth); window.editorType === 'de' && api.SetCollaborativeMarksShowType(Asc.c_oAscCollaborativeMarksShowType.None); api.asc_setAutoSaveGap(1); + } else if (appOptions.canLiveView) { // viewer + isFastCoauth = !(appOptions.config.coEditing && appOptions.config.coEditing.mode==='strict'); + api.asc_SetFastCollaborative(isFastCoauth); + window.editorType === 'de' && api.SetCollaborativeMarksShowType(Asc.c_oAscCollaborativeMarksShowType.None); + api.asc_setAutoSaveGap(1); } else { isFastCoauth = false; api.asc_SetFastCollaborative(isFastCoauth); diff --git a/apps/documenteditor/mobile/src/controller/Main.jsx b/apps/documenteditor/mobile/src/controller/Main.jsx index 12babf8d8..24c7f9281 100644 --- a/apps/documenteditor/mobile/src/controller/Main.jsx +++ b/apps/documenteditor/mobile/src/controller/Main.jsx @@ -133,18 +133,18 @@ class MainController extends Component { docInfo.put_Lang(this.editorConfig.lang); docInfo.put_Mode(this.editorConfig.mode); - // var coEditMode = !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object') ? 'fast' : // fast by default - // this.editorConfig.mode === 'view' && this.editorConfig.coEditing.change!==false ? 'fast' : // if can change mode in viewer - set fast for using live viewer - // this.editorConfig.coEditing.mode || 'fast'; - // docInfo.put_CoEditingMode(coEditMode); - docInfo.put_CoEditingMode('strict'); // need to change!!! + let type = /^(?:(pdf|djvu|xps|oxps))$/.exec(data.doc.fileType); + let coEditMode = (type && typeof type[1] === 'string') ? 'strict' : // offline viewer for pdf|djvu|xps|oxps + !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object') ? 'fast' : // fast by default + this.editorConfig.mode === 'view' && this.editorConfig.coEditing.change!==false ? 'fast' : // if can change mode in viewer - set fast for using live viewer + this.editorConfig.coEditing.mode || 'fast'; + docInfo.put_CoEditingMode(coEditMode); let enable = !this.editorConfig.customization || (this.editorConfig.customization.macros !== false); docInfo.asc_putIsEnabledMacroses(!!enable); enable = !this.editorConfig.customization || (this.editorConfig.customization.plugins !== false); docInfo.asc_putIsEnabledPlugins(!!enable); - let type = /^(?:(pdf|djvu|xps|oxps))$/.exec(data.doc.fileType); if (type && typeof type[1] === 'string') { this.permissions.edit = this.permissions.review = false; } @@ -426,6 +426,10 @@ class MainController extends Component { (licType === Asc.c_oLicenseResult.Connections || licType === Asc.c_oLicenseResult.UsersCount || licType === Asc.c_oLicenseResult.ConnectionsOS || licType === Asc.c_oLicenseResult.UsersCountOS || licType === Asc.c_oLicenseResult.SuccessLimit && (appOptions.trialMode & Asc.c_oLicenseMode.Limited) !== 0)) this._state.licenseType = licType; + + if (licType !== undefined && appOptions.canLiveView && (licType===Asc.c_oLicenseResult.ConnectionsLive || licType===Asc.c_oLicenseResult.ConnectionsLiveOS)) + this._state.licenseType = licType; + if (this._isDocReady && this._state.licenseType) this.applyLicense(); } @@ -457,7 +461,13 @@ class MainController extends Component { return; } - if (this._state.licenseType) { + if (appOptions.config.mode === 'view') { + if (appOptions.canLiveView && (this._state.licenseType===Asc.c_oLicenseResult.ConnectionsLive || this._state.licenseType===Asc.c_oLicenseResult.ConnectionsLiveOS)) { + appOptions.canLiveView = false; + this.api.asc_SetFastCollaborative(false); + } + Common.Notifications.trigger('toolbar:activatecontrols'); + } else if (this._state.licenseType) { let license = this._state.licenseType; let buttons = [{text: 'OK'}]; if ((appOptions.trialMode & Asc.c_oLicenseMode.Limited) !== 0 && diff --git a/apps/documenteditor/mobile/src/store/appOptions.js b/apps/documenteditor/mobile/src/store/appOptions.js index 83a839d05..caf9cea01 100644 --- a/apps/documenteditor/mobile/src/store/appOptions.js +++ b/apps/documenteditor/mobile/src/store/appOptions.js @@ -145,6 +145,8 @@ export class storeAppOptions { this.canUseReviewPermissions && AscCommon.UserInfoParser.setReviewPermissions(permissions.reviewGroups, this.customization.reviewPermissions); this.canUseCommentPermissions && AscCommon.UserInfoParser.setCommentPermissions(permissions.commentGroups); this.canUseUserInfoPermissions && AscCommon.UserInfoParser.setUserInfoPermissions(permissions.userInfoGroups); + + this.canLiveView = !!params.asc_getLiveViewerSupport() && (this.config.mode === 'view') && !(type && typeof type[1] === 'string') && isSupportEditFeature; } setCanViewReview (value) { this.canViewReview = value; diff --git a/apps/presentationeditor/mobile/src/controller/Main.jsx b/apps/presentationeditor/mobile/src/controller/Main.jsx index 50f654eeb..c95d8f00f 100644 --- a/apps/presentationeditor/mobile/src/controller/Main.jsx +++ b/apps/presentationeditor/mobile/src/controller/Main.jsx @@ -124,11 +124,10 @@ class MainController extends Component { docInfo.put_Lang(this.editorConfig.lang); docInfo.put_Mode(this.editorConfig.mode); - // var coEditMode = !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object') ? 'fast' : // fast by default - // this.editorConfig.mode === 'view' && this.editorConfig.coEditing.change!==false ? 'fast' : // if can change mode in viewer - set fast for using live viewer - // this.editorConfig.coEditing.mode || 'fast'; - // docInfo.put_CoEditingMode(coEditMode); - docInfo.put_CoEditingMode('strict'); // need to change!!! + let coEditMode = !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object') ? 'fast' : // fast by default + this.editorConfig.mode === 'view' && this.editorConfig.coEditing.change!==false ? 'fast' : // if can change mode in viewer - set fast for using live viewer + this.editorConfig.coEditing.mode || 'fast'; + docInfo.put_CoEditingMode(coEditMode); let enable = !this.editorConfig.customization || (this.editorConfig.customization.macros !== false); docInfo.asc_putIsEnabledMacroses(!!enable); @@ -499,6 +498,10 @@ class MainController extends Component { (licType === Asc.c_oLicenseResult.Connections || licType === Asc.c_oLicenseResult.UsersCount || licType === Asc.c_oLicenseResult.ConnectionsOS || licType === Asc.c_oLicenseResult.UsersCountOS || licType === Asc.c_oLicenseResult.SuccessLimit && (appOptions.trialMode & Asc.c_oLicenseMode.Limited) !== 0)) this._state.licenseType = licType; + + if (licType !== undefined && appOptions.canLiveView && (licType===Asc.c_oLicenseResult.ConnectionsLive || licType===Asc.c_oLicenseResult.ConnectionsLiveOS)) + this._state.licenseType = licType; + if (this._isDocReady && this._state.licenseType) this.applyLicense(); } @@ -530,7 +533,13 @@ class MainController extends Component { return; } - if (this._state.licenseType) { + if (appOptions.config.mode === 'view') { + if (appOptions.canLiveView && (this._state.licenseType===Asc.c_oLicenseResult.ConnectionsLive || this._state.licenseType===Asc.c_oLicenseResult.ConnectionsLiveOS)) { + appOptions.canLiveView = false; + this.api.asc_SetFastCollaborative(false); + } + Common.Notifications.trigger('toolbar:activatecontrols'); + } else if (this._state.licenseType) { let license = this._state.licenseType; let buttons = [{text: 'OK'}]; if ((appOptions.trialMode & Asc.c_oLicenseMode.Limited) !== 0 && diff --git a/apps/presentationeditor/mobile/src/store/appOptions.js b/apps/presentationeditor/mobile/src/store/appOptions.js index 97b83a381..8b187331b 100644 --- a/apps/presentationeditor/mobile/src/store/appOptions.js +++ b/apps/presentationeditor/mobile/src/store/appOptions.js @@ -116,5 +116,7 @@ export class storeAppOptions { this.canUseReviewPermissions && AscCommon.UserInfoParser.setReviewPermissions(permissions.reviewGroups, this.customization.reviewPermissions); this.canUseCommentPermissions && AscCommon.UserInfoParser.setCommentPermissions(permissions.commentGroups); this.canUseUserInfoPermissions && AscCommon.UserInfoParser.setUserInfoPermissions(permissions.userInfoGroups); + + this.canLiveView = !!params.asc_getLiveViewerSupport() && (this.config.mode === 'view') && isSupportEditFeature; } } \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx index 76ab31109..39bb6e933 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx @@ -171,11 +171,10 @@ class MainController extends Component { docInfo.put_Lang(this.editorConfig.lang); docInfo.put_Mode(this.editorConfig.mode); - // var coEditMode = !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object') ? 'fast' : // fast by default - // this.editorConfig.mode === 'view' && this.editorConfig.coEditing.change!==false ? 'fast' : // if can change mode in viewer - set fast for using live viewer - // this.editorConfig.coEditing.mode || 'fast'; - // docInfo.put_CoEditingMode(coEditMode); - docInfo.put_CoEditingMode('strict'); // need to change!!! + let coEditMode = !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object') ? 'fast' : // fast by default + this.editorConfig.mode === 'view' && this.editorConfig.coEditing.change!==false ? 'fast' : // if can change mode in viewer - set fast for using live viewer + this.editorConfig.coEditing.mode || 'fast'; + docInfo.put_CoEditingMode(coEditMode); const appOptions = this.props.storeAppOptions; let enable = !appOptions.customization || (appOptions.customization.macros !== false); @@ -622,6 +621,9 @@ class MainController extends Component { || licType === Asc.c_oLicenseResult.SuccessLimit && (appOptions.trialMode & Asc.c_oLicenseMode.Limited) !== 0)) this._state.licenseType = licType; + if (licType !== undefined && appOptions.canLiveView && (licType===Asc.c_oLicenseResult.ConnectionsLive || licType===Asc.c_oLicenseResult.ConnectionsLiveOS)) + this._state.licenseType = licType; + if (this._isDocReady && this._state.licenseType) this.applyLicense(); } @@ -653,7 +655,13 @@ class MainController extends Component { return; } - if (this._state.licenseType) { + if (appOptions.config.mode === 'view') { + if (appOptions.canLiveView && (this._state.licenseType===Asc.c_oLicenseResult.ConnectionsLive || this._state.licenseType===Asc.c_oLicenseResult.ConnectionsLiveOS)) { + appOptions.canLiveView = false; + this.api.asc_SetFastCollaborative(false); + } + Common.Notifications.trigger('toolbar:activatecontrols'); + } else if (this._state.licenseType) { let license = this._state.licenseType; let buttons = [{text: 'OK'}]; if ((appOptions.trialMode & Asc.c_oLicenseMode.Limited) !== 0 && diff --git a/apps/spreadsheeteditor/mobile/src/store/appOptions.js b/apps/spreadsheeteditor/mobile/src/store/appOptions.js index cdecf77b8..e1dcf79c5 100644 --- a/apps/spreadsheeteditor/mobile/src/store/appOptions.js +++ b/apps/spreadsheeteditor/mobile/src/store/appOptions.js @@ -111,5 +111,7 @@ export class storeAppOptions { this.canUseReviewPermissions && AscCommon.UserInfoParser.setReviewPermissions(permissions.reviewGroups, this.customization.reviewPermissions); this.canUseCommentPermissions && AscCommon.UserInfoParser.setCommentPermissions(permissions.commentGroups); this.canUseUserInfoPermissions && AscCommon.UserInfoParser.setUserInfoPermissions(permissions.userInfoGroups); + + this.canLiveView = !!params.asc_getLiveViewerSupport() && (this.config.mode === 'view') && isSupportEditFeature; } } \ No newline at end of file