mirror of
https://github.com/openharmony/applications_camera.git
synced 2026-07-18 21:05:43 -04:00
@@ -714,7 +714,7 @@ export class CameraService {
|
||||
} else {
|
||||
Log.info(`${TAG} setCaptureSetting captureSetting is null.`);
|
||||
}
|
||||
Log.debug(`${TAG} setCaptureSetting invoke X.`);
|
||||
Log.info(`${TAG} setCaptureSetting invoke X.`);
|
||||
}
|
||||
|
||||
public getThumbnail(functionCallBack: FunctionCallBack): image.PixelMap {
|
||||
|
||||
@@ -106,9 +106,9 @@ export default class SaveCameraAsset {
|
||||
try {
|
||||
Log.info(`${TAG} save Picker image`);
|
||||
const file: fs.File = await fs.open(pickerUri, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
|
||||
Log.debug(`${TAG} open Picker image byteLength` + buffer.byteLength);
|
||||
Log.info(`${TAG} open Picker image byteLength` + buffer.byteLength);
|
||||
await fs.write(file.fd, buffer);
|
||||
Log.debug(`${TAG} write Picker image byteLength`);
|
||||
Log.info(`${TAG} write Picker image byteLength`);
|
||||
captureCallBack.onCaptureSuccess('thumbnail', pickerUri);
|
||||
} catch (e) {
|
||||
captureCallBack.onCaptureSuccess('thumbnail', '');
|
||||
|
||||
@@ -95,11 +95,11 @@ export class PlaySound {
|
||||
return PlaySound.sInstancePlaySound;
|
||||
}
|
||||
private playCapture(data): void {
|
||||
Log.debug(`${this.TAG} playCapture invoke E`)
|
||||
Log.info(`${this.TAG} playCapture invoke E`);
|
||||
if (this.settingManager.getCaptureMute() == Voice.SOUND) {
|
||||
this.playSound(Voice.CAPTURE_URI)
|
||||
}
|
||||
Log.debug(`${this.TAG} playCapture invoke X`)
|
||||
Log.info(`${this.TAG} playCapture invoke X`);
|
||||
}
|
||||
|
||||
private async playSound(soundUri) {
|
||||
@@ -109,7 +109,7 @@ export class PlaySound {
|
||||
this.fdPath = this.fdPath + '' + fdData
|
||||
this.mAVPlayer.url = this.fdPath
|
||||
this.fdNumber = fdData
|
||||
Log.debug(`${this.TAG} fileIO open then ${this.fdPath}`)
|
||||
Log.info(`${this.TAG} fileIO open then ${this.fdPath}`);
|
||||
}).catch((err) => {
|
||||
Log.info(`${this.TAG} open soundUri failed, err: ${err}`)
|
||||
})
|
||||
|
||||
@@ -138,11 +138,11 @@ export struct ShutterButton {
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
Log.debug(`${this.TAG} aboutToDisappear E`)
|
||||
Log.info(`${this.TAG} aboutToDisappear E`);
|
||||
this.appEventBus.off(Action.ACTION_CHANGE_MODE, (data: ModeStruct) => this.changeShutterIcon(data))
|
||||
this.appEventBus.off(Action.ACTION_UPDATE_THUMBNAIL, (data: UpdateThumbnailStruct) => this.onThumbnailUpdate(data))
|
||||
this.appEventBus.off(Action.ACTION_INIT_MODE, (data: ModeStruct) => this.changeShutterIcon(data));
|
||||
Log.debug(`${this.TAG} aboutToDisappear X`)
|
||||
Log.info(`${this.TAG} aboutToDisappear X`);
|
||||
}
|
||||
|
||||
private async onThumbnailUpdate(data: UpdateThumbnailStruct): Promise<void> {
|
||||
@@ -176,13 +176,13 @@ export struct ShutterButton {
|
||||
}
|
||||
|
||||
private async changeShutterIcon(data: ModeStruct): Promise<void> {
|
||||
Log.debug(`${this.TAG} resetShutterIcon E`)
|
||||
Log.info(`${this.TAG} resetShutterIcon E`);
|
||||
this.refreshIcon(data.mode)
|
||||
Log.debug(`${this.TAG} resetShutterIcon X`)
|
||||
Log.info(`${this.TAG} resetShutterIcon X`);
|
||||
}
|
||||
|
||||
private async refreshIcon(mode: string): Promise<void> {
|
||||
Log.debug(`${this.TAG} refreshIcon E`)
|
||||
Log.info(`${this.TAG} refreshIcon E`);
|
||||
if (mode === 'PHOTO') {
|
||||
this.mAction.updateShutterIcon($r('app.media.ic_circled_filled'))
|
||||
} else if (mode === 'VIDEO') {
|
||||
@@ -190,7 +190,7 @@ export struct ShutterButton {
|
||||
} else {
|
||||
this.mAction.updateShutterIcon($r('app.media.ic_circled_filled'))
|
||||
}
|
||||
Log.debug(`${this.TAG} refreshIcon X`)
|
||||
Log.info(`${this.TAG} refreshIcon X`);
|
||||
}
|
||||
|
||||
build() {
|
||||
|
||||
@@ -119,7 +119,7 @@ export struct ShutterButtonLand {
|
||||
private mAction: ShutterButtonDispatcher = new ShutterButtonDispatcher();
|
||||
|
||||
aboutToAppear(): void {
|
||||
Log.debug(`${this.TAG} aboutToAppear E`)
|
||||
Log.info(`${this.TAG} aboutToAppear E`);
|
||||
getStore().subscribe((state: OhCombinedState) => {
|
||||
this.state = {
|
||||
uiEnable: state.contextReducer.uiEnable,
|
||||
@@ -145,18 +145,18 @@ export struct ShutterButtonLand {
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
Log.debug(`${this.TAG} aboutToDisappear E`)
|
||||
Log.info(`${this.TAG} aboutToDisappear E`);
|
||||
this.appEventBus.off(Action.ACTION_CHANGE_MODE, (data: ModeStruct) => this.changeShutterIcon(data))
|
||||
this.appEventBus.off(Action.ACTION_UPDATE_THUMBNAIL, (data: UpdateThumbnailStruct) => this.onThumbnailUpdate(data))
|
||||
this.appEventBus.off(Action.ACTION_INIT_MODE, (data: ModeStruct) => this.changeShutterIcon(data));
|
||||
Log.debug(`${this.TAG} aboutToDisappear X`)
|
||||
Log.info(`${this.TAG} aboutToDisappear X`);
|
||||
}
|
||||
|
||||
private async onThumbnailUpdate(data: UpdateThumbnailStruct): Promise<void> {
|
||||
Log.info(`${this.TAG} onThumbnailUpdate data: ${JSON.stringify(data)} E`)
|
||||
Log.debug(`${this.TAG} onThumbnailUpdate resourceUri= ${JSON.stringify(this.state.resourceUri)} E`)
|
||||
Log.info(`${this.TAG} onThumbnailUpdate resourceUri= ${JSON.stringify(this.state.resourceUri)} E`);
|
||||
Log.info(`${this.TAG} onThumbnailUpdate isThirdPartyCall= ${this.state.isThirdPartyCall} E`)
|
||||
Log.debug(`${this.TAG} onThumbnailUpdate videoUri= ${this.state.videoUri} 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({
|
||||
@@ -175,13 +175,13 @@ export struct ShutterButtonLand {
|
||||
}
|
||||
|
||||
private async changeShutterIcon(data: ModeStruct): Promise<void> {
|
||||
Log.debug(`${this.TAG} resetShutterIcon E`)
|
||||
Log.info(`${this.TAG} resetShutterIcon E`);
|
||||
this.refreshIcon(data.mode)
|
||||
Log.debug(`${this.TAG} resetShutterIcon X`)
|
||||
Log.info(`${this.TAG} resetShutterIcon X`);
|
||||
}
|
||||
|
||||
private async refreshIcon(mode: string): Promise<void> {
|
||||
Log.debug(`${this.TAG} refreshIcon E`)
|
||||
Log.info(`${this.TAG} refreshIcon E`);
|
||||
if (mode === 'PHOTO') {
|
||||
this.mAction.updateShutterIcon($r('app.media.ic_circled_filled'))
|
||||
} else if (mode === 'VIDEO') {
|
||||
@@ -189,7 +189,7 @@ export struct ShutterButtonLand {
|
||||
} else {
|
||||
this.mAction.updateShutterIcon($r('app.media.ic_circled_filled'))
|
||||
}
|
||||
Log.debug(`${this.TAG} refreshIcon X`)
|
||||
Log.info(`${this.TAG} refreshIcon X`);
|
||||
}
|
||||
|
||||
build() {
|
||||
|
||||
@@ -25,7 +25,7 @@ export class ActionHandler {
|
||||
|
||||
// 在worker线程中通过EventBus发送action,相关后台能力需要注册对应的action.type
|
||||
public handleAction(action: ActionData): void {
|
||||
Log.debug(`${TAG} handle action: ${JSON.stringify(action)}`);
|
||||
Log.info(`${TAG} handle action: ${JSON.stringify(action)}`);
|
||||
this.appEventBus.emit(action.type, [action.data]);
|
||||
}
|
||||
}
|
||||
@@ -76,13 +76,13 @@ export class AsyncManager {
|
||||
|
||||
// 向worker线程发送消息
|
||||
public postMessage(msg: Message): void {
|
||||
Log.debug(`${TAG} postMessage`);
|
||||
Log.info(`${TAG} postMessage`);
|
||||
this.appEventBus.emit('MAIN_TO_WORKER', [msg]);
|
||||
}
|
||||
|
||||
// 接收worker线程返回的UiData
|
||||
public onMessage(msg: Message): void {
|
||||
Log.debug(`${TAG} onMessage uidata: ${JSON.stringify(msg.data)}`);
|
||||
Log.info(`${TAG} onMessage uidata: ${JSON.stringify(msg.data)}`);
|
||||
}
|
||||
|
||||
public onmessageerror(msg: Message): void {
|
||||
|
||||
@@ -31,7 +31,7 @@ export class EventBus {
|
||||
* @param callback event related callbacck
|
||||
*/
|
||||
public on(event: string | string[], callback: Callback): void {
|
||||
Log.debug(`${this.TAG} on event = ${JSON.stringify(event)} ${JSON.stringify(callback)}`);
|
||||
Log.info(`${this.TAG} on event = ${JSON.stringify(event)} ${JSON.stringify(callback)}`);
|
||||
if (Array.isArray(event)) {
|
||||
for (let i = 0, l = event.length; i < l; i++) {
|
||||
this.on(event[i], callback)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 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
|
||||
@@ -13,7 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import display from '@ohos.display';
|
||||
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';
|
||||
@@ -24,7 +23,6 @@ import {
|
||||
PersistType,
|
||||
PreferencesService
|
||||
} from '@ohos/common/src/main/ets/default/featurecommon/preferences/PreferencesService';
|
||||
import hilog from '@ohos.hilog';
|
||||
|
||||
class StateStruct {
|
||||
isThirdPartyCall: boolean = false;
|
||||
@@ -78,22 +76,20 @@ class SwipeModeIndexStruct {
|
||||
|
||||
@Component
|
||||
export struct Control {
|
||||
private TAG: string = '[Control]'
|
||||
appEventBus: EventBus = EventBusManager.getInstance().getEventBus()
|
||||
private scroller: Scroller = new Scroller()
|
||||
private modeArray: Array<string> = ['PHOTO', 'VIDEO']
|
||||
private isScroll: boolean = false
|
||||
private scrollDistance: number = 0
|
||||
private itemWidth: number = 56
|
||||
protected mPreferencesService: PreferencesService = PreferencesService.getInstance()
|
||||
@State state: StateStruct = new StateStruct()
|
||||
private TAG: string = '[Control]';
|
||||
appEventBus: EventBus = EventBusManager.getInstance().getEventBus();
|
||||
private scroller: Scroller = new Scroller();
|
||||
private modeArray: Array<string> = ['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
|
||||
@State startScroll: number = 0;
|
||||
@State endScroll: number = 0;
|
||||
@State index: number = 0;
|
||||
|
||||
aboutToAppear(): void {
|
||||
Log.info(`${this.TAG} aboutToAppear E`)
|
||||
Log.info(`${this.TAG} aboutToAppear E`);
|
||||
getStore().subscribe((state: OhCombinedState) => {
|
||||
this.state = {
|
||||
isThirdPartyCall: state.contextReducer.isThirdPartyCall,
|
||||
@@ -110,39 +106,39 @@ export struct Control {
|
||||
});
|
||||
|
||||
this.appEventBus.on(Action.ACTION_SWIPE_MODE, (data: SwipeModeIndexStruct) => this.swipeChangeMode(data));
|
||||
Log.info(`${this.TAG} aboutToAppear X`)
|
||||
Log.info(`${this.TAG} aboutToAppear X`);
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
Log.info(`${this.TAG} aboutToDisappear E`)
|
||||
this.appEventBus.off(Action.ACTION_SWIPE_MODE, (data: SwipeModeIndexStruct) => this.swipeChangeMode(data))
|
||||
Log.info(`${this.TAG} aboutToDisappear X`)
|
||||
Log.info(`${this.TAG} aboutToDisappear E`);
|
||||
this.appEventBus.off(Action.ACTION_SWIPE_MODE, (data: SwipeModeIndexStruct) => this.swipeChangeMode(data));
|
||||
Log.info(`${this.TAG} aboutToDisappear X`);
|
||||
}
|
||||
|
||||
private changeToMode(modeIndex: number): void {
|
||||
Log.debug(`${this.TAG} changeToMode modeIndex: ${modeIndex} E`)
|
||||
this.scroller.scrollToIndex(modeIndex)
|
||||
Log.info(`${this.TAG} changeToMode modeIndex: ${modeIndex} E`);
|
||||
this.scroller.scrollToIndex(modeIndex);
|
||||
if (this.modeArray[modeIndex] !== this.state.mode) {
|
||||
Log.debug(`${this.TAG} this.state.changeToMode(${this.modeArray[modeIndex]})`)
|
||||
this.mAction.changeToMode(this.modeArray[modeIndex])
|
||||
this.mPreferencesService.putModeValue(PersistType.FOR_AWHILE, modeIndex)
|
||||
this.mPreferencesService.flushMode()
|
||||
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)
|
||||
this.mAction.updateListStatus(true);
|
||||
}
|
||||
Log.debug(`${this.TAG} changeToMode X`)
|
||||
Log.info(`${this.TAG} changeToMode X`);
|
||||
}
|
||||
|
||||
private getModeFontWeight(modeIndex: number): FontWeight {
|
||||
if (this.state.mode === this.modeArray[modeIndex]) {
|
||||
return FontWeight.Bold
|
||||
return FontWeight.Bold;
|
||||
} else {
|
||||
return FontWeight.Regular
|
||||
return FontWeight.Regular;
|
||||
}
|
||||
}
|
||||
|
||||
private swipeChangeMode(data: SwipeModeIndexStruct): void {
|
||||
this.changeToMode(data.swipeModeIndex)
|
||||
this.changeToMode(data.swipeModeIndex);
|
||||
}
|
||||
|
||||
build() {
|
||||
@@ -206,15 +202,16 @@ export struct Control {
|
||||
}
|
||||
.width(this.itemWidth * 3)
|
||||
.height('100%')
|
||||
.scrollBar(BarState.Off)
|
||||
.listDirection(Axis.Horizontal)
|
||||
.edgeEffect(EdgeEffect.None)
|
||||
.chainAnimation(false)
|
||||
.enabled(this.state.uiEnable)
|
||||
.onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => {
|
||||
Log.debug(`${this.TAG} Control scroll index first: ${firstIndex}, centerIndex: ${centerIndex}, last: ${lastIndex}`)
|
||||
Log.info(`${this.TAG} Control scroll index first: ${firstIndex}, centerIndex: ${centerIndex}, last: ${lastIndex}`)
|
||||
this.index = firstIndex;
|
||||
this.mAction.updateModeIndex(firstIndex);
|
||||
Log.debug(`${this.TAG} onScrollIndex this.state.modeIndex: ${this.state.modeIndex}`)
|
||||
Log.info(`${this.TAG} onScrollIndex this.state.modeIndex: ${this.state.modeIndex}`)
|
||||
})
|
||||
.onScrollStop(() => {
|
||||
Log.info(`${this.TAG} onScrollStop`);
|
||||
|
||||
@@ -44,7 +44,7 @@ GlobalContext.get().setXComponentController(new XComponentController())
|
||||
class StateStruct {
|
||||
mode: string = 'PHOTO';
|
||||
curMode: string = 'PHOTO';
|
||||
isShowPreview: boolean = false;
|
||||
isShowPreview: boolean = true;
|
||||
surfaceId: number = 0;
|
||||
xComponentWidth: number = 0;
|
||||
xComponentHeight: number = 0;
|
||||
@@ -310,7 +310,7 @@ export struct PreviewArea {
|
||||
}
|
||||
|
||||
private async doCameraAction() {
|
||||
Log.debug(`${this.TAG} doCameraAction E`);
|
||||
Log.info(`${this.TAG} doCameraAction E`);
|
||||
this.settingManager.setCameraId(this.state.cameraPosition);
|
||||
if (this.state.curCameraPosition != this.state.cameraPosition) {
|
||||
this.mAction.switchCamera(this.state.cameraPosition);
|
||||
@@ -327,15 +327,15 @@ export struct PreviewArea {
|
||||
} else {
|
||||
this.mAction.changeZoomRatio(1);
|
||||
}
|
||||
Log.debug(`${this.TAG} doCameraAction X`);
|
||||
Log.info(`${this.TAG} doCameraAction X`);
|
||||
}
|
||||
|
||||
private async onModeChanged(data: ModeStruct): Promise<void> {
|
||||
Log.debug(`${this.TAG} onModeChanged E data.mode: ${data.mode}`);
|
||||
Log.info(`${this.TAG} onModeChanged E data.mode: ${data.mode}`);
|
||||
let xComponentSize = this.settingManager.getPreviewDisplaySize(data.mode);
|
||||
this.mAction.changeXComponentSize(xComponentSize.width, xComponentSize.height);
|
||||
this.mAction.updateShowPreviewFlag(true);
|
||||
Log.debug(`${this.TAG} onModeChanged X`);
|
||||
Log.info(`${this.TAG} onModeChanged X`);
|
||||
}
|
||||
|
||||
private async onRecordError(): Promise<void> {
|
||||
@@ -447,7 +447,7 @@ export struct PreviewArea {
|
||||
let action: string = "";
|
||||
|
||||
if (GlobalContext.get().getCameraAbilityWant()) {
|
||||
Log.debug(`${this.TAG} cameraAbilityWant: ${JSON.stringify(GlobalContext.get().getCameraAbilityWant())}`);
|
||||
Log.info(`${this.TAG} cameraAbilityWant: ${JSON.stringify(GlobalContext.get().getCameraAbilityWant())}`);
|
||||
if (GlobalContext.get().getCameraAbilityWant()?.parameters?.from) {
|
||||
from = GlobalContext.get().getCameraAbilityWant()?.parameters?.from as string;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
"metadata": [
|
||||
{
|
||||
"name": "ArkTSPartialUpdate",
|
||||
"value": "false"
|
||||
"value": "true"
|
||||
}
|
||||
],
|
||||
"requestPermissions": [
|
||||
|
||||
@@ -130,18 +130,18 @@ export struct ControlLand {
|
||||
}
|
||||
|
||||
private changeToMode(modeIndex: number, callType?: string): void {
|
||||
Log.debug(`${this.TAG} changeToMode modeIndex: ${modeIndex} E`)
|
||||
Log.info(`${this.TAG} changeToMode modeIndex: ${modeIndex} E`);
|
||||
this.scroller.scrollToIndex(modeIndex)
|
||||
if (callType === 'begin') return;
|
||||
if (this.modeArray[modeIndex] !== this.state.mode) {
|
||||
Log.debug(`${this.TAG} this.state.changeToMode(${this.modeArray[modeIndex]})`)
|
||||
Log.info(`${this.TAG} this.state.changeToMode(${this.modeArray[modeIndex]})`);
|
||||
this.mAction.changeToMode(this.modeArray[modeIndex])
|
||||
let xComponentSize = this.settingManager.getPreviewDisplaySize(this.state.mode)
|
||||
this.mAction.changeXComponentSize(xComponentSize.width, xComponentSize.height)
|
||||
this.mPreferencesService.putModeValue(PersistType.FOR_AWHILE, modeIndex)
|
||||
this.mPreferencesService.flushMode()
|
||||
}
|
||||
Log.debug(`${this.TAG} changeToMode X`)
|
||||
Log.info(`${this.TAG} changeToMode X`);
|
||||
}
|
||||
|
||||
private getModeFontWeight(modeIndex: number): FontWeight {
|
||||
@@ -262,9 +262,9 @@ export struct ControlLand {
|
||||
.edgeEffect(EdgeEffect.None)
|
||||
.chainAnimation(false)
|
||||
.onScrollIndex((firstIndex: number, lastIndex: number) => {
|
||||
Log.debug(`${this.TAG} Control scroll index first: ${firstIndex}, last: ${lastIndex}`)
|
||||
Log.info(`${this.TAG} Control scroll index first: ${firstIndex}, last: ${lastIndex}`);
|
||||
this.mAction.updateModeIndex(firstIndex)
|
||||
Log.debug(`${this.TAG} onScrollIndex this.state.modeIndex: ${this.state.modeIndex}`)
|
||||
Log.info(`${this.TAG} onScrollIndex this.state.modeIndex: ${this.state.modeIndex}`);
|
||||
})
|
||||
// .onScrollBegin(() => {
|
||||
// if (!this.touchOff) this.scrollSwitchMode('begin')
|
||||
|
||||
@@ -339,10 +339,10 @@ export struct PreviewAreaLand {
|
||||
}
|
||||
|
||||
private async onModeChanged(data: ModeData) {
|
||||
Log.debug(`${this.TAG} onModeChanged E data.mode: ${data.mode}`);
|
||||
Log.info(`${this.TAG} onModeChanged E data.mode: ${data.mode}`);
|
||||
this.mAction.changeZoomRatio(1);
|
||||
this.mAction.updateShowPreviewFlag(true);
|
||||
Log.debug(`${this.TAG} onModeChanged X`);
|
||||
Log.info(`${this.TAG} onModeChanged X`);
|
||||
}
|
||||
|
||||
private async onRecordError() {
|
||||
|
||||
Reference in New Issue
Block a user