diff --git a/cases/IME/case001/.gitignore b/cases/IME/case001/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/cases/IME/case001/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/cases/IME/case001/BuildProfile.ets b/cases/IME/case001/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a501e5ddee8ea6d28961648fc7dd314a5304bd4 --- /dev/null +++ b/cases/IME/case001/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/cases/IME/case001/Index.ets b/cases/IME/case001/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..42bf4161c271e1b14d42a7ab98c982acc9bc3592 --- /dev/null +++ b/cases/IME/case001/Index.ets @@ -0,0 +1 @@ +export { MainPage } from './src/main/ets/components/MainPage'; diff --git a/cases/IME/case001/build-profile.json5 b/cases/IME/case001/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..cda3307123ec7c43181580a86ef7e82a18319a34 --- /dev/null +++ b/cases/IME/case001/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + } + ] +} diff --git a/cases/IME/case001/consumer-rules.txt b/cases/IME/case001/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/cases/IME/case001/manifest.json b/cases/IME/case001/manifest.json new file mode 100644 index 0000000000000000000000000000000000000000..ca67fdc566eefbc5b07e433c9a89ecb06d2e0be7 --- /dev/null +++ b/cases/IME/case001/manifest.json @@ -0,0 +1,6 @@ +{ + "caseNO": "case001", + "desc": "InputMethod", + "home": "case001/home", + "dependencies": [] +} \ No newline at end of file diff --git a/cases/IME/case001/obfuscation-rules.txt b/cases/IME/case001/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/cases/IME/case001/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/cases/IME/case001/oh-package.json5 b/cases/IME/case001/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..843f2a7a434e527a3057f14d0aff026abc4a39ae --- /dev/null +++ b/cases/IME/case001/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "case001", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": { + "@hadss/dialoghub": "file:./hadss_dialog.har" + } +} diff --git a/cases/IME/case001/src/main/ets/entryability/EntryAbility.ets b/cases/IME/case001/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..37f1eeed9851be04db45ab4c8c62d7871f749b10 --- /dev/null +++ b/cases/IME/case001/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,99 @@ +/* + * 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 '@ohos.hilog'; +import Window from '@ohos.window'; +import { AbilityConstant, Permissions, Want,AbilityLifecycleCallback, UIAbility } from '@kit.AbilityKit'; +import { PreferencesHandler } from '../model/PreferencesHandler'; +import window from '@ohos.window'; +import { SysPermissionUtil } from '../common/utils/SysPermissionUtil'; +import { KeyboardAvoidMode } from '@kit.ArkUI'; + + + +export default class EntryAbility extends UIAbility { + async onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); + hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? ''); + let AbilityLifecycleCallback: AbilityLifecycleCallback = { + onAbilityCreate(ability) { + console.log(`AbilityLifecycleCallback onAbilityCreate ability: ${ability}`); + }, + onWindowStageCreate(ability, windowStage) { + console.log(`AbilityLifecycleCallback onWindowStageCreate ability: ${ability}`); + console.log(`AbilityLifecycleCallback onWindowStageCreate windowStage: ${windowStage}`); + }, + onWindowStageActive(ability, windowStage) { + console.log(`AbilityLifecycleCallback onWindowStageActive ability: ${ability}`); + console.log(`AbilityLifecycleCallback onWindowStageActive windowStage: ${windowStage}`); + }, + onWindowStageInactive(ability, windowStage) { + console.log(`AbilityLifecycleCallback onWindowStageInactive ability: ${ability}`); + console.log(`AbilityLifecycleCallback onWindowStageInactive windowStage: ${windowStage}`); + }, + onWindowStageDestroy(ability, windowStage) { + console.log(`AbilityLifecycleCallback onWindowStageDestroy ability: ${ability}`); + console.log(`AbilityLifecycleCallback onWindowStageDestroy windowStage: ${windowStage}`); + }, + onAbilityDestroy(ability) { + console.log(`AbilityLifecycleCallback onAbilityDestroy ability: ${ability}`); + }, + onAbilityForeground(ability) { + console.log(`AbilityLifecycleCallback onAbilityForeground ability: ${ability}`); + }, + onAbilityBackground(ability) { + console.log(`AbilityLifecycleCallback onAbilityBackground ability: ${ability}`); + }, + onAbilityContinue(ability) { + console.log(`AbilityLifecycleCallback onAbilityContinue ability: ${ability}`); + } + } + let applicationContext = this.context.getApplicationContext(); + applicationContext.on('abilityLifecycle', AbilityLifecycleCallback); + } + + onDestroy() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + PreferencesHandler.getInstance().release(); + } + + async onWindowStageCreate(windowStage: Window.WindowStage) { + windowStage.getMainWindowSync().setPreferredOrientation(window.Orientation.PORTRAIT); + + windowStage.on('windowStageEvent', (data) => { + console.info('cwq Succeeded in enabling the listener for window stage event changes. Data: ' + + JSON.stringify(data)); + }); + windowStage.loadContent('pages/MainSetting', (err, data) => { + if (err.code) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR); + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { + console.log('cwq onNewWant want ' + JSON.stringify(want)) + let permission = want.parameters?.permission as Permissions; + SysPermissionUtil.request(this.context, [permission], (isGranted, str, isDialogShow) => { + this.context.moveAbilityToBackground(); + }) + } +}; diff --git a/cases/IME/case001/src/main/module.json5 b/cases/IME/case001/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6e7e00b252864193e4f52abb1ea9e625df589f9b --- /dev/null +++ b/cases/IME/case001/src/main/module.json5 @@ -0,0 +1,46 @@ +{ + "module": { + "name": "case001", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ], + "requestPermissions": [ + { + "name": "ohos.permission.MICROPHONE", + "reason": "$string:entry_desc", + "usedScene": { + "when": "always" + } + }, + { + // 通过ACL申请提权 + "name": "ohos.permission.READ_PASTEBOARD", + "reason": "$string:entry_desc", + "usedScene": { + "abilities": [ + "EntryAbility" + ], + "when": "always" + } + }, + ], + "extensionAbilities": [ + { + "srcEntry": "./ets/ServiceExtAbility/InputMethodService.ets", + "name": "InputMethodAbility", + "description": "$string:extension_ability_descripter", + "type": "inputMethod", + "exported": true, + "metadata": [ + { + "name": "ohos.extension.input_method", + "resource": "$profile:input_method_config" + } + ] + } + ] + } +} diff --git a/cases/IME/case001/src/main/resources/base/profile/input_method_config.json b/cases/IME/case001/src/main/resources/base/profile/input_method_config.json new file mode 100644 index 0000000000000000000000000000000000000000..dc5ef929dfc7f168912e69171719b04277a25a80 --- /dev/null +++ b/cases/IME/case001/src/main/resources/base/profile/input_method_config.json @@ -0,0 +1,18 @@ +{ + "subtypes": [ + { + "icon": "$media:en", + "id": "InputMethodExtAbility", + "label": "$string:input_method_en", + "locale": "en-US", + "mode": "lower" + }, + { + "icon": "$media:zh", + "id": "InputMethodExtAbility1", + "label": "$string:input_method_zn", + "locale": "zh-CN", + "mode": "lower" + } + ] +} \ No newline at end of file diff --git a/cases/IME/case001/src/main/resources/base/profile/main_pages.json b/cases/IME/case001/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..960c6b5b3089ecd97e0d7c79ba6d2aeea8179075 --- /dev/null +++ b/cases/IME/case001/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,10 @@ +{ + "src": [ + "pages/SoftKeyboard", + "pages/MainSetting", + "pages/PhysicKeyboard", + "pages/AssistBar", + "pages/AdjustArea", + "pages/KeyboardSetting" + ] +} \ No newline at end of file