From e2a5ebf94d717a249e1bf819b96c4acc12cb9423 Mon Sep 17 00:00:00 2001 From: lijinfengde123 Date: Thu, 9 Feb 2023 19:56:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=97=AA=E5=85=89=E7=81=AF?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lijinfengde123 --- common/package.json | 20 +- .../main/ets/default/camera/CameraService.ts | 18 ++ .../preferences/PreferencesService.ets | 21 +- .../featurecommon/tabbar/TabBarLand.ets | 164 ++++++++---- .../ets/default/featurecommon/tip/Tip.ets | 54 ++++ .../default/featurecommon/tip/TipAction.ts | 35 +++ .../default/featurecommon/tip/TipReducer.ts | 40 +++ .../default/featurecommon/tip/TipService.ts | 49 ++++ .../default/function/CameraBasicFunction.ts | 12 +- .../ets/default/function/core/UiElement.ets | 43 ++++ .../default/function/flash/FlashFunction.ets | 233 ++++++++++++++++++ .../ets/default/function/flash/FlashMode.ts | 23 ++ .../main/ets/default/redux/actions/Action.ts | 33 +++ .../default/redux/reducers/FlashReducer.ts | 41 +++ common/src/main/ets/default/redux/store.ts | 6 + .../src/main/ets/default/utils/Constants.ts | 11 + .../main/resources/base/element/string.json | 16 ++ .../main/resources/zh_CN/element/string.json | 16 ++ .../main/resources/zz_ZX/element/string.json | 16 ++ features/featureservice/Constants.ts | 1 + features/featureservice/FeatureManager.ts | 2 + features/multi/package.json | 22 +- features/photo/package.json | 22 +- .../src/main/ets/photo/PhotoModeParam.ts | 2 +- features/video/package.json | 22 +- .../src/main/ets/video/VideoModeParam.ts | 2 +- package.json | 46 ++-- product/phone/package.json | 26 +- product/tablet/package.json | 26 +- .../src/main/ets/pages/PreviewAreaLand.ets | 3 + .../tablet/src/main/ets/pages/indexLand.ets | 12 +- 31 files changed, 880 insertions(+), 157 deletions(-) create mode 100644 common/src/main/ets/default/featurecommon/tip/Tip.ets create mode 100644 common/src/main/ets/default/featurecommon/tip/TipAction.ts create mode 100644 common/src/main/ets/default/featurecommon/tip/TipReducer.ts create mode 100644 common/src/main/ets/default/featurecommon/tip/TipService.ts create mode 100644 common/src/main/ets/default/function/core/UiElement.ets create mode 100644 common/src/main/ets/default/function/flash/FlashFunction.ets create mode 100644 common/src/main/ets/default/function/flash/FlashMode.ts create mode 100644 common/src/main/ets/default/redux/reducers/FlashReducer.ts diff --git a/common/package.json b/common/package.json index 92546c7..c2c1c5e 100644 --- a/common/package.json +++ b/common/package.json @@ -1,12 +1,12 @@ { - "license": "ISC", - "devDependencies": {}, - "name": "@ohos/common", - "description": "common feature", - "ohos": { - "org": "" + "license":"ISC", + "devDependencies":{}, + "name":"@ohos/common", + "description":"common feature", + "ohos":{ + "org":"" }, - "repository": {}, - "version": "1.0.0", - "dependencies": {} -} + "repository":{}, + "version":"1.0.0", + "dependencies":{} +} \ No newline at end of file diff --git a/common/src/main/ets/default/camera/CameraService.ts b/common/src/main/ets/default/camera/CameraService.ts index 64a085e..248fc5b 100644 --- a/common/src/main/ets/default/camera/CameraService.ts +++ b/common/src/main/ets/default/camera/CameraService.ts @@ -64,6 +64,7 @@ export class CameraService { private curCameraName = '' private mCameraCount = 0 private mCameraInput!: camera.CameraInput + private mHasFlash: boolean = true private mCaptureSession!: camera.CaptureSession private mPreviewOutput!: camera.PreviewOutput private mPhotoOutPut!: camera.PhotoOutput @@ -176,6 +177,14 @@ export class CameraService { return this.mCameraIdMap } + public hasFlash() { + return this.mHasFlash + } + + public getCaptureSession() { + return this.mCaptureSession + } + public getLocalCameraMap() { return this.mLocalCameraMap } @@ -339,6 +348,15 @@ export class CameraService { Trace.write(Trace.START_TIMEOUT) } globalThis.cameraStartFlag = false + + this.mCaptureSession.hasFlash((err, status) => { + if (err) { + Log.error(`${this.TAG} Failed to check whether the device has flash light`) + return; + } + this.mHasFlash = status + Log.info(`${this.TAG} flash light support status ` + status) + }) Log.info(`${this.TAG} createSession invoke X.`) } diff --git a/common/src/main/ets/default/featurecommon/preferences/PreferencesService.ets b/common/src/main/ets/default/featurecommon/preferences/PreferencesService.ets index 9a3f06c..3d5ec12 100644 --- a/common/src/main/ets/default/featurecommon/preferences/PreferencesService.ets +++ b/common/src/main/ets/default/featurecommon/preferences/PreferencesService.ets @@ -15,6 +15,7 @@ */ import dataStorage from '@ohos.data.storage'; +import { FunctionId } from '../../utils/Constants' const TAG: string = 'PreferencesService' @@ -26,17 +27,27 @@ export enum PersistType { } export class PreferencesService { + private static functionStorage private static modeStorage public static getInstance(): PreferencesService { if (!globalThis?.sInstancePreferencesService) { globalThis.sInstancePreferencesService = new PreferencesService() let filePath = globalThis.cameraAbilityContext.filesDir + PreferencesService.functionStorage = dataStorage.getStorageSync(filePath + '/function_persist_values') PreferencesService.modeStorage = dataStorage.getStorageSync(filePath + '/mode_persist_values') } return globalThis.sInstancePreferencesService } + getFunctionValue(persistType: PersistType, functionId: FunctionId, defaultValue: any): any{ + return PreferencesService.functionStorage.getSync(this.getFunctionPersistKey(persistType, 'ALL', 'ALL', functionId), defaultValue) + } + + putFunctionValue(persistType, functionId, value: any) { + PreferencesService.functionStorage.putSync(this.getFunctionPersistKey(persistType, 'ALL', 'ALL', functionId), value) + } + getModeValue(persistType: PersistType, defaultValue: any) { if (persistType === PersistType.FOR_AWHILE && this.isModeExpire()) { return defaultValue @@ -54,12 +65,16 @@ export class PreferencesService { flush(): void { PreferencesService.modeStorage.putSync(this.getModePersistKey(PersistType.FOR_AWHILE, 'Timestamp'), new Date().getTime()) this.flushMode() + this.flushFunction() + } + + flushFunction(): void { + PreferencesService.functionStorage.flushSync() } flushMode(): void { PreferencesService.modeStorage.flushSync() } - private getModeTimestamp(persistType: PersistType, defaultValue: any): any { return PreferencesService.modeStorage.getSync(this.getModePersistKey(persistType, 'Timestamp'), defaultValue) } @@ -68,6 +83,10 @@ export class PreferencesService { return (new Date().getTime() - this.getModeTimestamp(PersistType.FOR_AWHILE, 0)) > 15*60*1000 } + private getFunctionPersistKey(persistType: PersistType, mode: string, position: string, functionId: FunctionId): string { + return 'function_' + persistType + '_' + mode + '_' + position + '_' + functionId + } + private getModePersistKey(persistType: PersistType, item: string): string { return 'mode_' + persistType + '_' + item } diff --git a/common/src/main/ets/default/featurecommon/tabbar/TabBarLand.ets b/common/src/main/ets/default/featurecommon/tabbar/TabBarLand.ets index d8fdf94..b26c1ae 100644 --- a/common/src/main/ets/default/featurecommon/tabbar/TabBarLand.ets +++ b/common/src/main/ets/default/featurecommon/tabbar/TabBarLand.ets @@ -17,15 +17,18 @@ import { Action } from '../../redux/actions/Action' import { Log } from '../../utils/Log' import { EventBus } from '../../worker/eventbus/EventBus' import EventBusManager from '../../worker/eventbus/EventBusManager' -import getStore from '../../redux/store' -//import { TabBarOther } from './TabBarTablet/TabBarOther' -//import { TabBarSame } from './TabBarTablet/TabBarSame' +import getStore, { OhCombinedState } from '../../redux/store' +import { UiElement } from '../../function/core/UiElement' +import { TipService } from '../tip/TipService' -let tabBarLandState = (state) => { +let tabBarLandState = (state: OhCombinedState) => { return { -// widthTabBar: state.PreviewReducer.widthTabBar, -// opacityValueForTabBar: state.SettingReducer.opacityValueForTabBar - isThirdPartyCall: state.ContextReducer.isThirdPartyCall + curMode: state.ModeReducer.curMode, + mode: state.ModeReducer.mode, + isThirdPartyCall: state.ContextReducer.isThirdPartyCall, + flashList: state.FlashReducer.flashList, + currentModel: state.FlashReducer.currentModel, + cameraPosition: state.CameraReducer.cameraPosition } } @@ -34,6 +37,9 @@ let tabBarLandDispatcher = (dispatch) => { showSettingView: () => { dispatch(Action.showSettingView(true)) }, + setFlashModel: (model) => { + dispatch(Action.setFlashModel(model)) + } } } @@ -43,62 +49,120 @@ export struct TabBarLand { @State state: any = {} @State opacityTabBar: number = 0 @State isShowTabBarOther: boolean= false + @State isFlashModeListShow: boolean= false + @State isCameraFront: boolean= false @Link screenSize: any - private onBackClicked:Function + private timerId: number = Number.MIN_VALUE + private onBackClicked: Function + private mTipService: TipService = TipService.getInstance() appEventBus: EventBus = EventBusManager.getInstance().getEventBus() + private onPopupButtonClicked() { + Log.info(`${this.TAG} onPopupButtonClicked`) + this.timerId = setTimeout(() => { + this.isFlashModeListShow = false + }, 5000) + } + + private onModeChanged(data): void { + Log.info(`${this.TAG} onModeChanged data mode : ` + data.mode) + this.isFlashModeListShow = false + } + + private switchCamera(data: any): void { + Log.info(`${this.TAG} switchCamera`) + if (data.cameraId === 'FRONT') { + this.isCameraFront = true + this.isFlashModeListShow = false + } else { + this.isCameraFront = false + } + } + aboutToAppear(): void { Log.info(`${this.TAG} aboutToAppear invoke E`) getStore().connect(tabBarLandState, tabBarLandDispatcher)(this.state) + this.appEventBus.on(Action.ACTION_CHANGE_MODE, this.onModeChanged.bind(this)) + this.appEventBus.on(Action.ACTION_SWITCH_CAMERA, this.switchCamera.bind(this)) + if (this.state.cameraPosition === 'FRONT') { + this.isCameraFront = true + } else { + this.isCameraFront = false + } Log.info(`${this.TAG} aboutToAppear invoke X`) } build() { - Flex({ direction: FlexDirection.ColumnReverse, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) { - if (this.state.isThirdPartyCall) { - Row() { - Image($r("app.media.ic_public_back")).width(24).height(24) + Stack({ alignContent: Alignment.Bottom }) { + Column() { + if (!this.isFlashModeListShow) { + Row() { + Image($r("app.media.setting")).width(24).height(24) + } + .width(48) + .height(48) + .padding({ left: 12 }) .onClick(() => { - this.onBackClicked() + this.state.showSettingView() }) - }.width(48).height(48) - .padding({left: 12}) - .margin({ bottom: 12 }) - } - Row() { - Image($r("app.media.setting")).width(24).height(24) - .onClick(() => { - this.state.showSettingView() - }) - }.width(48).height(48) - .padding({ left: 12 }) - .position(this.state.isThirdPartyCall ? {x:0,y:12} : {x:0,y: this.screenSize.height - 144}) - // Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - // TabBarOther() - // }.width('100%').height('20%') - // .opacity(this.state.opacityValueForTabBar) - // .animation({ - // duration: 2000, - // curve: Curve.Sharp, - // delay: 0, - // iterations: 1, - // playMode: PlayMode.Normal - // }) - // - // Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - // TabBarSame() - // } - // .position({ y: this.state.widthTabBar }) - // .width('100%') - // .height('20%') - // .animation({ - // duration: 2000, - // curve: Curve.Sharp, - // delay: 0, - // iterations: 1, - // playMode: PlayMode.Normal - // }) + if (!this.isCameraFront && this.state.flashList?.size) { + Row() { + Image(this.state.currentModel?.icon).width(24).height(24) + } + .width(48) + .height(48) + .margin({top: 24}) + .padding({left: 12}) + .onClick(() => { + this.isFlashModeListShow = true + this.onPopupButtonClicked() + }) + } + } else { + if (!this.isCameraFront && this.state.flashList?.size) { + Column() { + ForEach(Array.from(this.state.flashList?.values()) + .map((item: UiElement, index) => { + let functionValue = this.state.currentModel?.functionValue + let functionColor = '#FFFFFF' + if (functionValue === item.functionValue) { + functionColor = '#007DFF' + } + return {icon: item.icon, value: item.functionValue, desc: item.desc, color: functionColor} + }), (item, index) => { + Row() { + Image(item.icon).width(24).height(24).fillColor(item.color) + } + .width(48) + .height(48) + .margin({top: index === 0 ? 0 : 24}) + .padding({left: 12}) + .onClick(() => { + this.isFlashModeListShow = false + this.state.setFlashModel(item.value) + this.mTipService.showTip(item.desc, 3000) + if (Number.MIN_VALUE !== this.timerId) { + clearTimeout(this.timerId) + } + }) + }) + } + + } + } + }.width(48).height('100%').justifyContent(FlexAlign.Center).alignItems(HorizontalAlign.Center) + + if (this.state.isThirdPartyCall && !this.isFlashModeListShow) { + Row() { + Image($r("app.media.ic_public_back")).width(24).height(24) + .onClick(() => { + this.onBackClicked() + }) + }.width(48).height(48) + .padding({left: 12}) + .margin({ bottom: 12 }) + } }.width(48).height('100%') } } \ No newline at end of file diff --git a/common/src/main/ets/default/featurecommon/tip/Tip.ets b/common/src/main/ets/default/featurecommon/tip/Tip.ets new file mode 100644 index 0000000..74adcdc --- /dev/null +++ b/common/src/main/ets/default/featurecommon/tip/Tip.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Log } from '../../utils/Log' +import getStore from '../../redux/store' + +let localState = (state) => { + return { + isShowTip: state.TipReducer.isShowTip, + message: state.TipReducer.message + } +} + +let localDispatcher = (dispatch) => { + return { + } +} + +@Component +export struct Tip { + @State state: any = {} + + aboutToAppear() { + getStore().connect(localState, localDispatcher)(this.state) + } + + build() { + if (this.state.isShowTip) { + Column() { + Text(this.state.message) + .fontSize(12) + .fontColor(Color.Black) + .backgroundColor(Color.White) + .textCase(TextCase.UpperCase) + .textAlign(TextAlign.Center) + .borderRadius(4) + .padding({left: 6, right: 6, top: 4, bottom: 4}) + .shadow({radius: 2, color: '#99000000', offsetX: 0, offsetY: 0}) + }.alignItems(HorizontalAlign.Center).width('100%').height(40).position({x: 0, y: 20}) + } + } +} \ No newline at end of file diff --git a/common/src/main/ets/default/featurecommon/tip/TipAction.ts b/common/src/main/ets/default/featurecommon/tip/TipAction.ts new file mode 100644 index 0000000..c1d4382 --- /dev/null +++ b/common/src/main/ets/default/featurecommon/tip/TipAction.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ActionData } from '../../redux/actions/Action' + +export class TipAction { + public static readonly ACTION_SHOW_TIP = 'ACTION_SHOW_TIP' + public static readonly ACTION_HIDE_TIP = 'ACTION_HIDE_TIP' + + public static showTip(message: string): ActionData { + return { + type: TipAction.ACTION_SHOW_TIP, + data: { isShowTip: true, message: message } + } + } + + public static hideTip(): ActionData { + return { + type: TipAction.ACTION_HIDE_TIP, + data: { isShowTip: false } + } + } +} diff --git a/common/src/main/ets/default/featurecommon/tip/TipReducer.ts b/common/src/main/ets/default/featurecommon/tip/TipReducer.ts new file mode 100644 index 0000000..b319a8b --- /dev/null +++ b/common/src/main/ets/default/featurecommon/tip/TipReducer.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ActionData } from '../../redux/actions/Action' +import { TipAction } from './TipAction' + +export type TipState = { + isShowTip: boolean, + message: string +} + +const initState: TipState = { + isShowTip: false, + message: "" +} + +export default function TipReducer(state = initState, action: ActionData): TipState { + switch (action.type) { + case TipAction.ACTION_SHOW_TIP: + return { + isShowTip:true, message: action.data.message + } + case TipAction.ACTION_HIDE_TIP: + return initState + default: + return state + } +} diff --git a/common/src/main/ets/default/featurecommon/tip/TipService.ts b/common/src/main/ets/default/featurecommon/tip/TipService.ts new file mode 100644 index 0000000..16c2074 --- /dev/null +++ b/common/src/main/ets/default/featurecommon/tip/TipService.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { WorkerManager } from '../../worker/WorkerManager' +import { TipAction } from './TipAction' +import { Log } from '../../utils/Log' +const TAG = 'TipService' + +export class TipService { + private mWorkerManager: WorkerManager = new WorkerManager() + private mTipTimer: number = 0 + + public static getInstance(): TipService { + if (!globalThis?.sInstanceTipService) { + globalThis.sInstanceTipService = new TipService() + } + return globalThis.sInstanceTipService + } + + /** + * Show tip on screen top + * + * @param message Toast content + * @param duration Toast duration + */ + showTip(message: string, duration: number) { + Log.info(`${TAG} showTip: ` + message) + if (this.mTipTimer) { + clearTimeout(this.mTipTimer) + } + this.mWorkerManager.postMessage(TipAction.showTip(message)) + this.mTipTimer = setTimeout(() => { + Log.info(`${TAG} hide tip`) + this.mWorkerManager.postMessage(TipAction.hideTip()) + }, duration) + } +} diff --git a/common/src/main/ets/default/function/CameraBasicFunction.ts b/common/src/main/ets/default/function/CameraBasicFunction.ts index c437055..9e15be7 100644 --- a/common/src/main/ets/default/function/CameraBasicFunction.ts +++ b/common/src/main/ets/default/function/CameraBasicFunction.ts @@ -108,6 +108,10 @@ export class CameraBasicFunction extends BaseFunction { Log.info(`${this.TAG} onSurfacePrepare X`) } + private async createSession() { + await this.mCameraService.createSession(this.mSurfaceId, await this.isVideoMode()) + this.mWorkerManager.postMessage(Action.createSessionDone()) + } private async startPreview(data?) { Log.info(`${this.TAG} startPreview E`) globalThis.cameraStatus = CameraStatus.CAMERA_BEGIN_PREVIEW @@ -122,7 +126,7 @@ export class CameraBasicFunction extends BaseFunction { } else { await this.mCameraService.createPhotoOutput(this.functionBackImpl) } - await this.mCameraService.createSession(this.mSurfaceId, await this.isVideoMode()) + await this.createSession() if ([...this.mSessionList].pop() === 'RELEASE') { await this.close() } @@ -155,7 +159,7 @@ export class CameraBasicFunction extends BaseFunction { } else { await this.mCameraService.createPhotoOutput(this.functionBackImpl) } - await this.mCameraService.createSession(this.mSurfaceId, await this.isVideoMode()) + await this.createSession() if ([...this.mSessionList].pop() === 'RELEASE') { await this.close() } @@ -182,7 +186,7 @@ export class CameraBasicFunction extends BaseFunction { } else { await this.mCameraService.createPhotoOutput(this.functionBackImpl) } - await this.mCameraService.createSession(this.mSurfaceId, await this.isVideoMode()) + await this.createSession() this.mWorkerManager.postMessage(Action.onModeChanged(this.mCurrentMode)) this.mWorkerManager.postMessage(Action.swipeModeChangeDone(false)) globalThis.cameraStatus = CameraStatus.CAMERA_PREVIEW_FINISHED @@ -206,7 +210,7 @@ export class CameraBasicFunction extends BaseFunction { } else { await this.mCameraService.createPhotoOutput(this.functionBackImpl) } - await this.mCameraService.createSession(this.mSurfaceId, await this.isVideoMode()) + await this.createSession() globalThis.cameraStatus = CameraStatus.CAMERA_PREVIEW_FINISHED this.mWorkerManager.postMessage(Action.updateCameraStatus()) if (new Date().getTime() - globalThis.switchCameraTime > 2000) { diff --git a/common/src/main/ets/default/function/core/UiElement.ets b/common/src/main/ets/default/function/core/UiElement.ets new file mode 100644 index 0000000..a4be340 --- /dev/null +++ b/common/src/main/ets/default/function/core/UiElement.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class UiElement { + public static readonly DEFAULT = 'UiElement' + + functionValue: number + title: Resource + icon: Resource + desc: Resource + + setValue(functionValue: number): UiElement { + this.functionValue = functionValue + return this + } + + setTitle(title: Resource): UiElement { + this.title = title + return this + } + + setIcon(icon: Resource): UiElement { + this.icon = icon + return this + } + + setDesc(desc: Resource): UiElement { + this.desc = desc + return this + } +} \ No newline at end of file diff --git a/common/src/main/ets/default/function/flash/FlashFunction.ets b/common/src/main/ets/default/function/flash/FlashFunction.ets new file mode 100644 index 0000000..b7147ba --- /dev/null +++ b/common/src/main/ets/default/function/flash/FlashFunction.ets @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Log } from '../../utils/Log' +import { BaseFunction } from '../BaseFunction' +import { FunctionId } from '../../utils/Constants' +import { UiElement } from '../core/UiElement' +import camera from '@ohos.multimedia.camera' +import { Action } from '../../redux/actions/Action' +import getStore, { OhCombinedState } from '../../redux/store' +import { PreferencesService, PersistType } from '../../featurecommon/preferences/PreferencesService' + +const TAG = 'FlashFunction' + +let flashState = (state: OhCombinedState) => { + return { + cameraPosition: state.CameraReducer.cameraPosition, + zoomRatio: state.ZoomReducer.zoomRatio + } +} + +let flashDispatcher = (dispatch) => { + return { + setFlashModel: (model) => { + dispatch(Action.setFlashModel(model)) + } + } +} + +export class FlashFunction extends BaseFunction{ + private state: any = {} + private valueMap = new Map() + private cacheMap = new Map() + private zoomOver2x: boolean = false + private flashModel = new Map() + private modeStatus = 'PHOTO' + private currentCameraPosition = 'BACK' + private currentZoomRatio: number = 1.0 + private lastZoomRatio: number = 1.0 + + private getFlashModelList() { + this.flashModel.clear() + Log.info(`${TAG} getFlashModelList currentZoomRatio E : ${this.currentZoomRatio} mode : ${this.modeStatus}`) + if (!this.isAvailable()) { + this.mWorkerManager.postMessage(Action.getFlashModelList(this.flashModel)) + return + } + this.flashModel.set(camera.FlashMode.FLASH_MODE_ALWAYS_OPEN, new UiElement().setValue(camera.FlashMode.FLASH_MODE_ALWAYS_OPEN) + .setIcon($r('app.media.flash_always_on')) + .setDesc($r('app.string.flash_mode_always_on'))) + if (this.modeStatus === 'PHOTO' && this.currentZoomRatio <= 2.0) { + this.flashModel.set(camera.FlashMode.FLASH_MODE_OPEN, new UiElement().setValue(camera.FlashMode.FLASH_MODE_OPEN).setIcon($r('app.media.flash_on')) + .setDesc($r('app.string.flash_mode_on'))) + } + this.flashModel.set(camera.FlashMode.FLASH_MODE_CLOSE, new UiElement().setValue(camera.FlashMode.FLASH_MODE_CLOSE).setIcon($r('app.media.flash_off')) + .setDesc($r('app.string.flash_mode_off'))) + if (this.modeStatus === 'PHOTO' && this.currentZoomRatio <= 2.0) { + this.flashModel.set(camera.FlashMode.FLASH_MODE_AUTO, new UiElement().setValue(camera.FlashMode.FLASH_MODE_AUTO).setIcon($r('app.media.flash_auto')) + .setDesc($r('app.string.flash_mode_auto'))) + } + this.mWorkerManager.postMessage(Action.getFlashModelList(this.flashModel)) + this.getCurrentFlashModel() + Log.info(`${TAG} getFlashModelList currentZoomRatio X`) + } + + setFlashMode(data): void { + Log.info(`${TAG} setFlashMode model E : ${data.model}`) + let value = data.model + if (this.getValue() == value) { + return + } + let captureSession = this.mCameraService.getCaptureSession() + if (!captureSession) { + Log.info(`${TAG} setFlashMode captureSession is null`) + return + } + Log.info(`${TAG} setFlashMode modeStatus : ` + this.modeStatus) + captureSession.setFlashMode(value) + this.valueMap.set(this.modeStatus, value) + this.persistValue() + this.getFlashModelList() + } + + private switchCamera(data: any): void { + Log.info(`${TAG} switchCamera E data : ${JSON.stringify(data)}`) + this.currentCameraPosition = data.cameraId + this.currentZoomRatio = this.state.zoomRatio + this.getFlashModelList() + } + + private persistValue() { + let flashModeValue: {} = { + 'photo': this.valueMap.get('PHOTO'), + 'video': this.valueMap.get('VIDEO') + } + Log.info(`${TAG} persistValue flashModeValue : ${JSON.stringify(flashModeValue)}`) + PreferencesService.getInstance().putFunctionValue(PersistType.FOREVER, FunctionId.FLASH, JSON.stringify(flashModeValue)) + } + + getValue(): number { + let value = this.valueMap.get(this.modeStatus) + Log.info(`${TAG} getValue : ${value}`) + return value + } + + getCurrentFlashModel() { + this.mWorkerManager.postMessage(Action.getCurrentFlashModel(this.flashModel.get(this.getValue()))) + } + + isAvailable(): boolean { + Log.info(`${TAG} isAvailable E`) + return !this.isFrontCamera() && this.modeStatus !== 'MULTI' && this.mCameraService.hasFlash() + } + + protected isFrontCamera(): boolean { + Log.info(`${TAG} isFrontCamera E`) + return this.currentCameraPosition === 'FRONT' + } + + private onSessionCreated(): void { + Log.info(`${TAG} onSessionCreated E`) + if (!this.isAvailable()) { + return + } + let captureSession = this.mCameraService.getCaptureSession() + if (!captureSession) { + Log.info(`${TAG} onSessionCreated captureSession is null`) + return + } + captureSession.setFlashMode(this.getValue()) + Log.info(`${TAG} onSessionCreated X`) + } + + private onSettingViewShow(data):void { + Log.info(`${TAG} onSettingViewShow E`) + if (!this.isAvailable()) { + return + } + let captureSession = this.mCameraService.getCaptureSession() + if (!captureSession) { + Log.info(`${TAG} onSettingViewShow captureSession is null`) + return + } + if (data?.isShowSettingView) { + captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_CLOSE) + Log.info(`${TAG} onSettingViewShow setFlashMode off`) + } else { + captureSession.setFlashMode(this.getValue()) + Log.info(`${TAG} onSettingViewShow setFlashMode: ` + this.getValue()) + } + Log.info(`${TAG} onSettingViewShow X`) + } + + private onZoomChanged(data): void { + Log.info(`${TAG} onZoomChanged E ${JSON.stringify(data)}`) + this.currentZoomRatio = data?.zoomRatio + let isZoomOver = data?.zoomRatio > 2.0 + if (!this.zoomOver2x && isZoomOver) { + this.cacheMap.set('PHOTO', this.valueMap.get('PHOTO') | camera.FlashMode.FLASH_MODE_CLOSE) + this.cacheMap.set('VIDEO', this.valueMap.get('VIDEO') | camera.FlashMode.FLASH_MODE_CLOSE) + if (this.getValue() === camera.FlashMode.FLASH_MODE_OPEN || this.getValue() === camera.FlashMode.FLASH_MODE_AUTO) { + Log.info(`${TAG} onZoomChanged need close flash`) + this.state.setFlashModel(camera.FlashMode.FLASH_MODE_CLOSE) + } + } else if (this.zoomOver2x && !isZoomOver) { + Log.info(`${TAG} onZoomChanged keep cache flash`) + if (this.getValue() === camera.FlashMode.FLASH_MODE_ALWAYS_OPEN) { + this.state.setFlashModel(this.getValue()) + } else if (this.cacheMap.get(this.modeStatus) === camera.FlashMode.FLASH_MODE_OPEN + || this.cacheMap.get(this.modeStatus) === camera.FlashMode.FLASH_MODE_AUTO) { + this.state.setFlashModel(this.cacheMap.get(this.modeStatus)) + } else { + this.state.setFlashModel(camera.FlashMode.FLASH_MODE_CLOSE) + } + } else { + Log.info(`${TAG} onZoomChanged do nothing`) + } + if ((this.lastZoomRatio < 2.0 && this.currentZoomRatio > 2.0) + || (this.lastZoomRatio > 2.0 && this.currentZoomRatio < 2.0)) { + this.getFlashModelList() + } + this.zoomOver2x = isZoomOver + this.lastZoomRatio = this.currentZoomRatio + } + + private onModeChanged(data): void { + Log.info(`${TAG} onModeChanged E `) + this.modeStatus = data.mode + this.getFlashModelList() + } + + load(): void { + Log.info(`${TAG} load E `) + getStore().connect(flashState, flashDispatcher)(this.state) + this.mEventBus.on(Action.ACTION_CHANGE_MODE, this.onModeChanged.bind(this)) + this.mEventBus.on(Action.ACTION_CREATESESSION_DONE, this.onSessionCreated.bind(this)) + this.mEventBus.on(Action.ACTION_SHOW_SETTING_VIEW, this.onSettingViewShow.bind(this)) + this.mEventBus.on(Action.ACTION_CHANGE_ZOOM_RATIO, this.onZoomChanged.bind(this)) + this.mEventBus.on(Action.ACTION_SET_FLASH_MODEL,this.setFlashMode.bind(this) ) + this.mEventBus.on(Action.ACTION_SWITCH_CAMERA, this.switchCamera.bind(this)) + let cacheModeStr = PreferencesService.getInstance() + .getFunctionValue(PersistType.FOREVER, FunctionId.FLASH, "{}") + Log.info(`${TAG} load getFunctionValue : ${cacheModeStr}`) + let cacheModeJson = JSON.parse(`${cacheModeStr}`) + this.valueMap.set('PHOTO', cacheModeJson?.photo | camera.FlashMode.FLASH_MODE_CLOSE) + this.valueMap.set('VIDEO', cacheModeJson?.video | camera.FlashMode.FLASH_MODE_CLOSE) + this.currentCameraPosition = this.state.cameraPosition + this.getFlashModelList() + Log.info(`${TAG} load X `) + } + unload(): void { + Log.info(`${TAG} unload E `) + this.mEventBus.off(Action.ACTION_CHANGE_MODE, this.onModeChanged.bind(this)) + this.mEventBus.off(Action.ACTION_CREATESESSION_DONE, this.onSessionCreated.bind(this)) + this.mEventBus.off(Action.ACTION_SHOW_SETTING_VIEW, this.onSettingViewShow.bind(this)) + this.mEventBus.off(Action.ACTION_CHANGE_ZOOM_RATIO, this.onZoomChanged.bind(this)) + this.mEventBus.off(Action.ACTION_SET_FLASH_MODEL,this.setFlashMode.bind(this) ) + this.mEventBus.off(Action.ACTION_SWITCH_CAMERA, this.switchCamera.bind(this)) + Log.info(`${TAG} unload X `) + } +} \ No newline at end of file diff --git a/common/src/main/ets/default/function/flash/FlashMode.ts b/common/src/main/ets/default/function/flash/FlashMode.ts new file mode 100644 index 0000000..c3ca482 --- /dev/null +++ b/common/src/main/ets/default/function/flash/FlashMode.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import camera from '@ohos.multimedia.camera' + +export enum FlashMode { + OFF = camera.FlashMode.FLASH_MODE_CLOSE, + ON = camera.FlashMode.FLASH_MODE_OPEN, + AUTO = camera.FlashMode.FLASH_MODE_AUTO, + ALWAYS_OPEN = camera.FlashMode.FLASH_MODE_ALWAYS_OPEN +} diff --git a/common/src/main/ets/default/redux/actions/Action.ts b/common/src/main/ets/default/redux/actions/Action.ts index d4dc31c..195115e 100644 --- a/common/src/main/ets/default/redux/actions/Action.ts +++ b/common/src/main/ets/default/redux/actions/Action.ts @@ -49,6 +49,7 @@ export class Action { public static readonly ACTION_UPDATE_CAMERA_POSITION = 'ACTION_UPDATE_CAMERA_POSITION' public static readonly ACTION_CLOSE_CAMERA = 'ACTION_CLOSE_CAMERA' public static readonly ACTION_UPDATE_CAMERA_STATUS = 'ACTION_UPDATE_CAMERA_STATUS' + public static readonly ACTION_CREATESESSION_DONE = 'ACTION_CREATESESSION_DONE' // Mode public static readonly ACTION_INIT_MODE = 'ACTION_INIT_MODE' @@ -98,6 +99,11 @@ export class Action { public static readonly ACTION_CHANGE_TIME_LAPSE = 'ACTION_CHANGE_TIME_LAPSE' public static readonly ACTION_ASSISTIVE_GRID_VIEW = 'ACTION_ASSISTIVE_GRID_VIEW' + // flash + public static readonly ACTION_GET_FLASH_MODEL_LIST = 'ACTION_GET_FLASH_MODEL_LIST' + public static readonly ACTION_SET_FLASH_MODEL = 'ACTION_SET_FLASH_MODEL' + public static readonly ACTION_GET_CURRENT_FLASH_MODEL = 'ACTION_GET_CURRENT_FLASH_MODEL' + // Device error public static readonly ACTION_DEVICE_ERROR = 'ACTION_DEVICE_ERROR' @@ -212,6 +218,14 @@ export class Action { } } + public static createSessionDone(): ActionData { + return { + isEvent: true, + type: Action.ACTION_CREATESESSION_DONE, + data: {} + } + } + public static updateCameraPosition(cameraPosition: string): ActionData { return { type: Action.ACTION_UPDATE_CAMERA_POSITION, @@ -765,4 +779,23 @@ export class Action { data: { isShowSettingView: isShowSettingView } } } + + public static getFlashModelList(flashList: any): ActionData { + return { + type: Action.ACTION_GET_FLASH_MODEL_LIST, + data: { flashList: flashList } + } + } + public static setFlashModel(model: any): ActionData { + return { + type: Action.ACTION_SET_FLASH_MODEL, + data: { model: model } + } + } + public static getCurrentFlashModel(model: any): ActionData { + return { + type: Action.ACTION_GET_CURRENT_FLASH_MODEL, + data: { currentModel: model } + } + } } diff --git a/common/src/main/ets/default/redux/reducers/FlashReducer.ts b/common/src/main/ets/default/redux/reducers/FlashReducer.ts new file mode 100644 index 0000000..854e532 --- /dev/null +++ b/common/src/main/ets/default/redux/reducers/FlashReducer.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Action, ActionData } from '../actions/Action' + +export type FlashState = { + flashList: any, + currentModel: any, + model: number +} + +const initState: FlashState = { + flashList: {}, + currentModel: {}, + model: 0 +} + +export default function FlashReducer(state = initState, action: ActionData): FlashState { + switch (action.type) { + case Action.ACTION_GET_FLASH_MODEL_LIST: + return { ...state, flashList: action.data.flashList } + case Action.ACTION_GET_CURRENT_FLASH_MODEL: + return { ...state, currentModel: action.data.currentModel } + case Action.ACTION_SET_FLASH_MODEL: + return { ...state, model: action.data.model } + default: + return state + } +} \ No newline at end of file diff --git a/common/src/main/ets/default/redux/store.ts b/common/src/main/ets/default/redux/store.ts index b669d23..d04071b 100644 --- a/common/src/main/ets/default/redux/store.ts +++ b/common/src/main/ets/default/redux/store.ts @@ -29,6 +29,8 @@ import ModeReducer, { ModeState } from './reducers/ModeReducer' import SettingReducer, { SettingState } from './reducers/SettingReducer' import RecordReducer, { RecordState } from './reducers/RecordReducer' import ZoomReducer, { ZoomState } from './reducers/ZoomReducer' +import FlashReducer, { FlashState } from './reducers/FlashReducer' +import TipReducer, { TipState } from './../featurecommon/tip/TipReducer' import { ActionData } from './actions/Action' import { CombinedState, Dispatch, Unsubscribe } from './core/redux' import { MapDispatchProp, MapStateProp } from './core/ohredux/connect' @@ -47,6 +49,8 @@ export type OhCombinedState = CombinedState<{ ModeReducer: ModeState SettingReducer: SettingState ZoomReducer: ZoomState + TipReducer: TipState + FlashReducer: FlashState }> export default function getStore(): { @@ -69,6 +73,8 @@ export default function getStore(): { ModeReducer, SettingReducer, ZoomReducer, + TipReducer, + FlashReducer }), applyMiddleware(logger, reduxWorkerMiddle) ) diff --git a/common/src/main/ets/default/utils/Constants.ts b/common/src/main/ets/default/utils/Constants.ts index 7c7f48b..da20949 100644 --- a/common/src/main/ets/default/utils/Constants.ts +++ b/common/src/main/ets/default/utils/Constants.ts @@ -39,4 +39,15 @@ export enum CameraNeedStatus { CAMERA_NO_NEED_TO_DO = 'CAMERA_NO_NEED_TO_DO', CAMERA_NEED_INIT = 'CAMERA_NEED_INIT', CAMERA_NEED_RELEASE = 'CAMERA_NEED_RELEASE' +} + +export enum FunctionId { + NONE, + CAMERA_BASIC, + CAPTURE, + RECORDING, + ZOOM, + FLASH, + FOCUS, + MIRROR } \ No newline at end of file diff --git a/common/src/main/resources/base/element/string.json b/common/src/main/resources/base/element/string.json index 2df1a93..bfa2a42 100644 --- a/common/src/main/resources/base/element/string.json +++ b/common/src/main/resources/base/element/string.json @@ -1,5 +1,21 @@ { "string": [ + { + "name": "flash_mode_off", + "value": "Flash off" + }, + { + "name": "flash_mode_auto", + "value": "Auto flash" + }, + { + "name": "flash_mode_on", + "value": "Flash on" + }, + { + "name": "flash_mode_always_on", + "value": "Flash always on" + }, { "name": "commonutil_library", "value": "commonutil_library" diff --git a/common/src/main/resources/zh_CN/element/string.json b/common/src/main/resources/zh_CN/element/string.json index e21e833..9f5512d 100644 --- a/common/src/main/resources/zh_CN/element/string.json +++ b/common/src/main/resources/zh_CN/element/string.json @@ -1,5 +1,21 @@ { "string": [ + { + "name": "flash_mode_off", + "value": "闪光灯已关闭" + }, + { + "name": "flash_mode_auto", + "value": "闪光灯已自动" + }, + { + "name": "flash_mode_on", + "value": "闪光灯已开启" + }, + { + "name": "flash_mode_always_on", + "value": "闪光灯已常亮" + }, { "name": "noticeitem", "value": "noticeitem" diff --git a/common/src/main/resources/zz_ZX/element/string.json b/common/src/main/resources/zz_ZX/element/string.json index e21e833..e807d54 100644 --- a/common/src/main/resources/zz_ZX/element/string.json +++ b/common/src/main/resources/zz_ZX/element/string.json @@ -1,5 +1,21 @@ { "string": [ + { + "name": "flash_mode_off", + "value": "[TS_802744]_Flash off" + }, + { + "name": "flash_mode_auto", + "value": "[TS_802746]_Auto flash" + }, + { + "name": "flash_mode_on", + "value": "[TS_802745]_Flash on" + }, + { + "name": "flash_mode_always_on", + "value": "[TS_802743]_Flash always on" + }, { "name": "noticeitem", "value": "noticeitem" diff --git a/features/featureservice/Constants.ts b/features/featureservice/Constants.ts index 1d144dd..faa9ef2 100644 --- a/features/featureservice/Constants.ts +++ b/features/featureservice/Constants.ts @@ -18,4 +18,5 @@ export class Constants { public static readonly CAPTURE_FUNCTION = 'CAPTURE_FUNCTION' public static readonly RECORDING_FUNCTION = 'RECORDING_FUNCTION' public static readonly ZOOM_FUNCTION = 'ZOOM_FUNCTION' + public static readonly FLASH_FUNCTION = 'FLASH_FUNCTION' } \ No newline at end of file diff --git a/features/featureservice/FeatureManager.ts b/features/featureservice/FeatureManager.ts index 5c49536..8496631 100644 --- a/features/featureservice/FeatureManager.ts +++ b/features/featureservice/FeatureManager.ts @@ -16,6 +16,7 @@ import { Action } from '../../common/src/main/ets/default/redux/actions/Action' import { CameraBasicFunction } from '../../common/src/main/ets/default/function/CameraBasicFunction' import { CaptureFunction } from '../../common/src/main/ets/default/function/CaptureFunction' +import { FlashFunction } from '../../common/src/main/ets/default/function/flash/FlashFunction' import { Log } from '../../common/src/main/ets/default/utils/Log' import { Constants } from './Constants' import { EventBus } from '../../common/src/main/ets/default/worker/eventbus/EventBus' @@ -58,6 +59,7 @@ export class FeatureManager { this.mFunctionsMap.set(Constants.CAPTURE_FUNCTION, new CaptureFunction()) this.mFunctionsMap.set(Constants.RECORDING_FUNCTION, new RecordFunction()) this.mFunctionsMap.set(Constants.ZOOM_FUNCTION, new ZoomFunction()) + this.mFunctionsMap.set(Constants.FLASH_FUNCTION, new FlashFunction()) Log.info(`${this.TAG} initFunctionsMap invoke X.`) } } \ No newline at end of file diff --git a/features/multi/package.json b/features/multi/package.json index 1cea78f..7f77d44 100644 --- a/features/multi/package.json +++ b/features/multi/package.json @@ -1,14 +1,14 @@ { - "license": "ISC", - "devDependencies": {}, - "name": "@ohos/features", - "description": "multi mode", - "ohos": { - "org": "" + "license":"ISC", + "devDependencies":{}, + "name":"@ohos/features", + "description":"multi mode", + "ohos":{ + "org":"" }, - "repository": {}, - "version": "1.0.0", - "dependencies": { - "@ohos/common": "../../common" + "repository":{}, + "version":"1.0.0", + "dependencies":{ + "@ohos/common":"../../common" } -} +} \ No newline at end of file diff --git a/features/photo/package.json b/features/photo/package.json index 8e60af6..809cbc6 100644 --- a/features/photo/package.json +++ b/features/photo/package.json @@ -1,14 +1,14 @@ { - "license": "ISC", - "devDependencies": {}, - "name": "@ohos/photo", - "description": "photo mode", - "ohos": { - "org": "" + "license":"ISC", + "devDependencies":{}, + "name":"@ohos/photo", + "description":"photo mode", + "ohos":{ + "org":"" }, - "repository": {}, - "version": "1.0.0", - "dependencies": { - "@ohos/common": "../../common" + "repository":{}, + "version":"1.0.0", + "dependencies":{ + "@ohos/common":"../../common" } -} +} \ No newline at end of file diff --git a/features/photo/src/main/ets/photo/PhotoModeParam.ts b/features/photo/src/main/ets/photo/PhotoModeParam.ts index 6eb3cc9..20f8775 100644 --- a/features/photo/src/main/ets/photo/PhotoModeParam.ts +++ b/features/photo/src/main/ets/photo/PhotoModeParam.ts @@ -17,5 +17,5 @@ import { Constants } from '../../../../../featureservice/Constants' export class PhotoModeParam { public readonly tabBar: string[] = ['', 'flash', 'zoom', 'focus', 'setup'] - public readonly functions: string[] = [Constants.CAPTURE_FUNCTION, Constants.ZOOM_FUNCTION] + public readonly functions: string[] = [Constants.FLASH_FUNCTION, Constants.CAPTURE_FUNCTION, Constants.ZOOM_FUNCTION] } \ No newline at end of file diff --git a/features/video/package.json b/features/video/package.json index 655e217..434e701 100644 --- a/features/video/package.json +++ b/features/video/package.json @@ -1,14 +1,14 @@ { - "license": "ISC", - "devDependencies": {}, - "name": "@ohos/video", - "description": "video mode", - "ohos": { - "org": "" + "license":"ISC", + "devDependencies":{}, + "name":"@ohos/video", + "description":"video mode", + "ohos":{ + "org":"" }, - "repository": {}, - "version": "1.0.0", - "dependencies": { - "@ohos/common": "../../common" + "repository":{}, + "version":"1.0.0", + "dependencies":{ + "@ohos/common":"../../common" } -} +} \ No newline at end of file diff --git a/features/video/src/main/ets/video/VideoModeParam.ts b/features/video/src/main/ets/video/VideoModeParam.ts index cdb224b..868356c 100644 --- a/features/video/src/main/ets/video/VideoModeParam.ts +++ b/features/video/src/main/ets/video/VideoModeParam.ts @@ -17,5 +17,5 @@ import { Constants } from '../../../../../featureservice/Constants' export class VideoModeParam { public readonly tabBar: string[] = ['', '', 'zoom', 'timer', 'setup'] - public readonly functions: string[] = [Constants.RECORDING_FUNCTION, Constants.ZOOM_FUNCTION] + public readonly functions: string[] = [Constants.FLASH_FUNCTION, Constants.RECORDING_FUNCTION, Constants.ZOOM_FUNCTION] } \ No newline at end of file diff --git a/package.json b/package.json index 6af71a8..4e15c41 100644 --- a/package.json +++ b/package.json @@ -1,28 +1,28 @@ { - "license": "ISC", - "devDependencies": {}, - "name": "camera", - "ohos": { - "org": "huawei", - "directoryLevel": "project", - "buildTool": "hvigor" + "license":"ISC", + "devDependencies":{}, + "name":"camera", + "ohos":{ + "org":"huawei", + "directoryLevel":"project", + "buildTool":"hvigor" }, - "description": "example description", - "repository": {}, - "scripts": { - "tablet": "hvigor --m module --prop module=tablet assembleHap", - "phone": "hvigor --m module --prop module=phone assembleHap", - "allApp": "hvigor --mode project assembleApp", - "loadDependence": "node infra/prepare.js", - "allHap": "hvigor --mode module assembleHap" + "description":"example description", + "repository":{}, + "scripts":{ + "tablet":"hvigor --m module --prop module=tablet assembleHap", + "phone":"hvigor --m module --prop module=phone assembleHap", + "allApp":"hvigor --mode project assembleApp", + "loadDependence":"node infra/prepare.js", + "allHap":"hvigor --mode module assembleHap" }, - "version": "1.0.0", - "config": { - "unsafe-prem": true + "version":"1.0.0", + "config":{ + "unsafe-prem":true }, - "dependencies": { - "@ohos/hypium": "1.0.2", - "@ohos/hvigor-ohos-plugin": "1.2.2", - "@ohos/hvigor": "1.2.2" + "dependencies":{ + "@ohos/hypium":"1.0.2", + "@ohos/hvigor-ohos-plugin":"1.2.2", + "@ohos/hvigor":"1.2.2" } -} +} \ No newline at end of file diff --git a/product/phone/package.json b/product/phone/package.json index 2132d7f..6e620cb 100644 --- a/product/phone/package.json +++ b/product/phone/package.json @@ -1,16 +1,16 @@ { - "devDependencies": {}, - "name": "phone", - "ohos": { - "org": "huawei", - "directoryLevel": "module", - "buildTool": "hvigor" + "devDependencies":{}, + "name":"phone", + "ohos":{ + "org":"huawei", + "directoryLevel":"module", + "buildTool":"hvigor" }, - "version": "1.0.0", - "dependencies": { - "@ohos/multi": "../../features/multi", - "@ohos/common": "../../common", - "@ohos/video": "../../features/video", - "@ohos/photo": "../../features/photo" + "version":"1.0.0", + "dependencies":{ + "@ohos/multi":"../../features/multi", + "@ohos/common":"../../common", + "@ohos/video":"../../features/video", + "@ohos/photo":"../../features/photo" } -} +} \ No newline at end of file diff --git a/product/tablet/package.json b/product/tablet/package.json index 5bfa072..caa410a 100644 --- a/product/tablet/package.json +++ b/product/tablet/package.json @@ -1,16 +1,16 @@ { - "devDependencies": {}, - "name": "tablet", - "ohos": { - "org": "huawei", - "directoryLevel": "module", - "buildTool": "hvigor" + "devDependencies":{}, + "name":"tablet", + "ohos":{ + "org":"huawei", + "directoryLevel":"module", + "buildTool":"hvigor" }, - "version": "1.0.0", - "dependencies": { - "@ohos/multi": "../../features/multi", - "@ohos/common": "../../common", - "@ohos/video": "../../features/video", - "@ohos/photo": "../../features/photo" + "version":"1.0.0", + "dependencies":{ + "@ohos/multi":"../../features/multi", + "@ohos/common":"../../common", + "@ohos/video":"../../features/video", + "@ohos/photo":"../../features/photo" } -} +} \ 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 414f0b5..caca2d6 100644 --- a/product/tablet/src/main/ets/pages/PreviewAreaLand.ets +++ b/product/tablet/src/main/ets/pages/PreviewAreaLand.ets @@ -43,6 +43,7 @@ import { EventBus } from '../../../../../../common/src/main/ets/default/worker/e import EventBusManager from '../../../../../../common/src/main/ets/default/worker/eventbus/EventBusManager' import { GeoLocation } from '../../../../../../common/src/main/ets/default/featurecommon/geolocation/GeoLocation' import Trace from '../../../../../../common/src/main/ets/default/utils/Trace' +import { Tip } from '../../../../../../common/src/main/ets/default/featurecommon/tip/Tip' import ScreenLockManager from '../../../../../../common/src/main/ets/default/featurecommon/screenlock/ScreenLockManager' import prompt from '@ohos.prompt'; @@ -678,6 +679,8 @@ export struct PreviewAreaLand { .opacity(this.switchBackgroundOpacity) } + Tip() + if (this.btnSwitch) { Image($r('app.media.whitePicture')) .width(this.state.xComponentWidth) diff --git a/product/tablet/src/main/ets/pages/indexLand.ets b/product/tablet/src/main/ets/pages/indexLand.ets index e2e8244..1839b4b 100644 --- a/product/tablet/src/main/ets/pages/indexLand.ets +++ b/product/tablet/src/main/ets/pages/indexLand.ets @@ -293,8 +293,7 @@ struct Index { Column() { PreviewAreaLand({ screenSize: $screenSize }) } - .position(this.state.isThirdPartyCall ? ComponentPosition.previewTabletPosition(this.screenSize.width, this.screenSize.height, - this.state.xComponentWidth, this.state.xComponentHeight) : ComponentPosition.previewPosition(this.screenSize.width, this.screenSize.height, + .position(ComponentPosition.previewTabletPosition(this.screenSize.width, this.screenSize.height, this.state.xComponentWidth, this.state.xComponentHeight)) Column() { if ((this.state.mode === "PHOTO" || this.state.mode === "VIDEO") && this.state.cameraPosition !== 'FRONT') { @@ -304,23 +303,20 @@ struct Index { }.width(82).margin({ right: '20vp' }) } }.zIndex(2).height('100%') - .position(this.state.isThirdPartyCall ? {x: 984, y: 0} : ComponentPosition.zoomViewPosition(this.screenSize.width, this.screenSize.height, - this.state.xComponentWidth, this.state.xComponentHeight, this.state.videoState)) + .position({x: 984, y: 0}) .visibility(this.componentVisibility(!this.state.isShowPinch)) Column(){ FootBarLand({ screenSize: $screenSize }) }.zIndex(2).height('100%') - .position(this.state.isThirdPartyCall ? {x: 1124, y: 0} : ComponentPosition.footBarPosition(this.screenSize.width, this.screenSize.height, - this.state.xComponentWidth, this.state.xComponentHeight)) + .position({x: 1124, y: 0}) .visibility(this.componentVisibility(this.state.showZoomLabelValue)) Column() { TabBarLand({onBackClicked: () => this.onBackClicked(), screenSize: $screenSize}) }.zIndex(3) .visibility(this.componentVisibility(this.state.videoState === "beforeTakeVideo" && this.state.showZoomLabelValue)) - .position(this.state.isThirdPartyCall ? {x: 0, y: 44} : ComponentPosition.tabBarPosition(this.screenSize.width, this.screenSize.height, - this.state.xComponentWidth, this.state.xComponentHeight)) + .position({x: 0, y: 44}) .height(712) if (this.state.isShowMoreList) { -- Gitee