From 907e29e9388146878bfade7b394966242eb8112f Mon Sep 17 00:00:00 2001 From: linjun9528 <423341654@qq.com> Date: Fri, 21 Jul 2023 16:19:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=A4=9A=E6=9C=BA=E4=BD=8D?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=92=8C=E4=BF=AE=E5=A4=8D=E6=97=B6=E5=BA=8F?= =?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: linjun9528 <423341654@qq.com> --- Shell/InstallRun.bat | 13 ++++ .../cameraswitcher/CameraSwitchButton.ets | 12 ---- .../default/function/CameraBasicFunction.ts | 16 +++++ .../ets/default/redux/reducers/ModeReducer.ts | 4 +- product/phone/src/main/ets/pages/Control.ets | 67 ++++--------------- .../phone/src/main/ets/pages/PreviewArea.ets | 2 +- product/phone/src/main/ets/pages/index.ets | 4 +- 7 files changed, 47 insertions(+), 71 deletions(-) create mode 100644 Shell/InstallRun.bat diff --git a/Shell/InstallRun.bat b/Shell/InstallRun.bat new file mode 100644 index 0000000..9c594e9 --- /dev/null +++ b/Shell/InstallRun.bat @@ -0,0 +1,13 @@ +set camera_phone_folder=\product\phone\build\default\outputs\default\phone-default-signed.hap + +set hdc=hdc.exe + +%hdc% shell "mount -o remount,rw /" + +%hdc% shell "rm -rf /data/*" + +%hdc% file send %camera_phone_folder% /system/app/com.ohos.camera/Camera.hap + +%hdc% shell "reboot" + +Pause \ No newline at end of file diff --git a/common/src/main/ets/default/featurecommon/cameraswitcher/CameraSwitchButton.ets b/common/src/main/ets/default/featurecommon/cameraswitcher/CameraSwitchButton.ets index 8f8c2af..ef571a1 100644 --- a/common/src/main/ets/default/featurecommon/cameraswitcher/CameraSwitchButton.ets +++ b/common/src/main/ets/default/featurecommon/cameraswitcher/CameraSwitchButton.ets @@ -116,21 +116,9 @@ export struct CameraSwitchButton { } else { globalThis.switchCameraTime = new Date().getTime() if (this.state.cameraPosition !== 'BACK') { - try { - systemparameter.setSync("persist.camera.device.cameraid", "0"); - } catch(e) { - Log.info(`${this.TAG} set unexpected error: ${JSON.stringify(e)}}`) - } - this.state.changeCameraPosition('BACK') this.storageCameraId = 'BACK' } else { - try { - systemparameter.setSync("persist.camera.device.cameraid", "1"); - } catch(e) { - Log.info(`${this.TAG} set unexpected error: ${JSON.stringify(e)}}`) - } - this.state.changeCameraPosition('FRONT') this.storageCameraId = 'FRONT' } diff --git a/common/src/main/ets/default/function/CameraBasicFunction.ts b/common/src/main/ets/default/function/CameraBasicFunction.ts index adbdba0..3b6e1ab 100644 --- a/common/src/main/ets/default/function/CameraBasicFunction.ts +++ b/common/src/main/ets/default/function/CameraBasicFunction.ts @@ -21,6 +21,7 @@ import { CameraStatus } from '../utils/Constants' import { BaseFunction } from './BaseFunction' import { FunctionCallBack } from '../camera/CameraService' import EventLog from '../utils/EventLog' +import systemparameter from '@ohos.systemParameterEnhance' export class CameraBasicFunction extends BaseFunction { private TAG = '[CameraBasicFunction]:' @@ -198,6 +199,21 @@ export class CameraBasicFunction extends BaseFunction { this.mCameraId = data.cameraId this.mCameraService.setCameraId(this.mCameraId) await this.mCameraService.releaseCamera() + + if (data.cameraId == 'BACK') { + try { + systemparameter.setSync("persist.camera.device.cameraid", "0"); + } catch(e) { + Log.info(`${this.TAG} set unexpected error: ${JSON.stringify(e)}}`) + } + }else if (data.cameraId == 'FRONT') { + try { + systemparameter.setSync("persist.camera.device.cameraid", "1"); + } catch(e) { + Log.info(`${this.TAG} set unexpected error: ${JSON.stringify(e)}}`) + } + } + await this.mCameraService.createCameraInput(this.mCameraId) if (data?.curMode && data.curMode !== undefined && data.curMode !== this.mCurrentMode){ this.mCurrentMode = data.curMode diff --git a/common/src/main/ets/default/redux/reducers/ModeReducer.ts b/common/src/main/ets/default/redux/reducers/ModeReducer.ts index 67da2d4..62973be 100644 --- a/common/src/main/ets/default/redux/reducers/ModeReducer.ts +++ b/common/src/main/ets/default/redux/reducers/ModeReducer.ts @@ -31,8 +31,8 @@ const initState: ModeState = { mode: 'PHOTO', curMode: 'PHOTO', isShowBigText: false, - modeIndex: 1, - swipeModeIndex: 1, + modeIndex: 0, + swipeModeIndex: 0, isShowMoreList: false, modeChangeDone: false, } diff --git a/product/phone/src/main/ets/pages/Control.ets b/product/phone/src/main/ets/pages/Control.ets index bfc775b..ea3d037 100644 --- a/product/phone/src/main/ets/pages/Control.ets +++ b/product/phone/src/main/ets/pages/Control.ets @@ -85,14 +85,14 @@ export struct Control { appEventBus: EventBus = EventBusManager.getInstance().getEventBus() private scroller: Scroller = new Scroller() private settingManager = SettingManager.getInstance() - private modeArray: Array = ['MULTI', 'PHOTO', 'VIDEO'] + private modeArray: Array = ['PHOTO', 'VIDEO'] private isScroll: boolean = false private scrollDistance: number = 0 protected mPreferencesService: PreferencesService = PreferencesService.getInstance() @State state: StateStruct = new StateStruct() - @State modeBarItemLeftWidth: number = 225 - @State modeBarItemRightWidth: number = 225 + @State modeBarItemLeftWidth: number = 300 + @State modeBarItemRightWidth: number = 300 @State startScroll: number = 0 @State endScroll: number = 0 @State index: number = 0 @@ -101,8 +101,8 @@ export struct Control { Log.info(`${this.TAG} aboutToAppear E`) getStore().connect(controlState, controlDispatcher)(this.state) display.getDefaultDisplay().then((dis) => { - this.modeBarItemLeftWidth = px2vp(dis.width) / 2 - 156 - this.modeBarItemRightWidth = px2vp(dis.width) / 2 - 148 + this.modeBarItemLeftWidth = px2vp(dis.width) / 2 - 84 + this.modeBarItemRightWidth = px2vp(dis.width) / 2 - 80 }) this.appEventBus.on(Action.ACTION_SWIPE_MODE, this.swipeChangeMode.bind(this)) Log.info(`${this.TAG} aboutToAppear X`) @@ -147,33 +147,18 @@ export struct Control { } private scrollSwitchMode() { - if (this.index == 1 && Math.abs(this.scrollDistance) <= px2vp(28)) { + if (this.index == 1 && this.scrollDistance >= -8) { this.changeToMode(1) } - if (this.index == 1 && (this.scrollDistance) > px2vp(28)) { - this.changeToMode(2) - } - if (this.index == 1 && (this.scrollDistance) < px2vp(-28)) { + if (this.index == 1 && this.scrollDistance < -8) { this.changeToMode(0) } - if (this.index == 0 && (this.scrollDistance < px2vp(36))) { + if (this.index == 0 && this.scrollDistance <= 8) { this.changeToMode(0) } - if (this.index == 0 && this.scrollDistance <= px2vp(92) && this.scrollDistance >= px2vp(36)) { + if (this.index == 0 && this.scrollDistance > 8) { this.changeToMode(1) } - if (this.index == 0 && this.scrollDistance > px2vp(92)) { - this.changeToMode(2) - } - if (this.index == 2 && (this.scrollDistance > px2vp(-28))) { - this.changeToMode(2) - } - if (this.index == 2 && this.scrollDistance <= px2vp(-28) && this.scrollDistance >= px2vp(-92)) { - this.changeToMode(1) - } - if (this.index == 2 && this.scrollDistance < px2vp(-92)) { - this.changeToMode(0) - } } build() { @@ -201,9 +186,6 @@ export struct Control { }.width('100%').height('100%') } else { List({ initialIndex: this.state.modeIndex, scroller: this.scroller }) { - ListItem() { - }.width(64).height('100%') - ListItem() { }.width(56).height('100%') @@ -211,7 +193,7 @@ export struct Control { }.width(this.modeBarItemLeftWidth).height('100%') ListItem() { - Text($r('app.string.multi_mode')) + Text($r('app.string.photo_mode')) .width('100%') .height('100%') .fontColor('#fff') @@ -222,20 +204,6 @@ export struct Control { .onClick(() => { this.changeToMode(0) }) - }.width(72).height('100%') - - ListItem() { - Text($r('app.string.photo_mode')) - .width('100%') - .height('100%') - .fontColor('#fff') - .fontSize($r("sys.float.ohos_id_text_size_sub_title3")) - .fontWeight(this.getModeFontWeight(1)) - .textAlign(TextAlign.Center) - .enabled(this.state.uiEnable) - .onClick(() => { - this.changeToMode(1) - }) }.width(56).height('100%') ListItem() { @@ -244,20 +212,17 @@ export struct Control { .height('100%') .fontColor('#fff') .fontSize($r("sys.float.ohos_id_text_size_sub_title3")) - .fontWeight(this.getModeFontWeight(2)) + .fontWeight(this.getModeFontWeight(1)) .textAlign(TextAlign.Center) .enabled(this.state.uiEnable) .onClick(() => { - this.changeToMode(2) + this.changeToMode(1) }) }.width(56).height('100%') ListItem() { }.width(this.modeBarItemRightWidth).height('100%') - ListItem() { - }.width(64).height('100%') - ListItem() { }.width(56).height('100%') } @@ -277,13 +242,6 @@ export struct Control { this.scrollSwitchMode() }) .onScroll((scrollOffset: number, scrollState: ScrollState) => { - if (scrollState === ScrollState.Fling) { - this.scrollDistance += px2vp(scrollOffset) - if (!this.isScroll) { - this.isScroll = true - this.state.updateListStatus(false) - } - } }) .onTouch((event: TouchEvent) => { if (event.type === TouchType.Down) { @@ -295,6 +253,7 @@ export struct Control { this.endScroll = event.touches[0].screenX this.scrollDistance = px2vp(this.startScroll - this.endScroll) this.isScroll = false + this.scrollSwitchMode() } }) } diff --git a/product/phone/src/main/ets/pages/PreviewArea.ets b/product/phone/src/main/ets/pages/PreviewArea.ets index 5560dc1..99e0b1a 100644 --- a/product/phone/src/main/ets/pages/PreviewArea.ets +++ b/product/phone/src/main/ets/pages/PreviewArea.ets @@ -274,7 +274,7 @@ export struct PreviewArea { private settingManager = SettingManager.getInstance() private pinchGestureTimer: number private baseZoom: number - private modeArray: Array = ['MULTI', 'PHOTO', 'VIDEO'] + private modeArray: Array = ['PHOTO', 'VIDEO'] private async onCameraInit(data) { Log.info(`${this.TAG} EventBus onCameraInit isShowPreview = ${this.isShowPreview} platformCapability = ${this.state.platformCapability} E`) diff --git a/product/phone/src/main/ets/pages/index.ets b/product/phone/src/main/ets/pages/index.ets index c3366bb..2c92841 100644 --- a/product/phone/src/main/ets/pages/index.ets +++ b/product/phone/src/main/ets/pages/index.ets @@ -145,7 +145,7 @@ struct Index { appEventBus: EventBus = EventBusManager.getInstance().getEventBus() @State state: StateStruct = new StateStruct() private mPlaySound: PlaySound = PlaySound.getInstance() - private modeArray: Array = ['MULTI', 'PHOTO', 'VIDEO'] + private modeArray: Array = ['PHOTO', 'VIDEO'] protected mPreferencesService: PreferencesService = PreferencesService.getInstance() aboutToAppear(): void { @@ -215,7 +215,7 @@ struct Index { }) if (!this.state.isInitiated) { - let initIndex = this.mPreferencesService.getModeValue(PersistType.FOR_AWHILE, 1) + let initIndex = this.mPreferencesService.getModeValue(PersistType.FOR_AWHILE, 0) Log.info(`${this.TAG} initModeIndex: ${initIndex}`) this.state.initMode(this.modeArray[initIndex]) this.state.updateModeIndex(initIndex) -- Gitee