From 8eeddc6a8931299c93904aa5813f970856147429 Mon Sep 17 00:00:00 2001 From: nagexiucai Date: Mon, 13 Jun 2022 10:04:55 +0800 Subject: [PATCH 1/7] Level 9 APIs for IMF of OpenHarmony. Signed-off-by: nagexiucai --- api/@ohos.inputmethod.d.ts | 31 ++++++ api/@ohos.inputmethodengine.d.ts | 170 +++++++++++++++++++++++++++++++ 2 files changed, 201 insertions(+) diff --git a/api/@ohos.inputmethod.d.ts b/api/@ohos.inputmethod.d.ts index fb1d97ce7d..7d478a1a60 100644 --- a/api/@ohos.inputmethod.d.ts +++ b/api/@ohos.inputmethod.d.ts @@ -39,10 +39,41 @@ declare namespace inputMethod { */ function getInputMethodController(): InputMethodController; + /** + * Switch input method + * @since 9 + * @param target Indicates the input method which will replace the current one + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + function switchInputMethod(target: InputMethodProperty, callback: AsyncCallback): void; + function switchInputMethod(target: InputMethodProperty): Promise; + + /** + * Get current input method + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + function getCurrentInputMethod(): InputMethodProperty; + /** * @since 8 */ interface InputMethodSetting { + /** + * List input methods + * @since 9 + * @param enable A three-state flag: + * if true, collect enabled input methods. + * if false, collect disabled input methods. + * if not given, collect all input methods. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + listInputMethod(callback: AsyncCallback>, enable?: boolean): void; + listInputMethod(enable?: boolean): Promise>; + listInputMethod(callback: AsyncCallback>): void; listInputMethod(): Promise>; diff --git a/api/@ohos.inputmethodengine.d.ts b/api/@ohos.inputmethodengine.d.ts index 332c396c47..52ed3325dc 100644 --- a/api/@ohos.inputmethodengine.d.ts +++ b/api/@ohos.inputmethodengine.d.ts @@ -14,6 +14,11 @@ */ import {AsyncCallback} from './basic'; +import Want from './@ohos.application.Want'; +import StartOptions from "./@ohos.application.StartOptions"; +import { ConnectOptions } from "./ability/connectOptions"; +import ExtensionContext from './application/ExtensionContext'; +import { ExtensionAbilityInfo } from "./bundle/extensionAbilityInfo"; /** * inputmethodengine @@ -53,6 +58,13 @@ declare namespace inputMethodEngine { const OPTION_MULTI_LINE: number; const OPTION_NO_FULLSCREEN: number; + /** + * window style for inputmethod ability. + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + const WINDOW_TYPE_INPUT_METHOD_FLOAT: number; + function getInputMethodEngine(): InputMethodEngine; function createKeyboardDelegate(): KeyboardDelegate; @@ -101,6 +113,18 @@ declare namespace inputMethodEngine { getEditorAttribute(callback: AsyncCallback): void; getEditorAttribute(): Promise; + + /** + * Move curosr from input method. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param direction Indicates the distance of cursor to be moved. + * @return - + * @StageModelOnly + */ + moveCursor(direction: number, callback: AsyncCallback): void; + moveCursor(direction: number): Promise; } interface KeyboardDelegate { @@ -130,6 +154,152 @@ declare namespace inputMethodEngine { readonly keyCode: number; readonly keyAction: number; } + + /** + * The extension context class of input method. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + class InputMethodExtensionContext extends ExtensionContext { + + /** + * Information of an extension ability. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + abilityInfo: ExtensionAbilityInfo; + + /** + * Input method extension uses this method to start a specific ability. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param want Indicates the ability to start. + * @param options Indicates the start options. + * @return - + * @StageModelOnly + */ + startAbility(want: Want, callback: AsyncCallback): void; + startAbility(want: Want, options: StartOptions, callback: AsyncCallback): void; + startAbility(want: Want, options?: StartOptions): Promise; + + /** + * Input method extension uses this method to start a specific ability with account. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param want Indicates the ability to start. + * @param accountId Indicates the accountId to start. + * @param options Indicates the start options. + * @return - + * @StageModelOnly + */ + startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback): void; + startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise; + + /** + * Connects an ability to an input method extension. + * + *

This method can be called by an ability or input method extension, but the destination of the connection must be an + * input method extension. You must implement the {@link ConnectOptions} interface to obtain the proxy of the target + * input method extension when the input method extension is connected.

+ * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param want Indicates the service extension to connect. + * @param options Indicates the callback of connection. + * @return connection id, int value. + * @StageModelOnly + */ + connectAbility(want: Want, options: ConnectOptions): number; + + /** + * Connects an ability to an input method extension with account. + * + *

This method can be called by an ability or input method extension, but the destination of the connection must be an + * input method extension. You must implement the {@link ConnectOptions} interface to obtain the proxy of the target + * input method extension when the input method extension is connected.

+ * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param want Indicates the service extension to connect. + * @param accountId Indicates the account to connect. + * @param options Indicates the callback of connection. + * @return connection id, int value. + * @StageModelOnly + */ + connectAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; + + /** + * Disconnects an ability to an input method extension, in contrast to + * {@link connectAbility}. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param connection the connection id returned from connectAbility api. + * @return - + * @StageModelOnly + */ + disconnectAbility(connection: number, callback:AsyncCallback): void; + disconnectAbility(connection: number): Promise; + + /** + * Destroy the input method extension. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @return - + * @StageModelOnly + */ + terminateSelf(callback: AsyncCallback): void; + terminateSelf(): Promise; + + } + + /** + * The extension ability class of input method. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + class InputMethodExtensionAbility { + + /** + * Indicates input method extension ability context. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + context: InputMethodExtensionContext; + + /** + * Called back when a input method extension is started for initialization. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param want Indicates the want of created service extension. + * @return - + * @StageModelOnly + */ + onCreate(want: Want): void; + + /** + * Called back before a input method extension is destroyed. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @return - + * @StageModelOnly + */ + onDestroy(): void; + + } } export default inputMethodEngine; -- Gitee From cb491321204e44df6d06203a86093fd164b5283c Mon Sep 17 00:00:00 2001 From: nagexiucai Date: Mon, 13 Jun 2022 12:10:21 +0800 Subject: [PATCH 2/7] fix style. Signed-off-by: nagexiucai --- api/@ohos.inputmethodengine.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/@ohos.inputmethodengine.d.ts b/api/@ohos.inputmethodengine.d.ts index 52ed3325dc..cfca365e6f 100644 --- a/api/@ohos.inputmethodengine.d.ts +++ b/api/@ohos.inputmethodengine.d.ts @@ -59,7 +59,7 @@ declare namespace inputMethodEngine { const OPTION_NO_FULLSCREEN: number; /** - * window style for inputmethod ability. + * The window styles for inputmethod ability. * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework */ -- Gitee From 1da32d448bd7924ab2b61aba33a48a68e12b6e8a Mon Sep 17 00:00:00 2001 From: nagexiucai Date: Wed, 15 Jun 2022 15:56:55 +0800 Subject: [PATCH 3/7] Remove unnecessary APIs and attribute of InputMethodExtensionContext. Signed-off-by: nagexiucai --- api/@ohos.inputmethodengine.d.ts | 69 -------------------------------- 1 file changed, 69 deletions(-) diff --git a/api/@ohos.inputmethodengine.d.ts b/api/@ohos.inputmethodengine.d.ts index cfca365e6f..3e6184a8d6 100644 --- a/api/@ohos.inputmethodengine.d.ts +++ b/api/@ohos.inputmethodengine.d.ts @@ -164,14 +164,6 @@ declare namespace inputMethodEngine { */ class InputMethodExtensionContext extends ExtensionContext { - /** - * Information of an extension ability. - * - * @since 9 - * @syscap SystemCapability.MiscServices.InputMethodFramework - */ - abilityInfo: ExtensionAbilityInfo; - /** * Input method extension uses this method to start a specific ability. * @@ -186,67 +178,6 @@ declare namespace inputMethodEngine { startAbility(want: Want, options: StartOptions, callback: AsyncCallback): void; startAbility(want: Want, options?: StartOptions): Promise; - /** - * Input method extension uses this method to start a specific ability with account. - * - * @since 9 - * @syscap SystemCapability.MiscServices.InputMethodFramework - * @param want Indicates the ability to start. - * @param accountId Indicates the accountId to start. - * @param options Indicates the start options. - * @return - - * @StageModelOnly - */ - startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; - startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback): void; - startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise; - - /** - * Connects an ability to an input method extension. - * - *

This method can be called by an ability or input method extension, but the destination of the connection must be an - * input method extension. You must implement the {@link ConnectOptions} interface to obtain the proxy of the target - * input method extension when the input method extension is connected.

- * - * @since 9 - * @syscap SystemCapability.MiscServices.InputMethodFramework - * @param want Indicates the service extension to connect. - * @param options Indicates the callback of connection. - * @return connection id, int value. - * @StageModelOnly - */ - connectAbility(want: Want, options: ConnectOptions): number; - - /** - * Connects an ability to an input method extension with account. - * - *

This method can be called by an ability or input method extension, but the destination of the connection must be an - * input method extension. You must implement the {@link ConnectOptions} interface to obtain the proxy of the target - * input method extension when the input method extension is connected.

- * - * @since 9 - * @syscap SystemCapability.MiscServices.InputMethodFramework - * @param want Indicates the service extension to connect. - * @param accountId Indicates the account to connect. - * @param options Indicates the callback of connection. - * @return connection id, int value. - * @StageModelOnly - */ - connectAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; - - /** - * Disconnects an ability to an input method extension, in contrast to - * {@link connectAbility}. - * - * @since 9 - * @syscap SystemCapability.MiscServices.InputMethodFramework - * @param connection the connection id returned from connectAbility api. - * @return - - * @StageModelOnly - */ - disconnectAbility(connection: number, callback:AsyncCallback): void; - disconnectAbility(connection: number): Promise; - /** * Destroy the input method extension. * -- Gitee From 5a31b8a07752efa7b302b0b77d26bca9b8cd6f6c Mon Sep 17 00:00:00 2001 From: nagexiucai Date: Thu, 23 Jun 2022 09:24:46 +0800 Subject: [PATCH 4/7] Fix the 'enable' parameter of 'InputMethodSetting.listInputMethod'. Signed-off-by: nagexiucai --- api/@ohos.inputmethod.d.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/api/@ohos.inputmethod.d.ts b/api/@ohos.inputmethod.d.ts index 7d478a1a60..8683020b08 100644 --- a/api/@ohos.inputmethod.d.ts +++ b/api/@ohos.inputmethod.d.ts @@ -64,15 +64,14 @@ declare namespace inputMethod { /** * List input methods * @since 9 - * @param enable A three-state flag: + * @param enable : * if true, collect enabled input methods. * if false, collect disabled input methods. - * if not given, collect all input methods. * @syscap SystemCapability.MiscServices.InputMethodFramework * @StageModelOnly */ - listInputMethod(callback: AsyncCallback>, enable?: boolean): void; - listInputMethod(enable?: boolean): Promise>; + listInputMethod(enable: boolean, callback: AsyncCallback>): void; + listInputMethod(enable: boolean): Promise>; listInputMethod(callback: AsyncCallback>): void; -- Gitee From b9b4432efe5144f932e6a08ea6d772e028bc58a3 Mon Sep 17 00:00:00 2001 From: nagexiucai Date: Thu, 23 Jun 2022 09:38:57 +0800 Subject: [PATCH 5/7] Fix the return type of 'switchInputMethod' and some others' return annotation. Signed-off-by: nagexiucai --- api/@ohos.inputmethod.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/@ohos.inputmethod.d.ts b/api/@ohos.inputmethod.d.ts index 8683020b08..bfa0a01f9a 100644 --- a/api/@ohos.inputmethod.d.ts +++ b/api/@ohos.inputmethod.d.ts @@ -43,15 +43,17 @@ declare namespace inputMethod { * Switch input method * @since 9 * @param target Indicates the input method which will replace the current one + * @return Success or failure * @syscap SystemCapability.MiscServices.InputMethodFramework * @StageModelOnly */ - function switchInputMethod(target: InputMethodProperty, callback: AsyncCallback): void; - function switchInputMethod(target: InputMethodProperty): Promise; + function switchInputMethod(target: InputMethodProperty, callback: AsyncCallback): boolean; + function switchInputMethod(target: InputMethodProperty): Promise; /** * Get current input method * @since 9 + * @return The InputMethodProperty object of the current input method * @syscap SystemCapability.MiscServices.InputMethodFramework * @StageModelOnly */ @@ -67,6 +69,7 @@ declare namespace inputMethod { * @param enable : * if true, collect enabled input methods. * if false, collect disabled input methods. + * @return - * @syscap SystemCapability.MiscServices.InputMethodFramework * @StageModelOnly */ -- Gitee From 6bcfefa56c6d9940ee6ab9b0cdd7d41f7e45e3d4 Mon Sep 17 00:00:00 2001 From: nagexiucai Date: Thu, 23 Jun 2022 09:45:12 +0800 Subject: [PATCH 6/7] Fix return type again. Signed-off-by: nagexiucai --- api/@ohos.inputmethod.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/@ohos.inputmethod.d.ts b/api/@ohos.inputmethod.d.ts index bfa0a01f9a..62bf8a099e 100644 --- a/api/@ohos.inputmethod.d.ts +++ b/api/@ohos.inputmethod.d.ts @@ -43,11 +43,11 @@ declare namespace inputMethod { * Switch input method * @since 9 * @param target Indicates the input method which will replace the current one - * @return Success or failure + * @return - * @syscap SystemCapability.MiscServices.InputMethodFramework * @StageModelOnly */ - function switchInputMethod(target: InputMethodProperty, callback: AsyncCallback): boolean; + function switchInputMethod(target: InputMethodProperty, callback: AsyncCallback): void; function switchInputMethod(target: InputMethodProperty): Promise; /** -- Gitee From 07ac9fa1d0bc4f32252f85242bc7659d516c0c1c Mon Sep 17 00:00:00 2001 From: nagexiucai Date: Thu, 23 Jun 2022 10:11:13 +0800 Subject: [PATCH 7/7] Fix annotations. Signed-off-by: nagexiucai --- api/@ohos.inputmethod.d.ts | 27 ++++++++++++++++++++++++++- api/@ohos.inputmethodengine.d.ts | 10 ++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/api/@ohos.inputmethod.d.ts b/api/@ohos.inputmethod.d.ts index 62bf8a099e..7a47e7b3c7 100644 --- a/api/@ohos.inputmethod.d.ts +++ b/api/@ohos.inputmethod.d.ts @@ -48,6 +48,15 @@ declare namespace inputMethod { * @StageModelOnly */ function switchInputMethod(target: InputMethodProperty, callback: AsyncCallback): void; + + /** + * Switch input method + * @since 9 + * @param target Indicates the input method which will replace the current one + * @return - + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ function switchInputMethod(target: InputMethodProperty): Promise; /** @@ -74,10 +83,26 @@ declare namespace inputMethod { * @StageModelOnly */ listInputMethod(enable: boolean, callback: AsyncCallback>): void; + + /** + * List input methods + * @since 9 + * @param enable : + * if true, collect enabled input methods. + * if false, collect disabled input methods. + * @return - + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ listInputMethod(enable: boolean): Promise>; + /** + * @since 8 + */ listInputMethod(callback: AsyncCallback>): void; - + /** + * @since 8 + */ listInputMethod(): Promise>; displayOptionalInputMethod(callback: AsyncCallback): void; diff --git a/api/@ohos.inputmethodengine.d.ts b/api/@ohos.inputmethodengine.d.ts index 3e6184a8d6..51f2366f93 100644 --- a/api/@ohos.inputmethodengine.d.ts +++ b/api/@ohos.inputmethodengine.d.ts @@ -124,6 +124,16 @@ declare namespace inputMethodEngine { * @StageModelOnly */ moveCursor(direction: number, callback: AsyncCallback): void; + + /** + * Move curosr from input method. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param direction Indicates the distance of cursor to be moved. + * @return - + * @StageModelOnly + */ moveCursor(direction: number): Promise; } -- Gitee