1/* 2 * Copyright (c) 2021-2023 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 * 25 * @syscap SystemCapability.Ability.Form 26 * @StageModelOnly 27 * @since 9 28 */ 29export default class FormExtensionAbility { 30 /** 31 * Indicates form extension context. 32 * 33 * @type { FormExtensionContext } 34 * @syscap SystemCapability.Ability.Form 35 * @StageModelOnly 36 * @since 9 37 */ 38 context: FormExtensionContext; 39 40 /** 41 * Called to return a {@link formBindingData#FormBindingData} object. 42 * 43 * @param { Want } want - Indicates the detailed information for creating a {@link formBindingData#FormBindingData}. 44 * The {@code Want} object must include the form ID, form name, and grid style of the form. 45 * Such form information must be managed as persistent data for further form 46 * acquisition, update, and deletion. 47 * @returns { formBindingData.FormBindingData } Returns the created {@link formBindingData#FormBindingData} object. 48 * @syscap SystemCapability.Ability.Form 49 * @StageModelOnly 50 * @since 9 51 */ 52 onAddForm(want: Want): formBindingData.FormBindingData; 53 54 /** 55 * Called when the form provider is notified that a temporary form is successfully converted to a normal form. 56 * 57 * @param { string } formId - Indicates the ID of the form. 58 * @syscap SystemCapability.Ability.Form 59 * @StageModelOnly 60 * @since 9 61 */ 62 onCastToNormalForm(formId: string): void; 63 64 /** 65 * Called to notify the form provider to update a specified form. 66 * 67 * @param { string } formId - Indicates the ID of the form to update. 68 * @syscap SystemCapability.Ability.Form 69 * @StageModelOnly 70 * @since 9 71 */ 72 onUpdateForm(formId: string): void; 73 74 /** 75 * Called when the form provider receives form events from the system. 76 * 77 * @param { object } newStatus - Indicates the form events occurred. The key in the {@code Map} 78 * object indicates the form ID, and the value indicates the event 79 * type, which can be either 80 * {@link formInfo#VisibilityType#FORM_VISIBLE} or 81 * {@link formInfo#VisibilityType#FORM_INVISIBLE}. 82 * {@link formInfo#VisibilityType#FORM_VISIBLE} means that the form becomes visible, 83 * {@link formInfo#VisibilityType#FORM_INVISIBLE} means that the form becomes 84 * invisible. 85 * @syscap SystemCapability.Ability.Form 86 * @StageModelOnly 87 * @since 9 88 */ 89 onChangeFormVisibility(newStatus: { [key: string]: number }): void; 90 91 /** 92 * Called when a specified message event defined by the form provider is triggered. This method is valid only for 93 * JS forms. 94 * 95 * @param { string } formId - Indicates the ID of the form on which the message event is triggered, which is 96 * provided by the client to the form provider. 97 * @param { string } message - Indicates the value of the {@code params} field of the message event. This parameter 98 * is used to identify the specific component on which the event is triggered. 99 * @syscap SystemCapability.Ability.Form 100 * @StageModelOnly 101 * @since 9 102 */ 103 onFormEvent(formId: string, message: string): void; 104 105 /** 106 * Called to notify the form provider that a specified form has been destroyed. Override this method if 107 * you want your application, as the form provider, to be notified of form deletion. 108 * 109 * @param { string } formId - Indicates the ID of the destroyed form. 110 * @syscap SystemCapability.Ability.Form 111 * @StageModelOnly 112 * @since 9 113 */ 114 onRemoveForm(formId: string): void; 115 116 /** 117 * Called when the system configuration is updated. 118 * 119 * @param { Configuration } newConfig - Indicates the system configuration, such as language and color mode. 120 * @syscap SystemCapability.Ability.Form 121 * @StageModelOnly 122 * @since 9 123 */ 124 onConfigurationUpdate(newConfig: Configuration): void; 125 126 /** 127 * Called to return a {@link FormState} object. 128 * <p>You must override this callback if you want this ability to return the actual form state. Otherwise, 129 * this method returns {@link FormState#DEFAULT} by default.</p> 130 * 131 * @param { Want } want - Indicates the description of the form for which the {@link formInfo#FormState} 132 * is obtained. The description covers the bundle name, ability name, module name, 133 * form name, and form dimensions. 134 * @returns { formInfo.FormState } Returns the {@link formInfo#FormState} object. 135 * @syscap SystemCapability.Ability.Form 136 * @StageModelOnly 137 * @since 9 138 */ 139 onAcquireFormState?(want: Want): formInfo.FormState; 140 141 /** 142 * Called when the system shares the form. 143 * 144 * @param { string } formId - Indicates the ID of the form. 145 * @returns { object } Returns the wantParams object. 146 * @syscap SystemCapability.Ability.Form 147 * @systemapi 148 * @StageModelOnly 149 * @since 9 150 */ 151 onShareForm?(formId: string): { [key: string]: Object }; 152 153 /** 154 * Called when the system acquire the form data. 155 * 156 * @param { string } formId - Indicates the ID of the form. 157 * @returns { object } Returns the wantParams object. 158 * @syscap SystemCapability.Ability.Form 159 * @systemapi 160 * @StageModelOnly 161 * @since 10 162 */ 163 onAcquireFormData?(formId: string): { [key: string]: Object }; 164} 165