diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000000000000000000000000000000000..48439ed68073b99be118d374d1ebd43d04d4c4eb --- /dev/null +++ b/.clang-format @@ -0,0 +1,64 @@ +Language: Cpp +# BasedOnStyle: LLVM +ColumnLimit: 120 +SortIncludes: CaseSensitive +TabWidth: 4 +IndentWidth: 4 +UseTab: Never +AccessModifierOffset: -4 +ContinuationIndentWidth: 4 +IndentCaseBlocks: false +IndentCaseLabels: false +IndentGotoLabels: true +IndentWrappedFunctionNames: false +SortUsingDeclarations: false +NamespaceIndentation: None +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInConditionalStatement: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +AlignTrailingComments: true +AlignAfterOpenBracket: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakTemplateDeclarations: MultiLine +BinPackArguments: true +BinPackParameters: true +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +InsertBraces: false +IndentExternBlock: NoIndent +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false +ReflowComments: true +MaxEmptyLinesToKeep: 2 \ No newline at end of file diff --git a/build-profile.json5 b/build-profile.json5 index 85b6cc897543b48ee1f5db1c129f04cb0d743d16..ae06abb0fbc239d2a45e80ad6b7dba35107b508b 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -19,8 +19,8 @@ { "name": "default", "signingConfig": "default", - "compileSdkVersion": 11, - "compatibleSdkVersion": 10 + "compileSdkVersion": 14, + "compatibleSdkVersion": 14 } ], "signingConfigs": [ diff --git a/common/BuildProfile.ets b/common/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a501e5ddee8ea6d28961648fc7dd314a5304bd4 --- /dev/null +++ b/common/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/common/src/main/ets/default/camera/CameraPlatformCapability.ts b/common/src/main/ets/default/camera/CameraPlatformCapability.ts index 65639c036624855adb6ffca197c48058de835f01..eb0f19c8690b958e30d71bbe1c7083cae2e52919 100644 --- a/common/src/main/ets/default/camera/CameraPlatformCapability.ts +++ b/common/src/main/ets/default/camera/CameraPlatformCapability.ts @@ -30,22 +30,22 @@ export class CameraPlatformCapability { public mPhotoPreviewSize = [ { width: 640, height: 480 }, //Photo 4:3 { width: 720, height: 720 }, //Photo 1:1 - { width: 1920, height: 1080 }, //Photo 16:9 + { width: 1920, height: 1080 },//Photo 16:9 ] public mVideoPreviewSize = [ { width: 1280, height: 720 }, //Video 16:9 720p { width: 1920, height: 1080 }, //Video 16:9 1080p - { width: 1920, height: 1080 } //Video 16:9 4k + { width: 1920, height: 1080 }//Video 16:9 4k ] public mImageSize = [ { width: 1280, height: 960 }, //4:3 { width: 3120, height: 3120 }, //1:1 - { width: 1920, height: 1080 } //16:9 + { width: 1920, height: 1080 }//16:9 ] public mVideoFrameSize = [ { width: 1280, height: 720 }, //16:9 720p { width: 1920, height: 1080 }, //16:9 1080p - { width: 3840, height: 2160 } //16:9 4k + { width: 3840, height: 2160 }//16:9 4k ] constructor() { diff --git a/common/src/main/ets/default/camera/CameraService.ts b/common/src/main/ets/default/camera/CameraService.ts index b23bbddd5c39bf95de096c58f3c0bede7817a965..fb63ef1b4660c096fe0872e46286d91371cbe950 100644 --- a/common/src/main/ets/default/camera/CameraService.ts +++ b/common/src/main/ets/default/camera/CameraService.ts @@ -142,10 +142,12 @@ export class CameraService { for (let i = 0; i < cameras.length; i++) { Log.info(`${TAG} camera_id: ${cameras[i].cameraId} cameraPosition: ${cameras[i].cameraPosition} cameraType: ${cameras[i].cameraType} connectionType: ${cameras[i].connectionType}`); - if (cameras[i].cameraPosition === FRONT_CAMERA_POSITION && cameras[i].connectionType !== CAMERA_CONNECT_TYPE) { + if (cameras[i].cameraPosition === FRONT_CAMERA_POSITION && + cameras[i].connectionType !== CAMERA_CONNECT_TYPE) { this.mLocalCameraMap.set('front', 'true'); } - if (cameras[i].cameraPosition !== FRONT_CAMERA_POSITION && cameras[i].connectionType !== CAMERA_CONNECT_TYPE) { + if (cameras[i].cameraPosition !== FRONT_CAMERA_POSITION && + cameras[i].connectionType !== CAMERA_CONNECT_TYPE) { this.mLocalCameraMap.set('back', 'true'); } } @@ -369,7 +371,8 @@ export class CameraService { ReportUtil.write(ReportUtil.OPEN_FAIL); } } - if (GlobalContext.get().getT('cameraStartFlag') && (new Date().getTime() - GlobalContext.get().getT('cameraStartTime')) > 2000) { + if (GlobalContext.get().getT('cameraStartFlag') && + (new Date().getTime() - GlobalContext.get().getT('cameraStartTime')) > 2000) { ReportUtil.write(ReportUtil.START_TIMEOUT); } GlobalContext.get().setObject('cameraStartFlag', false); diff --git a/common/src/main/ets/default/camera/SaveCameraAsset.ts b/common/src/main/ets/default/camera/SaveCameraAsset.ts index 93675fcf16deab2ada63a87a904b27835c71cbaf..5a82d1b836e637297ae1dc2758dc2da6b61ea673 100644 --- a/common/src/main/ets/default/camera/SaveCameraAsset.ts +++ b/common/src/main/ets/default/camera/SaveCameraAsset.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import fs, { Filter, ConflictFiles } from '@ohos.file.fs'; +import fs from '@ohos.file.fs'; import image from '@ohos.multimedia.image'; import UserFileManager from '@ohos.filemanagement.userFileManager'; import dataSharePredicates from '@ohos.data.dataSharePredicates'; @@ -24,7 +24,6 @@ import { FunctionCallBack, VideoCallBack } from './CameraService'; import ThumbnailGetter from './ThumbnailGetter'; import ReportUtil from '../utils/ReportUtil'; import { GlobalContext } from '../utils/GlobalContext'; -import buffer from '@ohos.buffer'; const TAG = '[SaveCameraAsset]:'; @@ -34,10 +33,10 @@ export type FetchOpType = { }; export default class SaveCameraAsset { + public videoPrepareFile: UserFileManager.FileAsset; private lastSaveTime = ''; private saveIndex = 0; private mUserFileManager: UserFileManager.UserFileManager; - public videoPrepareFile: UserFileManager.FileAsset; private mCameraAlbum: UserFileManager.Album; private photoUri: string = ''; private videoUri: string = ''; @@ -51,17 +50,8 @@ export default class SaveCameraAsset { return this.photoUri; } - private async createCameraAlbum(): Promise { - Log.log(`${TAG} createCameraAlbum E`); - if (!this.mCameraAlbum) { - let fetchResult = await this.mUserFileManager?.getAlbums(UserFileManager.AlbumType.SYSTEM, UserFileManager.AlbumSubType.CAMERA); - this.mCameraAlbum = await fetchResult?.getFirstObject(); - Log.log(`${TAG} createCameraAlbum albumUri: ${JSON.stringify(this.mCameraAlbum.albumUri)}`); - } - Log.log(`${TAG} createCameraAlbum X`); - } - - public saveImage(mReceiver, thumbWidth: number, thumbHeight: number, thumbnailGetter: ThumbnailGetter, captureCallBack: FunctionCallBack): void { + public saveImage(mReceiver, thumbWidth: number, thumbHeight: number, thumbnailGetter: ThumbnailGetter, + captureCallBack: FunctionCallBack): void { Log.info(`${TAG} saveImage E mediaLibrary.getMediaLibrary media: ${this.mUserFileManager}`); mReceiver.on('imageArrival', async () => { Log.start(Log.UPDATE_PHOTO_THUMBNAIL); @@ -174,6 +164,58 @@ export default class SaveCameraAsset { return fileAsset; } + public async createAsset(type: UserFileManager.FileType): Promise { + const displayName = this.getDisplayName(type); + Log.info(`${TAG} createAsset displayName: ${displayName}`); + let option: UserFileManager.PhotoCreateOptions = { + subType: UserFileManager.PhotoSubType.CAMERA, + }; + let fileAsset: UserFileManager.FileAsset; + try { + fileAsset = await this.mUserFileManager.createPhotoAsset(displayName, option); + if (fileAsset !== undefined) { + Log.info(`${TAG} createPhotoAsset successfully displayName` + fileAsset.displayName); + } else { + Log.error(`${TAG} createPhotoAsset failed, fileAsset is undefined `); + } + } catch (e) { + Log.error(`${TAG} createPhotoAsset failed, error: ${JSON.stringify(e)}}`); + } + return fileAsset; + } + + public async createVideoFd(captureCallBack: VideoCallBack): Promise { + Log.info(`${TAG} createVideoFd E`); + const fileAsset: UserFileManager.FileAsset = await this.createAsset(UserFileManager.FileType.VIDEO); + if (!fileAsset) { + Log.error(`${TAG} createVideoFd mediaLibrary createAsset error: fileAsset undefined.`); + return undefined; + } + let fdNumber: number = 0; + try { + this.videoPrepareFile = fileAsset; + this.videoUri = fileAsset.uri; + captureCallBack.videoUri(this.videoUri); + Log.info(`${TAG} SaveCameraAsset getLastObject.uri: ${JSON.stringify(fileAsset.uri)}`); + fdNumber = await fileAsset.open('Rw'); + } catch (err) { + Log.error(`${TAG} createVideoFd err: ${err}`); + } + Log.info(`${TAG} createVideoFd X`); + return fdNumber; + } + + private async createCameraAlbum(): Promise { + Log.log(`${TAG} createCameraAlbum E`); + if (!this.mCameraAlbum) { + let fetchResult = + await this.mUserFileManager?.getAlbums(UserFileManager.AlbumType.SYSTEM, UserFileManager.AlbumSubType.CAMERA); + this.mCameraAlbum = await fetchResult?.getFirstObject(); + Log.log(`${TAG} createCameraAlbum albumUri: ${JSON.stringify(this.mCameraAlbum.albumUri)}`); + } + Log.log(`${TAG} createCameraAlbum X`); + } + private async fileAssetOperate(fileAsset: UserFileManager.FileAsset, operate: (fd: number) => void): Promise { const fd: number = await fileAsset.open('Rw').catch(error => { Log.error(`${TAG} fileAsset open error: ${JSON.stringify(error)}`); @@ -218,26 +260,6 @@ export default class SaveCameraAsset { return undefined; } - public async createAsset(type: UserFileManager.FileType): Promise { - const displayName = this.getDisplayName(type); - Log.info(`${TAG} createAsset displayName: ${displayName}`); - let option: UserFileManager.PhotoCreateOptions = { - subType: UserFileManager.PhotoSubType.CAMERA, - }; - let fileAsset: UserFileManager.FileAsset; - try { - fileAsset = await this.mUserFileManager.createPhotoAsset(displayName, option); - if (fileAsset !== undefined) { - Log.info(`${TAG} createPhotoAsset successfully displayName` + fileAsset.displayName); - } else { - Log.error(`${TAG} createPhotoAsset failed, fileAsset is undefined `); - } - } catch (e) { - Log.error(`${TAG} createPhotoAsset failed, error: ${JSON.stringify(e)}}`); - } - return fileAsset; - } - private getDisplayName(type: UserFileManager.FileType): string { const mDateTimeUtil: DateTimeUtil = new DateTimeUtil(); const mData: string = mDateTimeUtil.getDate(); @@ -249,27 +271,6 @@ export default class SaveCameraAsset { } } - public async createVideoFd(captureCallBack: VideoCallBack): Promise { - Log.info(`${TAG} createVideoFd E`); - const fileAsset: UserFileManager.FileAsset = await this.createAsset(UserFileManager.FileType.VIDEO); - if (!fileAsset) { - Log.error(`${TAG} createVideoFd mediaLibrary createAsset error: fileAsset undefined.`); - return undefined; - } - let fdNumber: number = 0; - try { - this.videoPrepareFile = fileAsset; - this.videoUri = fileAsset.uri; - captureCallBack.videoUri(this.videoUri); - Log.info(`${TAG} SaveCameraAsset getLastObject.uri: ${JSON.stringify(fileAsset.uri)}`); - fdNumber = await fileAsset.open('Rw'); - } catch (err) { - Log.error(`${TAG} createVideoFd err: ${err}`); - } - Log.info(`${TAG} createVideoFd X`); - return fdNumber; - } - private checkName(name: string): string { if (this.lastSaveTime === name) { this.saveIndex++; diff --git a/common/src/main/ets/default/camera/ThumbnailGetter.ts b/common/src/main/ets/default/camera/ThumbnailGetter.ts index e5933103d273a22a46b52d4d01549ea043214965..c37ae5eca70d2d21c840e57e65bed067041210d8 100644 --- a/common/src/main/ets/default/camera/ThumbnailGetter.ts +++ b/common/src/main/ets/default/camera/ThumbnailGetter.ts @@ -16,13 +16,12 @@ import UserFileManager from '@ohos.filemanagement.userFileManager'; import dataSharePredicates from '@ohos.data.dataSharePredicates'; import image from '@ohos.multimedia.image'; -import { Log } from '../utils/Log' +import { Log } from '../utils/Log'; import { GlobalContext } from '../utils/GlobalContext'; const TAG = '[ThumbnailGetter]:'; export default class ThumbnailGetter { - private mUserFileManager: UserFileManager.UserFileManager; private mCameraAlbum: UserFileManager.Album; private mRecentFileUri: string = ''; @@ -62,16 +61,6 @@ export default class ThumbnailGetter { return this.getFileAssetByFetchOp(fetchOptions); } - private async createCameraAlbum(): Promise { - Log.log(`${TAG} createCameraAlbum E`); - if (!this.mCameraAlbum) { - let fetchResult = await this.mUserFileManager?.getAlbums(UserFileManager.AlbumType.SYSTEM, UserFileManager.AlbumSubType.CAMERA); - this.mCameraAlbum = await fetchResult?.getFirstObject(); - Log.log(`${TAG} createCameraAlbum albumUri: ${JSON.stringify(this.mCameraAlbum.albumUri)}`); - } - Log.log(`${TAG} createCameraAlbum X`); - } - public getRecentFileUri(): string { return this.mRecentFileUri; } @@ -98,4 +87,15 @@ export default class ThumbnailGetter { Log.info(`${TAG} mRecentFileUri : ${JSON.stringify(this.mRecentFileUri)}`); return fileAsset; } + + private async createCameraAlbum(): Promise { + Log.log(`${TAG} createCameraAlbum E`); + if (!this.mCameraAlbum) { + let fetchResult = + await this.mUserFileManager?.getAlbums(UserFileManager.AlbumType.SYSTEM, UserFileManager.AlbumSubType.CAMERA); + this.mCameraAlbum = await fetchResult?.getFirstObject(); + Log.log(`${TAG} createCameraAlbum albumUri: ${JSON.stringify(this.mCameraAlbum.albumUri)}`); + } + Log.log(`${TAG} createCameraAlbum X`); + } } \ No newline at end of file diff --git a/common/src/main/ets/default/featurecommon/animate/ShowFlashBlack.ets b/common/src/main/ets/default/featurecommon/animate/ShowFlashBlack.ets index 06cb9062085e6b40f6ad1d468defc5a691c9628b..7570a17e99b7275e4026bda28cb038d4fcd5364f 100644 --- a/common/src/main/ets/default/featurecommon/animate/ShowFlashBlack.ets +++ b/common/src/main/ets/default/featurecommon/animate/ShowFlashBlack.ets @@ -14,9 +14,9 @@ */ import { Log } from '../../utils/Log'; -import { Dispatch, OhCombinedState } from '../../redux/store'; -import { getStore } from '../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../redux/store'; import { Action } from '../../redux/actions/Action'; + class StateStruct { xComponentWidth: number = 0; xComponentHeight: number = 0; @@ -24,8 +24,6 @@ class StateStruct { class ShowFlashBlackDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -33,13 +31,15 @@ class ShowFlashBlackDispatcher { public updateShowFlashBlackFlag(flag: boolean): void { this.mDispatch(Action.updateShowFlashBlackFlag(flag)); } + + private mDispatch: Dispatch = (data) => data; } @Component export struct ShowFlashBlack { - private TAG: string = '[ShowFlashBlack]:' @State state: StateStruct = new StateStruct() @State opacityValue: number = 1 + private TAG: string = '[ShowFlashBlack]:' private mAction: ShowFlashBlackDispatcher = new ShowFlashBlackDispatcher(); aboutToAppear() { diff --git a/common/src/main/ets/default/featurecommon/assistivegridview/AssistiveGridView.ets b/common/src/main/ets/default/featurecommon/assistivegridview/AssistiveGridView.ets index 03b8a58325f48f1cebf823d2377f1e1f50fcb855..58c1011f6c77dd8283342a6173ba9f490b796fbc 100644 --- a/common/src/main/ets/default/featurecommon/assistivegridview/AssistiveGridView.ets +++ b/common/src/main/ets/default/featurecommon/assistivegridview/AssistiveGridView.ets @@ -14,8 +14,7 @@ */ import { Log } from '../../utils/Log'; -import { Dispatch, OhCombinedState } from '../../redux/store'; -import { getStore } from '../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../redux/store'; class StateStruct { xComponentWidth: number = 0; @@ -23,15 +22,16 @@ class StateStruct { } class AssistiveGridViewDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } + + private mDispatch: Dispatch = (data) => data; } @Component export struct AssistiveGridView { + @State state: StateStruct = new StateStruct(); private TAG: string = '[AssistiveGridView]:'; private mGlobalAlpha: number = 0.5; private mLineWidth: number = 0.5; @@ -43,7 +43,6 @@ export struct AssistiveGridView { private settings: RenderingContextSettings = new RenderingContextSettings(true); private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); private mAction: AssistiveGridViewDispatcher = new AssistiveGridViewDispatcher(); - @State state: StateStruct = new StateStruct(); aboutToAppear(): void { Log.info(`${this.TAG} aboutToAppear invoke E`); diff --git a/common/src/main/ets/default/featurecommon/cameraswitcher/CameraSwitchButton.ets b/common/src/main/ets/default/featurecommon/cameraswitcher/CameraSwitchButton.ets index d5a35209728be874df431298fb378ba7a79a2c33..e82901fd79f76cd5d7c09dac64825c4c4c5c8c4d 100644 --- a/common/src/main/ets/default/featurecommon/cameraswitcher/CameraSwitchButton.ets +++ b/common/src/main/ets/default/featurecommon/cameraswitcher/CameraSwitchButton.ets @@ -15,8 +15,7 @@ import { Action } from '../../redux/actions/Action'; import { CameraSwitchController } from './CameraSwitchController'; -import { Dispatch, OhCombinedState } from '../../redux/store'; -import { getStore } from '../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../redux/store'; import { Log } from '../../utils/Log'; import MultiCameraDialog from '../customdialog/MultiCameraDialog'; import deviceInfo from '@ohos.deviceInfo'; @@ -34,8 +33,6 @@ class StateStruct { class CameraSwitchDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -45,12 +42,13 @@ class CameraSwitchDispatcher { this.mDispatch(Action.switchCamera(cameraPosition)); this.mDispatch(Action.resetZoomRatio(1)); } + + private mDispatch: Dispatch = (data) => data; } @Component export struct CameraSwitchButton { - private TAG: string = '[CameraSwitchButton]:' @State state: StateStruct = new StateStruct() @State deviceType: string = deviceInfo.deviceType @StorageLink('storageCameraId') storageCameraId: string = '' @@ -60,7 +58,6 @@ export struct CameraSwitchButton { mMargin: number = 0; type: ButtonType = ButtonType.Capsule; stateEffect: boolean = false; - private mAction: CameraSwitchDispatcher = new CameraSwitchDispatcher(); cameraSwitchController: CameraSwitchController = new CameraSwitchController() multiDialogController: CustomDialogController = new CustomDialogController({ builder: MultiCameraDialog({ @@ -72,6 +69,8 @@ export struct CameraSwitchButton { customStyle: true, cancel: this.existView }) + private TAG: string = '[CameraSwitchButton]:' + private mAction: CameraSwitchDispatcher = new CameraSwitchDispatcher(); aboutToAppear() { Log.info(`${this.TAG} aboutToAppear E`); @@ -95,22 +94,20 @@ export struct CameraSwitchButton { Log.info(`${this.TAG} aboutToAppear X`) } - private openMultiDialog() { - Log.info(`${this.TAG} openMultiDialog E`) - this.multiDialogController.open() - Log.info(`${this.TAG} openMultiDialog X`) - } - - private existView(): void {} - build() { Column() { Stack() { Image($r('app.media.small_switch_camera')) .width('67.5%').aspectRatio(1) .clip(new Circle({ width: '100%', height: '100%' })) - Column() {}.width(44).height(44) - .border({ width: 1, color: Color.White, radius: 22, style: BorderStyle.Solid }) + Column() { + }.width(44).height(44) + .border({ + width: 1, + color: Color.White, + radius: 22, + style: BorderStyle.Solid + }) } .width('100%').height('100%').enabled(this.state.uiEnable) .onClick(() => { @@ -121,7 +118,7 @@ export struct CameraSwitchButton { if (this.state.mode === 'MULTI') { this.openMultiDialog() } else { - GlobalContext.get().setObject('switchCameraTime',new Date().getTime()) + GlobalContext.get().setObject('switchCameraTime', new Date().getTime()) if (this.state.cameraPosition !== 'BACK') { this.mAction.changeCameraPosition('BACK') this.storageCameraId = 'BACK' @@ -135,4 +132,13 @@ export struct CameraSwitchButton { }) }.width(44).aspectRatio(1) } + + private openMultiDialog() { + Log.info(`${this.TAG} openMultiDialog E`) + this.multiDialogController.open() + Log.info(`${this.TAG} openMultiDialog X`) + } + + private existView(): void { + } } \ No newline at end of file diff --git a/common/src/main/ets/default/featurecommon/customdialog/EntryComponentForMulti.ets b/common/src/main/ets/default/featurecommon/customdialog/EntryComponentForMulti.ets index a8d80dbfff145157ece80d32e75b192420d1ec82..00265683193359c3b81f061d7082628709016edf 100644 --- a/common/src/main/ets/default/featurecommon/customdialog/EntryComponentForMulti.ets +++ b/common/src/main/ets/default/featurecommon/customdialog/EntryComponentForMulti.ets @@ -14,8 +14,7 @@ */ import { CameraService } from '../../camera/CameraService'; -import { Dispatch, OhCombinedState } from '../../redux/store'; -import { getStore } from '../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../redux/store'; import { Log } from '../../utils/Log'; class StateStruct { @@ -23,29 +22,28 @@ class StateStruct { } class ComponentForMultiDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } + + private mDispatch: Dispatch = (data) => data; } @Component export default struct EntryComponentForMulti { - private TAG: string = '[EntryComponentForMulti]:'; @State state: StateStruct = new StateStruct(); @State isLocalDevice: boolean = false; @State switchCameraState: boolean = false; @State recCameraState: boolean = true; @State defaultChecked: boolean = false; @State curCameraName: string = ''; + private TAG: string = '[EntryComponentForMulti]:'; private localList: string = ''; private item: string = ''; - private onChange: Function = () => {}; private cameraService: CameraService = CameraService.getInstance(); private deviceName: string = ''; - private cameraPositionRes:string | Resource = ''; + private cameraPositionRes: string | Resource = ''; private cameraPositionName: string = ''; private mAction: ComponentForMultiDispatcher = new ComponentForMultiDispatcher(); @@ -66,29 +64,6 @@ export default struct EntryComponentForMulti { } } - private getShowName(item: string): void { - this.cameraPositionName = item.split('_').pop() as string; - switch (this.cameraPositionName) { - case 'FRONT': - this.cameraPositionRes = $r('app.string.front') - break - case 'BACK': - this.cameraPositionRes = $r('app.string.back') - break - default: - break - } - if (item.split('_').length == 1) { - this.isLocalDevice = true - } else { - const cameraItem = this.cameraService.getCameraMap().get(item) - if (cameraItem) { - this.deviceName = cameraItem.deviceName as string; - this.isLocalDevice = false - } - } - } - build() { Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { Row() { @@ -127,4 +102,30 @@ export default struct EntryComponentForMulti { .height(48) .width('100%') } + + private onChange: Function = () => { + }; + + private getShowName(item: string): void { + this.cameraPositionName = item.split('_').pop() as string; + switch (this.cameraPositionName) { + case 'FRONT': + this.cameraPositionRes = $r('app.string.front') + break + case 'BACK': + this.cameraPositionRes = $r('app.string.back') + break + default: + break + } + if (item.split('_').length == 1) { + this.isLocalDevice = true + } else { + const cameraItem = this.cameraService.getCameraMap().get(item) + if (cameraItem) { + this.deviceName = cameraItem.deviceName as string; + this.isLocalDevice = false + } + } + } } \ No newline at end of file diff --git a/common/src/main/ets/default/featurecommon/customdialog/MultiCameraDialog.ets b/common/src/main/ets/default/featurecommon/customdialog/MultiCameraDialog.ets index b5a4ea7a259bd9bdc143f57f805bef6bcf630561..e4effcdce011ca171018d6d5599f7a37c9d7291d 100644 --- a/common/src/main/ets/default/featurecommon/customdialog/MultiCameraDialog.ets +++ b/common/src/main/ets/default/featurecommon/customdialog/MultiCameraDialog.ets @@ -17,8 +17,7 @@ import { CameraService } from '../../camera/CameraService'; import { CameraId } from '../../setting/settingitem/CameraId'; import { Log } from '../../utils/Log'; import EntryComponentForMulti from './EntryComponentForMulti'; -import { Dispatch, OhCombinedState } from '../../redux/store'; -import { getStore } from '../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../redux/store'; import { Action } from '../../redux/actions/Action'; let storageCameraId: string = AppStorage.Link('storageCameraId') as string; @@ -27,8 +26,6 @@ class StateStruct { } class MultiCameraDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -38,34 +35,39 @@ class MultiCameraDispatcher { this.mDispatch(Action.switchCamera(cameraPosition)); this.mDispatch(Action.resetZoomRatio(1)); } + + private mDispatch: Dispatch = (data) => data; } @CustomDialog export default struct MultiCameraDialog { - private TAG: string = '[MultiCameraDialog]:'; - private cameraService = CameraService.getInstance(); controller?: CustomDialogController; - cancel: () => void = () => {}; - confirm: () => void = () => {}; - private localList: string[] = [ - CameraId.FRONT, - CameraId.BACK - ]; - @State private moreList: string[] = []; @State state: StateStruct = new StateStruct(); @State isShowMore: boolean = false; @State gridColumns: number = 12; @State useSizeTypeOffset: number = 4; @Link deviceType: string; @StorageLink('storageCameraId') storageCameraId: string = ''; + private TAG: string = '[MultiCameraDialog]:'; + private cameraService = CameraService.getInstance(); + private localList: string[] = [ + CameraId.FRONT, + CameraId.BACK + ]; + @State private moreList: string[] = []; private mAction: MultiCameraDispatcher = new MultiCameraDispatcher(); + cancel: () => void = () => { + }; + + confirm: () => void = () => { + }; + aboutToAppear() { Log.info(`${this.TAG} aboutToAppear.`) getStore().subscribe((state: OhCombinedState) => { - this.state = { - }; + this.state = {}; }, (dispatch: Dispatch) => { this.mAction.setDispatch(dispatch); }); @@ -76,7 +78,7 @@ export default struct MultiCameraDialog { } else if (!localCameraInfo.get('back')) { this.localList.pop() } - if (this.deviceType === 'phone' || this .deviceType === 'default') { + if (this.deviceType === 'phone' || this.deviceType === 'default') { this.gridColumns = 4 this.useSizeTypeOffset = 0 } else { @@ -85,20 +87,6 @@ export default struct MultiCameraDialog { } } - private onChange(item: string): void { - Log.info(`${this.TAG} MultiCameraPosition ${JSON.stringify(item)}`) - if (item.includes('BACK')) { - this.storageCameraId = 'BACK' - } else if(item.includes('FRONT')) { - this.storageCameraId = 'FRONT' - } - this.mAction.changeCameraPosition(item); - this.cancel(); - if (this.controller) { - this.controller.close(); - } - } - build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { GridContainer({ columns: this.gridColumns, gutter: 12, margin: 12 }) { @@ -122,7 +110,7 @@ export default struct MultiCameraDialog { } .width('100%') .height('48vp') - .padding({top: 20, bottom: 8}) + .padding({ top: 20, bottom: 8 }) List() { ForEach(this.localList, (item: string) => { @@ -130,7 +118,7 @@ export default struct MultiCameraDialog { EntryComponentForMulti({ item: item, localList: this.localList.toString(), - onChange: (data:string) => this.onChange(data) + onChange: (data: string) => this.onChange(data) }) } .width('100%') @@ -138,7 +126,12 @@ export default struct MultiCameraDialog { }) } .listDirection(Axis.Vertical) - .divider({ strokeWidth: '1vp', color: '#33182431', startMargin: 0, endMargin: 12}) + .divider({ + strokeWidth: '1vp', + color: '#33182431', + startMargin: 0, + endMargin: 12 + }) Row() { Text($r('app.string.more_devices')) @@ -148,7 +141,7 @@ export default struct MultiCameraDialog { } .width('100%') .height('48vp') - .padding({top: 20, bottom: 8}) + .padding({ top: 20, bottom: 8 }) if (this.isShowMore) { List() { @@ -165,7 +158,12 @@ export default struct MultiCameraDialog { }) } .listDirection(Axis.Vertical) - .divider({ strokeWidth: 0.5, color: '#33000000', startMargin: 0, endMargin: 12 }) + .divider({ + strokeWidth: 0.5, + color: '#33000000', + startMargin: 0, + endMargin: 12 + }) } Column() { @@ -203,4 +201,18 @@ export default struct MultiCameraDialog { }.width('100%') } } + + private onChange(item: string): void { + Log.info(`${this.TAG} MultiCameraPosition ${JSON.stringify(item)}`) + if (item.includes('BACK')) { + this.storageCameraId = 'BACK' + } else if (item.includes('FRONT')) { + this.storageCameraId = 'FRONT' + } + this.mAction.changeCameraPosition(item); + this.cancel(); + if (this.controller) { + this.controller.close(); + } + } } \ No newline at end of file diff --git a/common/src/main/ets/default/featurecommon/customdialog/dialogComponent/CustomDialogView.ets b/common/src/main/ets/default/featurecommon/customdialog/dialogComponent/CustomDialogView.ets index c059187cc4e36cf3f11c40369e5ba97665664fc2..4f31be249ff7c7d5d6fbeeafa2bd93127c870cde 100644 --- a/common/src/main/ets/default/featurecommon/customdialog/dialogComponent/CustomDialogView.ets +++ b/common/src/main/ets/default/featurecommon/customdialog/dialogComponent/CustomDialogView.ets @@ -17,28 +17,26 @@ import deviceInfo from '@ohos.deviceInfo'; import { Action } from '../../../redux/actions/Action'; import { Log } from '../../../utils/Log'; -import { Dispatch, OhCombinedState } from '../../../redux/store'; -import { getStore } from '../../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../../redux/store'; import EntryComponent from './EntryComponent'; @Observed export class CustomDialogDetails { - confirmCallback: Function = () => { - }; confirmItem: boolean = false; height: number = 0; width: number = 0; setAlias: string = ''; childrenList: ChildrenItemStruct[] = []; settingTitle: string = ''; + + confirmCallback: Function = () => { + }; } class StateStruct { } class CustomDialogViewDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -46,6 +44,8 @@ class CustomDialogViewDispatcher { public closeDialog(isCloseFlag: boolean): void { this.mDispatch(Action.closeDialog(isCloseFlag)); } + + private mDispatch: Dispatch = (data) => data; } class ChildrenItemStruct { @@ -59,20 +59,22 @@ class StyleStruct { @CustomDialog export struct CustomDialogView { - private TAG: string = '[CustomDialogView]:' localStyle: StyleStruct = { columns: 4, offset: 0 }; controller?: CustomDialogController; - cancel: () => void = () => { - }; - confirm: () => void = () => { - }; @Consume customDialogDetails: CustomDialogDetails; @State settingAlias: string = ""; @State getValue: string = ""; @State childrenList: Array = []; @State state: StateStruct = new StateStruct(); + private TAG: string = '[CustomDialogView]:' private mAction: CustomDialogViewDispatcher = new CustomDialogViewDispatcher(); + cancel: () => void = () => { + }; + + confirm: () => void = () => { + }; + async aboutToAppear() { Log.info(`${this.TAG} aboutToAppear start`) this.childrenList = this.customDialogDetails.childrenList @@ -127,7 +129,12 @@ export struct CustomDialogView { }) } .listDirection(Axis.Vertical) - .divider({ strokeWidth: 0.5, color: '#33000000', startMargin: 0, endMargin: 12 }) // 每行之间的分界线 + .divider({ + strokeWidth: 0.5, + color: '#33000000', + startMargin: 0, + endMargin: 12 + }) // 每行之间的分界线 Column() { Button({ type: ButtonType.Capsule, stateEffect: true }) { Text($r('app.string.cancel')) @@ -188,7 +195,12 @@ export struct CustomDialogView { }) } .listDirection(Axis.Vertical) - .divider({ strokeWidth: 0.5, color: '#33000000', startMargin: 0, endMargin: 12 }) // 每行之间的分界线 + .divider({ + strokeWidth: 0.5, + color: '#33000000', + startMargin: 0, + endMargin: 12 + }) // 每行之间的分界线 Column() { Button({ type: ButtonType.Capsule, stateEffect: true }) { Text($r('app.string.cancel')) diff --git a/common/src/main/ets/default/featurecommon/customdialog/dialogComponent/EntryComponent.ets b/common/src/main/ets/default/featurecommon/customdialog/dialogComponent/EntryComponent.ets index bb25740d1e56287b2a860eb3261b426de77425c8..c95ddef3d3a862b1670378b6bc6d2923cb2c53a5 100644 --- a/common/src/main/ets/default/featurecommon/customdialog/dialogComponent/EntryComponent.ets +++ b/common/src/main/ets/default/featurecommon/customdialog/dialogComponent/EntryComponent.ets @@ -18,31 +18,29 @@ import { SettingManager } from '../../../setting/SettingManager'; import Timer from '../../../setting/settingitem/Timer'; import AspectRatio from '../../../setting/settingitem/AspectRatio'; import Resolution from '../../../setting/settingitem/Resolution'; -import { Dispatch, OhCombinedState } from '../../../redux/store'; -import { getStore } from '../../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../../redux/store'; class StateStruct { mode: string = ''; } class EntryComponentDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } + + private mDispatch: Dispatch = (data) => data; } @Component export default struct EntryComponent { - private TAG: string = '[EntryComponent]:'; @State itemValue: Resource = $r('app.string.photo_ratio_4_3'); @State checkedValue: string = ''; @State settingAlias: string = ''; + @State state: StateStruct = new StateStruct(); + private TAG: string = '[EntryComponent]:'; private getValue: Resource = $r('app.string.resolution_1280_720'); - private onChange: Function = () => {}; private settingManager = SettingManager.getInstance(); - @State state: StateStruct = new StateStruct(); private mAction: EntryComponentDispatcher = new EntryComponentDispatcher(); aboutToAppear(): void { @@ -93,4 +91,7 @@ export default struct EntryComponent { } .width('100%') } + + private onChange: Function = () => { + }; } \ No newline at end of file diff --git a/common/src/main/ets/default/featurecommon/geolocation/GeoLocation.ets b/common/src/main/ets/default/featurecommon/geolocation/GeoLocation.ets index b65edcb13d57e8188adf62741ff7939fcd550e0a..967e5d5610d96adefae374ba2a3f2798610cad05 100644 --- a/common/src/main/ets/default/featurecommon/geolocation/GeoLocation.ets +++ b/common/src/main/ets/default/featurecommon/geolocation/GeoLocation.ets @@ -19,8 +19,8 @@ import { SettingManager } from '../../setting/SettingManager'; import { BusinessError } from '@ohos.base'; export class GeoLocation { - private TAG: string = '[GeoLocation]:' private static instance: GeoLocation + private TAG: string = '[GeoLocation]:' private requestInfo: geolocation.LocationRequest = { priority: 0x203, scenario: 0x300, @@ -28,10 +28,6 @@ export class GeoLocation { distanceInterval: 0, maxAccuracy: 0 } - private locationChange = (location: geolocation.Location): void => { //删掉参数err及相关逻辑 - Log.info(`[GeoLocation]: locationChange: ${location}`) - SettingManager.getInstance().setCurGeoLocation(location) - } public static getInstance() { if (!GeoLocation.instance) { @@ -57,7 +53,7 @@ export class GeoLocation { geolocation.getCurrentLocation(curRequestInfo).then((result) => { Log.info(`${this.TAG} on getCurrentLocation result: ${JSON.stringify(result)}`) SettingManager.getInstance().setCurGeoLocation(result) - }).catch((err:BusinessError) => { + }).catch((err: BusinessError) => { Log.info(`${this.TAG} on getCurrentLocation err result: ${JSON.stringify(err)}`) }) geolocation.on('locationChange', this.requestInfo, this.locationChange) @@ -75,4 +71,9 @@ export class GeoLocation { geolocation.off('locationChange', this.locationChange) Log.info(`${this.TAG} off X`) } + + private locationChange = (location: geolocation.Location): void => { //删掉参数err及相关逻辑 + Log.info(`[GeoLocation]: locationChange: ${location}`) + SettingManager.getInstance().setCurGeoLocation(location) + } } \ No newline at end of file diff --git a/common/src/main/ets/default/featurecommon/moreList/moreList.ets b/common/src/main/ets/default/featurecommon/moreList/moreList.ets index 7ac4099ec7e766531227271a0eb25f1fd293011f..9e7d227510ac3b8ad9256a729412e882fece9fda 100644 --- a/common/src/main/ets/default/featurecommon/moreList/moreList.ets +++ b/common/src/main/ets/default/featurecommon/moreList/moreList.ets @@ -15,8 +15,7 @@ import deviceInfo from '@ohos.deviceInfo'; import { Action } from '../../redux/actions/Action'; import { Log } from '../../utils/Log'; -import { Dispatch, OhCombinedState } from '../../redux/store'; -import { getStore } from '../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../redux/store'; class MoreListInfo { itemIcon: Resource = $r('app.media.photo'); @@ -28,8 +27,6 @@ class StateStruct { } class MoreListDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -37,12 +34,14 @@ class MoreListDispatcher { public swipeChangeMode(swipeModeIndex: number): void { this.mDispatch(Action.swipeChangeMode(swipeModeIndex)); } + + private mDispatch: Dispatch = (data) => data; } @Component export struct MoreList { - private TAG: string = '[moreList]:'; @State state: StateStruct = new StateStruct(); + private TAG: string = '[moreList]:'; private mAction: MoreListDispatcher = new MoreListDispatcher(); private mDirection: PanDirection = PanDirection.Right; private moreList: MoreListInfo[] = [{ @@ -75,20 +74,6 @@ export struct MoreList { Log.info(`${this.TAG} aboutToAppear end`) } - private setDirection(): void { - switch (deviceInfo.deviceType) { - case 'PAD': - this.mDirection = PanDirection.Down - break - case 'tablet': - this.mDirection = PanDirection.Down - break - default: - this.mDirection = PanDirection.Right - break - } - } - build() { Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) { Grid() { @@ -118,10 +103,24 @@ export struct MoreList { .width('100%') .height('70%') .gesture( - PanGesture({ direction: this.mDirection }) - .onActionEnd(() => { - this.mAction.swipeChangeMode(this.state.modeIndex - 1) - }) + PanGesture({ direction: this.mDirection }) + .onActionEnd(() => { + this.mAction.swipeChangeMode(this.state.modeIndex - 1) + }) ) } + + private setDirection(): void { + switch (deviceInfo.deviceType) { + case 'PAD': + this.mDirection = PanDirection.Down + break + case 'tablet': + this.mDirection = PanDirection.Down + break + default: + this.mDirection = PanDirection.Right + break + } + } } \ No newline at end of file diff --git a/common/src/main/ets/default/featurecommon/playsound/playSound.ets b/common/src/main/ets/default/featurecommon/playsound/playSound.ets index 229b3e71d61e93157969d701be88b1770ee30b7b..5e1d66c0455f193855fd3edd910cd082c8adc956 100644 --- a/common/src/main/ets/default/featurecommon/playsound/playSound.ets +++ b/common/src/main/ets/default/featurecommon/playsound/playSound.ets @@ -24,6 +24,7 @@ import { SettingManager } from '../../setting/SettingManager' import { Voice } from '../../setting/settingitem/Voice' export class PlaySound { + private static sInstancePlaySound: PlaySound; private TAG: string = '[PlaySound]:' private appEventBus: EventBus = EventBusManager.getInstance().getEventBus() private settingManager = SettingManager.getInstance() @@ -31,7 +32,6 @@ export class PlaySound { private fdPath // @ts-ignore private mAVPlayer: media.AVPlayer - private static sInstancePlaySound: PlaySound; constructor() { Log.info(`${this.TAG} constructor start, enroll playCapture to ACTION_CAPTURE`) @@ -44,6 +44,13 @@ export class PlaySound { }) } + public static getInstance(): PlaySound { + if (!PlaySound.sInstancePlaySound) { + PlaySound.sInstancePlaySound = new PlaySound(); + } + return PlaySound.sInstancePlaySound; + } + setAVPlayerCallback(): void { Log.info(`${this.TAG} setAudioCallback`) this.mAVPlayer.on('stateChange', async (state, reason) => { @@ -53,7 +60,8 @@ export class PlaySound { break; case 'initialized': Log.info(`${this.TAG} stateChange initialized state`) - this.mAVPlayer.prepare().then(() => {}, (err) => { + this.mAVPlayer.prepare().then(() => { + }, (err) => { Log.error(`${this.TAG} case prepare error`) }) break; @@ -88,12 +96,6 @@ export class PlaySound { }) } - public static getInstance(): PlaySound { - if (!PlaySound.sInstancePlaySound) { - PlaySound.sInstancePlaySound = new PlaySound(); - } - return PlaySound.sInstancePlaySound; - } private playCapture(data): void { Log.info(`${this.TAG} playCapture invoke E`); if (this.settingManager.getCaptureMute() == Voice.SOUND) { diff --git a/common/src/main/ets/default/featurecommon/preferences/PreferencesService.ts b/common/src/main/ets/default/featurecommon/preferences/PreferencesService.ts index 9130708e6567257fe34f4abfe02d4a63dedb440f..1d1535c175ef4cfd9d7d198e648d714cc7fa5f58 100644 --- a/common/src/main/ets/default/featurecommon/preferences/PreferencesService.ts +++ b/common/src/main/ets/default/featurecommon/preferences/PreferencesService.ts @@ -29,7 +29,8 @@ export class PreferencesService { public static getInstance(): PreferencesService { if (!globalThis?.sInstancePreferencesService) { globalThis.sInstancePreferencesService = new PreferencesService(); - PreferencesService.modeStorage = dataStorage.getStorageSync(GlobalContext.get().getCameraAbilityContext().filesDir + '/mode_persist_values'); + PreferencesService.modeStorage = + dataStorage.getStorageSync(GlobalContext.get().getCameraAbilityContext().filesDir + '/mode_persist_values'); } return globalThis.sInstancePreferencesService; } @@ -49,7 +50,8 @@ export class PreferencesService { } flush(): void { - PreferencesService.modeStorage.putSync(this.getModePersistKey(PersistType.FOR_AWHILE, 'Timestamp'), new Date().getTime()); + PreferencesService.modeStorage.putSync(this.getModePersistKey(PersistType.FOR_AWHILE, 'Timestamp'), + new Date().getTime()); this.flushMode(); } diff --git a/common/src/main/ets/default/featurecommon/screenlock/Decorators.ts b/common/src/main/ets/default/featurecommon/screenlock/Decorators.ts index 51b6dccae81b927d833d1e94c1762b63c891e57e..aabf15253e694485d84f73298db8982e2d9c5eba 100644 --- a/common/src/main/ets/default/featurecommon/screenlock/Decorators.ts +++ b/common/src/main/ets/default/featurecommon/screenlock/Decorators.ts @@ -13,33 +13,33 @@ * limitations under the License. */ -import { Log } from '../../utils/Log' +import { Log } from '../../utils/Log'; const TAG = '[Decorators]:' export function debounce(timeout: number) { - return function inner(target: any, propKey: string, descriptor: PropertyDescriptor) { - let curFunc: number = 0; - const original = descriptor.value; - descriptor.value = function (...args: string[]) { - Log.log(`${TAG} debounce invoke ${propKey} curFunc: ${curFunc}`); - curFunc && clearTimeout(curFunc); - curFunc = setTimeout(() => original.call(this, ...args), timeout); - }; + return function inner(target: any, propKey: string, descriptor: PropertyDescriptor) { + let curFunc: number = 0; + const original = descriptor.value; + descriptor.value = function (...args: string[]) { + Log.log(`${TAG} debounce invoke ${propKey} curFunc: ${curFunc}`); + curFunc && clearTimeout(curFunc); + curFunc = setTimeout(() => original.call(this, ...args), timeout); }; + }; } export function throttle(waitTime: number) { - return function inner(target: any, propKey: string, descriptor: PropertyDescriptor) { - let lastTime: number = 0; - const original = descriptor.value; - descriptor.value = function (...args: string[]) { - let curTime = Date.now(); - Log.log(`${TAG} throttle invoke ${propKey} timeInterval: ${curTime - lastTime}`); - if (curTime - lastTime >= waitTime) { - original.call(this, ...args); - lastTime = curTime; - } - }; + return function inner(target: any, propKey: string, descriptor: PropertyDescriptor) { + let lastTime: number = 0; + const original = descriptor.value; + descriptor.value = function (...args: string[]) { + let curTime = Date.now(); + Log.log(`${TAG} throttle invoke ${propKey} timeInterval: ${curTime - lastTime}`); + if (curTime - lastTime >= waitTime) { + original.call(this, ...args); + lastTime = curTime; + } }; + }; } diff --git a/common/src/main/ets/default/featurecommon/settingview/model/SettingData.ts b/common/src/main/ets/default/featurecommon/settingview/model/SettingData.ts index b675cbabfdcc8075f48765062fbb1e06acd2d463..e2af8ca05d2384e225dcdb1c00b9a0e8432411cd 100644 --- a/common/src/main/ets/default/featurecommon/settingview/model/SettingData.ts +++ b/common/src/main/ets/default/featurecommon/settingview/model/SettingData.ts @@ -14,9 +14,6 @@ */ export class SettingData { - constructor() { - } - settingTitle?: string | Resource; imagePath?: string | Resource; settingName?: Resource; @@ -26,6 +23,9 @@ export class SettingData { radio?: string; toggle?: string; description?: string; + + constructor() { + } } diff --git a/common/src/main/ets/default/featurecommon/settingview/phone/SetResolution.ets b/common/src/main/ets/default/featurecommon/settingview/phone/SetResolution.ets index 10995488e5eb829c7913509842ab04ecfdbd7fc3..ea30268e7fd98a48cc415fea7e47f2c4cd394995 100644 --- a/common/src/main/ets/default/featurecommon/settingview/phone/SetResolution.ets +++ b/common/src/main/ets/default/featurecommon/settingview/phone/SetResolution.ets @@ -15,11 +15,9 @@ import { Action } from '../../../redux/actions/Action'; import Timer from '../../../setting/settingitem/Timer'; -import { CustomDialogDetails } from '../../customdialog/dialogComponent/CustomDialogView'; -import { CustomDialogView } from '../../customdialog/dialogComponent/CustomDialogView'; +import { CustomDialogDetails, CustomDialogView } from '../../customdialog/dialogComponent/CustomDialogView'; import { Log } from '../../../utils/Log'; -import { Dispatch, OhCombinedState } from '../../../redux/store'; -import { getStore } from '../../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../../redux/store'; import { SettingManager } from '../../../setting/SettingManager'; import { SettingData, SettingGroupItem } from '../model/SettingData'; @@ -27,8 +25,6 @@ class StateStruct { } class SetResolutionDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -36,22 +32,30 @@ class SetResolutionDispatcher { public closeDialog(isCloseFlag: boolean): void { this.mDispatch(Action.closeDialog(isCloseFlag)); } + + private mDispatch: Dispatch = (data) => data; } @Component export struct SetResolution { - private TAG: string = '[SetResolution]:'; @Link settingsList: SettingGroupItem[]; @Link @Watch('onCloseDialog') closeFlag: boolean; + @StorageLink('settingDialogFlag') settingDialogFlag: boolean = true; + @State curCheckName: Resource = $r('app.string.default_value'); + @State state: StateStruct = new StateStruct(); + CustomDialogView: CustomDialogController = new CustomDialogController({ + builder: CustomDialogView({ cancel: () => this.existView() }), + autoCancel: true, + alignment: DialogAlignment.Bottom, + cancel: this.existView, + customStyle: true + }); + private TAG: string = '[SetResolution]:'; private itemValue: SettingData = {}; private WH_100_100: string = "100%"; private settingManager = SettingManager.getInstance(); private setAlias: string = ''; - @StorageLink('settingDialogFlag') settingDialogFlag: boolean = true; - @State curCheckName: Resource = $r('app.string.default_value'); - @State state: StateStruct = new StateStruct(); - private mAction: SetResolutionDispatcher = new SetResolutionDispatcher(); @Provide customDialogDetails: CustomDialogDetails = { confirmCallback: Function, confirmItem: true, @@ -61,13 +65,7 @@ export struct SetResolution { childrenList: [], settingTitle: '' }; - CustomDialogView: CustomDialogController = new CustomDialogController({ - builder: CustomDialogView({ cancel: () => this.existView() }), - autoCancel: true, - alignment: DialogAlignment.Bottom, - cancel: this.existView, - customStyle: true - }); + private mAction: SetResolutionDispatcher = new SetResolutionDispatcher(); existView(): void { Log.info(`${this.TAG} existView E`) diff --git a/common/src/main/ets/default/featurecommon/settingview/phone/SetToggle.ets b/common/src/main/ets/default/featurecommon/settingview/phone/SetToggle.ets index 3701fb0934e3a408d52bc23d3a8241d276f186b3..f78aaa558a94a988c1d12fd6c71fd45535f488b2 100644 --- a/common/src/main/ets/default/featurecommon/settingview/phone/SetToggle.ets +++ b/common/src/main/ets/default/featurecommon/settingview/phone/SetToggle.ets @@ -16,31 +16,30 @@ import { Log } from '../../../utils/Log'; import { SettingManager } from '../../../setting/SettingManager'; import { SettingData, SettingGroupItem } from '../model/SettingData'; -import { Dispatch, OhCombinedState } from '../../../redux/store'; -import { getStore } from '../../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../../redux/store'; class StateStruct { mode: string = ''; } class SetToggleDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } + + private mDispatch: Dispatch = (data) => data; } @Component export struct SetToggle { - private TAG: string = '[SetToggle]:'; @Link settingsList: SettingGroupItem[]; @State isOn: boolean = false; + @State generalStatusValue: boolean = false; + @State state: StateStruct = new StateStruct(); + private TAG: string = '[SetToggle]:'; private itemValue: SettingData = {}; private WH_100_100: string = "100%"; private settingManager = SettingManager.getInstance(); - @State generalStatusValue: boolean = false; - @State state: StateStruct = new StateStruct(); private mAction: SetToggleDispatcher = new SetToggleDispatcher(); aboutToAppear() { @@ -95,7 +94,8 @@ export struct SetToggle { .opacity($r('sys.float.ohos_id_alpha_content_secondary')) }.margin({ top: $r('sys.float.ohos_id_text_margin_vertical'), - left: 40 }) + left: 40 + }) } } .layoutWeight(1) diff --git a/common/src/main/ets/default/featurecommon/settingview/phone/SettingItem.ets b/common/src/main/ets/default/featurecommon/settingview/phone/SettingItem.ets index 5a21b5f542e77a5c5f9912ce4f637ee919b0f758..0053627cdbd5deecb5d37756312084b4163972a6 100644 --- a/common/src/main/ets/default/featurecommon/settingview/phone/SettingItem.ets +++ b/common/src/main/ets/default/featurecommon/settingview/phone/SettingItem.ets @@ -13,18 +13,16 @@ * limitations under the License. */ -import { SettingManager } from '../../../setting/SettingManager' -import { Log } from '../../../utils/Log' -import { SetResolution } from './SetResolution' -import { SetToggle } from './SetToggle' -import { BaseData } from '../model/BaseData' -import { SettingData, SettingGroupItem } from '../model/SettingData' +import { Log } from '../../../utils/Log'; +import { SetResolution } from './SetResolution'; +import { SetToggle } from './SetToggle'; +import { SettingData, SettingGroupItem } from '../model/SettingData'; @Component export struct SettingItem { - private TAG: string = '[SettingItem]:'; @Link settingsList: SettingGroupItem[]; @Link closeFlag: Boolean; + private TAG: string = '[SettingItem]:'; private item: SettingGroupItem = {}; private index: number = 0; private WH_100_100: string = "100%"; @@ -36,15 +34,19 @@ export struct SettingItem { } build() { - Flex({ direction: FlexDirection.Column, + Flex({ + direction: FlexDirection.Column, alignItems: ItemAlign.Center, - justifyContent: FlexAlign.SpaceBetween }) { + justifyContent: FlexAlign.SpaceBetween + }) { Column() { Row() { Text(this.item.settingTitle) - .margin({ top: $r('app.float.margin_value_20'), + .margin({ + top: $r('app.float.margin_value_20'), left: $r('sys.float.ohos_id_card_margin_start'), - bottom: $r('app.float.margin_value_8') }) + bottom: $r('app.float.margin_value_8') + }) .fontColor($r('app.color.font_color_FFFFFF')) .opacity($r('app.float.opacity_6')) .fontSize($r('app.float.font_14')) @@ -79,7 +81,12 @@ export struct SettingItem { }) } .listDirection(Axis.Vertical) - .divider({ strokeWidth: 0.5, color: '#33FFFFFF', startMargin: 56, endMargin: 12 }) + .divider({ + strokeWidth: 0.5, + color: '#33FFFFFF', + startMargin: 56, + endMargin: 12 + }) .borderRadius($r('sys.float.ohos_id_corner_radius_card')) .backgroundColor('#202224') .padding({ top: 4, bottom: 4 }) diff --git a/common/src/main/ets/default/featurecommon/settingview/tablet/TabletSetResolution.ets b/common/src/main/ets/default/featurecommon/settingview/tablet/TabletSetResolution.ets index 6e1141b51c2f72a00b2cfcc41aeea8d5b5ceff49..bb5bbd77a1c3a644af68ea3e0d6b68964dac3171 100644 --- a/common/src/main/ets/default/featurecommon/settingview/tablet/TabletSetResolution.ets +++ b/common/src/main/ets/default/featurecommon/settingview/tablet/TabletSetResolution.ets @@ -15,20 +15,17 @@ import { Action } from '../../../redux/actions/Action' import Timer from '../../../setting/settingitem/Timer' -import { CustomDialogDetails } from '../../customdialog/dialogComponent/CustomDialogView' -import { CustomDialogView } from '../../customdialog/dialogComponent/CustomDialogView' +import { CustomDialogDetails, CustomDialogView } from '../../customdialog/dialogComponent/CustomDialogView' import { Log } from '../../../utils/Log' -import { Dispatch, OhCombinedState } from '../../../redux/store' -import { getStore } from '../../../redux/store' +import { Dispatch, getStore, OhCombinedState } from '../../../redux/store' import { SettingManager } from '../../../setting/SettingManager' import { SettingData, SettingGroupItem } from '../model/SettingData' class StateStruct { isCloseFlag: boolean = false; } -class SetResolutionDispatcher { - private mDispatch: Dispatch = (data) => data; +class SetResolutionDispatcher { public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -36,24 +33,33 @@ class SetResolutionDispatcher { public closeDialog(isCloseFlag: boolean): void { this.mDispatch(Action.closeDialog(isCloseFlag)); } + + private mDispatch: Dispatch = (data) => data; } @Component export struct TabletSetResolution { - private TAG: string = '[TabletSetResolution]:'; @Link settingsList: SettingGroupItem[]; @Link @Watch('onCloseDialog') closeFlag: boolean; + @StorageLink('settingDialogFlag') settingDialogFlag: boolean = true; + @State curCheckName: Resource = $r('app.string.default_value'); + @State state: StateStruct = new StateStruct(); + CustomDialogView: CustomDialogController = new CustomDialogController({ + builder: CustomDialogView({ cancel: () => this.existView }), + autoCancel: true, + alignment: DialogAlignment.Center, + cancel: this.existView, + customStyle: true + }) + private TAG: string = '[TabletSetResolution]:'; private itemValue: SettingData = new SettingData(); private WH_100_100: string = "100%"; private settingManager: SettingManager = SettingManager.getInstance(); private setAlias: string = ''; - @StorageLink('settingDialogFlag') settingDialogFlag: boolean = true; - @State curCheckName: Resource = $r('app.string.default_value'); - @State state: StateStruct = new StateStruct(); private mAction: SetResolutionDispatcher = new SetResolutionDispatcher(); - @Provide customDialogDetails: CustomDialogDetails = { - confirmCallback: () => {}, + confirmCallback: () => { + }, confirmItem: true, height: 256, width: 256, @@ -62,13 +68,6 @@ export struct TabletSetResolution { settingTitle: '', // dialogCloseFlag:false } - CustomDialogView: CustomDialogController = new CustomDialogController({ - builder: CustomDialogView({ cancel: () => this.existView }), - autoCancel: true, - alignment: DialogAlignment.Center, - cancel: this.existView, - customStyle: true - }) existView() { Log.info(`${this.TAG} existView E`) @@ -83,7 +82,7 @@ export struct TabletSetResolution { Log.info(`${this.TAG} aboutToAppear settingsList: ${JSON.stringify(this.settingsList)} E`) getStore().subscribe((state: OhCombinedState) => { this.state = { - isCloseFlag:state.settingReducer.isCloseFlag + isCloseFlag: state.settingReducer.isCloseFlag }; }, (dispatch: Dispatch) => { this.mAction.setDispatch(dispatch); diff --git a/common/src/main/ets/default/featurecommon/settingview/tablet/TabletSetToggle.ets b/common/src/main/ets/default/featurecommon/settingview/tablet/TabletSetToggle.ets index 0d4fcb023e5509e7e7fd2e8d876da04ed0b0442a..0bdd4e5714bdad875c70f2e3cf2773066cc3e980 100644 --- a/common/src/main/ets/default/featurecommon/settingview/tablet/TabletSetToggle.ets +++ b/common/src/main/ets/default/featurecommon/settingview/tablet/TabletSetToggle.ets @@ -13,35 +13,34 @@ * limitations under the License. */ -import { Log } from '../../../utils/Log' -import { SettingManager } from '../../../setting/SettingManager' -import { SettingData, SettingGroupItem } from '../model/SettingData' -import { Dispatch, OhCombinedState } from '../../../redux/store' -import { getStore } from '../../../redux/store'; +import { Log } from '../../../utils/Log'; +import { SettingManager } from '../../../setting/SettingManager'; +import { SettingData, SettingGroupItem } from '../model/SettingData'; +import { Dispatch, getStore, OhCombinedState } from '../../../redux/store'; class StateStruct { mode: string = '' } class SetToggleDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } + + private mDispatch: Dispatch = (data) => data; } @Component export struct TabletSetToggle { - private TAG: string = '[TabletSetToggle]:' @Link settingsList: SettingGroupItem[] @State isOn: boolean = false + @State generalStatusValue: boolean = false + @State state: StateStruct = new StateStruct() + private TAG: string = '[TabletSetToggle]:' private itemValue: SettingData = new SettingData(); // private getToggleStatus: Promise private WH_100_100: string = "100%" private settingManager = SettingManager.getInstance() - @State generalStatusValue: boolean = false - @State state: StateStruct = new StateStruct() private mAction: SetToggleDispatcher = new SetToggleDispatcher(); aboutToAppear() { @@ -95,7 +94,8 @@ export struct TabletSetToggle { .opacity($r('sys.float.ohos_id_alpha_content_secondary')) }.margin({ top: $r('sys.float.ohos_id_text_margin_vertical'), - left: 40 }) + left: 40 + }) } } .layoutWeight(1) @@ -119,7 +119,12 @@ export struct TabletSetToggle { } .margin({ left: $r('sys.float.ohos_id_card_margin_end') }) } - .padding({ left: 12, right: 12, top: 4, bottom: 4 }) + .padding({ + left: 12, + right: 12, + top: 4, + bottom: 4 + }) } .height(this.itemValue?.description ? 72 : 56) .width(this.WH_100_100) diff --git a/common/src/main/ets/default/featurecommon/settingview/tablet/TabletSettingItem.ets b/common/src/main/ets/default/featurecommon/settingview/tablet/TabletSettingItem.ets index 0b217e2896344dfcefbbdf45613d863790f8cc58..a582b7cf35c6a0d1caf5c441db2d904cf9101ec5 100644 --- a/common/src/main/ets/default/featurecommon/settingview/tablet/TabletSettingItem.ets +++ b/common/src/main/ets/default/featurecommon/settingview/tablet/TabletSettingItem.ets @@ -17,19 +17,20 @@ import { SettingManager } from '../../../setting/SettingManager' import { Log } from '../../../utils/Log' import { TabletSetResolution } from './TabletSetResolution' import { TabletSetToggle } from './TabletSetToggle' -import { BaseData } from '../model/BaseData' import { SettingData, SettingGroupItem } from '../model/SettingData' @Component export struct TabletSettingItem { - private TAG: string = '[TabletSettingItem]:' @Link settingsList: SettingGroupItem[] @Link closeFlag: Boolean + private TAG: string = '[TabletSettingItem]:' private item: SettingGroupItem = new SettingGroupItem(); private index: number = 0 private settingsListIndex: number = 0 - private getPhotoValue: Promise = new Promise(() => {}); - private getVideoValue: Promise = new Promise(() => {}); + private getPhotoValue: Promise = new Promise(() => { + }); + private getVideoValue: Promise = new Promise(() => { + }); private WH_100_100: string = "100%" private settingManager = SettingManager.getInstance() @@ -40,15 +41,19 @@ export struct TabletSettingItem { } build() { - Flex({ direction: FlexDirection.Column, + Flex({ + direction: FlexDirection.Column, alignItems: ItemAlign.Center, - justifyContent: FlexAlign.SpaceBetween }) { + justifyContent: FlexAlign.SpaceBetween + }) { Column() { Row() { Text(this.item.settingTitle) - .margin({ top: $r('app.float.margin_value_20'), + .margin({ + top: $r('app.float.margin_value_20'), left: $r('sys.float.ohos_id_card_margin_start'), - bottom: $r('app.float.margin_value_8') }) + bottom: $r('app.float.margin_value_8') + }) .fontColor($r('app.color.font_color_FFFFFF')) .opacity($r('app.float.opacity_6')) .fontSize($r('app.float.font_14')) @@ -83,7 +88,12 @@ export struct TabletSettingItem { }) } .listDirection(Axis.Vertical) - .divider({ strokeWidth: 0.5, color: '#33FFFFFF', startMargin: 56, endMargin: 12 }) + .divider({ + strokeWidth: 0.5, + color: '#33FFFFFF', + startMargin: 56, + endMargin: 12 + }) .borderRadius($r('sys.float.ohos_id_corner_radius_card')) .backgroundColor('#202224') .padding({ top: 4, bottom: 4 }) diff --git a/common/src/main/ets/default/featurecommon/shutterbutton/ShutterButton.ets b/common/src/main/ets/default/featurecommon/shutterbutton/ShutterButton.ets index f553e1f958ecbf066e5ed18771f0037885a29413..af3f1492afc6542b7f8dc35a580bb9a91a8bba0d 100644 --- a/common/src/main/ets/default/featurecommon/shutterbutton/ShutterButton.ets +++ b/common/src/main/ets/default/featurecommon/shutterbutton/ShutterButton.ets @@ -16,8 +16,7 @@ import router from '@system.router'; import image from '@ohos.multimedia.image'; import { Log } from '../../utils/Log'; -import { Dispatch, OhCombinedState } from '../../redux/store'; -import { getStore } from '../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../redux/store'; import { Action } from '../../redux/actions/Action'; import { EventBus } from '../../worker/eventbus/EventBus'; import { EventBusManager } from '../../worker/eventbus/EventBusManager'; @@ -42,8 +41,6 @@ class StateStruct { class ShutterButtonDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -89,6 +86,8 @@ class ShutterButtonDispatcher { public changeTimeLapse(isShowtimeLapse: boolean): void { this.mDispatch(Action.changeTimeLapse(isShowtimeLapse)); } + + private mDispatch: Dispatch = (data) => data; } class ModeStruct { @@ -102,13 +101,13 @@ class UpdateThumbnailStruct { @Component export struct ShutterButton { - private TAG: string = '[ShutterButton]:'; - private appEventBus: EventBus = EventBusManager.getInstance().getEventBus(); - private settingManager = SettingManager.getInstance(); type: ButtonType = ButtonType.Capsule; stateEffect: boolean = false; @State state: StateStruct = new StateStruct(); @State captureBtnScale: number = 1; + private TAG: string = '[ShutterButton]:'; + private appEventBus: EventBus = EventBusManager.getInstance().getEventBus(); + private settingManager = SettingManager.getInstance(); private mAction: ShutterButtonDispatcher = new ShutterButtonDispatcher(); aboutToAppear() { @@ -145,61 +144,15 @@ export struct ShutterButton { Log.info(`${this.TAG} aboutToDisappear X`); } - private async onThumbnailUpdate(data: UpdateThumbnailStruct): Promise { - Log.info(`${this.TAG} onThumbnailUpdate data: ${JSON.stringify(data)} E`) - Log.info(`${this.TAG} onThumbnailUpdate resourceUri= ${JSON.stringify(this.state.resourceUri)} E`) - Log.info(`${this.TAG} onThumbnailUpdate isThirdPartyCall= ${this.state.isThirdPartyCall} E`) - Log.info(`${this.TAG} onThumbnailUpdate videoUri= ${this.state.videoUri} E`) - if (this.state.isThirdPartyCall) { - Log.info(`${this.TAG} onThumbnailUpdate start router to ThirdPreviewView`) - router.push({ - uri: "pages/ThirdPreviewView", - params: { - width: this.state.xComponentWidth, - height: this.state.xComponentHeight, - mode: this.state.mode, - uri: this.state.resourceUri, - videoUri: this.state.videoUri, - callBundleName: this.getCallBundleName(), - } - }) - } - Log.info(`${this.TAG} onThumbnailUpdate this.state.thumbnail: ${JSON.stringify(this.state.thumbnail)} X`) - } - - private getCallBundleName(): string { - let parameters = GlobalContext.get().getCameraAbilityWant().parameters; - if (!parameters) { - return ''; - } - return parameters?.callBundleName as string; - } - - private async changeShutterIcon(data: ModeStruct): Promise { - Log.info(`${this.TAG} resetShutterIcon E`); - this.refreshIcon(data.mode) - Log.info(`${this.TAG} resetShutterIcon X`); - } - - private async refreshIcon(mode: string): Promise { - Log.info(`${this.TAG} refreshIcon E`); - if (mode === 'PHOTO') { - this.mAction.updateShutterIcon($r('app.media.ic_circled_filled')) - } else if (mode === 'VIDEO') { - this.mAction.updateShutterIcon($r('app.media.take_video_normal')) - } else { - this.mAction.updateShutterIcon($r('app.media.ic_circled_filled')) - } - Log.info(`${this.TAG} refreshIcon X`); - } - build() { if (this.state.videoState === 'beforeTakeVideo') { Stack({ alignContent: Alignment.Center }) { if (this.state.mode === 'VIDEO') { Image(this.state.shutterIcon) .key(ComponentIdKeys.SHUTTER_VIDEO_1) - .width(76).aspectRatio(1).enabled(this.state.uiEnable) + .width(76) + .aspectRatio(1) + .enabled(this.state.uiEnable) .onTouch((event?: TouchEvent) => { if (!event) { return; @@ -218,7 +171,10 @@ export struct ShutterButton { }) } else { Image($r('app.media.ic_circled')).fillColor(Color.White) - Image(this.state.shutterIcon).width(54).aspectRatio(1).fillColor(Color.White) + Image(this.state.shutterIcon) + .width(54) + .aspectRatio(1) + .fillColor(Color.White) .key(ComponentIdKeys.SHUTTER_PHOTO_1) .scale({ x: this.captureBtnScale, y: this.captureBtnScale, z: this.captureBtnScale }) .enabled(this.state.uiEnable) @@ -229,12 +185,22 @@ export struct ShutterButton { if (event.type === TouchType.Down) { animateTo( { duration: 125, curve: Curve.Sharp, delay: 0 }, - () => { this.captureBtnScale = 0.85 }) + () => { + this.captureBtnScale = 0.85 + }) } else if (event.type === TouchType.Up) { animateTo( - { duration: 125, curve: Curve.Sharp, delay: 0, - onFinish: () => { this.captureBtnScale = 1 }}, - () => { this.captureBtnScale = 1 }) + { + duration: 125, + curve: Curve.Sharp, + delay: 0, + onFinish: () => { + this.captureBtnScale = 1 + } + }, + () => { + this.captureBtnScale = 1 + }) let timerLapse = this.settingManager.getTimeLapse() Log.log(`${this.TAG} ShutterButton start capture getValue= ${JSON.stringify(timerLapse)}`) if (timerLapse && timerLapse.id !== Timer.RESOURCE_OFF.id) { @@ -282,13 +248,63 @@ export struct ShutterButton { .margin({ left: 6 }) .enabled(this.state.uiEnable) .onClick(() => { - this.state.videoState === 'startTakeVideo' ? this.mAction.pauseRecording() : this.mAction.resumeRecording() + this.state.videoState === 'startTakeVideo' ? this.mAction.pauseRecording() : this.mAction.resumeRecording() }) }.width('100%').height('100%') } - .width(120).height(56).borderRadius(28) + .width(120) + .height(56) + .borderRadius(28) .border({ width: 1, color: Color.White, style: BorderStyle.Solid }) .margin({ left: 24, right: 24 }) } } + + private async onThumbnailUpdate(data: UpdateThumbnailStruct): Promise { + Log.info(`${this.TAG} onThumbnailUpdate data: ${JSON.stringify(data)} E`) + Log.info(`${this.TAG} onThumbnailUpdate resourceUri= ${JSON.stringify(this.state.resourceUri)} E`) + Log.info(`${this.TAG} onThumbnailUpdate isThirdPartyCall= ${this.state.isThirdPartyCall} E`) + Log.info(`${this.TAG} onThumbnailUpdate videoUri= ${this.state.videoUri} E`) + if (this.state.isThirdPartyCall) { + Log.info(`${this.TAG} onThumbnailUpdate start router to ThirdPreviewView`) + router.push({ + uri: "pages/ThirdPreviewView", + params: { + width: this.state.xComponentWidth, + height: this.state.xComponentHeight, + mode: this.state.mode, + uri: this.state.resourceUri, + videoUri: this.state.videoUri, + callBundleName: this.getCallBundleName(), + } + }) + } + Log.info(`${this.TAG} onThumbnailUpdate this.state.thumbnail: ${JSON.stringify(this.state.thumbnail)} X`) + } + + private getCallBundleName(): string { + let parameters = GlobalContext.get().getCameraAbilityWant().parameters; + if (!parameters) { + return ''; + } + return parameters?.callBundleName as string; + } + + private async changeShutterIcon(data: ModeStruct): Promise { + Log.info(`${this.TAG} resetShutterIcon E`); + this.refreshIcon(data.mode) + Log.info(`${this.TAG} resetShutterIcon X`); + } + + private async refreshIcon(mode: string): Promise { + Log.info(`${this.TAG} refreshIcon E`); + if (mode === 'PHOTO') { + this.mAction.updateShutterIcon($r('app.media.ic_circled_filled')) + } else if (mode === 'VIDEO') { + this.mAction.updateShutterIcon($r('app.media.take_video_normal')) + } else { + this.mAction.updateShutterIcon($r('app.media.ic_circled_filled')) + } + Log.info(`${this.TAG} refreshIcon X`); + } } \ No newline at end of file diff --git a/common/src/main/ets/default/featurecommon/shutterbutton/ShutterButtonLand.ets b/common/src/main/ets/default/featurecommon/shutterbutton/ShutterButtonLand.ets index 0582cac5db4e0d4da0846ddfd794f40ec09fc120..a72daa82c632a38f0d5f22ab175cb7754d237ff1 100644 --- a/common/src/main/ets/default/featurecommon/shutterbutton/ShutterButtonLand.ets +++ b/common/src/main/ets/default/featurecommon/shutterbutton/ShutterButtonLand.ets @@ -19,8 +19,7 @@ import { Action } from '../../redux/actions/Action'; import { Log } from '../../utils/Log'; import { EventBus } from '../../worker/eventbus/EventBus'; import { EventBusManager } from '../../worker/eventbus/EventBusManager'; -import { Dispatch, OhCombinedState } from '../../redux/store'; -import { getStore } from '../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../redux/store'; import { SettingManager } from '../../setting/SettingManager'; import Timer from '../../setting/settingitem/Timer'; import { ComponentPosition } from '../../utils/ComponentPosition'; @@ -42,8 +41,6 @@ class StateStruct { } class ShutterButtonDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -89,6 +86,8 @@ class ShutterButtonDispatcher { public changeTimeLapse(isShowtimeLapse: boolean): void { this.mDispatch(Action.changeTimeLapse(isShowtimeLapse)); } + + private mDispatch: Dispatch = (data) => data; } class ScreenSizeType { @@ -107,15 +106,15 @@ class UpdateThumbnailStruct { @Component export struct ShutterButtonLand { - private TAG: string = '[ShutterButtonLand]:'; - private appEventBus: EventBus = EventBusManager.getInstance().getEventBus(); - private settingManager = SettingManager.getInstance(); - private lastTime = 0; @Link screenSize: ScreenSizeType; type: ButtonType = ButtonType.Capsule; stateEffect: boolean = false; @State state: StateStruct = new StateStruct(); @State captureBtnScale: number = 1; + private TAG: string = '[ShutterButtonLand]:'; + private appEventBus: EventBus = EventBusManager.getInstance().getEventBus(); + private settingManager = SettingManager.getInstance(); + private lastTime = 0; private mAction: ShutterButtonDispatcher = new ShutterButtonDispatcher(); aboutToAppear(): void { @@ -152,46 +151,6 @@ export struct ShutterButtonLand { Log.info(`${this.TAG} aboutToDisappear X`); } - private async onThumbnailUpdate(data: UpdateThumbnailStruct): Promise { - Log.info(`${this.TAG} onThumbnailUpdate data: ${JSON.stringify(data)} E`) - Log.info(`${this.TAG} onThumbnailUpdate resourceUri= ${JSON.stringify(this.state.resourceUri)} E`); - Log.info(`${this.TAG} onThumbnailUpdate isThirdPartyCall= ${this.state.isThirdPartyCall} E`) - Log.info(`${this.TAG} onThumbnailUpdate videoUri= ${this.state.videoUri} E`); - if (this.state.isThirdPartyCall) { - Log.info(`${this.TAG} onThumbnailUpdate start router to ThirdPreviewView`) - router.push({ - uri: "pages/ThirdPreviewView", - params: { - width: this.state.xComponentWidth, - height: this.state.xComponentHeight, - mode: this.state.mode, - uri: this.state.resourceUri, - videoUri: this.state.videoUri, - callBundleName: GlobalContext.get().getCameraAbilityWant()?.parameters?.callBundleName - } - }) - } - Log.info(`${this.TAG} onThumbnailUpdate this.state.thumbnail: ${JSON.stringify(this.state.thumbnail)} X`) - } - - private async changeShutterIcon(data: ModeStruct): Promise { - Log.info(`${this.TAG} resetShutterIcon E`); - this.refreshIcon(data.mode) - Log.info(`${this.TAG} resetShutterIcon X`); - } - - private async refreshIcon(mode: string): Promise { - Log.info(`${this.TAG} refreshIcon E`); - if (mode === 'PHOTO') { - this.mAction.updateShutterIcon($r('app.media.ic_circled_filled')) - } else if (mode === 'VIDEO') { - this.mAction.updateShutterIcon($r('app.media.take_video_normal')) - } else { - this.mAction.updateShutterIcon($r('app.media.ic_circled_filled')) - } - Log.info(`${this.TAG} refreshIcon X`); - } - build() { if (this.state.videoState === 'beforeTakeVideo') { Stack({ alignContent: Alignment.Center }) { @@ -226,10 +185,14 @@ export struct ShutterButtonLand { }) } else if (event.type === TouchType.Up) { animateTo( - { duration: 125, curve: Curve.Sharp, delay: 0, + { + duration: 125, + curve: Curve.Sharp, + delay: 0, onFinish: () => { this.captureBtnScale = 1 - } }, + } + }, () => { this.captureBtnScale = 1 }) @@ -250,8 +213,10 @@ export struct ShutterButtonLand { }) } }.width(76).aspectRatio(1).margin({ - top: ComponentPosition.getShutterButtonMargin(this.screenSize.width, this.screenSize.height, this.state.xComponentHeight), - bottom: ComponentPosition.getShutterButtonMargin(this.screenSize.width, this.screenSize.height, this.state.xComponentHeight) + top: ComponentPosition.getShutterButtonMargin(this.screenSize.width, this.screenSize.height, + this.state.xComponentHeight), + bottom: ComponentPosition.getShutterButtonMargin(this.screenSize.width, this.screenSize.height, + this.state.xComponentHeight) }) } else { Column() { @@ -295,4 +260,44 @@ export struct ShutterButtonLand { .margin({ top: 26, bottom: 26 }) } } + + private async onThumbnailUpdate(data: UpdateThumbnailStruct): Promise { + Log.info(`${this.TAG} onThumbnailUpdate data: ${JSON.stringify(data)} E`) + Log.info(`${this.TAG} onThumbnailUpdate resourceUri= ${JSON.stringify(this.state.resourceUri)} E`); + Log.info(`${this.TAG} onThumbnailUpdate isThirdPartyCall= ${this.state.isThirdPartyCall} E`) + Log.info(`${this.TAG} onThumbnailUpdate videoUri= ${this.state.videoUri} E`); + if (this.state.isThirdPartyCall) { + Log.info(`${this.TAG} onThumbnailUpdate start router to ThirdPreviewView`) + router.push({ + uri: "pages/ThirdPreviewView", + params: { + width: this.state.xComponentWidth, + height: this.state.xComponentHeight, + mode: this.state.mode, + uri: this.state.resourceUri, + videoUri: this.state.videoUri, + callBundleName: GlobalContext.get().getCameraAbilityWant()?.parameters?.callBundleName + } + }) + } + Log.info(`${this.TAG} onThumbnailUpdate this.state.thumbnail: ${JSON.stringify(this.state.thumbnail)} X`) + } + + private async changeShutterIcon(data: ModeStruct): Promise { + Log.info(`${this.TAG} resetShutterIcon E`); + this.refreshIcon(data.mode) + Log.info(`${this.TAG} resetShutterIcon X`); + } + + private async refreshIcon(mode: string): Promise { + Log.info(`${this.TAG} refreshIcon E`); + if (mode === 'PHOTO') { + this.mAction.updateShutterIcon($r('app.media.ic_circled_filled')) + } else if (mode === 'VIDEO') { + this.mAction.updateShutterIcon($r('app.media.take_video_normal')) + } else { + this.mAction.updateShutterIcon($r('app.media.ic_circled_filled')) + } + Log.info(`${this.TAG} refreshIcon X`); + } } \ No newline at end of file diff --git a/common/src/main/ets/default/featurecommon/tabbar/TabBar.ets b/common/src/main/ets/default/featurecommon/tabbar/TabBar.ets index f6f2b0c1b1b21c78777e7469e74e79669b310286..c98fd31b08fd340d1fbc5d75b06c11de33b1f7c9 100644 --- a/common/src/main/ets/default/featurecommon/tabbar/TabBar.ets +++ b/common/src/main/ets/default/featurecommon/tabbar/TabBar.ets @@ -14,8 +14,7 @@ */ import { Log } from '../../utils/Log'; -import { Dispatch, OhCombinedState } from '../../redux/store'; -import { getStore } from '../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../redux/store'; import { Action } from '../../redux/actions/Action'; class StateStruct { @@ -23,8 +22,6 @@ class StateStruct { } class TabBarDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -32,14 +29,15 @@ class TabBarDispatcher { public showSettingView(isShowSettingView: boolean): void { this.mDispatch(Action.showSettingView(isShowSettingView)); } + + private mDispatch: Dispatch = (data) => data; } @Component export struct TabBar { - private TAG: string = '[TabBar]'; @State state: StateStruct = new StateStruct(); - private onBackClicked: Function = () => {}; + private TAG: string = '[TabBar]'; private mAction: TabBarDispatcher = new TabBarDispatcher(); aboutToAppear(): void { @@ -59,6 +57,7 @@ export struct TabBar { Column() { // TabBarOther() }.width('40%').height('100%') + Column() { if (this.state.isThirdPartyCall) { Row() { @@ -68,10 +67,11 @@ export struct TabBar { this.onBackClicked() }) }.width(48).height(48) - .padding({left: 12}) + .padding({ left: 12 }) .margin({ bottom: 12 }) } }.width('40%').height('100%') + Column() { Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Image($r('app.media.setting')).width(24).height(24) @@ -81,4 +81,7 @@ export struct TabBar { }) }.width('100%').height('100%') } + + private onBackClicked: Function = () => { + }; } \ No newline at end of file diff --git a/common/src/main/ets/default/featurecommon/tabbar/TabBarLand.ets b/common/src/main/ets/default/featurecommon/tabbar/TabBarLand.ets index 689b0f0f9938d6bedf9c642bf14d1d41d20bc7cd..16329c89c605de76cafc99cef7e42caa883f32ed 100644 --- a/common/src/main/ets/default/featurecommon/tabbar/TabBarLand.ets +++ b/common/src/main/ets/default/featurecommon/tabbar/TabBarLand.ets @@ -17,8 +17,7 @@ import { Action } from '../../redux/actions/Action' import { Log } from '../../utils/Log' import { EventBus } from '../../worker/eventbus/EventBus' import { EventBusManager } from '../../worker/eventbus/EventBusManager' -import { Dispatch, OhCombinedState } from '../../redux/store' -import { getStore } from '../../redux/store' +import { Dispatch, getStore, OhCombinedState } from '../../redux/store' import ReportUtil from '../../utils/ReportUtil' class StateStruct { @@ -31,8 +30,6 @@ class ScreenSizeType { } class TabBarDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -40,18 +37,18 @@ class TabBarDispatcher { public showSettingView(isShowSettingView: boolean): void { this.mDispatch(Action.showSettingView(isShowSettingView)); } + + private mDispatch: Dispatch = (data) => data; } @Component export struct TabBarLand { - private TAG: string = '[TabBarLand]'; @State state: StateStruct = new StateStruct(); @State opacityTabBar: number = 0; @State isShowTabBarOther: boolean = false; @Link screenSize: ScreenSizeType; - private onBackClicked: Function = () => { - }; appEventBus: EventBus = EventBusManager.getInstance().getEventBus(); + private TAG: string = '[TabBarLand]'; private mAction: TabBarDispatcher = new TabBarDispatcher(); aboutToAppear(): void { @@ -91,4 +88,7 @@ export struct TabBarLand { .position(this.state.isThirdPartyCall ? { x: 0, y: 12 } : { x: 0, y: this.screenSize.height - 144 }) }.width(48).height('100%') } + + private onBackClicked: Function = () => { + }; } \ No newline at end of file diff --git a/common/src/main/ets/default/featurecommon/thumbnail/ThumbnailView.ets b/common/src/main/ets/default/featurecommon/thumbnail/ThumbnailView.ets index 7351f91b3b72804d041509080a0cffeb0b214bd1..19172b336a6d3cdabaf48864b4b4415aa69bed46 100644 --- a/common/src/main/ets/default/featurecommon/thumbnail/ThumbnailView.ets +++ b/common/src/main/ets/default/featurecommon/thumbnail/ThumbnailView.ets @@ -14,8 +14,7 @@ */ import { Log } from '../../utils/Log'; -import { Dispatch, OhCombinedState } from '../../redux/store'; -import { getStore } from '../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../redux/store'; import { Action } from '../../redux/actions/Action'; import { EventBus } from '../../worker/eventbus/EventBus'; import { EventBusManager } from '../../worker/eventbus/EventBusManager'; @@ -42,60 +41,26 @@ class StartAbilityParameterStruct { } class ThumbnailViewDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } + + private mDispatch: Dispatch = (data) => data; } @Component export struct ThumbnailView { - private TAG: string = '[ThumbnailView]:' - private appEventBus: EventBus = EventBusManager.getInstance().getEventBus() @State thumbnailBorder: BorderOptions = {}; @State state: StateStruct = new StateStruct() @State thumbnail: Resource | PixelMap = $r('app.media.ic_camera_thumbnail_default_white') @State hasThumbnail: boolean = false @State scaleValue: number = 1 @State tempOpacity: number = 1 + private TAG: string = '[ThumbnailView]:' + private appEventBus: EventBus = EventBusManager.getInstance().getEventBus() private cameraService = CameraService.getInstance() private mAction: ThumbnailViewDispatcher = new ThumbnailViewDispatcher(); - private async onThumbnailUpdate(data: UpdateThumbnailStruct): Promise { - Log.info(`${this.TAG} onThumbnailUpdate data: ${JSON.stringify(data)} E`) - this.thumbnail = (data.thumbnail == null ? $r('app.media.ic_camera_thumbnail_default_white') : data.thumbnail) - this.hasThumbnail = data.thumbnail != undefined - if (this.hasThumbnail) { - this.thumbnailBorder = { width: 1, color: Color.White, style: BorderStyle.Solid } - } else { - this.thumbnailBorder = { width: 0 } - } - this.scaleValue = 1.5 - this.tempOpacity = 0.0 - animateTo({ duration: 100, curve: Curve.Sharp }, () => { - this.tempOpacity = 1 - }) - animateTo({ duration: 300, curve: Curve.Sharp }, () => { - this.scaleValue = 1 - }) - Log.info(`${this.TAG} onThumbnailUpdate this.state.thumbnail: ${JSON.stringify(this.thumbnail)} X`) - } - - private async onThumbnailLoad(data: ThumbnailStruct): Promise { - Log.info(`${this.TAG} onThumbnailLoad data: ${JSON.stringify(data)} E`) - this.thumbnail = (data.thumbnail == null ? $r('app.media.ic_camera_thumbnail_default_white') : data.thumbnail) - this.hasThumbnail = data.thumbnail != undefined - if (this.hasThumbnail) { - this.thumbnailBorder = { width: 1, color: Color.White, style: BorderStyle.Solid } - } else { - this.thumbnailBorder = { width: 0 } - } - this.scaleValue = 1 - this.tempOpacity = 1 - Log.info(`${this.TAG} onThumbnailLoad this.state.thumbnail: ${JSON.stringify(this.thumbnail)} X`) - } - aboutToAppear() { Log.info(`${this.TAG} aboutToAppear E`) getStore().subscribe((state: OhCombinedState) => { @@ -143,6 +108,40 @@ export struct ThumbnailView { .scale({ x: this.scaleValue, y: this.scaleValue }) } + private async onThumbnailUpdate(data: UpdateThumbnailStruct): Promise { + Log.info(`${this.TAG} onThumbnailUpdate data: ${JSON.stringify(data)} E`) + this.thumbnail = (data.thumbnail == null ? $r('app.media.ic_camera_thumbnail_default_white') : data.thumbnail) + this.hasThumbnail = data.thumbnail != undefined + if (this.hasThumbnail) { + this.thumbnailBorder = { width: 1, color: Color.White, style: BorderStyle.Solid } + } else { + this.thumbnailBorder = { width: 0 } + } + this.scaleValue = 1.5 + this.tempOpacity = 0.0 + animateTo({ duration: 100, curve: Curve.Sharp }, () => { + this.tempOpacity = 1 + }) + animateTo({ duration: 300, curve: Curve.Sharp }, () => { + this.scaleValue = 1 + }) + Log.info(`${this.TAG} onThumbnailUpdate this.state.thumbnail: ${JSON.stringify(this.thumbnail)} X`) + } + + private async onThumbnailLoad(data: ThumbnailStruct): Promise { + Log.info(`${this.TAG} onThumbnailLoad data: ${JSON.stringify(data)} E`) + this.thumbnail = (data.thumbnail == null ? $r('app.media.ic_camera_thumbnail_default_white') : data.thumbnail) + this.hasThumbnail = data.thumbnail != undefined + if (this.hasThumbnail) { + this.thumbnailBorder = { width: 1, color: Color.White, style: BorderStyle.Solid } + } else { + this.thumbnailBorder = { width: 0 } + } + this.scaleValue = 1 + this.tempOpacity = 1 + Log.info(`${this.TAG} onThumbnailLoad this.state.thumbnail: ${JSON.stringify(this.thumbnail)} X`) + } + private buildCameraAbilityWant(parameter: Record): Want { let res: Want = { parameters: parameter, diff --git a/common/src/main/ets/default/featurecommon/timelapseview/TimeLapseView.ets b/common/src/main/ets/default/featurecommon/timelapseview/TimeLapseView.ets index d1e3439bf38f16a51b805413dc05fa981d97ca52..fc9c4c5e71a9d565406c6718b9578d385cae5fae 100644 --- a/common/src/main/ets/default/featurecommon/timelapseview/TimeLapseView.ets +++ b/common/src/main/ets/default/featurecommon/timelapseview/TimeLapseView.ets @@ -13,10 +13,9 @@ * limitations under the License. */ -import { BusinessError } from "@ohos.base"; +import { BusinessError } from '@ohos.base'; import { Log } from '../../utils/Log'; -import { Dispatch, OhCombinedState } from '../../redux/store'; -import { getStore } from '../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../redux/store'; import { Action } from '../../redux/actions/Action'; import { SettingManager } from '../../setting/SettingManager'; import Timer from '../../setting/settingitem/Timer'; @@ -29,8 +28,6 @@ class StateStruct { } class TimeLapseViewDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -50,6 +47,8 @@ class TimeLapseViewDispatcher { this.mDispatch(Action.updateBigVideoTimerVisible(true)); this.mDispatch(Action.updateScreenStatus(true)); } + + private mDispatch: Dispatch = (data) => data; } class KeepScreenStruct { @@ -58,30 +57,14 @@ class KeepScreenStruct { @Component export struct TimeLapseView { - private TAG: string = '[TimeLapseView]:' - private timer: number = 0 - private settingManager = SettingManager.getInstance() appEventBus: EventBus = EventBusManager.getInstance().getEventBus() @State state: StateStruct = new StateStruct() @State timerLapse: number = 0 + private TAG: string = '[TimeLapseView]:' + private timer: number = 0 + private settingManager = SettingManager.getInstance() private mAction: TimeLapseViewDispatcher = new TimeLapseViewDispatcher(); - private onKeepScreen(data: KeepScreenStruct): void { - Log.info(`${this.TAG} onKeepScreen E`) - if (data) { - GlobalContext.get() - .getCameraWinClass() - .setKeepScreenOn(data.isKeepScreenOn) - .then(() => { - Log.info('Succeeded in setting the screen to be always on'); - }) - .catch((err: BusinessError) => { - Log.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); - }); - } - Log.info(`${this.TAG} onKeepScreen X`) - } - aboutToAppear() { Log.info(`${this.TAG} aboutToAppear E`) getStore().subscribe((state: OhCombinedState) => { @@ -144,4 +127,20 @@ export struct TimeLapseView { .textAlign(TextAlign.Center) }.width('100%').height('100%') } + + private onKeepScreen(data: KeepScreenStruct): void { + Log.info(`${this.TAG} onKeepScreen E`) + if (data) { + GlobalContext.get() + .getCameraWinClass() + .setKeepScreenOn(data.isKeepScreenOn) + .then(() => { + Log.info('Succeeded in setting the screen to be always on'); + }) + .catch((err: BusinessError) => { + Log.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); + }); + } + Log.info(`${this.TAG} onKeepScreen X`) + } } \ No newline at end of file diff --git a/common/src/main/ets/default/featurecommon/zoomview/ZoomText.ets b/common/src/main/ets/default/featurecommon/zoomview/ZoomText.ets index e7adab50453e67ae60ccfb4b6b6a636dd679461c..98b6c01d17584238a0521e56f3a2a5e9ec1b701f 100644 --- a/common/src/main/ets/default/featurecommon/zoomview/ZoomText.ets +++ b/common/src/main/ets/default/featurecommon/zoomview/ZoomText.ets @@ -14,25 +14,24 @@ */ import { Log } from '../../utils/Log'; -import { Dispatch, OhCombinedState } from '../../redux/store'; -import { getStore } from '../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../redux/store'; class StateStruct { zoomRatio: number = 1; } class ZoomTextDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } + + private mDispatch: Dispatch = (data) => data; } @Component export struct ZoomText { - private TAG: string = '[ZoomText]' @Link state: StateStruct + private TAG: string = '[ZoomText]' private mAction: ZoomTextDispatcher = new ZoomTextDispatcher(); aboutToAppear() { diff --git a/common/src/main/ets/default/featurecommon/zoomview/ZoomView.ets b/common/src/main/ets/default/featurecommon/zoomview/ZoomView.ets index 5c7d9a5627ebc14795298fb31cfa9c5c8421a588..9f9953025c57e6d2640b2a3f11b926fdc33c30c4 100644 --- a/common/src/main/ets/default/featurecommon/zoomview/ZoomView.ets +++ b/common/src/main/ets/default/featurecommon/zoomview/ZoomView.ets @@ -13,8 +13,7 @@ * limitations under the License. */ -import { Dispatch, OhCombinedState, Unsubscribe } from '../../redux/store'; -import { getStore } from '../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../redux/store'; import { Action } from '../../redux/actions/Action'; import { EventBus } from '../../worker/eventbus/EventBus'; import { EventBusManager } from '../../worker/eventbus/EventBusManager'; @@ -36,8 +35,6 @@ class StateStruct { } class ZoomViewDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -53,6 +50,8 @@ class ZoomViewDispatcher { public updateShowZoomLabelValue(flag: boolean): void { this.mDispatch(Action.updateShowZoomLabelValue(flag)); } + + private mDispatch: Dispatch = (data) => data; } class ZoomRatioStruct { @@ -65,10 +64,10 @@ class VideoStateStruct { @Component export struct ZoomView { - private appEventBus: EventBus = EventBusManager.getInstance().getEventBus() @State state: StateStruct = new StateStruct(); @State offsetX: number = 0 @State triggerRebuildNum: number = 0 + private appEventBus: EventBus = EventBusManager.getInstance().getEventBus() private mAction: ZoomViewDispatcher = new ZoomViewDispatcher(); private notTakeVideoExtCanvasWidth: number = 360 private takingVideoExtCanvasWidth: number = 196 @@ -81,11 +80,11 @@ export struct ZoomView { private takingVideoExtCanvasCtx: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.canvasSettings) private foldCanvasCtx: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.canvasSettings) private notTakeVideoExtOffCanvasCtx: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D( - this.notTakeVideoExtCanvasWidth, this.canvasHeight, this.canvasSettings) + this.notTakeVideoExtCanvasWidth, this.canvasHeight, this.canvasSettings) private takingVideoExtOffCanvasCxt: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D( - this.takingVideoExtCanvasWidth, this.canvasHeight, this.canvasSettings) + this.takingVideoExtCanvasWidth, this.canvasHeight, this.canvasSettings) private foldOffCanvasCtx: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D( - this.foldCanvasWidth, this.canvasHeight, this.canvasSettings) + this.foldCanvasWidth, this.canvasHeight, this.canvasSettings) private lpgTimer: number = 0 private pgTimer: number = 0 private lpgExp: boolean = false @@ -120,12 +119,245 @@ export struct ZoomView { this.appEventBus.off(Action.ACTION_UPDATE_VIDEO_STATE, (data: VideoStateStruct) => this.updateZoomState(data)) } + build() { + Stack({ alignContent: Alignment.Top }) { + Stack({ alignContent: Alignment.Top }) + .width(this.offsetX + this.touchedOffsetX + this.state.zoomRatio) + .height(this.triggerRebuildNum) + .visibility(Visibility.None) + if (this.getCurrentCanvasType() === SHOW_NOT_TAKE_VIDEO_CANVAS) { + Canvas(this.notTakeVideoExtCanvasCtx) + .width(this.notTakeVideoExtCanvasWidth) + .height(this.canvasHeight) + .onReady(() => { + this.notTakeVideoExtCanvasCtx.clearRect(0, 0, this.notTakeVideoExtCanvasWidth, this.canvasHeight) + this.notTakeVideoExtOffCanvasCtx.clearRect(0, 0, this.notTakeVideoExtCanvasWidth, this.canvasHeight) + this.notTakeVideoExtOffCanvasCtx.strokeStyle = '#ffffff' + this.notTakeVideoExtOffCanvasCtx.fillStyle = '#ffffff' + this.notTakeVideoExtOffCanvasCtx.lineWidth = 1.5 + this.notTakeVideoExtOffCanvasCtx.beginPath() + this.notTakeVideoExtOffCanvasCtx.arc(this.getZoomBtnCenterX(), this.canvasHeight / 2, + this.getZoomBtnRadius(), 0, 6.28) + this.notTakeVideoExtOffCanvasCtx.stroke() + if (this.state.showZoomLabelValue) { + this.notTakeVideoExtOffCanvasCtx.font = `bold ${vp2px(11)}px` + this.notTakeVideoExtOffCanvasCtx.textAlign = 'center' + this.notTakeVideoExtOffCanvasCtx.fillText(this.getZoomText(), this.getZoomBtnCenterX(), + this.canvasHeight / 2 + 5) + } else { + this.notTakeVideoExtOffCanvasCtx.beginPath() + this.notTakeVideoExtOffCanvasCtx.arc(this.getZoomBtnCenterX(), this.canvasHeight / 2, + this.centerDotRadius, 0, 6.28) + this.notTakeVideoExtOffCanvasCtx.fill() + } + + let spotCount = + (this.notTakeVideoExtCanvasWidth - this.getPadding() * 2 - this.mainDotRadius * 4 - this.dotSpacing) / + (this.dotSpacing + this.secDotRadius * 2) + 2 + for (let i = 0; i < spotCount; i++) { + let spotCenter = 0 + let spotRadius = 0 + if (i === 0) { + spotRadius = this.mainDotRadius + spotCenter = this.getPadding() + spotRadius + this.notTakeVideoExtOffCanvasCtx.font = `bold ${vp2px(11)}px` + this.notTakeVideoExtOffCanvasCtx.textAlign = 'center' + this.notTakeVideoExtOffCanvasCtx.fillText(`${this.state.minZoomRatio}x`, spotCenter, + this.canvasHeight / 2 - (!this.state.showZoomLabelValue ? 26 : 24)) + } else if (i === spotCount - 1) { + spotRadius = this.mainDotRadius + spotCenter = this.notTakeVideoExtCanvasWidth - this.getPadding() - spotRadius + this.notTakeVideoExtOffCanvasCtx.font = `bold ${vp2px(11)}px` + this.notTakeVideoExtOffCanvasCtx.textAlign = 'center' + this.notTakeVideoExtOffCanvasCtx.fillText(`${this.state.maxZoomRatio}x`, spotCenter, + this.canvasHeight / 2 - (!this.state.showZoomLabelValue ? 26 : 24)) + } else { + spotRadius = this.secDotRadius + spotCenter = + this.getPadding() + this.mainDotRadius + (2 * i - 1) * this.secDotRadius + i * this.dotSpacing + this.notTakeVideoExtOffCanvasCtx.globalAlpha = 0.2 + } + if (spotCenter < this.getZoomBtnCenterX() - this.getZoomBtnRadius() || + spotCenter > this.getZoomBtnCenterX() + this.getZoomBtnRadius()) { + this.notTakeVideoExtOffCanvasCtx.beginPath() + this.notTakeVideoExtOffCanvasCtx.arc(spotCenter, this.canvasHeight / 2, spotRadius, 0, 6.28) + this.notTakeVideoExtOffCanvasCtx.fill() + } + this.notTakeVideoExtOffCanvasCtx.globalAlpha = 1 + } + this.notTakeVideoExtCanvasCtx.transferFromImageBitmap(this.notTakeVideoExtOffCanvasCtx.transferToImageBitmap()) + }) + .gesture(GestureGroup(GestureMode.Parallel, + PanGesture({ fingers: 1, distance: 1, direction: PanDirection.Horizontal }) + .onActionStart(() => this.pgOnActionStart()) + .onActionUpdate((event?: GestureEvent) => { + if (event) { + return this.pgOnActionUpdate(event); + } + }) + .onActionEnd(() => this.pgOnActionEnd()))) + .onTouch((event?: TouchEvent) => { + if (event) { + return this.mOnTouch(event); + } + }) + } else if (this.getCurrentCanvasType() === SHOW_TAKING_VIDEO_CANVAS) { + Row() { + Image($r('app.media.ic_camera_public_focus_ev_bright_subtract')) + .width(24) + .height(24) + .fillColor(Color.White) + .onTouch((event?: TouchEvent) => this.subtractTouched(event)) + .gesture( + GestureGroup( + GestureMode.Parallel, + LongPressGesture({ repeat: true }) + .onAction((event?: GestureEvent) => this.subtractLongOnAction(event)) + .onActionEnd(() => this.subtractLongOnActionEnd()), + ) + ) + Canvas(this.takingVideoExtCanvasCtx) + .width(this.takingVideoExtCanvasWidth) + .height(this.canvasHeight) + .onReady(() => { + this.takingVideoExtCanvasCtx.clearRect(0, 0, this.takingVideoExtCanvasWidth, this.canvasHeight) + this.takingVideoExtOffCanvasCxt.clearRect(0, 0, this.takingVideoExtCanvasWidth, this.canvasHeight) + this.takingVideoExtOffCanvasCxt.strokeStyle = '#ffffff' + this.takingVideoExtOffCanvasCxt.fillStyle = '#ffffff' + this.takingVideoExtOffCanvasCxt.lineWidth = 1.5 + this.takingVideoExtOffCanvasCxt.beginPath() + this.takingVideoExtOffCanvasCxt.arc(this.getZoomBtnCenterX(), this.canvasHeight / 2, + this.getZoomBtnRadius(), 0, 6.28) + this.takingVideoExtOffCanvasCxt.stroke() + if (this.state.isShowZoomText) { + this.takingVideoExtOffCanvasCxt.beginPath() + this.takingVideoExtOffCanvasCxt.arc(this.getZoomBtnCenterX(), this.canvasHeight / 2, + this.centerDotRadius, 0, 6.28) + this.takingVideoExtOffCanvasCxt.fill() + } else { + this.takingVideoExtOffCanvasCxt.font = `bold ${vp2px(11)}px` + this.takingVideoExtOffCanvasCxt.textAlign = 'center' + this.takingVideoExtOffCanvasCxt.fillText(this.getZoomText(), this.getZoomBtnCenterX(), + this.canvasHeight / 2 + 5) + } + + let spotCount = 30 + for (let i = 0; i < spotCount; i++) { + let spotCenter = 0 + let spotRadius = 0 + spotRadius = this.secDotRadius + spotCenter = this.getPadding() + (2 * i + 1) * this.secDotRadius + i * this.dotSpacing + this.takingVideoExtOffCanvasCxt.globalAlpha = 0.2 + if (spotCenter < this.getZoomBtnCenterX() - this.getZoomBtnRadius() || + spotCenter > this.getZoomBtnCenterX() + this.getZoomBtnRadius()) { + this.takingVideoExtOffCanvasCxt.beginPath() + this.takingVideoExtOffCanvasCxt.arc(spotCenter, this.canvasHeight / 2, spotRadius, 0, 6.28) + this.takingVideoExtOffCanvasCxt.fill() + } + this.takingVideoExtOffCanvasCxt.globalAlpha = 1 + } + + this.takingVideoExtCanvasCtx.transferFromImageBitmap(this.takingVideoExtOffCanvasCxt.transferToImageBitmap()) + }) + .gesture( + GestureGroup( + GestureMode.Parallel, + LongPressGesture({ repeat: true }) + .onAction((event?: GestureEvent) => this.takingVideoExtLongPgAction(event)) + .onActionEnd(() => this.takingVideoExtLongPgActionEnd()), + PanGesture({ fingers: 1, distance: 1, direction: PanDirection.Horizontal }) + .onActionStart((event?: GestureEvent) => this.takingVideoExtPgActionStart(event)) + .onActionUpdate((event?: GestureEvent) => this.takingVideoExtPgActionUpdate(event)) + .onActionEnd((event?: GestureEvent) => this.takingVideoExtPgActionEnd(event)) + )) + .onTouch((event?: TouchEvent) => this.takingVideoExtTouched(event)) + Image($r('app.media.ic_camera_public_focus_ev_bright_add')) + .width(24) + .height(24) + .fillColor(Color.White) + .onTouch((event?: TouchEvent) => this.addTouched(event)) + .gesture( + GestureGroup( + GestureMode.Parallel, + LongPressGesture({ repeat: true }) + .onAction(() => this.addLongOnAction()) + .onActionEnd(() => this.addLongOnActionEnd()), + ) + ) + }.width(this.notTakeVideoExtCanvasWidth).height('100%').padding({ left: 58, right: 58 }) + } else { + Canvas(this.foldCanvasCtx) + .width(this.foldCanvasWidth) + .height(this.canvasHeight) + .onReady(() => { + this.foldCanvasCtx.clearRect(0, 0, this.foldCanvasWidth, this.canvasHeight) + this.foldOffCanvasCtx.clearRect(0, 0, this.foldCanvasWidth, this.canvasHeight) + this.foldOffCanvasCtx.strokeStyle = '#ffffff' + this.foldOffCanvasCtx.fillStyle = '#ffffff' + this.foldOffCanvasCtx.lineWidth = 1.5 + this.foldOffCanvasCtx.beginPath() + this.foldOffCanvasCtx.arc(this.foldCanvasWidth / 2, this.canvasHeight / 2, this.getZoomBtnRadius(), 0, 6.28) + this.foldOffCanvasCtx.stroke() + this.foldOffCanvasCtx.font = `bold ${vp2px(10)}px` + this.foldOffCanvasCtx.textAlign = 'center' + this.foldOffCanvasCtx.fillText(this.getZoomText(), this.foldCanvasWidth / 2, this.canvasHeight / 2 + 3) + + let fullWidth = this.foldCanvasWidth / 2 - this.mainDotRadius + let spotCount = + (fullWidth - this.mainDotRadius * 2 - this.dotSpacing) / (this.dotSpacing + this.secDotRadius * 2) + 2 + let spotOffset = this.state.zoomRatio === this.state.maxZoomRatio ? this.foldCanvasWidth / 2 - fullWidth + : this.foldCanvasWidth / 2 + for (let i = 0; i < spotCount; i++) { + let spotCenter = 0 + let spotRadius = 0 + if (i === 0) { + spotRadius = this.mainDotRadius + spotCenter = spotOffset + spotRadius + } else if (i === spotCount - 1) { + spotRadius = this.mainDotRadius + spotCenter = + spotOffset + this.mainDotRadius * 2 + (i - 1) * this.dotSpacing + (2 * i - 1) * this.secDotRadius - + this.secDotRadius + spotRadius + } else { + spotRadius = this.secDotRadius + spotCenter = + spotOffset + this.mainDotRadius * 2 + (i - 1) * this.dotSpacing + (2 * i - 1) * this.secDotRadius + + spotRadius + this.foldOffCanvasCtx.globalAlpha = 0.2 + } + if (spotCenter < this.foldCanvasWidth / 2 - this.getZoomBtnRadius() || + spotCenter > this.foldCanvasWidth / 2 + this.getZoomBtnRadius()) { + this.foldOffCanvasCtx.beginPath() + this.foldOffCanvasCtx.arc(spotCenter, this.canvasHeight / 2, spotRadius, 0, 6.28) + this.foldOffCanvasCtx.fill() + } + this.foldOffCanvasCtx.globalAlpha = 1.0 + } + + this.foldCanvasCtx.transferFromImageBitmap(this.foldOffCanvasCtx.transferToImageBitmap()) + }) + .gesture( + GestureGroup( + GestureMode.Parallel, + LongPressGesture({ repeat: true }) + .onAction(() => this.lpgOnAction()) + .onActionEnd(() => this.lpgOnActionEnd()), + PanGesture({ fingers: 1, distance: 1, direction: PanDirection.Horizontal }) + .onActionStart(() => this.pgOnActionStart()) + .onActionUpdate((event?: GestureEvent) => this.pgOnActionUpdate(event)) + .onActionEnd(() => this.pgOnActionEnd()) + ) + ) + } + }.width('100%').height(this.canvasHeight).margin({ bottom: !this.state.showZoomLabelValue ? 58 : 0 }) + } + private getCurrentCanvasType(): number { if (this.state.isShowZoomText && (this.state.videoState === 'beforeTakeVideo' - && (this.state.mode === 'PHOTO' || this.state.mode === 'VIDEO'))) { + && (this.state.mode === 'PHOTO' || this.state.mode === 'VIDEO'))) { return SHOW_NOT_TAKE_VIDEO_CANVAS } else if (this.state.mode === 'VIDEO' - && (this.state.isShowZoomText || this.state.videoState !== 'beforeTakeVideo')) { + && (this.state.isShowZoomText || this.state.videoState !== 'beforeTakeVideo')) { return SHOW_TAKING_VIDEO_CANVAS } else { return SHOW_FOLD_CANVAS @@ -409,7 +641,8 @@ export struct ZoomView { private updateZoomRatio(): void { let padding = this.getPadding() let fullWidth = this.notTakeVideoExtCanvasWidth - padding * 2 - this.mainDotRadius * 2 - let curZoomRatio = (this.offsetX / fullWidth) * (this.state.maxZoomRatio - this.state.minZoomRatio) + this.state.minZoomRatio + let curZoomRatio = + (this.offsetX / fullWidth) * (this.state.maxZoomRatio - this.state.minZoomRatio) + this.state.minZoomRatio if (curZoomRatio > this.state.maxZoomRatio) { curZoomRatio = this.state.maxZoomRatio } @@ -440,218 +673,4 @@ export struct ZoomView { return 15.25 } } - - build() { - Stack({ alignContent: Alignment.Top }) { - Stack({ alignContent: Alignment.Top }) - .width(this.offsetX + this.touchedOffsetX + this.state.zoomRatio) - .height(this.triggerRebuildNum) - .visibility(Visibility.None) - if (this.getCurrentCanvasType() === SHOW_NOT_TAKE_VIDEO_CANVAS) { - Canvas(this.notTakeVideoExtCanvasCtx) - .width(this.notTakeVideoExtCanvasWidth) - .height(this.canvasHeight) - .onReady(() => { - this.notTakeVideoExtCanvasCtx.clearRect(0, 0, this.notTakeVideoExtCanvasWidth, this.canvasHeight) - this.notTakeVideoExtOffCanvasCtx.clearRect(0, 0, this.notTakeVideoExtCanvasWidth, this.canvasHeight) - this.notTakeVideoExtOffCanvasCtx.strokeStyle = '#ffffff' - this.notTakeVideoExtOffCanvasCtx.fillStyle = '#ffffff' - this.notTakeVideoExtOffCanvasCtx.lineWidth = 1.5 - this.notTakeVideoExtOffCanvasCtx.beginPath() - this.notTakeVideoExtOffCanvasCtx.arc(this.getZoomBtnCenterX(), this.canvasHeight / 2, this.getZoomBtnRadius(), 0, 6.28) - this.notTakeVideoExtOffCanvasCtx.stroke() - if (this.state.showZoomLabelValue) { - this.notTakeVideoExtOffCanvasCtx.font = `bold ${vp2px(11)}px` - this.notTakeVideoExtOffCanvasCtx.textAlign = 'center' - this.notTakeVideoExtOffCanvasCtx.fillText(this.getZoomText(), this.getZoomBtnCenterX(), this.canvasHeight / 2 + 5) - } else { - this.notTakeVideoExtOffCanvasCtx.beginPath() - this.notTakeVideoExtOffCanvasCtx.arc(this.getZoomBtnCenterX(), this.canvasHeight / 2, this.centerDotRadius, 0, 6.28) - this.notTakeVideoExtOffCanvasCtx.fill() - } - - let spotCount = (this.notTakeVideoExtCanvasWidth - this.getPadding() * 2 - this.mainDotRadius * 4 - this.dotSpacing) / (this.dotSpacing + this.secDotRadius * 2) + 2 - for (let i = 0; i < spotCount; i++) { - let spotCenter = 0 - let spotRadius = 0 - if (i === 0) { - spotRadius = this.mainDotRadius - spotCenter = this.getPadding() + spotRadius - this.notTakeVideoExtOffCanvasCtx.font = `bold ${vp2px(11)}px` - this.notTakeVideoExtOffCanvasCtx.textAlign = 'center' - this.notTakeVideoExtOffCanvasCtx.fillText(`${this.state.minZoomRatio}x`, spotCenter, this.canvasHeight / 2 - (!this.state.showZoomLabelValue ? 26 : 24)) - } else if (i === spotCount - 1) { - spotRadius = this.mainDotRadius - spotCenter = this.notTakeVideoExtCanvasWidth - this.getPadding() - spotRadius - this.notTakeVideoExtOffCanvasCtx.font = `bold ${vp2px(11)}px` - this.notTakeVideoExtOffCanvasCtx.textAlign = 'center' - this.notTakeVideoExtOffCanvasCtx.fillText(`${this.state.maxZoomRatio}x`, spotCenter, this.canvasHeight / 2 - (!this.state.showZoomLabelValue ? 26 : 24)) - } else { - spotRadius = this.secDotRadius - spotCenter = this.getPadding() + this.mainDotRadius + (2 * i - 1) * this.secDotRadius + i * this.dotSpacing - this.notTakeVideoExtOffCanvasCtx.globalAlpha = 0.2 - } - if (spotCenter < this.getZoomBtnCenterX() - this.getZoomBtnRadius() || spotCenter > this.getZoomBtnCenterX() + this.getZoomBtnRadius()) { - this.notTakeVideoExtOffCanvasCtx.beginPath() - this.notTakeVideoExtOffCanvasCtx.arc(spotCenter, this.canvasHeight / 2, spotRadius, 0, 6.28) - this.notTakeVideoExtOffCanvasCtx.fill() - } - this.notTakeVideoExtOffCanvasCtx.globalAlpha = 1 - } - this.notTakeVideoExtCanvasCtx.transferFromImageBitmap(this.notTakeVideoExtOffCanvasCtx.transferToImageBitmap()) - }) - .gesture(GestureGroup(GestureMode.Parallel, - PanGesture({ fingers: 1, distance: 1, direction: PanDirection.Horizontal }) - .onActionStart(() => this.pgOnActionStart()) - .onActionUpdate((event?: GestureEvent) => { - if (event) { - return this.pgOnActionUpdate(event); - } - }) - .onActionEnd(() => this.pgOnActionEnd()))) - .onTouch((event?: TouchEvent) => { - if (event) { - return this.mOnTouch(event); - } - }) - } else if (this.getCurrentCanvasType() === SHOW_TAKING_VIDEO_CANVAS) { - Row() { - Image($r('app.media.ic_camera_public_focus_ev_bright_subtract')) - .width(24) - .height(24) - .fillColor(Color.White) - .onTouch((event?: TouchEvent) => this.subtractTouched(event)) - .gesture( - GestureGroup( - GestureMode.Parallel, - LongPressGesture({ repeat: true }) - .onAction((event?: GestureEvent) => this.subtractLongOnAction(event)) - .onActionEnd(() => this.subtractLongOnActionEnd()), - ) - ) - Canvas(this.takingVideoExtCanvasCtx) - .width(this.takingVideoExtCanvasWidth) - .height(this.canvasHeight) - .onReady(() => { - this.takingVideoExtCanvasCtx.clearRect(0, 0, this.takingVideoExtCanvasWidth, this.canvasHeight) - this.takingVideoExtOffCanvasCxt.clearRect(0, 0, this.takingVideoExtCanvasWidth, this.canvasHeight) - this.takingVideoExtOffCanvasCxt.strokeStyle = '#ffffff' - this.takingVideoExtOffCanvasCxt.fillStyle = '#ffffff' - this.takingVideoExtOffCanvasCxt.lineWidth = 1.5 - this.takingVideoExtOffCanvasCxt.beginPath() - this.takingVideoExtOffCanvasCxt.arc(this.getZoomBtnCenterX(), this.canvasHeight / 2, this.getZoomBtnRadius(), 0, 6.28) - this.takingVideoExtOffCanvasCxt.stroke() - if (this.state.isShowZoomText) { - this.takingVideoExtOffCanvasCxt.beginPath() - this.takingVideoExtOffCanvasCxt.arc(this.getZoomBtnCenterX(), this.canvasHeight / 2, this.centerDotRadius, 0, 6.28) - this.takingVideoExtOffCanvasCxt.fill() - } else { - this.takingVideoExtOffCanvasCxt.font = `bold ${vp2px(11)}px` - this.takingVideoExtOffCanvasCxt.textAlign = 'center' - this.takingVideoExtOffCanvasCxt.fillText(this.getZoomText(), this.getZoomBtnCenterX(), this.canvasHeight / 2 + 5) - } - - let spotCount = 30 - for (let i = 0; i < spotCount; i++) { - let spotCenter = 0 - let spotRadius = 0 - spotRadius = this.secDotRadius - spotCenter = this.getPadding() + (2 * i + 1) * this.secDotRadius + i * this.dotSpacing - this.takingVideoExtOffCanvasCxt.globalAlpha = 0.2 - if (spotCenter < this.getZoomBtnCenterX() - this.getZoomBtnRadius() || spotCenter > this.getZoomBtnCenterX() + this.getZoomBtnRadius()) { - this.takingVideoExtOffCanvasCxt.beginPath() - this.takingVideoExtOffCanvasCxt.arc(spotCenter, this.canvasHeight / 2, spotRadius, 0, 6.28) - this.takingVideoExtOffCanvasCxt.fill() - } - this.takingVideoExtOffCanvasCxt.globalAlpha = 1 - } - - this.takingVideoExtCanvasCtx.transferFromImageBitmap(this.takingVideoExtOffCanvasCxt.transferToImageBitmap()) - }) - .gesture( - GestureGroup( - GestureMode.Parallel, - LongPressGesture({ repeat: true }) - .onAction((event?: GestureEvent) => this.takingVideoExtLongPgAction(event)) - .onActionEnd(() => this.takingVideoExtLongPgActionEnd()), - PanGesture({ fingers: 1, distance: 1, direction: PanDirection.Horizontal }) - .onActionStart((event?: GestureEvent) => this.takingVideoExtPgActionStart(event)) - .onActionUpdate((event?: GestureEvent) => this.takingVideoExtPgActionUpdate(event)) - .onActionEnd((event?: GestureEvent) => this.takingVideoExtPgActionEnd(event)) - )) - .onTouch((event?: TouchEvent) => this.takingVideoExtTouched(event)) - Image($r('app.media.ic_camera_public_focus_ev_bright_add')) - .width(24) - .height(24) - .fillColor(Color.White) - .onTouch((event?: TouchEvent) => this.addTouched(event)) - .gesture( - GestureGroup( - GestureMode.Parallel, - LongPressGesture({ repeat: true }) - .onAction(() => this.addLongOnAction()) - .onActionEnd(() => this.addLongOnActionEnd()), - ) - ) - }.width(this.notTakeVideoExtCanvasWidth).height('100%').padding({ left: 58, right: 58 }) - } else { - Canvas(this.foldCanvasCtx) - .width(this.foldCanvasWidth) - .height(this.canvasHeight) - .onReady(() => { - this.foldCanvasCtx.clearRect(0, 0, this.foldCanvasWidth, this.canvasHeight) - this.foldOffCanvasCtx.clearRect(0, 0, this.foldCanvasWidth, this.canvasHeight) - this.foldOffCanvasCtx.strokeStyle = '#ffffff' - this.foldOffCanvasCtx.fillStyle = '#ffffff' - this.foldOffCanvasCtx.lineWidth = 1.5 - this.foldOffCanvasCtx.beginPath() - this.foldOffCanvasCtx.arc(this.foldCanvasWidth / 2, this.canvasHeight / 2, this.getZoomBtnRadius(), 0, 6.28) - this.foldOffCanvasCtx.stroke() - this.foldOffCanvasCtx.font = `bold ${vp2px(10)}px` - this.foldOffCanvasCtx.textAlign = 'center' - this.foldOffCanvasCtx.fillText(this.getZoomText(), this.foldCanvasWidth / 2, this.canvasHeight / 2 + 3) - - let fullWidth = this.foldCanvasWidth / 2 - this.mainDotRadius - let spotCount = (fullWidth - this.mainDotRadius * 2 - this.dotSpacing) / (this.dotSpacing + this.secDotRadius * 2) + 2 - let spotOffset = this.state.zoomRatio === this.state.maxZoomRatio ? this.foldCanvasWidth / 2 - fullWidth - : this.foldCanvasWidth / 2 - for (let i = 0; i < spotCount; i++) { - let spotCenter = 0 - let spotRadius = 0 - if (i === 0) { - spotRadius = this.mainDotRadius - spotCenter = spotOffset + spotRadius - } else if (i === spotCount - 1) { - spotRadius = this.mainDotRadius - spotCenter = spotOffset + this.mainDotRadius * 2 + (i - 1) * this.dotSpacing + (2 * i - 1) * this.secDotRadius - this.secDotRadius + spotRadius - } else { - spotRadius = this.secDotRadius - spotCenter = spotOffset + this.mainDotRadius * 2 + (i - 1) * this.dotSpacing + (2 * i - 1) * this.secDotRadius + spotRadius - this.foldOffCanvasCtx.globalAlpha = 0.2 - } - if (spotCenter < this.foldCanvasWidth / 2 - this.getZoomBtnRadius() || spotCenter > this.foldCanvasWidth / 2 + this.getZoomBtnRadius()) { - this.foldOffCanvasCtx.beginPath() - this.foldOffCanvasCtx.arc(spotCenter, this.canvasHeight / 2, spotRadius, 0, 6.28) - this.foldOffCanvasCtx.fill() - } - this.foldOffCanvasCtx.globalAlpha = 1.0 - } - - this.foldCanvasCtx.transferFromImageBitmap(this.foldOffCanvasCtx.transferToImageBitmap()) - }) - .gesture( - GestureGroup( - GestureMode.Parallel, - LongPressGesture({ repeat: true }) - .onAction(() => this.lpgOnAction()) - .onActionEnd(() => this.lpgOnActionEnd()), - PanGesture({ fingers: 1, distance: 1, direction: PanDirection.Horizontal }) - .onActionStart(() => this.pgOnActionStart()) - .onActionUpdate((event?: GestureEvent) => this.pgOnActionUpdate(event)) - .onActionEnd(() => this.pgOnActionEnd()) - ) - ) - } - }.width('100%').height(this.canvasHeight).margin({ bottom: !this.state.showZoomLabelValue ? 58 : 0 }) - } } \ No newline at end of file diff --git a/common/src/main/ets/default/featurecommon/zoomview/ZoomViewLand.ets b/common/src/main/ets/default/featurecommon/zoomview/ZoomViewLand.ets index faf7f452aeea87440ac75cae3e0208d6e2e4be58..6d44f665a772f617f2a89086b5f53398e4ce6dbf 100644 --- a/common/src/main/ets/default/featurecommon/zoomview/ZoomViewLand.ets +++ b/common/src/main/ets/default/featurecommon/zoomview/ZoomViewLand.ets @@ -13,8 +13,7 @@ * limitations under the License. */ -import { Dispatch, OhCombinedState } from '../../redux/store'; -import { getStore } from '../../redux/store'; +import { Dispatch, getStore, OhCombinedState } from '../../redux/store'; import { Action } from '../../redux/actions/Action'; import { EventBus } from '../../worker/eventbus/EventBus'; import { EventBusManager } from '../../worker/eventbus/EventBusManager'; @@ -37,8 +36,6 @@ class StateStruct { class ZoomViewDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -54,6 +51,8 @@ class ZoomViewDispatcher { public updateShowZoomLabelValue(flag: boolean): void { this.mDispatch(Action.updateShowZoomLabelValue(flag)); } + + private mDispatch: Dispatch = (data) => data; } class ZoomRatioStruct { @@ -66,9 +65,6 @@ class VideoStateStruct { @Component export struct ZoomViewLand { - private appEventBus: EventBus = EventBusManager.getInstance().getEventBus() - private mAction: ZoomViewDispatcher = new ZoomViewDispatcher(); - @State state: StateStruct = new StateStruct() @State @Watch('onZoomRatioRefresh') zoomRatio: number = 0 @State @Watch('onZoomRatioRefresh') showZoomLabelValue: boolean = true @@ -76,33 +72,30 @@ export struct ZoomViewLand { @State @Watch('onZoomRatioRefresh') curZoomRatio: number = 0 @State offsetY: number = 0 @State triggerRebuildNum: number = 0 - + private appEventBus: EventBus = EventBusManager.getInstance().getEventBus() + private mAction: ZoomViewDispatcher = new ZoomViewDispatcher(); private canvasWidth: number = 82 private notTakeVideoExtCanvasHeight: number = 360 private takingVideoExtCanvasHeight: number = 196 private foldCanvasHeight: number = 94 - private touchedOffsetY: number = this.takingVideoExtCanvasHeight / 2 private startOffsetY: number = 0 - private canvasSettings: RenderingContextSettings = new RenderingContextSettings(true) private notTakeVideoExtCanvasCxt: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.canvasSettings) private takingVideoExtCanvasCxt: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.canvasSettings) private foldCanvasCxt: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.canvasSettings) private notTakeVideoExtOffCanvasCxt: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D( - this.canvasWidth, this.notTakeVideoExtCanvasHeight, this.canvasSettings) + this.canvasWidth, this.notTakeVideoExtCanvasHeight, this.canvasSettings) private takingVideoExtOffCanvasCxt: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D( - this.canvasWidth, this.notTakeVideoExtCanvasHeight, this.canvasSettings) + this.canvasWidth, this.notTakeVideoExtCanvasHeight, this.canvasSettings) private foldOffCanvasCxt: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D( - this.canvasWidth, this.foldCanvasHeight, this.canvasSettings) - + this.canvasWidth, this.foldCanvasHeight, this.canvasSettings) private lpgTimer: number = 0 private pgTimer: number = 0 private lpgExp: boolean = false private pgExp: boolean = false private zoomTimer: number = 0 private baseZoomRatio: number = 1 - private mainDotRadius: number = 1.5 private secDotRadius: number = 0.75 private centerDotRadius: number = 2.5 @@ -134,12 +127,105 @@ export struct ZoomViewLand { this.appEventBus.off(Action.ACTION_UPDATE_VIDEO_STATE, (data: VideoStateStruct) => this.updateZoomState(data)) } + build() { + Stack({ alignContent: Alignment.Start }) { + Stack({ alignContent: Alignment.Top }) + .width(this.triggerRebuildNum) + .height(this.offsetY + this.touchedOffsetY + this.zoomRatio) + .visibility(Visibility.None) + if (this.getCurrentCanvasType() === SHOW_NOT_TAKE_VIDEO_CANVAS) { + Canvas(this.notTakeVideoExtCanvasCxt) + .width(this.canvasWidth) + .height(this.notTakeVideoExtCanvasHeight) + .onReady(() => this.canvasInit(SHOW_NOT_TAKE_VIDEO_CANVAS)) + .gesture( + GestureGroup( + GestureMode.Parallel, + PanGesture({ fingers: 1, distance: 1, direction: PanDirection.Vertical }) + .onActionStart(() => this.pgOnActionStart()) + .onActionUpdate((event?: GestureEvent) => { + if (event) { + return this.pgOnActionUpdate(event); + } + }) + .onActionEnd(() => this.pgOnActionEnd()))) + .onTouch((event?: TouchEvent) => { + if (event) { + return this.mOnTouch(event); + } + }) + } else if (this.getCurrentCanvasType() === SHOW_TAKING_VIDEO_CANVAS) { + Column() { + Image($r('app.media.ic_camera_public_focus_ev_bright_add')) + .width(24) + .height(24) + .fillColor(Color.White) + .onTouch((event?: TouchEvent) => this.addTouched(event)) + .gesture( + GestureGroup( + GestureMode.Parallel, + LongPressGesture({ repeat: true }) + .onAction(() => this.addLongOnAction()) + .onActionEnd(() => this.addLongOnActionEnd()), + ) + ) + Canvas(this.takingVideoExtCanvasCxt) + .width(this.canvasWidth) + .height(this.takingVideoExtCanvasHeight) + .onReady(() => this.canvasInit(SHOW_TAKING_VIDEO_CANVAS)) + .gesture( + GestureGroup( + GestureMode.Parallel, + LongPressGesture({ repeat: true }) + .onAction((event?: GestureEvent) => this.takingVideoExtLongPgAction(event)) + .onActionEnd(() => this.takingVideoExtLongPgActionEnd()), + PanGesture({ fingers: 1, distance: 1, direction: PanDirection.Horizontal }) + .onActionStart((event?: GestureEvent) => this.takingVideoExtPgActionStart(event)) + .onActionUpdate((event?: GestureEvent) => this.takingVideoExtPgActionUpdate(event)) + .onActionEnd((event?: GestureEvent) => this.takingVideoExtPgActionEnd(event)) + )) + .onTouch((event?: TouchEvent) => this.takingVideoExtTouched(event)) + Image($r('app.media.ic_camera_public_focus_ev_bright_subtract')) + .width(24) + .height(24) + .fillColor(Color.White) + .onTouch((event?: TouchEvent) => this.subtractTouched(event)) + .gesture( + GestureGroup( + GestureMode.Parallel, + LongPressGesture({ repeat: true }) + .onAction((event?: GestureEvent) => this.subtractLongOnAction(event)) + .onActionEnd(() => this.subtractLongOnActionEnd()), + ) + ) + }.width('100%').height(this.notTakeVideoExtCanvasHeight).padding({ top: 58, bottom: 58 }) + } else { + Canvas(this.foldCanvasCxt) + .width(this.canvasWidth) + .height(this.foldCanvasHeight) + .onReady(() => this.canvasInit(SHOW_FOLD_CANVAS)) + .gesture( + GestureGroup( + GestureMode.Parallel, + LongPressGesture({ repeat: true }) + .onAction(() => this.lpgOnAction()) + .onActionEnd(() => this.lpgOnActionEnd()), + PanGesture({ fingers: 1, distance: 1, direction: PanDirection.Horizontal }) + .onActionStart(() => this.pgOnActionStart()) + .onActionUpdate((event?: GestureEvent) => this.pgOnActionUpdate(event)) + .onActionEnd(() => this.pgOnActionEnd()) + ) + ) + } + }.width(82).height('100%') + } + private getCurrentCanvasType(): number { if (this.isShowZoomText && (this.state.videoState === 'beforeTakeVideo' - && (this.state.mode === 'PHOTO' || this.state.mode === 'VIDEO'))) { + && (this.state.mode === 'PHOTO' || this.state.mode === 'VIDEO'))) { return SHOW_NOT_TAKE_VIDEO_CANVAS } else if (this.state.mode === 'VIDEO' - && (this.isShowZoomText || this.state.videoState !== 'beforeTakeVideo')) { + && (this.isShowZoomText || this.state.videoState !== 'beforeTakeVideo')) { return SHOW_TAKING_VIDEO_CANVAS } else { return SHOW_FOLD_CANVAS @@ -200,7 +286,6 @@ export struct ZoomViewLand { this.changeZoomRatioOnTakingVideoExt() } - private takingVideoExtLongPgActionEnd(): void { this.touchedOffsetY = this.takingVideoExtCanvasHeight / 2 this.changeZoomRatioOnTakingVideoExt() @@ -392,7 +477,6 @@ export struct ZoomViewLand { return fullHeight / (this.state.maxZoomRatio - this.state.minZoomRatio) } - private updateZoomOffset(data: ZoomRatioStruct): void { let offset = (data.zoomRatio - this.state.minZoomRatio) * this.getZoomOffsetUnit(); this.offsetY = offset; @@ -418,7 +502,8 @@ export struct ZoomViewLand { private updateZoomRatio(): void { let padding = this.getPadding() let fullHeight = this.notTakeVideoExtCanvasHeight - padding * 2 - this.mainDotRadius * 2 - this.curZoomRatio = (this.offsetY / fullHeight) * (this.state.maxZoomRatio - this.state.minZoomRatio) + this.state.minZoomRatio + this.curZoomRatio = + (this.offsetY / fullHeight) * (this.state.maxZoomRatio - this.state.minZoomRatio) + this.state.minZoomRatio if (this.curZoomRatio > this.state.maxZoomRatio) { this.curZoomRatio = this.state.maxZoomRatio } @@ -481,7 +566,8 @@ export struct ZoomViewLand { this.notTakeVideoExtOffCanvasCxt.fillStyle = '#ffffff' this.notTakeVideoExtOffCanvasCxt.lineWidth = 1.5 this.notTakeVideoExtOffCanvasCxt.beginPath() - this.notTakeVideoExtOffCanvasCxt.arc(this.canvasWidth / 2, this.getZoomBtnCenterY(), this.getZoomBtnRadius(), 0, 6.28) + this.notTakeVideoExtOffCanvasCxt.arc(this.canvasWidth / 2, this.getZoomBtnCenterY(), this.getZoomBtnRadius(), 0, + 6.28) this.notTakeVideoExtOffCanvasCxt.stroke() if (this.showZoomLabelValue) { this.notTakeVideoExtOffCanvasCxt.font = `bold ${vp2px(11)}px` @@ -489,11 +575,14 @@ export struct ZoomViewLand { this.notTakeVideoExtOffCanvasCxt.fillText(this.getZoomText(), this.canvasWidth / 2, this.getZoomBtnCenterY() + 5) } else { this.notTakeVideoExtOffCanvasCxt.beginPath() - this.notTakeVideoExtOffCanvasCxt.arc(this.canvasWidth / 2, this.getZoomBtnCenterY(), this.centerDotRadius, 0, 6.28) + this.notTakeVideoExtOffCanvasCxt.arc(this.canvasWidth / 2, this.getZoomBtnCenterY(), this.centerDotRadius, 0, + 6.28) this.notTakeVideoExtOffCanvasCxt.fill() } - let spotCount = (this.notTakeVideoExtCanvasHeight - this.getPadding() * 2 - this.mainDotRadius * 4 - this.dotSpacing) / (this.dotSpacing + this.secDotRadius * 2) + 2 + let spotCount = + (this.notTakeVideoExtCanvasHeight - this.getPadding() * 2 - this.mainDotRadius * 4 - this.dotSpacing) / + (this.dotSpacing + this.secDotRadius * 2) + 2 for (let i = 0; i < spotCount; i++) { let spotCenter = 0 let spotRadius = 0 @@ -502,19 +591,23 @@ export struct ZoomViewLand { spotCenter = this.notTakeVideoExtCanvasHeight - this.getPadding() - spotRadius this.notTakeVideoExtOffCanvasCxt.font = `bold ${vp2px(11)}px` this.notTakeVideoExtOffCanvasCxt.textAlign = 'right' - this.notTakeVideoExtOffCanvasCxt.fillText(`${this.state.minZoomRatio}x`,this.canvasWidth / 2 - (!this.showZoomLabelValue ? 26: 24), spotCenter) + this.notTakeVideoExtOffCanvasCxt.fillText(`${this.state.minZoomRatio}x`, + this.canvasWidth / 2 - (!this.showZoomLabelValue ? 26 : 24), spotCenter) } else if (i === spotCount - 1) { spotRadius = this.mainDotRadius spotCenter = this.getPadding() + spotRadius this.notTakeVideoExtOffCanvasCxt.font = `bold ${vp2px(11)}px` this.notTakeVideoExtOffCanvasCxt.textAlign = 'right' - this.notTakeVideoExtOffCanvasCxt.fillText(`${this.state.maxZoomRatio}x`,this.canvasWidth / 2 - (!this.showZoomLabelValue ? 26: 24), spotCenter) + this.notTakeVideoExtOffCanvasCxt.fillText(`${this.state.maxZoomRatio}x`, + this.canvasWidth / 2 - (!this.showZoomLabelValue ? 26 : 24), spotCenter) } else { spotRadius = this.secDotRadius - spotCenter = this.notTakeVideoExtCanvasHeight - this.getPadding() - this.mainDotRadius * 2 - (2 * i - 1) * this.secDotRadius - i * this.dotSpacing + spotCenter = this.notTakeVideoExtCanvasHeight - this.getPadding() - this.mainDotRadius * 2 - + (2 * i - 1) * this.secDotRadius - i * this.dotSpacing this.notTakeVideoExtOffCanvasCxt.globalAlpha = 0.2 } - if (spotCenter < this.getZoomBtnCenterY() - this.getZoomBtnRadius() || spotCenter > this.getZoomBtnCenterY() + this.getZoomBtnRadius()) { + if (spotCenter < this.getZoomBtnCenterY() - this.getZoomBtnRadius() || + spotCenter > this.getZoomBtnCenterY() + this.getZoomBtnRadius()) { this.notTakeVideoExtOffCanvasCxt.beginPath() this.notTakeVideoExtOffCanvasCxt.arc(this.canvasWidth / 2, spotCenter, spotRadius, 0, 6.28) this.notTakeVideoExtOffCanvasCxt.fill() @@ -531,7 +624,8 @@ export struct ZoomViewLand { this.takingVideoExtOffCanvasCxt.fillStyle = '#ffffff' this.takingVideoExtOffCanvasCxt.lineWidth = 1.5 this.takingVideoExtOffCanvasCxt.beginPath() - this.takingVideoExtOffCanvasCxt.arc(this.canvasWidth / 2, this.getZoomBtnCenterY(), this.getZoomBtnRadius(), 0, 6.28) + this.takingVideoExtOffCanvasCxt.arc(this.canvasWidth / 2, this.getZoomBtnCenterY(), this.getZoomBtnRadius(), 0, + 6.28) this.takingVideoExtOffCanvasCxt.stroke() if (this.isShowZoomText) { this.takingVideoExtOffCanvasCxt.beginPath() @@ -550,7 +644,8 @@ export struct ZoomViewLand { spotRadius = this.secDotRadius spotCenter = this.getPadding() + (2 * i + 1) * this.secDotRadius + i * this.dotSpacing this.takingVideoExtOffCanvasCxt.globalAlpha = 0.2 - if (spotCenter < this.getZoomBtnCenterY() - this.getZoomBtnRadius() || spotCenter > this.getZoomBtnCenterY() + this.getZoomBtnRadius()) { + if (spotCenter < this.getZoomBtnCenterY() - this.getZoomBtnRadius() || + spotCenter > this.getZoomBtnCenterY() + this.getZoomBtnRadius()) { this.takingVideoExtOffCanvasCxt.beginPath() this.takingVideoExtOffCanvasCxt.arc(this.canvasWidth / 2, spotCenter, spotRadius, 0, 6.28) this.takingVideoExtOffCanvasCxt.fill() @@ -576,9 +671,10 @@ export struct ZoomViewLand { this.foldOffCanvasCxt.fillText(this.getZoomText(), this.canvasWidth / 2, this.foldCanvasHeight / 2 + 3) let fullHeight = this.foldCanvasHeight / 2 - this.mainDotRadius - let spotCount = (fullHeight - this.mainDotRadius * 2 - this.dotSpacing) / (this.dotSpacing + this.secDotRadius * 2) + 2 + let spotCount = + (fullHeight - this.mainDotRadius * 2 - this.dotSpacing) / (this.dotSpacing + this.secDotRadius * 2) + 2 let spotOffset = (this.zoomRatio === this.state.maxZoomRatio) ? this.foldCanvasHeight / 2 + fullHeight - : this.foldCanvasHeight / 2 + : this.foldCanvasHeight / 2 for (let i = 0; i < spotCount; i++) { let spotCenter = 0 let spotRadius = 0 @@ -587,13 +683,16 @@ export struct ZoomViewLand { spotCenter = spotOffset - spotRadius } else if (i === spotCount - 1) { spotRadius = this.mainDotRadius - spotCenter = spotOffset - this.mainDotRadius * 2 - (i - 1) * this.dotSpacing - (2 * i - 1) * this.secDotRadius + this.secDotRadius - spotRadius + spotCenter = spotOffset - this.mainDotRadius * 2 - (i - 1) * this.dotSpacing - (2 * i - 1) * this.secDotRadius + + this.secDotRadius - spotRadius } else { spotRadius = this.secDotRadius - spotCenter = spotOffset - this.mainDotRadius * 2 - (i - 1) * this.dotSpacing - (2 * i - 1) * this.secDotRadius - spotRadius + spotCenter = + spotOffset - this.mainDotRadius * 2 - (i - 1) * this.dotSpacing - (2 * i - 1) * this.secDotRadius - spotRadius this.foldOffCanvasCxt.globalAlpha = 0.2 } - if (spotCenter > this.foldCanvasHeight / 2 + this.getZoomBtnRadius() || spotCenter < this.foldCanvasHeight / 2 - this.getZoomBtnRadius()) { + if (spotCenter > this.foldCanvasHeight / 2 + this.getZoomBtnRadius() || + spotCenter < this.foldCanvasHeight / 2 - this.getZoomBtnRadius()) { this.foldOffCanvasCxt.beginPath() this.foldOffCanvasCxt.arc(this.canvasWidth / 2, spotCenter, spotRadius, 0, 6.28) this.foldOffCanvasCxt.fill() @@ -602,94 +701,4 @@ export struct ZoomViewLand { } this.foldCanvasCxt.transferFromImageBitmap(this.foldOffCanvasCxt.transferToImageBitmap()) } - - build() { - Stack({ alignContent: Alignment.Start}) { - Stack({ alignContent: Alignment.Top }).width(this.triggerRebuildNum).height(this.offsetY + this.touchedOffsetY + this.zoomRatio).visibility(Visibility.None) - if (this.getCurrentCanvasType() === SHOW_NOT_TAKE_VIDEO_CANVAS) { - Canvas(this.notTakeVideoExtCanvasCxt) - .width(this.canvasWidth) - .height(this.notTakeVideoExtCanvasHeight) - .onReady(() => this.canvasInit(SHOW_NOT_TAKE_VIDEO_CANVAS)) - .gesture( - GestureGroup( - GestureMode.Parallel, - PanGesture({ fingers: 1, distance: 1, direction: PanDirection.Vertical}) - .onActionStart(() => this.pgOnActionStart()) - .onActionUpdate((event?: GestureEvent) => { - if (event) { - return this.pgOnActionUpdate(event); - } - }) - .onActionEnd(() => this.pgOnActionEnd()))) - .onTouch((event?: TouchEvent) => { - if (event) { - return this.mOnTouch(event); - } - }) - } else if (this.getCurrentCanvasType() === SHOW_TAKING_VIDEO_CANVAS) { - Column() { - Image($r('app.media.ic_camera_public_focus_ev_bright_add')) - .width(24) - .height(24) - .fillColor(Color.White) - .onTouch((event?: TouchEvent) => this.addTouched(event)) - .gesture( - GestureGroup( - GestureMode.Parallel, - LongPressGesture({ repeat: true }) - .onAction(() => this.addLongOnAction()) - .onActionEnd(() => this.addLongOnActionEnd()), - ) - ) - Canvas(this.takingVideoExtCanvasCxt) - .width(this.canvasWidth) - .height(this.takingVideoExtCanvasHeight) - .onReady(() => this.canvasInit(SHOW_TAKING_VIDEO_CANVAS)) - .gesture( - GestureGroup( - GestureMode.Parallel, - LongPressGesture({ repeat: true }) - .onAction((event?: GestureEvent) => this.takingVideoExtLongPgAction(event)) - .onActionEnd(() => this.takingVideoExtLongPgActionEnd()), - PanGesture({ fingers: 1, distance: 1, direction: PanDirection.Horizontal }) - .onActionStart((event?: GestureEvent) => this.takingVideoExtPgActionStart(event)) - .onActionUpdate((event?: GestureEvent) => this.takingVideoExtPgActionUpdate(event)) - .onActionEnd((event?: GestureEvent) => this.takingVideoExtPgActionEnd(event)) - )) - .onTouch((event?: TouchEvent) => this.takingVideoExtTouched(event)) - Image($r('app.media.ic_camera_public_focus_ev_bright_subtract')) - .width(24) - .height(24) - .fillColor(Color.White) - .onTouch((event?: TouchEvent) => this.subtractTouched(event)) - .gesture( - GestureGroup( - GestureMode.Parallel, - LongPressGesture({ repeat: true }) - .onAction((event?: GestureEvent) => this.subtractLongOnAction(event)) - .onActionEnd(() => this.subtractLongOnActionEnd()), - ) - ) - }.width('100%').height(this.notTakeVideoExtCanvasHeight).padding({ top: 58, bottom: 58 }) - } else { - Canvas(this.foldCanvasCxt) - .width(this.canvasWidth) - .height(this.foldCanvasHeight) - .onReady(() => this.canvasInit(SHOW_FOLD_CANVAS)) - .gesture( - GestureGroup( - GestureMode.Parallel, - LongPressGesture({ repeat: true }) - .onAction(() => this.lpgOnAction()) - .onActionEnd(() => this.lpgOnActionEnd()), - PanGesture({ fingers: 1, distance: 1, direction: PanDirection.Horizontal }) - .onActionStart(() => this.pgOnActionStart()) - .onActionUpdate((event?: GestureEvent) => this.pgOnActionUpdate(event)) - .onActionEnd(() => this.pgOnActionEnd()) - ) - ) - } - }.width(82).height('100%') - } } \ No newline at end of file diff --git a/common/src/main/ets/default/featureservice/FeatureManager.ts b/common/src/main/ets/default/featureservice/FeatureManager.ts index 7cfee7df68042d3466779d9bbe7237c4f00d606d..2cca85cecf6467ad930dea084a38efb19f11af3e 100644 --- a/common/src/main/ets/default/featureservice/FeatureManager.ts +++ b/common/src/main/ets/default/featureservice/FeatureManager.ts @@ -22,7 +22,6 @@ import type { EventBus } from '../worker/eventbus/EventBus'; import { EventBusManager } from '../worker/eventbus/EventBusManager'; import { ModeAssembler } from './ModeAssembler'; import { RecordFunction } from '../function/RecordFunction'; -import { WorkerManager } from '../worker/WorkerManager'; import { ZoomFunction } from '../function/ZoomFunction'; import type { IModeMap } from './IModeMap'; diff --git a/common/src/main/ets/default/featureservice/FunctionId.ts b/common/src/main/ets/default/featureservice/FunctionId.ts index aea88defc43e0c1b724618263aad9e0b7516166c..709826a1b4db5debbd4a937c36b93b73a3e8d7e7 100644 --- a/common/src/main/ets/default/featureservice/FunctionId.ts +++ b/common/src/main/ets/default/featureservice/FunctionId.ts @@ -14,9 +14,9 @@ */ export enum FunctionId { - NONE, - CAMERA_BASIC_FUNCTION, - CAPTURE_FUNCTION, - RECORDING_FUNCTION, - ZOOM_FUNCTION + NONE, + CAMERA_BASIC_FUNCTION, + CAPTURE_FUNCTION, + RECORDING_FUNCTION, + ZOOM_FUNCTION } \ No newline at end of file diff --git a/common/src/main/ets/default/featureservice/ModeAssembler.ts b/common/src/main/ets/default/featureservice/ModeAssembler.ts index 405eb1442f7a007566c304d1959bcc270fa37c44..c80b9126b2a34cddf9c44e14d36a1e6150100b91 100644 --- a/common/src/main/ets/default/featureservice/ModeAssembler.ts +++ b/common/src/main/ets/default/featureservice/ModeAssembler.ts @@ -45,11 +45,11 @@ export class ModeAssembler { this.mNeedAdd = JSON.parse(JSON.stringify(currentModeFun)) for (let fun of preModeFun) { let index = currentModeFun.indexOf(fun) - if (index == -1) { - this.mNeedDelete.push(fun) - } else { - this.mNeedAdd.splice(index, 1) - } + if (index == -1) { + this.mNeedDelete.push(fun) + } else { + this.mNeedAdd.splice(index, 1) + } } } Log.info(`${this.TAG} assembler mNeedAdd = ${this.mNeedAdd} mNeedDelete = ${this.mNeedDelete}`) diff --git a/common/src/main/ets/default/function/BaseFunction.ts b/common/src/main/ets/default/function/BaseFunction.ts index 834c49b09220fa3d5e5dd3fb72dd70df2fb442d0..49fd7574a5f360247ea7cab7bccbf9648b5111b7 100644 --- a/common/src/main/ets/default/function/BaseFunction.ts +++ b/common/src/main/ets/default/function/BaseFunction.ts @@ -25,6 +25,10 @@ export abstract class BaseFunction { protected mWorkerManager: WorkerManager = new WorkerManager(); protected mEventBus: EventBus = EventBusManager.getInstance().getEventBus(); + abstract load(): void + + abstract unload(): void + protected enableUi(): void { this.mWorkerManager.postMessage(Action.uiState(true)); } @@ -40,8 +44,4 @@ export abstract class BaseFunction { protected disableUiWithMode(uiStateMode: UiStateMode): void { this.mWorkerManager.postMessage(Action.uiStateWithMode(false, uiStateMode)); } - - abstract load(): void - - abstract unload(): void } \ No newline at end of file diff --git a/common/src/main/ets/default/function/CameraBasicFunction.ts b/common/src/main/ets/default/function/CameraBasicFunction.ts index 994ab2073d2db2026eadf7195146459fc6fdc600..1ddbfa128c9d61f72649b3bc61c7df094318a027 100644 --- a/common/src/main/ets/default/function/CameraBasicFunction.ts +++ b/common/src/main/ets/default/function/CameraBasicFunction.ts @@ -24,6 +24,7 @@ import ReportUtil from '../utils/ReportUtil'; import { GlobalContext } from '../utils/GlobalContext'; export class CameraBasicFunction extends BaseFunction { + public startIdentification: boolean = false private TAG = '[CameraBasicFunction]:'; private mCameraId: string = CameraId.BACK; private mSurfaceId: string = ''; @@ -31,33 +32,12 @@ export class CameraBasicFunction extends BaseFunction { private mSessionList: string[] = []; private isSessionReleasing: boolean = false private initDataCache: any = null - public startIdentification: boolean = false - private functionBackImpl: FunctionCallBack = { - onCapturePhotoOutput: (): void => { - Log.info(`${this.TAG} functionBackImpl onCapturePhotoOutput`) - this.mWorkerManager.postMessage(Action.capturePhotoOutput()) - }, - onCaptureSuccess: (thumbnail: any, resourceUri: any): void => { - Log.info(`${this.TAG} functionBackImpl onCaptureSuccess ${thumbnail}`) - this.mWorkerManager.postMessage(Action.updateThumbnail(thumbnail, resourceUri)) - }, - onCaptureFailure: (): void => { - Log.info(`${this.TAG} functionBackImpl onCaptureFailure`) - this.mWorkerManager.postMessage(Action.captureError()) - }, - onRecordSuccess: (thumbnail: any): void => { - Log.info(`${this.TAG} functionBackImpl onRecordSuccess ${thumbnail}`) - this.mWorkerManager.postMessage(Action.recordDone(thumbnail)) - }, - onRecordFailure: (): void => { - Log.info(`${this.TAG} functionBackImpl onRecordFailure`) - this.mWorkerManager.postMessage(Action.recordError()) - }, - thumbnail: (thumbnail: any): void => { - Log.info(`${this.TAG} functionBackImpl thumbnail ${thumbnail}`) - this.mWorkerManager.postMessage(Action.loadThumbnail(thumbnail)) + static getInstance() { + if (!globalThis?.cameraBasicMethod) { + globalThis.cameraBasicMethod = new CameraBasicFunction() } + return globalThis.cameraBasicMethod } public async initCamera(data, callType?: string) { @@ -68,7 +48,9 @@ export class CameraBasicFunction extends BaseFunction { this.mWorkerManager.postMessage(Action.initCameraDone(platformCapability)); return; } - if (callType) this.startIdentification = true + if (callType) { + this.startIdentification = true + } Log.start(`${this.TAG} initCamera`) this.mSessionList.push('CREATE') let curStorageCameraId = AppStorage.Get('storageCameraId') @@ -93,6 +75,63 @@ export class CameraBasicFunction extends BaseFunction { Log.end(`${this.TAG} initCamera`) } + load(): void { + Log.info(`${this.TAG} load E`) + this.mEventBus.on(Action.ACTION_INIT, this.initCamera.bind(this)) + this.mEventBus.on(Action.ACTION_CHANGE_IMAGE_SIZE, this.imageSize.bind(this)) + this.mEventBus.on(Action.ACTION_CHANGE_VIDEO_SIZE, this.videoSize.bind(this)) + this.mEventBus.on(Action.ACTION_PREPARE_SURFACE, this.onSurfacePrepare.bind(this)) + this.mEventBus.on(Action.ACTION_START_PREVIEW, this.startPreview.bind(this)) + this.mEventBus.on(Action.ACTION_RESTART_PREVIEW, this.reStartPreview.bind(this)) + this.mEventBus.on(Action.ACTION_CHANGE_MODE, this.changeMode.bind(this)) + this.mEventBus.on(Action.ACTION_SWITCH_CAMERA, this.switchCamera.bind(this)) + this.mEventBus.on(Action.ACTION_CLOSE_CAMERA, this.close.bind(this)) + this.mEventBus.on(Action.ACTION_RELOAD_THUMBNAIL, this.reloadThumbnail.bind(this)) + Log.info(`${this.TAG} load X`) + } + + unload(): void { + Log.info(`${this.TAG} unload E`) + this.mEventBus.off(Action.ACTION_INIT, this.initCamera.bind(this)) + this.mEventBus.off(Action.ACTION_CHANGE_IMAGE_SIZE, this.imageSize.bind(this)) + this.mEventBus.off(Action.ACTION_CHANGE_VIDEO_SIZE, this.videoSize.bind(this)) + this.mEventBus.off(Action.ACTION_PREPARE_SURFACE, this.onSurfacePrepare.bind(this)) + this.mEventBus.off(Action.ACTION_START_PREVIEW, this.startPreview.bind(this)) + this.mEventBus.off(Action.ACTION_RESTART_PREVIEW, this.reStartPreview.bind(this)) + this.mEventBus.off(Action.ACTION_CHANGE_MODE, this.changeMode.bind(this)) + this.mEventBus.off(Action.ACTION_SWITCH_CAMERA, this.switchCamera.bind(this)) + this.mEventBus.off(Action.ACTION_CLOSE_CAMERA, this.close.bind(this)) + this.mEventBus.off(Action.ACTION_RELOAD_THUMBNAIL, this.reloadThumbnail.bind(this)) + Log.info(`${this.TAG} unload X`) + } + + private functionBackImpl: FunctionCallBack = { + onCapturePhotoOutput: (): void => { + Log.info(`${this.TAG} functionBackImpl onCapturePhotoOutput`) + this.mWorkerManager.postMessage(Action.capturePhotoOutput()) + }, + onCaptureSuccess: (thumbnail: any, resourceUri: any): void => { + Log.info(`${this.TAG} functionBackImpl onCaptureSuccess ${thumbnail}`) + this.mWorkerManager.postMessage(Action.updateThumbnail(thumbnail, resourceUri)) + }, + onCaptureFailure: (): void => { + Log.info(`${this.TAG} functionBackImpl onCaptureFailure`) + this.mWorkerManager.postMessage(Action.captureError()) + }, + onRecordSuccess: (thumbnail: any): void => { + Log.info(`${this.TAG} functionBackImpl onRecordSuccess ${thumbnail}`) + this.mWorkerManager.postMessage(Action.recordDone(thumbnail)) + }, + onRecordFailure: (): void => { + Log.info(`${this.TAG} functionBackImpl onRecordFailure`) + this.mWorkerManager.postMessage(Action.recordError()) + }, + thumbnail: (thumbnail: any): void => { + Log.info(`${this.TAG} functionBackImpl thumbnail ${thumbnail}`) + this.mWorkerManager.postMessage(Action.loadThumbnail(thumbnail)) + } + } + private async imageSize(data) { Log.info(`${this.TAG} imageSize ${JSON.stringify(data)} E`) this.mCameraService.mImageSize.imageWidth = data.imageSize.width @@ -255,41 +294,4 @@ export class CameraBasicFunction extends BaseFunction { this.mCameraService.getThumbnail(this.functionBackImpl) Log.info(`${this.TAG} loadThumbnail X`) } - - static getInstance() { - if (!globalThis?.cameraBasicMethod) { - globalThis.cameraBasicMethod = new CameraBasicFunction() - } - return globalThis.cameraBasicMethod - } - - load(): void { - Log.info(`${this.TAG} load E`) - this.mEventBus.on(Action.ACTION_INIT, this.initCamera.bind(this)) - this.mEventBus.on(Action.ACTION_CHANGE_IMAGE_SIZE, this.imageSize.bind(this)) - this.mEventBus.on(Action.ACTION_CHANGE_VIDEO_SIZE, this.videoSize.bind(this)) - this.mEventBus.on(Action.ACTION_PREPARE_SURFACE, this.onSurfacePrepare.bind(this)) - this.mEventBus.on(Action.ACTION_START_PREVIEW, this.startPreview.bind(this)) - this.mEventBus.on(Action.ACTION_RESTART_PREVIEW, this.reStartPreview.bind(this)) - this.mEventBus.on(Action.ACTION_CHANGE_MODE, this.changeMode.bind(this)) - this.mEventBus.on(Action.ACTION_SWITCH_CAMERA, this.switchCamera.bind(this)) - this.mEventBus.on(Action.ACTION_CLOSE_CAMERA, this.close.bind(this)) - this.mEventBus.on(Action.ACTION_RELOAD_THUMBNAIL, this.reloadThumbnail.bind(this)) - Log.info(`${this.TAG} load X`) - } - - unload(): void { - Log.info(`${this.TAG} unload E`) - this.mEventBus.off(Action.ACTION_INIT, this.initCamera.bind(this)) - this.mEventBus.off(Action.ACTION_CHANGE_IMAGE_SIZE, this.imageSize.bind(this)) - this.mEventBus.off(Action.ACTION_CHANGE_VIDEO_SIZE, this.videoSize.bind(this)) - this.mEventBus.off(Action.ACTION_PREPARE_SURFACE, this.onSurfacePrepare.bind(this)) - this.mEventBus.off(Action.ACTION_START_PREVIEW, this.startPreview.bind(this)) - this.mEventBus.off(Action.ACTION_RESTART_PREVIEW, this.reStartPreview.bind(this)) - this.mEventBus.off(Action.ACTION_CHANGE_MODE, this.changeMode.bind(this)) - this.mEventBus.off(Action.ACTION_SWITCH_CAMERA, this.switchCamera.bind(this)) - this.mEventBus.off(Action.ACTION_CLOSE_CAMERA, this.close.bind(this)) - this.mEventBus.off(Action.ACTION_RELOAD_THUMBNAIL, this.reloadThumbnail.bind(this)) - Log.info(`${this.TAG} unload X`) - } } \ No newline at end of file diff --git a/common/src/main/ets/default/function/RecordFunction.ts b/common/src/main/ets/default/function/RecordFunction.ts index 3167725d8f226e206c460d1ab618c07d8e5e6fe4..f84f963c1958164be78635860e939ae2249efef7 100644 --- a/common/src/main/ets/default/function/RecordFunction.ts +++ b/common/src/main/ets/default/function/RecordFunction.ts @@ -23,12 +23,26 @@ import { GlobalContext } from '../utils/GlobalContext'; const TAG = '[RecordFunction]:'; export class RecordFunction extends BaseFunction { + load(): void { + this.mEventBus.on(Action.ACTION_RECORD_START, this.startRecording.bind(this)); + this.mEventBus.on(Action.ACTION_RECORD_PAUSE, this.pauseRecording.bind(this)); + this.mEventBus.on(Action.ACTION_RECORD_RESUME, this.resumeRecording.bind(this)); + this.mEventBus.on(Action.ACTION_RECORD_STOP, this.stopRecording.bind(this)); + } + + unload(): void { + this.mEventBus.off(Action.ACTION_RECORD_START, this.startRecording.bind(this)); + this.mEventBus.off(Action.ACTION_RECORD_PAUSE, this.pauseRecording.bind(this)); + this.mEventBus.off(Action.ACTION_RECORD_RESUME, this.resumeRecording.bind(this)); + this.mEventBus.off(Action.ACTION_RECORD_STOP, this.stopRecording.bind(this)); + } + private functionBackImpl: VideoCallBack = { videoUri: (videoUri: any): void => { Log.info(`${TAG} functionBackImpl videoUri ${videoUri}`); this.mWorkerManager.postMessage(Action.updateVideoUri(videoUri)); }, - onRecodeError:(data: any): void => { + onRecodeError: (data: any): void => { this.mWorkerManager.postMessage(Action.recordError()); this.mWorkerManager.postMessage(Action.reStartPreview(1)); } @@ -79,7 +93,8 @@ export class RecordFunction extends BaseFunction { private async stopRecording() { Log.info(`${TAG} stopRecording E`); - Log.info(`${TAG} globalThis.startRecording : ${JSON.stringify(GlobalContext.get().getT('startRecordingFlag'))}`); + Log.info(`${TAG} globalThis.startRecording : ${JSON.stringify(GlobalContext.get() + .getT('startRecordingFlag'))}`); if (GlobalContext.get().getT('startRecordingFlag')) { return; } @@ -97,18 +112,4 @@ export class RecordFunction extends BaseFunction { this.enableUiWithMode(UiStateMode.EXCLUDE_PREVIEW); Log.info(`${TAG} stopRecording X`); } - - load(): void{ - this.mEventBus.on(Action.ACTION_RECORD_START, this.startRecording.bind(this)); - this.mEventBus.on(Action.ACTION_RECORD_PAUSE, this.pauseRecording.bind(this)); - this.mEventBus.on(Action.ACTION_RECORD_RESUME, this.resumeRecording.bind(this)); - this.mEventBus.on(Action.ACTION_RECORD_STOP, this.stopRecording.bind(this)); - } - - unload(): void { - this.mEventBus.off(Action.ACTION_RECORD_START, this.startRecording.bind(this)); - this.mEventBus.off(Action.ACTION_RECORD_PAUSE, this.pauseRecording.bind(this)); - this.mEventBus.off(Action.ACTION_RECORD_RESUME, this.resumeRecording.bind(this)); - this.mEventBus.off(Action.ACTION_RECORD_STOP, this.stopRecording.bind(this)); - } } \ No newline at end of file diff --git a/common/src/main/ets/default/function/ZoomFunction.ts b/common/src/main/ets/default/function/ZoomFunction.ts index 09eb4391e8913e9459de28aa7f373fab4e1af238..a193132b901d0a35b80c3ff1980a60d069b91baf 100644 --- a/common/src/main/ets/default/function/ZoomFunction.ts +++ b/common/src/main/ets/default/function/ZoomFunction.ts @@ -20,12 +20,6 @@ import { BaseFunction } from './BaseFunction' export class ZoomFunction extends BaseFunction { private TAG = '[ZoomFunction]:' - private async changeZoomRatio(data) { - Log.info(`${this.TAG} setZoomRatio ${JSON.stringify(data)} E`) - await this.mCameraService.setZoomRatio(data.zoomRatio) - Log.info(`${this.TAG} setZoomRatio X`) - } - load(): void { Log.info(`${this.TAG} load E`) this.mEventBus.on(Action.ACTION_CHANGE_ZOOM_RATIO, this.changeZoomRatio.bind(this)) @@ -37,4 +31,10 @@ export class ZoomFunction extends BaseFunction { this.mEventBus.off(Action.ACTION_CHANGE_ZOOM_RATIO, this.changeZoomRatio.bind(this)) Log.info(`${this.TAG} unload X`) } + + private async changeZoomRatio(data) { + Log.info(`${this.TAG} setZoomRatio ${JSON.stringify(data)} E`) + await this.mCameraService.setZoomRatio(data.zoomRatio) + Log.info(`${this.TAG} setZoomRatio X`) + } } \ No newline at end of file diff --git a/common/src/main/ets/default/redux/actions/Action.ts b/common/src/main/ets/default/redux/actions/Action.ts index eef2625857310e960d5a85333a5b14d5a364926e..3ccdb9cba522adfb8c058e683c78c1342d1e1acc 100644 --- a/common/src/main/ets/default/redux/actions/Action.ts +++ b/common/src/main/ets/default/redux/actions/Action.ts @@ -116,7 +116,8 @@ export class Action { public static readonly ACTION_UPDATE_BIG_VIDEO_TIMER_VISIBLE = 'ACTION_UPDATE_BIG_VIDEO_TIMER_VISIBLE'; public static readonly ACTION_UPDATE_RECORDING_SPOT_VISIBLE = 'ACTION_UPDATE_RECORDING_SPOT_VISIBLE'; public static readonly ACTION_UPDATE_OPACITY_VALUE = 'ACTION_UPDATE_OPACITY_VALUE'; - public static readonly ACTION_UPDATE_SHOW_PRESS_SCROLL_DETAIL_PHOTO_BUTTON = 'ACTION_UPDATE_SHOW_PRESS_SCROLL_DETAIL_PHOTO_BUTTON'; + public static readonly ACTION_UPDATE_SHOW_PRESS_SCROLL_DETAIL_PHOTO_BUTTON = + 'ACTION_UPDATE_SHOW_PRESS_SCROLL_DETAIL_PHOTO_BUTTON'; public static readonly ACTION_UPDATE_SCROLL_DETAILS_BOX = 'ACTION_UPDATE_SCROLL_DETAILS_BOX'; public static readonly ACTION_INIT_PHOTO_DETAILS_OFFSET_X = 'ACTION_INIT_PHOTO_DETAILS_OFFSET_X'; public static readonly ACTION_UPDATE_PHOTO_DETAILS_OFFSET_X = 'ACTION_UPDATE_PHOTO_DETAILS_OFFSET_X'; diff --git a/common/src/main/ets/default/redux/core/combineReducers.ts b/common/src/main/ets/default/redux/core/combineReducers.ts index f00f0dbd8aa8d23c50a4f652daacf9c5b5c326b0..220661c9e979d92e8eeb933d796694f91eeea562 100644 --- a/common/src/main/ets/default/redux/core/combineReducers.ts +++ b/common/src/main/ets/default/redux/core/combineReducers.ts @@ -23,8 +23,8 @@ export type Reducer = ( export function combineReducers(reducers: Array): Reducer { return function combination( - state: OhCombinedState | undefined, - action: ActionData + state: OhCombinedState | undefined, + action: ActionData ) { const nextState: unknown = {}; const currentState = state || {}; diff --git a/common/src/main/ets/default/redux/middlewares/EventBusMiddle.ts b/common/src/main/ets/default/redux/middlewares/EventBusMiddle.ts index f04cb006af9491db18630312a7ddaa0059b1dace..8ad6e44bc003cadca967005a2b9dc4ead0763ea2 100644 --- a/common/src/main/ets/default/redux/middlewares/EventBusMiddle.ts +++ b/common/src/main/ets/default/redux/middlewares/EventBusMiddle.ts @@ -29,8 +29,10 @@ const ACTION_LENGTH: number = 2; * @returns (next: Dispatch) => (action: AnyAction) => anyAction */ export const eventBusMiddle: Middleware = () => (next: Dispatch) => (action: ActionData) => { - const uiAction = { type: action.type, - data: action.data }; + const uiAction = { + type: action.type, + data: action.data + }; // EventBusManager.getInstance().getEventBus().emit(action.type, [action.data]) const result = next(uiAction); diff --git a/common/src/main/ets/default/redux/store.ts b/common/src/main/ets/default/redux/store.ts index b5c21142b17066cfb65135145a2f32bd5f41fd18..789e86deedcc89636a5c7fad54f7d9d5b55f6c32 100644 --- a/common/src/main/ets/default/redux/store.ts +++ b/common/src/main/ets/default/redux/store.ts @@ -36,10 +36,9 @@ import { recordReducer } from './reducers/RecordReducer'; import type { ZoomState } from './reducers/ZoomReducer'; import { zoomReducer } from './reducers/ZoomReducer'; import type { ActionData } from './actions/Action'; -import { applyMiddleware } from './core'; import type { Enhancer, Reducer } from './core'; +import { applyMiddleware, combineReducers } from './core'; import { eventBusMiddle } from './middlewares/EventBusMiddle'; -import { combineReducers } from './core'; const TAG = '[store]:'; const INIT_TAG = 'StoreInit'; @@ -90,12 +89,18 @@ export function getStore(): Store { } export class Store { + private static mInstance: Store | undefined = undefined; private currentReducer: Reducer; private currentState = undefined; private currentListeners: (() => void)[] | null = []; private nextListeners = this.currentListeners; private isDispatching = false; - private static mInstance: Store | undefined = undefined; + + private constructor(reducer: Reducer, enhancer: Enhancer) { + this.currentReducer = reducer; + this.dispatch({ type: INIT_TAG, data: null }); + this.dispatch = enhancer(this.dispatch.bind(this)); + } public static hasStore(): boolean { return Store.mInstance !== undefined; @@ -113,12 +118,6 @@ export class Store { return Store.mInstance; } - private constructor(reducer: Reducer, enhancer: Enhancer) { - this.currentReducer = reducer; - this.dispatch({ type: INIT_TAG, data: null }); - this.dispatch = enhancer(this.dispatch.bind(this)); - } - public getState(): OhCombinedState { if (this.isDispatching) { Log.error('isDispatching get error'); @@ -152,7 +151,8 @@ export class Store { if (mapToDispatch) { mapToDispatch(this.dispatch as Dispatch); } - let unsubscribe: () => void = () => {}; + let unsubscribe: () => void = () => { + }; if (mapToProps) { mapToProps(this.currentState); unsubscribe = this.stateSubscribe(() => mapToProps(this.currentState)); @@ -168,11 +168,13 @@ export class Store { private stateSubscribe(listener: () => void): () => void { if (typeof listener !== 'function') { Log.error('listener is not function'); - return () => {}; + return () => { + }; } if (this.isDispatching) { Log.error('isDispatching stateSubscribe error'); - return () => {}; + return () => { + }; } let isSubScribed = true; diff --git a/common/src/main/ets/default/setting/DisplayCalculator.ts b/common/src/main/ets/default/setting/DisplayCalculator.ts index 253e2286f1ae881758be5d21d824c33ec2cc8b40..5e6bab5d54490ee4e9f0b037286bd25bdd3019f7 100644 --- a/common/src/main/ets/default/setting/DisplayCalculator.ts +++ b/common/src/main/ets/default/setting/DisplayCalculator.ts @@ -13,13 +13,14 @@ * limitations under the License. */ -import { Log } from '../utils/Log' +import { Log } from '../utils/Log'; import deviceInfo from '@ohos.deviceInfo'; export default class DisplayCalculator { private static TAG = '[DisplayCalculator]:' - public static calcSurfaceDisplaySize(screenWidth: number, screenHeight: number, previewWidth: number, previewHeight: number) { + public static calcSurfaceDisplaySize(screenWidth: number, screenHeight: number, previewWidth: number, + previewHeight: number) { const displaySize = { width: 1920, height: 1080 } diff --git a/common/src/main/ets/default/setting/settingitem/AssistiveGrid.ts b/common/src/main/ets/default/setting/settingitem/AssistiveGrid.ts index 850cc1925a002ca95194a9b4480a1525ba5e4c88..7a96970c102ef32086bb14f14c2ff11e30edd7b7 100644 --- a/common/src/main/ets/default/setting/settingitem/AssistiveGrid.ts +++ b/common/src/main/ets/default/setting/settingitem/AssistiveGrid.ts @@ -14,7 +14,7 @@ */ export default class AssistiveGrid { - private static TAG = '[AssistiveGrid]:' public static readonly ALIAS = 'AssistiveGrid' public static readonly DEFAULT_VALUE = '0' + private static TAG = '[AssistiveGrid]:' } \ No newline at end of file diff --git a/common/src/main/ets/default/setting/settingitem/SaveGeoLocation.ts b/common/src/main/ets/default/setting/settingitem/SaveGeoLocation.ts index 6704b61c87d32ebbd5bc7d6290d2f73d43d03a37..168fea54e6f8c91ed367489166eddf151c9362ee 100644 --- a/common/src/main/ets/default/setting/settingitem/SaveGeoLocation.ts +++ b/common/src/main/ets/default/setting/settingitem/SaveGeoLocation.ts @@ -14,7 +14,7 @@ */ export default class SaveGeoLocation { - private static TAG = '[SaveGeoLocation]:' public static readonly ALIAS = 'SaveGeoLocation' public static readonly DEFAULT_VALUE = '1' + private static TAG = '[SaveGeoLocation]:' } \ No newline at end of file diff --git a/common/src/main/ets/default/setting/settingitem/SelfMirror.ts b/common/src/main/ets/default/setting/settingitem/SelfMirror.ts index 6cd0e4dbe679a15e7bc2e71341db9c8f6419293e..8911403b18192c1981fc068b347b37731d41311b 100644 --- a/common/src/main/ets/default/setting/settingitem/SelfMirror.ts +++ b/common/src/main/ets/default/setting/settingitem/SelfMirror.ts @@ -14,7 +14,7 @@ */ export default class SelfMirror { - private static TAG = '[SelfMirror]:' public static readonly ALIAS = 'SelfMirror' public static readonly DEFAULT_VALUE = '0' + private static TAG = '[SelfMirror]:' } \ No newline at end of file diff --git a/common/src/main/ets/default/setting/settingitem/Timer.ts b/common/src/main/ets/default/setting/settingitem/Timer.ts index 94de82014765a7d593020911bdab76bfdb3a9741..84415e168d7b26ad1b5c03387e9d671f7c1e60b0 100644 --- a/common/src/main/ets/default/setting/settingitem/Timer.ts +++ b/common/src/main/ets/default/setting/settingitem/Timer.ts @@ -14,7 +14,6 @@ */ export default class Timer { - private static TAG = '[Timer]:' public static readonly ALIAS = 'Timer' public static readonly TIMER_OFF = 'off' public static readonly TIMER_TWO_SECONDS = '2' @@ -26,30 +25,31 @@ export default class Timer { public static readonly RESOURCE_FIVE_SECONDS = $r('app.string.timer_5_seconds') public static readonly RESOURCE_TEN_SECONDS = $r('app.string.timer_10_seconds') public static readonly RESOURCE_OFF_ALREADY = $r('app.string.already_off') + private static TAG = '[Timer]:' public static convertToResource(timer: string): Resource { switch (timer) { - case Timer.TIMER_OFF: - return Timer.RESOURCE_OFF - case Timer.TIMER_TWO_SECONDS: - return Timer.RESOURCE_TWO_SECONDS - case Timer.TIMER_FIVE_SECONDS: - return Timer.RESOURCE_FIVE_SECONDS - case Timer.TIMER_TEN_SECONDS: - return Timer.RESOURCE_TEN_SECONDS - default: - return Timer.RESOURCE_OFF + case Timer.TIMER_OFF: + return Timer.RESOURCE_OFF + case Timer.TIMER_TWO_SECONDS: + return Timer.RESOURCE_TWO_SECONDS + case Timer.TIMER_FIVE_SECONDS: + return Timer.RESOURCE_FIVE_SECONDS + case Timer.TIMER_TEN_SECONDS: + return Timer.RESOURCE_TEN_SECONDS + default: + return Timer.RESOURCE_OFF } } public static convertToString(res: Resource): string { if (res.id === Timer.RESOURCE_OFF.id) { return Timer.TIMER_OFF - } else if(res.id === Timer.RESOURCE_TWO_SECONDS.id) { + } else if (res.id === Timer.RESOURCE_TWO_SECONDS.id) { return Timer.TIMER_TWO_SECONDS - } else if(res.id === Timer.RESOURCE_FIVE_SECONDS.id) { + } else if (res.id === Timer.RESOURCE_FIVE_SECONDS.id) { return Timer.TIMER_FIVE_SECONDS - } else if(res.id === Timer.RESOURCE_TEN_SECONDS.id) { + } else if (res.id === Timer.RESOURCE_TEN_SECONDS.id) { return Timer.TIMER_TEN_SECONDS } } diff --git a/common/src/main/ets/default/setting/settingitem/VideoCodec.ts b/common/src/main/ets/default/setting/settingitem/VideoCodec.ts index a7a7ed1e6542f19793745a266650cc392ee08f06..3a4ecfa93dd35bbabbb0d686d11ce5a9b456c3ff 100644 --- a/common/src/main/ets/default/setting/settingitem/VideoCodec.ts +++ b/common/src/main/ets/default/setting/settingitem/VideoCodec.ts @@ -14,7 +14,7 @@ */ export default class VideoCodec { - private static TAG = '[VideoCodec]:' public static readonly ALIAS = 'VideoCodec' public static readonly DEFAULT_VALUE = '0' + private static TAG = '[VideoCodec]:' } \ No newline at end of file diff --git a/common/src/main/ets/default/setting/storage/RdbStoreManager.ts b/common/src/main/ets/default/setting/storage/RdbStoreManager.ts index b7c267cdd2cd00e59264d2c94f8169eda929d4a7..ed2c282dddba4820ccba1bbf4f3073660339c0e3 100644 --- a/common/src/main/ets/default/setting/storage/RdbStoreManager.ts +++ b/common/src/main/ets/default/setting/storage/RdbStoreManager.ts @@ -16,16 +16,16 @@ import dataRdb from '@ohos.data.rdb'; import { GlobalContext } from '../../utils/GlobalContext'; -import { Log } from '../../utils/Log' -import SettingItemInfo from './SettingItemInfo' +import { Log } from '../../utils/Log'; +import SettingItemInfo from './SettingItemInfo'; const DB_NAME = 'Camera.db' const DB_VERSION = 1 const TABLE_NAME = 'SETTING' const CREATE_TABLE = 'CREATE TABLE IF NOT EXISTS SETTING ' + -'(id INTEGER PRIMARY KEY AUTOINCREMENT, ' + -'item_name TEXT, ' + -'item_value TEXT)' + '(id INTEGER PRIMARY KEY AUTOINCREMENT, ' + + 'item_name TEXT, ' + + 'item_value TEXT)' /** * db manager @@ -36,6 +36,7 @@ export class RdbStoreManager { private constructor() { } + /** * db manager instance * @@ -64,13 +65,6 @@ export class RdbStoreManager { Log.info(this.TAG + 'initRdbConfig end'); } - private async createTable() { - Log.info(this.TAG + 'create table start'); - Log.info(this.TAG + `RdbStoreConfig.CREATE_TABLE: ${CREATE_TABLE}`); - await this.mRdbStore.executeSql(CREATE_TABLE, []); - Log.info(this.TAG + 'create table end'); - } - public async getSettingByItem(itemName: string) { Log.info(this.TAG + 'getSettingByItem start'); const resultList: SettingItemInfo[] = []; @@ -130,6 +124,13 @@ export class RdbStoreManager { return result; } + private async createTable() { + Log.info(this.TAG + 'create table start'); + Log.info(this.TAG + `RdbStoreConfig.CREATE_TABLE: ${CREATE_TABLE}`); + await this.mRdbStore.executeSql(CREATE_TABLE, []); + Log.info(this.TAG + 'create table end'); + } + private ifStringIsNull(str): boolean { return (str == undefined || str == '' || str == null) } diff --git a/common/src/main/ets/default/setting/storage/SettingItemInfo.ts b/common/src/main/ets/default/setting/storage/SettingItemInfo.ts index eabd424e19ee1bdfd388b988e4f232368f0b4801..36831f261996bab2b65d7162b86ec7a65370f1ac 100644 --- a/common/src/main/ets/default/setting/storage/SettingItemInfo.ts +++ b/common/src/main/ets/default/setting/storage/SettingItemInfo.ts @@ -14,7 +14,6 @@ */ export default class SettingItemInfo { - /** * itemName */ diff --git a/common/src/main/ets/default/utils/ComponentPosition.ts b/common/src/main/ets/default/utils/ComponentPosition.ts index 2873d440b292315ac453d265b1b63ebfd0040fcb..66d8628e1a798f9dc95440d15b7aa79ee452f7de 100644 --- a/common/src/main/ets/default/utils/ComponentPosition.ts +++ b/common/src/main/ets/default/utils/ComponentPosition.ts @@ -34,24 +34,27 @@ export class ComponentPosition { private static foldControlHeight: number = 650 private static controlItemHeight: number = 32 - public static previewPosition(screenWidth: number, screenHeight: number, previewWidth: number, previewHeight: number) { + public static previewPosition(screenWidth: number, screenHeight: number, previewWidth: number, + previewHeight: number) { Log.info(`${this.TAG} previewPosition `) - let position = (Math.abs(screenWidth - previewWidth) < 1) ? { x: 0, y: (screenHeight - previewHeight) / 2} - : { x: (screenWidth - previewWidth) / 2, y: 0 } + let position = (Math.abs(screenWidth - previewWidth) < 1) ? { x: 0, y: (screenHeight - previewHeight) / 2 } + : { x: (screenWidth - previewWidth) / 2, y: 0 } return position } - public static previewTabletPosition(screenWidth: number, screenHeight: number, previewWidth: number, previewHeight: number) { + public static previewTabletPosition(screenWidth: number, screenHeight: number, previewWidth: number, + previewHeight: number) { Log.info(`${this.TAG} previewTabletPosition ` + previewHeight + previewWidth) - if ((screenHeight == previewHeight && previewWidth > previewHeight)) { - return {x: 0, y: 0} + if ((screenHeight == previewHeight && previewWidth > previewHeight)) { + return { x: 0, y: 0 } } - let position = (Math.abs(screenWidth - previewWidth) < 1) ? { x: 0, y: (screenHeight - previewHeight) / 2} - : { x: (screenWidth - previewWidth) / 2, y: 0 } + let position = (Math.abs(screenWidth - previewWidth) < 1) ? { x: 0, y: (screenHeight - previewHeight) / 2 } + : { x: (screenWidth - previewWidth) / 2, y: 0 } return position } - public static footBarPosition(screenWidth: number, screenHeight: number, previewWidth: number, previewHeight: number) { + public static footBarPosition(screenWidth: number, screenHeight: number, previewWidth: number, + previewHeight: number) { Log.info(`${this.TAG} footBarPosition `) if (screenWidth == previewWidth && (3 * previewWidth > 4 * previewHeight)) { let previewSize = DisplayCalculator.calcSurfaceDisplaySize(screenWidth, screenHeight, 4, 3) @@ -60,7 +63,7 @@ export class ComponentPosition { } let position = screenWidth <= previewWidth + this.footBarInPreviewMaxMargin * 2 ? { x: (screenWidth / 2 + previewWidth / 2 - this.footBarComponentWidth), y: 0 } : - { x: (screenWidth * 3 / 4 + previewWidth / 4 - this.footBarComponentWidth / 2), y: 0} + { x: (screenWidth * 3 / 4 + previewWidth / 4 - this.footBarComponentWidth / 2), y: 0 } return position } @@ -73,17 +76,17 @@ export class ComponentPosition { } let xPosition: number = (screenWidth == previewWidth) ? this.tabBarLeftDistance : ((screenWidth >= previewWidth + this.tabBarInPreviewMaxMargin * 2) ? - ((screenWidth - previewWidth) / 4) - this.tarBarWidth / 2 : - ((screenWidth - previewWidth) / 2) + this.tabBarLeftDistance) + ((screenWidth - previewWidth) / 4) - this.tarBarWidth / 2 : + ((screenWidth - previewWidth) / 2) + this.tabBarLeftDistance) let yPosition: number = (screenWidth * 9 <= screenHeight * 16) ? (screenHeight / 2 + screenWidth * 9 / 32 - this.tarBarHeight) : (screenHeight - this.tarBarHeight - this.tabBarBottomDistance) - let position = { x: xPosition, y: 44} + let position = { x: xPosition, y: 44 } return position } public static zoomViewPosition(screenWidth: number, screenHeight: number, previewWidth: number, previewHeight: number, - videoState: string) { + videoState: string) { Log.info(`${this.TAG} zoomViewPosition `) let zoomViewWidth: number let shutterButtonWidth: number @@ -102,7 +105,7 @@ export class ComponentPosition { let xPosition: number = 0; if (screenWidth < previewWidth + this.footBarInPreviewMaxMargin * 2) { xPosition = (screenWidth / 2 + previewWidth / 2 - ((this.footBarComponentWidth + this.zoomViewComponentWidth - + zoomViewWidth + shutterButtonWidth) / 2 + this.zoomViewRightDistance)) + + zoomViewWidth + shutterButtonWidth) / 2 + this.zoomViewRightDistance)) } else if (screenWidth < previewWidth + zoomViewWidth * 4 + shutterButtonWidth * 2) { xPosition = screenWidth / 2 + previewWidth / 2 - this.zoomViewToPreview } else { @@ -134,7 +137,7 @@ export class ComponentPosition { } public static getFootBarHeight(screenWidth: number, screenHeight: number, previewHeight: number) { - let x = this.getShutterButtonMargin(screenWidth, screenHeight, previewHeight) * 2 + 164 + let x = this.getShutterButtonMargin(screenWidth, screenHeight, previewHeight) * 2 + 164 return x } @@ -144,7 +147,7 @@ export class ComponentPosition { return 0 } let previewSize = DisplayCalculator.calcSurfaceDisplaySize(screenWidth, screenHeight, 4, 3) - let x = previewSize.height * 12 / 100 - 48 + let x = previewSize.height * 12 / 100 - 48 return x } diff --git a/common/src/main/ets/default/utils/DateTimeUtil.ts b/common/src/main/ets/default/utils/DateTimeUtil.ts index a03b32458f990f61829a9009c39743ac418033f4..1cc7755250b3aab7f4236c961680e948a8df6681 100644 --- a/common/src/main/ets/default/utils/DateTimeUtil.ts +++ b/common/src/main/ets/default/utils/DateTimeUtil.ts @@ -17,12 +17,11 @@ * @file: 日期工具 */ export default class DateTimeUtil { - /** - * 时分秒 - * - * @return {string} - 返回时分秒 - */ + * 时分秒 + * + * @return {string} - 返回时分秒 + */ getTime() { const DATETIME = new Date(); const HOURS = DATETIME.getHours(); @@ -32,10 +31,10 @@ export default class DateTimeUtil { } /** - * 年月日 - * - * @return {string} - 返回年月日 - */ + * 年月日 + * + * @return {string} - 返回年月日 + */ getDate() { const DATETIME = new Date(); const YEAR = DATETIME.getFullYear(); @@ -45,35 +44,35 @@ export default class DateTimeUtil { } /** - * 日期不足两位补 0 - * - * @param {string} value - 数据值 - * @return {string} - 日期不足两位补 0 - */ + * 日期不足两位补 0 + * + * @param {string} value - 数据值 + * @return {string} - 日期不足两位补 0 + */ fill(value): string { return (value > 9 ? '' : '0') + value; } /** - * 年月日格式修饰 - * - * @param {string} year - 年 - * @param {string} month - 月 - * @param {string} date - 日 - * @return {string} - 年月日格式修饰 - */ + * 年月日格式修饰 + * + * @param {string} year - 年 + * @param {string} month - 月 + * @param {string} date - 日 + * @return {string} - 年月日格式修饰 + */ concatDate(year, month, date) { return `${year}${month}${date}`; } /** - * 时分秒格式修饰 - * - * @param {string} hours - 时 - * @param {string} minutes - 分 - * @param {string} seconds - 秒 - * @return {string} - 时分秒格式修饰 - */ + * 时分秒格式修饰 + * + * @param {string} hours - 时 + * @param {string} minutes - 分 + * @param {string} seconds - 秒 + * @return {string} - 时分秒格式修饰 + */ concatTime(hours, minutes, seconds) { return `${this.fill(hours)}${this.fill(minutes)}${this.fill(seconds)}`; } diff --git a/common/src/main/ets/default/utils/GlobalContext.ts b/common/src/main/ets/default/utils/GlobalContext.ts index 97dcafe195b5fe2588e55e23eb6cb946428cff17..76b7f8e9b816d4222cbae317ab871280f82cc94e 100644 --- a/common/src/main/ets/default/utils/GlobalContext.ts +++ b/common/src/main/ets/default/utils/GlobalContext.ts @@ -22,10 +22,6 @@ import { Log } from './Log'; export class GlobalContext { private static TAG: string = '[GlobalContext]:'; - - private constructor() { - } - private static instance: GlobalContext; private _objects = new Map(); private mDisplay: display.Display | undefined = undefined; @@ -44,6 +40,9 @@ export class GlobalContext { private cameraUIExtensionContentSession: UIExtensionContentSession; private pickerUri: string; + private constructor() { + } + public static get(): GlobalContext { if (!Boolean(GlobalContext.instance).valueOf()) { GlobalContext.instance = new GlobalContext(); diff --git a/common/src/main/ets/default/utils/Log.ts b/common/src/main/ets/default/utils/Log.ts index 9fda48a55ff91ceaf7840fccac10ff7d402c331d..fff67fced09a99e044ab2a815e8524b000d674a7 100644 --- a/common/src/main/ets/default/utils/Log.ts +++ b/common/src/main/ets/default/utils/Log.ts @@ -92,11 +92,6 @@ export class Log { hiTraceMeter.startTrace(methodName, taskId); } - private static init(): void { - globalThis.taskIdMap = new Map(); - globalThis.traceIndex = TRACE_BASE_INDEX; - } - static end(methodName: string): void { this.info(methodName + TRACE_LOG_END); if (!RECORD_TRACE) { @@ -112,4 +107,9 @@ export class Log { } hiTraceMeter.finishTrace(methodName, taskId); } + + private static init(): void { + globalThis.taskIdMap = new Map(); + globalThis.traceIndex = TRACE_BASE_INDEX; + } } \ No newline at end of file diff --git a/common/src/main/ets/default/worker/AsyncManager.ts b/common/src/main/ets/default/worker/AsyncManager.ts index c74b6af34a19ce68f5592bf309dc7c025dfc5805..b467f01ea9edac8422e122d23467470a2f6e8a8c 100644 --- a/common/src/main/ets/default/worker/AsyncManager.ts +++ b/common/src/main/ets/default/worker/AsyncManager.ts @@ -26,9 +26,9 @@ export interface Message { } export class AsyncManager { + protected mWorker: any; private workerName: string; private workerUri: string; - protected mWorker: any; private appEventBus: EventBus = EventBusManager.getWorkerInstance().getEventBus(); private _appEventBus: EventBus = EventBusManager.getCameraInstance().getEventBus(); @@ -60,11 +60,10 @@ export class AsyncManager { // this.mWorker.onexit = this.onexit.bind(this) // } - private initWorker(): void { - this._appEventBus.on('WORKER_TO_MAIN', (...args) => { - Log.info(`${TAG} mWorker.onmessage`); - this.onMessage(args[0]); - }) + // 向worker线程发送消息 + public postMessage(msg: Message): void { + Log.info(`${TAG} postMessage`); + this.appEventBus.emit('MAIN_TO_WORKER', [msg]); } //todo 预留实现,待能力稳定后开放 @@ -74,12 +73,6 @@ export class AsyncManager { // return this // } - // 向worker线程发送消息 - public postMessage(msg: Message): void { - Log.info(`${TAG} postMessage`); - this.appEventBus.emit('MAIN_TO_WORKER', [msg]); - } - // 接收worker线程返回的UiData public onMessage(msg: Message): void { Log.info(`${TAG} onMessage uidata: ${JSON.stringify(msg.data)}`); @@ -96,4 +89,11 @@ export class AsyncManager { public onexit(msg: Message): void { } + + private initWorker(): void { + this._appEventBus.on('WORKER_TO_MAIN', (...args) => { + Log.info(`${TAG} mWorker.onmessage`); + this.onMessage(args[0]); + }) + } } \ No newline at end of file diff --git a/common/src/main/ets/default/worker/eventbus/EventBus.ts b/common/src/main/ets/default/worker/eventbus/EventBus.ts index 01c06d49d1739f0a417a57084da825bbdfe8a4ee..52e21c31358a005d168eb1a3d804cc4bac7983df 100644 --- a/common/src/main/ets/default/worker/eventbus/EventBus.ts +++ b/common/src/main/ets/default/worker/eventbus/EventBus.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import { Log } from '../../utils/Log' +import { Log } from '../../utils/Log'; type Callback = (args: any) => void @@ -25,11 +25,11 @@ export class EventBus { } /** - * Register events and handlers - * - * @param event event to handle. - * @param callback event related callbacck - */ + * Register events and handlers + * + * @param event event to handle. + * @param callback event related callbacck + */ public on(event: string | string[], callback: Callback): void { Log.info(`${this.TAG} on event = ${JSON.stringify(event)} ${JSON.stringify(callback)}`); if (Array.isArray(event)) { @@ -48,11 +48,11 @@ export class EventBus { } /** - * Register events and processing functions, and destroy them after triggering once - * - * @param event event to handle - * @param callback event related callback - */ + * Register events and processing functions, and destroy them after triggering once + * + * @param event event to handle + * @param callback event related callback + */ public once(event: string | string[], callback: Callback): void { const _self = this @@ -67,11 +67,11 @@ export class EventBus { } /** - * Destroy events and handlers - * - * @param event event to handle - * @param callback event related callback - */ + * Destroy events and handlers + * + * @param event event to handle + * @param callback event related callback + */ public off(event: string | string[], callback: Callback | undefined): void { // Array cyclic emptying if (Array.isArray(event)) { @@ -96,11 +96,11 @@ export class EventBus { } /** - * Trigger all callbacks of an event with parameters - * - * @param event event to handle - * @param argument parameter for the related callback - */ + * Trigger all callbacks of an event with parameters + * + * @param event event to handle + * @param argument parameter for the related callback + */ public emit(event: string, argument: any): void { // once deleting the event will cause this in the following loop this._events moves forward in fn, // so it is copied here as a new array diff --git a/features/multi/BuildProfile.ets b/features/multi/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a501e5ddee8ea6d28961648fc7dd314a5304bd4 --- /dev/null +++ b/features/multi/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/features/multi/oh-package-lock.json5 b/features/multi/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..71fb2aa27ea03ee139d0c1365fbfd5ab52c7931d --- /dev/null +++ b/features/multi/oh-package-lock.json5 @@ -0,0 +1,18 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/common@../../common": "@ohos/common@../../common" + }, + "packages": { + "@ohos/common@../../common": { + "name": "@ohos/common", + "version": "1.0.0", + "resolved": "../../common", + "registryType": "local" + } + } +} \ No newline at end of file diff --git a/features/multi/oh-package.json5 b/features/multi/oh-package.json5 index a2ce472ab7925b7bc77c33455392e007145fd12f..23b7568429b22b944ce31dfbfd0a1a61add0891b 100644 --- a/features/multi/oh-package.json5 +++ b/features/multi/oh-package.json5 @@ -3,7 +3,7 @@ "devDependencies": {}, "name": "@ohos/multi", "description": "multi mode", - "main": "index.ets", + "main": "index.ts", "repository": {}, "version": "1.0.0", "dependencies": { diff --git a/features/photo/BuildProfile.ets b/features/photo/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a501e5ddee8ea6d28961648fc7dd314a5304bd4 --- /dev/null +++ b/features/photo/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/features/photo/oh-package-lock.json5 b/features/photo/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..71fb2aa27ea03ee139d0c1365fbfd5ab52c7931d --- /dev/null +++ b/features/photo/oh-package-lock.json5 @@ -0,0 +1,18 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/common@../../common": "@ohos/common@../../common" + }, + "packages": { + "@ohos/common@../../common": { + "name": "@ohos/common", + "version": "1.0.0", + "resolved": "../../common", + "registryType": "local" + } + } +} \ No newline at end of file diff --git a/features/photo/oh-package.json5 b/features/photo/oh-package.json5 index a5c7b128c60d8e80691ec418c9d80ec80213a421..8175b7d8ab9b40a8801273365c712f726f7eaa87 100644 --- a/features/photo/oh-package.json5 +++ b/features/photo/oh-package.json5 @@ -3,7 +3,7 @@ "devDependencies": {}, "name": "@ohos/photo", "description": "photo mode", - "main": "index.ets", + "main": "index.ts", "repository": {}, "version": "1.0.0", "dependencies": { diff --git a/features/video/BuildProfile.ets b/features/video/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a501e5ddee8ea6d28961648fc7dd314a5304bd4 --- /dev/null +++ b/features/video/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/features/video/oh-package-lock.json5 b/features/video/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..71fb2aa27ea03ee139d0c1365fbfd5ab52c7931d --- /dev/null +++ b/features/video/oh-package-lock.json5 @@ -0,0 +1,18 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/common@../../common": "@ohos/common@../../common" + }, + "packages": { + "@ohos/common@../../common": { + "name": "@ohos/common", + "version": "1.0.0", + "resolved": "../../common", + "registryType": "local" + } + } +} \ No newline at end of file diff --git a/features/video/oh-package.json5 b/features/video/oh-package.json5 index 87a016f162e203fddf31322a8697413d3777d73f..55fe74ef826c4ac75a217c4abd0d704467aa14c8 100644 --- a/features/video/oh-package.json5 +++ b/features/video/oh-package.json5 @@ -3,7 +3,7 @@ "devDependencies": {}, "name": "@ohos/video", "description": "video mode", - "main": "index.ets", + "main": "index.ts", "repository": {}, "version": "1.0.0", "dependencies": { diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 index 122677b194bc767301ef00a87a4b93c45562fe31..925d91375818953dfab6c055575f484b10a4bb0d 100644 --- a/hvigor/hvigor-config.json5 +++ b/hvigor/hvigor-config.json5 @@ -1,6 +1,5 @@ { - "hvigorVersion": "3.0.9", + "modelVersion": "5.0.2", "dependencies": { - "@ohos/hvigor-ohos-plugin": "3.0.9" } } \ No newline at end of file diff --git a/hvigor/hvigor-wrapper.js b/hvigor/hvigor-wrapper.js deleted file mode 100644 index 372eae8eb4a124095936f9cd78df5c6756746f3f..0000000000000000000000000000000000000000 --- a/hvigor/hvigor-wrapper.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";var u=require("path"),D=require("os"),e=require("fs"),t=require("crypto"),r=require("child_process"),n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i={},C={},F=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(C,"__esModule",{value:!0}),C.maxPathLength=C.isMac=C.isLinux=C.isWindows=void 0;const E=F(D),A="Windows_NT",o="Darwin";function a(){return E.default.type()===A}function c(){return E.default.type()===o}C.isWindows=a,C.isLinux=function(){return"Linux"===E.default.type()},C.isMac=c,C.maxPathLength=function(){return c()?1016:a()?259:4095},function(e){var t=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),r=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),i=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&t(D,u,e);return r(D,u),D};Object.defineProperty(e,"__esModule",{value:!0}),e.WORK_SPACE=e.HVIGOR_PROJECT_WRAPPER_HOME=e.HVIGOR_PROJECT_ROOT_DIR=e.HVIGOR_PROJECT_CACHES_HOME=e.HVIGOR_PNPM_STORE_PATH=e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=e.PROJECT_CACHES=e.HVIGOR_WRAPPER_TOOLS_HOME=e.HVIGOR_USER_HOME=e.DEFAULT_PACKAGE_JSON=e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME=e.PNPM=e.HVIGOR=e.NPM_TOOL=e.PNPM_TOOL=e.HVIGOR_ENGINE_PACKAGE_NAME=void 0;const F=i(D),E=i(u),A=C;e.HVIGOR_ENGINE_PACKAGE_NAME="@ohos/hvigor",e.PNPM_TOOL=(0,A.isWindows)()?"pnpm.cmd":"pnpm",e.NPM_TOOL=(0,A.isWindows)()?"npm.cmd":"npm",e.HVIGOR="hvigor",e.PNPM="pnpm",e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME="hvigor-config.json5",e.DEFAULT_PACKAGE_JSON="package.json",e.HVIGOR_USER_HOME=E.resolve(F.homedir(),".hvigor"),e.HVIGOR_WRAPPER_TOOLS_HOME=E.resolve(e.HVIGOR_USER_HOME,"wrapper","tools"),e.PROJECT_CACHES="project_caches",e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=E.resolve(e.HVIGOR_WRAPPER_TOOLS_HOME,"node_modules",".bin",e.PNPM_TOOL),e.HVIGOR_PNPM_STORE_PATH=E.resolve(e.HVIGOR_USER_HOME,"caches"),e.HVIGOR_PROJECT_CACHES_HOME=E.resolve(e.HVIGOR_USER_HOME,e.PROJECT_CACHES),e.HVIGOR_PROJECT_ROOT_DIR=process.cwd(),e.HVIGOR_PROJECT_WRAPPER_HOME=E.resolve(e.HVIGOR_PROJECT_ROOT_DIR,e.HVIGOR),e.WORK_SPACE="workspace"}(i);var s={},l={};Object.defineProperty(l,"__esModule",{value:!0}),l.logInfoPrintConsole=l.logErrorAndExit=void 0,l.logErrorAndExit=function(u){u instanceof Error?console.error(u.message):console.error(u),process.exit(-1)},l.logInfoPrintConsole=function(u){console.log(u)};var B=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),d=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),f=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&B(D,u,e);return d(D,u),D};Object.defineProperty(s,"__esModule",{value:!0});var _=s.executeBuild=void 0;const p=f(e),O=f(u),h=l;_=s.executeBuild=function(u){const D=O.resolve(u,"node_modules","@ohos","hvigor","bin","hvigor.js");try{const u=p.realpathSync(D);require(u)}catch(e){(0,h.logErrorAndExit)(`Error: ENOENT: no such file ${D},delete ${u} and retry.`)}};var P={},v={};!function(u){var D=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(u,"__esModule",{value:!0}),u.hashFile=u.hash=u.createHash=void 0;const r=D(t),i=D(e);u.createHash=(u="MD5")=>r.default.createHash(u);u.hash=(D,e)=>(0,u.createHash)(e).update(D).digest("hex");u.hashFile=(D,e)=>{if(i.default.existsSync(D))return(0,u.hash)(i.default.readFileSync(D,"utf-8"),e)}}(v);var g={},m={},R={};Object.defineProperty(R,"__esModule",{value:!0}),R.Unicode=void 0;class y{}R.Unicode=y,y.SPACE_SEPARATOR=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,y.ID_START=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,y.ID_CONTINUE=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,Object.defineProperty(m,"__esModule",{value:!0}),m.JudgeUtil=void 0;const I=R;m.JudgeUtil=class{static isIgnoreChar(u){return"string"==typeof u&&("\t"===u||"\v"===u||"\f"===u||" "===u||" "===u||"\ufeff"===u||"\n"===u||"\r"===u||"\u2028"===u||"\u2029"===u)}static isSpaceSeparator(u){return"string"==typeof u&&I.Unicode.SPACE_SEPARATOR.test(u)}static isIdStartChar(u){return"string"==typeof u&&(u>="a"&&u<="z"||u>="A"&&u<="Z"||"$"===u||"_"===u||I.Unicode.ID_START.test(u))}static isIdContinueChar(u){return"string"==typeof u&&(u>="a"&&u<="z"||u>="A"&&u<="Z"||u>="0"&&u<="9"||"$"===u||"_"===u||"‌"===u||"‍"===u||I.Unicode.ID_CONTINUE.test(u))}static isDigitWithoutZero(u){return/[1-9]/.test(u)}static isDigit(u){return"string"==typeof u&&/[0-9]/.test(u)}static isHexDigit(u){return"string"==typeof u&&/[0-9A-Fa-f]/.test(u)}};var N=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(g,"__esModule",{value:!0}),g.parseJsonText=g.parseJsonFile=void 0;const b=N(e),S=N(D),w=N(u),H=m;var x;!function(u){u[u.Char=0]="Char",u[u.EOF=1]="EOF",u[u.Identifier=2]="Identifier"}(x||(x={}));let M,T,V,G,j,J,W="start",U=[],L=0,$=1,k=0,K=!1,z="default",q="'",Z=1;function X(u,D=!1){T=String(u),W="start",U=[],L=0,$=1,k=0,G=void 0,K=D;do{M=Q(),nu[W]()}while("eof"!==M.type);return G}function Q(){for(z="default",j="",q="'",Z=1;;){J=Y();const u=Du[z]();if(u)return u}}function Y(){if(T[L])return String.fromCodePoint(T.codePointAt(L))}function uu(){const u=Y();return"\n"===u?($++,k=0):u?k+=u.length:k++,u&&(L+=u.length),u}g.parseJsonFile=function(u,D=!1,e="utf-8"){const t=b.default.readFileSync(w.default.resolve(u),{encoding:e});try{return X(t,D)}catch(D){if(D instanceof SyntaxError){const e=D.message.split("at");if(2===e.length)throw new Error(`${e[0].trim()}${S.default.EOL}\t at ${u}:${e[1].trim()}`)}throw new Error(`${u} is not in valid JSON/JSON5 format.`)}},g.parseJsonText=X;const Du={default(){switch(J){case"/":return uu(),void(z="comment");case void 0:return uu(),eu("eof")}if(!H.JudgeUtil.isIgnoreChar(J)&&!H.JudgeUtil.isSpaceSeparator(J))return Du[W]();uu()},start(){z="value"},beforePropertyName(){switch(J){case"$":case"_":return j=uu(),void(z="identifierName");case"\\":return uu(),void(z="identifierNameStartEscape");case"}":return eu("punctuator",uu());case'"':case"'":return q=J,uu(),void(z="string")}if(H.JudgeUtil.isIdStartChar(J))return j+=uu(),void(z="identifierName");throw Eu(x.Char,uu())},afterPropertyName(){if(":"===J)return eu("punctuator",uu());throw Eu(x.Char,uu())},beforePropertyValue(){z="value"},afterPropertyValue(){switch(J){case",":case"}":return eu("punctuator",uu())}throw Eu(x.Char,uu())},beforeArrayValue(){if("]"===J)return eu("punctuator",uu());z="value"},afterArrayValue(){switch(J){case",":case"]":return eu("punctuator",uu())}throw Eu(x.Char,uu())},end(){throw Eu(x.Char,uu())},comment(){switch(J){case"*":return uu(),void(z="multiLineComment");case"/":return uu(),void(z="singleLineComment")}throw Eu(x.Char,uu())},multiLineComment(){switch(J){case"*":return uu(),void(z="multiLineCommentAsterisk");case void 0:throw Eu(x.Char,uu())}uu()},multiLineCommentAsterisk(){switch(J){case"*":return void uu();case"/":return uu(),void(z="default");case void 0:throw Eu(x.Char,uu())}uu(),z="multiLineComment"},singleLineComment(){switch(J){case"\n":case"\r":case"\u2028":case"\u2029":return uu(),void(z="default");case void 0:return uu(),eu("eof")}uu()},value(){switch(J){case"{":case"[":return eu("punctuator",uu());case"n":return uu(),tu("ull"),eu("null",null);case"t":return uu(),tu("rue"),eu("boolean",!0);case"f":return uu(),tu("alse"),eu("boolean",!1);case"-":case"+":return"-"===uu()&&(Z=-1),void(z="numerical");case".":case"0":case"I":case"N":return void(z="numerical");case'"':case"'":return q=J,uu(),j="",void(z="string")}if(void 0===J||!H.JudgeUtil.isDigitWithoutZero(J))throw Eu(x.Char,uu());z="numerical"},numerical(){switch(J){case".":return j=uu(),void(z="decimalPointLeading");case"0":return j=uu(),void(z="zero");case"I":return uu(),tu("nfinity"),eu("numeric",Z*(1/0));case"N":return uu(),tu("aN"),eu("numeric",NaN)}if(void 0!==J&&H.JudgeUtil.isDigitWithoutZero(J))return j=uu(),void(z="decimalInteger");throw Eu(x.Char,uu())},zero(){switch(J){case".":case"e":case"E":return void(z="decimal");case"x":case"X":return j+=uu(),void(z="hexadecimal")}return eu("numeric",0)},decimalInteger(){switch(J){case".":case"e":case"E":return void(z="decimal")}if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},decimal(){switch(J){case".":j+=uu(),z="decimalFraction";break;case"e":case"E":j+=uu(),z="decimalExponent"}},decimalPointLeading(){if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalFraction");throw Eu(x.Char,uu())},decimalFraction(){switch(J){case"e":case"E":return j+=uu(),void(z="decimalExponent")}if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},decimalExponent(){switch(J){case"+":case"-":return j+=uu(),void(z="decimalExponentSign")}if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalExponentInteger");throw Eu(x.Char,uu())},decimalExponentSign(){if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalExponentInteger");throw Eu(x.Char,uu())},decimalExponentInteger(){if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},hexadecimal(){if(H.JudgeUtil.isHexDigit(J))return j+=uu(),void(z="hexadecimalInteger");throw Eu(x.Char,uu())},hexadecimalInteger(){if(!H.JudgeUtil.isHexDigit(J))return eu("numeric",Z*Number(j));j+=uu()},identifierNameStartEscape(){if("u"!==J)throw Eu(x.Char,uu());uu();const u=ru();switch(u){case"$":case"_":break;default:if(!H.JudgeUtil.isIdStartChar(u))throw Eu(x.Identifier)}j+=u,z="identifierName"},identifierName(){switch(J){case"$":case"_":case"‌":case"‍":return void(j+=uu());case"\\":return uu(),void(z="identifierNameEscape")}if(!H.JudgeUtil.isIdContinueChar(J))return eu("identifier",j);j+=uu()},identifierNameEscape(){if("u"!==J)throw Eu(x.Char,uu());uu();const u=ru();switch(u){case"$":case"_":case"‌":case"‍":break;default:if(!H.JudgeUtil.isIdContinueChar(u))throw Eu(x.Identifier)}j+=u,z="identifierName"},string(){switch(J){case"\\":return uu(),void(j+=function(){const u=Y(),D=function(){switch(Y()){case"b":return uu(),"\b";case"f":return uu(),"\f";case"n":return uu(),"\n";case"r":return uu(),"\r";case"t":return uu(),"\t";case"v":return uu(),"\v"}return}();if(D)return D;switch(u){case"0":if(uu(),H.JudgeUtil.isDigit(Y()))throw Eu(x.Char,uu());return"\0";case"x":return uu(),function(){let u="",D=Y();if(!H.JudgeUtil.isHexDigit(D))throw Eu(x.Char,uu());if(u+=uu(),D=Y(),!H.JudgeUtil.isHexDigit(D))throw Eu(x.Char,uu());return u+=uu(),String.fromCodePoint(parseInt(u,16))}();case"u":return uu(),ru();case"\n":case"\u2028":case"\u2029":return uu(),"";case"\r":return uu(),"\n"===Y()&&uu(),""}if(void 0===u||H.JudgeUtil.isDigitWithoutZero(u))throw Eu(x.Char,uu());return uu()}());case'"':case"'":if(J===q){const u=eu("string",j);return uu(),u}return void(j+=uu());case"\n":case"\r":case void 0:throw Eu(x.Char,uu());case"\u2028":case"\u2029":!function(u){console.warn(`JSON5: '${Fu(u)}' in strings is not valid ECMAScript; consider escaping.`)}(J)}j+=uu()}};function eu(u,D){return{type:u,value:D,line:$,column:k}}function tu(u){for(const D of u){if(Y()!==D)throw Eu(x.Char,uu());uu()}}function ru(){let u="",D=4;for(;D-- >0;){const D=Y();if(!H.JudgeUtil.isHexDigit(D))throw Eu(x.Char,uu());u+=uu()}return String.fromCodePoint(parseInt(u,16))}const nu={start(){if("eof"===M.type)throw Eu(x.EOF);iu()},beforePropertyName(){switch(M.type){case"identifier":case"string":return V=M.value,void(W="afterPropertyName");case"punctuator":return void Cu();case"eof":throw Eu(x.EOF)}},afterPropertyName(){if("eof"===M.type)throw Eu(x.EOF);W="beforePropertyValue"},beforePropertyValue(){if("eof"===M.type)throw Eu(x.EOF);iu()},afterPropertyValue(){if("eof"===M.type)throw Eu(x.EOF);switch(M.value){case",":return void(W="beforePropertyName");case"}":Cu()}},beforeArrayValue(){if("eof"===M.type)throw Eu(x.EOF);"punctuator"!==M.type||"]"!==M.value?iu():Cu()},afterArrayValue(){if("eof"===M.type)throw Eu(x.EOF);switch(M.value){case",":return void(W="beforeArrayValue");case"]":Cu()}},end(){}};function iu(){const u=function(){let u;switch(M.type){case"punctuator":switch(M.value){case"{":u={};break;case"[":u=[]}break;case"null":case"boolean":case"numeric":case"string":u=M.value}return u}();if(K&&"object"==typeof u&&(u._line=$,u._column=k),void 0===G)G=u;else{const D=U[U.length-1];Array.isArray(D)?K&&"object"!=typeof u?D.push({value:u,_line:$,_column:k}):D.push(u):D[V]=K&&"object"!=typeof u?{value:u,_line:$,_column:k}:u}!function(u){if(u&&"object"==typeof u)U.push(u),W=Array.isArray(u)?"beforeArrayValue":"beforePropertyName";else{const u=U[U.length-1];W=u?Array.isArray(u)?"afterArrayValue":"afterPropertyValue":"end"}}(u)}function Cu(){U.pop();const u=U[U.length-1];W=u?Array.isArray(u)?"afterArrayValue":"afterPropertyValue":"end"}function Fu(u){const D={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(D[u])return D[u];if(u<" "){const D=u.charCodeAt(0).toString(16);return`\\x${`00${D}`.substring(D.length)}`}return u}function Eu(u,D){let e="";switch(u){case x.Char:e=void 0===D?`JSON5: invalid end of input at ${$}:${k}`:`JSON5: invalid character '${Fu(D)}' at ${$}:${k}`;break;case x.EOF:e=`JSON5: invalid end of input at ${$}:${k}`;break;case x.Identifier:k-=5,e=`JSON5: invalid identifier character at ${$}:${k}`}const t=new Au(e);return t.lineNumber=$,t.columnNumber=k,t}class Au extends SyntaxError{}var ou={},au=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),cu=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),su=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&au(D,u,e);return cu(D,u),D},lu=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(ou,"__esModule",{value:!0}),ou.isFileExists=ou.offlinePluginConversion=ou.executeCommand=ou.getNpmPath=ou.hasNpmPackInPaths=void 0;const Bu=r,du=lu(e),fu=su(u),_u=i,pu=l;ou.hasNpmPackInPaths=function(u,D){try{return require.resolve(u,{paths:[...D]}),!0}catch(u){return!1}},ou.getNpmPath=function(){const u=process.execPath;return fu.join(fu.dirname(u),_u.NPM_TOOL)},ou.executeCommand=function(u,D,e){0!==(0,Bu.spawnSync)(u,D,e).status&&(0,pu.logErrorAndExit)(`Error: ${u} ${D} execute failed.See above for details.`)},ou.offlinePluginConversion=function(u,D){return D.startsWith("file:")||D.endsWith(".tgz")?fu.resolve(u,_u.HVIGOR,D.replace("file:","")):D},ou.isFileExists=function(u){return du.default.existsSync(u)&&du.default.statSync(u).isFile()};var Ou=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),hu=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),Pu=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&Ou(D,u,e);return hu(D,u),D},vu=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(P,"__esModule",{value:!0});var gu=P.initProjectWorkSpace=void 0;const mu=Pu(e),Ru=vu(D),yu=Pu(u),Iu=v,Nu=i,bu=g,Su=l,wu=ou;let Hu,xu,Mu;function Tu(u,D,e){return void 0!==e.dependencies&&(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,D.dependencies[u])===yu.normalize(e.dependencies[u])}function Vu(){const u=yu.join(Mu,Nu.WORK_SPACE);if((0,Su.logInfoPrintConsole)("Hvigor cleaning..."),!mu.existsSync(u))return;const D=mu.readdirSync(u);if(!D||0===D.length)return;const e=yu.resolve(Mu,"node_modules","@ohos","hvigor","bin","hvigor.js");mu.existsSync(e)&&(0,wu.executeCommand)(process.argv[0],[e,"--stop-daemon"],{});try{D.forEach((D=>{mu.rmSync(yu.resolve(u,D),{recursive:!0})}))}catch(D){(0,Su.logErrorAndExit)(`The hvigor build tool cannot be installed. Please manually clear the workspace directory and synchronize the project again.\n\n Workspace Path: ${u}.`)}}gu=P.initProjectWorkSpace=function(){if(Hu=function(){const u=yu.resolve(Nu.HVIGOR_PROJECT_WRAPPER_HOME,Nu.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME);mu.existsSync(u)||(0,Su.logErrorAndExit)(`Error: Hvigor config file ${u} does not exist.`);return(0,bu.parseJsonFile)(u)}(),Mu=function(u){let D;D=function(u){let D=u.hvigorVersion;if(D.startsWith("file:")||D.endsWith(".tgz"))return!1;const e=u.dependencies,t=Object.getOwnPropertyNames(e);for(const u of t){const D=e[u];if(D.startsWith("file:")||D.endsWith(".tgz"))return!1}if(1===t.length&&"@ohos/hvigor-ohos-plugin"===t[0])return D>"2.5.0";return!1}(u)?function(u){let D=`${Nu.HVIGOR_ENGINE_PACKAGE_NAME}@${u.hvigorVersion}`;const e=u.dependencies;if(e){Object.getOwnPropertyNames(e).sort().forEach((u=>{D+=`,${u}@${e[u]}`}))}return(0,Iu.hash)(D)}(u):(0,Iu.hash)(process.cwd());return yu.resolve(Ru.default.homedir(),".hvigor","project_caches",D)}(Hu),xu=function(){const u=yu.resolve(Mu,Nu.WORK_SPACE,Nu.DEFAULT_PACKAGE_JSON);return mu.existsSync(u)?(0,bu.parseJsonFile)(u):{dependencies:{}}}(),!(0,wu.hasNpmPackInPaths)(Nu.HVIGOR_ENGINE_PACKAGE_NAME,[yu.join(Mu,Nu.WORK_SPACE)])||(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,Hu.hvigorVersion)!==xu.dependencies[Nu.HVIGOR_ENGINE_PACKAGE_NAME]||!function(){function u(u){const D=null==u?void 0:u.dependencies;return void 0===D?0:Object.getOwnPropertyNames(D).length}const D=u(Hu),e=u(xu);if(D+1!==e)return!1;for(const u in null==Hu?void 0:Hu.dependencies)if(!(0,wu.hasNpmPackInPaths)(u,[yu.join(Mu,Nu.WORK_SPACE)])||!Tu(u,Hu,xu))return!1;return!0}()){Vu();try{!function(){(0,Su.logInfoPrintConsole)("Hvigor installing...");for(const u in Hu.dependencies)Hu.dependencies[u]&&(Hu.dependencies[u]=(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,Hu.dependencies[u]));const u={dependencies:{...Hu.dependencies}};u.dependencies[Nu.HVIGOR_ENGINE_PACKAGE_NAME]=(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,Hu.hvigorVersion);const D=yu.join(Mu,Nu.WORK_SPACE);try{mu.mkdirSync(D,{recursive:!0});const e=yu.resolve(D,Nu.DEFAULT_PACKAGE_JSON);mu.writeFileSync(e,JSON.stringify(u))}catch(u){(0,Su.logErrorAndExit)(u)}(function(){const u=["config","set","store-dir",Nu.HVIGOR_PNPM_STORE_PATH],D={cwd:yu.join(Mu,Nu.WORK_SPACE),stdio:["inherit","inherit","inherit"]};(0,wu.executeCommand)(Nu.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,u,D)})(),function(){const u=["install"],D={cwd:yu.join(Mu,Nu.WORK_SPACE),stdio:["inherit","inherit","inherit"]};(0,wu.executeCommand)(Nu.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,u,D)}(),(0,Su.logInfoPrintConsole)("Hvigor install success.")}()}catch(u){Vu()}}return Mu};var Gu={};!function(t){var C=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),F=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),E=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&C(D,u,e);return F(D,u),D},A=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(t,"__esModule",{value:!0}),t.executeInstallPnpm=t.isPnpmInstalled=t.environmentHandler=t.checkNpmConifg=t.PNPM_VERSION=void 0;const o=r,a=E(e),c=A(D),s=E(u),B=i,d=l,f=ou;t.PNPM_VERSION="7.30.0",t.checkNpmConifg=function(){const u=s.resolve(B.HVIGOR_PROJECT_ROOT_DIR,".npmrc"),D=s.resolve(c.default.homedir(),".npmrc");if((0,f.isFileExists)(u)||(0,f.isFileExists)(D))return;const e=(0,f.getNpmPath)(),t=(0,o.spawnSync)(e,["config","get","prefix"],{cwd:B.HVIGOR_PROJECT_ROOT_DIR});if(0!==t.status||!t.stdout)return void(0,d.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.");const r=s.resolve(`${t.stdout}`.replace(/[\r\n]/gi,""),".npmrc");(0,f.isFileExists)(r)||(0,d.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.")},t.environmentHandler=function(){process.env["npm_config_update-notifier"]="false"},t.isPnpmInstalled=function(){return!!a.existsSync(B.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH)&&(0,f.hasNpmPackInPaths)("pnpm",[B.HVIGOR_WRAPPER_TOOLS_HOME])},t.executeInstallPnpm=function(){(0,d.logInfoPrintConsole)(`Installing pnpm@${t.PNPM_VERSION}...`);const u=(0,f.getNpmPath)();!function(){const u=s.resolve(B.HVIGOR_WRAPPER_TOOLS_HOME,B.DEFAULT_PACKAGE_JSON);try{a.existsSync(B.HVIGOR_WRAPPER_TOOLS_HOME)||a.mkdirSync(B.HVIGOR_WRAPPER_TOOLS_HOME,{recursive:!0});const D={dependencies:{}};D.dependencies[B.PNPM]=t.PNPM_VERSION,a.writeFileSync(u,JSON.stringify(D))}catch(D){(0,d.logErrorAndExit)(`Error: EPERM: operation not permitted,create ${u} failed.`)}}(),(0,f.executeCommand)(u,["install","pnpm"],{cwd:B.HVIGOR_WRAPPER_TOOLS_HOME,stdio:["inherit","inherit","inherit"],env:process.env}),(0,d.logInfoPrintConsole)("Pnpm install success.")}}(Gu),function(){Gu.checkNpmConifg(),Gu.environmentHandler(),Gu.isPnpmInstalled()||Gu.executeInstallPnpm();const D=gu();_(u.join(D,i.WORK_SPACE))}(); \ No newline at end of file diff --git a/hvigorw b/hvigorw deleted file mode 100644 index 54aadd226b453397860013d328fd01031648fc31..0000000000000000000000000000000000000000 --- a/hvigorw +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -# ---------------------------------------------------------------------------- -# Hvigor startup script, version 1.0.0 -# -# Required ENV vars: -# ------------------ -# NODE_HOME - location of a Node home dir -# or -# Add /usr/local/nodejs/bin to the PATH environment variable -# ---------------------------------------------------------------------------- - -HVIGOR_APP_HOME=$(dirname $(readlink -f $0)) -HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js -warn() { - echo "" - echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" -} - -error() { - echo "" - echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" -} - -fail() { - error "$@" - exit 1 -} - -# Determine node to start hvigor wrapper script -if [ -n "${NODE_HOME}" ];then - EXECUTABLE_NODE="${NODE_HOME}/bin/node" - if [ ! -x "$EXECUTABLE_NODE" ];then - fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed" - fi -else - EXECUTABLE_NODE="node" - which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" -fi - -# Check hvigor wrapper script -if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then - fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" -fi - -# start hvigor-wrapper script -exec "${EXECUTABLE_NODE}" \ - "${HVIGOR_WRAPPER_SCRIPT}" "$@" diff --git a/hvigorw.bat b/hvigorw.bat deleted file mode 100644 index 29196b4d4e82f370133574d33636bdf9c7440a0b..0000000000000000000000000000000000000000 --- a/hvigorw.bat +++ /dev/null @@ -1,57 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Hvigor startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js -set NODE_EXE=node.exe - -goto start - -:start -@rem Find node.exe -if defined NODE_HOME goto findNodeFromNodeHome - -%NODE_EXE% --version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. -echo. -echo Please set the NODE_HOME variable in your environment to match the -echo location of your NodeJs installation. - -goto fail - -:findNodeFromNodeHome -set NODE_HOME=%NODE_HOME:"=% -set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE% - -if exist "%NODE_EXE_PATH%" goto execute -echo. -echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. -echo. -echo Please set the NODE_HOME variable in your environment to match the -echo location of your NodeJs installation. - -goto fail - -:execute -@rem Execute hvigor -"%NODE_EXE%" %WRAPPER_MODULE_PATH% %* - -:fail -exit /b 1 diff --git a/oh-package.json5 b/oh-package.json5 index 2440bfe1843d1d704a2eb844a4f5b3573cf03893..f9b51d65737e1df528354a25c546c097c21f10ef 100644 --- a/oh-package.json5 +++ b/oh-package.json5 @@ -1,4 +1,5 @@ { + "modelVersion": "5.0.2", "license": "ISC", "devDependencies": { "@ohos/hypium": "1.0.6" diff --git a/product/phone/build-profile.json5 b/product/phone/build-profile.json5 index 30e38e21058dba9e02bb1d87cd94d064cab120a0..6bdeb4627be6d0df3a79092fe8357777b552015a 100644 --- a/product/phone/build-profile.json5 +++ b/product/phone/build-profile.json5 @@ -16,7 +16,6 @@ { "apiType": 'stageMode', "buildOption": { - "compileMode": "esmodule" }, "targets": [ { diff --git a/product/phone/oh-package-lock.json5 b/product/phone/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..566fe6710f166e38255e6f4d8be6305627f8a895 --- /dev/null +++ b/product/phone/oh-package-lock.json5 @@ -0,0 +1,48 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/common@../../common": "@ohos/common@../../common", + "@ohos/multi@../../features/multi": "@ohos/multi@../../features/multi", + "@ohos/photo@../../features/photo": "@ohos/photo@../../features/photo", + "@ohos/video@../../features/video": "@ohos/video@../../features/video" + }, + "packages": { + "@ohos/common@../../common": { + "name": "@ohos/common", + "version": "1.0.0", + "resolved": "../../common", + "registryType": "local" + }, + "@ohos/multi@../../features/multi": { + "name": "@ohos/multi", + "version": "1.0.0", + "resolved": "../../features/multi", + "registryType": "local", + "dependencies": { + "@ohos/common": "../../common" + } + }, + "@ohos/photo@../../features/photo": { + "name": "@ohos/photo", + "version": "1.0.0", + "resolved": "../../features/photo", + "registryType": "local", + "dependencies": { + "@ohos/common": "../../common" + } + }, + "@ohos/video@../../features/video": { + "name": "@ohos/video", + "version": "1.0.0", + "resolved": "../../features/video", + "registryType": "local", + "dependencies": { + "@ohos/common": "../../common" + } + } + } +} \ No newline at end of file diff --git a/product/phone/src/main/ets/MainAbility/ExtensionPickerAbility.ts b/product/phone/src/main/ets/MainAbility/ExtensionPickerAbility.ts index 19dd63e0cd9bee27b270dc2b7b347ddf3655b33c..7d7583dfe15738ac3ed93360ed25c70b077b2179 100644 --- a/product/phone/src/main/ets/MainAbility/ExtensionPickerAbility.ts +++ b/product/phone/src/main/ets/MainAbility/ExtensionPickerAbility.ts @@ -23,7 +23,6 @@ import { GlobalContext } from '@ohos/common/src/main/ets/default/utils/GlobalCon import UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility'; import Want from '@ohos.app.ability.Want'; import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; -import hilog from '@ohos.hilog'; export default class ExtensionPickerAbility extends UIExtensionAbility { private cameraBasicFunction: any = null; diff --git a/product/phone/src/main/ets/MainAbility/MainAbility.ts b/product/phone/src/main/ets/MainAbility/MainAbility.ts index b308dff81e28b47de9017aeed6bb8d7c8640aef2..9685d0918dba48b8e05e5e43dd52fb9c3a65aa1c 100644 --- a/product/phone/src/main/ets/MainAbility/MainAbility.ts +++ b/product/phone/src/main/ets/MainAbility/MainAbility.ts @@ -95,14 +95,14 @@ export default class MainAbility extends Ability { }) if (this.launchWant?.action === wantConstant.Action.ACTION_IMAGE_CAPTURE || - this.launchWant?.parameters?.action === wantConstant.Action.ACTION_IMAGE_CAPTURE) { + this.launchWant?.parameters?.action === wantConstant.Action.ACTION_IMAGE_CAPTURE) { GlobalContext.get().setCameraFormParam({ action: 'capture', cameraPosition: 'PHOTO', mode: 'PHOTO' }); } else if (this.launchWant?.action === wantConstant.Action.ACTION_VIDEO_CAPTURE || - this.launchWant?.parameters?.action === wantConstant.Action.ACTION_VIDEO_CAPTURE) { + this.launchWant?.parameters?.action === wantConstant.Action.ACTION_VIDEO_CAPTURE) { GlobalContext.get().setCameraFormParam({ action: 'video', cameraPosition: 'VIDEO', diff --git a/product/phone/src/main/ets/common/ModeConfig.ts b/product/phone/src/main/ets/common/ModeConfig.ts index 02012a255affa9bff43d79caaf478b038c9167f5..ae6e62891668f1f7ab8481bbe1a3a2e7d17f9d4c 100644 --- a/product/phone/src/main/ets/common/ModeConfig.ts +++ b/product/phone/src/main/ets/common/ModeConfig.ts @@ -19,10 +19,10 @@ export class ModeConfig { public getPaddingConfig(mode: string): PaddingData { switch (mode) { - case 'PHOTO': - return this.photoPadding - case 'VIDEO': - return this.videoPadding + case 'PHOTO': + return this.photoPadding + case 'VIDEO': + return this.videoPadding } } } diff --git a/product/phone/src/main/ets/pages/BigVideoTimer.ets b/product/phone/src/main/ets/pages/BigVideoTimer.ets index cd98afc365a0ad2eaaa3bbf34e519c8c77929f4f..8b56df79aae1fe5da2782df275a2ed197e082a3a 100644 --- a/product/phone/src/main/ets/pages/BigVideoTimer.ets +++ b/product/phone/src/main/ets/pages/BigVideoTimer.ets @@ -17,8 +17,7 @@ import { Action } from '@ohos/common/src/main/ets/default/redux/actions/Action'; import { EventBus } from '@ohos/common/src/main/ets/default/worker/eventbus/EventBus'; import { EventBusManager } from '@ohos/common/src/main/ets/default/worker/eventbus/EventBusManager'; import { Log } from '@ohos/common/src/main/ets/default/utils/Log'; -import { Dispatch, OhCombinedState } from '@ohos/common/src/main/ets/default/redux/store'; -import { getStore } from '@ohos/common/src/main/ets/default/redux/store'; +import { Dispatch, getStore, OhCombinedState } from '@ohos/common/src/main/ets/default/redux/store'; import { GlobalContext } from '@ohos/common/src/main/ets/default/utils/GlobalContext'; class StateStruct { @@ -30,8 +29,6 @@ class StateStruct { } class BigVideoTimerDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -63,32 +60,20 @@ class BigVideoTimerDispatcher { this.mDispatch(Action.updateSmallVideoTimerVisible(false)) this.mDispatch(Action.updateScreenStatus(false)) } + + private mDispatch: Dispatch = (data) => data; } @Component export struct BigVideoTimer { + @State state: StateStruct = new StateStruct() private TAG: string = '[BigVideoTimer]' private timer: number = 0 private timerTick: number = 0 private appEventBus: EventBus = EventBusManager.getInstance().getEventBus() - @State state: StateStruct = new StateStruct() private mAction: BigVideoTimerDispatcher = new BigVideoTimerDispatcher(); - private async onRecordPaused(): Promise { - Log.info(`${this.TAG} onRecordPaused timer id: ${this.timer} E`) - clearInterval(this.timer) - Log.info(`${this.TAG} onRecordPaused X`) - } - - private async onRecordResumed(): Promise { - Log.info(`${this.TAG} onRecordResumed E`) - if (this.state.recordingTime <= 2) { - this.setIntervalTimer() - } - Log.info(`${this.TAG} onRecordResumed X`) - } - aboutToAppear(): void { Log.info(`${this.TAG} aboutToAppear E`) getStore().subscribe((state: OhCombinedState) => { @@ -118,48 +103,6 @@ export struct BigVideoTimer { Log.info(`${this.TAG} aboutToDisappear X`) } - private setIntervalTimer(): void { - clearInterval(this.timer) - this.timer = setInterval(() => { - this.timerTick++ - if (this.timerTick % 2 === 0) { - this.mAction.updateRecordingTime(this.state.recordingTime + 1) - let shownSec = '00' - let shownMin = '00' - let sec = this.state.recordingTime % 60 - if (sec < 10) { - shownSec = `0${sec}` - } else { - shownSec = `${sec}` - } - let minute = Math.floor(this.state.recordingTime / 60) - if (minute < 10) { - shownMin = `0${minute}` - } else { - shownMin = `${minute}` - } - this.mAction.updateRecordingTimeDisplay(`${shownMin}:${shownSec}`) - if (this.state.recordingTime > 2) { - clearInterval(this.timer) - this.mAction.updateSmallVideoTimerVisible(true) - this.mAction.updateBigVideoTimerVisible(false) - } - } - this.mAction.updateRecordingSpotVisible(!this.state.isRecordingSpotVisible) - if (this.state.isThirdPartyCall && GlobalContext.get().getCameraAbilityWant().parameters?.videoDuration) { - try { - let videoDuration: number = Number.parseInt(GlobalContext.get().getCameraAbilityWant().parameters?.videoDuration as string) - Log.info(`${this.TAG} videoDuration is ${videoDuration}`); - if (this.state.recordingTime >= videoDuration) { - this.mAction.stopRecording(); - } - } catch (error) { - Log.info(`${this.TAG} picker videoDuration --> ${JSON.stringify(error)}}`) - } - } - }, 500) - } - build() { Column() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { @@ -200,4 +143,61 @@ export struct BigVideoTimer { } }.width('100%').height(96).position({ x: 0, y: 0 }) } + + private async onRecordPaused(): Promise { + Log.info(`${this.TAG} onRecordPaused timer id: ${this.timer} E`) + clearInterval(this.timer) + Log.info(`${this.TAG} onRecordPaused X`) + } + + private async onRecordResumed(): Promise { + Log.info(`${this.TAG} onRecordResumed E`) + if (this.state.recordingTime <= 2) { + this.setIntervalTimer() + } + Log.info(`${this.TAG} onRecordResumed X`) + } + + private setIntervalTimer(): void { + clearInterval(this.timer) + this.timer = setInterval(() => { + this.timerTick++ + if (this.timerTick % 2 === 0) { + this.mAction.updateRecordingTime(this.state.recordingTime + 1) + let shownSec = '00' + let shownMin = '00' + let sec = this.state.recordingTime % 60 + if (sec < 10) { + shownSec = `0${sec}` + } else { + shownSec = `${sec}` + } + let minute = Math.floor(this.state.recordingTime / 60) + if (minute < 10) { + shownMin = `0${minute}` + } else { + shownMin = `${minute}` + } + this.mAction.updateRecordingTimeDisplay(`${shownMin}:${shownSec}`) + if (this.state.recordingTime > 2) { + clearInterval(this.timer) + this.mAction.updateSmallVideoTimerVisible(true) + this.mAction.updateBigVideoTimerVisible(false) + } + } + this.mAction.updateRecordingSpotVisible(!this.state.isRecordingSpotVisible) + if (this.state.isThirdPartyCall && GlobalContext.get().getCameraAbilityWant().parameters?.videoDuration) { + try { + let videoDuration: number = + Number.parseInt(GlobalContext.get().getCameraAbilityWant().parameters?.videoDuration as string) + Log.info(`${this.TAG} videoDuration is ${videoDuration}`); + if (this.state.recordingTime >= videoDuration) { + this.mAction.stopRecording(); + } + } catch (error) { + Log.info(`${this.TAG} picker videoDuration --> ${JSON.stringify(error)}}`) + } + } + }, 500) + } } \ No newline at end of file diff --git a/product/phone/src/main/ets/pages/Control.ets b/product/phone/src/main/ets/pages/Control.ets index f085b93839cd05a7042a4f6846f672732927540c..4e58934b5963acb36cc1aa3e07379f26b9648fdd 100644 --- a/product/phone/src/main/ets/pages/Control.ets +++ b/product/phone/src/main/ets/pages/Control.ets @@ -16,8 +16,7 @@ import { Action } from '@ohos/common/src/main/ets/default/redux/actions/Action'; import { EventBus } from '@ohos/common/src/main/ets/default/worker/eventbus/EventBus'; import { EventBusManager } from '@ohos/common/src/main/ets/default/worker/eventbus/EventBusManager'; -import { Dispatch, OhCombinedState } from '@ohos/common/src/main/ets/default/redux/store'; -import { getStore } from '@ohos/common/src/main/ets/default/redux/store'; +import { Dispatch, getStore, OhCombinedState } from '@ohos/common/src/main/ets/default/redux/store'; import { Log } from '@ohos/common/src/main/ets/default/utils/Log'; import { PersistType, @@ -36,8 +35,6 @@ class StateStruct { } class ControlDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -67,6 +64,8 @@ class ControlDispatcher { public updateListStatus(enable: boolean): void { this.mDispatch(Action.uiState(enable)); } + + private mDispatch: Dispatch = (data) => data; } class SwipeModeIndexStruct { @@ -76,17 +75,17 @@ class SwipeModeIndexStruct { @Component export struct Control { - private TAG: string = '[Control]'; appEventBus: EventBus = EventBusManager.getInstance().getEventBus(); - private scroller: Scroller = new Scroller(); - private modeArray: Array = ['PHOTO', 'VIDEO']; - private itemWidth: number = 56; - protected mPreferencesService: PreferencesService = PreferencesService.getInstance(); @State state: StateStruct = new StateStruct(); - private mAction: ControlDispatcher = new ControlDispatcher(); @State startScroll: number = 0; @State endScroll: number = 0; @State index: number = 0; + protected mPreferencesService: PreferencesService = PreferencesService.getInstance(); + private TAG: string = '[Control]'; + private scroller: Scroller = new Scroller(); + private modeArray: Array = ['PHOTO', 'VIDEO']; + private itemWidth: number = 56; + private mAction: ControlDispatcher = new ControlDispatcher(); aboutToAppear(): void { Log.info(`${this.TAG} aboutToAppear E`); @@ -115,36 +114,11 @@ export struct Control { Log.info(`${this.TAG} aboutToDisappear X`); } - private changeToMode(modeIndex: number): void { - Log.info(`${this.TAG} changeToMode modeIndex: ${modeIndex} E`); - this.scroller.scrollToIndex(modeIndex); - if (this.modeArray[modeIndex] !== this.state.mode) { - Log.info(`${this.TAG} this.state.changeToMode(${this.modeArray[modeIndex]})`); - this.mAction.changeToMode(this.modeArray[modeIndex]); - this.mPreferencesService.putModeValue(PersistType.FOR_AWHILE, modeIndex); - this.mPreferencesService.flushMode(); - } else { - this.mAction.updateListStatus(true); - } - Log.info(`${this.TAG} changeToMode X`); - } - - private getModeFontWeight(modeIndex: number): FontWeight { - if (this.state.mode === this.modeArray[modeIndex]) { - return FontWeight.Bold; - } else { - return FontWeight.Regular; - } - } - - private swipeChangeMode(data: SwipeModeIndexStruct): void { - this.changeToMode(data.swipeModeIndex); - } - build() { Column() { Stack({ alignContent: Alignment.BottomStart }) { - if ((this.state.isThirdPartyCall || this.state.isFaCall) && this.state.mode === 'PHOTO' && (this.state.thirdCallAction != 'ALL')) { + if ((this.state.isThirdPartyCall || this.state.isFaCall) && this.state.mode === 'PHOTO' && + (this.state.thirdCallAction != 'ALL')) { Row() { Text($r('app.string.photo_mode')) .width('100%') @@ -154,7 +128,8 @@ export struct Control { .fontWeight(FontWeight.Bold) .textAlign(TextAlign.Center) }.width('100%').height('100%').offset({ x: -156, y: 0 }) - } else if ((this.state.isThirdPartyCall || this.state.isFaCall) && this.state.mode === 'VIDEO' && (this.state.thirdCallAction != 'ALL')) { + } else if ((this.state.isThirdPartyCall || this.state.isFaCall) && this.state.mode === 'VIDEO' && + (this.state.thirdCallAction != 'ALL')) { Row() { Text($r('app.string.video_mode')) .width('100%') @@ -225,4 +200,30 @@ export struct Control { }.width('100%').height(58) } } + + private changeToMode(modeIndex: number): void { + Log.info(`${this.TAG} changeToMode modeIndex: ${modeIndex} E`); + this.scroller.scrollToIndex(modeIndex); + if (this.modeArray[modeIndex] !== this.state.mode) { + Log.info(`${this.TAG} this.state.changeToMode(${this.modeArray[modeIndex]})`); + this.mAction.changeToMode(this.modeArray[modeIndex]); + this.mPreferencesService.putModeValue(PersistType.FOR_AWHILE, modeIndex); + this.mPreferencesService.flushMode(); + } else { + this.mAction.updateListStatus(true); + } + Log.info(`${this.TAG} changeToMode X`); + } + + private getModeFontWeight(modeIndex: number): FontWeight { + if (this.state.mode === this.modeArray[modeIndex]) { + return FontWeight.Bold; + } else { + return FontWeight.Regular; + } + } + + private swipeChangeMode(data: SwipeModeIndexStruct): void { + this.changeToMode(data.swipeModeIndex); + } } \ No newline at end of file diff --git a/product/phone/src/main/ets/pages/FootBar.ets b/product/phone/src/main/ets/pages/FootBar.ets index 6ab237c2dc19b9697575f03c912fc74a13c49224..6eb6a8acd1e9b97e26b25abc6f069a5ca513f2c6 100644 --- a/product/phone/src/main/ets/pages/FootBar.ets +++ b/product/phone/src/main/ets/pages/FootBar.ets @@ -18,8 +18,7 @@ import { Action } from '@ohos/common/src/main/ets/default/redux/actions/Action'; import { CameraSwitchButton } from '@ohos/common/src/main/ets/default/featurecommon/cameraswitcher/CameraSwitchButton'; import { EventBus } from '@ohos/common/src/main/ets/default/worker/eventbus/EventBus'; import { EventBusManager } from '@ohos/common/src/main/ets/default/worker/eventbus/EventBusManager'; -import { Dispatch, OhCombinedState } from '@ohos/common/src/main/ets/default/redux/store'; -import { getStore } from '@ohos/common/src/main/ets/default/redux/store'; +import { Dispatch, getStore, OhCombinedState } from '@ohos/common/src/main/ets/default/redux/store'; import { Log } from '@ohos/common/src/main/ets/default/utils/Log'; import { ShutterButton } from '@ohos/common/src/main/ets/default/featurecommon/shutterbutton/ShutterButton'; import { ThumbnailView } from '@ohos/common/src/main/ets/default/featurecommon/thumbnail/ThumbnailView'; @@ -34,31 +33,21 @@ class StateStruct { } class FootBarDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } + + private mDispatch: Dispatch = (data) => data; } @Component export struct FootBar { - private TAG: string = '[FootBar]:'; @State state: StateStruct = new StateStruct(); @State isRecording: boolean = false; + private TAG: string = '[FootBar]:'; private appEventBus: EventBus = EventBusManager.getInstance().getEventBus(); private mAction: FootBarDispatcher = new FootBarDispatcher(); - private async onRecordStart(): Promise { - this.isRecording = true - Log.info(`${this.TAG} onRecordStart`) - } - - private async onRecordStop(): Promise { - this.isRecording = false - Log.info(`${this.TAG} onRecordStop`) - } - aboutToAppear(): void { Log.info(`${this.TAG} aboutToAppear E`) getStore().subscribe((state: OhCombinedState) => { @@ -85,20 +74,6 @@ export struct FootBar { Log.info(`${this.TAG} aboutToDisappear X`) } - private isThumbnailViewVisibility(): boolean { - return!this.isRecording && !this.state.isThirdPartyCall && - this.state.videoState !== "startTakeVideo" && this.state.videoState !== "pauseTakeVideo" - } - - private isPhoneSwitchShow(): boolean { - if (this.state.platformCapability) { - return deviceInfo.deviceType !== 'default' && this.state.platformCapability?.mCameraCount > 1 && - !this.isRecording - } else { - return false; - } - } - build() { Flex({ direction: FlexDirection.Row, @@ -125,4 +100,28 @@ export struct FootBar { .padding({ top: 10, bottom: 10 }) .visibility(this.state.showZoomLabelValue ? Visibility.Visible : Visibility.Hidden) } + + private async onRecordStart(): Promise { + this.isRecording = true + Log.info(`${this.TAG} onRecordStart`) + } + + private async onRecordStop(): Promise { + this.isRecording = false + Log.info(`${this.TAG} onRecordStop`) + } + + private isThumbnailViewVisibility(): boolean { + return !this.isRecording && !this.state.isThirdPartyCall && + this.state.videoState !== "startTakeVideo" && this.state.videoState !== "pauseTakeVideo" + } + + private isPhoneSwitchShow(): boolean { + if (this.state.platformCapability) { + return deviceInfo.deviceType !== 'default' && this.state.platformCapability?.mCameraCount > 1 && + !this.isRecording + } else { + return false; + } + } } \ No newline at end of file diff --git a/product/phone/src/main/ets/pages/PreviewArea.ets b/product/phone/src/main/ets/pages/PreviewArea.ets index 95bcc04e5a6e716ed74eab4d493d38a691d12ee0..225a87fa3aec943d806418888ec8859af861a5da 100644 --- a/product/phone/src/main/ets/pages/PreviewArea.ets +++ b/product/phone/src/main/ets/pages/PreviewArea.ets @@ -23,8 +23,7 @@ import { CameraNeedStatus, CameraStatus } from '@ohos/common/src/main/ets/defaul import { CameraId } from '@ohos/common/src/main/ets/default/setting/settingitem/CameraId'; import { EventBus } from '@ohos/common/src/main/ets/default/worker/eventbus/EventBus'; import { EventBusManager } from '@ohos/common/src/main/ets/default/worker/eventbus/EventBusManager'; -import { Dispatch, OhCombinedState } from '@ohos/common/src/main/ets/default/redux/store'; -import { getStore } from '@ohos/common/src/main/ets/default/redux/store'; +import { Dispatch, getStore, OhCombinedState } from '@ohos/common/src/main/ets/default/redux/store'; import { Log } from '@ohos/common/src/main/ets/default/utils/Log'; import { GeoLocation } from '@ohos/common/src/main/ets/default/featurecommon/geolocation/GeoLocation'; import { SettingManager } from '@ohos/common/src/main/ets/default/setting/SettingManager'; @@ -76,8 +75,6 @@ class StateStruct { } class PreviewAreaDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -233,6 +230,8 @@ class PreviewAreaDispatcher { public swipeModeChangeDone(actionOff: boolean): void { this.mDispatch(Action.swipeModeChangeDone(actionOff)); } + + private mDispatch: Dispatch = (data) => data; } class SizeStruct { @@ -254,7 +253,6 @@ class KeepScreenOnStruct { @Component export struct PreviewArea { - private TAG: string = '[PreviewArea]:'; appEventBus: EventBus = EventBusManager.getInstance().getEventBus(); @State state: StateStruct = new StateStruct(); @State mAspectRatio: number = 3 / 4; @@ -262,6 +260,7 @@ export struct PreviewArea { @State btnSwitchSec: boolean = false; @State isSwitchBackground: boolean = false; @State pageType: string = ''; + private TAG: string = '[PreviewArea]:'; private isShowPreview: boolean = false; private isForegroundInit: boolean = false; private settingManager = SettingManager.getInstance(); @@ -270,6 +269,251 @@ export struct PreviewArea { private modeArray: Array = ['PHOTO', 'VIDEO']; private mAction: PreviewAreaDispatcher = new PreviewAreaDispatcher(); + aboutToAppear(): void { + Log.info(`${this.TAG} PreviewArea aboutToAppear ${JSON.stringify(router.getParams())}`); + let routerParams = router.getParams(); + if (routerParams && routerParams.pageType) { + this.pageType = routerParams.pageType.toString(); + } + + getStore().subscribe((state: OhCombinedState) => { + let isShowBlur: boolean = !state.contextReducer.uiEnable && state.contextReducer.uiStateMode == UiStateMode.NONE; + this.state = { + mode: state.modeReducer.mode, + curMode: state.modeReducer.curMode, + isShowPreview: state.previewReducer.isShowPreview, + surfaceId: state.previewReducer.surfaceId, + xComponentWidth: state.previewReducer.xComponentWidth, + xComponentHeight: state.previewReducer.xComponentHeight, + cameraPosition: state.cameraReducer.cameraPosition, + curCameraPosition: state.cameraReducer.curCameraPosition, + minZoomRatio: state.zoomReducer.minZoomRatio, + maxZoomRatio: state.zoomReducer.maxZoomRatio, + zoomRatio: state.zoomReducer.zoomRatio, + platformCapability: state.cameraInitReducer.platformCapability, + videoState: state.recordReducer.videoState, + isShowZoomText: state.zoomReducer.isShowZoomText, + showZoomLabelValue: state.zoomReducer.showZoomLabelValue, + footBarHeight: state.contextReducer.footBarHeight, + isShowFlashBlack: state.previewReducer.isShowFlashBlack, + isShowBigText: state.modeReducer.isShowBigText, + isShowtimeLapse: state.settingReducer.isShowtimeLapse, + isBigVideoTimerVisible: state.recordReducer.isBigVideoTimerVisible, + isSmallVideoTimerVisible: state.recordReducer.isSmallVideoTimerVisible, + isAssGridViewShow: state.settingReducer.isAssGridViewShow, + modeIndex: state.modeReducer.modeIndex, + isThirdPartyCall: state.contextReducer.isThirdPartyCall, + modeChangeDone: state.modeReducer.modeChangeDone, + isShowPageView: state.settingReducer.isShowSettingView, + showBlur: isShowBlur, + isFaCall: state.contextReducer.isFaCall, + rotateAngle: 0, + rotateAngleSec: 0, + switchBackgroundOpacity: 1, + }; + }, (dispatch: Dispatch) => { + this.mAction.setDispatch(dispatch); + }); + this.state.platformCapability; + this.appEventBus.on(Action.ACTION_INIT_DONE, (data: CameraInitStruct) => this.onCameraInit(data)); + this.appEventBus.on(Action.ACTION_ON_MODE_CHANGED, (data: ModeStruct) => this.onModeChanged(data)); + this.appEventBus.on(Action.ACTION_KEEP_SCREEN_ON, (data: KeepScreenOnStruct) => this.onKeepScreen(data)); + this.appEventBus.on(Action.ACTION_RECORD_ERROR, () => this.onRecordError()); + this.appEventBus.on(Action.ACTION_UPDATE_CAMERA_STATUS, () => this.updateCameraStatus()); + GlobalContext.get().setObject('updateCameraStatus', () => { + Log.info(`${this.TAG} globalThis.updateCameraStatus called`); + this.updateCameraStatus(); + }); + this.calledByOther(); + this.mAction.initCamera(this.state.curCameraPosition, this.state.mode); + this.mAction.initZoomRatio(1, 6); //TODO 需要动态取得实际变焦能力范围 + Log.start(Log.X_COMPONENT_LIFE); + } + + aboutToDisappear(): void { + Log.info(`${this.TAG} previewAreaLand aboutToDisappear called`); + this.appEventBus.off(Action.ACTION_INIT_DONE, (data: CameraInitStruct) => this.onCameraInit(data)); + this.appEventBus.off(Action.ACTION_ON_MODE_CHANGED, (data: ModeStruct) => this.onModeChanged(data)); + this.appEventBus.off(Action.ACTION_UPDATE_CAMERA_STATUS, () => this.updateCameraStatus()); + GeoLocation.getInstance().off(); + GlobalContext.get().setObject('cameraNeedStatus', CameraNeedStatus.CAMERA_NEED_RELEASE); + this.updateCameraStatus(); + } + + onBackPress(): void { + Log.info(`${this.TAG} previewAreaLand onBackPress called`); + } + + onPageHide(): void { + this.mAction.startVideoFlag(false); + } + + build() { + Column() { + if (this.state.isShowPreview) { + Stack() { + XComponent({ + id: '', + type: 'surface', + libraryname: '', + controller: GlobalContext.get().getXComponentController() + }) + .onLoad(() => { + Log.end(Log.X_COMPONENT_LIFE); + Log.info(`${this.TAG} XComponent_onLoad `); + let surfaceId: number = GlobalContext.get().getXComponentController().getXComponentSurfaceId(); + this.mAction.prepareSurface(surfaceId); + this.doCameraAction(); + }) + .width(this.state.xComponentWidth) + .height(this.state.xComponentHeight) + .animation({ + duration: 100, + curve: Curve.Sharp, + delay: 0, + iterations: 1, + playMode: PlayMode.Normal + }) + + if (this.isSwitchBackground) { + Column() { + } + .width(this.state.xComponentWidth) + .height(this.state.xComponentHeight) + .backgroundColor('#000') + .opacity(this.state.switchBackgroundOpacity) + } + + if (this.state.showBlur) { + Column() + .width(this.state.xComponentWidth) + .height(this.state.xComponentHeight) + .backgroundColor(Color.Black) + .border({ width: { top: 0.5, bottom: 0.5 }, color: Color.Black }) + } + + if (this.btnSwitch) { + Image($r('app.media.whitePicture')) + .width(this.state.xComponentWidth) + .height(this.state.xComponentHeight) + .syncLoad(false) + .scale({ y: 1.0 }) + .rotate({ + x: 0, + y: 10, + z: 0, + angle: this.state.rotateAngle + })// .opacity(this.state.btnOpacity_first) + .onComplete(() => { + }) + } + + if (this.btnSwitchSec) { + Image($r('app.media.whitePicture')) + .width(this.state.xComponentWidth) + .height(this.state.xComponentHeight) + .syncLoad(false) + .scale({ y: 1.0 }) + .rotate({ + x: 0, + y: 10, + z: 0, + angle: this.state.rotateAngleSec + })// .opacity(this.state.btnOpacity_sec) + .onComplete(() => { + }) + } + + if (this.state.isShowFlashBlack) { + ShowFlashBlack(); + } + + if (this.state.isShowZoomText && deviceInfo.deviceType !== 'default' && !this.state.isShowtimeLapse) { + Stack({ alignContent: Alignment.Top }) { + ZoomText({ state: $state }) + } + .width('100%') + .height('96%') + } + + if (this.state.isShowBigText) { + Stack({ alignContent: Alignment.BottomStart }) { + BigText() + } + .width('100%') + .height('100%') + .padding({ bottom: '40vp' }) + } + + if (this.state.isAssGridViewShow === '1' && this.state.mode !== 'MORE') { + AssistiveGridView(); + } + + if (this.state.isSmallVideoTimerVisible) { + SmallVideoTimer(); + } + + if (this.state.isBigVideoTimerVisible) { + BigVideoTimer(); + } + + if (this.state.isShowtimeLapse) { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + TimeLapseView(); + }.width('100%').height(150) + } + } + } + .width('100%') + .height('100%') + } + } + .height('100%') + .width(this.state.xComponentWidth) + .aspectRatio(this.mAspectRatio) + .margin({ top: 0 }) + .backgroundColor('#000') + .gesture( + GestureGroup( + GestureMode.Exclusive, + TapGesture({ fingers: 1, count: 1 }) + .onAction(() => this.onPreviewClicked()), + PinchGesture({ fingers: 2, distance: 1 }) + .onActionStart((event) => { + if (event === undefined) { + return; + } + this.pinchGestureStart(event) + }) + .onActionUpdate((event) => { + if (event === undefined) { + return; + } + this.pinchGestureUpdate(event) + }) + .onActionEnd((event) => { + if (event === undefined) { + return; + } + this.pinchGestureEnd(event) + }), + PanGesture({ fingers: 1, direction: PanDirection.Left, distance: 10 }) + .onActionEnd(() => { + if (!this.state.isThirdPartyCall && !GlobalContext.get().getCameraAbilityWant()?.parameters?.from) { + this.swipeChangeMode(1); + } + }), + PanGesture({ fingers: 1, direction: PanDirection.Right, distance: 10 }) + .onActionEnd(() => { + if (!this.state.isThirdPartyCall && !GlobalContext.get().getCameraAbilityWant()?.parameters?.from) { + this.swipeChangeMode(-1); + } + }) + ) + ) + } + private async onCameraInit(data: CameraInitStruct): Promise { Log.info(`${this.TAG} EventBus onCameraInit isShowPreview = ${this.isShowPreview} platformCapability = ${this.state.platformCapability} E`); if (this.isForegroundInit === true) { @@ -351,77 +595,6 @@ export struct PreviewArea { Log.info(`${this.TAG} onRecordError invoke X`); } - aboutToAppear(): void { - Log.info(`${this.TAG} PreviewArea aboutToAppear ${JSON.stringify(router.getParams())}`); - let routerParams = router.getParams(); - if (routerParams && routerParams.pageType) { - this.pageType = routerParams.pageType.toString(); - } - - getStore().subscribe((state: OhCombinedState) => { - let isShowBlur: boolean = !state.contextReducer.uiEnable && state.contextReducer.uiStateMode == UiStateMode.NONE; - this.state = { - mode: state.modeReducer.mode, - curMode: state.modeReducer.curMode, - isShowPreview: state.previewReducer.isShowPreview, - surfaceId: state.previewReducer.surfaceId, - xComponentWidth: state.previewReducer.xComponentWidth, - xComponentHeight: state.previewReducer.xComponentHeight, - cameraPosition: state.cameraReducer.cameraPosition, - curCameraPosition: state.cameraReducer.curCameraPosition, - minZoomRatio: state.zoomReducer.minZoomRatio, - maxZoomRatio: state.zoomReducer.maxZoomRatio, - zoomRatio: state.zoomReducer.zoomRatio, - platformCapability: state.cameraInitReducer.platformCapability, - videoState: state.recordReducer.videoState, - isShowZoomText: state.zoomReducer.isShowZoomText, - showZoomLabelValue: state.zoomReducer.showZoomLabelValue, - footBarHeight: state.contextReducer.footBarHeight, - isShowFlashBlack: state.previewReducer.isShowFlashBlack, - isShowBigText: state.modeReducer.isShowBigText, - isShowtimeLapse: state.settingReducer.isShowtimeLapse, - isBigVideoTimerVisible: state.recordReducer.isBigVideoTimerVisible, - isSmallVideoTimerVisible: state.recordReducer.isSmallVideoTimerVisible, - isAssGridViewShow: state.settingReducer.isAssGridViewShow, - modeIndex: state.modeReducer.modeIndex, - isThirdPartyCall: state.contextReducer.isThirdPartyCall, - modeChangeDone: state.modeReducer.modeChangeDone, - isShowPageView: state.settingReducer.isShowSettingView, - showBlur: isShowBlur, - isFaCall: state.contextReducer.isFaCall, - rotateAngle: 0, - rotateAngleSec: 0, - switchBackgroundOpacity: 1, - }; - }, (dispatch: Dispatch) => { - this.mAction.setDispatch(dispatch); - }); - this.state.platformCapability; - this.appEventBus.on(Action.ACTION_INIT_DONE, (data: CameraInitStruct) => this.onCameraInit(data)); - this.appEventBus.on(Action.ACTION_ON_MODE_CHANGED, (data: ModeStruct) => this.onModeChanged(data)); - this.appEventBus.on(Action.ACTION_KEEP_SCREEN_ON, (data: KeepScreenOnStruct) => this.onKeepScreen(data)); - this.appEventBus.on(Action.ACTION_RECORD_ERROR, () => this.onRecordError()); - this.appEventBus.on(Action.ACTION_UPDATE_CAMERA_STATUS, () => this.updateCameraStatus()); - GlobalContext.get().setObject('updateCameraStatus', () => { - Log.info(`${this.TAG} globalThis.updateCameraStatus called`); - this.updateCameraStatus(); - }); - this.calledByOther(); - this.mAction.initCamera(this.state.curCameraPosition, this.state.mode); - this.mAction.initZoomRatio(1, 6); //TODO 需要动态取得实际变焦能力范围 - Log.start(Log.X_COMPONENT_LIFE); - } - - aboutToDisappear(): void { - Log.info(`${this.TAG} previewAreaLand aboutToDisappear called`); - this.appEventBus.off(Action.ACTION_INIT_DONE, (data: CameraInitStruct) => this.onCameraInit(data)); - this.appEventBus.off(Action.ACTION_ON_MODE_CHANGED, (data: ModeStruct) => this.onModeChanged(data)); - this.appEventBus.off(Action.ACTION_UPDATE_CAMERA_STATUS, () => this.updateCameraStatus()); - GeoLocation.getInstance().off(); - GlobalContext.get().setObject('cameraNeedStatus', CameraNeedStatus.CAMERA_NEED_RELEASE); - this.updateCameraStatus(); - } - private releaseCamera(): void { Log.info(`${this.TAG} globalThis.releaseCamera called`); GlobalContext.get().setObject('cameraNeedStatus', CameraNeedStatus.CAMERA_NO_NEED_TO_DO); @@ -499,7 +672,7 @@ export struct PreviewArea { case 'ALL': this.mAction.initMode(this.state.mode); this.mAction.updateModeIndex(this.state.modeIndex); - // private modeArray: Array = ['PHOTO', 'VIDEO']; //, 'MORE'this.modeArray[modeIndex] + // private modeArray: Array = ['PHOTO', 'VIDEO']; //, 'MORE'this.modeArray[modeIndex] break; default: Log.info(`${this.TAG} FA default`); @@ -533,14 +706,6 @@ export struct PreviewArea { GlobalContext.get().getT('cameraStatus') == CameraStatus.CAMERA_TAKE_VIDEO_FINISHED; } - onBackPress(): void { - Log.info(`${this.TAG} previewAreaLand onBackPress called`); - } - - onPageHide(): void { - this.mAction.startVideoFlag(false); - } - private pinchGestureStart(event: GestureEvent): void { Log.info(`${this.TAG} pinchGestureStart E`); if (this.state.mode != 'MULTI' && this.state.curCameraPosition !== 'FRONT') { @@ -593,7 +758,8 @@ export struct PreviewArea { private swipeChangeMode(swipe: number): void { Log.info(`${this.TAG} swipeChangeMode E`); - if (!this.state.modeChangeDone && this.state.modeIndex + swipe >= 0 && this.state.modeIndex + swipe <= this.modeArray.length - 1 && !this.state.isShowtimeLapse) { + if (!this.state.modeChangeDone && this.state.modeIndex + swipe >= 0 && + this.state.modeIndex + swipe <= this.modeArray.length - 1 && !this.state.isShowtimeLapse) { this.mAction.swipeChangeMode(this.state.modeIndex + swipe); this.mAction.swipeModeChangeDone(true); } @@ -615,154 +781,4 @@ export struct PreviewArea { } Log.info(`${this.TAG} onKeepScreen X`); } - - build() { - Column() { - if (this.state.isShowPreview) { - Stack() { - XComponent({ - id: '', - type: 'surface', - libraryname: '', - controller: GlobalContext.get().getXComponentController() - }) - .onLoad(() => { - Log.end(Log.X_COMPONENT_LIFE); - Log.info(`${this.TAG} XComponent_onLoad `); - let surfaceId: number = GlobalContext.get().getXComponentController().getXComponentSurfaceId(); - this.mAction.prepareSurface(surfaceId); - this.doCameraAction(); - }) - .width(this.state.xComponentWidth) - .height(this.state.xComponentHeight) - .animation({ - duration: 100, - curve: Curve.Sharp, - delay: 0, - iterations: 1, - playMode: PlayMode.Normal - }) - - if (this.isSwitchBackground) { - Column() { - } - .width(this.state.xComponentWidth) - .height(this.state.xComponentHeight) - .backgroundColor('#000') - .opacity(this.state.switchBackgroundOpacity) - } - - if (this.state.showBlur) { - Column() - .width(this.state.xComponentWidth) - .height(this.state.xComponentHeight) - .backgroundColor(Color.Black) - .border({ width: { top: 0.5, bottom: 0.5 }, color: Color.Black }) - } - - if (this.btnSwitch) { - Image($r('app.media.whitePicture')) - .width(this.state.xComponentWidth) - .height(this.state.xComponentHeight) - .syncLoad(false) - .scale({ y: 1.0 }) - .rotate({ x: 0, y: 10, z: 0, angle: this.state.rotateAngle })// .opacity(this.state.btnOpacity_first) - .onComplete(() => { - }) - } - - if (this.btnSwitchSec) { - Image($r('app.media.whitePicture')) - .width(this.state.xComponentWidth) - .height(this.state.xComponentHeight) - .syncLoad(false) - .scale({ y: 1.0 }) - .rotate({ x: 0, y: 10, z: 0, angle: this.state.rotateAngleSec })// .opacity(this.state.btnOpacity_sec) - .onComplete(() => { - }) - } - - if (this.state.isShowFlashBlack) { - ShowFlashBlack(); - } - - if (this.state.isShowZoomText && deviceInfo.deviceType !== "default" && !this.state.isShowtimeLapse) { - Stack({ alignContent: Alignment.Top }) { - ZoomText({ state: $state }) - } - .width('100%') - .height('96%') - } - - if (this.state.isShowBigText) { - Stack({ alignContent: Alignment.BottomStart }) { - BigText() - } - .width('100%') - .height('100%') - .padding({ bottom: '40vp' }) - } - - if (this.state.isAssGridViewShow === '1' && this.state.mode !== 'MORE') { - AssistiveGridView(); - } - - if (this.state.isSmallVideoTimerVisible) { - SmallVideoTimer(); - } - - if (this.state.isBigVideoTimerVisible) { - BigVideoTimer(); - } - - if (this.state.isShowtimeLapse) { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Column() { - TimeLapseView(); - }.width('100%').height(150) - } - } - } - .width('100%') - .height('100%') - } - } - .height('100%') - .width(this.state.xComponentWidth) - .aspectRatio(this.mAspectRatio) - .margin({ top: 0 }) - .backgroundColor('#000') - .gesture( - GestureGroup( - GestureMode.Exclusive, - TapGesture({ fingers: 1, count: 1 }) - .onAction(() => this.onPreviewClicked()), - PinchGesture({ fingers: 2, distance: 1 }) - .onActionStart((event) => { - if (event === undefined) return; - this.pinchGestureStart(event) - }) - .onActionUpdate((event) => { - if (event === undefined) return; - this.pinchGestureUpdate(event) - }) - .onActionEnd((event) => { - if (event === undefined) return; - this.pinchGestureEnd(event) - }), - PanGesture({ fingers: 1, direction: PanDirection.Left, distance: 10 }) - .onActionEnd(() => { - if (!this.state.isThirdPartyCall && !GlobalContext.get().getCameraAbilityWant()?.parameters?.from) { - this.swipeChangeMode(1); - } - }), - PanGesture({ fingers: 1, direction: PanDirection.Right, distance: 10 }) - .onActionEnd(() => { - if (!this.state.isThirdPartyCall && !GlobalContext.get().getCameraAbilityWant()?.parameters?.from) { - this.swipeChangeMode(-1); - } - }) - ) - ) - } } \ No newline at end of file diff --git a/product/phone/src/main/ets/pages/SettingView.ets b/product/phone/src/main/ets/pages/SettingView.ets index 7ac602ca3c07f0fb850e1531d88fff8c744e61ca..310d2a44e578ccae979b217a0fb6079e6266b3bc 100644 --- a/product/phone/src/main/ets/pages/SettingView.ets +++ b/product/phone/src/main/ets/pages/SettingView.ets @@ -16,8 +16,7 @@ import deviceInfo from '@ohos.deviceInfo'; import { Action } from '@ohos/common/src/main/ets/default/redux/actions/Action'; import { EventBusManager } from '@ohos/common/src/main/ets/default/worker/eventbus/EventBusManager'; -import { Dispatch, OhCombinedState } from '@ohos/common/src/main/ets/default/redux/store'; -import { getStore } from '@ohos/common/src/main/ets/default/redux/store'; +import { Dispatch, getStore, OhCombinedState } from '@ohos/common/src/main/ets/default/redux/store'; import { Log } from '@ohos/common/src/main/ets/default/utils/Log'; import { SettingManager } from '@ohos/common/src/main/ets/default/setting/SettingManager'; import { SettingItem } from '@ohos/common/src/main/ets/default/featurecommon/settingview/phone/SettingItem'; @@ -31,8 +30,6 @@ class StateStruct { } class SettingViewDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -56,6 +53,8 @@ class SettingViewDispatcher { public reStartPreview(zoomRatio: number): void { this.mDispatch(Action.reStartPreview(zoomRatio)); } + + private mDispatch: Dispatch = (data) => data; } class SizeStruct { @@ -65,14 +64,14 @@ class SizeStruct { @Component export struct SettingView { - private TAG: string = '[SettingView]:' - private settingManager = SettingManager.getInstance() @State checkNameList: Array = ['4:3', '[16:9] 720p'] @State closeFlag: boolean = false @State tempGutter: number = 12; //列间距 @State tempMargin: number = 12; //两侧间距 @State settingsList: SettingGroupItem[] = new SettingListModel().getSettingList() @State state: StateStruct = new StateStruct() + private TAG: string = '[SettingView]:' + private settingManager = SettingManager.getInstance() private mEventBus = EventBusManager.getInstance().getEventBus() private WH_100_100: string = "100%"; private mAction: SettingViewDispatcher = new SettingViewDispatcher(); @@ -111,24 +110,6 @@ export struct SettingView { return true; } - private aspectRatioChange(xComponentSize: SizeStruct): void { - if (this.state.mode != 'VIDEO') { - this.mAction.changeXComponentSize(xComponentSize.width, xComponentSize.height) - this.mAction.reStartPreview(this.state.zoomRatio) - } - } - - private resolutionChange(xComponentSize: SizeStruct): void { - if (this.state.mode == 'VIDEO') { - this.mAction.changeXComponentSize(xComponentSize.width, xComponentSize.height) - this.mAction.reStartPreview(this.state.zoomRatio) - } - } - - private assistiveGridChange(mAssistiveGrid: number): void { - this.mAction.assistiveGridView(mAssistiveGrid) - } - build() { Flex({ direction: FlexDirection.Column }) { Row() { @@ -194,4 +175,22 @@ export struct SettingView { .height(this.WH_100_100) .backgroundColor(Color.Black) } + + private aspectRatioChange(xComponentSize: SizeStruct): void { + if (this.state.mode != 'VIDEO') { + this.mAction.changeXComponentSize(xComponentSize.width, xComponentSize.height) + this.mAction.reStartPreview(this.state.zoomRatio) + } + } + + private resolutionChange(xComponentSize: SizeStruct): void { + if (this.state.mode == 'VIDEO') { + this.mAction.changeXComponentSize(xComponentSize.width, xComponentSize.height) + this.mAction.reStartPreview(this.state.zoomRatio) + } + } + + private assistiveGridChange(mAssistiveGrid: number): void { + this.mAction.assistiveGridView(mAssistiveGrid) + } } \ No newline at end of file diff --git a/product/phone/src/main/ets/pages/SmallVideoTimer.ets b/product/phone/src/main/ets/pages/SmallVideoTimer.ets index 1ff15cfdf664c89b1823a1c6a98533880ea1d9f8..f3a765dc34b5b742f8e26b2aa440b3e32fe4fad4 100644 --- a/product/phone/src/main/ets/pages/SmallVideoTimer.ets +++ b/product/phone/src/main/ets/pages/SmallVideoTimer.ets @@ -16,8 +16,7 @@ import { Action } from '@ohos/common/src/main/ets/default/redux/actions/Action'; import { EventBus } from '@ohos/common/src/main/ets/default/worker/eventbus/EventBus'; import { EventBusManager } from '@ohos/common/src/main/ets/default/worker/eventbus/EventBusManager'; -import { Dispatch, OhCombinedState } from '@ohos/common/src/main/ets/default/redux/store'; -import { getStore } from '@ohos/common/src/main/ets/default/redux/store'; +import { Dispatch, getStore, OhCombinedState } from '@ohos/common/src/main/ets/default/redux/store'; import { Log } from '@ohos/common/src/main/ets/default/utils/Log'; import { GlobalContext } from '@ohos/common/src/main/ets/default/utils/GlobalContext'; @@ -30,8 +29,6 @@ class StateStruct { } class SmallVideoTimerDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -55,29 +52,19 @@ class SmallVideoTimerDispatcher { this.mDispatch(Action.updateSmallVideoTimerVisible(false)) this.mDispatch(Action.updateScreenStatus(false)) } + + private mDispatch: Dispatch = (data) => data; } @Component export struct SmallVideoTimer { + @State state: StateStruct = new StateStruct() private TAG: string = '[SmallVideoTimer]' private timer: number = 0 private timerTick: number = 0 private appEventBus: EventBus = EventBusManager.getInstance().getEventBus() - @State state: StateStruct = new StateStruct() private mAction: SmallVideoTimerDispatcher = new SmallVideoTimerDispatcher(); - private async onRecordPaused(): Promise { - Log.info(`${this.TAG} onRecordPaused timer id: ${this.timer} E`) - clearInterval(this.timer) - Log.info(`${this.TAG} onRecordPaused X`) - } - - private async onRecordResumed(): Promise { - Log.info(`${this.TAG} onRecordResumed E`) - this.setIntervalTimer() - Log.info(`${this.TAG} onRecordResumed timer id: ${this.timer} X`) - } - aboutToAppear(): void { Log.info(`${this.TAG} aboutToAppear E`) getStore().subscribe((state: OhCombinedState) => { @@ -105,43 +92,6 @@ export struct SmallVideoTimer { Log.info(`${this.TAG} aboutToDisappear X`) } - private setIntervalTimer(): void { - clearInterval(this.timer) - this.timer = setInterval(() => { - this.timerTick++ - if (this.timerTick % 2 === 0) { - this.mAction.updateRecordingTime(this.state.recordingTime + 1) - let shownSec = '00' - let shownMin = '00' - let sec = this.state.recordingTime % 60 - if (sec < 10) { - shownSec = `0${sec}` - } else { - shownSec = `${sec}` - } - let minute = Math.floor(this.state.recordingTime / 60) - if (minute < 10) { - shownMin = `0${minute}` - } else { - shownMin = `${minute}` - } - this.mAction.updateRecordingTimeDisplay(`${shownMin}:${shownSec}`) - } - this.mAction.updateSpotVisible(!this.state.isRecordingSpotVisible) - if (this.state.isThirdPartyCall && GlobalContext.get().getCameraAbilityWant().parameters?.videoDuration) { - try { - let videoDuration: number = Number.parseInt(GlobalContext.get().getCameraAbilityWant().parameters?.videoDuration as string) - Log.info(`${this.TAG} videoDuration is ${videoDuration}`); - if (this.state.recordingTime >= videoDuration) { - this.mAction.stopRecording(); - } - } catch (error) { - Log.info(`${this.TAG} picker videoDuration --> ${JSON.stringify(error)}}`) - } - } - }, 500) - } - build() { Column() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { @@ -182,4 +132,54 @@ export struct SmallVideoTimer { } }.width('100%').height(48).position({ x: 0, y: -48 }) } + + private async onRecordPaused(): Promise { + Log.info(`${this.TAG} onRecordPaused timer id: ${this.timer} E`) + clearInterval(this.timer) + Log.info(`${this.TAG} onRecordPaused X`) + } + + private async onRecordResumed(): Promise { + Log.info(`${this.TAG} onRecordResumed E`) + this.setIntervalTimer() + Log.info(`${this.TAG} onRecordResumed timer id: ${this.timer} X`) + } + + private setIntervalTimer(): void { + clearInterval(this.timer) + this.timer = setInterval(() => { + this.timerTick++ + if (this.timerTick % 2 === 0) { + this.mAction.updateRecordingTime(this.state.recordingTime + 1) + let shownSec = '00' + let shownMin = '00' + let sec = this.state.recordingTime % 60 + if (sec < 10) { + shownSec = `0${sec}` + } else { + shownSec = `${sec}` + } + let minute = Math.floor(this.state.recordingTime / 60) + if (minute < 10) { + shownMin = `0${minute}` + } else { + shownMin = `${minute}` + } + this.mAction.updateRecordingTimeDisplay(`${shownMin}:${shownSec}`) + } + this.mAction.updateSpotVisible(!this.state.isRecordingSpotVisible) + if (this.state.isThirdPartyCall && GlobalContext.get().getCameraAbilityWant().parameters?.videoDuration) { + try { + let videoDuration: number = + Number.parseInt(GlobalContext.get().getCameraAbilityWant().parameters?.videoDuration as string) + Log.info(`${this.TAG} videoDuration is ${videoDuration}`); + if (this.state.recordingTime >= videoDuration) { + this.mAction.stopRecording(); + } + } catch (error) { + Log.info(`${this.TAG} picker videoDuration --> ${JSON.stringify(error)}}`) + } + } + }, 500) + } } \ No newline at end of file diff --git a/product/phone/src/main/ets/pages/ThirdPreviewView.ets b/product/phone/src/main/ets/pages/ThirdPreviewView.ets index 4231636d82995df849496f990bb70a064de729f9..6e96ea0d6e9187ef2b5541b370abf21f37d255fe 100644 --- a/product/phone/src/main/ets/pages/ThirdPreviewView.ets +++ b/product/phone/src/main/ets/pages/ThirdPreviewView.ets @@ -25,6 +25,9 @@ import { ComponentIdKeys } from '@ohos/common/src/main/ets/default/utils/Compone @Entry @Component struct ThirdPreviewView { + @State controls: boolean = false; + @State isShowVideoButton: boolean = true; + myVideoController: VideoController = new VideoController(); private TAG: string = '[ThirdPreviewView]:'; private photoWidth: string = ''; private photoHeight: string = ''; @@ -32,9 +35,6 @@ struct ThirdPreviewView { private videoUri: string = ''; private mode: string = ''; private callBundleName: string = ''; - @State controls: boolean = false; - @State isShowVideoButton: boolean = true; - myVideoController: VideoController = new VideoController(); aboutToAppear() { Log.info(`${this.TAG} aboutToAppear E`); @@ -75,7 +75,7 @@ struct ThirdPreviewView { Log.info(`${this.TAG} backCalledApp X`); } - terminateSelfWithResult(resourceUri: string, resultCode : number): void { + terminateSelfWithResult(resourceUri: string, resultCode: number): void { Log.info(`${this.TAG} terminateSelfWithResult start`); let abilityResult: ability.AbilityResult = { resultCode: resultCode, @@ -107,18 +107,6 @@ struct ThirdPreviewView { } - private getVideoPlayIcon() { - if (vp2px(1) >= 1 && vp2px(1) < 2) { - return $r('app.media.ic_video_play_btn_hdpi'); - } else if (vp2px(1) == 2) { - return $r('app.media.ic_video_play_btn_xhdpi'); - } else if (vp2px(1) == 3) { - return $r('app.media.ic_video_play_btn_xxhdpi'); - } else { - return $r('app.media.ic_video_play_btn_xxxhdpi'); - } - } - build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Stack() { @@ -194,4 +182,16 @@ struct ThirdPreviewView { .position({ x: 0, y: 0 }) }.width('100%').height('100%').backgroundColor('#000') } + + private getVideoPlayIcon() { + if (vp2px(1) >= 1 && vp2px(1) < 2) { + return $r('app.media.ic_video_play_btn_hdpi'); + } else if (vp2px(1) == 2) { + return $r('app.media.ic_video_play_btn_xhdpi'); + } else if (vp2px(1) == 3) { + return $r('app.media.ic_video_play_btn_xxhdpi'); + } else { + return $r('app.media.ic_video_play_btn_xxxhdpi'); + } + } } \ No newline at end of file diff --git a/product/phone/src/main/ets/pages/index.ets b/product/phone/src/main/ets/pages/index.ets index ab605c8c7f914b967a11b61daadfd8e5def20930..2372feef84b54094f2cf420245664ee91e49061f 100644 --- a/product/phone/src/main/ets/pages/index.ets +++ b/product/phone/src/main/ets/pages/index.ets @@ -20,8 +20,7 @@ import { Action } from '@ohos/common/src/main/ets/default/redux/actions/Action'; import { CameraWorker } from '@ohos/common/src/main/ets/default/worker/CameraWorker'; import { EventBus } from '@ohos/common/src/main/ets/default/worker/eventbus/EventBus'; import { EventBusManager } from '@ohos/common/src/main/ets/default/worker/eventbus/EventBusManager'; -import { Dispatch, OhCombinedState } from '@ohos/common/src/main/ets/default/redux/store'; -import { getStore } from '@ohos/common/src/main/ets/default/redux/store'; +import { Dispatch, getStore, OhCombinedState } from '@ohos/common/src/main/ets/default/redux/store'; import { Log } from '@ohos/common/src/main/ets/default/utils/Log'; import { MoreList } from '@ohos/common/src/main/ets/default/featurecommon/moreList/moreList'; import { @@ -62,8 +61,6 @@ class StateStruct { } class IndexDispatcher { - private mDispatch: Dispatch = (data) => data; - public setDispatch(dispatch: Dispatch) { this.mDispatch = dispatch; } @@ -116,6 +113,8 @@ class IndexDispatcher { public faCall(isFaCall: boolean): void { this.mDispatch(Action.faCall(isFaCall)); } + + private mDispatch: Dispatch = (data) => data; } const ZOOM_HEIGHT = 140; @@ -179,24 +178,25 @@ struct Index { Log.info(`${this.TAG} permissions need to require from user: ${JSON.stringify(permissionList)}`); let atManager = abilityAccessCtrl.createAtManager(); try { - atManager.requestPermissionsFromUser(GlobalContext.get().getCameraAbilityContext(), permissionList).then((data) => { - Log.info(`${this.TAG} data permissions: ${JSON.stringify(data.permissions)}`); - Log.info(`${this.TAG} data authResult: ${JSON.stringify(data.authResults)}`); - let sum = 0 - for (let i = 0; i < data.authResults.length; i++) { - sum += data.authResults[i]; - } - if (sum >= 0) { - GlobalContext.get().setObject('permissionFlag', true); - this.mAction.setPermissionFlag(true); - } else { - GlobalContext.get().setObject('permissionFlag', false); - this.mAction.setPermissionFlag(false); - } - Log.info(`${this.TAG} request permissions result: ${GlobalContext.get().getT('permissionFlag')}`); - }, (err: BusinessError) => { - Log.error(`${this.TAG} Failed to start ability err code: ${err.code}`); - }) + atManager.requestPermissionsFromUser(GlobalContext.get().getCameraAbilityContext(), permissionList) + .then((data) => { + Log.info(`${this.TAG} data permissions: ${JSON.stringify(data.permissions)}`); + Log.info(`${this.TAG} data authResult: ${JSON.stringify(data.authResults)}`); + let sum = 0 + for (let i = 0; i < data.authResults.length; i++) { + sum += data.authResults[i]; + } + if (sum >= 0) { + GlobalContext.get().setObject('permissionFlag', true); + this.mAction.setPermissionFlag(true); + } else { + GlobalContext.get().setObject('permissionFlag', false); + this.mAction.setPermissionFlag(false); + } + Log.info(`${this.TAG} request permissions result: ${GlobalContext.get().getT('permissionFlag')}`); + }, (err: BusinessError) => { + Log.error(`${this.TAG} Failed to start ability err code: ${err.code}`); + }) } catch (error) { Log.info(`${this.TAG} catch error: ${JSON.stringify(error)}`); } @@ -223,10 +223,13 @@ struct Index { } onPageShow(): void { - Log.info(`${this.TAG} onPageShow this.permissionFlag: ${this.state.permissionFlag} permissionFlag: ${GlobalContext.get().getT('permissionFlag')}`); + Log.info(`${this.TAG} onPageShow this.permissionFlag: ${this.state.permissionFlag} permissionFlag: ${GlobalContext.get() + .getT('permissionFlag')}`); this.mAction.setPermissionFlag(GlobalContext.get().getT('permissionFlag')); let curCameraId = AppStorage.Get('storageCameraId'); - if (curCameraId) this.mAction.initCameraPosition(curCameraId); + if (curCameraId) { + this.mAction.initCameraPosition(curCameraId); + } this.mAction.resetRecordingTime(); Log.info(`${this.TAG} onPageShow X`); } @@ -313,7 +316,8 @@ struct Index { }.width('100%').position({ y: 48 }) Stack() { - if (deviceInfo.deviceType !== "default" && this.state.videoState === "beforeTakeVideo" && !this.state.isShowtimeLapse && this.state.showZoomLabelValue) { + if (deviceInfo.deviceType !== "default" && this.state.videoState === "beforeTakeVideo" && + !this.state.isShowtimeLapse && this.state.showZoomLabelValue) { TabBar({ onBackClicked: () => this.onBackClicked() }); } }.width('100%').height(48).position({ x: '0', y: '0' }) @@ -328,14 +332,16 @@ struct Index { Column() { ZoomView() } - .visibility(!this.state.isShowtimeLapse && !this.state.isShowPinch ? Visibility.Visible : Visibility.Hidden) + .visibility(!this.state.isShowtimeLapse && !this.state.isShowPinch ? Visibility.Visible : + Visibility.Hidden) } } if (this.state.videoState === "beforeTakeVideo" && this.state.showZoomLabelValue) { Column() { Control() } - .visibility((!this.state.isShowtimeLapse && this.state.showZoomLabelValue) ? Visibility.Visible : Visibility.Hidden) + .visibility((!this.state.isShowtimeLapse && this.state.showZoomLabelValue) ? Visibility.Visible : + Visibility.Hidden) .width('100%') .offset({ x: 156, y: 0 @@ -344,7 +350,8 @@ struct Index { Column() { FootBar() } - .visibility((!this.state.isShowtimeLapse && this.state.showZoomLabelValue) ? Visibility.Visible : Visibility.Hidden) + .visibility((!this.state.isShowtimeLapse && this.state.showZoomLabelValue) ? Visibility.Visible : + Visibility.Hidden) } }.width('100%').height(302 - ZOOM_HEIGHT).position({ y: this.state.footBarHeight + ZOOM_HEIGHT }) .visibility(!this.state.isShowtimeLapse ? Visibility.Visible : Visibility.Hidden) diff --git a/product/phone/src/main/module.json5 b/product/phone/src/main/module.json5 index ac935dd8ee0750a4df4dfe134d755bf9532e437d..6610df636e2c5ce8ba58a980aeb80c81777b905d 100644 --- a/product/phone/src/main/module.json5 +++ b/product/phone/src/main/module.json5 @@ -34,7 +34,13 @@ ], "requestPermissions": [ { - "name": "ohos.permission.MEDIA_LOCATION" + "name": "ohos.permission.MEDIA_LOCATION", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { "name": "ohos.permission.INTERNET" @@ -43,31 +49,79 @@ "name": "ohos.permission.MODIFY_AUDIO_SETTINGS" }, { - "name": "ohos.permission.READ_IMAGEVIDEO" + "name": "ohos.permission.READ_IMAGEVIDEO", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { - "name": "ohos.permission.WRITE_IMAGEVIDEO" + "name": "ohos.permission.WRITE_IMAGEVIDEO", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { "name": "ohos.permission.GET_BUNDLE_INFO" }, { - "name": "ohos.permission.CAMERA" + "name": "ohos.permission.CAMERA", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { - "name": "ohos.permission.MICROPHONE" + "name": "ohos.permission.MICROPHONE", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { - "name": "ohos.permission.DISTRIBUTED_DATASYNC" + "name": "ohos.permission.DISTRIBUTED_DATASYNC", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { - "name": "ohos.permission.LOCATION" + "name": "ohos.permission.LOCATION", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { - "name": "ohos.permission.LOCATION_IN_BACKGROUND" + "name": "ohos.permission.LOCATION_IN_BACKGROUND", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { - "name": "ohos.permission.APPROXIMATELY_LOCATION" + "name": "ohos.permission.APPROXIMATELY_LOCATION", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { "name": "ohos.permission.ACCESS_SERVICE_DM" @@ -79,7 +133,7 @@ "abilities": [ { "name": "com.ohos.camera.MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "srcEntry": "./ets/MainAbility/MainAbility.ts", "startWindowIcon": "$media:icon", "startWindowBackground": "$color:startWindowBackground", "launchType": "singleton", @@ -117,7 +171,7 @@ "extensionAbilities": [ { "name": "com.ohos.camera.FormAbility", - "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "srcEntry": "./ets/FormAbility/FormAbility.ts", "label": "$string:app_name", "description": "$string:app_name", "type": "form", @@ -130,7 +184,7 @@ }, { "name": "com.ohos.camera.ExtensionPickerAbility", - "srcEntrance": "./ets/MainAbility/ExtensionPickerAbility.ts", + "srcEntry": "./ets/MainAbility/ExtensionPickerAbility.ts", "label": "$string:app_name", "description": "ExtensionPickerAbility", "visible": true, diff --git a/product/phone/src/main/resources/base/profile/form_config.json b/product/phone/src/main/resources/base/profile/form_config.json index 7976a4825a6ca97ca3f6033a1dd726734f54d1ff..bf4c53de1857f753e48cb8b15b242991aa83bbc9 100644 --- a/product/phone/src/main/resources/base/profile/form_config.json +++ b/product/phone/src/main/resources/base/profile/form_config.json @@ -2,6 +2,7 @@ "forms": [ { "name": "widget", + "displayName": "This is a service widget.", "description": "This is a service widget.", "src": "./js/widget/pages/index/index", "window": { diff --git a/product/phone/src/ohosTest/module.json5 b/product/phone/src/ohosTest/module.json5 index 21ef32d318946005693092dc10136cb01b8c908a..0fcc2e4962a8a1d91b9979fa41ddb6a88d154036 100644 --- a/product/phone/src/ohosTest/module.json5 +++ b/product/phone/src/ohosTest/module.json5 @@ -17,7 +17,7 @@ "module": { "name": "entry_test", "type": "feature", - "srcEntrance": "./ets/TestAbility/TestAbility.ts", + "srcEntry": "./ets/TestAbility/TestAbility.ts", "description": "$string:entry_test_desc", "mainElement": "TestAbility", "deviceTypes": [ @@ -31,7 +31,7 @@ "abilities": [ { "name": "TestAbility", - "srcEntrance": "./ets/TestAbility/TestAbility.ts", + "srcEntry": "./ets/TestAbility/TestAbility.ts", "description": "$string:TestAbility_desc", "icon": "$media:icon", "label": "$string:TestAbility_label", diff --git a/product/tablet/build-profile.json5 b/product/tablet/build-profile.json5 index 30e38e21058dba9e02bb1d87cd94d064cab120a0..6bdeb4627be6d0df3a79092fe8357777b552015a 100644 --- a/product/tablet/build-profile.json5 +++ b/product/tablet/build-profile.json5 @@ -16,7 +16,6 @@ { "apiType": 'stageMode', "buildOption": { - "compileMode": "esmodule" }, "targets": [ { diff --git a/product/tablet/oh-package-lock.json5 b/product/tablet/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..566fe6710f166e38255e6f4d8be6305627f8a895 --- /dev/null +++ b/product/tablet/oh-package-lock.json5 @@ -0,0 +1,48 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/common@../../common": "@ohos/common@../../common", + "@ohos/multi@../../features/multi": "@ohos/multi@../../features/multi", + "@ohos/photo@../../features/photo": "@ohos/photo@../../features/photo", + "@ohos/video@../../features/video": "@ohos/video@../../features/video" + }, + "packages": { + "@ohos/common@../../common": { + "name": "@ohos/common", + "version": "1.0.0", + "resolved": "../../common", + "registryType": "local" + }, + "@ohos/multi@../../features/multi": { + "name": "@ohos/multi", + "version": "1.0.0", + "resolved": "../../features/multi", + "registryType": "local", + "dependencies": { + "@ohos/common": "../../common" + } + }, + "@ohos/photo@../../features/photo": { + "name": "@ohos/photo", + "version": "1.0.0", + "resolved": "../../features/photo", + "registryType": "local", + "dependencies": { + "@ohos/common": "../../common" + } + }, + "@ohos/video@../../features/video": { + "name": "@ohos/video", + "version": "1.0.0", + "resolved": "../../features/video", + "registryType": "local", + "dependencies": { + "@ohos/common": "../../common" + } + } + } +} \ No newline at end of file diff --git a/product/tablet/src/main/ets/pages/PreviewAreaLand.ets b/product/tablet/src/main/ets/pages/PreviewAreaLand.ets index 473468911fc4a1e3782fc1083122d51fc8d86e73..586218e7834f75967bd58588cd5a3b0e469cd845 100644 --- a/product/tablet/src/main/ets/pages/PreviewAreaLand.ets +++ b/product/tablet/src/main/ets/pages/PreviewAreaLand.ets @@ -15,25 +15,24 @@ import router from '@system.router'; import display from '@ohos.display'; -import deviceInfo from '@ohos.deviceInfo' -import { BigVideoTimer } from './BigVideoTimer' -import { Action, UiStateMode } from '@ohos/common/src/main/ets/default/redux/actions/Action' -import { AssistiveGridView } from '@ohos/common/src/main/ets/default/featurecommon/assistivegridview/AssistiveGridView' -import { BigText } from '@ohos/common/src/main/ets/default/featurecommon/bigtext/BigText' -import { CameraNeedStatus, CameraStatus } from '@ohos/common/src/main/ets/default/utils/Constants' -import { CameraId } from '@ohos/common/src/main/ets/default/setting/settingitem/CameraId' -import { EventBus } from '@ohos/common/src/main/ets/default/worker/eventbus/EventBus' -import { EventBusManager } from '@ohos/common/src/main/ets/default/worker/eventbus/EventBusManager' -import { Dispatch, OhCombinedState } from '@ohos/common/src/main/ets/default/redux/store' -import { getStore } from '@ohos/common/src/main/ets/default/redux/store' -import { Log } from '@ohos/common/src/main/ets/default/utils/Log' -import { GeoLocation } from '@ohos/common/src/main/ets/default/featurecommon/geolocation/GeoLocation' -import { ScreenLockManager } from '@ohos/common/src/main/ets/default/featurecommon/screenlock/ScreenLockManager' -import { SettingManager } from '@ohos/common/src/main/ets/default/setting/SettingManager' -import { ShowFlashBlack } from '@ohos/common/src/main/ets/default/featurecommon/animate/ShowFlashBlack' -import { TimeLapseView } from '@ohos/common/src/main/ets/default/featurecommon/timelapseview/TimeLapseView' -import { ZoomText } from '@ohos/common/src/main/ets/default/featurecommon/zoomview/ZoomText' -import { SmallVideoTimer } from './SmallVideoTimer' +import deviceInfo from '@ohos.deviceInfo'; +import { BigVideoTimer } from './BigVideoTimer'; +import { Action, UiStateMode } from '@ohos/common/src/main/ets/default/redux/actions/Action'; +import { AssistiveGridView } from '@ohos/common/src/main/ets/default/featurecommon/assistivegridview/AssistiveGridView'; +import { BigText } from '@ohos/common/src/main/ets/default/featurecommon/bigtext/BigText'; +import { CameraNeedStatus, CameraStatus } from '@ohos/common/src/main/ets/default/utils/Constants'; +import { CameraId } from '@ohos/common/src/main/ets/default/setting/settingitem/CameraId'; +import { EventBus } from '@ohos/common/src/main/ets/default/worker/eventbus/EventBus'; +import { EventBusManager } from '@ohos/common/src/main/ets/default/worker/eventbus/EventBusManager'; +import { Dispatch, getStore, OhCombinedState } from '@ohos/common/src/main/ets/default/redux/store'; +import { Log } from '@ohos/common/src/main/ets/default/utils/Log'; +import { GeoLocation } from '@ohos/common/src/main/ets/default/featurecommon/geolocation/GeoLocation'; +import { ScreenLockManager } from '@ohos/common/src/main/ets/default/featurecommon/screenlock/ScreenLockManager'; +import { SettingManager } from '@ohos/common/src/main/ets/default/setting/SettingManager'; +import { ShowFlashBlack } from '@ohos/common/src/main/ets/default/featurecommon/animate/ShowFlashBlack'; +import { TimeLapseView } from '@ohos/common/src/main/ets/default/featurecommon/timelapseview/TimeLapseView'; +import { ZoomText } from '@ohos/common/src/main/ets/default/featurecommon/zoomview/ZoomText'; +import { SmallVideoTimer } from './SmallVideoTimer'; import promptAction from '@ohos.promptAction'; import wantConstant from '@ohos.ability.wantConstant'; import { GlobalContext } from '@ohos/common/src/main/ets/default/utils/GlobalContext'; @@ -547,7 +546,8 @@ export struct PreviewAreaLand { private switchAnimationSec(): void { Log.info(`${this.TAG} switchAnimationSec called`); - animateTo({ duration: 200, + animateTo({ + duration: 200, delay: 0, curve: Curve.Sharp, }, () => { @@ -580,7 +580,8 @@ export struct PreviewAreaLand { } private switchBackgroundAnimation(): void { - animateTo({ duration: 350, + animateTo({ + duration: 350, delay: 0, curve: Curve.Sharp, onFinish: () => { @@ -653,7 +654,8 @@ export struct PreviewAreaLand { private swipeChangeMode(swipe: number): void { Log.info(`${this.TAG} swipeChangeMode E`); - if (!this.state.modeChangeDone && this.state.modeIndex + swipe >= 0 && this.state.modeIndex + swipe <= this.modeArray.length - 1 && !this.state.isShowtimeLapse) { + if (!this.state.modeChangeDone && this.state.modeIndex + swipe >= 0 && + this.state.modeIndex + swipe <= this.modeArray.length - 1 && !this.state.isShowtimeLapse) { this.mAction.swipeChangeMode(this.state.modeIndex + swipe); this.mAction.swipeModeChangeDone(true); } @@ -744,7 +746,12 @@ export struct PreviewAreaLand { .height(this.state.xComponentHeight) .syncLoad(false) .scale({ x: this.scaleX, y: 1.0 }) - .rotate({ x: 0, y: 10, z: 0, angle: this.rotateAngle })// .opacity(this.state.btnOpacity_first) + .rotate({ + x: 0, + y: 10, + z: 0, + angle: this.rotateAngle + })// .opacity(this.state.btnOpacity_first) .onComplete(() => { }) } @@ -755,7 +762,12 @@ export struct PreviewAreaLand { .height(this.state.xComponentHeight) .syncLoad(false) .scale({ x: this.scaleX, y: 1.0 }) - .rotate({ x: 0, y: 10, z: 0, angle: this.rotateAngleSec })// .opacity(this.state.btnOpacity_sec) + .rotate({ + x: 0, + y: 10, + z: 0, + angle: this.rotateAngleSec + })// .opacity(this.state.btnOpacity_sec) .onComplete(() => { }) } @@ -764,7 +776,7 @@ export struct PreviewAreaLand { ShowFlashBlack(); } - if (this.state.isShowZoomText && deviceInfo.deviceType !== "default" && !this.state.isShowtimeLapse) { + if (this.state.isShowZoomText && deviceInfo.deviceType !== 'default' && !this.state.isShowtimeLapse) { Stack({ alignContent: Alignment.Top }) { Column() { Column() { diff --git a/product/tablet/src/main/module.json5 b/product/tablet/src/main/module.json5 index 5ceab3bfe124db4cca34afb31af3f20ef277bf52..7589160230d5630a21c178bc79ef0747fb897c82 100644 --- a/product/tablet/src/main/module.json5 +++ b/product/tablet/src/main/module.json5 @@ -34,7 +34,13 @@ ], "requestPermissions": [ { - "name": "ohos.permission.MEDIA_LOCATION" + "name": "ohos.permission.MEDIA_LOCATION", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { "name": "ohos.permission.INTERNET" @@ -43,31 +49,79 @@ "name": "ohos.permission.MODIFY_AUDIO_SETTINGS" }, { - "name": "ohos.permission.READ_IMAGEVIDEO" + "name": "ohos.permission.READ_IMAGEVIDEO", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { - "name": "ohos.permission.WRITE_IMAGEVIDEO" + "name": "ohos.permission.WRITE_IMAGEVIDEO", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { "name": "ohos.permission.GET_BUNDLE_INFO" }, { - "name": "ohos.permission.CAMERA" + "name": "ohos.permission.CAMERA", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { - "name": "ohos.permission.MICROPHONE" + "name": "ohos.permission.MICROPHONE", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { - "name": "ohos.permission.DISTRIBUTED_DATASYNC" + "name": "ohos.permission.DISTRIBUTED_DATASYNC", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { - "name": "ohos.permission.LOCATION" + "name": "ohos.permission.LOCATION", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { - "name": "ohos.permission.LOCATION_IN_BACKGROUND" + "name": "ohos.permission.LOCATION_IN_BACKGROUND", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { - "name": "ohos.permission.APPROXIMATELY_LOCATION" + "name": "ohos.permission.APPROXIMATELY_LOCATION", + "reason": "$string:mainability_description", + "usedScene": { + "abilities": [ + "com.ohos.camera.MainAbility" + ] + } }, { "name": "ohos.permission.ACCESS_SERVICE_DM" @@ -79,7 +133,7 @@ "abilities": [ { "name": "com.ohos.camera.MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "srcEntry": "./ets/MainAbility/MainAbility.ts", "startWindowIcon": "$media:icon", "startWindowBackground": "$color:startWindowBackground", "launchType": "singleton", @@ -102,13 +156,14 @@ "minWindowHeight": 558, "minWindowWidth": 844, "maxWindowHeight": 800, - "maxWindowWidth": 1280 + "maxWindowWidth": 1280, + "srcEntry": "" } ], "extensionAbilities": [ { "name": "com.ohos.camera.FormAbility", - "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "srcEntry": "./ets/FormAbility/FormAbility.ts", "label": "$string:app_name", "description": "$string:app_name", "type": "form", diff --git a/product/tablet/src/main/resources/base/profile/form_config.json b/product/tablet/src/main/resources/base/profile/form_config.json index 7976a4825a6ca97ca3f6033a1dd726734f54d1ff..bf4c53de1857f753e48cb8b15b242991aa83bbc9 100644 --- a/product/tablet/src/main/resources/base/profile/form_config.json +++ b/product/tablet/src/main/resources/base/profile/form_config.json @@ -2,6 +2,7 @@ "forms": [ { "name": "widget", + "displayName": "This is a service widget.", "description": "This is a service widget.", "src": "./js/widget/pages/index/index", "window": { diff --git a/product/tablet/src/ohosTest/module.json5 b/product/tablet/src/ohosTest/module.json5 index 21ef32d318946005693092dc10136cb01b8c908a..0fcc2e4962a8a1d91b9979fa41ddb6a88d154036 100644 --- a/product/tablet/src/ohosTest/module.json5 +++ b/product/tablet/src/ohosTest/module.json5 @@ -17,7 +17,7 @@ "module": { "name": "entry_test", "type": "feature", - "srcEntrance": "./ets/TestAbility/TestAbility.ts", + "srcEntry": "./ets/TestAbility/TestAbility.ts", "description": "$string:entry_test_desc", "mainElement": "TestAbility", "deviceTypes": [ @@ -31,7 +31,7 @@ "abilities": [ { "name": "TestAbility", - "srcEntrance": "./ets/TestAbility/TestAbility.ts", + "srcEntry": "./ets/TestAbility/TestAbility.ts", "description": "$string:TestAbility_desc", "icon": "$media:icon", "label": "$string:TestAbility_label",