From e291ecfb66487b3c297d4e3d29b80c94c1b4f182 Mon Sep 17 00:00:00 2001 From: Huawei_tutorials Date: Mon, 1 Sep 2025 12:31:15 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!14=20:?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E6=8B=89=E8=B5=B7=E5=9B=BE=E7=89=87picker?= =?UTF-8?q?=E7=9A=84=E5=A4=84=E7=90=86'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commons/commons/.gitignore | 6 --- commons/commons/Index.ets | 2 - commons/commons/build-profile.json5 | 10 ----- commons/commons/hvigorfile.ts | 6 --- commons/commons/oh-package.json5 | 9 ---- .../commons/src/main/ets/utils/FileUtils.ets | 39 ---------------- commons/commons/src/main/ets/utils/Logger.ets | 45 ------------------- commons/commons/src/main/module.json5 | 9 ---- .../main/resources/base/element/float.json | 8 ---- .../main/resources/base/element/string.json | 8 ---- features/home/oh-package.json5 | 4 +- .../src/main/ets/view/CommentKeyboard.ets | 26 +++-------- oh-package.json5 | 5 ++- 13 files changed, 10 insertions(+), 167 deletions(-) delete mode 100644 commons/commons/.gitignore delete mode 100644 commons/commons/Index.ets delete mode 100644 commons/commons/build-profile.json5 delete mode 100644 commons/commons/hvigorfile.ts delete mode 100644 commons/commons/oh-package.json5 delete mode 100644 commons/commons/src/main/ets/utils/FileUtils.ets delete mode 100644 commons/commons/src/main/ets/utils/Logger.ets delete mode 100644 commons/commons/src/main/module.json5 delete mode 100644 commons/commons/src/main/resources/base/element/float.json delete mode 100644 commons/commons/src/main/resources/base/element/string.json diff --git a/commons/commons/.gitignore b/commons/commons/.gitignore deleted file mode 100644 index e2713a2..0000000 --- a/commons/commons/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/commons/commons/Index.ets b/commons/commons/Index.ets deleted file mode 100644 index b4a404b..0000000 --- a/commons/commons/Index.ets +++ /dev/null @@ -1,2 +0,0 @@ -export { Logger } from './src/main/ets/utils/Logger'; -export { selectImagesFromAlbum } from './src/main/ets/utils/FileUtils' diff --git a/commons/commons/build-profile.json5 b/commons/commons/build-profile.json5 deleted file mode 100644 index 79961f9..0000000 --- a/commons/commons/build-profile.json5 +++ /dev/null @@ -1,10 +0,0 @@ -{ - "apiType": "stageMode", - "buildOption": { - }, - "targets": [ - { - "name": "default" - } - ] -} diff --git a/commons/commons/hvigorfile.ts b/commons/commons/hvigorfile.ts deleted file mode 100644 index 805c5d7..0000000 --- a/commons/commons/hvigorfile.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { harTasks } from '@ohos/hvigor-ohos-plugin'; - -export default { - system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ - plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ -} \ No newline at end of file diff --git a/commons/commons/oh-package.json5 b/commons/commons/oh-package.json5 deleted file mode 100644 index d50184a..0000000 --- a/commons/commons/oh-package.json5 +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "commons", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "Index.ets", - "author": "", - "license": "Apache-2.0", - "dependencies": {} -} diff --git a/commons/commons/src/main/ets/utils/FileUtils.ets b/commons/commons/src/main/ets/utils/FileUtils.ets deleted file mode 100644 index a9d38a3..0000000 --- a/commons/commons/src/main/ets/utils/FileUtils.ets +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2025 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 { photoAccessHelper } from '@kit.MediaLibraryKit'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { Logger } from './Logger'; - -const TAG_LOG = 'FileUtil'; - -/** - * Select a images from the album - * - * @returns {string[]} return selected image uris - */ -export function selectImagesFromAlbum(maxNumber: number = 5): Promise { - const photoPicker = new photoAccessHelper.PhotoViewPicker(); - const photoSelectOptions: photoAccessHelper.PhotoSelectOptions = { - MIMEType: photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE, - maxSelectNumber: maxNumber - }; - return photoPicker.select(photoSelectOptions).then(photoSelectResult => { - return photoSelectResult.photoUris; - }).catch((e: BusinessError) => { - Logger.error(TAG_LOG, `Failed to select images from album: ${e.code}, ${e.message}`); - return []; - }); -} \ No newline at end of file diff --git a/commons/commons/src/main/ets/utils/Logger.ets b/commons/commons/src/main/ets/utils/Logger.ets deleted file mode 100644 index c769a60..0000000 --- a/commons/commons/src/main/ets/utils/Logger.ets +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit'; - -export class Logger { - private static readonly DOMAIN: number = 0xFF00; - private static readonly TAG: string = 'com.example.customcamera'; - private static readonly PREFIX: string = '[camera-log]'; - - public static debug(logTag: string, messageFormat: string, ...args: Object[]): void { - hilog.debug(Logger.DOMAIN, Logger.TAG, `${Logger.PREFIX} ${logTag}: ${messageFormat}`, args); - } - - public static info(logTag: string, messageFormat: string, ...args: Object[]): void { - hilog.info(Logger.DOMAIN, Logger.TAG, `${Logger.PREFIX} ${logTag}: ${messageFormat}`, args); - } - - public static warn(logTag: string, messageFormat: string, ...args: Object[]): void { - hilog.warn(Logger.DOMAIN, Logger.TAG, `${Logger.PREFIX} ${logTag}: ${messageFormat}`, args); - } - - public static error(logTag: string, messageFormat: string, ...args: Object[]): void { - hilog.error(Logger.DOMAIN, Logger.TAG, `${Logger.PREFIX} ${logTag}: ${messageFormat}`, args); - } - - public static fatal(logTag: string, messageFormat: string, ...args: Object[]): void { - hilog.fatal(Logger.DOMAIN, Logger.TAG, `${Logger.PREFIX} ${logTag}: ${messageFormat}`, args); - } - - private constructor() { - } -} diff --git a/commons/commons/src/main/module.json5 b/commons/commons/src/main/module.json5 deleted file mode 100644 index 1adf09b..0000000 --- a/commons/commons/src/main/module.json5 +++ /dev/null @@ -1,9 +0,0 @@ -{ - "module": { - "name": "commons", - "type": "har", - "deviceTypes": [ - "default" - ] - } -} diff --git a/commons/commons/src/main/resources/base/element/float.json b/commons/commons/src/main/resources/base/element/float.json deleted file mode 100644 index 33ea223..0000000 --- a/commons/commons/src/main/resources/base/element/float.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "float": [ - { - "name": "page_text_font_size", - "value": "50fp" - } - ] -} diff --git a/commons/commons/src/main/resources/base/element/string.json b/commons/commons/src/main/resources/base/element/string.json deleted file mode 100644 index f51a9c8..0000000 --- a/commons/commons/src/main/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "page_show", - "value": "page from package" - } - ] -} diff --git a/features/home/oh-package.json5 b/features/home/oh-package.json5 index ddab6f1..3f480ab 100644 --- a/features/home/oh-package.json5 +++ b/features/home/oh-package.json5 @@ -5,7 +5,5 @@ "main": "Index.ets", "author": "", "license": "Apache-2.0", - "dependencies": { - "commons": "file:../../commons/commons" - } + "dependencies": {} } diff --git a/features/home/src/main/ets/view/CommentKeyboard.ets b/features/home/src/main/ets/view/CommentKeyboard.ets index f3899b6..49d0917 100644 --- a/features/home/src/main/ets/view/CommentKeyboard.ets +++ b/features/home/src/main/ets/view/CommentKeyboard.ets @@ -15,9 +15,6 @@ import { window } from "@kit.ArkUI"; import { NavigationDialog } from "./NavigationDialog"; -import { Logger, selectImagesFromAlbum } from 'commons' - -const TAG = 'CommentKeyboard'; interface OperateButton { icon: Resource @@ -62,8 +59,6 @@ export struct CommentKeyboard { @State isEmojiKeyboardVisible: boolean = false; @State isAtFriendListVisible: boolean = false; @Consume navDialogPageInfos: NavPathStack; - // When the photo picker is pulled up, the soft keyboard will also be dismissed, but no need to exit the comment page - @State isPhotoPickerVisible: boolean = false; // [Start comment_keyboard1] aboutToAppear(): void { @@ -84,7 +79,7 @@ export struct CommentKeyboard { addKeyboardHeightListener(win: window.Window) { win.on('keyboardHeightChange', height => { - Logger.info(TAG, 'keyboard height has changed', this.getUIContext().px2vp(height)); + console.info('keyboard height has changed', this.getUIContext().px2vp(height)); if (height !== 0) { this.keyboardHeight = this.getUIContext().px2vp(height); return; @@ -92,10 +87,8 @@ export struct CommentKeyboard { // [StartExclude comment_keyboard1] // if close keyboard, don't set keyboardHeight, avoid EmojiKeyboard height is 0 if (!this.isEmojiKeyboardVisible) { - // When the photo picker is pulled up, the soft keyboard will also be dismissed, but no need to exit the comment page - if (this.isPhotoPickerVisible) return; - // handle system keyboard close button click - Logger.info(TAG, 'click soft keyboard close button'); + // handle keyboard close button click + console.info('click soft keyboard close button'); this.navDialogPageInfos.pop(); } // [EndExclude comment_keyboard1] @@ -114,20 +107,11 @@ export struct CommentKeyboard { icon: this.isEmojiKeyboardVisible ? $r('app.media.keyboard_circle') : $r('app.media.face'), onClick: this.onEmojiButtonClick }, - { icon: $r('app.media.picture'), onClick: this.onPictureButtonClick }, + { icon: $r('app.media.picture') }, { icon: $r('app.media.paper_plane'), onClick: this.onSendComment } ]; } - onPictureButtonClick: () => void = () => { - this.isPhotoPickerVisible = true; - selectImagesFromAlbum(1).then(uris => { - Logger.info(TAG, JSON.stringify(uris)); - }).finally(() => { - this.isPhotoPickerVisible = false; - }); - } - // [Start comment_keyboard2] // features/home/src/main/ets/view/CommentKeyboard.ets onAtButtonClick: (event?: ClickEvent) => void = event => { @@ -178,7 +162,7 @@ export struct CommentKeyboard { richEditorSpans.push(richEditorSpan); }); // [StartExclude comment_keyboard4] - Logger.info(TAG, 'richEditorContent', JSON.stringify(richEditorSpans)); + console.info('richEditorContent', JSON.stringify(richEditorSpans)); this.navDialogPageInfos.pop(); this.navDialogPageInfos.pushPathByName('CommentSendDialog', richEditorSpans); // [EndExclude comment_keyboard4] diff --git a/oh-package.json5 b/oh-package.json5 index 0cec982..bb12751 100644 --- a/oh-package.json5 +++ b/oh-package.json5 @@ -3,5 +3,8 @@ "description": "Please describe the basic information.", "dependencies": { }, - "devDependencies": {} + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } } -- Gitee