未验证 提交 f229c0fa 编写于 作者: O openharmony_ci 提交者: Gitee

!18908 翻译完成:18036+18502+17939 卡片请求用户自定义数据API

Merge pull request !18908 from wusongqing/TR18036
......@@ -25,7 +25,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
onAddForm(want: Want): formBindingData.FormBindingData
Called to notify the widget provider that a **Form** instance (widget) has been created.
Called to notify the widget provider that a **Form** instance (widget) is being created.
**System capability**: SystemCapability.Ability.Form
......@@ -49,7 +49,7 @@ import formBindingData from '@ohos.app.form.formBindingData';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onAddForm(want) {
console.log('FormExtensionAbility onAddForm, want: ${want.abilityName}');
console.log(`FormExtensionAbility onAddForm, want: ${want.abilityName}`);
let dataObj1 = {
temperature: '11c',
'time': '11:00'
......@@ -64,7 +64,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onCastToNormalForm(formId: string): void
Called to notify the widget provider that a temporary widget has been converted to a normal one.
Called to notify the widget provider that a temporary widget is being converted to a normal one.
**System capability**: SystemCapability.Ability.Form
......@@ -81,7 +81,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onCastToNormalForm(formId) {
console.log('FormExtensionAbility onCastToNormalForm, formId: ${formId}');
console.log(`FormExtensionAbility onCastToNormalForm, formId: ${formId}`);
}
};
```
......@@ -90,7 +90,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onUpdateForm(formId: string): void
Called to notify the widget provider that a widget has been updated. After obtaining the latest data, your application should call [updateForm](js-apis-app-form-formProvider.md#updateform) of **formProvider** to update the widget data.
Called to notify the widget provider that a widget is being updated. After obtaining the latest data, your application should call [updateForm](js-apis-app-form-formProvider.md#updateform) of **formProvider** to update the widget data.
**System capability**: SystemCapability.Ability.Form
......@@ -109,15 +109,15 @@ import formProvider from '@ohos.app.form.formProvider';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onUpdateForm(formId) {
console.log('FormExtensionAbility onUpdateForm, formId: ${formId}');
console.log(`FormExtensionAbility onUpdateForm, formId: ${formId}`);
let obj2 = formBindingData.createFormBindingData({
temperature: '22c',
time: '22:00'
});
formProvider.updateForm(formId, obj2).then((data) => {
console.log('FormExtensionAbility context updateForm, data: ${data}');
console.log(`FormExtensionAbility context updateForm, data: ${data}`);
}).catch((error) => {
console.error('Operation updateForm failed. Cause: ${error}');
console.error(`Operation updateForm failed. Cause: ${error}`);
});
}
};
......@@ -127,7 +127,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onChangeFormVisibility(newStatus: { [key: string]: number }): void
Called to notify the widget provider of the change of visibility.
Called to notify the widget provider that the widget visibility status is being changed.
**System capability**: SystemCapability.Ability.Form
......@@ -146,18 +146,18 @@ import formProvider from '@ohos.app.form.formProvider';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onChangeFormVisibility(newStatus) {
console.log('FormExtensionAbility onChangeFormVisibility, newStatus: ${newStatus}');
console.log(`FormExtensionAbility onChangeFormVisibility, newStatus: ${newStatus}`);
let obj2 = formBindingData.createFormBindingData({
temperature: '22c',
time: '22:00'
});
for (let key in newStatus) {
console.log('FormExtensionAbility onChangeFormVisibility, key: ${key}, value= ${newStatus[key]}');
console.log(`FormExtensionAbility onChangeFormVisibility, key: ${key}, value= ${newStatus[key]}`);
formProvider.updateForm(key, obj2).then((data) => {
console.log('FormExtensionAbility context updateForm, data: ${data}');
console.log(`FormExtensionAbility context updateForm, data: ${data}`);
}).catch((error) => {
console.error('Operation updateForm failed. Cause: ${error}');
console.error(`Operation updateForm failed. Cause: ${error}`);
});
}
}
......@@ -168,7 +168,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onFormEvent(formId: string, message: string): void
Called to instruct the widget provider to receive and process the widget event.
Called to instruct the widget provider to process the widget event.
**System capability**: SystemCapability.Ability.Form
......@@ -186,7 +186,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onFormEvent(formId, message) {
console.log('FormExtensionAbility onFormEvent, formId: ${formId}, message: ${message}');
console.log(`FormExtensionAbility onFormEvent, formId: ${formId}, message: ${message}`);
}
};
```
......@@ -195,7 +195,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onRemoveForm(formId: string): void
Called to notify the widget provider that a **Form** instance (widget) has been destroyed.
Called to notify the widget provider that a **Form** instance (widget) is being destroyed.
**System capability**: SystemCapability.Ability.Form
......@@ -212,7 +212,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onRemoveForm(formId) {
console.log('FormExtensionAbility onRemoveForm, formId: ${formId}');
console.log(`FormExtensionAbility onRemoveForm, formId: ${formId}`);
}
};
```
......@@ -221,7 +221,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onConfigurationUpdate(newConfig: Configuration): void;
Called when the configuration of the environment where the ability is running is updated.
Called when the configuration of the environment where the FormExtensionAbility is running is updated.
**System capability**: SystemCapability.Ability.Form
......@@ -238,7 +238,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onConfigurationUpdate(config) {
console.log('onConfigurationUpdate, config: ${JSON.stringify(config)}');
console.log(`onConfigurationUpdate, config: ${JSON.stringify(config)}`);
}
};
```
......@@ -247,7 +247,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onAcquireFormState?(want: Want): formInfo.FormState;
Called when the widget provider receives the status query result of a widget. By default, the initial state is returned.
Called to notify the widget provider that the widget host is requesting the widget state. By default, the initial state is returned.
**System capability**: SystemCapability.Ability.Form
......@@ -265,7 +265,7 @@ import formInfo from '@ohos.app.form.formInfo';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onAcquireFormState(want) {
console.log('FormExtensionAbility onAcquireFormState, want: ${want}');
console.log(`FormExtensionAbility onAcquireFormState, want: ${want}`);
return formInfo.FormState.UNKNOWN;
}
};
......@@ -275,7 +275,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onShareForm?(formId: string): { [key: string]: Object }
Called by the widget provider to receive shared widget data.
Called to notify the widget provider that the widget host is sharing the widget data.
**System API**: This is a system API.
......@@ -300,7 +300,46 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onShareForm(formId) {
console.log('FormExtensionAbility onShareForm, formId: ${formId}');
console.log(`FormExtensionAbility onShareForm, formId: ${formId}`);
let wantParams = {
'temperature': '20',
'time': '2022-8-8 09:59',
};
return wantParams;
}
};
```
## onAcquireFormData<sup>10+</sup>
onAcquireFormData?(formId: string): { [key: string]: Object }
Called to notify the widget provider that the widget host is requesting the custom data.
**System API**: This is a system API.
**System capability**: SystemCapability.Ability.Form
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| formId | string | Yes | Widget ID.|
**Return value**
| Type | Description |
| ------------------------------------------------------------ | ----------------------------------------------------------- |
| {[key: string]: any} | Custom data of the widget, in the form of key-value pairs.|
**Example**
```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onAcquireFormData(formId) {
console.log('FormExtensionAbility onAcquireFormData, formId: ${formId}');
let wantParams = {
'temperature': '20',
'time': '2022-8-8 09:59',
......
......@@ -2222,7 +2222,7 @@ try {
## getRunningFormInfosByFilter<sup>10+</sup>
function getRunningFormInfosByFilter(formProviderFilter: formInfo.FormProviderFilter): Promise&lt;Array&lt;formInfo.RunningFormInfo&gt;&gt;
getRunningFormInfosByFilter(formProviderFilter: formInfo.FormProviderFilter): Promise&lt;Array&lt;formInfo.RunningFormInfo&gt;&gt;
Obtains the information about widget hosts based on the widget provider information. This API uses a promise to return the result.
......@@ -2273,7 +2273,7 @@ try {
## getRunningFormInfosByFilter<sup>10+</sup>
function getRunningFormInfosByFilter(formProviderFilter: formInfo.FormProviderFilter, callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): void
getRunningFormInfosByFilter(formProviderFilter: formInfo.FormProviderFilter, callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): void
Obtains the information about widget hosts based on the widget provider information. This API uses an asynchronous callback to return the result.
......@@ -2321,7 +2321,7 @@ try {
## getRunningFormInfoById<sup>10+</sup>
function getRunningFormInfoById(formId: string): Promise&lt;Array&lt;formInfo.RunningFormInfo&gt;&gt;
getRunningFormInfoById(formId: string): Promise&lt;Array&lt;formInfo.RunningFormInfo&gt;&gt;
Obtains the information about widget hosts based on the widget ID. This API uses a promise to return the result.
......@@ -2366,7 +2366,7 @@ try {
## getRunningFormInfoById<sup>10+</sup>
function getRunningFormInfoById(formId: string, callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): void
getRunningFormInfoById(formId: string, callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): void
Obtains the information about widget hosts based on the widget ID. This API uses an asynchronous callback to return the result.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册