1/* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"), 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import formBindingData from './@ohos.app.form.formBindingData'; 17import formInfo from "./@ohos.app.form.formInfo"; 18import FormExtensionContext from "./application/FormExtensionContext"; 19import Want from './@ohos.app.ability.Want'; 20import { Configuration } from './@ohos.app.ability.Configuration'; 21 22/** 23 * class of form extension. 24 * @syscap SystemCapability.Ability.Form 25 * @StageModelOnly 26 * @since 9 27 */ 28export default class FormExtensionAbility { 29 /** 30 * Indicates form extension context. 31 * @type { FormExtensionContext } 32 * @syscap SystemCapability.Ability.Form 33 * @StageModelOnly 34 * @since 9 35 */ 36 context: FormExtensionContext; 37 38 /** 39 * Called to return a {@link formBindingData#FormBindingData} object. 40 * @param { Want } want - Indicates the detailed information for creating a {@link formBindingData#FormBindingData}. 41 * The {@code Want} object must include the form ID, form name, and grid style of the form. 42 * Such form information must be managed as persistent data for further form 43 * acquisition, update, and deletion. 44 * @returns { formBindingData.FormBindingData } Returns the created {@link formBindingData#FormBindingData} object. 45 * @syscap SystemCapability.Ability.Form 46 * @StageModelOnly 47 * @since 9 48 */ 49 onAddForm(want: Want): formBindingData.FormBindingData; 50 51 /** 52 * Called when the form provider is notified that a temporary form is successfully converted to a normal form. 53 * @param { string } formId - Indicates the ID of the form. 54 * @syscap SystemCapability.Ability.Form 55 * @StageModelOnly 56 * @since 9 57 */ 58 onCastToNormalForm(formId: string): void; 59 60 /** 61 * Called to notify the form provider to update a specified form. 62 * @param { string } formId - Indicates the ID of the form to update. 63 * @syscap SystemCapability.Ability.Form 64 * @StageModelOnly 65 * @since 9 66 */ 67 onUpdateForm(formId: string): void; 68 69 /** 70 * Called when the form provider receives form events from the system. 71 * @param { { [key: string]: number } } newStatus - Indicates the form events occurred. The key in the {@code Map} 72 * object indicates the form ID, and the value indicates the event type, which can be either 73 * {@link formInfo#VisibilityType#FORM_VISIBLE} or {@link formInfo#VisibilityType#FORM_INVISIBLE}. 74 * {@link formInfo#VisibilityType#FORM_VISIBLE} means that the form becomes visible, and 75 * {@link formInfo#VisibilityType#FORM_INVISIBLE} means that the form becomes invisible. 76 * @syscap SystemCapability.Ability.Form 77 * @StageModelOnly 78 * @since 9 79 */ 80 onChangeFormVisibility(newStatus: { [key: string]: number }): void; 81 82 /** 83 * Called when a specified message event defined by the form provider is triggered. This method is valid only for 84 * JS forms. 85 * @param { string } formId - Indicates the ID of the form on which the message event is triggered, which is 86 * provided by the client to the form provider. 87 * @param { string } message - Indicates the value of the {@code params} field of the message event. This parameter 88 * is used to identify the specific component on which the event is triggered. 89 * @syscap SystemCapability.Ability.Form 90 * @StageModelOnly 91 * @since 9 92 */ 93 onFormEvent(formId: string, message: string): void; 94 95 /** 96 * Called to notify the form provider that a specified form has been destroyed. Override this method if 97 * you want your application, as the form provider, to be notified of form deletion. 98 * @param { string } formId - Indicates the ID of the destroyed form. 99 * @syscap SystemCapability.Ability.Form 100 * @StageModelOnly 101 * @since 9 102 */ 103 onRemoveForm(formId: string): void; 104 105 /** 106 * Called when the system configuration is updated. 107 * @param { Configuration } newConfig - Indicates the system configuration, such as language and color mode. 108 * @syscap SystemCapability.Ability.Form 109 * @StageModelOnly 110 * @since 9 111 */ 112 onConfigurationUpdate(newConfig: Configuration): void; 113 114 /** 115 * Called to return a {@link FormState} object. 116 * <p>You must override this callback if you want this ability to return the actual form state. Otherwise, 117 * this method returns {@link FormState#DEFAULT} by default.</p> 118 * @param { Want } want - Indicates the description of the form for which the {@link formInfo#FormState} 119 * is obtained. The description covers the bundle name, ability name, module name, 120 * form name, and form dimensions. 121 * @returns { formInfo.FormState } Returns the {@link formInfo#FormState} object. 122 * @syscap SystemCapability.Ability.Form 123 * @StageModelOnly 124 * @since 9 125 */ 126 onAcquireFormState?(want: Want): formInfo.FormState; 127 128 /** 129 * Called when the system shares the form. 130 * @param { string } formId - Indicates the ID of the form. 131 * @returns { { [key: string]: Object } } Returns the wantParams object. 132 * @syscap SystemCapability.Ability.Form 133 * @systemapi 134 * @StageModelOnly 135 * @since 9 136 */ 137 onShareForm?(formId: string): { [key: string]: Object }; 138} 139