diff --git a/en/application-dev/IDL/idl-guidelines.md b/en/application-dev/IDL/idl-guidelines.md index a7ce0ec46adeeca0dd697cd8dabde834b7cc14fc..4bb2395ca2913c3cc662af154f8b9386d57336e2 100644 --- a/en/application-dev/IDL/idl-guidelines.md +++ b/en/application-dev/IDL/idl-guidelines.md @@ -162,7 +162,7 @@ Go to the local installation path, choose **toolchains > 3.x.x.x** (the folder n If the executable file does not exist, download the SDK package from the mirror as instructed in the [Release Notes](../../release-notes). The following uses [3.2 Beta3](../../release-notes/OpenHarmony-v3.2-beta3.md) as an example. -For details about how to replace the SDK package, see [Full SDK Compilation Guide](../quick-start/full-sdk-compile-guide.md). +For details about how to replace the SDK package, see [Full SDK Compilation Guide](../faqs/full-sdk-compile-guide.md). After obtaining the executable file, perform subsequent development steps based on your scenario. diff --git a/en/application-dev/application-models/Readme-EN.md b/en/application-dev/application-models/Readme-EN.md index 79230cf32f010ee568575817643996f15b0bf007..aca0bbb39f14d5110bf82d2a610eca7d8b05dd6c 100644 --- a/en/application-dev/application-models/Readme-EN.md +++ b/en/application-dev/application-models/Readme-EN.md @@ -36,9 +36,10 @@ - [Applying Custom Drawing in the Widget](arkts-ui-widget-page-custom-drawing.md) - Widget Event Development - [Widget Event Capability Overview](arkts-ui-widget-event-overview.md) - - [Redirecting to a Specified Page Through the Router Event](arkts-ui-widget-event-router.md) - - [Updating Widget Content Through FormExtensionAbility](arkts-ui-widget-event-formextensionability.md) - - [Updating Widget Content Through UIAbility](arkts-ui-widget-event-uiability.md) + - [Redirecting to a UIAbility Through the router Event](arkts-ui-widget-event-router.md) + - [Launching a UIAbility in the Background Through the call Event](arkts-ui-widget-event-call.md) + - [Updating Widget Content Through the message Event](arkts-ui-widget-event-formextensionability.md) + - [Updating Widget Content Through the router or call Event](arkts-ui-widget-event-uiability.md) - Widget Data Interaction - [Widget Data Interaction Overview](arkts-ui-widget-interaction-overview.md) - [Configuring a Widget to Update Periodically](arkts-ui-widget-update-by-time.md) diff --git a/en/application-dev/application-models/accessibilityextensionability.md b/en/application-dev/application-models/accessibilityextensionability.md index 688eaefa4bc10723d23f880dfbb4c1502cb42053..c14b4b95921f8adef52c83b20253d26b774b16fa 100644 --- a/en/application-dev/application-models/accessibilityextensionability.md +++ b/en/application-dev/application-models/accessibilityextensionability.md @@ -12,17 +12,31 @@ The **AccessibilityExtensionAbility** module provides accessibility extension ca This document is organized as follows: -- [AccessibilityExtensionAbility Development](#accessibilityextensionability-development) - - [Creating an Accessibility Extension Service](#creating-an-accessibility-extension-service) - - [Creating a Project](#creating-a-project) - - [Creating an AccessibilityExtAbility File](#creating-an-accessibilityextability-file) - - [Processing an Accessibility Event](#processing-an-accessibility-event) - - [Declaring Capabilities of Accessibility Extension Services](#declaring-capabilities-of-accessibility-extension-services) - - [Enabling a Custom Accessibility Extension Service](#enabling-a-custom-accessibility-extension-service) +- [AccessibilityExtensionAbility Overview](#accessibilityextensionability-overview) +- [Creating an Accessibility Extension Service](#creating-an-accessibility-extension-service) +- [Processing an Accessibility Event](#processing-an-accessibility-event) +- [Declaring Capabilities of Accessibility Extension Services](#declaring-capabilities-of-accessibility-extension-services) +- [Enabling a Custom Accessibility Extension Service](#enabling-a-custom-accessibility-extension-service) + +## AccessibilityExtensionAbility Overview + +Accessibility is about giving equal access to everyone so that they can access and use information equally and conveniently under any circumstances. It helps narrow the digital divide between people of different classes, regions, ages, and health status in terms of information understanding, information exchange, and information utilization, so that they can participate in social life more conveniently and enjoy the benefits of technological advances. + +AccessibilityExtensionAbility is an accessibility extension service framework. It allows you to develop your own extension services and provides a standard mechanism for exchanging information between applications and extension services. You can make use of the provided capabilities and APIs to develop accessibility features for users with disabilities or physical limitations. For example, you can develop a screen reader for users with vision impairments. + +Below shows the AccessibilityExtensionAbility framework. + +![AccessibilityFramework](figures/AccessibilityFramework.png) + +1. Accessibility app: extension service application developed based on the AccessibilityExtensionAbility framework, for example, a screen reader application. +2. Target app: application assisted by the accessibility app. +3. AccessibilityAbilityManagerService (AAMS): main service of the AccessibilityExtensionAbility framework, which is used to manage the lifecycle of accessibility apps and provide a bridge for information exchange between accessibility apps and target apps. +4. AccessibilityAbility (AAkit): ability that is used by the accessibility app to build an extension service ability operating environment and that provides interfaces for the accessibility app to query and operate the target app, including performing click/long press operations. +5. AccessibilitySystemAbilityClient (ASACkit): used by the target app to send accessibility events, such as content change events, to AAMS, and respond to the instructions (such as performing click/long press operations) sent by the accessibility app through AAMS. ## Creating an Accessibility Extension Service -You can create an accessibility extension service by creating a project from scratch or adding the service to an existing project. +You can create an accessibility extension service by creating a project from scratch or adding the service to an existing project. Only one accessibility extension service can be created for a project. ### Creating a Project @@ -40,15 +54,15 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtens class AccessibilityExtAbility extends AccessibilityExtensionAbility { onConnect() { - console.log('AccessibilityExtAbility onConnect'); + console.info('AccessibilityExtAbility onConnect'); } onDisconnect() { - console.log('AccessibilityExtAbility onDisconnect'); + console.info('AccessibilityExtAbility onDisconnect'); } onAccessibilityEvent(accessibilityEvent) { - console.log('AccessibilityExtAbility onAccessibilityEvent: ' + JSON.stringify(accessibilityEvent)); + console.info('AccessibilityExtAbility onAccessibilityEvent: ' + JSON.stringify(accessibilityEvent)); } } @@ -69,9 +83,9 @@ You can process the service logic for accessibility events in the **onAccessibil ```typescript onAccessibilityEvent(accessibilityEvent) { - console.log('AccessibilityExtAbility onAccessibilityEvent: ' + JSON.stringify(accessibilityEvent)); + console.info('AccessibilityExtAbility onAccessibilityEvent: ' + JSON.stringify(accessibilityEvent)); if (accessibilityEvent.eventType === 'pageStateUpdate') { - console.log('AccessibilityExtAbility onAccessibilityEvent: pageStateUpdate'); + console.info('AccessibilityExtAbility onAccessibilityEvent: pageStateUpdate'); // TODO: Develop custom logic. } } @@ -119,3 +133,4 @@ To enable or disable an accessibility extension service, run the following comma In the preceding commands, **AccessibilityExtAbility** indicates the name of the accessibility extension service, **com.example.demo** indicates the bundle name, and **rg** indicates the capabilities (**r** is short for retrieve). If the service is enabled or disabled successfully, the message "enable ability successfully" or "disable ability successfully" is displayed. + diff --git a/en/application-dev/application-models/arkts-ui-widget-event-call.md b/en/application-dev/application-models/arkts-ui-widget-event-call.md new file mode 100644 index 0000000000000000000000000000000000000000..073506706053e31402d7c69d645138ec7ab112cc --- /dev/null +++ b/en/application-dev/application-models/arkts-ui-widget-event-call.md @@ -0,0 +1,89 @@ +# Launching a UIAbility in the Background Through the call Event + + +There may be cases you want to provide in a widget access to features available in your application when it is running in the foreground, for example, the play, pause, and stop buttons in a music application widget. This is where the **call** capability of the **postCardAction** API comes in handy. This capability, when used in a widget, can start the specified UIAbility of the widget provider in the background. It also allows the widget to call the specified method of the application and transfer data so that the application, while in the background, can behave accordingly in response to touching of the buttons on the widget. + + +Generally, buttons are used to trigger the **call** event. Below is an example. + + +- In this example, two buttons are laid out on the widget page. When one button is clicked, the **postCardAction** API is called to send a **call** event to the target UIAbility. Note that the **method** parameter in the API indicates the method to call in the target UIAbility. It is mandatory and of the string type. + + ```ts + @Entry + @Component + struct WidgetCard { + build() { + Column() { + Button ('Feature A') + .margin('20%') + .onClick(() => { + console.info('call EntryAbility funA'); + postCardAction(this, { + 'action': 'call', + 'abilityName': 'EntryAbility', // Only the UIAbility of the current application is allowed. + 'params': { + 'method': 'funA' // Set the name of the method to call in the EntryAbility. + } + }); + }) + + Button ('Feature B') + .margin('20%') + .onClick(() => { + console.info('call EntryAbility funB'); + postCardAction(this, { + 'action': 'call', + 'abilityName': 'EntryAbility', // Only the UIAbility of the current application is allowed. + 'params': { + 'method': 'funB', // Set the name of the method to call in the EntryAbility. + 'num': 1 // Set other parameters to be transferred. + } + }); + }) + } + .width('100%') + .height('100%') + } + } + ``` + +- The UIAbility receives the **call** event and obtains the transferred parameters. It then executes the target method specified by the **method** parameter. Other data can be obtained in readString mode. Listen for the method required by the **call** event in the **onCreate** callback of the UIAbility. + + ```ts + import UIAbility from '@ohos.app.ability.UIAbility'; + + function FunACall(data) { + // Obtain all parameters transferred in the call event. + console.info('FunACall param:' + JSON.stringify(data.readString())); + return null; + } + + function FunBCall(data) { + console.info('FunACall param:' + JSON.stringify(data.readString())); + return null; + } + + export default class CameraAbility extends UIAbility { + // If the UIAbility is started for the first time, the onCreate lifecycle callback is triggered after the call event is received. + onCreate(want, launchParam) { + try { + // Listen for the method required by the call event. + this.callee.on('funA', FunACall); + this.callee.on('funB', FunBCall); + } catch (error) { + console.error(`Failed to register callee on. Cause: ${JSON.stringify(err)}`); + } + } + + // Deregister the listener when the process exits. + onDestroy() { + try { + this.callee.off('funA'); + this.callee.off('funB'); + } catch (err) { + console.error(`Failed to register callee off. Cause: ${JSON.stringify(err)}`); + } + } + }; + ``` diff --git a/en/application-dev/application-models/arkts-ui-widget-event-formextensionability.md b/en/application-dev/application-models/arkts-ui-widget-event-formextensionability.md index 861f5ca66eea9a06ee50c7b1448e1f6ed040c01a..be7761d8d78da5102afadd2c37043c228dfcd53e 100644 --- a/en/application-dev/application-models/arkts-ui-widget-event-formextensionability.md +++ b/en/application-dev/application-models/arkts-ui-widget-event-formextensionability.md @@ -1,7 +1,7 @@ -# Updating Widget Content Through FormExtensionAbility +# Updating Widget Content Through the message Event -On the widget page, the **postCardAction** API can be used to trigger a message event to the FormExtensionAbility, which then updates the widget content. The following is an example of this widget update mode. +On the widget page, the **postCardAction** API can be used to trigger a message event to start a FormExtensionAbility, which then updates the widget content. The following is an example of this widget update mode. - On the widget page, register the **onClick** event callback of the button and call the **postCardAction** API in the callback to trigger the event to the FormExtensionAbility. @@ -57,10 +57,10 @@ On the widget page, the **postCardAction** API can be used to trigger a message }) } - // ... + ... } ``` The figure below shows the effect. - + ![WidgetUpdatePage](figures/WidgetUpdatePage.png) diff --git a/en/application-dev/application-models/arkts-ui-widget-event-overview.md b/en/application-dev/application-models/arkts-ui-widget-event-overview.md index fbc77b97a27b52b0f7b2a3b0cebc5b5cb5940f72..ed029fc3017d00a7d4c2cf14e1b905139bd7eb49 100644 --- a/en/application-dev/application-models/arkts-ui-widget-event-overview.md +++ b/en/application-dev/application-models/arkts-ui-widget-event-overview.md @@ -1,40 +1,31 @@ # Widget Event Capability Overview - The ArkTS widget provides the **postCardAction()** API for interaction between the widget internal and the provider application. Currently, this API supports the router, message, and call events and can be called only in the widget. - ![WidgetPostCardAction](figures/WidgetPostCardAction.png) +**Definition**: postCardAction(component: Object, action: Object): void -Definition: postCardAction(component: Object, action: Object): void - - -Parameters: - +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | component | Object | Yes| Instance of the current custom component. Generally, **this** is transferred.| | action | Object | Yes| Action description. For details, see the following table.| +**Description of the action parameter** -Description of the action parameter - - -| **Key** | **Value** | Description| +| Key | Value | Description| | -------- | -------- | -------- | -| "action" | string | Action type.
- **"router"**: application redirection. If this type of action is triggered, the corresponding UIAbility is displayed. Only the UIAbility of the current application can be displayed.
- **"message"**: custom message. If this type of action is triggered, the [onFormEvent()](../reference/apis/js-apis-app-form-formExtensionAbility.md#onformevent) lifecycle callback of the provider FormExtensionAbility is called.
- **"call"**: application startup in the background. If this type of action is triggered, the corresponding UIAbility is started but does not run in the foreground. The target application must have the permission to run in the background ([ohos.permission.KEEP_BACKGROUND_RUNNING](../security/permission-list.md#ohospermissionkeep_background_running)).| +| "action" | string | Action type.
- **"router"**: redirection to the specified UIAbility of the widget provider.
- **"message"**: custom message. If this type of action is triggered, the [onFormEvent()](../reference/apis/js-apis-app-form-formExtensionAbility.md#onformevent) lifecycle callback of the provider FormExtensionAbility is called.
- **"call"**: launch of the widget provider in the background. If this type of action is triggered, the specified UIAbility of the widget provider is started in the background, but not displayed in the foreground. This action type requires that the widget provider should have the [ohos.permission.KEEP_BACKGROUND_RUNNING](../security/permission-list.md#ohospermissionkeep_background_running) permission.| | "bundleName" | string | Name of the target bundle when **action** is **"router"** or **"call"**. This parameter is optional.| | "moduleName" | string | Name of the target module when **action** is **"router"** or **"call"**. This parameter is optional.| | "abilityName" | string | Name of the target UIAbility when **action** is **"router"** or **"call"**. This parameter is mandatory.| -| "params" | Object | Additional parameters carried in the current action. The value is a key-value pair in JSON format.| +| "params" | Object | Additional parameters carried in the current action. The value is a key-value pair in JSON format. For the **"call"** action type, the **method** parameter must be set and its value type must be string. This parameter is mandatory.| Sample code of the **postCardAction()** API: - - ```typescript Button ('Jump') .width('40%') @@ -45,18 +36,26 @@ Button ('Jump') 'bundleName': 'com.example.myapplication', 'abilityName': 'EntryAbility', 'params': { - 'message': 'testForRouter' // Customize the message to be sent. + 'message': 'testForRouter' // Customize the message to send. } }); }) -``` - - -The following are typical widget development scenarios that can be implemented through widget events: +Button ('Start in Background') + .width('40%') + .height('20%') + .onClick(() => { + postCardAction(this, { + 'action': 'call', + 'bundleName': 'com.example.myapplication', + 'abilityName': 'EntryAbility', + 'params': { + 'method': 'fun', // Set the name of the method to call. It is mandatory. + 'message': 'testForcall' // Customize the message to send. + } + }); + }) +``` -- [Updating Widget Content Through FormExtensionAbility](arkts-ui-widget-event-formextensionability.md) - -- [Updating Widget Content Through UIAbility](arkts-ui-widget-event-uiability.md) -- [Redirecting to a Specified Page Through the Router Event](arkts-ui-widget-event-router.md) +Read on to learn the typical widget development scenarios that can be implemented through widget events. diff --git a/en/application-dev/application-models/arkts-ui-widget-event-router.md b/en/application-dev/application-models/arkts-ui-widget-event-router.md index 371cbc6b2729a7985ed2fd183297ed771fddb11d..733ff7f59b57ec4295fa21cb4d83ae8a5b2b8eb4 100644 --- a/en/application-dev/application-models/arkts-ui-widget-event-router.md +++ b/en/application-dev/application-models/arkts-ui-widget-event-router.md @@ -1,8 +1,6 @@ -# Redirecting to a Specified Page Through the Router Event - - -The **router** capability of the **postCardAction** API can be used in a widget to quickly start the widget provider application. An application can provide different buttons through the widget so that users can jump to different pages at the touch of a button. For example, a camera widget provides the buttons that direct the user to respective pages, such as the page for taking a photo and the page for recording a video. +# Redirecting to a UIAbility Through the router Event +The **router** capability of the **postCardAction** API can be used in a widget to quickly start a specific UIAbility of the widget provider. By leveraging this capability, an application can provide in the widget multiple buttons, each of which targets a different target UIAbility. For example, a camera widget can provide the buttons that redirect the user to the UIAbility for taking a photo and the UIAbility for recording a video. ![WidgerCameraCard](figures/WidgerCameraCard.png) diff --git a/en/application-dev/application-models/arkts-ui-widget-event-uiability.md b/en/application-dev/application-models/arkts-ui-widget-event-uiability.md index 0d6cb33a3749c81b6b41dd4904ba64c89a7942ae..ca66e20aa2d258a0e05002296dac39c19ac131c3 100644 --- a/en/application-dev/application-models/arkts-ui-widget-event-uiability.md +++ b/en/application-dev/application-models/arkts-ui-widget-event-uiability.md @@ -1,10 +1,11 @@ -# Updating Widget Content Through UIAbility +# Updating Widget Content Through the router or call Event -On the widget page, the **postCardAction** API can be used to trigger a router or call event to start the UIAbility, which then updates the widget content. The following is an example of this widget update mode. +On the widget page, the **postCardAction** API can be used to trigger a router or call event to start a UIAbility, which then updates the widget content. The following is an example of this widget update mode. +## Updating Widget Content Through the router Event -- On the widget page, register the **onClick** event callback of the button and call the **postCardAction** API in the callback to trigger the event to the FormExtensionAbility. +- On the widget page, register the **onClick** event callback of the button and call the **postCardAction** API in the callback to trigger the **router** event to the FormExtensionAbility. ```ts let storage = new LocalStorage(); @@ -84,3 +85,104 @@ On the widget page, the **postCardAction** API can be used to trigger a router o ... } ``` + +## Updating Widget Content Through the call Event + +- When using the **call** event of the **postCardAction** API, the value of **formId** must be updated in the **onAddForm** callback of the FormExtensionAbility. + + ```ts + import formBindingData from '@ohos.app.form.formBindingData'; + import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; + + export default class EntryFormAbility extends FormExtensionAbility { + onAddForm(want) { + let formId = want.parameters["ohos.extra.param.key.form_identity"]; + let dataObj1 = { + "formId": formId + }; + let obj1 = formBindingData.createFormBindingData(dataObj1); + return obj1; + } + + ... + }; + ``` + +- On the widget page, register the **onClick** event callback of the button and call the **postCardAction** API in the callback to trigger the event to the UIAbility. + + ```ts + let storage = new LocalStorage(); + @Entry(storage) + @Component + struct WidgetCard { + @LocalStorageProp('detail') detail: string = 'init'; + @LocalStorageProp('formId') formId: string = '0'; + + build() { + Column() { + Button ('Start in Background') + .margin('20%') + .onClick(() => { + console.info('postCardAction to EntryAbility'); + postCardAction(this, { + 'action': 'call', + 'abilityName': 'EntryAbility', // Only the UIAbility of the current application is allowed. + 'params': { + 'method': 'funA', + 'formId': this.formId, + 'detail': 'CallFromCard' + } + }); + }) + Text(`${this.detail}`).margin('20%') + } + .width('100%') + .height('100%') + } + } + ``` + +- Listen for the method required by the **call** event in the **onCreate** callback of the UIAbility, and then call the [updateForm](../reference/apis/js-apis-app-form-formProvider.md#updateform) API in the corresponding method to update the widget. + + ```ts + import UIAbility from '@ohos.app.ability.UIAbility'; + import formBindingData from '@ohos.app.form.formBindingData'; + import formProvider from '@ohos.app.form.formProvider'; + import formInfo from '@ohos.app.form.formInfo'; + + const MSG_SEND_METHOD: string = 'funA'; + + // After the call event is received, the method listened for by the callee is triggered. + function FunACall(data) { + // Obtain all parameters transferred in the call event. + let params = JSON.parse(data.readString()) + if (params.formId !== undefined) { + let curFormId = params.formId; + let message = params.detail; + console.info(`UpdateForm formId: ${curFormId}, message: ${message}`); + let formData = { + "detail": message + }; + let formMsg = formBindingData.createFormBindingData(formData) + formProvider.updateForm(curFormId, formMsg).then((data) => { + console.info('updateForm success.' + JSON.stringify(data)); + }).catch((error) => { + console.error('updateForm failed:' + JSON.stringify(error)); + }) + } + return null; + } + export default class EntryAbility extends UIAbility { + // If the UIAbility is started for the first time, the onCreate lifecycle callback is triggered after the call event is received. + onCreate(want, launchParam) { + console.info('Want:' + JSON.stringify(want)); + try { + // Listen for the method required by the call event. + this.callee.on(MSG_SEND_METHOD, FunACall); + } catch (error) { + console.info(`${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`) + } + } + ... + } + ``` diff --git a/en/application-dev/application-models/arkts-ui-widget-image-update.md b/en/application-dev/application-models/arkts-ui-widget-image-update.md index 4862fbf747c0275d179eb4a2f988280379f2d262..dfe6dbf0e9249c66c3fb1d0723f1c7b296443381 100644 --- a/en/application-dev/application-models/arkts-ui-widget-image-update.md +++ b/en/application-dev/application-models/arkts-ui-widget-image-update.md @@ -1,10 +1,10 @@ # Updating Local and Online Images in the Widget -Generally, local images or online images downloaded from the network need to be displayed on a widget. To obtain local and online images, use the FormExtensionAbility. The following exemplifies how to show local and online images on a widget. +Typically, a widget includes local images or online images downloaded from the network. To obtain local and online images, use the FormExtensionAbility. The following exemplifies how to show local and online images on a widget. -1. Internet access is required for downloading online images. Therefore, you need to apply for the **ohos.permission.INTERNET** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md). +1. For the widget to download online images, declare the **ohos.permission.INTERNET** permission for the widget. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md). 2. Update local files in the **onAddForm** lifecycle callback of the EntryFormAbility. @@ -44,7 +44,7 @@ Generally, local images or online images downloaded from the network need to be } ``` -3. Update online files in the onFormEvent lifecycle callback of the EntryFormAbility. +3. Update online images in the **onFormEvent** lifecycle callback of the EntryFormAbility. ```ts import formBindingData from '@ohos.app.form.formBindingData'; @@ -60,8 +60,8 @@ Generally, local images or online images downloaded from the network need to be 'text': 'Updating...' }) formProvider.updateForm(formId, formInfo) - // Note: The FormExtensionAbility is started when the lifecycle callback is triggered. It can run in the background for only 5 seconds. - // When possible, limit the size of the image to download. If an image cannot be downloaded within 5 seconds, it cannot be updated to the widget page. + // Note: After being started with the triggering of the lifecycle callback, the FormExtensionAbility can run in the background for only 5 seconds. + // When possible, limit the size of the image to download. If an image cannot be downloaded within 5 seconds, it will not be updated to the widget page. let netFile = 'https://xxxx/xxxx.png'; // Specify the URL of the image to download. let tempDir = this.context.getApplicationContext().tempDir; let fileName = 'file' + Date.now(); @@ -161,6 +161,6 @@ Generally, local images or online images downloaded from the network need to be ``` > **NOTE** -> - The **\** component displays images in the remote memory based on the **memory://** identifier in the input parameter (**memory://fileName**). The **fileName** value must be consistent with the key in the object (**'formImages': {key: fd}**) passed by the EntryFormAbility. +> - The **\** component displays images in the remote memory based on the **memory://** identifier in the input parameter (**memory://fileName**). The value of **fileName** must be consistent with the key in the object (**'formImages': {key: fd}**) passed by the EntryFormAbility. > -> - The **\** component determines whether to update the image based on whether the input parameter is changed. Therefore, the value of **imgName** passed by the EntryFormAbility each time must be different. If the two values of **imgName** passed consecutively are identical, the image is not updated. +> - The **\** component determines whether to update the image by comparing the values of **imgName** consecutively passed by the EntryFormAbility. It updates the image only when the values are different. diff --git a/en/application-dev/application-models/arkts-ui-widget-lifecycle.md b/en/application-dev/application-models/arkts-ui-widget-lifecycle.md index 4cb68536312e26e0f7c98546839134c0ab435a8c..fb25fd362f67646d65853b870a6a9cb518c4d760 100644 --- a/en/application-dev/application-models/arkts-ui-widget-lifecycle.md +++ b/en/application-dev/application-models/arkts-ui-widget-lifecycle.md @@ -92,4 +92,5 @@ When creating an ArkTS widget, you need to implement the [FormExtensionAbility]( > **NOTE** -> The FormExtensionAbility cannot reside in the background. Therefore, continuous tasks cannot be processed in the widget lifecycle callbacks. The FormExtensionAbility persists for 5 seconds after the lifecycle callback is completed and will exit if no new lifecycle callback is invoked during this time frame. For the service logic that may take more than 5 seconds to complete, it is recommended that you [start the application](arkts-ui-widget-event-uiability.md). After the processing is complete, use the [updateForm](../reference/apis/js-apis-app-form-formProvider.md#updateform) to notify the widget of the update. +> +> The FormExtensionAbility cannot reside in the background. It persists for 5 seconds after the lifecycle callback is completed and exist if no new lifecycle callback is invoked during this time frame. This means that continuous tasks cannot be processed in the widget lifecycle callbacks. For the service logic that may take more than 5 seconds to complete, it is recommended that you [start the application](arkts-ui-widget-event-uiability.md) for processing. After the processing is complete, use [updateForm()](../reference/apis/js-apis-app-form-formProvider.md#updateform) to notify the widget of the update. diff --git a/en/application-dev/application-models/arkts-ui-widget-modules.md b/en/application-dev/application-models/arkts-ui-widget-modules.md index 5084b7ea5045002759ca57f10c055ef5623eb7d0..b9a411426db84a4c1af12e70eab956adc8f25806 100644 --- a/en/application-dev/application-models/arkts-ui-widget-modules.md +++ b/en/application-dev/application-models/arkts-ui-widget-modules.md @@ -1,7 +1,7 @@ # ArkTS Widget Related Modules +**Figure 1** ArkTS widget related modules - **Figure 1** ArkTS widget related modules ![WidgetModules](figures/WidgetModules.png) @@ -15,10 +15,10 @@ - [formBindingData](../reference/apis/js-apis-app-form-formBindingData.md): provides APIs for widget data binding. You can use the APIs to create a **FormBindingData** object and obtain related information. -- [Page Layout (Card.ets)](arkts-ui-widget-page-overview.md): provides APIs for a declarative paradigm UI. - - [ArkTS widget capabilities](arkts-ui-widget-event-overview.md): include the **postCardAction** API used for interaction between the widget internal and the provider application and can be called only in the widget. - - [ArkTS widget capability list](arkts-ui-widget-page-overview.md#page-capabilities-supported-by-arkts-widgets): lists the APIs, components, events, attributes, and lifecycle callbacks that can be used in ArkTS widgets. +- [Page layout (Card.ets)](arkts-ui-widget-page-overview.md): provides APIs for a declarative paradigm UI. + - [Capabilities exclusive to ArkTS widgets](arkts-ui-widget-event-overview.md): include the **postCardAction** API used for interaction between the widget internal and the provider application and can be called only in the widget. + - [ArkTS widget capability list](arkts-ui-widget-page-overview.md#page-capabilities-supported-by-arkts-widgets): contain the APIs, components, events, attributes, and lifecycle callbacks that can be used in ArkTS widgets. - [Widget configuration](arkts-ui-widget-configuration.md): includes FormExtensionAbility configuration and widget configuration. - - Configure FormExtensionAbility information under **extensionAbilities** in the [module.json5 file](../quick-start/module-configuration-file.md). + - Configure the FormExtensionAbility information under **extensionAbilities** in the [module.json5 file](../quick-start/module-configuration-file.md). - Configure the widget configuration information (**WidgetCard.ets**) in the [form_config.json](arkts-ui-widget-configuration.md) file in **resources/base/profile**. diff --git a/en/application-dev/application-models/arkts-ui-widget-page-animation.md b/en/application-dev/application-models/arkts-ui-widget-page-animation.md index 9a940aeecb62682a185ba8c0529adc38017c8e2d..0cb8e356c61155d367e55c0f39bbf491d03e2e12 100644 --- a/en/application-dev/application-models/arkts-ui-widget-page-animation.md +++ b/en/application-dev/application-models/arkts-ui-widget-page-animation.md @@ -1,10 +1,10 @@ # Using Animations in the Widget -To make your ArkTS widget more engaging, you can apply animations to it, including [explicit animation](../reference/arkui-ts/ts-explicit-animation.md), [attribute animation](../reference/arkui-ts/ts-animatorproperty.md), and [component transition](../reference/arkui-ts/ts-transition-animation-component.md). Note the following restrictions when using the animations in ArkTS widgets. +To make your ArkTS widget more engaging, you can apply animations to it, including [explicit animation](../reference/arkui-ts/ts-explicit-animation.md), [attribute animation](../reference/arkui-ts/ts-animatorproperty.md), and [component transition](../reference/arkui-ts/ts-transition-animation-component.md). Just note the following restrictions when using the animations in ArkTS widgets. - **Table 1** Restrictions on animation parameters +**Table 1** Restrictions on animation parameters | Name| Description| Description| | -------- | -------- | -------- | @@ -13,14 +13,10 @@ To make your ArkTS widget more engaging, you can apply animations to it, includi | delay | Animation delay duration.| Do not set this parameter in the widget. Use the default value 0.| | iterations | Number of times that the animation is played.| Do not set this parameter in the widget. Use the default value 1.| - The following sample code implements the animation effect of button rotation: - ![WidgetAnimation](figures/WidgetAnimation.gif) - - ```ts @Entry @Component diff --git a/en/application-dev/application-models/arkts-ui-widget-page-custom-drawing.md b/en/application-dev/application-models/arkts-ui-widget-page-custom-drawing.md index 49523d60af886db40b55fc90d80c9bd5027cade8..a55cb9cd17cda67cc2989e5916db19c5cf36cc47 100644 --- a/en/application-dev/application-models/arkts-ui-widget-page-custom-drawing.md +++ b/en/application-dev/application-models/arkts-ui-widget-page-custom-drawing.md @@ -1,9 +1,9 @@ # Applying Custom Drawing in the Widget - You can apply custom drawing in your ArkTS widget to create a more vibrant experience. Use the [Canvas](../reference/arkui-ts/ts-components-canvas-canvas.md) component to create a canvas on the widget, and then use the [CanvasRenderingContext2D](../reference/arkui-ts/ts-canvasrenderingcontext2d.md) object to draw custom graphics on the canvas. The following code shows how to draw a smiling face in the center of the canvas. +You can apply custom drawing in your ArkTS widget to create a more vibrant experience. Use the [Canvas](../reference/arkui-ts/ts-components-canvas-canvas.md) component to create a canvas on the widget, and then use the [CanvasRenderingContext2D](../reference/arkui-ts/ts-canvasrenderingcontext2d.md) object to draw custom graphics on the canvas. The following code snippet draws a smiling face in the center of a canvas. -```typescript +```ts @Entry @Component struct Card { @@ -30,41 +30,41 @@ struct Card { this.context.fillRect(0, 0, this.canvasWidth, this.canvasHeight); // Draw a red circle in the center of the canvas. this.context.beginPath(); - let radius = this.context.width / 3 - let circleX = this.context.width / 2 - let circleY = this.context.height / 2 + let radius = this.context.width / 3; + let circleX = this.context.width / 2; + let circleY = this.context.height / 2; this.context.moveTo(circleX - radius, circleY); this.context.arc(circleX, circleY, radius, 2 * Math.PI, 0, true); this.context.closePath(); this.context.fillStyle = 'red'; this.context.fill(); // Draw the left eye of the smiling face. - let leftR = radius / 4 - let leftX = circleX - (radius / 2) - let leftY = circleY - (radius / 3.5) + let leftR = radius / 4; + let leftX = circleX - (radius / 2); + let leftY = circleY - (radius / 3.5); this.context.beginPath(); this.context.arc(leftX, leftY, leftR, 0, Math.PI, true); - this.context.strokeStyle = '#ffff00' - this.context.lineWidth = 10 - this.context.stroke() + this.context.strokeStyle = '#ffff00'; + this.context.lineWidth = 10; + this.context.stroke(); // Draw the right eye of the smiling face. - let rightR = radius / 4 - let rightX = circleX + (radius / 2) - let rightY = circleY - (radius / 3.5) + let rightR = radius / 4; + let rightX = circleX + (radius / 2); + let rightY = circleY - (radius / 3.5); this.context.beginPath(); this.context.arc(rightX, rightY, rightR, 0, Math.PI, true); - this.context.strokeStyle = '#ffff00' - this.context.lineWidth = 10 - this.context.stroke() + this.context.strokeStyle = '#ffff00'; + this.context.lineWidth = 10; + this.context.stroke(); // Draw the mouth of the smiling face. - let mouthR = radius / 2.5 - let mouthX = circleX - let mouthY = circleY + (radius / 3) + let mouthR = radius / 2.5; + let mouthX = circleX; + let mouthY = circleY + (radius / 3); this.context.beginPath(); this.context.arc(mouthX, mouthY, mouthR, Math.PI, 0, true); - this.context.strokeStyle = '#ffff00' - this.context.lineWidth = 10 - this.context.stroke() + this.context.strokeStyle = '#ffff00'; + this.context.lineWidth = 10; + this.context.stroke(); }) } }.height('100%').width('100%') @@ -72,8 +72,6 @@ struct Card { } ``` - The figure below shows the effect. - -![WidgetCanvasDemo](figures/WidgetCanvasDemo.jpeg) +![WidgetCanvasDemo](figures/WidgetCanvasDemo.png) \ No newline at end of file diff --git a/en/application-dev/application-models/arkts-ui-widget-update-by-status.md b/en/application-dev/application-models/arkts-ui-widget-update-by-status.md index 8952b8dff4ecdd3acad6b1a65513d8e529c4dc70..b27958c66d3e174a66c80c90e46cdd71f5ecf668 100644 --- a/en/application-dev/application-models/arkts-ui-widget-update-by-status.md +++ b/en/application-dev/application-models/arkts-ui-widget-update-by-status.md @@ -1,7 +1,7 @@ # Updating Widget Content by State -Multiple widgets of the same application can be configured to implement different features. For example, two weather widgets can be added to the home screen: one for displaying the weather of London, and the other Beijing. The widget is set to be updated at 07:00 every morning. It needs to detect the configured city, and then updates the city-specific weather information. The following example describes how to dynamically update the widget content based on the state. +There are cases where multiple copies of the same widget are added to the home screen to accommodate different needs. In these cases, the widget content needs to be dynamically updated based on the state. This topic exemplifies how this is implemented. In the following example, two weather widgets are added to the home screen: one for displaying the weather of London, and the other Beijing, both configured to be updated at 07:00 every morning. The widget provider detects the target city, and then displays the city-specific weather information on the widgets. - Widget configuration file: Configure the widget to be updated at 07:00 every morning. @@ -74,7 +74,7 @@ Multiple widgets of the same application can be configured to implement differen } Row() {// Content that is updated only in state A - Text('State A: ') + Text ('State A:') Text(this.textA) } @@ -167,4 +167,5 @@ Multiple widgets of the same application can be configured to implement differen > **NOTE** +> > When the local database is used for widget information persistence, it is recommended that [TEMPORARY_KEY](../reference/apis/js-apis-app-form-formInfo.md#formparam) be used to determine whether the currently added widget is a normal one in the [onAddForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#onaddform) lifecycle callback. If the widget is a normal one, the widget information is directly persisted. If the widget is a temporary one, the widget information is persisted when the widget is converted to a normal one ([onCastToNormalForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#oncasttonormalform)). In addition, the persistent widget information needs to be deleted when the widget is destroyed ([onRemoveForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#onremoveform)), preventing the database size from continuously increasing due to repeated widget addition and deletion. diff --git a/en/application-dev/application-models/arkts-ui-widget-update-by-time.md b/en/application-dev/application-models/arkts-ui-widget-update-by-time.md index 5b27a636f83f144110c5533a3d43baf0087c3716..2c2643c802aff436656f5855d67c00e1a3c38dcd 100644 --- a/en/application-dev/application-models/arkts-ui-widget-update-by-time.md +++ b/en/application-dev/application-models/arkts-ui-widget-update-by-time.md @@ -5,7 +5,7 @@ Before configuring a widget to update periodically, enable the periodic update f The widget framework provides the following modes of updating widgets periodically: -- Set the update interval: The widget will be updated at the specified interval. You can specify the interval by setting the [updateDuration](arkts-ui-widget-configuration.md) field in the **form_config.json** file. For example, you can configure the widget to update once an hour. +- Set the update interval: The widget will be updated at the specified interval by calling [onUpdateForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#onupdateform). You can specify the interval by setting the [updateDuration](arkts-ui-widget-configuration.md) field in the **form_config.json** file. For example, you can configure the widget to update once an hour. > **NOTE** > diff --git a/en/application-dev/application-models/common-event-overview.md b/en/application-dev/application-models/common-event-overview.md index e8be9abaa3015a5512c47af55d2f364be0de79ad..3f532865e686592282b9080f234c088ee24a64f8 100644 --- a/en/application-dev/application-models/common-event-overview.md +++ b/en/application-dev/application-models/common-event-overview.md @@ -7,8 +7,7 @@ OpenHarmony provides Common Event Service (CES) for applications to subscribe to Common events are classified into system common events and custom common events. -- System common events: defined in CES. Only system applications and system services can publish system common events, such as HAP installation, update, and uninstall. For details about the supported system common events, see [Support](../reference/apis/js-apis-commonEventManager.md#support). - +- System common events: defined in CES. Currently, only system applications and system services can publish system common events, such as HAP installation, update, and uninstall. For details about the supported system common events, see [System Common Events](../reference/apis/commonEventManager-definitions.md). - Custom common events: customized by applications to implement cross-process event communication. @@ -16,9 +15,7 @@ Common events are also classified into unordered, ordered, and sticky common eve - Unordered common events: common events that CES forwards regardless of whether subscribers receive the events and when they subscribe to the events. - -- Ordered common events: common events that CES forwards based on the subscriber priority. CES forwards common events to the subscriber with lower priority only after receiving a reply from the previous subscriber with higher priority. Subscribers with the same priority receive common events in a random order. - +- Ordered common events: common events that CES forwards based on the subscriber priority. CES preferentially forwards an ordered common event to the subscriber with higher priority, waits until the subscriber receives the event, and then forwards the events to the subscriber with lower priority. Subscribers with the same priority receive common events in a random order. - Sticky common events: common events that can be sent to a subscriber before or after they initiate a subscription. Only system applications and system services can send sticky common events, which remain in the system after being sent. The sends must first request the **ohos.permission.COMMONEVENT_STICKY** permission. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file). diff --git a/en/application-dev/application-models/common-event-remove-sticky.md b/en/application-dev/application-models/common-event-remove-sticky.md index 358cf8ccf912e0c329684ff904207b933713835b..2ad907a9c7962d496f0a791c88a25aaab54a9d25 100644 --- a/en/application-dev/application-models/common-event-remove-sticky.md +++ b/en/application-dev/application-models/common-event-remove-sticky.md @@ -1,4 +1,4 @@ -# Removing Sticky Common Events +# Removing Sticky Common Events (for System Applications Only) ## When to Use @@ -16,21 +16,26 @@ For details, see [Common Event](../reference/apis/js-apis-commonEventManager.md) ## How to Develop -1. Import the module. - +1. Request the **ohos.permission.COMMONEVENT_STICKY** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file). + +2. Import the module. + ```ts import commonEventManager from '@ohos.commonEventManager'; ``` -2. The sticky common event to be removed must have been released by the application. For details about how to release sticky common events, see [Publishing Common Events](common-event-publish.md). +3. Call the [removeStickyCommonEvent()](../reference/apis/js-apis-commonEventManager.md#commoneventmanagerremovestickycommonevent10) API to remove the target sticky common event. + + > **NOTE** + > + > The sticky common event to be removed must have been released by the application. For details about how to release sticky common events, see [Publishing Common Events](common-event-publish.md). ```ts - CommonEventManager.removeStickyCommonEvent("sticky_event", (err) => { // sticky_event indicates the name of the sticky common event to remove. - if (err) { - console.info(`Remove sticky event AsyncCallback failed, errCode: ${err.code}, errMes: ${err.message}`); - return; - } - console.info(`Remove sticky event AsyncCallback success`); - } + commonEventManager.removeStickyCommonEvent("sticky_event", (err) => { // sticky_event indicates the name of the target sticky common event. + if (err) { + console.error(`Failed to remove sticky common event. Code is ${err.code}, message is ${err.message}`); + return; + } + console.info(`Succeeded in removeing sticky event.`); }); ``` diff --git a/en/application-dev/application-models/common-event-static-subscription.md b/en/application-dev/application-models/common-event-static-subscription.md index 53e014abe38ac3f8ec89fe8a21dc9280184a280b..7005c86ae2e29eb7c635f55b5da05f658ccd8360 100644 --- a/en/application-dev/application-models/common-event-static-subscription.md +++ b/en/application-dev/application-models/common-event-static-subscription.md @@ -2,38 +2,46 @@ ## When to Use -A static subscriber is started once it receives a target event published by the system or application. At the same time, the **onReceiveEvent** callback is triggered, in which you can implement the service logic. For example, if an application needs to execute some initialization tasks during device power-on, the application can subscribe to the power-on event in static mode. After receiving the power-on event, the application is started to execute the initialization tasks. Subscribing to a common event in static mode is achieved by configuring a declaration file and implementing a class that inherits from **StaticSubscriberExtensionAbility**. Note that this subscribing mode has negative impact on system power consumption. Therefore, exercise caution when using this mode. +A static subscriber is started once it receives a target event published by the system or application. At the same time, the [onReceiveEvent()](../reference/apis/js-apis-application-staticSubscriberExtensionAbility.md#staticsubscriberextensionabilityonreceiveevent) callback is triggered. + +You can implement the service logic in the [onReceiveEvent()](../reference/apis/js-apis-application-staticSubscriberExtensionAbility.md#staticsubscriberextensionabilityonreceiveevent) callback. For example, if an application needs to execute some initialization tasks during device power-on, the application can subscribe to the power-on event in static mode. After receiving the power-on event, the application is started to execute the initialization tasks. + +Subscribing to a common event in static mode is achieved by configuring a declaration file and implementing a class that inherits from [StaticSubscriberExtensionAbility](../reference/apis/js-apis-application-staticSubscriberExtensionAbility.md). + +> **NOTE** +> +> The static subscription mode has negative impact on system power consumption. Therefore, exercise caution when using this mode. ## How to Develop -1. Declaring a Static Subscriber +1. Declaring a static subscriber. - To declare a static subscriber, create an ExtensionAbility, which is derived from the **StaticSubscriberExtensionAbility** class, in the project. The sample code is as follows: + To declare a static subscriber, create an ExtensionAbility, which is derived from the **StaticSubscriberExtensionAbility** class, in the project. + + You can implement service logic in the **onReceiveEvent()** callback. ```ts import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility' export default class StaticSubscriber extends StaticSubscriberExtensionAbility { - onReceiveEvent(event) { - console.log('onReceiveEvent, event:' + event.event); - } + onReceiveEvent(event) { + console.info('onReceiveEvent, event: ' + event.event); + } } ``` - You can implement service logic in the **onReceiveEvent** callback. - -2. Project Configuration for a Static Subscriber +2. Configure static subscriber settings. - After writing the static subscriber code, configure the subscriber in the **module.json5** file. The configuration format is as follows: + After writing the static subscriber code, configure the subscriber in the [module.json5](../quick-start/module-configuration-file.md) file. ```ts { "module": { - ...... + ... "extensionAbilities": [ { "name": "StaticSubscriber", - "srcEntry": "./ets/StaticSubscriber/StaticSubscriber.ts", + "srcEntry": "./ets/staticsubscriber/StaticSubscriber.ts", "description": "$string:StaticSubscriber_desc", "icon": "$media:icon", "label": "$string:StaticSubscriber_label", @@ -47,14 +55,14 @@ A static subscriber is started once it receives a target event published by the ] } ] - ...... + ... } } ``` - Pay attention to the following fields in the JSON file: + Some fields in the file are described as follows: - - **srcEntry**: entry file path of the ExtensionAbility, that is, the file path of the static subscriber declared in Step 2. + - **srcEntry **: entry file path of the ExtensionAbility, that is, the file path of the static subscriber declared in Step 2. - **type**: ExtensionAbility type. For a static subscriber, set this field to **staticSubscriber**. @@ -62,42 +70,46 @@ A static subscriber is started once it receives a target event published by the - **name**: name of the ExtensionAbility. For a static subscriber, declare the name as **ohos.extension.staticSubscriber** for successful identification. - **resource**: path that stores the ExtensionAbility configuration, which is customizable. In this example, the path is **resources/base/profile/subscribe.json**. - A level-2 configuration file pointed to by **metadata** must be in the following format: - ```ts - { - "commonEvents": [ - { - "name": "xxx", - "permission": "xxx", - "events":[ - "xxx" - ] - } - ] - } - ``` +3. Configure the level-2 configuration file to which the metadata points. - If the level-2 configuration file is not declared in this format, the file cannot be identified. The fields are described as follows: + ```json + { + "commonEvents": [ + { + "name": "xxx", + "permission": "xxx", + "events":[ + "xxx" + ] + } + ] + } + ``` - - **name**: name of the ExtensionAbility, which must be the same as the name of **extensionAbility** declared in **module.json5**. + If the level-2 configuration file is not declared in this format, the file cannot be identified. Some fields in the file are described as follows: - - **permission**: permission required for the publisher. If a publisher without the required permission attempts to publish an event, the event is regarded as invalid and will not be published. + - **name**: name of the ExtensionAbility, which must be the same as the name of **extensionAbility** declared in **module.json5**. + - **permission**: permission required for the publisher. If a publisher without the required permission attempts to publish an event, the event is regarded as invalid and will not be published. + - **events**: list of target events to subscribe to. - - **events**: list of target events to subscribe to. +4. Modify the [preset configuration file](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_permissions.json) of the device, that is, the **/system/etc/app/install_list_permission.json** file on the device. When the device is started, this file is read. During application installation, the common event type specified by **allowCommonEvent** in the file is authorized. The **install_list_permission.json** file contains the following fields: -3. Device System Configuration + - **bundleName**: bundle name of the application. + - **app_signature**: fingerprint information of the application. For details, see [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md#configuration-in-install_list_capabilityjson). + - **allowCommonEvent**: type of common event that can be started by static broadcast. - In the device system configuration file **/system/etc/app/install_list_capability.json**, add the bundle name of the static subscriber. + > **NOTE** + > + > The **install_list_permissions.json** file is available only for preinstalled applications. - ```json - { - "install_list": [ - { - "bundleName": "ohos.extension.staticSubscriber", - "allowCommonEvent": ["usual.event.A", "usual.event.B"], - } - ] - } + ```json + [ + { + "bundleName": "com.example.myapplication", + "app_signature": ["****"], + "allowCommonEvent": ["usual.event.A", "usual.event.B"] + } + ] ``` diff --git a/en/application-dev/application-models/common-event-subscription-overview.md b/en/application-dev/application-models/common-event-subscription-overview.md index 20064af92d3df2e6f7ab7d62c4f71f911848057a..262f30c87e6018fed4e417a196dcaeeb58e42ae2 100644 --- a/en/application-dev/application-models/common-event-subscription-overview.md +++ b/en/application-dev/application-models/common-event-subscription-overview.md @@ -1,7 +1,7 @@ # Common Event Subscription Overview -​The common event service provides two subscription modes: dynamic and static. The biggest difference between these two modes is that dynamic subscription requires the application to be running, while static subscription does not. +The common event service provides two subscription modes: dynamic and static. The biggest difference between these two modes is that dynamic subscription requires the application to be running, while static subscription does not. - In dynamic subscription mode, a subscriber subscribes to common events by calling an API during the running period. For details, see [Subscribing to Common Events in Dynamic Mode](common-event-subscription.md). -- In static subscription mode, a subscriber subscribes to common events by configuring a declaration file and implementing a class that inherits from StaticSubscriberExtensionAbility. For details, see [Subscribing to Common Events in Static Mode](common-event-static-subscription.md). +- In static subscription mode, a subscriber subscribes to common events by configuring a declaration file and implementing a class that inherits from **StaticSubscriberExtensionAbility**. For details, see [Subscribing to Common Events in Static Mode](common-event-static-subscription.md). diff --git a/en/application-dev/application-models/common-event-subscription.md b/en/application-dev/application-models/common-event-subscription.md index 6cdc52ef9b798e48a911892f965db8fbf2aaa67f..c3e3ebfa52415d5e0ebade26973f78a589fb348f 100644 --- a/en/application-dev/application-models/common-event-subscription.md +++ b/en/application-dev/application-models/common-event-subscription.md @@ -32,7 +32,7 @@ For details about the APIs, see [API Reference](../reference/apis/js-apis-common let subscriber = null; // Subscriber information. let subscribeInfo = { - events: ["usual.event.SCREEN_OFF"], // Subscribe to the common event screen-off. + events: ["usual.event.SCREEN_OFF"], // Subscribe to the common event screen-off. } ``` @@ -41,13 +41,13 @@ For details about the APIs, see [API Reference](../reference/apis/js-apis-common ```ts // Callback for subscriber creation. commonEventManager.createSubscriber(subscribeInfo, (err, data) => { - if (err) { - console.error(`[CommonEvent] CreateSubscriberCallBack err=${JSON.stringify(err)}`); - } else { - console.info(`[CommonEvent] CreateSubscriber success`); - subscriber = data; - // Callback for common event subscription. - } + if (err) { + console.error(`Failed to create subscriber. Code is ${err.code}, message is ${err.message}`); + return; + } + console.info('Succeeded in creating subscriber.'); + subscriber = data; + // Callback for common event subscription. }) ``` @@ -56,14 +56,13 @@ For details about the APIs, see [API Reference](../reference/apis/js-apis-common ```ts // Callback for common event subscription. if (subscriber !== null) { - commonEventManager.subscribe(subscriber, (err, data) => { - if (err) { - console.error(`[CommonEvent] SubscribeCallBack err=${JSON.stringify(err)}`); - } else { - console.info(`[CommonEvent] SubscribeCallBack data=${JSON.stringify(data)}`); - } - }) + commonEventManager.subscribe(subscriber, (err, data) => { + if (err) { + console.error(`Failed to subscribe common event. Code is ${err.code}, message is ${err.message}`); + return; + } + }) } else { - console.error(`[CommonEvent] Need create subscriber`); + console.error(`Need create subscriber`); } ``` diff --git a/en/application-dev/application-models/figures/AccessibilityFramework.png b/en/application-dev/application-models/figures/AccessibilityFramework.png new file mode 100644 index 0000000000000000000000000000000000000000..786233e6ac160972f62b9786397eb077f7ee767c Binary files /dev/null and b/en/application-dev/application-models/figures/AccessibilityFramework.png differ diff --git a/en/application-dev/application-models/figures/WidgetCanvasDemo.jpeg b/en/application-dev/application-models/figures/WidgetCanvasDemo.jpeg deleted file mode 100644 index 9c797ff4575ae0aaf9aad27ae5d4d701181faf97..0000000000000000000000000000000000000000 Binary files a/en/application-dev/application-models/figures/WidgetCanvasDemo.jpeg and /dev/null differ diff --git a/en/application-dev/application-models/figures/WidgetCanvasDemo.png b/en/application-dev/application-models/figures/WidgetCanvasDemo.png new file mode 100644 index 0000000000000000000000000000000000000000..c09c82dd88cf002020990b5b8327701c445eeaaf Binary files /dev/null and b/en/application-dev/application-models/figures/WidgetCanvasDemo.png differ diff --git a/en/application-dev/application-models/inputmethodextentionability.md b/en/application-dev/application-models/inputmethodextentionability.md index 2b3910707ecdb6f964822380a85b14857ec8fd29..b36cf2a050cd15c1d4047410406ed46343f604e5 100644 --- a/en/application-dev/application-models/inputmethodextentionability.md +++ b/en/application-dev/application-models/inputmethodextentionability.md @@ -1,11 +1,11 @@ # InputMethodExtensionAbility Development -[InputMethodExtensionAbility](../reference/apis/js-apis-inputmethod-extension-ability.md) is an ExtensionAbility component of the inputMethod type that provides extension capabilities for the input method framework. +## When to Use +[InputMethodExtensionAbility](../reference/apis/js-apis-inputmethod-extension-ability.md), inherited from [ExtensionAbility](extensionability-overview.md), is used for developing input method applications. -InputMethodExtensionAbility can be started or connected by other application components to process transactions in the background based on the request of the caller. +The entire lifecycle of the [InputMethodExtensionAbility](../reference/apis/js-apis-inputmethod-extension-ability.md) instance and the owning ExtensionAbility process is scheduled and managed by the input method framework. The input method framework provides the [InputMethodExtensionAbility](../reference/apis/js-apis-inputmethod-extension-ability.md) base class. Derive this base class to implement initialization and resource clearing. - -InputMethodExtensionAbility provides related capabilities through the [InputMethodExtensionContext](../reference/apis/js-apis-inputmethod-extension-context.md). +[InputMethodExtensionAbility](../reference/apis/js-apis-inputmethod-extension-ability.md) provides related capabilities through [InputMethodExtensionContext](../reference/apis/js-apis-inputmethod-extension-context.md). ## Implementing an Input Method Application @@ -13,15 +13,13 @@ InputMethodExtensionAbility provides related capabilities through the [InputMeth InputMethodExtensionAbility provides the **onCreate()** and **onDestory()** callbacks, as described below. Override them as required. - **onCreate** - This callback is triggered when a service is created for the first time. You can perform initialization operations, for example, registering a common event listener. - + > **NOTE** > > If a service has been created, starting it again does not trigger the **onCreate()** callback. - + - **onDestroy** - This callback is triggered when the service is no longer used and the instance is ready for destruction. You can clear resources in this callback, for example, deregister the listener. @@ -29,7 +27,7 @@ InputMethodExtensionAbility provides the **onCreate()** and **onDestory()** call To implement an input method application, manually create an InputMethodExtensionAbility component in DevEco Studio. The procedure is as follows: -In the **ets** directory of the target module, right-click and choose **New** > **Extention Ability** > **InputMethod** to a minimum template of InputMethodExtensionAbility. +In the **ets** directory of the target module, right-click and choose **New** > **Extension Ability** > **InputMethod** to a minimum template of InputMethodExtensionAbility. > **NOTE** > @@ -70,7 +68,7 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth onDestroy() { console.log("onDestroy."); - this.context.destroy(); + this.keyboardController.onDestroy(); // Destroy the window and deregister the event listener. } } ``` @@ -109,7 +107,6 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth this.unRegisterListener(); // Deregister the event listener. let win = windowManager.findWindow(this.windowName); win.destroyWindow(); // Destroy the window. - this.mContext.terminateSelf(); // Terminate the InputMethodExtensionAbility service. } private initWindow(): void // Initialize the window. @@ -159,7 +156,7 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth }) globalThis.inputAbility.on('inputStop', (imeId) => { if (imeId == "Bundle name/Ability name") { - this.onDestroy(); + this.mContext.destroy(); // Destroy the InputMethodExtensionAbility service. } }); } @@ -233,7 +230,7 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth Add the path to this file to the **src** field in the **resources/base/profile/main_pages.json** file. - ```ts + ```ets import { numberSourceListData, sourceListType } from './keyboardKeyData' @Component @@ -342,12 +339,12 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth } ``` - Register the InputMethodExtensionAbility in the [module.json5 file](../quick-start/module-configuration-file.md) corresponding to the target module. Set **type** to **"inputMethod"** and **srcEntry** to the code path of the InputMethodExtensionAbility component. +5. Register the InputMethodExtensionAbility in the [module.json5 file](../quick-start/module-configuration-file.md) corresponding to the **Module** project. Set **type** to **"inputMethod"** and **srcEntry** to the code path of the InputMethodExtensionAbility component. ```ts { "module": { - // ... + ... "extensionAbilities": [ { "description": "inputMethod", @@ -364,3 +361,47 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth +## Restrictions + +To reduce the risk of abuse of the InputMethodExtensionAbility by third-party applications, the invoking of APIs in the following modules is restricted in the InputMethodExtensionAbility: + +> **NOTE** +> +> - If a restricted module is imported, no error is reported during compilation, but an incorrect value (**undefined**) is returned during running. As a result, the module does not take effect. +> - Currently, access to the [@ohos.multimedia.audio (Audio Management)](../reference/apis/js-apis-audio.md) module is allowed, with compliance with the following rules: +> - Users who deny the recording permission should still be allowed to use the non-voice-input features of the input method application. +> - Recording-related services are allowed only when the InputMethodExtensionAbility is in the foreground. For example, perform recording only when the soft keyboard is in the foreground and the user is proactively using the voice input method; stop recording when the application is switched to the background. +> - Applications will see increasingly stringent measures against violations with the preceding rules, and any violation may result in function exceptions. + +**Restricted modules:** + +- [@ohos.ability.featureAbility (FeatureAbility)](../reference/apis/js-apis-ability-featureAbility.md) +- [@ohos.ability.particleAbility (ParticleAbility)](../reference/apis/js-apis-ability-particleAbility.md) +- [@ohos.account.distributedAccount (Distributed Account Management)](../reference/apis/js-apis-distributed-account.md) +- [@ohos.backgroundTaskManager (Background Task Management)](../reference/apis/js-apis-backgroundTaskManager.md) +- [@ohos.bluetooth (Bluetooth)](../reference/apis/js-apis-bluetooth.md) +- [@ohos.bluetoothManager (Bluetooth)](../reference/apis/js-apis-bluetoothManager.md) +- [@ohos.connectedTag (Active Tags)](../reference/apis/js-apis-connectedTag.md) +- [@ohos.geolocation (Geolocation)](../reference/apis/js-apis-geolocation.md) +- [@ohos.geoLocationManager (Geolocation Manager)](../reference/apis/js-apis-geoLocationManager.md) +- [@ohos.nfc.cardEmulation (Standard NFC Card Emulation)](../reference/apis/js-apis-cardEmulation.md) +- [@ohos.nfc.controller (Standard NFC)](../reference/apis/js-apis-nfcController.md) +- [@ohos.nfc.tag (Standard NFC Tags)](../reference/apis/js-apis-nfcTag.md) +- [@ohos.reminderAgent (Reminder Agent)](../reference/apis/js-apis-reminderAgent.md) +- [@ohos.reminderAgentManager (reminderAgentManager)](../reference/apis/js-apis-reminderAgentManager.md) +- [@ohos.sensor (Sensor)](../reference/apis/js-apis-sensor.md) +- [@ohos.telephony.call (Call)](../reference/apis/js-apis-call.md) +- [@ohos.telephony.data (Cellular Data)](../reference/apis/js-apis-telephony-data.md) +- [@ohos.telephony.observer (observer)](../reference/apis/js-apis-observer.md) +- [@ohos.telephony.radio (Network Search)](../reference/apis/js-apis-radio.md) +- [@ohos.telephony.sim (SIM Management)](../reference/apis/js-apis-sim.md) +- [@ohos.telephony.sms (SMS)](../reference/apis/js-apis-sms.md) +- [@ohos.wallpaper (Wallpaper)](../reference/apis/js-apis-wallpaper.md) +- [@ohos.wifiext (WLAN Extension)](../reference/apis/js-apis-wifiext.md) +- [@ohos.wifiManager (WLAN)](../reference/apis/js-apis-wifiManager.md) +- [@ohos.wifiManagerExt (WLAN Extension Interface)](../reference/apis/js-apis-wifiManagerExt.md) +- [@system.geolocation (Geolocation)](../reference/apis/js-apis-system-location.md) +- [nfctech (Standard NFC Technologies)](../reference/apis/js-apis-nfctech.md) +- [tagSession (Standard NFC Tag Session)](../reference/apis/js-apis-tagSession.md) + + diff --git a/en/application-dev/application-models/service-widget-overview.md b/en/application-dev/application-models/service-widget-overview.md index 3739129f2a07765b2ebe015910d1d6e3d8d721d0..528d9d4c134107c30de75f7f9e84ab42be514224 100644 --- a/en/application-dev/application-models/service-widget-overview.md +++ b/en/application-dev/application-models/service-widget-overview.md @@ -6,7 +6,7 @@ A service widget (also called widget) is a set of UI components that display imp ## Service Widget Architecture - **Figure 1** Service widget architecture +**Figure 1** Service widget architecture ![WidgetArchitecture](figures/WidgetArchitecture.png) @@ -24,7 +24,7 @@ Before you get started, it would be helpful if you have a basic understanding of Below is the typical procedure of using the widget: - **Figure 2** Typical procedure of using the widget +**Figure 2** Typical procedure of using the widget ![WidgetUse](figures/WidgetUse.png) @@ -55,4 +55,4 @@ ArkTS widgets and JS widgets have different implementation principles and featur | Custom drawing| Not supported| Supported| | Logic code execution (excluding the import capability)| Not supported| Supported| -As can be seen above, ArkTS widgets have more capabilities and use cases than JS widgets. Therefore, ArkTS widgets are always recommended, except for the case where the widget consists of only static pages. +As can be seen above, ArkTS widgets provide more capabilities and use cases than JS widgets. Therefore, ArkTS widgets are always recommended, except for the case where the widget consists of only static pages. diff --git a/en/application-dev/connectivity/Readme-EN.md b/en/application-dev/connectivity/Readme-EN.md index 59df854e8a37289cc9dcf55ed2f7d8110a7c84d0..c09ca21b6d0814bd1cd2cecb95b0d2896fada8c4 100755 --- a/en/application-dev/connectivity/Readme-EN.md +++ b/en/application-dev/connectivity/Readme-EN.md @@ -5,7 +5,6 @@ - [HTTP Data Request](http-request.md) - [WebSocket Connection](websocket-connection.md) - [Socket Connection](socket-connection.md) - - [Network Policy Management](net-policy-management.md) - [Network Sharing](net-sharing.md) - [Ethernet Connection](net-ethernet.md) - [Network Connection Management](net-connection-manager.md) diff --git a/en/application-dev/connectivity/net-connection-manager.md b/en/application-dev/connectivity/net-connection-manager.md index 5ee75a717882c3344612e741b2e197fa6e57509d..c443c93759caddbc5203b65022426882c0bb960b 100644 --- a/en/application-dev/connectivity/net-connection-manager.md +++ b/en/application-dev/connectivity/net-connection-manager.md @@ -39,7 +39,7 @@ For the complete list of APIs and example code, see [Network Connection Manageme | ---- | ---- | ---- | | ohos.net.connection | function getDefaultNet(callback: AsyncCallback\): void; |Creates a **NetHandle** object that contains the **netId** of the default network. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getGlobalHttpProxy10+(callback: AsyncCallback\): void;| Obtains the global HTTP proxy for the network. This API uses an asynchronous callback to return the result.| -| ohos.net.connection | function setGlobalHttpProxy10+(httpProxy: HttpProxy, callback: AsyncCallback): void;| Sets the global HTTP proxy for the network. This API uses an asynchronous callback to return the result.| +| ohos.net.connection | function setGlobalHttpProxy10+(httpProxy: HttpProxy, callback: AsyncCallback\): void;| Sets the global HTTP proxy for the network. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getAppNet9+(callback: AsyncCallback\): void;| Obtains a **NetHandle** object that contains the **netId** of the network bound to the application. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function setAppNet9+(netHandle: NetHandle, callback: AsyncCallback\): void;| Binds an application to the specified network. The application can access the external network only through this network. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getDefaultNetSync9+(): NetHandle; |Obtains the default active data network in synchronous mode. You can use **getNetCapabilities** to obtain information such as the network type and capabilities.| @@ -47,7 +47,7 @@ For the complete list of APIs and example code, see [Network Connection Manageme | ohos.net.connection | function getAllNets(callback: AsyncCallback\>): void;| Obtains the list of **NetHandle** objects of the connected network. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\): void; |Obtains link information of the default network. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback\): void; |Obtains the capability set of the default network. This API uses an asynchronous callback to return the result.| -| ohos.net.connection | function isDefaultNetMetered9+(callback: AsyncCallback): void; |Checks whether the data traffic usage on the current network is metered. This API uses an asynchronous callback to return the result.| +| ohos.net.connection | function isDefaultNetMetered9+(callback: AsyncCallback\): void; |Checks whether the data traffic usage on the current network is metered. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function reportNetConnected(netHandle: NetHandle, callback: AsyncCallback\): void;| Reports a **netAavailable** event to NetManager. If this API is called, the application considers that its network status (ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED) is inconsistent with that of NetManager. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback\): void;| Reports a **netAavailable** event to NetManager. If this API is called, the application considers that its network status (ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED) is inconsistent with that of NetManager. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getAddressesByName(host: string, callback: AsyncCallback\>): void; |Obtains all IP addresses of the specified network by resolving the domain name. This API uses an asynchronous callback to return the result.| diff --git a/en/application-dev/connectivity/net-mgmt-overview.md b/en/application-dev/connectivity/net-mgmt-overview.md index 043d41768f89dd851839eae893b7ba4409395f5e..f03d7668edc9fc27ef22c4ef4d69b186f7b4c3d9 100644 --- a/en/application-dev/connectivity/net-mgmt-overview.md +++ b/en/application-dev/connectivity/net-mgmt-overview.md @@ -5,7 +5,6 @@ Network management functions include: - [HTTP data request](http-request.md): initiates a data request through HTTP. - [WebSocket connection](websocket-connection.md): establishes a bidirectional connection between the server and client through WebSocket. - [Socket connection](socket-connection.md): transmits data through Socket. -- [Network policy management](net-policy-management.md): restricts network capabilities by setting network policies, including cellular network policy, sleep/power-saving mode policy, and background network policy, and resets network policies as needed. - [Network sharing](net-sharing.md): shares a device's Internet connection with other connected devices by means of Wi-Fi hotspot, Bluetooth, and USB sharing, and queries the network sharing state and shared mobile data volume. - [Ethernet connection](net-ethernet.md): provides wired network capabilities, which allow you to set the IP address, subnet mask, gateway, and Domain Name System (DNS) server of a wired network. - [Network connection management](net-connection-manager.md): provides basic network management capabilities, including management of Wi-Fi/cellular/Ethernet connection priorities, network quality evaluation, subscription to network connection status changes, query of network connection information, and DNS resolution. diff --git a/en/application-dev/connectivity/net-policy-management.md b/en/application-dev/connectivity/net-policy-management.md deleted file mode 100644 index 6450bd671e565fdffafb7eeed499e123893a45a3..0000000000000000000000000000000000000000 --- a/en/application-dev/connectivity/net-policy-management.md +++ /dev/null @@ -1,402 +0,0 @@ -# Network Policy Management - -## Introduction - -The Network Policy Management module allows you to restrict network capabilities by setting network policies, including cellular network policy, sleep/power-saving mode policy, and background network policy, and to reset network policies as needed. - -> **NOTE** -> To maximize the application running efficiency, most API calls are called asynchronously in callback or promise mode. The following code examples use the callback mode. For details about the APIs, see [sms API Reference](../reference/apis/js-apis-net-policy.md). - -## Basic Concepts - -- Sleep mode: A mode in which the system shuts down some idle components and peripherals to enter the low-power mode and restricts some applications from accessing the network. -- Power-saving mode: A mode in which the system disables certain functions and features to save power. When this mode is enabled, the system performance deteriorates and some applications are restricted from accessing the network. -- Traffic-saving mode: A mode in which the system restricts background applications that use the metering network. It is equivalent to the background network policy. -- Cellular network: A mobile communication network. -- Metering network: A mobile network with preconfigured traffic quota, WLAN network, or Ethernet network. - -## **Constraints** - -- Programming language: C++ and JS -- System: Linux kernel -- The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. - -## When to Use - -Typical application scenarios of network policy management are as follows: - -- Managing the metering network policy: Set the metering network quota and obtain the configured metering network policy. -- Managing network access for an application in the background: Set and obtain the status of the background network restriction switch, and check whether the application indicated by the specified UID can access the network in the background. -- Managing the metering network access policy: Set and obtain the policy for the application indicated by the specified UID to access the metering network, and obtain the UIDs of the applications for which the policy is configured. -- Restoring network policies -- Checking whether an application indicated by the specified UID can access a metering or non-metering network -- Adding a UID to or removing a UID from the sleep mode allowlist, and obtaining the sleep mode allowlist -- Adding a UID to or removing a UID from the power-saving mode allowlist, and obtaining the power-saving mode allowlist -- Updating the network notification policy - -The following describes the development procedure specific to each application scenario. - -## Available APIs - -For the complete list of APIs and example code, see [Network Policy Management](../reference/apis/js-apis-net-policy.md). - -| Type| API| Description| -| ---- | ---- | ---- | -| ohos.net.policy | function setBackgroundPolicy(isAllowed: boolean, callback: AsyncCallback\): void |Sets a background network policy. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function isBackgroundAllowed(callback: AsyncCallback\): void; |Obtains the background network policy. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function setPolicyByUid(uid: number, policy: NetUidPolicy, callback: AsyncCallback\): void; |Sets an application-specific network policy by **uid**. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function getPolicyByUid(uid: number, callback: AsyncCallback\): void;| Obtains an application-specific network policy by **uid**. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function getUidsByPolicy(policy: NetUidPolicy, callback: AsyncCallback\>): void; | Obtains the UID array of applications configured with a certain application-specific network policy. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function getNetQuotaPolicies(callback: AsyncCallback\>): void; |Obtains the network quota policies. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function setNetQuotaPolicies(quotaPolicies: Array\, callback: AsyncCallback\): void; |Sets an array of network quota policies. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function restoreAllPolicies(iccid: string, callback: AsyncCallback\): void; | Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function isUidNetAllowed(uid: number, isMetered: boolean, callback: AsyncCallback\): void; | Checks whether an application is allowed to access metering or non-metering networks. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function isUidNetAllowed(uid: number, iface: string, callback: AsyncCallback\): void; | Checks whether an application is allowed to access the given network. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function setDeviceIdleAllowList(uid: number, isAllowed: boolean, callback: AsyncCallback\): void; | Sets whether to add an application to the device idle allowlist. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function getDeviceIdleAllowList(callback: AsyncCallback\>): void; | Obtains the UID array of applications that are on the device idle allowlist. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function getBackgroundPolicyByUid(uid: number, callback: AsyncCallback\): void; | Obtains the background network policies configured for the given application. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function resetPolicies(iccid: string, callback: AsyncCallback\): void; | Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function updateRemindPolicy(netType: NetBearType, iccid: string, remindType: RemindType, callback: AsyncCallback\): void; | Updates a reminder policy. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function setPowerSaveAllowList(uid: number, isAllowed: boolean, callback: AsyncCallback\): void; | Sets whether to add an application to the power-saving allowlist. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function getPowerSaveAllowList(callback: AsyncCallback\>): void; | Obtains the UID array of applications that are on the power-saving allowlist. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function on(type: "netUidPolicyChange", callback: Callback\<{ uid: number, policy: NetUidPolicy }>): void; | Subscribes to policy changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function off(type: "netUidPolicyChange", callback: Callback\<{ uid: number, policy: NetUidPolicy }>): void; | Unsubscribes from policy changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function on(type: "netUidRuleChange", callback: Callback\<{ uid: number, rule: NetUidRule }>): void; | Subscribes to rule changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function off(type: "netUidRuleChange", callback: Callback\<{ uid: number, rule: NetUidRule }>): void; | Unsubscribes from rule changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function on(type: "netMeteredIfacesChange", callback: Callback\>): void; | Subscribes to metered **iface** changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function off(type: "netMeteredIfacesChange", callback: Callback\>): void; | Unsubscribes from metered **iface** changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function on(type: "netQuotaPolicyChange", callback: Callback\>): void; | Subscribes to network quota policy changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function off(type: "netQuotaPolicyChange", callback: Callback\>): void; | Unsubscribes from network quota policy changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function on(type: "netBackgroundPolicyChange", callback: Callback\): void; | Subscribes to background network policy changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function off(type: "netBackgroundPolicyChange", callback: Callback\): void; | Unsubscribes from background network policy changes. This API uses an asynchronous callback to return the result.| - -## Managing the Metering Network Policy - -1. Import the **policy** namespace from **@ohos.net.policy.d.ts**. - -2. Call **setNetQuotaPolicies** to configure the metering network policy. - -3. Call **getNetQuotaPolicies** to obtain the configured metering network policy. - -```js - // Import the policy namespace. - import policy from '@ohos.net.policy'; - - addNetQuotaPolicy(){ - let param = { - // For details about the value of netType, see [NetBearType](../reference/apis/js-apis-net-connection.md#netbeartype). - netType:Number.parseInt(this.netType), - - // Integrated circuit card identifier (ICCID) of the SIM card on the metering cellular network. It is not available for an Ethernet or Wi-Fi network. - iccid:this.iccid, - - // Used together with ICCID on the metering cellular network. It is used independently on an Ethernet or Wi-Fi network. - ident:this.ident, - - // Metering start time, for example, M1, D1, and Y1. - periodDuration:this.periodDuration, - - // Set the traffic threshold for generating an alarm to an integer greater than 0. - warningBytes:Number.parseInt(this.warningBytes), - - // Set the traffic quota to an integer greater than 0. - limitBytes:Number.parseInt(this.limitBytes), - - // Specify whether the network is a metering network. The value true means a metering network and false means a non-metering network. - metered:Boolean(Number.parseInt(this.metered)),https://gitee.com/openharmony/docs/pulls/14404 - // For details about the action triggered after the traffic limit is reached, see [LimitAction](../reference/apis/js-apis-net-policy.md#limitaction). - limitAction:Number.parseInt(this.limitAction) - }; - this.netQuotaPolicyList.push(param); - }, - - // Subscribe to metered iface changes. - policy.on('netMeteredIfacesChange', (data) => { - this.log('on netMeteredIfacesChange: ' + JSON.stringify(data)); - }); - - // Subscribe to metering network policy changes. - policy.on('netQuotaPolicyChange', (data) => { - this.log('on netQuotaPolicyChange: ' + JSON.stringify(data)); - }); - - // Call setNetQuotaPolicies to configure the metering network policy. - setNetQuotaPolicies(){ - this.dialogType = DialogType.HIDE; - policy.setNetQuotaPolicies(this.netQuotaPolicyList, (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)); - }); - }, - - // Call getNetQuotaPolicies to obtain the configured metering network policy. - getNetQuotaPolicies(){ - policy.getNetQuotaPolicies((err, data) => { - this.callBack(err, data); - if(data){ - this.netQuotaPolicyList = data; - } - }); - }, - - // Unsubscribe from metered iface changes. - policy.off('netMeteredIfacesChange', (data) => { - this.log('off netMeteredIfacesChange: ' + JSON.stringify(data)); - }); - - // Unsubscribe from metering network policy changes. - policy.off('netQuotaPolicyChange', (data) => { - this.log('off netQuotaPolicyChange: ' + JSON.stringify(data)); - }); -``` - -## Managing Network Access for an Application in the Background - -### How to Develop - -1. Import the **policy** namespace from **@ohos.net.policy.d.ts**. - -2. Call **setBackgroundAllowed** to enable or disable the background network restriction switch. - -3. Call **isBackgroundAllowed** to check whether the background network restriction switch is enabled or disabled. - -4. Call **getBackgroundPolicyByUid** to check whether the application indicated b the specified UID can access the network in the background. - -```js - // Import the policy namespace. - import policy from '@ohos.net.policy' - - // Subscribe to background network policy changes. - policy.on('netBackgroundPolicyChange', (data) => { - this.log('on netBackgroundPolicyChange: ' + JSON.stringify(data)); - }); - - // Call setBackgroundAllowed to enable or disable the background network restriction switch. - setBackgroundAllowed() { - policy.setBackgroundAllowed(Boolean(Number.parseInt(this.isBoolean)), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, - - // Call isBackgroundAllowed to check whether the background network restriction switch is enabled or disabled. - isBackgroundAllowed() { - policy.isBackgroundAllowed((err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, - - // Call getBackgroundPolicyByUid to check whether the application indicated b the specified UID can access the network in the background. - getBackgroundPolicyByUid() { - policy.getBackgroundPolicyByUid(Number.parseInt(this.firstParam), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, - - // Unsubscribe from background network policy changes. - policy.off('netBackgroundPolicyChange', (data) => { - this.log('off netBackgroundPolicyChange: ' + JSON.stringify(data)); - }); -``` - -## Managing the Metering Network Access Policy - -### How to Develop - -1. Import the **policy** namespace from **@ohos.net.policy.d.ts**. - -2. Call **setPolicyByUid** to set whether the application indicated by the specified UID can access the network in the background. - -3. Call **getPolicyByUid** to check whether the metering network access policy for the application indicated by the specified UID. - -4. Call **getUidsByPolicy** to obtain the UIDs of the applications for which the metering network access policy is configured. - -```js - // Import the policy namespace. - import policy from '@ohos.net.policy' - - // Subscribe to policy changes of the application indicated by the specified UID. - policy.on('netUidPolicyChange', (data) => { - this.log('on netUidPolicyChange: ' + JSON.stringify(data)); - }); - - // Subscribe to rule changes of the application indicated by the specified UID. - policy.on('netUidRuleChange', (data) => { - this.log('on netUidRuleChange: ' + JSON.stringify(data)); - }); - - // Call setPolicyByUid to set whether the application indicated by the specified UID can access the network in the background. - setPolicyByUid() { - let param = { - uid: Number.parseInt(this.firstParam), policy: Number.parseInt(this.currentNetUidPolicy) - } - policy.setPolicyByUid(Number.parseInt(this.firstParam), Number.parseInt(this.currentNetUidPolicy), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, - - // Call getPolicyByUid to check whether the metering network access policy for the application indicated by the specified UID. - getPolicyByUid() { - policy.getPolicyByUid(Number.parseInt(this.firstParam), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, - - // Call getUidsByPolicy to obtain the UIDs of the applications for which the metering network access policy is configured. - getUidsByPolicy(){ - policy.getUidsByPolicy(Number.parseInt(this.currentNetUidPolicy), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, - - // Unsubscribe from policy changes of the application indicated by the specified UID. - policy.off('netUidPolicyChange', (data) => { - this.log('off netUidPolicyChange: ' + JSON.stringify(data)); - }); - - // Unsubscribe from rule changes of the application indicated by the specified UID. - policy.off('netUidRuleChange', (data) => { - this.log('off netUidRuleChange: ' + JSON.stringify(data)); - }); - -``` - -## Restoring Network Policies - -### How to Develop - -1. Import the **policy** namespace from **@ohos.net.policy.d.ts**. - -2. Call **restoreAllPolicies** to restore all network policies. - -```js - // Import the policy namespace. - import policy from '@ohos.net.policy' - - // Call restoreAllPolicies to restore all network policies. - restoreAllPolicies(){ - policy.restoreAllPolicies(this.firstParam, (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, -``` - -## Checking Access to a Metering or Non-metering Network - -### How to Develop - -1. Import the **policy** namespace from **@ohos.net.policy.d.ts**. - -2. Call **isUidNetAllowed** to check whether the UID can access the metering or non-metering network. - -```js - // Import the policy namespace. - import policy from '@ohos.net.policy' - - // Call isUidNetAllowed to check whether the application indicated by the specified UID can access the metering or non-metering network. - isUidNetAllowedIsMetered(){ - let param = { - uid: Number.parseInt(this.firstParam), isMetered: Boolean(Number.parseInt(this.isBoolean)) - } - policy.isUidNetAllowed(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, -``` - -## Managing the Sleep Mode Allowlist - -### How to Develop - -1. Import the **policy** namespace from **@ohos.net.policy.d.ts**. - -2. Call **setDeviceIdleAllowList** to add a UID to or remove a UID from the sleep mode allowlist. - -3. Call **getDeviceIdleAllowList** to obtain the UIDs added to the sleep mode allowlist. - -```js - // Import the policy namespace. - import policy from '@ohos.net.policy' - - // Call setDeviceIdleAllowList to add a UID to or remove a UID from the sleep mode allowlist. - setDeviceIdleAllowList(){ - let param = { - uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean)) - } - policy.setDeviceIdleAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, - - // Call getDeviceIdleAllowList to obtain the UIDs added to the sleep mode allowlist. - getDeviceIdleAllowList(){ - policy.getDeviceIdleAllowList((err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, -``` - -## Managing the Power-saving Mode Allowlist - -### How to Develop - -1. Import the **policy** namespace from **@ohos.net.policy.d.ts**. -2. Call **setPowerSaveAllowList** to add a UID to or remove a UID from the power-saving mode allowlist. -3. Call **getPowerSaveAllowList** to obtain the UIDs added to the power-saving mode allowlist. - -```js - // Import the policy namespace. - import policy from '@ohos.net.policy' - - // Call setPowerSaveAllowList to add a UID to or remove a UID from the power-saving mode allowlist. - setPowerSaveAllowList(){ - let param = { - uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean)) - } - policy.setPowerSaveAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, - - // Call getPowerSaveAllowList to obtain the UIDs added to the power-saving mode allowlist. - getPowerSaveAllowList(){ - policy.getPowerSaveAllowList((err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, -``` - -## Updating the Network Notification Policy - -### How to Develop - -1. Import the **policy** namespace from **@ohos.net.policy.d.ts**. - -2. Call **updateRemindPolicy** to update the network notification policy. - -```js - // Import the policy namespace. - import policy from '@ohos.net.policy' - - // Call updateRemindPolicy to update the network notification policy. - updateRemindPolicy() { - let param = { - netType: Number.parseInt(this.netType), iccid: this.firstParam, remindType: this.currentRemindType - } - policy.updateRemindPolicy(Number.parseInt(this.netType), this.firstParam, Number.parseInt(this.currentRemindType), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, -``` diff --git a/en/application-dev/device/usb-guidelines.md b/en/application-dev/device/usb-guidelines.md index 68c8c3de013e75d56854bf0cf0e3a71aca9eb261..ef09e1ee89940220f8b9d1936362d34ebf8bf7a6 100644 --- a/en/application-dev/device/usb-guidelines.md +++ b/en/application-dev/device/usb-guidelines.md @@ -1,156 +1,161 @@ # USB Service Development + ## When to Use In Host mode, you can obtain the list of connected USB devices, enable or disable the devices, manage device access permissions, and perform data transfer or control transfer. -## APIs + +## Available APIs The USB service provides the following functions: query of USB device list, bulk data transfer, control transfer, and access permission management. The following table lists the USB APIs currently available. For details, see the [API Reference](../reference/apis/js-apis-usbManager.md). -**Table 1** Open USB APIs +**Table 1** Open USB APIs -| API | Description | +| Name | Description | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| hasRight(deviceName: string): boolean | Checks whether the user has the device access permissions. | -| requestRight(deviceName: string): Promise\ | Requests the temporary permission for a given application to access the USB device. This API uses a promise to return the result. | -| connectDevice(device: USBDevice): Readonly\ | Connects to the USB device based on the device list returned by `getDevices()`. | -| getDevices(): Array> | Obtains the list of USB devices connected to the USB host. If no USB device is connected, an empty list is returned. | -| setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number | Sets the USB device configuration. | -| setInterface(pipe: USBDevicePipe, iface: USBInterface): number | Sets a USB interface. | -| claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number | Claims a USB interface. | -| bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout ?: number): Promise\ | Performs bulk transfer. | -| closePipe(pipe: USBDevicePipe): number | Closes a USB device pipe. | -| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | Releases a USB interface. | -| getFileDescriptor(pipe: USBDevicePipe): number | Obtains the file descriptor. | -| getRawDescriptor(pipe: USBDevicePipe): Uint8Array | Obtains the raw USB descriptor. | -| controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise<number> | Performs control transfer. | +| hasRight(deviceName: string): boolean | Checks whether the user has the device access permissions.| +| requestRight(deviceName: string): Promise<boolean> | Requests the device access permissions for the application. This API uses a promise to return the result. | +| removeRight(deviceName: string): boolean | Revokes the device access permissions of the application.| +| connectDevice(device: USBDevice): Readonly<USBDevicePipe> | Connects to the USB device based on the device information returned by `getDevices()`. | +| getDevices(): Array<Readonly<USBDevice>> | Obtains the list of USB devices connected to the host. If no device is connected, an empty list is returned. | +| setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number | Sets the USB device configuration. | +| setInterface(pipe: USBDevicePipe, iface: USBInterface): number | Sets a USB interface. | +| claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number | Claims a USB interface. | +| bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout ?: number): Promise<number> | Performs bulk transfer. | +| closePipe(pipe: USBDevicePipe): number | Closes a USB device pipe. | +| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | Releases a USB interface. | +| getFileDescriptor(pipe: USBDevicePipe): number | Obtains the file descriptor. | +| getRawDescriptor(pipe: USBDevicePipe): Uint8Array | Obtains the raw USB descriptor. | +| controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise<number> | Performs control transfer. | + ## How to Develop -You can set a USB device as the USB host to connect to other USB devices for data transfer. The development procedure is as follows: - -1. Obtain the USB device list. - - ```js - // Import the USB API package. - import usb from '@ohos.usbManager'; - // Obtain the USB device list. - let deviceList = usb.getDevices(); - /* - Example deviceList structure - [ - { - name: "1-1", - serial: "", - manufacturerName: "", - productName: "", - version: "", - vendorId: 7531, - productId: 2, - clazz: 9, - subClass: 0, - protocol: 1, - devAddress: 1, - busNum: 1, - configs: [ - { - id: 1, - attributes: 224, - isRemoteWakeup: true, - isSelfPowered: true, - maxPower: 0, - name: "1-1", - interfaces: [ - { - id: 0, - protocol: 0, - clazz: 9, - subClass: 0, - alternateSetting: 0, - name: "1-1", - endpoints: [ - { - address: 129, - attributes: 3, - interval: 12, - maxPacketSize: 4, - direction: 128, - number: 1, - type: 3, - interfaceId: 0, - } - ] - } - ] - } - ] - } - ] - */ - ``` - +You can set a USB device as a host to connect to a device for data transfer. The development procedure is as follows: + + +1. Obtain the USB device list. + + ```js + // Import the USB API package. + import usb from '@ohos.usbManager'; + // Obtain the USB device list. + let deviceList = usb.getDevices(); + /* + Example deviceList structure: + [ + { + name: "1-1", + serial: "", + manufacturerName: "", + productName: "", + version: "", + vendorId: 7531, + productId: 2, + clazz: 9, + subClass: 0, + protocol: 1, + devAddress: 1, + busNum: 1, + configs: [ + { + id: 1, + attributes: 224, + isRemoteWakeup: true, + isSelfPowered: true, + maxPower: 0, + name: "1-1", + interfaces: [ + { + id: 0, + protocol: 0, + clazz: 9, + subClass: 0, + alternateSetting: 0, + name: "1-1", + endpoints: [ + { + address: 129, + attributes: 3, + interval: 12, + maxPacketSize: 4, + direction: 128, + number: 1, + type: 3, + interfaceId: 0, + } + ] + } + ] + } + ] + } + ] + */ + ``` 2. Obtain the device operation permissions. - ```js - let deviceName = deviceList[0].name; - // Request the permissions to operate a specified device. - usb.requestRight(deviceName).then(hasRight => { - console.info("usb device request right result: " + hasRight); - }).catch(error => { - console.info("usb device request right failed : " + error); - }); - ``` + ```js + let deviceName = deviceList[0].name; + // Request the permissions to operate a specified device. + usb.requestRight(deviceName).then(hasRight => { + console.info("usb device request right result: " + hasRight); + }).catch(error => { + console.info("usb device request right failed : " + error); + }); + ``` 3. Open the device. - ```js - // Open the device, and obtain the USB device pipe for data transfer. - let interface1 = deviceList[0].configs[0].interfaces[0]; - /* - Claim the corresponding interface from deviceList. - interface1 must be one present in the device configuration. - */ - usb.claimInterface(pipe, interface1, true); - ``` + ```js + // Open the device, and obtain the USB device pipe for data transfer. + let pipe = usb.connectDevice(deviceList[0]); + let interface1 = deviceList[0].configs[0].interfaces[0]; + /* + Claim the corresponding interface from **deviceList**. + interface1 must be one present in the device configuration. + */ + usb.claimInterface(pipe, interface1, true); + ``` 4. Perform data transfer. - ```js - /* + ```js + /* Read data. Select the corresponding RX endpoint from deviceList for data transfer. - (endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array. - */ - let inEndpoint = interface1.endpoints[2]; - let outEndpoint = interface1.endpoints[1]; - let dataUint8Array = new Uint8Array(1024); - usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => { - if (dataLength >= 0) { - console.info("usb readData result Length : " + dataLength); - } else { - console.info("usb readData failed : " + dataLength); - } - }).catch(error => { - console.info("usb readData error : " + JSON.stringify(error)); - }); - // Send data. Select the corresponding TX endpoint from deviceList for data transfer. (endpoint.direction == 0) - usb.bulkTransfer(pipe, outEndpoint, dataUint8Array, 15000).then(dataLength => { - if (dataLength >= 0) { - console.info("usb writeData result write length : " + dataLength); - } else { - console.info("writeData failed"); - } - }).catch(error => { - console.info("usb writeData error : " + JSON.stringify(error)); - }); - ``` - -5. Release the USB interface, and close the USB device. - - ```js - usb.releaseInterface(pipe, interface); - usb.closePipe(pipe); - ``` \ No newline at end of file + (endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array. + */ + let inEndpoint = interface1.endpoints[2]; + let outEndpoint = interface1.endpoints[1]; + let dataUint8Array = new Uint8Array(1024); + usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => { + if (dataLength >= 0) { + console.info("usb readData result Length : " + dataLength); + } else { + console.info("usb readData failed : " + dataLength); + } + }).catch(error => { + console.info("usb readData error : " + JSON.stringify(error)); + }); + // Send data. Select the corresponding TX endpoint from deviceList for data transfer. (endpoint.direction == 0) + usb.bulkTransfer(pipe, outEndpoint, dataUint8Array, 15000).then(dataLength => { + if (dataLength >= 0) { + console.info("usb writeData result write length : " + dataLength); + } else { + console.info("writeData failed"); + } + }).catch(error => { + console.info("usb writeData error : " + JSON.stringify(error)); + }); + ``` + +5. Release the USB interface, and close the USB device. + + ```js + usb.releaseInterface(pipe, interface1); + usb.closePipe(pipe); + ``` \ No newline at end of file diff --git a/en/application-dev/faqs/Readme-EN.md b/en/application-dev/faqs/Readme-EN.md index 636543eb3ed09b9d14f63fba8a466f6eb01ebea0..2d2d57ca6bb00f25c3db08338518910905417e5d 100644 --- a/en/application-dev/faqs/Readme-EN.md +++ b/en/application-dev/faqs/Readme-EN.md @@ -2,9 +2,9 @@ - [Full SDK Compilation](full-sdk-compile-guide.md) - [Switching to Full SDK](full-sdk-switch-guide.md) -- [Ability Development](faqs-ability.md) -- [ArkUI Development](faqs-arkui.md) -- [ArkUI Development (ArkTS Syntax)](faqs-arkui-arkts.md) +- [Application Model Development](faqs-ability.md) +- ArkUI Framework Development (ArkTS) + - [ArkUI Development (ArkTS Syntax)](faqs-arkui-arkts.md) - [Web Development](faqs-arkui-web.md) - [Bundle Management Development](faqs-bundle-management.md) - [Resource Manager Development](faqs-globalization.md) diff --git a/en/application-dev/faqs/faqs-ability.md b/en/application-dev/faqs/faqs-ability.md index b6901e40e6d84c622c41e487e30c62ba87a28ff4..fef66125771888f9dfe3dce2ae4297ce858d56b8 100644 --- a/en/application-dev/faqs/faqs-ability.md +++ b/en/application-dev/faqs/faqs-ability.md @@ -1,8 +1,8 @@ -# Ability Development +# Application Model Development ## How do I obtain a notification when the device orientation changes? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -14,7 +14,7 @@ Use the **UIAbility.onConfigurationUpdate\(\)** callback to subscribe to system ## How do I redirect a user to a specified page after they touch a service widget? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -42,7 +42,7 @@ Create a background task to provide the background service. ## Can I create a UIAbility and specify the process to run the UIAbility in the FA and Stage models? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -59,7 +59,7 @@ Yes. ## What are the differences between the stage model and the FA model in intra-process object sharing? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -72,7 +72,7 @@ Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) ## How do I use the lifecycle functions of AbilityStage? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -85,7 +85,7 @@ Add the field **"srcEntry": "./ets/myabilitystage/MyAbilityStage.ts"** under **m ## How do I delete the mission snapshot in Recents after terminateself is called in the multiton scenario? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -93,7 +93,7 @@ You can set **removeMissionAfterTerminate** to **true** in the **module.json5** ## Why can't I start a UIAbility instance by using startAbility\(\)? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -102,7 +102,7 @@ Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) ## How do I prevent "this" in a method from changing to "undefined" when the method is called? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -112,7 +112,7 @@ Method 2: Use the arrow function. ## What should I do when the error message "must have required property 'startWindowIcon'" is displayed during the UIAbility startup? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -135,11 +135,11 @@ Configure the **startWindowIcon** attribute under **abilities** in the **module. **Reference** -[module.json5 Configuration File](../quick-start/module-configuration-file.md) +[module.json5 File](../quick-start/module-configuration-file.md) ## Can I obtain the context through globalThis in the stage model? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) Do not use **globalThis** to obtain the context in the stage model. @@ -151,7 +151,7 @@ This is because all the processes of an application share a JS VM instance in th ## What should I do when an error indicating too large size is reported during HAP deployment? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Symptom** @@ -165,11 +165,11 @@ You can split the HAP into multiple HAPs. ## How is data returned when startAbilityForResult is called? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** -The target UIAbilities uses **AbilityContext.terminateSelfWithResult** to terminate itselef and pass the result to **startAbilityForResult**. +The target UIAbilities uses **AbilityContext.terminateSelfWithResult** to terminate itself and pass the result to **startAbilityForResult**. **Reference** @@ -178,7 +178,7 @@ The target UIAbilities uses **AbilityContext.terminateSelfWithResult** to termin ## How do I obtain the system timestamp? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -209,7 +209,7 @@ Use the **@ohos.systemDateTime** API as follows: ## How do I obtain the cache directory of the current application? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -221,7 +221,7 @@ Use **Context.cacheDir** to obtain the cache directory of the application. ## In which JS file is the service widget lifecycle callback invoked? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -233,7 +233,7 @@ When a widget is created, a **FormAblity.ts** file is generated, which contains ## What should I do when the compilation on DevEco Studio fails while ServiceExtensionAbility and DataShareExtensionAbility APIs are used? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Symptom** @@ -250,7 +250,7 @@ The SDK downloaded using DevEco Studio is the public SDK. **Solution** -Third-party application cannot use **ServiceExtensionAbility** and **DataShareExtensionAbility**. To develop a system application, first [download the full SDK](../quick-start/full-sdk-switch-guide.md). +Third-party application cannot use **ServiceExtensionAbility** and **DataShareExtensionAbility**. To develop a system application, first [download the full SDK](../faqs/full-sdk-switch-guide.md). ## How do I obtain the temp and files paths at the application level? @@ -264,18 +264,99 @@ Obtain them from the application context. Specifically, use **this.context.getAp [Obtaining the Application Development Path](../application-models/application-context-stage.md#obtaining-the-application-development-path) +## Why the application is not deleted from the background mission list after it calls terminateSelf? + +Applicable to: OpenHarmony 3.2 Beta5 + +**Solution** + +This is because the **removeMissionAfterTerminate** field under **abilities** in the **module.json5** file of the UIAbility is set to **false** (default value). To enable the application snapshot to be automatically deleted when the application is destroyed, set this field to **true**. + +**Reference** + +[module.json5 File](../quick-start/module-configuration-file.md) + +## How does an application developed in the stage model start an application developed in the FA model? + +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) + +**Solution** + +Refer to the code snippet below: + +``` +let want = { + deviceId: "", // An empty deviceId indicates the local device. + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", + moduleName: "Module1", // moduleName is optional. + parameters: { // Custom information. + }, +} +// context is the AbilityContext of the FA model to be started. +context.startAbility(want).then(() => { + ... +}).catch((err) => { + ... +}) +``` + +## Can atomic services be implemented using JavaScript code only? + +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) + +**Solution** + +Currently, the directory structure of new widgets is css+hml+json. This means that the widgets cannot be implemented by using JavaScript code only. Event triggering and parameter transfer can be processed in JSON files. ## Can the lifecycle callback of a released FA widget be triggered when the widget is displayed in the service center so that the user login information can be obtained without opening the FA application? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** -After a widget is added, the **onCreate()** lifecycle is triggered so that related user information (silent login) can be displayed even when the application is not started. However, users must manually add the widget after the application is installed. +After a widget is added, the **onCreate\(\)** lifecycle is triggered so that related user information (silent login) can be displayed even when the application is not started. However, users must manually add the widget after the application is installed. + +## What should I do when the error message "\[c4d4d3492eb8531, 0, 0\] ContextDeal::startAbility fetchAbilities failed" is displayed during switching to another application? + +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) + +**Symptom** + +The **startAbility** API reports an error during redirection. + +**Solution** + +Use **startAbility** for implementation as follows: + +``` +import featureAbility from '@ohos.ability.featureAbility' +function onStartRemoteAbility() { +console.info('onStartRemoteAbility begin'); +let params; +let wantValue = { + bundleName: 'ohos.samples.etsDemo', + abilityName: 'ohos.samples.etsDemo.RemoteAbility', + deviceId: getRemoteDeviceId(), + parameters: params +}; +console.info('onStartRemoteAbility want=' + JSON.stringify(wantValue)); +featureAbility.startAbility({ + want: wantValue +}).then((data) => { +console.info('onStartRemoteAbility finished, ' + JSON.stringify(data)); +}); +console.info('onStartRemoteAbility end'); +} +``` + +**Reference** + +See [Starting a Local PageAbility] (../application-models/start-local-pageability.md). ## How do I implement service login by touching a widget? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -299,7 +380,7 @@ To create a service widget in the FA model, perform the following steps: ## How do I redirect to the application details page in Settings? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -319,35 +400,33 @@ Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** -You can use **UIAbility.Context** to obtain the context. +You can use **UIAbility.Context** to obtain the context. **Example** ``` -import UIAbility from '@ohos.app.ability.UIAbility'; +import common from '@ohos.app.ability.common'; -let UIAbilityContext = UIAbility.context; -let ApplicationContext = UIAbility.context.getApplicationContext(); @Entry @Component struct AbilityContextTest { // abilityContext - @State UIabilityInfo: string = 'Obtaining abilityInfo' - UIabilityContext: UIAbilityContext + @State UIAbilityInfo: string = 'Obtaining abilityInfo' + UIAbilityContext: common.UIAbilityContext aboutToAppear() { // Use getContext to obtain the context and convert it to abilityContext. - this.UIabilityContext = getContext(this) as UIAbilityContext + this.UIAbilityContext = getContext(this) as common.UIAbilityContext } build() { Row() { Column({ space: 20 }) { - Text(this.abilityInfo) + Text(this.UIAbilityInfo) .fontSize(20) - .onClick(()=>{ - this.UIabilityInfo = JSON.stringify(this.UIabilityContext.UIabilityInfo) - console.log(`ContextDemo abilityInfo= ${this.UIabilityInfo}`) + .onClick(() => { + this.UIAbilityInfo = JSON.stringify(this.UIAbilityContext.abilityInfo) + console.log(`ContextDemo abilityInfo = ${this.UIAbilityInfo}`) }) } .width('100%') @@ -356,3 +435,51 @@ struct AbilityContextTest { } } ``` + +## What should I do when starting a continuous task fails? + +Applicable to: OpenHarmony 3.2 Release (API version 9) + +**Symptom** + +A ServiceAbility is started by calling **featureAbility.startAbility\(\)**. When the ServiceAbility attempts to start a continuous task, the error message \{"code":201,"message":"BussinessError 201: Permission denied."\} is reported. + +**Solution** + +To start a continuous task in the background, you must configure the permission **ohos.permission.KEEP\_BACKGROUND\_RUNNING** in the **module.json5** file and declare the background mode for the ability that needs to use the continuous task. + +``` +"module": { + "abilities": [ + { + "backgroundModes": [ + "dataTransfer", + "location" + ], // Background mode + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.KEEP_BACKGROUND_RUNNING" // Continuous task permission + } + ] +} +``` + +**Reference** + +[ServiceAbility Configuration Items - backgroundModes](../application-models/serviceability-configuration.md) + +[Continuous Task Permission](../security/permission-list.md#ohospermissionkeep_background_running) + +[Continuous Task Development](../task-management/continuous-task-dev-guide.md#development-in-the-stage-model) + +## How do FA widgets exchange data? + +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) + +The widget interacts with the widget provider through the **postCardAction** API, and the provider updates data through the **updateForm** API. + +**Reference** + +[Widget Development in the FA Model](../application-models/widget-development-fa.md) diff --git a/en/application-dev/faqs/faqs-bundle-management.md b/en/application-dev/faqs/faqs-bundle-management.md index 71b1e01ffcffea415266fb90213fc722e4f5b628..7be0055748ce5ac6d53fd6b3bef55a59fa721bc5 100644 --- a/en/application-dev/faqs/faqs-bundle-management.md +++ b/en/application-dev/faqs/faqs-bundle-management.md @@ -2,7 +2,7 @@ ## How do I determine whether an application is a system application? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -14,7 +14,7 @@ Use **bundleManager.getApplicationInfo** (available only for system applications ## How do I obtain the version code and version name of an application? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -96,7 +96,7 @@ Applicable to: OpenHarmony 3.2 Beta5 ## How do I obtain the source file path of the current application? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -121,6 +121,81 @@ Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) ## Can I obtain the HAP information of other applications from the current application? +Applicable to: OpenHarmony 3.2 (API version 9) + +**Solution** + +Currently, only system applications can call the API to query information about other applications. + +- To query information about an application in the system, you must obtain the normal-level permission **ohos.permission.GET\_BUNDLE\_INFO** and call the **bundleManager.getApplicationInfo\(\)** API. + +- To query information about all applications in the system, you must obtain the system\_basic-level permission **ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED** and call the **bundleManager.getAllApplicationInfo\(\)** API. + +**Reference** + +[@ohos.bundle.bundleManager \(bundleManager\)](../reference/apis/js-apis-bundleManager.md) + +## How do I query the PID of a process? + +Applicable to: OpenHarmony 3.2 Beta (API version 9) + +**Solution** + +You can obtain the PID through the **@ohos.process** interface. + +**Example** + +``` +import process from '@ohos.process'; +private pid = process.pid; +``` + +**Reference** + +[@ohos.process \ (Obtaining Process Information\)](../reference/apis/js-apis-process.md) + +## How do I disable the maximize button? + Applicable to: OpenHarmony 3.2 Beta (API version 9) -According to the OpenHarmony security design specifications, the SDK does not provide APIs for third-party applications to obtain bundle information (including but not limited to the application name and version number) of other applications. +**Solution** + +You can use the **supportWindowModes** field to specify whether to display the maximize button. + +- **full\_screen** means that a window in full-screen mode is supported. + +- **split** means that a window in split-screen mode is supported. + +- **floating** means that a floating window is supported. + +**Example** + +``` +"abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "supportWindowMode": ["split", "floating"], + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } +] +``` + +**Reference** + +[supportWindowModes](../reference/apis/js-apis-bundleManager-abilityInfo.md) diff --git a/en/application-dev/faqs/faqs-graphics.md b/en/application-dev/faqs/faqs-graphics.md index 9469a35736ef859342d2c24bdcb9780e94445bf8..345cbf83c5b2976c810e78237cb2587eaa4b1404 100644 --- a/en/application-dev/faqs/faqs-graphics.md +++ b/en/application-dev/faqs/faqs-graphics.md @@ -23,7 +23,7 @@ try { ## How do I hide the status bar to get the immersive effect? -Applicable to: OpenHarmony 3.2 Beta5 (API version 9, stage model) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -59,7 +59,7 @@ Applicable to: OpenHarmony 3.2 Beta5 (API version 9, stage model) ## How do I obtain the window width and height? -Applicable to: OpenHarmony SDK 3.2 Beta5 (API version 9, stage model) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9, stage model) **Solution** @@ -90,3 +90,32 @@ try { console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); } ``` + +## How do I perform Gaussian blurring on images? + +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) + +**Solution** + +Import the **@ohos.multimedia.image** and **@ohos.effectKit** modules to process the image and add the blur effect. + +**Example** + +``` +import image from "@ohos.multimedia.image"; +import effectKit from "@ohos.effectKit"; + + const color = new ArrayBuffer(96); + let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; + image.createPixelMap(color, opts).then((pixelMap) => { + let radius = 5; + let headFilter = effectKit.createEffect(pixelMap); + if (headFilter != null) { + headFilter.blur(radius); + } + }) +``` + +**Reference** + +[blur](../reference/apis/js-apis-effectKit.md#blur) diff --git a/en/application-dev/faqs/faqs-multimedia.md b/en/application-dev/faqs/faqs-multimedia.md index 080860a9a5ca913d1d40d9de049f9220a66118da..6d15bc704000f19b61d2f753b46a38592b052f06 100644 --- a/en/application-dev/faqs/faqs-multimedia.md +++ b/en/application-dev/faqs/faqs-multimedia.md @@ -2,7 +2,7 @@ ## How do I obtain the frame data of a camera when using the XComponent to display the preview output stream of the camera? -Applicable to: OpenHarmony 3.2 (API version 9, stage model) +Applicable to: OpenHarmony 3.2 (API version 9) **Symptom** @@ -35,7 +35,7 @@ Create a dual-channel preview to obtain the frame data. ## How do I obtain the preview image of the front camera? -Applicable to: OpenHarmony 3.2 (API version 9, stage model) +Applicable to: OpenHarmony 3.2 (API version 9) **Solution** @@ -76,7 +76,7 @@ Applicable to: OpenHarmony 3.2 (API version 9, stage model) ## How do I set the camera focal length? -Applicable to: OpenHarmony 3.2 (API version 9, stage model) +Applicable to: OpenHarmony 3.2 (API version 9) **Solution** @@ -86,7 +86,7 @@ Applicable to: OpenHarmony 3.2 (API version 9, stage model) ## How do I play music in the background? -Applicable to: OpenHarmony 3.2 (API version 9, stage model) +Applicable to: OpenHarmony 3.2 (API version 9) **Symptom** @@ -105,7 +105,7 @@ Music cannot be played in the background. ## What should I do when multiple video components cannot be used for playback? -Applicable to: OpenHarmony 3.2 (API version 9, stage model) +Applicable to: OpenHarmony 3.2 (API version 9) **Symptom** @@ -115,10 +115,9 @@ A large number of video components are created. They cannot play media normally A maximum of 13 media player instances can be created. - ## How do I invoke the image library directly? -Applicable to: OpenHarmony 3.2 (API version 9, stage model) +Applicable to: OpenHarmony 3.2 (API version 9) **Solution** @@ -133,3 +132,69 @@ let want = { let context = getContext(this) as common.UIAbilityContext; context.startAbility(want); ``` + +## How do I apply for the media read/write permission on a device? + +Applicable to: OpenHarmony 3.2 (API version 9, stage model) + +**Solution** + +1. Configure the permissions **ohos.permission.READ\_MEDIA** and **ohos.permission.WRITE\_MEDIA** in the **module.json5** file. + + Example: + + ``` + { + "module" : { + "requestPermissions":[ + { + "name" : "ohos.permission.READ_MEDIA", + "reason": "$string:reason" + }, + { + "name" : "ohos.permission.WRITE_MEDIA", + "reason": "$string:reason" + } + ] + } + } + ``` + +2. Call **requestPermissionsFromUser** to request the permissions from end users in the form of a dialog box. This operation is required because the grant mode of both permissions is **user\_grant**. + + ``` + let context = getContext(this) as common.UIAbilityContext; + let atManager = abilityAccessCtrl.createAtManager(); + let permissions: Array = ['ohos.permission.READ_MEDIA','ohos.permission.WRITE_MEDIA'] + atManager.requestPermissionsFromUser(context, permissions) + .then((data) => { + console.log("Succeed to request permission from user with data: " + JSON.stringify(data)) + }).catch((error) => { + console.log("Failed to request permission from user with error: " + JSON.stringify(error)) + }) + ``` + +## How do I obtain the camera status? + +Applicable to: OpenHarmony 3.2 (API version 9, stage model) + +**Solution** + +The **cameraManager** class provides a listener to subscribe to the camera status. + +``` +cameraManager.on('cameraStatus', (cameraStatusInfo) => { + console.log(`camera : ${cameraStatusInfo.camera.cameraId}`); + console.log(`status: ${cameraStatusInfo.status}`); +}) +``` +CameraStatus: Enumerates the camera statuses. + +- **CAMERA_STATUS_APPEAR** (0): A camera appears. +- **CAMERA_STATUS_DISAPPEAR** (1): The camera disappears. +- **CAMERA_STATUS_AVAILABLE** (2): The camera is available. +- **CAMERA_STATUS_UNAVAILABLE** (3): The camera is unavailable. + +**Reference** + +[CameraStatus](../reference/apis/js-apis-camera.md#oncamerastatus) \ No newline at end of file diff --git a/en/application-dev/faqs/faqs-sensor.md b/en/application-dev/faqs/faqs-sensor.md index 3932b223fb5c6af755c9eae019851e37edfa6ef4..60a6f55f8f19f2336d0a3d7ab44a83b4191b0182 100644 --- a/en/application-dev/faqs/faqs-sensor.md +++ b/en/application-dev/faqs/faqs-sensor.md @@ -2,6 +2,24 @@ ## Are the APIs used for obtaining PPG and ECG sensor data open to individual developers? -Applicable to: OpenHarmony 3.1 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.1 Beta5 (API version 9) Data collected by the PPG and ECG sensors of wearable devices is personal privacy data. Therefore, relative APIs are not open to individual developers. + +## What should I do when error code 201 is reported during the calling of a vibrator API? + +Applicable to: OpenHarmony 3.2 (API version 9, stage model) + +**Symptom** + +The following error message (error code 201) is reported when an API of the vibrator module is called: + +vibrate fail, error.code: 201error.message: NaN + +**Solution** + +Permission verification failed. You must apply for the **ohos.permission.VIBRATE** permission. + +**Reference** + +[Applying for Permissions](../security/accesstoken-guidelines.md) \ No newline at end of file diff --git a/en/application-dev/faqs/faqs-third-fourth-party-library.md b/en/application-dev/faqs/faqs-third-fourth-party-library.md index 045a3f5efe77b0ad16b64960bbf015b62b07d46f..07101ee37f6977728b909a68caed82c92a324810 100644 --- a/en/application-dev/faqs/faqs-third-fourth-party-library.md +++ b/en/application-dev/faqs/faqs-third-fourth-party-library.md @@ -2,19 +2,19 @@ ## How do I obtain available third-party libraries? -Applicable to: OpenHarmony 3.1 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.1 Beta5 (API version 9) The three-party and four-party libraries that can be obtained through ohpm are summarized in the [OpenHarmony-TPC/tpc_resource repository](https://gitee.com/openharmony-tpc/tpc_resource). You can access this repository, and find the desired component based on the directory index. ## Which third-party libraries are related to network requests? -Applicable to: OpenHarmony 3.1 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.1 Beta5 (API version 9) The following third-party libraries are related to network requests: [Axios](https://gitee.com/openharmony-sig/axios), httpclient, and okdownload. For details, see the [OpenHarmony-TPC/tpc_resource repository](https://gitee.com/openharmony-tpc/tpc_resource). ## How do I use ohpm to import third- and fourth-party libraries? -Applicable to: OpenHarmony 3.1 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.1 Beta5 (API version 9) **Solution** diff --git a/en/application-dev/faqs/faqs-window-manager.md b/en/application-dev/faqs/faqs-window-manager.md index 7368ec7cbb95ee0235810464d822554cf2b1880d..cc3cb1074bd8ae828ae38925a74594311b0f6c35 100644 --- a/en/application-dev/faqs/faqs-window-manager.md +++ b/en/application-dev/faqs/faqs-window-manager.md @@ -2,7 +2,7 @@ ## How do I obtain the height of the status bar and navigation bar? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -44,7 +44,7 @@ export default class MainAbility extends Ability { ## How do I hide the status bar on the top of an application? -Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) **Solution** @@ -62,3 +62,101 @@ onWindowStageCreate(windowStage){ **Reference** [Window](../reference/apis/js-apis-window.md) + +## How do I lock the window in portrait mode so that it does not rotate with the device? + +Applicable to: OpenHarmony SDK 3.2 Beta5 (API version 9, stage model) + +**Solution** + +To lock the window in portrait mode, call **setPreferredOrientation** of the window module, with **orientation** set to **window.Orientation.PORTRAIT**. + +**Example** + +``` +import window from "@ohos.window"; +// 1. Obtain a Window instance. Specifically, you can call createWindow to create a window or findWindow to obtain an existing window. +let windowClass = null; +let config = {name: "alertWindow", windowType: window.WindowType.TYPE_SYSTEM_ALERT, ctx: this.context}; +try { + let promise = window.createWindow(config); + promise.then((data)=> { + windowClass = data; + console.info('Succeeded in creating the window. Data:' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to create the Window. Cause:' + JSON.stringify(err)); + });} catch (exception) { + console.error('Failed to create the window. Cause: ' + JSON.stringify(exception)); +} +// 2. Call setPreferredOrientation to set the window orientation. The value PROTRAIT indicates that the window is displayed in portrait mode. +let orientation = window.Orientation.PORTRAIT; +if (windowClass) { + windowClass.setPreferredOrientation(orientation, (err) => { + if (err.code) { + console.error('Failed to set window orientation. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting window orientation.'); +} +``` + +**Reference** + +[window.Orientation](../reference/apis/js-apis-window.md#orientation9) + +## Why do the isStatusBarLightIcon and isNavigationBarLightIcon attributes set by calling setWindowSystemBarProperties not take effect? + +Applicable to: OpenHarmony SDK 3.2 Beta5 (API version 9, stage model) + +**Solution** + +In effect, the **isStatusBarLightIcon** and **isNavigationBarLightIcon** attributes turn the font white when set to **true**. If **statusBarContentColor** is also set in **setWindowSystemBarProperties**, the **isStatusBarLightIcon** attribute does not take effect. Similarly, if **navigationBarContentColor** is set, the **isNavigationBarLightIcon** attribute does not take effect. + +**Reference** + +[window.SystemBarProperties](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-window.md#systembarproperties) + +## How do I keep the screen always on? + +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) + +**Solution** + +Obtain a **Window** instance, and call [setWindowKeepScreenOn](../reference/apis/js-apis-window.md#setwindowkeepscreenon9) to keep the screen always on. + +``` +let isKeepScreenOn = true; +try { + windowClass.setWindowKeepScreenOn(isKeepScreenOn, (err) => { + if (err.code) { + console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the screen to be always on.'); + }); +} catch (exception) { + console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception)); +} +``` + +## How do I listen for window size changes? + +Applicable to: OpenHarmony 3.2 Beta5 (API version 9) + +**Solution** + +Obtain a **Window** instance, and call **on\('windowSizeChange'\)** to listen for window size changes. + +``` +try { + windowClass.on('windowSizeChange', (data) => { + console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to enable the listener for window size changes. Cause: ' + JSON.stringify(exception)); +} +``` + +**Reference** + +[window.on\("windowSizeChange"\)](../reference/apis/js-apis-window.md#onwindowsizechange7) diff --git a/en/application-dev/internationalization/intl-guidelines.md b/en/application-dev/internationalization/intl-guidelines.md index fcac5325292b27f349f6c3dcadb627dca2dd0c03..44b69713783501cc21c0612fa2bb08390a53dcc0 100644 --- a/en/application-dev/internationalization/intl-guidelines.md +++ b/en/application-dev/internationalization/intl-guidelines.md @@ -111,7 +111,7 @@ The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capa let dateTimeFormat = new Intl.DateTimeFormat(); ``` - Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md#datetimeoptions9). + Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md#datetimeoptions6). ```js let options = {dateStyle: "full", timeStyle: "full"}; @@ -181,7 +181,7 @@ The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capa let numberFormat = new Intl.NumberFormat(); ``` - Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md#numberoptions9). + Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md#numberoptions6). ```js let options = {compactDisplay: "short", notation: "compact"}; @@ -240,7 +240,7 @@ Users in different regions have different requirements for string sorting. [Coll let collator = new Intl.Collator(); ``` - Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md#collatoroptions9). + Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md#collatoroptions8). The **sensitivity** parameter is used to specify the levels of differences that will be used for string comparison. The value **base** indicates that only characters are compared, but not the accent and capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **accent** indicates that the accent is considered, but not the capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **case** indicates that the capitalization is considered, but the accent. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **variant** indicates that the accent and capitalization are considered. For example, 'a' != 'b', 'a' == '', 'a'=='A'. ```js @@ -301,7 +301,7 @@ According to grammars in certain languages, the singular or plural form of a nou let pluralRules = new Intl.PluralRules(); ``` - Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md#pluralrulesoptions9). + Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md#pluralrulesoptions8). ```js let pluralRules = new Intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"}); @@ -349,7 +349,7 @@ According to grammars in certain languages, the singular or plural form of a nou let relativeTimeFormat = new Intl.RelativeTimeFormat(); ``` - Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md#relativetimeformatinputoptions9). + Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md#relativetimeformatinputoptions8). ```js let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}); @@ -384,4 +384,4 @@ According to grammars in certain languages, the singular or plural form of a nou ```js let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}); let options = relativeTimeFormat.resolvedOptions(); // options = {"locale": "zh-CN", "style": "long", "numeric": "always", "numberingSystem": "latn"} - ``` + ``` \ No newline at end of file diff --git a/en/application-dev/napi/Readme-EN.md b/en/application-dev/napi/Readme-EN.md index c6bdba99546cafb30a88b9b39c3cd552dfd4419e..1295e0798c8a2e98beace89c016828eac79d5a5a 100644 --- a/en/application-dev/napi/Readme-EN.md +++ b/en/application-dev/napi/Readme-EN.md @@ -1,67 +1,9 @@ # Native APIs -Native APIs are a set of native development interfaces and tools provided by the OHOS SDK. It enables the use of C or C++ code to implement key application functionalities. Native APIs provide part of basic underlying capabilities of OHOS, such as libc, graphics library, window system, multimedia, and compression library. They do not provide complete OHOS platform capabilities as JS APIs do. Native APIs are compiled into a dynamic library before being packed into the application. -## Native API Composition - -### Native API Directory Structure - -Native APIs are stored in the **$(SDK_ROOT)/native** directory of the SDK. They consist of the following parts: - -|Directory|Description| -|--|--| -|build|Used to build the toolchain.cmake script of the dynamic library in the application. The **ohos.toolchain.cmake** file in this directory defines OHOS cross compilation options.| -|build-tools|Stores build tools, such as CMake.| -|docs|Stores Native API reference documents, which is extracted from the header files using Doxgen.| -|llvm|Stores LLVM, a cross compiler that supports OHOS ABIs.| -|sysroot|Stores dependent files of build links, including header files and dynamic libraries.| - -### Native APIs - -|Category|Function|Introduced In| -|--|--|--| -|C standard library|C standard library interfaces based on musl. Currently, more than 1500 interfaces are provided.|API version 8| -|C++ standard library|C++ runtime library libc++_shared. This library must be packed or statically linked to the application during packing.|API version 8| -|Log|HiLog interfaces for printing logs to the system|API version 8| -|napi|A group of Node-APIs provided by ArkUI to facilitate access to the JS application environment during application development. Node-APIs are part of native APIs.|API version 8| -|XComponent|Provides surface and touchscreen event interfaces for developing high-performance graphics applications.|API version 8| -|libuv|Third-party asynchronous I/O library integrated by ArkUI.|API version 8| -|libz|zlib library that provides basic compression and decompression interfaces.|API version 8| -|Drawing|2D graphics library that can be used for drawing on the surface.|API version 8| -|OpenGL|OpenGL 3.0 interfaces.|API version 8| -|Rawfile|Application resource access interfaces that can be used to read various resources packed in the application.|API version 8| -|OpenSLES|Interface library used for 2D and 3D audio acceleration.|API version 8| -|Mindspore|AI model interface library.|API version 9| -|Bundle management|Bundle service interfaces that can be used to query bundle information of the application.|API version 8| - -Some native APIs use open source standards. For details, see [Native Standard Libraries Supported by OpenHarmony](https://docs.openharmony.cn/pages/v3.1/en/application-dev/reference/native-lib/third_party_libc/musl.md/) and [Node_API](https://docs.openharmony.cn/pages/v3.1/en/application-dev/reference/native-lib/third_party_napi/napi.md/). - -## Usage Guidelines - -### Scenarios Where Native APIs Are Recommended - -You can use native APIs when you want to: - -1. Develop performance-sensitive code in computing-intensive scenarios such as gaming and physical simulation. -2. Reuse the existing C or C++ library. -3. Customize libraries related to CPU features, such as neon acceleration. - -### Scenarios Where Native APIs Are Not Recommended - -You do not need to use native APIs when you want to: - -1. Write a native OHOS application. -2. Develop an application compatible on as many OHOS devices as possible. - -# Native API References - -- [Native API hello world]() - - This sample shows how to develop a hello native API library, which can display strings obtained from the hello library on the TS page. -- [Using Native APIs in Application Projects](napi-guidelines.md) - - This document describes how to use native APIs to interact with modules, interfaces, and asynchronous tasks in JS. +- [Introduction to Native APIs](introduction.md) +- [Using N-APIs in Application Projects](napi-guidelines.md) - [Drawing Development](drawing-guidelines.md) - [Raw File Development](rawfile-guidelines.md) - [Native Window Development](native-window-guidelines.md) - [Using MindSpore Lite for Model Inference](mindspore-lite-guidelines.md) -- [Connecting the Neural Network Runtime to an AI Inference Framework](neural-network-runtime-guidelines.md) +- [Connecting the Neural Network Runtime to an AI Inference Framework](neural-network-runtime-guidelines.md) \ No newline at end of file diff --git a/en/application-dev/napi/introduction.md b/en/application-dev/napi/introduction.md new file mode 100644 index 0000000000000000000000000000000000000000..fb7cebaf9afadc6669934924512c6104812c94cf --- /dev/null +++ b/en/application-dev/napi/introduction.md @@ -0,0 +1,52 @@ +# Introduction to Native APIs + +Native APIs are a set of native development interfaces and tools provided by the OHOS SDK. It enables the use of C or C++ code to implement key application functionalities. Native APIs provide part of basic underlying capabilities of OHOS, such as libc, graphics library, window system, multimedia, and compression library. They do not provide complete OHOS platform capabilities as JS APIs do. Native APIs are compiled into a dynamic library before being packed into the application. + +## Native API Composition + +### Native API Directory Structure + +Native APIs are stored in the **$(SDK_ROOT)/native** directory of the SDK. They consist of the following parts: + +|Directory|Description| +|--|--| +|build|Used to build the toolchain.cmake script of the dynamic library in the application. The **ohos.toolchain.cmake** file in this directory defines OHOS cross compilation options.| +|build-tools|Stores build tools, such as CMake.| +|docs|Stores Native API reference documents, which is extracted from the header files using Doxgen.| +|llvm|Stores LLVM, a cross compiler that supports OHOS ABIs.| +|sysroot|Stores dependent files of build links, including header files and dynamic libraries.| + +### Native APIs + +|Category|Function|Introduced In| +|--|--|--| +|C standard library|C standard library interfaces based on musl. Currently, more than 1500 interfaces are provided.|API version 8| +|C++ standard library|C++ runtime library libc++_shared. This library must be packed or statically linked to the application during packing.|API version 8| +|Log|HiLog interfaces for printing logs to the system|API version 8| +|napi|A group of Node-APIs provided by ArkUI to facilitate access to the JS application environment during application development. Node-APIs are part of native APIs.|API version 8| +|XComponent|Provides surface and touchscreen event interfaces for developing high-performance graphics applications.|API version 8| +|libuv|Third-party asynchronous I/O library integrated by ArkUI.|API version 8| +|libz|zlib library that provides basic compression and decompression interfaces.|API version 8| +|Drawing|2D graphics library that can be used for drawing on the surface.|API version 8| +|OpenGL|OpenGL 3.0 interfaces.|API version 8| +|Rawfile|Application resource access interfaces that can be used to read various resources packed in the application.|API version 8| +|OpenSLES|Interface library used for 2D and 3D audio acceleration.|API version 8| +|Mindspore|AI model interface library.|API version 9| +|Bundle management|Bundle service interfaces that can be used to query bundle information of the application.|API version 8| + +Some native APIs use open-source standards. For details, see [Native Standard Libraries Supported by OpenHarmony](../reference/native-lib/third_party_libc/musl.md) and [Node-API](../reference/native-lib/third_party_napi/napi.md). + +## Usage Guidelines + +### Scenarios Where Native APIs Are Recommended + +You can use native APIs when you want to: + +1. Develop performance-sensitive code in computing-intensive scenarios such as gaming and physical simulation. +2. Reuse the existing C or C++ library. +3. Customize libraries related to CPU features, such as neon acceleration. + +### Scenarios Where Native APIs Are Not Recommended
You do not need to use native APIs when you want to: + +1. Write a native OHOS application. +2. Develop an application compatible on as many OHOS devices as possible. diff --git a/en/application-dev/notification/figures/en-us_image_0000001466462305.png b/en/application-dev/notification/figures/en-us_image_0000001466462305.png index 740f4b79a9ee234008cad6cf3616a8f213569476..7db8892ea08d7bc75f87c1f90cc7bc7281a7e07e 100644 Binary files a/en/application-dev/notification/figures/en-us_image_0000001466462305.png and b/en/application-dev/notification/figures/en-us_image_0000001466462305.png differ diff --git a/en/application-dev/notification/notification-enable.md b/en/application-dev/notification/notification-enable.md index 4b0ecd303d8f13b3f7ba4f43364ddd53ffadc1d7..0ab05bec0d4ec44eee8f2c5c43151c2da6da51d3 100644 --- a/en/application-dev/notification/notification-enable.md +++ b/en/application-dev/notification/notification-enable.md @@ -1,17 +1,17 @@ # Enabling Notification -To publish a notification, you must have notification enabled for your application. You can call the [requestEnableNotification()](../reference/apis/js-apis-notificationManager.md#notificationrequestenablenotification) API to display a dialog box prompting the user to enable notification for your application. Note that the dialog box is displayed only when the API is called for the first time. +To publish a notification, you must have notification enabled for your application. You can call the [requestEnableNotification()](../reference/apis/js-apis-notificationManager.md#notificationmanagerrequestenablenotification) API to display a dialog box prompting the user to enable notification for your application. Note that the dialog box is displayed only when the API is called for the first time. - **Figure 1** Dialog box prompting the user to enable notification +**Figure 1** Dialog box prompting the user to enable notification ![en-us_image_0000001416585590](figures/en-us_image_0000001416585590.png) - Touching **allow** enables notification for the application, and touching **ban** keeps notification disabled. -- The dialog box will not be displayed again when [requestEnableNotification()](../reference/apis/js-apis-notificationManager.md#notificationrequestenablenotification) is called later. The user can manually enable notification as follows. - +- The dialog box will not be displayed again when [requestEnableNotification()](../reference/apis/js-apis-notificationManager.md#notificationmanagerrequestenablenotification) is called later. The user can manually enable notification as follows. + | 1. Swipe down from the upper left corner of the device screen to access the notification panel. | 2. Touch the **Settings** icon in the upper right corner. On the notification screen, locate the target application.| 3. Toggle on **Allow notifications**. | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | ![en-us_image_0000001417062434](figures/en-us_image_0000001417062434.png) | ![en-us_image_0000001466462297](figures/en-us_image_0000001466462297.png) | ![en-us_image_0000001466782025](figures/en-us_image_0000001466782025.png) | @@ -19,7 +19,7 @@ To publish a notification, you must have notification enabled for your applicati ## Available APIs -For details about the APIs, see [@ohos.notificationManager](../reference/apis/js-apis-notificationManager.md#notificationrequestenablenotification). +For details about the APIs, see [@ohos.notificationManager](../reference/apis/js-apis-notificationManager.md#notificationmanagerrequestenablenotification). **Table 1** Notification APIs diff --git a/en/application-dev/notification/notification-overview.md b/en/application-dev/notification/notification-overview.md index 6bef8be8fd446e62b3e3da04582b467c9ddc5961..f3dd4149d7b9c77be498f6d02abed67d9e070ab8 100644 --- a/en/application-dev/notification/notification-overview.md +++ b/en/application-dev/notification/notification-overview.md @@ -24,4 +24,5 @@ A notification is generated by the notification sender and sent to the notificat System applications also support notification-related configuration options, such as switches. The system configuration initiates a configuration request and sends the request to the notification subsystem for storage in the memory and database. +**Figure 1** Notification service process ![en-us_image_0000001466582017](figures/en-us_image_0000001466582017.png) diff --git a/en/application-dev/notification/notification-subscription.md b/en/application-dev/notification/notification-subscription.md index 95fe77de7feead97208082c12519523588cd6521..45e75f1f64606cfa89cae2cfae91b89a13faaa5c 100644 --- a/en/application-dev/notification/notification-subscription.md +++ b/en/application-dev/notification/notification-subscription.md @@ -16,19 +16,19 @@ The major APIs for notification subscription are described as follows. For detai | Name | Description| | -------- | -------- | | subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, callback: AsyncCallback<void>): void | Subscribes to notifications from a specific application.| -| subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback<void>): void | Subscribes to notifications from all applications. | +| subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback<void>): void | Subscribes to notifications from all applications. | **Table 2** Callbacks for notification subscription | Name | Description| | -------- | -------- | -| onConsume?:(data: SubscribeCallbackData) => void | Callback for receiving notifications. | -| onCancel?:(data: SubscribeCallbackData) => void | Callback for canceling notifications. | -| onUpdate?:(data: NotificationSortingMap) => void | Callback for notification sorting updates. | -| onConnect?:() => void; | Callback for subscription. | -| onDisconnect?:() => void; | Callback for unsubscription. | -| onDestroy?:() => void | Callback for disconnecting from the notification subsystem. | -| onDoNotDisturbDateChange?:(mode: notification.DoNotDisturbDate) => void | Callback for the Do Not Disturb (DNT) time changes.| +| onConsume?:(data: SubscribeCallbackData) => void | Callback for receiving notifications. | +| onCancel?:(data: SubscribeCallbackData) => void | Callback for canceling notifications. | +| onUpdate?:(data: NotificationSortingMap) => void | Callback for notification sorting updates. | +| onConnect?:() => void; | Callback for subscription. | +| onDisconnect?:() => void; | Callback for unsubscription. | +| onDestroy?:() => void | Callback for disconnecting from the notification subsystem. | +| onDoNotDisturbDateChange?:(mode: notification.DoNotDisturbDate) => void | Callback for the Do Not Disturb (DNT) time changes.| | onEnabledNotificationChanged?:(callbackData: EnabledNotificationCallbackData) => void | Callback for notification switch changes. | @@ -46,37 +46,38 @@ The major APIs for notification subscription are described as follows. For detai ```ts let subscriber = { - onConsume: function (data) { - let req = data.request; - console.info('[ANS] onConsume callback req.id: ' + req.id); - }, - onCancel: function (data) { - let req = data.request; - console.info('[ANS] onCancel callback req.id: : ' + req.id); - }, - onUpdate: function (data) { - console.info('[ANS] onUpdate in test'); - }, - onConnect: function () { - console.info('[ANS] onConnect in test'); - }, - onDisconnect: function () { - console.info('[ANS] onDisConnect in test'); - }, - onDestroy: function () { - console.info('[ANS] onDestroy in test'); - }, + onConsume: function (data) { + let req = data.request; + console.info(`onConsume callback. req.id: ${req.id}`); + }, + onCancel: function (data) { + let req = data.request; + console.info(`onCancel callback. req.id: ${req.id}`); + }, + onUpdate: function (data) { + let req = data.request; + console.info(`onUpdate callback. req.id: ${req.id}`); + }, + onConnect: function () { + console.info(`onConnect callback.}`); + }, + onDisconnect: function () { + console.info(`onDisconnect callback.}`); + }, + onDestroy: function () { + console.info(`onDestroy callback.}`); + }, }; ``` - + 4. Initiate notification subscription. ```ts notificationSubscribe.subscribe(subscriber, (err, data) => { // This API uses an asynchronous callback to return the result. if (err) { - console.error(`[ANS] subscribe failed, code is ${err.code}, message is ${err.message}`); + console.error(`Failed to subscribe notification. Code is ${err.code}, message is ${err.message}`); return; } - console.info(`[ANS] subscribeTest success : + ${data}`); + console.info(`Succeeded in subscribing to notification. Data: ${data}`); }); ``` diff --git a/en/application-dev/notification/notification-with-wantagent.md b/en/application-dev/notification/notification-with-wantagent.md index 47275ecabeed338cfb67cff44cb39c325498e0ff..638f53ef2f6f6fce1637468ba4c900496727f23d 100644 --- a/en/application-dev/notification/notification-with-wantagent.md +++ b/en/application-dev/notification/notification-with-wantagent.md @@ -4,7 +4,7 @@ A [WantAgent](../reference/apis/js-apis-app-ability-wantAgent.md) object encapsu Below you can see the process of adding a **WantAgent** object to a notification. The notification publisher requests a **WantAgent** object from the Ability Manager Service (AMS), and then sends a notification carrying the **WantAgent** object to the home screen. When the user touches the notification from the notification panel on the home screen, the **WantAgent** object is triggered. - **Figure 1** Publishing a notification with a WantAgent object +**Figure 1** Publishing a notification with a WantAgent object ![notification-with-wantagent](figures/notification-with-wantagent.png) @@ -15,11 +15,11 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ | Name| Description| | -------- | -------- | -|getWantAgent(info: WantAgentInfo, callback: AsyncCallback<WantAgent>): void | Creates a **WantAgent** object.| -|trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback<CompleteData>): void | Triggers a **WantAgent** object.| -|cancel(agent: WantAgent, callback: AsyncCallback<void>): void | Cancels a **WantAgent** object.| -|getWant(agent: WantAgent, callback: AsyncCallback<Want>): void | Obtains a **WantAgent** object.| -|equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback<boolean>): void | Checks whether two **WantAgent** objects are equal.| +| getWantAgent(info: WantAgentInfo, callback: AsyncCallback<WantAgent>): void | Creates a **WantAgent** object.| +| trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback<CompleteData>): void | Triggers a **WantAgent** object.| +| cancel(agent: WantAgent, callback: AsyncCallback<void>): void | Cancels a **WantAgent** object.| +| getWant(agent: WantAgent, callback: AsyncCallback<Want>): void | Obtains a **WantAgent** object.| +| equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback<boolean>): void | Checks whether two **WantAgent** objects are equal.| ## How to Develop @@ -42,20 +42,20 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ // Set the action type through operationType of WantAgentInfo. let wantAgentInfo = { - wants: [ - { - deviceId: '', - bundleName: 'com.example.myapplication', - abilityName: 'EntryAbility', - action: '', - entities: [], - uri: '', - parameters: {} - } - ], - operationType: wantAgent.OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags:[wantAgent.WantAgentFlags.CONSTANT_FLAG] + wants: [ + { + deviceId: '', + bundleName: 'com.example.myapplication', + abilityName: 'EntryAbility', + action: '', + entities: [], + uri: '', + parameters: {} + } + ], + operationType: wantAgent.OperationType.START_ABILITY, + requestCode: 0, + wantAgentFlags:[wantAgent.WantAgentFlags.CONSTANT_FLAG] }; ``` @@ -66,16 +66,16 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ // Set the action type through operationType of WantAgentInfo. let wantAgentInfo = { - wants: [ - { - action: 'event_name', // Set the action name. - parameters: {}, - } - ], - operationType: wantAgent.OperationType.SEND_COMMON_EVENT, - requestCode: 0, - wantAgentFlags: [wantAgent.WantAgentFlags.CONSTANT_FLAG], - } + wants: [ + { + action: 'event_name', // Set the action name. + parameters: {}, + } + ], + operationType: wantAgent.OperationType.SEND_COMMON_EVENT, + requestCode: 0, + wantAgentFlags: [wantAgent.WantAgentFlags.CONSTANT_FLAG], + }; ``` 4. Invoke the [getWantAgent()](../reference/apis/js-apis-app-ability-wantAgent.md#wantagentgetwantagent) API to create a **WantAgent** object. @@ -83,12 +83,12 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ ```typescript // Create a WantAgent object. wantAgent.getWantAgent(wantAgentInfo, (err, data) => { - if (err) { - console.error('[WantAgent]getWantAgent err=' + JSON.stringify(err)); - return; - } - console.info('[WantAgent]getWantAgent success'); - wantAgentObj = data; + if (err) { + console.error(`Failed to get want agent. Code is ${err.code}, message is ${err.message}`); + return; + } + console.info('Succeeded in geting want agent.'); + wantAgentObj = data; }); ``` @@ -97,25 +97,25 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ ```typescript // Create a NotificationRequest object. let notificationRequest: notificationManager.NotificationRequest = { - content: { - contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: 'Test_Title', - text: 'Test_Text', - additionalText: 'Test_AdditionalText', - }, + content: { + contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: 'Test_Title', + text: 'Test_Text', + additionalText: 'Test_AdditionalText', }, - id: 1, - label: 'TEST', - wantAgent: wantAgentObj, + }, + id: 1, + label: 'TEST', + wantAgent: wantAgentObj, } notificationManager.publish(notificationRequest, (err) => { - if (err) { - console.error(`[ANS] publish failed, code is ${err.code}, message is ${err.message}`); - return; - } - console.info(`[ANS] publish success`); + if (err) { + console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); + return; + } + console.info('Succeeded in publishing notification.'); }); ``` diff --git a/en/application-dev/notification/progress-bar-notification.md b/en/application-dev/notification/progress-bar-notification.md index db7cae812218c2f7b6c363d204baa04dfeeb639f..4f016fefcbb6912fa9a0b998c7b5feb672503eee 100644 --- a/en/application-dev/notification/progress-bar-notification.md +++ b/en/application-dev/notification/progress-bar-notification.md @@ -27,13 +27,14 @@ In the [NotificationTemplate](../reference/apis/js-apis-inner-notification-notif ```ts notificationManager.isSupportTemplate('downloadTemplate').then((data) => { console.info(`[ANS] isSupportTemplate success`); + console.info('Succeeded in supporting download template notification.'); let isSupportTpl: boolean = data; // The value true means that the template of the downloadTemplate type is supported, and false means the opposite. // ... }).catch((err) => { - console.error(`[ANS] isSupportTemplate failed, code is ${err.code}, message is ${err.message}`); + console.error(`Failed to support download template notification. Code is ${err.code}, message is ${err.message}`); }); ``` - + > **NOTE** > > Proceed with the step below only when the specified template is supported. @@ -61,9 +62,9 @@ In the [NotificationTemplate](../reference/apis/js-apis-inner-notification-notif // Publish the notification. notificationManager.publish(notificationRequest, (err) => { if (err) { - console.error(`[ANS] publish failed, code is ${err.code}, message is ${err.message}`); + console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); return; } - console.info(`[ANS] publish success `); + console.info('Succeeded in publishing notification.'); }); ``` diff --git a/en/application-dev/notification/text-notification.md b/en/application-dev/notification/text-notification.md index 7901a78a4c547ca02caae191b551d27f6cae3e3a..fb1455e0dcdd791db6658935b48e90a6f14a3a14 100644 --- a/en/application-dev/notification/text-notification.md +++ b/en/application-dev/notification/text-notification.md @@ -3,8 +3,7 @@ You can publish basic notifications to send SMS messages, prompt messages, and advertisements. Available content types of basic notifications include normal text, long text, multi-line text, and picture-attached. - - **Table 1** Basic notification content types +**Table 1** Basic notification content types | Type| Description| | -------- | -------- | @@ -13,16 +12,16 @@ You can publish basic notifications to send SMS messages, prompt messages, and a | NOTIFICATION_CONTENT_MULTILINE | Multi-line text notification.| | NOTIFICATION_CONTENT_PICTURE | Picture-attached notification.| +Notifications are displayed in the notification panel, which is the only supported subscriber to notifications. Below you can see two examples of the basic notification. -Notifications are displayed in the notification panel, which is the only system subscriber to notifications. Below you can see two examples of the basic notification. +**Figure 1** Examples of the basic notification -**Figure 1** Examples of the basic notification ![en-us_image_0000001466462305](figures/en-us_image_0000001466462305.png) ## Available APIs -The following table describes the APIs for notification publishing. You specify the notification type by setting the [NotificationRequest](../reference/apis/js-apis-notificationManager.md#notificationrequest) parameter in the APIs. +The following table describes the APIs for notification publishing. You specify the notification type by setting the [NotificationRequest](../reference/apis/js-apis-inner-notification-notificationRequest.md#notificationrequest) parameter in the APIs. | Name| Description| | -------- | -------- | @@ -48,21 +47,21 @@ The following table describes the APIs for notification publishing. You specify let notificationRequest: notificationManager.NotificationRequest = { id: 1, content: { - contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, // Basic notification - normal: { - title: 'test_title', - text: 'test_text', - additionalText: 'test_additionalText', - } + contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, // Basic notification + normal: { + title: 'test_title', + text: 'test_text', + additionalText: 'test_additionalText', + } } - } + }; notificationManager.publish(notificationRequest, (err) => { - if (err) { - console.error(`[ANS] publish failed, code is ${err.code}, message is ${err.message}`); - return; - } - console.info(`[ANS] publish success.`); + if (err) { + console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); + return; + } + console.info('Succeeded in publishing notification.'); }); ``` @@ -74,25 +73,25 @@ The following table describes the APIs for notification publishing. You specify let notificationRequest: notificationManager.NotificationRequest = { id: 1, content: { - contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, // Long-text notification - longText: { - title: 'test_title', - text: 'test_text', - additionalText: 'test_additionalText', - longText: 'test_longText', - briefText: 'test_briefText', - expandedTitle: 'test_expandedTitle', - } + contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, // Long-text notification + longText: { + title: 'test_title', + text: 'test_text', + additionalText: 'test_additionalText', + longText: 'test_longText', + briefText: 'test_briefText', + expandedTitle: 'test_expandedTitle', + } } - } + }; // Publish the notification. notificationManager.publish(notificationRequest, (err) => { - if (err) { - console.error(`[ANS] publish failed, code is ${err.code}, message is ${err.message}`); - return; - } - console.info(`[ANS] publish success.`); + if (err) { + console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); + return; + } + console.info('Succeeded in publishing notification.'); }); ``` @@ -104,24 +103,24 @@ The following table describes the APIs for notification publishing. You specify let notificationRequest: notificationManager.NotificationRequest = { id: 1, content: { - contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_MULTILINE, // Multi-line text notification - multiLine: { - title: 'test_title', - text: 'test_text', - briefText: 'test_briefText', - longTitle: 'test_longTitle', - lines: ['line_01', 'line_02', 'line_03', 'line_04'], - } + contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_MULTILINE, // Multi-line text notification + multiLine: { + title: 'test_title', + text: 'test_text', + briefText: 'test_briefText', + longTitle: 'test_longTitle', + lines: ['line_01', 'line_02', 'line_03', 'line_04'], + } } - } + }; // Publish the notification. notificationManager.publish(notificationRequest, (err) => { if (err) { - console.error(`[ANS] publish failed, code is ${err.code}, message is ${err.message}`); - return; + console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); + return; } - console.info(`[ANS] publish success`); + console.info('Succeeded in publishing notification.'); }); ``` @@ -132,27 +131,27 @@ The following table describes the APIs for notification publishing. You specify ```ts let imagePixelMap: PixelMap = undefined; // Obtain the PixelMap information. let notificationRequest: notificationManager.NotificationRequest = { - id: 1, - content: { - contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_PICTURE, - picture: { - title: 'test_title', - text: 'test_text', - additionalText: 'test_additionalText', - briefText: 'test_briefText', - expandedTitle: 'test_expandedTitle', - picture: imagePixelMap - } + id: 1, + content: { + contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_PICTURE, + picture: { + title: 'test_title', + text: 'test_text', + additionalText: 'test_additionalText', + briefText: 'test_briefText', + expandedTitle: 'test_expandedTitle', + picture: imagePixelMap } - } + } + }; // Publish the notification. notificationManager.publish(notificationRequest, (err) => { - if (err) { - console.error(`[ANS] publish failed, code is ${err.code}, message is ${err.message}`); - return; - } - console.info(`[ANS] publish success.`); + if (err) { + console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); + return; + } + console.info('Succeeded in publishing notification.'); }); ``` diff --git a/en/application-dev/quick-start/figures/ci_download.png b/en/application-dev/quick-start/figures/ci_download.png new file mode 100644 index 0000000000000000000000000000000000000000..da0d306e0f95a4fa114af51ca010d9109ae7e029 Binary files /dev/null and b/en/application-dev/quick-start/figures/ci_download.png differ diff --git a/en/application-dev/quick-start/figures/compiler.png b/en/application-dev/quick-start/figures/compiler.png new file mode 100644 index 0000000000000000000000000000000000000000..3854c378fd56761952b0f6443458e4ae663b3bf2 Binary files /dev/null and b/en/application-dev/quick-start/figures/compiler.png differ diff --git a/en/application-dev/quick-start/figures/sdk-structure.png b/en/application-dev/quick-start/figures/sdk-structure.png new file mode 100644 index 0000000000000000000000000000000000000000..18a9315151bc7b184a87c2f95b23238bbefc2b82 Binary files /dev/null and b/en/application-dev/quick-start/figures/sdk-structure.png differ diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index b942d5aa2a56cfc90c0496074d2ca7dda6d96b6f..f9a6af9e1de4ac19c1623914fcd7e6a62c41a3fd 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -120,6 +120,7 @@ - [@ohos.events.emitter (Emitter)](js-apis-emitter.md) - [@ohos.notificationManager (NotificationManager) (Recommended)](js-apis-notificationManager.md) - [@ohos.notificationSubscribe (NotificationSubscribe) (Recommended)](js-apis-notificationSubscribe.md) + - [@ohos.application.StaticSubscriberExtensionContext (NotificationSubscribe) (Recommended)](js-apis-application-StaticSubscriberExtensionContext.md) - [System Common Events (To Be Deprecated Soon)](commonEvent-definitions.md) - [@ohos.commonEvent (Common Event) (To Be Deprecated Soon)](js-apis-commonEvent.md) - [@ohos.notification (Notification) (To Be Deprecated Soon)](js-apis-notification.md) @@ -137,6 +138,10 @@ - [NotificationFlags](js-apis-inner-notification-notificationFlags.md) - [NotificationRequest](js-apis-inner-notification-notificationRequest.md) - [NotificationSlot](js-apis-inner-notification-notificationSlot.md) + - [NotificationSorting](js-apis-inner-notification-notificationSorting.md) + - [NotificationSortingMap](js-apis-inner-notification-notificationSortingMap.md) + - [NotificationSubscribeInfo](js-apis-inner-notification-notificationSubscribeInfo.md) + - [NotificationSubscriber](js-apis-inner-notification-notificationSubscriber.md) - [NotificationTemplate](js-apis-inner-notification-notificationTemplate.md) - [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) - Common Events @@ -320,7 +325,7 @@ - [@ohos.systemTimer (System Timer)](js-apis-system-timer.md) - [@ohos.wallpaper (Wallpaper)](js-apis-wallpaper.md) - [@ohos.web.webview (Webview)](js-apis-webview.md) - - [console (Log)](js-apis-logs.md) + - [Console](js-apis-logs.md) - [Timer](js-apis-timer.md) - application - [AccessibilityExtensionContext (Accessibility Extension Context)](js-apis-inner-application-accessibilityExtensionContext.md) @@ -330,6 +335,7 @@ - [@ohos.batteryStatistics (Battery Statistics)](js-apis-batteryStatistics.md) - [@ohos.brightness (Screen Brightness)](js-apis-brightness.md) - [@ohos.charger (Charging Type)](js-apis-charger.md) + - [@ohos.cooperate (Screen Hopping)](js-apis-devicestatus-cooperate.md) - [@ohos.deviceInfo (Device Information)](js-apis-device-info.md) - [@ohos.distributedHardware.deviceManager (Device Management)](js-apis-device-manager.md) - [@ohos.geoLocationManager (Geolocation Manager)](js-apis-geoLocationManager.md) @@ -344,6 +350,7 @@ - [@ohos.multimodalInput.mouseEvent (Mouse Event)](js-apis-mouseevent.md) - [@ohos.multimodalInput.pointer (Mouse Pointer)](js-apis-pointer.md) - [@ohos.multimodalInput.touchEvent (Touch Event)](js-apis-touchevent.md) + - [@ohos.multimodalInput.shortKey (Shortcut Key)](js-apis-shortKey.md) - [@ohos.power (System Power Management)](js-apis-power.md) - [@ohos.runningLock (Runninglock)](js-apis-runninglock.md) - [@ohos.sensor (Sensor)](js-apis-sensor.md) @@ -365,6 +372,7 @@ - [@ohos.configPolicy (Configuration Policy)](js-apis-configPolicy.md) - [@ohos.enterprise.accountManager (Account Management)](js-apis-enterprise-accountManager.md) - [@ohos.enterprise.adminManager (Enterprise Device Management)](js-apis-enterprise-adminManager.md) + - [@ohos.enterprise.applicationManager (Application Management)](js-apis-enterprise-applicationManager.md) - [@ohos.enterprise.bundleManager (Bundle Management)](js-apis-enterprise-bundleManager.md) - [@ohos.enterprise.dateTimeManager (System Time Management)](js-apis-enterprise-dateTimeManager.md) - [@ohos.enterprise.deviceControl (Device Control Management)](js-apis-enterprise-deviceControl.md) diff --git a/en/application-dev/reference/apis/development-intro.md b/en/application-dev/reference/apis/development-intro.md index d20577ab0a909e6e650ce09bbfb0524fb679bd4e..4be8ab6a6b3a12768761e9affa09345180c394fb 100644 --- a/en/application-dev/reference/apis/development-intro.md +++ b/en/application-dev/reference/apis/development-intro.md @@ -29,14 +29,14 @@ A description regarding system APIs will be provided in the document. A common application is an application whose application type is **hos_normal_app** in the HarmonyAppProvision configuration file. **hos_normal_app** is the default value for project creation. The public SDK, which does not include system APIs, is provided as standard in DevEco Studio. To use the system APIs, you must: -- Switch the public SDK to the full SDK by following the instructions provided in [Guide to Switching to Full SDK](../../faqs/full-sdk-switch-guide.md). -- Change the value of **app-feature** in the HarmonyAppProvision configuration file to **hos_system_app**. For details, see [HarmonyAppProvision Configuration File](../../security/app-provision-structure.md). +- Switch the public SDK to the full SDK by following the instructions provided in [Switching to Full SDK](../../faqs/full-sdk-switch-guide.md). +- Change the value of **app-feature** in the HarmonyAppProvision configuration file to **hos_system_app** (indicating a system application). For details, see [HarmonyAppProvision Configuration File](../../security/app-provision-structure.md). ## Permission Description -By default, applications can access limited system resources. However, in some cases, an application needs to access excess data (including personal data) and functions of the system or another application to implement extended functions. For details, see [Access Control (Permission) Overview](../../security/accesstoken-overview.md). +By default, applications can access limited system resources. However, in some cases, an application needs to access excess data (including personal data) and functions of the system or another application to implement extended functions. For details, see [Access Control Overview](../../security/accesstoken-overview.md). -To call APIs to access these resources, you must apply for the corresponding permissions by following the instructions provided in [Applying for Permissions](../../security/accesstoken-guidelines.md). +To call APIs to access these resources, you must apply for the corresponding permissions by following the instructions provided in [Access Control Development](../../security/accesstoken-guidelines.md). - If an application can call an API only after it has obtained a specific permission, the following description is provided for the API: "**Required permissions**: ohos.permission.xxxx" - If an application can call an API without any permission, no special description is provided. diff --git a/en/application-dev/reference/apis/js-apis-Bundle.md b/en/application-dev/reference/apis/js-apis-Bundle.md index c116f901789c4a0fd1898d28bb7e8fd69a1b38fc..db930ccbe8cc14f368b9e16d29b556074e981482 100644 --- a/en/application-dev/reference/apis/js-apis-Bundle.md +++ b/en/application-dev/reference/apis/js-apis-Bundle.md @@ -904,7 +904,7 @@ bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => { > This API is deprecated since API version 9. You are advised to use [bundleManager.getAllApplicationInfo](js-apis-bundleManager.md#bundlemanagergetallapplicationinfo) instead. -getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback>) : void; +getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback\\>): void; Obtains the information about all applications of the current user. This API uses an asynchronous callback to return the result. diff --git a/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md b/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md index 7ea0a7024970cffde1434f76ce911cce28dbcd2e..95d4b1e408a255be8f9830ecc0594640211a26e1 100644 --- a/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md @@ -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; + } +}; +``` + +## onAcquireFormData10+ + +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', diff --git a/en/application-dev/reference/apis/js-apis-app-form-formHost.md b/en/application-dev/reference/apis/js-apis-app-form-formHost.md index 0afda1db43c8830ffbf9eeb63cceae0c07a62f2c..d81c78c439f21e0ce60ff3df6e33c3d949ee980a 100644 --- a/en/application-dev/reference/apis/js-apis-app-form-formHost.md +++ b/en/application-dev/reference/apis/js-apis-app-form-formHost.md @@ -2222,7 +2222,7 @@ try { ## getRunningFormInfosByFilter10+ -function getRunningFormInfosByFilter(formProviderFilter: formInfo.FormProviderFilter): Promise<Array<formInfo.RunningFormInfo>> +getRunningFormInfosByFilter(formProviderFilter: formInfo.FormProviderFilter): Promise<Array<formInfo.RunningFormInfo>> 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 { ## getRunningFormInfosByFilter10+ -function getRunningFormInfosByFilter(formProviderFilter: formInfo.FormProviderFilter, callback: AsyncCallback<Array<formInfo.FormInfo>>): void +getRunningFormInfosByFilter(formProviderFilter: formInfo.FormProviderFilter, callback: AsyncCallback<Array<formInfo.FormInfo>>): 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 { ## getRunningFormInfoById10+ -function getRunningFormInfoById(formId: string): Promise<Array<formInfo.RunningFormInfo>> +getRunningFormInfoById(formId: string): Promise<Array<formInfo.RunningFormInfo>> 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 { ## getRunningFormInfoById10+ -function getRunningFormInfoById(formId: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void +getRunningFormInfoById(formId: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void Obtains the information about widget hosts based on the widget ID. This API uses an asynchronous callback to return the result. diff --git a/en/application-dev/reference/apis/js-apis-application-StaticSubscriberExtensionContext.md b/en/application-dev/reference/apis/js-apis-application-StaticSubscriberExtensionContext.md new file mode 100644 index 0000000000000000000000000000000000000000..f1c7c82e6af9bdeacc971596d47b217c72f1ddc9 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-application-StaticSubscriberExtensionContext.md @@ -0,0 +1,161 @@ +# @ohos.application.StaticSubscriberExtensionContext (StaticSubscriberExtensionContext) + +The **StaticSubscriberExtensionContext** module, inherited from **ExtensionContext**, provides context for StaticSubscriberExtensionAbilities. + +You can use the APIs of this module to start StaticSubscriberExtensionAbilities. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> The APIs of this module can be used only in the stage model. + +## Usage + +Before using the **StaticSubscriberExtensionContext** module, you must first obtain a **StaticSubscriberExtensionAbility** instance. + +```ts +import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility' + +export default class MyStaticSubscriberExtensionAbility extends StaticSubscriberExtensionAbility { + context = this.context; +}; +``` + +## StaticSubscriberExtensionContext.startAbility + +startAbility(want: Want, callback: AsyncCallback<void>): void; + +Starts an ability that belongs to the same application as this StaticSubscriberExtensionAbility. This API uses an asynchronous callback to return the result. + +Observe the following when using this API: + - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission. + - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------- | ---- | -------------------------- | +| want | [Want](js-apis-application-want.md) | Yes | Want information about the target ability. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| + +**Error codes** + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). + +| ID| Error Message | +| -------- | ------------------------------------------------------------ | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16000053 | The ability is not on the top of the UI. | +| 16000055 | Installation-free timed out. | +| 16200001 | The caller has been released. | +| 16300003 | The target application is not self application. | + +**Example** + + ```ts + let want = { + bundleName: "com.example.myapp", + abilityName: "MyAbility" + }; + + try { + this.context.startAbility(want, (error) => { + if (error) { + // Process service logic errors. + console.log('startAbility failed, error.code: ' + JSON.stringify(error.code) + + ' error.message: ' + JSON.stringify(error.message)); + return; + } + // Carry out normal service processing. + console.log('startAbility succeed'); + }); + } catch (paramError) { + // Process input parameter errors. + console.log('startAbility failed, error.code: ' + JSON.stringify(paramError.code) + + ' error.message: ' + JSON.stringify(paramError.message)); + } + ``` + +## StaticSubscriberExtensionContext.startAbility + +startAbility(want: Want): Promise<void>; + +Starts an ability that belongs to the same application as this StaticSubscriberExtensionAbility. This API uses a promise to return the result. + +Observe the following when using this API: + - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission. + - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ----------------------------------- | ---- | ----------------------- | +| want | [Want](js-apis-application-want.md) | Yes | Want information about the target ability.| + +**Return value** + +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise used to return the result.| + +**Error codes** + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). + +| ID| Error Message | +| -------- | ------------------------------------------------------------ | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16000053 | The ability is not on the top of the UI. | +| 16000055 | Installation-free timed out. | +| 16200001 | The caller has been released. | +| 16300003 | The target application is not self application. | + +**Example** + + ```ts + let want = { + bundleName: "com.example.myapp", + abilityName: "MyAbility" + }; + + try { + this.context.startAbility(want) + .then(() => { + // Carry out normal service processing. + console.log('startAbility succeed'); + }) + .catch((error) => { + // Process service logic errors. + console.log('startAbility failed, error.code: ' + JSON.stringify(error.code) + + ' error.message: ' + JSON.stringify(error.message)); + }); + } catch (paramError) { + // Process input parameter errors. + console.log('startAbility failed, error.code: ' + JSON.stringify(paramError.code) + + ' error.message: ' + JSON.stringify(paramError.message)); + } + ``` diff --git a/en/application-dev/reference/apis/js-apis-application-environmentCallback.md b/en/application-dev/reference/apis/js-apis-application-environmentCallback.md deleted file mode 100644 index 00396ca388d9145f2b3905166b2ef317959f2744..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/apis/js-apis-application-environmentCallback.md +++ /dev/null @@ -1,82 +0,0 @@ -# @ohos.application.EnvironmentCallback (EnvironmentCallback) - -The **EnvironmentCallback** module provides APIs, such as **onConfigurationUpdated** and **onMemoryLevel**, for the application context to listen for system environment changes. - -> **NOTE** -> -> The APIs of this module are supported since API version 9 and are deprecated in versions later than API version 9. You are advised to use [@ohos.app.ability.EnvironmentCallback](js-apis-app-ability-environmentCallback.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version. -> The APIs of this module can be used only in the stage model. - - -## Modules to Import - -```ts -import EnvironmentCallback from '@ohos.application.EnvironmentCallback'; -``` - - -## EnvironmentCallback.onConfigurationUpdated - -onConfigurationUpdated(config: Configuration): void; - -Called when the system environment changes. - -**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore - -**Parameters** - - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | config | [Configuration](js-apis-application-configuration.md) | Yes| **Configuration** object after the change.| - -## EnvironmentCallback.onMemoryLevel - -onMemoryLevel(level: number): void; - -Called when the system memory level changes. - -**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore - -**Parameters** - - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | level | [MemoryLevel](js-apis-app-ability-abilityConstant.md#abilityconstantmemorylevel) | Yes| New memory level.| - -**Example** - - ```ts -import UIAbility from '@ohos.app.ability.UIAbility'; - -let callbackId; - -export default class EntryAbility extends UIAbility { - onCreate() { - console.log('MyAbility onCreate'); - globalThis.applicationContext = this.context.getApplicationContext(); - let environmentCallback = { - onConfigurationUpdated(config){ - console.log('onConfigurationUpdated config: ${JSON.stringify(config)}'); - }, - onMemoryLevel(level){ - console.log('onMemoryLevel level: ${level}'); - } - }; - // 1. Obtain an applicationContext object. - let applicationContext = globalThis.applicationContext; - // 2. Register a listener for the environment changes through the applicationContext object. - callbackId = applicationContext.registerEnvironmentCallback(environmentCallback); - console.log('registerEnvironmentCallback number: ${JSON.stringify(callbackId)}'); - } - onDestroy() { - let applicationContext = globalThis.applicationContext; - applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => { - if (error && error.code !== 0) { - console.error('unregisterEnvironmentCallback fail, error: ${JSON.stringify(error)}'); - } else { - console.log('unregisterEnvironmentCallback success, data: ${JSON.stringify(data)}'); - } - }); - } -} - ``` diff --git a/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md index 096433a60c44904bbe9b2f25d09e9384e192c7fb..c28c4372ba1cf10ad9c67669913de1b4ac06ae17 100644 --- a/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md @@ -13,6 +13,14 @@ The **StaticSubscriberExtensionAbility** module provides Extension abilities for import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility'; ``` +## Attributes + +**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore + +| Name | Type | Readable| Writable| Description | +| ------- | ------------------------------------------------------------ | ---- | ---- | -------- | +| context | [StaticSubscriberExtensionContext](js-apis-application-StaticSubscriberExtensionContext.md) | Yes | No | Context.| + ## StaticSubscriberExtensionAbility.onReceiveEvent onReceiveEvent(event: CommonEventData): void; @@ -30,7 +38,6 @@ Callback of the common event of a static subscriber. | event | [CommonEventData](js-apis-commonEventManager.md#commoneventdata) | Yes| Common event of a static subscriber.| **Example** - ```ts class MyStaticSubscriberExtensionAbility extends StaticSubscriberExtensionAbility { onReceiveEvent(event) { diff --git a/en/application-dev/reference/apis/js-apis-arkui-componentSnapshot.md b/en/application-dev/reference/apis/js-apis-arkui-componentSnapshot.md index 340a54ba1b1e5950cdced1971050c42590208f74..f8bbe2212f0b6b9ae41183bfce2ae7c03a726d99 100644 --- a/en/application-dev/reference/apis/js-apis-arkui-componentSnapshot.md +++ b/en/application-dev/reference/apis/js-apis-arkui-componentSnapshot.md @@ -1,6 +1,6 @@ # @ohos.arkui.componentSnapshot (Component Snapshot) -The **componentSnapshot** module provides APIs for obtaining component snapshots, including snapshots of components that have been loaded and snapshots of components that have not been loaded yet. +The **componentSnapshot** module provides APIs for obtaining component snapshots, including snapshots of components that have been loaded and snapshots of components that have not been loaded yet. Note that a component snapshot does not contain content drawn outside of the area of the owning component or the parent component. > **NOTE** > @@ -8,6 +8,7 @@ The **componentSnapshot** module provides APIs for obtaining component snapshots > > You can preview how this component looks on a real device. The preview is not yet available in the DevEco Studio Previewer. + ## Modules to Import ```js @@ -20,14 +21,18 @@ get(id: string, callback: AsyncCallback): void Obtains the snapshot of a component that has been loaded. This API uses an asynchronous callback to return the result. +> **NOTE** +> +> The snapshot captures content rendered in the last frame. If this API is called when the component triggers an update, the re-rendered content will not be included in the obtained snapshot. + **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------------------- | ---- | ------------------------------------------------------------------------------ | -| id | string | Yes | [ID](../arkui-ts/ts-universal-attributes-component-id.md) of the target component.| -| callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| -------- | ----------------------------------- | ---- | ---------------------------------------- | +| id | string | Yes | [ID](../arkui-ts/ts-universal-attributes-component-id.md) of the target component.| +| callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return the result. | **Example** @@ -45,8 +50,8 @@ struct SnapshotExample { Image(this.pixmap) .width(300).height(300) // ...Component - // ...Components - // ...Components + // ...Component + // ...Component Button("click to generate UI snapshot") .onClick(() => { componentSnapshot.get("root", (error: Error, pixmap: image.PixelMap) => { @@ -71,25 +76,29 @@ get(id: string): Promise Obtains the snapshot of a component that has been loaded. This API uses a promise to return the result. +> **NOTE** +> +> The snapshot captures content rendered in the last frame. If this API is called when the component triggers an update, the re-rendered content will not be included in the obtained snapshot. + **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------------------------------------------------------- | ---- | -------------------- | -| id | string | Yes | [ID](../arkui-ts/ts-universal-attributes-component-id.md) of the target component.| +| Name | Type | Mandatory | Description | +| ---- | ------ | ---- | ---------------------------------------- | +| id | string | Yes | [ID](../arkui-ts/ts-universal-attributes-component-id.md) of the target component.| **Return value** -| Type | Description | -| ----------------------------- | -------------- | +| Type | Description | +| ----------------------------- | -------- | | Promise<image.PixelMap> | Promise used to return the result.| **Error codes** -| ID| Error Message | -| -------- | ------------------- | -| 100001 | if id is not valid. | +| ID | Error Message | +| ------ | ------------------- | +| 100001 | if id is not valid. | **Example** @@ -134,14 +143,21 @@ createFromBuilder(builder: CustomBuilder, callback: AsyncCallback **NOTE** +> +> To account for the time spent in awaiting component building and rendering, the callback of offscreen snapshots has a delay of less than 500 ms. +> +> If a component is on a time-consuming task, for example, an **\** or **\** component that is loading online images, its loading may be still in progress when this API is called. In this case, the output snapshot does not represent the component in the way it looks when the loading is successfully completed. + + **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------------- | ---- | -------------------- | -| builder | [CustomBuilder](../arkui-ts/ts-types.md#custombuilder8) | Yes | Builder of the custom component.| -| callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ---------- | +| builder | [CustomBuilder](../arkui-ts/ts-types.md#custombuilder8) | Yes | Builder of the custom component.| +| callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return the result.| **Example** @@ -194,25 +210,31 @@ createFromBuilder(builder: CustomBuilder): Promise Renders a custom component in the application background and outputs its snapshot. This API uses a promise to return the result. +> **NOTE** +> +> To account for the time spent in awaiting component building and rendering, the callback of offscreen snapshots has a delay of less than 500 ms. +> +> If a component is on a time-consuming task, for example, an **\** or **\** component that is loading online images, its loading may be still in progress when this API is called. In this case, the output snapshot does not represent the component in the way it looks when the loading is successfully completed. + **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------------------------------------------------------- | ---- | -------------------- | -| builder | [CustomBuilder](../arkui-ts/ts-types.md#custombuilder8) | Yes | Builder of the custom component.| +| Name | Type | Mandatory | Description | +| ------- | ---------------------------------------- | ---- | ---------- | +| builder | [CustomBuilder](../arkui-ts/ts-types.md#custombuilder8) | Yes | Builder of the custom component.| **Return value** -| Type | Description | -| ----------------------------- | -------------- | +| Type | Description | +| ----------------------------- | -------- | | Promise<image.PixelMap> | Promise used to return the result.| **Error codes** -| ID| Error Message | -| -------- | ----------------------------------------- | -| 100001 | if builder is not a valid build function. | +| ID | Error Message | +| ------ | ---------------------------------------- | +| 100001 | if builder is not a valid build function. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-bundleManager.md b/en/application-dev/reference/apis/js-apis-bundleManager.md index 7962d8ae77ab77dc1bba0d72b4418d3da2f867a2..a4d1dab714b0b5f632b020d0b57d6c788b48d8b7 100644 --- a/en/application-dev/reference/apis/js-apis-bundleManager.md +++ b/en/application-dev/reference/apis/js-apis-bundleManager.md @@ -113,6 +113,7 @@ Enumerates the types of Extension abilities. | THUMBNAIL | 13 | ThumbnailExtensionAbility: provides thumbnails for files. This ability is reserved.| | PREVIEW | 14 | PreviewExtensionAbility: provides APIs for file preview so that other applications can be embedded and displayed in the current application. This ability is reserved.| | PRINT10+ | 15 | PrintExtensionAbility: provides APIs for printing images. Printing documents is not supported yet.| +| PUSH10+ | 17 | **PushExtensionAbility**: provides APIs for pushing scenario-specific messages. This ability is reserved.| | DRIVER10+ | 18 | DriverExtensionAbility: provides APIs for the peripheral driver. This type of ability is not supported yet.| | UNSPECIFIED | 255 | No type is specified. It is used together with **queryExtensionAbilityInfo** to query all types of Extension abilities.| diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index 1f90664de26360d3099d9f0870baabaad1063b23..a488a313beff34555f589b57bdea17ddbdbcc752 100644 --- a/en/application-dev/reference/apis/js-apis-call.md +++ b/en/application-dev/reference/apis/js-apis-call.md @@ -2057,7 +2057,7 @@ promise.then(data => { setCallWaiting\(slotId: number, activate: boolean, callback: AsyncCallback\\): void -Sets the call waiting switch. This API uses an asynchronous callback to return the result. +Specifies whether to enable the call waiting service. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -2099,7 +2099,7 @@ call.setCallWaiting(0, true, (err) => { setCallWaiting\(slotId: number, activate: boolean\): Promise\ -Sets the call waiting switch. This API uses a promise to return the result. +Specifies whether to enable the call waiting service. This API uses a promise to return the result. **System API**: This is a system API. @@ -2719,6 +2719,91 @@ call.off('mmiCodeResult', data => { }); ``` + +## call.on('audioDeviceChange')10+ + +on\(type: 'audioDeviceChange', callback: Callback\\): void + +Subscribes to audio device change events. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------------- | ---- | --------------------------------------------------- | +| type | string | Yes | Audio device change. This field has a fixed value of **audioDeviceChange**.| +| callback | Callback<[AudioDeviceInfo](#audiodeviceinfo10)> | Yes | Callback used to return the result. | + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +call.on('audioDeviceChange', data => { + console.log(`callback: data->${JSON.stringify(data)}`); +}); +``` + + +## call.off('audioDeviceChange')10+ + +off\(type: 'audioDeviceChange', callback?: Callback\\): void + +Unsubscribes from **audioDeviceChange** events. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------------------------- | ---- | --------------------------------------------------- | +| type | string | Yes | Audio device change. This field has a fixed value of **audioDeviceChange**.| +| callback | Callback<[AudioDeviceInfo](#audiodeviceinfo10)> | No | Callback used to return the result. If this parameter is not set, no subscription cancellation result will be received. | + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +call.off('audioDeviceChange', data => { + console.log(`callback: data->${JSON.stringify(data)}`); +}); +``` + + ## call.isNewCallAllowed8+ isNewCallAllowed\(callback: AsyncCallback\\): void @@ -3804,7 +3889,7 @@ call.updateImsCallMode(1, 1).then(() => { enableImsSwitch\(slotId: number, callback: AsyncCallback\\): void -Enables the IMS switch. This API uses an asynchronous callback to return the result. +Enables the IMS service. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -3845,7 +3930,7 @@ call.enableImsSwitch(0, (err) => { enableImsSwitch\(slotId: number\): Promise\ -Enables the IMS switch. This API uses a promise to return the result. +Enables the IMS service. This API uses a promise to return the result. **System API**: This is a system API. @@ -3893,7 +3978,7 @@ call.enableImsSwitch(0).then(() => { disableImsSwitch\(slotId: number, callback: AsyncCallback\\): void -Disables the IMS switch. This API uses an asynchronous callback to return the result. +Disables the IMS service. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -3934,7 +4019,7 @@ call.disableImsSwitch(0, (err) => { disableImsSwitch\(slotId: number\): Promise\ -Disables the IMS switch. This API uses a promise to return the result. +Disables the IMS service. This API uses a promise to return the result. **System API**: This is a system API. @@ -3982,7 +4067,7 @@ call.disableImsSwitch(0).then(() => { isImsSwitchEnabled\(slotId: number, callback: AsyncCallback\\): void -Checks whether the IMS switch is enabled. This API uses an asynchronous callback to return the result. +Checks whether the IMS service is enabled. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -4020,7 +4105,7 @@ call.isImsSwitchEnabled(0, (err, data) => { isImsSwitchEnabled\(slotId: number\): Promise\ -Checks whether the IMS switch is enabled. This API uses a promise to return the result. +Checks whether the IMS service is enabled. This API uses a promise to return the result. **System API**: This is a system API. @@ -4062,6 +4147,472 @@ promise.then(data => { }); ``` + +## call.closeUnfinishedUssd10+ + +closeUnfinishedUssd\(slotId: number, callback: AsyncCallback\\): void + +Cancels the unfinished USSD services. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let slotId = 0; +call.closeUnfinishedUssd(slotId, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); +}); +``` + +## call.closeUnfinishedUssd10+ + +closeUnfinishedUssd\(slotId: number\): Promise\ + +Cancels the unfinished USSD services. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | + +**Return value** + +| Type | Description | +| ------------------- | --------------------------- | +| Promise<void> | Promise used to return the result. | + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let slotId = 0; +call.closeUnfinishedUssd(slotId).then(() => { + console.log(`closeUnfinishedUssd success.`); +}).catch((err) => { + console.error(`closeUnfinishedUssd fail, promise: err->${JSON.stringify(err)}`); +}); +``` + + +## call.setVoNRState10+ + +setVoNRState\(slotId: number, state: VoNRState, callback: AsyncCallback\\): void + +Sets the status of the VoNR switch. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ----------------------------- | ---- | ---------------------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| state | [VoNRState](#vonrstate10) | Yes | Status of the VoNR switch. | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. Callback used to return the result. The value **true** indicates that the operation is successful, and value **false** indicates the opposite.| + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let slotId = 0; +let state = 1; +call.setVoNRState(slotId, state, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.setVoNRState10+ + +setVoNRState\(slotId: number, state: VoNRState\): Promise\ + +Sets the status of the VoNR switch. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ----------------------------- | ---- | ------------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| state | [VoNRState](#vonrstate10) | Yes | Status of the VoNR switch. | + +**Return value** + +| Type | Description | +| ---------------------- | --------------------------------------------- | +| Promise<boolean> | Promise used to return the result. | + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let slotId = 0; +let state = 1; +call.setVoNRState(slotId, state).then(() => { + console.log(`setVoNRState success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`setVoNRState fail, promise: err->${JSON.stringify(err)}`); +}); +``` + + +## call.getVoNRState10+ + +getVoNRState\(slotId: number, callback: AsyncCallback\\): void + +Obtains the status of the VoNR switch. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.GET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | --------------------------------------------- | ---- | ------------------------------------------------------ | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| callback | AsyncCallback<[VoNRState](#vonrstate10)>| Yes | Callback used to return the result. | + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let slotId = 0; +call.getVoNRState(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.getVoNRState10+ + +getVoNRState\(slotId: number\): Promise\ + +Obtains the status of the VoNR switch. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.GET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ----------------------------- | ---- | ------------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | + +**Return value** + +| Type | Description | +| ---------------------------------------- | ------------------------------------------- | +| Promise<[VoNRState](#vonrstate10)> | Promise used to return the result. | + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let slotId = 0; +let promise = call.getVoNRState(slotId); +promise.then(data => { + console.log(`getVoNRState success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getVoNRState fail, promise: err->${JSON.stringify(err)}`); +}); +``` + + +## call.canSetCallTransferTime10+ + +canSetCallTransferTime\(slotId: number, callback: AsyncCallback\\): void + +Checks whether the call forwarding time can be set. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.GET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ----------------------------- | ---- | ----------------------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. Callback used to return the result. The value **true** indicates that the call forwarding time can be set, and the value **false** indicates the opposite.| + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let slotId = 0; +call.canSetCallTransferTime(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.canSetCallTransferTime10+ + +canSetCallTransferTime\(slotId: number\): Promise\ + +Checks whether the call forwarding time can be set. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.GET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ----------------------------- | ---- | ------------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | + +**Return value** + +| Type | Description | +| ---------------------- | --------------------------------------------- | +| Promise<boolean> | Promise used to return the result.| + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let slotId = 0; +call.canSetCallTransferTime(slotId).then(() => { + console.log(`canSetCallTransferTime success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`canSetCallTransferTime fail, promise: err->${JSON.stringify(err)}`); +}); +``` + + +## call.inputDialerSpecialCode10+ + +inputDialerSpecialCode\(inputCode: string, callback: AsyncCallback\\): void + +Performs a secret code broadcast. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required Permissions**: ohos.permission.PLACE_CALL + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ---------------------------- | ---- | ----------------------------------------- | +| inputCode | string | Yes | Secret code, for example, **2846579** (project menu).| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | + +**Example** + +```js +call.inputDialerSpecialCode('2846579', (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); +}); +``` + +## call.inputDialerSpecialCode10+ + +inputDialerSpecialCode\(inputCode: string\): Promise\ + +Performs a secret code broadcast. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required Permissions**: ohos.permission.PLACE_CALL + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ---------------------------- | ---- | ----------------------------------------- | +| inputCode | string | Yes | Secret code, for example, **2846579** (project menu).| + +**Return value** + +| Type | Description | +| ------------------- | --------------------------- | +| Promise<void> | Promise used to return the result.| + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | + +**Example** + +```js +try { + call.inputDialerSpecialCode('2846579'); + console.log(`inputDialerSpecialCode success`); +} catch (error) { + console.log(`inputDialerSpecialCode fail, promise: err->${JSON.stringify(error)}`); +} +``` + + ## DialOptions Provides an option for determining whether a call is a video call. @@ -4071,23 +4622,25 @@ Provides an option for determining whether a call is a video call. | Name | Type | Mandatory| Description | | ------------------------ | ---------------------------------- | ---- | ----------------------------------------------------------------------------------------------- | | extras | boolean | No | Indication of a video call.
- **true**: video call
- **false** (default): voice call | -| accountId 8+ | number | No | Account ID.
- **0**: card slot 1
- **1**: card slot 2
| -| videoState 8+ | [VideoStateType](#videostatetype7) | No | Video state type. | -| dialScene 8+ | [DialScene](#dialscene8) | No | Dialup scenario. | -| dialType 8+ | [DialType](#dialtype8) | No | Dialup type. | +| accountId 8+ | number | No | Account ID.
- **0**: card slot 1
- **1**: card slot 2
This is a system API. | +| videoState 8+ | [VideoStateType](#videostatetype7) | No | Video state type. This is a system API. | +| dialScene 8+ | [DialScene](#dialscene8) | No | Dialup scenario. This is a system API. | +| dialType 8+ | [DialType](#dialtype8) | No | Dialup type. This is a system API. | ## DialCallOptions9+ Defines options for initiating a call. +**System API**: This is a system API. + **System capability**: SystemCapability.Telephony.CallManager -| Name | Type | Mandatory| Description | -| ------------------------ | ---------------------------------- | ---- | ------------------------------------------------------------ | -| accountId 9+ | number | No | Account ID.
- **0**: card slot 1
- **1**: card slot 2
This is a system API.| -| videoState 9+ | [VideoStateType](#videostatetype7) | No | Video state type. This is a system API. | -| dialScene 9+ | [DialScene](#dialscene8) | No | Dialup scenario. This is a system API. | -| dialType 9+ | [DialType](#dialtype8) | No | Dialup type. This is a system API. | +| Name | Type | Mandatory| Description | +| ------------------------ | ---------------------------------- | ---- | ------------------------------------------- | +| accountId 9+ | number | No | Account ID.
- **0**: card slot 1
- **1**: card slot 2
| +| videoState 9+ | [VideoStateType](#videostatetype7) | No | Video state type. | +| dialScene 9+ | [DialScene](#dialscene8) | No | Dialup scenario. | +| dialType 9+ | [DialType](#dialtype8) | No | Dialup type. | ## CallState @@ -4138,6 +4691,19 @@ Enumerates IMS call modes. | CALL_MODE_SEND_RECEIVE | 3 | Sending and receiving calls.| | CALL_MODE_VIDEO_PAUSED | 4 | Pausing video calls. | +## VoNRState10+ + +Enumerates VoNR switch states. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Telephony.CallManager + +| Name | Value | Description | +| ---------------------- | ---- | ----------------- | +| VONR_STATE_OFF | 0 | Disabled. | +| VONR_STATE_ON | 1 | Enabled. | + ## AudioDevice8+ Enumerates audio devices. @@ -4154,6 +4720,36 @@ Enumerates audio devices. | DEVICE_BLUETOOTH_SCO | 3 | Bluetooth SCO device. | | DEVICE_MIC | 4 | Microphone device| +## AudioDeviceType10+ + +Enumerates audio device types. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Telephony.CallManager + +| Name | Value | Description | +| -------------------- | ---- | ----------- | +| DEVICE_EARPIECE | 0 | Headset device. | +| DEVICE_SPEAKER | 1 | Speaker device. | +| DEVICE_WIRED_HEADSET | 2 | Wired headset device.| +| DEVICE_BLUETOOTH_SCO | 3 | Bluetooth SCO device. | + +## AudioDeviceInfo10+ + +Defines the audio device information. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Telephony.CallManager + +| Name | Type | Mandatory | Description | +| --------------------------------- | ------------------------------------- | ---- | ---------------- | +| audioDeviceList 10+ | [Array\](#audiodevice8) | Yes | Audio device list. | +| currentAudioDevice 10+ | [AudioDevice](#audiodevice8) | Yes | Audio device type. | +| isMuted 10+ | boolean | Yes | Whether the audio device is muted. | + + ## CallRestrictionType8+ Enumerates call restriction types. @@ -4511,7 +5107,7 @@ Enumerates call disconnection causes. | BEARER_SERVICE_NOT_IMPLEMENTED9+ | 65 | Bearer service not implemented. | | ACM_EQUALTO_OR_GREATER_THAN_THE_MAXIMUM_VALUE9+ | 68 | ACM greater than or equal to the maximum value. | | REQUESTED_FACILITY_NOT_IMPLEMENTED9+ | 69 | Requested facility not implemented. | -| ONLY_RESTRICTED_DIGITAL_INFO_BEARER_CAPABILITY_IS_AVAILABLE9+ | 70 | Only restricted digital information capability available. | +| ONLY_RESTRICTED_DIGITAL_INFO_BEARER_CAPABILITY_IS_AVAILABLE9+ | 70 | Only restricted digital information bearer capability available. | | SERVICE_OR_OPTION_NOT_IMPLEMENTED_UNSPECIFIED9+ | 79 | Service or option not implemented, unspecified. | | INVALID_TRANSACTION_IDENTIFIER_VALUE9+ | 81 | Invalid transaction identifier value. | | USER_NOT_MEMBER_OF_CUG9+ | 87 | User not member of CUG. | diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md index 106aa2ecdcea58b97966a46e1f4ea38bcb2432eb..b8d4e4b54a0d34826962b8d3d66b5e7f1b30be13 100644 --- a/en/application-dev/reference/apis/js-apis-camera.md +++ b/en/application-dev/reference/apis/js-apis-camera.md @@ -550,7 +550,7 @@ Listens for camera status changes. This API uses an asynchronous callback to ret **Example** ```js -cameraManager.on('cameraStatus', (cameraStatusInfo) => { +cameraManager.on('cameraStatus', (err, cameraStatusInfo) => { console.log(`camera : ${cameraStatusInfo.camera.cameraId}`); console.log(`status: ${cameraStatusInfo.status}`); }) @@ -1679,7 +1679,7 @@ The coordinate system is based on the horizontal device direction with the devic | Name | Type | Mandatory| Description | | ------------- | -------------------------------| ---- | ------------------- | -| exposurePoint | [Point](#point) | Yes | Exposure point. | +| exposurePoint | [Point](#point) | Yes | Metering point. The value range of x and y must be within [0,1]. If a value less than 0 is passed, the value **0** is used. If a value greater than **1** is passed, the value **1** is used. | **Return value** @@ -1754,7 +1754,7 @@ Before the setting, you are advised to use **[getExposureBiasRange](#getexposure | Name | Type | Mandatory| Description | | -------- | -------------------------------| ---- | ------------------- | -| exposureBias | number | Yes | Exposure bias to set, which must be within the range obtained by running **getExposureBiasRange** interface. If the API call fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +| exposureBias | number | Yes | EV. The supported EV range can be obtained by calling **getExposureBiasRange**. If calling the API fails, an error code defined in [CameraErrorCode](#cameraerrorcode) will be returned. If the value passed is not within the supported range, the nearest critical point is used.| **Error codes** @@ -1936,7 +1936,7 @@ The coordinate system is based on the horizontal device direction with the devic | Name | Type | Mandatory| Description | | -------- | ----------------------- | ---- | ------------------- | -| Point1 | [Point](#point) | Yes | Focal point. | +| Point1 | [Point](#point) | Yes | Focal point. The value range of x and y must be within [0,1]. If a value less than 0 is passed, the value **0** is used. If a value greater than **1** is passed, the value **1** is used. | **Return value** @@ -2075,7 +2075,7 @@ Sets a zoom ratio, with a maximum precision of two decimal places. | Name | Type | Mandatory| Description | | --------- | -------------------- | ---- | ------------------- | -| zoomRatio | number | Yes | Zoom ratio. You can use **getZoomRatioRange** to obtain the supported values.| +| zoomRatio | number | Yes | Zoom ratio. The supported zoom ratio range can be obtained by calling **getZoomRatioRange**. If the value passed is not within the supported range, the nearest critical point is used.| **Return value** @@ -2735,7 +2735,7 @@ Captures a photo with the specified shooting parameters. This API uses a promise | Name | Type | Mandatory| Description | | ------- | ------------------------------------------- | ---- | -------- | -| setting | [PhotoCaptureSetting](#photocapturesetting) | No | Shooting settings.| +| setting | [PhotoCaptureSetting](#photocapturesetting) | No | Shooting parameters. The input of **undefined** is processed as if no parameters were passed.| **Return value** diff --git a/en/application-dev/reference/apis/js-apis-enterprise-applicationManager.md b/en/application-dev/reference/apis/js-apis-enterprise-applicationManager.md new file mode 100644 index 0000000000000000000000000000000000000000..0f9d2852f88f7e6b729326e62fc3886422d63eb2 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-enterprise-applicationManager.md @@ -0,0 +1,434 @@ +# @ohos.enterprise.applicationManager (Application Management) + +The **applicationManager** module provides application management capabilities, including adding applications to or removing applications from an application blocklist, and obtaining the application blocklist. The application blocklist contains the applications that are forbidden to run. Only the enterprise device administrator applications can call the APIs provided by this module. + +> **NOTE** +> +> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> - The APIs of this module can be called only after a [device administrator application](js-apis-enterprise-adminManager.md#adminmanagerenableadmin) is enabled. + +## Modules to Import + +```js +import applicationManager from '@ohos.enterprise.applicationManager'; +``` + +## applicationManager.addDisallowedRunningBundles + +addDisallowedRunningBundles(admin: Want, appIds: Array\, callback: AsyncCallback<void>): void; + +Adds applications to the application blocklist using the specified device administrator application. This API uses an asynchronous callback to return the result. The applications added to the blocklist cannot run under the administrator user. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY + +**System capability**: SystemCapability.Customization.EnterpriseDeviceManager + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ------------------------------- | +| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | +| appIds | Array<string> | Yes | IDs of the applications to add. | +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). + +| ID| Error Message | +| ------- | ---------------------------------------------------------------------------- | +| 9200001 | the application is not an administrator of the device. | +| 9200002 | the administrator application does not have permission to manage the device. | + + +**Example** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; +let appIds = ["com.example.myapplication"]; + +applicationManager.addDisallowedRunningBundles(wantTemp, appIds, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## applicationManager.addDisallowedRunningBundles + +addDisallowedRunningBundles(admin: Want, appIds: Array\, userId: number, callback: AsyncCallback<void>): void; + +Adds applications to the application list for a user using the specified device administrator application. This API uses an asynchronous callback to return the result. The applications added to the blocklist cannot run under the user specified by **userId**. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY + +**System capability**: SystemCapability.Customization.EnterpriseDeviceManager + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----- | ----------------------------------- | ---- | ------- | +| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | +| appIds | Array<string> | Yes | IDs of the applications to add. | +| userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). + +| ID| Error Message | +| ------- | ---------------------------------------------------------------------------- | +| 9200001 | the application is not an administrator of the device. | +| 9200002 | the administrator application does not have permission to manage the device. | + +**Example** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; +let appIds = ["com.example.myapplication"]; + +applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## applicationManager.addDisallowedRunningBundles + +addDisallowedRunningBundles(admin: Want, appIds: Array\, userId?: number): Promise<void>; + +Adds applications to the application blocklist using the specified device administrator application. This API uses a promise to return the result. If **userId** is passed in when this API is called, the added applications cannot run under the specified user. If **userId** is not passed in, the added applications cannot run under the current user. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY + +**System capability**: SystemCapability.Customization.EnterpriseDeviceManager + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----- | ----------------------------------- | ---- | ------- | +| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | +| appIds | Array<string> | Yes | IDs of the applications to add. | +| userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| + +**Return value** + +| Type | Description | +| --------------------- | ------------------------- | +| Promise<void> | Promise that returns no value. An error object is thrown when the applications fail to be added. | + +**Error codes** + +For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). + +| ID| Error Message | +| ------- | ---------------------------------------------------------------------------- | +| 9200001 | the application is not an administrator of the device. | +| 9200002 | the administrator application does not have permission to manage the device. | + +**Example** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; +let appIds = ["com.example.myapplication"]; + +applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100).then(() => { + console.log("success"); +}).catch(error => { + console.log("error code:" + error.code + " error message:" + error.message); +}); +``` + +## applicationManager.removeDisallowedRunningBundles + +removeDisallowedRunningBundles(admin: Want, appIds: Array\, callback: AsyncCallback<void>): void; + +Removes applications from the application blocklist using the specified device administrator application. This API uses an asynchronous callback to return the result. If an application blocklist exists, the applications in the blocklist cannot run under the current user. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY + +**System capability**: SystemCapability.Customization.EnterpriseDeviceManager + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ------------------------------- | +| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | +| appIds | Array<string> | Yes | IDs of the applications to remove. | +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). + +| ID| Error Message | +| ------- | ---------------------------------------------------------------------------- | +| 9200001 | the application is not an administrator of the device. | +| 9200002 | the administrator application does not have permission to manage the device. | + +**Example** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; +let appIds = ["com.example.myapplication"]; + +applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## applicationManager.removeDisallowedRunningBundles + +removeDisallowedRunningBundles(admin: Want, appIds: Array\, userId: number, callback: AsyncCallback<void>): void; + +Removes applications from the application blocklist of a user using the specified device administrator application. This API uses an asynchronous callback to return the result. If an application blocklist exists, the applications in the blocklist cannot run under the user specified by **userId**. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY + +**System capability**: SystemCapability.Customization.EnterpriseDeviceManager + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----- | ----------------------------------- | ---- | ------- | +| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | +| appIds | Array<string> | Yes | IDs of the applications to remove. | +| userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). + +| ID| Error Message | +| ------- | ---------------------------------------------------------------------------- | +| 9200001 | the application is not an administrator of the device. | +| 9200002 | the administrator application does not have permission to manage the device. | + +**Example** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; +let appIds = ["com.example.myapplication"]; + +applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## applicationManager.removeDisallowedRunningBundles + +removeDisallowedRunningBundles(admin: Want, appIds: Array\, userId?: number): Promise<void>; + +Removes applications from the application blocklist using the specified device administrator application. This API uses a promise to return the result. If **userId** is passed in when this API is called to remove applications from the blocklist, the applications in the blocklist cannot run under the specified user. If **userId** is not passed in, the applications in the blocklist cannot run under the current user. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY + +**System capability**: SystemCapability.Customization.EnterpriseDeviceManager + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----- | ----------------------------------- | ---- | ------- | +| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | +| appIds | Array<string> | Yes | IDs of the applications to remove. | +| userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| + +**Return value** + +| Type | Description | +| --------------------- | ------------------------- | +| Promise<void> | Promise that returns no value. An error object is thrown when the applications fail to be removed. | + +**Error codes** + +For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). + +| ID| Error Message | +| ------- | ---------------------------------------------------------------------------- | +| 9200001 | the application is not an administrator of the device. | +| 9200002 | the administrator application does not have permission to manage the device. | + +**Example** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; +let appIds = ["com.example.myapplication"]; + +applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100).then(() => { + console.log("success"); +}).catch(error => { + console.log("error code:" + error.code + " error message:" + error.message); +}); +``` + +## applicationManager.getDisallowedRunningBundles + +getDisallowedRunningBundles(admin: Want, callback: AsyncCallback<Array<string>>): void; + +Obtains the application blocklist of the administrator user using the specified device administrator application. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY + +**System capability**: SystemCapability.Customization.EnterpriseDeviceManager + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ------------------------------- | +| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | +| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | + +**Error codes** + +For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). + +| ID| Error Message | +| ------- | ---------------------------------------------------------------------------- | +| 9200001 | the application is not an administrator of the device. | +| 9200002 | the administrator application does not have permission to manage the device. | + +**Example** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; + +applicationManager.getDisallowedRunningBundles(wantTemp, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## applicationManager.getDisallowedRunningBundles + +getDisallowedRunningBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void; + +Obtains the application blocklist of a user using the specified device administrator application. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY + +**System capability**: SystemCapability.Customization.EnterpriseDeviceManager + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ------------------------------- | +| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | +| userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| +| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | + +**Error codes** + +For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). + +| ID| Error Message | +| ------- | ---------------------------------------------------------------------------- | +| 9200001 | the application is not an administrator of the device. | +| 9200002 | the administrator application does not have permission to manage the device. | + +**Example** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; + +applicationManager.getDisallowedRunningBundles(wantTemp, 100, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## applicationManager.getDisallowedRunningBundles + +getDisallowedRunningBundles(admin: Want, userId?: number): Promise<Array<string>>; + +Obtains the application blocklist using the specified device administrator application. This API uses a promise to return the result. If **userId** is passed in when this API is called, the device administrator application obtains the application blocklist of the specified user. If **userId** is not passed in, the device administrator application obtains the application blocklist of the current user. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY + +**System capability**: SystemCapability.Customization.EnterpriseDeviceManager + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----- | ----------------------------------- | ---- | ------- | +| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.| +| userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| + +**Return value** + +| Type | Description | +| --------------------- | ------------------------- | +| Promise<Array<string>> | Promise used to return the application blocklist of the administrator user.| + +**Error codes** + +For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). + +| ID| Error Message | +| ------- | ---------------------------------------------------------------------------- | +| 9200001 | the application is not an administrator of the device. | +| 9200002 | the administrator application does not have permission to manage the device. | + +**Example** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; +applicationManager.getDisallowedRunningBundles(wantTemp, 100).then(() => { + console.log("success"); +}).catch(error => { + console.log("error code:" + error.code + " error message:" + error.message); +}); +``` diff --git a/en/application-dev/reference/apis/js-apis-i18n.md b/en/application-dev/reference/apis/js-apis-i18n.md index db85444d68f958ed8af462815a2865ddc02adc0f..fe9a116b82379a17518731accb378484eb71dfc2 100644 --- a/en/application-dev/reference/apis/js-apis-i18n.md +++ b/en/application-dev/reference/apis/js-apis-i18n.md @@ -46,7 +46,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -85,7 +85,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -116,7 +116,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -153,7 +153,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -191,7 +191,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -222,7 +222,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -257,7 +257,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -288,7 +288,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -323,7 +323,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -354,7 +354,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -389,7 +389,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -420,7 +420,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -455,7 +455,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -492,7 +492,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -530,7 +530,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -563,7 +563,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -594,7 +594,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -625,7 +625,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -660,7 +660,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```ts @@ -691,7 +691,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```ts @@ -1737,6 +1737,35 @@ Obtains the **TimeZone** object corresponding to the specified time zone city ID let timezone = I18n.TimeZone.getTimezoneFromCity("Shanghai"); ``` +### getTimezonesByLocation10+ + +static getTimezonesByLocation(longitude: number, latitude: number): Array<TimeZone> + +Creates an array of **TimeZone** objects corresponding to the specified longitude and latitude. + +**System capability**: SystemCapability.Global.I18n + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | ------ | ---- | ------ | +| longitude | number | Yes | Longitude. The value ranges from **-180** to **179.9**. A positive value is used for east longitude and a negative value is used for west longitude.| +| latitude | number | Yes | Latitude. The value ranges from **-90** to **89.9**. A positive value is used for north latitude and a negative value is used for south latitude.| + +**Return value** + +| Type | Description | +| -------- | ----------- | +| Array<[TimeZone](#timezone)> | Array of **TimeZone** objects.| + +**Example** + ```js + let timezoneArray = I18n.TimeZone.getTimezonesByLocation(-118.1, 34.0); + for (var i = 0; i < timezoneArray.length; i++) { + let tzId = timezoneArray[i].getID(); + } + ``` + ## Transliterator9+ diff --git a/en/application-dev/reference/apis/js-apis-image.md b/en/application-dev/reference/apis/js-apis-image.md index 9c6037df7f907354d71a6eacb211855b579945a5..34337fa9198edeeeab9d437bc084538777834d31 100644 --- a/en/application-dev/reference/apis/js-apis-image.md +++ b/en/application-dev/reference/apis/js-apis-image.md @@ -879,6 +879,53 @@ async function Demo() { } ``` +### getColorSpace10+ + +getColorSpace(): colorSpaceManager.ColorSpaceManager + +Obtains the color space of this image + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Return value** + +| Type | Description | +| ----------------------------------- | ---------------- | +| [colorSpaceManager.ColorSpaceManager](js-apis-colorSpaceManager.md#colorspacemanager) | Color space obtained.| + +**Example** + +```js +import colorSpaceManager from '@ohos.graphics.colorSpaceManager'; +async function Demo() { + let csm = pixelmap.getColorSpace(); +} +``` + +### setColorSpace10+ + +setColorSpace(colorSpace: colorSpaceManager.ColorSpaceManager): void + +Sets the color space for this image. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | --------------- | +| colorSpace | [colorSpaceManager.ColorSpaceManager](js-apis-colorSpaceManager.md#colorspacemanager) | Yes | Color space to set.| + +**Example** + +```js +import colorSpaceManager from '@ohos.graphics.colorSpaceManager'; +async function Demo() { + var csm = colorSpaceManager.create(colorSpaceName); + pixelmap.setColorSpace(csm); +} +``` + ### release7+ release():Promise\ @@ -937,7 +984,7 @@ Creates an **ImageSource** instance based on the URI. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ---------------------------------- | -| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.
Currently, the following formats are supported: JPG, PNG, GIF, BMP, Webp, and RAW.| +| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.
Currently, the following formats are supported: .jpg, .png, .gif, .bmp, .webp, and raw. For details, see [SVG Tags10+](#svg-tags). | **Return value** @@ -975,7 +1022,7 @@ Creates an **ImageSource** instance based on the URI. | Name | Type | Mandatory| Description | | ------- | ------------------------------- | ---- | ----------------------------------- | -| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.
Currently, the following formats are supported: JPG, PNG, GIF, BMP, Webp, and RAW.| +| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.
Currently, the following formats are supported: .jpg, .png, .gif, .bmp, .webp, and raw. For details, see [SVG Tags10+](#svg-tags). | | options | [SourceOptions](#sourceoptions9) | Yes | Image properties, including the image index and default property value.| **Return value** @@ -1553,10 +1600,10 @@ let decodeOpts = { editable: true, desiredSize: { width: 198, height: 202 }, rotate: 0, - desiredPixelFormat: RGBA_8888, + desiredPixelFormat: 3, index: 0, }; -let pixelmaplist = await imageSourceApi.createPixelMapList(decodeOpts); +let pixelmaplist = imageSourceApi.createPixelMapList(decodeOpts); ``` ### createPixelMapList10+ @@ -1604,7 +1651,7 @@ let decodeOpts = { editable: true, desiredSize: { width: 198, height: 202 }, rotate: 0, - desiredPixelFormat: RGBA_8888, + desiredPixelFormat: 3, index: 0, }; imageSourceApi.createPixelMap(decodeOpts, pixelmaplist => { @@ -1651,12 +1698,12 @@ Obtains an array of delay times. This API uses a promise to return the result. **Example** ```js -let delayTimes = await imageSourceApi.getDelayTime(); +let delayTimes = imageSourceApi.getDelayTime(); ``` ### getFrameCount10+ -getFrameCount(callback: AsyncCallback): void; +getFrameCount(callback: AsyncCallback\): void; Obtains the number of frames. This API uses an asynchronous callback to return the result. @@ -1693,7 +1740,7 @@ Obtains the number of frames. This API uses a promise to return the result. **Example** ```js -let frameCount = await imageSourceApi.getFrameCount(); +let frameCount = imageSourceApi.getFrameCount(); ``` ### release @@ -2787,7 +2834,50 @@ Describes the color components of an image. | pixelStride | number | Yes | No | Pixel stride. | | byteBuffer | ArrayBuffer | Yes | No | Component buffer.| -## ResponseCode +## Supplementary Information +### SVG Tags + +The SVG tags are supported since API verison 10. The used version is (SVG) 1.1. Currently, the following tags are supported: +- a +- circla +- clipPath +- defs +- ellipse +- feBlend +- feColorMatrix +- feComposite +- feDiffuseLighting +- feDisplacementMap +- feDistantLight +- feFlood +- feGaussianBlur +- feImage +- feMorphology +- feOffset +- fePointLight +- feSpecularLighting +- feSpotLight +- feTurbulence +- filter +- g +- image +- line +- linearGradient +- mask +- path +- pattern +- polygon +- polyline +- radialGradient +- rect +- stop +- svg +- text +- textPath +- tspan +- use + +### ResponseCode Enumerates the response codes returned upon build errors. diff --git a/en/application-dev/reference/apis/js-apis-inner-application-pacMap.md b/en/application-dev/reference/apis/js-apis-inner-application-pacMap.md deleted file mode 100644 index afdf5e6c84413edfcb7303ea1069fca74898bd7c..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/apis/js-apis-inner-application-pacMap.md +++ /dev/null @@ -1,9 +0,0 @@ -## PacMap - -[key: string]: number | string | boolean | Array\ | null; - -**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel - -| Name| Type| Mandatory| Description| -| ------ | ------ | ------ | ------ | -| [key: string] | number \| string \| boolean \| Array\ \| null | Yes| Data stored in key-value pairs.| diff --git a/en/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md b/en/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md index 38928f42669eb30db5746d2c68037aff2961870f..fd791bc36fe187786aee1454612faac8c97b2131 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md @@ -1559,3 +1559,84 @@ try { console.error(`startRecentAbility failed, code is ${err.code}, message is ${err.message}`); } ``` + +## ServiceExtensionContext.startAbilityByCallWithAccount10+ + +startAbilityByCallWithAccount(want: Want, accountId: number): Promise<Caller>; + +Starts an ability with the account ID specified and obtains the caller object for communicating with the ability. + +Observe the following when using this API: + - If an application needs to call this API to start an ability that belongs to another user, it must have the **ohos.permission.ABILITY_BACKGROUND_COMMUNICATION** and **ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS** permissions. + - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission. + - If **exported** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission. + - The rules for using this API in the same-device and cross-device scenarios are different. For details, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md). + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-want.md) | Yes| Information about the ability to start, including **abilityName**, **moduleName**, **bundleName**, **deviceId** (optional), and **parameters** (optional). If **deviceId** is left blank or null, the local ability is started. If **parameters** is left blank or null, the ability is started in the background.| +| accountId | number | Yes| ID of a system account. The value **-1** indicates the current user. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<Caller> | Promise used to return the caller object to communicate with.| + +**Error codes** + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). + +| ID| Error Message| +| ------- | -------------------------------- | +| 16000001 | Input error. The specified ability name does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Visibility verification failed. | +| 16000005 | Static permission denied. The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | Crowdtest App Expiration. | +| 16000011 | The context does not exist. | +| 16000050 | Internal Error. | +| 16200001 | The caller has been released. | + +**Example** + + ```ts + let caller; + + // ID of a system account. The value -1 indicates the current user. + let accountId = -1; + + // Specify the ability to start. + let want = { + bundleName: 'com.acts.actscalleeabilityrely', + moduleName: 'entry', + abilityName: 'EntryAbility' + deviceId: '' + parameters: { + // If the value of 'ohos.aafwk.param.callAbilityToForeground' is true, the ability is started in the foreground. If the value is false or not set, the ability is started in the background. + 'ohos.aafwk.param.callAbilityToForeground': true + } + }; + + try { + this.context.startAbilityByCallWithAccount(want, accountId) + .then((obj) => { + // Carry out normal service processing. + caller = obj; + console.log('startAbilityByCallWithAccount succeed'); + }).catch((error) => { + // Process service logic errors. + console.error('startAbilityByCallWithAccount failed, error.code: ${error.code}, error.message: ${error.message}'); + }); + } catch (paramError) { + // Process input parameter errors. + console.error('error.code: ${paramError.code}, error.message: ${paramError.message}'); + } + ``` diff --git a/en/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md b/en/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md index cbfec0e2905afa5cf03244d67504ec9628a36c45..63b85f46899461f7ccf6235a7ea870b933542007 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md @@ -2519,3 +2519,84 @@ try { console.error(`startRecentAbility failed, code is ${err.code}, message is ${err.message}`); } ``` + +## UIAbilityContext.startAbilityByCallWithAccount + +startAbilityByCallWithAccount(want: Want, accountId: number): Promise<Caller>; + +Starts an ability with the account ID specified and obtains the caller object for communicating with the ability. + +Observe the following when using this API: + - If an application needs to call this API to start an ability that belongs to another user, it must have the **ohos.permission.ABILITY_BACKGROUND_COMMUNICATION** and **ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS** permissions. + - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission. + - If **exported** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission. + - The rules for using this API in the same-device and cross-device scenarios are different. For details, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md). + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-want.md) | Yes| Information about the ability to start, including **abilityName**, **moduleName**, **bundleName**, **deviceId** (optional), and **parameters** (optional). If **deviceId** is left blank or null, the local ability is started. If **parameters** is left blank or null, the ability is started in the background.| +| accountId | number | Yes| ID of a system account. The value **-1** indicates the current user. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<Caller> | Promise used to return the caller object to communicate with.| + +**Error codes** + +| ID| Error Message| +| ------- | -------------------------------- | +| 16000001 | Input error. The specified ability name does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Visibility verification failed. | +| 16000005 | Static permission denied. The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | Crowdtest App Expiration. | +| 16000011 | The context does not exist. | +| 16000050 | Internal Error. | +| 16200001 | The caller has been released. | + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). + +**Example** + + ```ts + let caller; + + // ID of a system account. The value -1 indicates the current user. + let accountId = -1; + + // Specify the ability to start. + let want = { + bundleName: 'com.acts.actscalleeabilityrely', + moduleName: 'entry', + abilityName: 'EntryAbility' + deviceId: '' + parameters: { + // If the value of 'ohos.aafwk.param.callAbilityToForeground' is true, the ability is started in the foreground. If the value is false or not set, the ability is started in the background. + 'ohos.aafwk.param.callAbilityToForeground': true + } + }; + + try { + this.context.startAbilityByCallWithAccount(want, accountId) + .then((obj) => { + // Carry out normal service processing. + caller = obj; + console.log('startAbilityByCallWithAccount succeed'); + }).catch((error) => { + // Process service logic errors. + console.error('startAbilityByCallWithAccount failed, error.code: ${error.code}, error.message: ${error.message}'); + }); + } catch (paramError) { + // Process input parameter errors. + console.error('error.code: ${paramError.code}, error.message: ${paramError.message}'); + } + ``` diff --git a/en/application-dev/reference/apis/js-apis-intl.md b/en/application-dev/reference/apis/js-apis-intl.md index cec10d9eef5fbd50d9d81ca6a5358d57d78fdbf0..99131363c58faef8abe196d0e20e01b176a1258e 100644 --- a/en/application-dev/reference/apis/js-apis-intl.md +++ b/en/application-dev/reference/apis/js-apis-intl.md @@ -1,7 +1,6 @@ # @ohos.intl (Internationalization) -The **intl** module provides basic i18n capabilities, such as time and date formatting, number formatting, and string sorting, through the standard i18n APIs defined in ECMA 402. - + The **intl** module provides basic i18n capabilities, such as time and date formatting, number formatting, and string sorting, through the standard i18n APIs defined in ECMA 402. The [i18n](js-apis-i18n.md) module provides enhanced i18n capabilities through supplementary interfaces that are not defined in ECMA 402. It works with the intl module to provide a complete suite of i18n capabilities. > **NOTE** @@ -68,7 +67,7 @@ Creates a **Locale** object. | Name | Type | Mandatory | Description | | -------------------- | -------------------------------- | ---- | ---------------------------- | | locale | string | Yes | A string containing locale information, including the language, optional script, and region. For details about the international standards and combination modes for the language, script, and country or region, see [intl Development](../../internationalization/intl-guidelines.md#setting-locale-information).| -| options9+ | [LocaleOptions](#localeoptions9) | No | Options for creating the **Locale** object. | +| options | [LocaleOptions](#localeoptions6) | No | Options for creating the **Locale** object. | **Example** ```js @@ -160,9 +159,10 @@ Minimizes information of the **Locale** object. If the script and locale informa ``` -## LocaleOptions9+ +## LocaleOptions6+ Represents the locale options. +In API version 9, the attributes in **LocaleOptions** are optional. **System capability**: SystemCapability.Global.I18n @@ -207,7 +207,7 @@ Creates a **DateTimeOptions** object for the specified locale. | Name | Type | Mandatory | Description | | -------------------- | ------------------------------------ | ---- | ---------------------------- | | locale | string \| Array<string> | Yes | A string containing locale information, including the language, optional script, and region.| -| options9+ | [DateTimeOptions](#datetimeoptions9) | No | Options for creating a **DateTimeFormat** object. | +| options | [DateTimeOptions](#datetimeoptions6) | No | Options for creating a **DateTimeFormat** object. | **Example** ```js @@ -299,7 +299,7 @@ Obtains the formatting options for **DateTimeFormat** object. | Type | Description | | ------------------------------------ | ----------------------------- | -| [DateTimeOptions](#datetimeoptions9) | Formatting options for **DateTimeFormat** objects.| +| [DateTimeOptions](#datetimeoptions6) | Formatting options for **DateTimeFormat** objects.| **Example** ```js @@ -311,9 +311,10 @@ Obtains the formatting options for **DateTimeFormat** object. ``` -## DateTimeOptions9+ +## DateTimeOptions6+ Provides the options for the **DateTimeFormat** object. +In API version 9, the attributes in **DateTimeOptions** are optional. **System capability**: SystemCapability.Global.I18n @@ -371,7 +372,7 @@ Creates a **NumberFormat** object for the specified locale. | Name | Type | Mandatory | Description | | -------------------- | -------------------------------- | ---- | ---------------------------- | | locale | string \| Array<string> | Yes | A string containing locale information, including the language, optional script, and region.| -| options9+ | [NumberOptions](#numberoptions9) | No | Options for creating a **NumberFormat** object. | +| options | [NumberOptions](#numberoptions6) | No | Options for creating a **NumberFormat** object. | **Example** ```js @@ -421,7 +422,7 @@ Obtains the options of the **NumberFormat** object. | Type | Description | | -------------------------------- | --------------------------- | -| [NumberOptions](#numberoptions9) | Formatting options for **NumberFormat** objects.| +| [NumberOptions](#numberoptions6) | Formatting options for **NumberFormat** objects.| **Example** @@ -434,9 +435,10 @@ Obtains the options of the **NumberFormat** object. ``` -## NumberOptions9+ +## NumberOptions6+ Defines the device capability. +In API version 9, the attributes in **NumberOptions** are optional. **System capability**: SystemCapability.Global.I18n @@ -448,7 +450,7 @@ Defines the device capability. | currencyDisplay | string | Yes | Yes | Currency display mode. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.| | unit | string | Yes | Yes | Unit name, for example, **meter**, **inch**, or **hectare**. | | unitDisplay | string | Yes | Yes | Unit display format. The value can be **long**, **short**, or **narrow**.| -| unitUsage | string | Yes | Yes | Unit usage scenario. The value can be any of the following: **default**, **area-land-agricult**, **area-land-commercl**, **area-land-residntl**, **length-person**, **length-person-small**, **length-rainfall**, **length-road**, **length-road-small**, **length-snowfall**, **length-vehicle**, **length-visiblty**, **length-visiblty-small**, **length-person-informal**, **length-person-small-informal**, **length-road-informal**, **speed-road-travel**, **speed-wind**, **temperature-person**, **temperature-weather**, **volume-vehicle-fuel**.| +| unitUsage8+ | string | Yes | Yes | Unit usage scenario. The value can be any of the following: **default**, **area-land-agricult**, **area-land-commercl**, **area-land-residntl**, **length-person**, **length-person-small**, **length-rainfall**, **length-road**, **length-road-small**, **length-snowfall**, **length-vehicle**, **length-visiblty**, **length-visiblty-small**, **length-person-informal**, **length-person-small-informal**, **length-road-informal**, **speed-road-travel**, **speed-wind**, **temperature-person**, **temperature-weather**, **volume-vehicle-fuel**.| | signDisplay | string | Yes | Yes | Number sign display format. The value can be **auto**, **never**, **always**, or **expectZero**.| | compactDisplay | string | Yes | Yes | Compact display format. The value can be **long** or **short**. | | notation | string | Yes | Yes | Number formatting specification. The value can be **standard**, **scientific**, **engineering**, or **compact**.| @@ -494,7 +496,7 @@ Creates a **Collator** object. | Name | Type | Mandatory | Description | | -------------------- | ------------------------------------ | ---- | ---------------------------- | | locale | string \| Array<string> | Yes | A string containing locale information, including the language, optional script, and region.| -| options9+ | [CollatorOptions](#collatoroptions9) | No | Options for creating a **Collator** object. | +| options | [CollatorOptions](#collatoroptions8) | No | Options for creating a **Collator** object. | **Example** ```js @@ -545,7 +547,7 @@ Returns properties reflecting the locale and collation options of a **Collator** | Type | Description | | ------------------------------------ | ----------------- | -| [CollatorOptions](#collatoroptions9) | Properties of the **Collator** object.| +| [CollatorOptions](#collatoroptions8) | Properties of the **Collator** object.| **Example** ```js @@ -557,9 +559,10 @@ Returns properties reflecting the locale and collation options of a **Collator** ``` -## CollatorOptions9+ +## CollatorOptions8+ Represents the properties of a **Collator** object. +In API version 9, the attributes in **CollatorOptions** are optional. **System capability**: SystemCapability.Global.I18n @@ -605,7 +608,7 @@ Creates a **PluralRules** object to obtain the singular-plural type of numbers. | Name | Type | Mandatory | Description | | -------------------- | ---------------------------------------- | ---- | ---------------------------- | | locale | string \| Array<string> | Yes | A string containing locale information, including the language, optional script, and region.| -| options9+ | [PluralRulesOptions](#pluralrulesoptions9) | No | Options for creating a **PluralRules** object. | +| options | [PluralRulesOptions](#pluralrulesoptions8) | No | Options for creating a **PluralRules** object. | **Example** ```js @@ -648,9 +651,10 @@ Obtains a string that represents the singular-plural type of the specified numbe ``` -## PluralRulesOptions9+ +## PluralRulesOptions8+ Represents the properties of a **PluralRules** object. +In API version 9, the attributes in **PluralRulesOptions** are optional. **System capability**: SystemCapability.Global.I18n @@ -696,7 +700,7 @@ Creates a **RelativeTimeFormat** object. | Name | Type | Mandatory | Description | | -------------------- | ---------------------------------------- | ---- | ---------------------------- | | locale | string \| Array<string> | Yes | A string containing locale information, including the language, optional script, and region.| -| options9+ | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions9) | No | Options for creating a **RelativeTimeFormat** object. | +| options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions8) | No | Options for creating a **RelativeTimeFormat** object. | **Example** ```js @@ -788,9 +792,10 @@ Obtains the formatting options for **RelativeTimeFormat** objects. ``` -## RelativeTimeFormatInputOptions9+ +## RelativeTimeFormatInputOptions8+ Represents the properties of a **RelativeTimeFormat** object. +In API version 9, the attributes in **RelativeTimeFormatInputOptions** are optional. **System capability**: SystemCapability.Global.I18n diff --git a/en/application-dev/reference/apis/js-apis-loglibrary.md b/en/application-dev/reference/apis/js-apis-loglibrary.md new file mode 100644 index 0000000000000000000000000000000000000000..cbb849eab6fca14001bdd9f648fb2ce60cd8e2f1 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-loglibrary.md @@ -0,0 +1,319 @@ +# @ohos.logLibrary (Log Library) + +The **logLibrary** module provides APIs for obtaining various system maintenance and test logs. + +> **NOTE** +> +> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> - The APIs provided by this module are system APIs. + +## Modules to Import + +```js +import logLibrary from '@ohos.logLibrary'; +``` + +## LogEntry + +Defines a **LogEntry** object. + +**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| name | string | Yes| No| Log file name. | +| mtime | number | Yes| No | Time of the last modification to the file. The value is the number of seconds elapsed since 00:00:00 on January 1, 1970.| +| size | number | Yes| No | File size, in bytes.| + +## logLibrary.list + +list(logType: string): LogEntry[] + +Obtains the list of log files of the specified type in synchronous mode. This API accepts objects of the string type as input parameters and returns a list log files of the specified type. + +**Required permission**: ohos.permission.READ_HIVIEW_SYSTEM + +**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------------------- | ---- | ------------------------------------------------------------ | +| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.| + +**Return value** + +| Type | Description | +| ------------------- | ------------------------------------------------------------ | +| LogEntry[] | Array of log file objects.| + +**Error codes** + +For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md). + +| ID| Error Message| +| ------- | ----------------------------------------------------------------- | +| 201 | Permission denied. | +| 202 | Permission denied, non-system app called system api. | +| 401 | Invalid argument.| + +**Example** + +```js +import logLibrary from '@ohos.logLibrary'; + +try { + let logObj = logLibrary.list('HILOG'); + // do something here. +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} +``` + +## logLibrary.copy + +copy(logType: string, logName: string, dest: string): Promise<void> + +Copies log files of the specified type to the target application directory. This API uses a promise to return the result. + +**Required permission**: ohos.permission.READ_HIVIEW_SYSTEM + +**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary + +**Parameters** + +| Name | Type | Mandatory| Description| +| --------- | ----------------------- | ---- | --------------- | +| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.| +| logName | string | Yes | Log file name.| +| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.
If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.| + +**Return value** + +| Type | Description | +| ------------------- | ------------------------------------------------------------ | +| Promise<void> | Promise used to return the result. Depending on whether the operation is successful, you can use the **then()** or **catch()** method to process the callback.| + +**Error codes** + +For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md). + +| ID| Error Message| +| -------- | ---------------------------------------------------------------- | +| 201 | Permission denied. | +| 202 | Permission denied, non-system app called system api. | +| 401 | Invalid argument.| +| 21300001 | Source file does not exists. | + +**Example** + +```js +import logLibrary from '@ohos.logLibrary'; + +try { + logLibrary.copy('HILOG', 'hiapplogcat-1.zip', '' + ).then( + (val) => { + // do something here. + } + ).catch( + (err) => { + // do something here. + } + ) +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} +``` + +## logLibrary.copy + +copy(logType: string, logName: string, dest: string, callback: AsyncCallback<void>): void + +Copies log files of the specified type to the target application directory. This API uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.READ_HIVIEW_SYSTEM + +**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------------------- | ---- | ------------------------------------------------------------ | +| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.| +| logName | string | Yes | Log file name.| +| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.
If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.| +| callback | AsyncCallback<void> | Yes| Callback used to process the received return value. The value **0** indicates that the operation is successful, and any other value indicates that the operation has failed.| + +**Error codes** + +For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md). + +| ID| Error Message| +| ------- | ----------------------------------------------------------------- | +| 201 | Permission denied. | +| 202 | Permission denied, non-system app called system api. | +| 401 | Invalid argument.| +| 21300001 | Source file does not exists. | + +**Example** + +```js +import logLibrary from '@ohos.logLibrary'; + +try { + logLibrary.copy('HILOG', 'hiapplogcat-1.zip', 'dir1', (error, val) => { + if (val === undefined) { + // copy failed. + } else { + // copy success. + } + }); +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} +``` + +## logLibrary.move + +move(logType: string, logName: string, dest: string): Promise<void> + +Moves log files of the specified type to the target application directory. This API uses a promise to return the result. + +**Required permission**: ohos.permission.WRITE_HIVIEW_SYSTEM + +**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary + +**Parameters** + +| Name | Type | Mandatory| Description| +| --------- | ----------------------- | ---- | --------------- | +| logType | string | Yes| Log type, for example, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.| +| logName | string | Yes | Log file name.| +| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.
If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.| + +**Return value** + +| Type | Description | +| ------------------- | ------------------------------------------------------------ | +| Promise<void> | Promise used to return the result. Depending on whether the operation is successful, you can use the **then()** or **catch()** method to process the callback.| + +**Error codes** + +For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md). + +| ID| Error Message| +| -------- | ---------------------------------------------------------------- | +| 201 | Permission denied. | +| 202 | Permission denied, non-system app called system api. | +| 401 | Invalid argument.| +| 21300001 | Source file does not exists. | + +**Example** + +```js +import logLibrary from '@ohos.logLibrary'; + +try { + logLibrary.move('FAULTLOG', 'fault_log_test.zip', '' + ).then( + (val) => { + // do something here. + } + ).catch( + (err) => { + // do something here. + } + ) +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} +``` + +## logLibrary.move + +move(logType: string, logName: string, dest: string, callback: AsyncCallback<void>): void + +Moves log files of the specified type to the target application directory. This API uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.WRITE_HIVIEW_SYSTEM + +**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------------------- | ---- | ------------------------------------------------------------ | +| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.| +| logName | string | Yes | Log file name.| +| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.
If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.| +| callback | AsyncCallback<void> | Yes| Callback used to process the received return value. The value **0** indicates that the operation is successful, and any other value indicates that the operation has failed.| + +**Error codes** + +For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md). + +| ID| Error Message| +| ------- | ----------------------------------------------------------------- | +| 201 | Permission denied. | +| 202 | Permission denied, non-system app called system api. | +| 401 | Invalid argument.| +| 21300001 | Source file does not exists. | + +**Example** + +```js +import logLibrary from '@ohos.logLibrary'; + +try { + logLibrary.move('FAULTLOG', 'fault_log_test.zip', 'dir1/dir2', (error, val) => { + if (val === undefined) { + // move failed. + } else { + // move success. + } + }); +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} +``` + +## logLibrary.remove + +remove(logType: string, logName: string): void + +Deletes log files of the specified type in synchronous mode. + +**Required permission**: ohos.permission.WRITE_HIVIEW_SYSTEM + +**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------------------- | ---- | ------------------------------------------------------------ | +| logType | string | Yes| Log type, for example, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.| +| logName | string | Yes | Log file name.| + +**Error codes** + +For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md). + +| ID| Error Message| +| ------- | ----------------------------------------------------------------- | +| 201 | Permission denied. | +| 202 | Permission denied, non-system app called system api. | +| 401 | Invalid argument.| +| 21300001 | Source file does not exists. | + +**Example** + +```js +import logLibrary from '@ohos.logLibrary'; + +try { + logLibrary.remove('FAULTLOG', 'fault_log_test.zip'); +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} +``` diff --git a/en/application-dev/reference/apis/js-apis-logs.md b/en/application-dev/reference/apis/js-apis-logs.md index b2d837bae04d378938b355d535971cf6d56e48c5..fa73f169b26bec6240b6205c2970af08f5def1f8 100644 --- a/en/application-dev/reference/apis/js-apis-logs.md +++ b/en/application-dev/reference/apis/js-apis-logs.md @@ -1,8 +1,6 @@ -# console (Log Printing) +# Console -The **console** module provides basic log printing capabilities and supports log printing by log level. - -If you want to use more advanced log printing services, for example, filtering logs by the specified ID, you are advised to use [`@ohos.hilog`](js-apis-hilog.md). +The **console** module provides a simple debugging console, which is similar to the JavaScript console provided by the browser. > **NOTE** > @@ -10,9 +8,9 @@ If you want to use more advanced log printing services, for example, filtering l ## console.debug -debug(message: string): void +debug(message: string, ...arguments: any[]): void -Prints debug-level logs. +Prints debugging information in formatted output mode. **System capability**: SystemCapability.ArkUI.ArkUI.Full @@ -20,14 +18,25 @@ Prints debug-level logs. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| message | string | Yes | Text to print.| +| message | string | Yes | Text to be printed.| +| arguments | any | No | Arguments in the message or other information to be printed.| +**Example** +```js +const number = 5; +console.debug('count: %d', number); // Print the debugging information with arguments in the message replaced. +// count: 5 +console.debug('count:', number); // Print the message and other information. +// count: 5 +console.debug('count:'); // Print the message only. +// count: +``` ## console.log -log(message: string): void +log(message: string, ...arguments: any[]): void -Prints debug-level logs. +Prints log information in formatted output mode. **System capability**: SystemCapability.ArkUI.ArkUI.Full @@ -35,14 +44,25 @@ Prints debug-level logs. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| message | string | Yes | Text to print.| +| message | string | Yes | Text to be printed.| +| arguments | any | No |Arguments in the message or other information to be printed.| +**Example** +```js +const number = 5; +console.log('count: %d', number); // Print the log information with arguments in the message replaced. +// count: 5 +console.log('count:', number); // Print the message and other information. +// count: 5 +console.log('count:'); // Print the message only. +// count: +``` ## console.info -info(message: string): void +info(message: string, ...arguments: any[]): void -Prints info-level logs. +Prints log information in formatted output mode. This API is the alias of **console.log ()**. **System capability**: SystemCapability.ArkUI.ArkUI.Full @@ -50,14 +70,25 @@ Prints info-level logs. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| message | string | Yes | Text to print.| +| message | string | Yes | Text to be printed.| +| arguments | any | No | Arguments in the message or other information to be printed.| +**Example** +```js +const number = 5; +console.info('count: %d', number); // Print the log information with arguments in the message replaced. +// count: 5 +console.info('count:', number); // Print the message and other information. +// count: 5 +console.info('count:'); // Print the message only. +// count: +``` ## console.warn -warn(message: string): void +warn(message: string, ...arguments: any[]): void -Prints warn-level logs. +Prints warning information in formatted output mode. **System capability**: SystemCapability.ArkUI.ArkUI.Full @@ -65,14 +96,25 @@ Prints warn-level logs. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| message | string | Yes | Text to print.| +| message | string | Yes | Warning information to be printed.| +| arguments | any | No | Arguments in the message or other information to be printed.| +**Example** +```js +const str = "name should be string"; +console.warn('warn: %d', str); // Print the warning information with arguments in the message replaced. +// warn: name should be string +console.warn('warn:', str); // Print the message and other information. +// warn: name should be string +console.warn('warn:'); // Print the message only. +// warn: +``` ## console.error -error(message: string): void +error(message: string, ...arguments: any[]): void -Prints error-level logs. +Prints error information in formatted output mode. **System capability**: SystemCapability.ArkUI.ArkUI.Full @@ -80,31 +122,26 @@ Prints error-level logs. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| message | string | Yes | Text to print.| +| message | string | Yes | Error information to be printed.| +| arguments | any | No | Arguments in the message or other information to be printed.| **Example** - +```js +const str = "value is not defined"; +console.error('error: %d', str); // Print the error information with arguments in the message replaced. +// error: value is not defined +console.error('error:', str); // Print the message and other information. +// error: value is not defined +console.error('error:'); // Print the message only. +// error: ``` -export default { - clickConsole(){ - var versionCode = 1; - console.info('Hello World. The current version code is ' + versionCode); - console.log(`versionCode: ${versionCode}`); - / / The following is supported since API version 6: console.log('versionCode:%d.', versionCode); - } -} -``` - -Switch to the HiLog window at the bottom of HUAWEI DevEco Studio. Specifically, select the current device and process, set the log level to Info, and enter Hello World in the search box. Logs that meet the search criteria are displayed, as shown in the following figure. - -![Printing logs](figures/printing-logs.png) ## console.assert10+ assert(value?: Object, ...arguments: Object[]): void -If **value** is false, the subsequent content will be printed. +Prints assertion information. **System capability**: SystemCapability.Utils.Lang @@ -112,24 +149,26 @@ If **value** is false, the subsequent content will be printed. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| value | Object | No | Value| -| arguments | Object | No | Prints error messages.| +| value | Object | No | Result value. If **value** is **false** or left blank, the output starting with "Assertion failed" is printed. If **value** is **true**, no information is printed.| +| arguments | Object | No | Other information to be printed when **value** is **false**. If this parameter is left blank, other information is not printed.| **Example** -``` -console.assert(true, 'does nothing'); +```js +console.assert(true, 'does nothing'); // Do not print error information as value is true. +console.assert(2% 1 == 0,'does nothing'); // Do not print error information as value is true. console.assert(false, 'console %s work', 'didn\'t'); -// Assertion console:ohos didn't work +// Assertion failed: console didn't work console.assert(); // Assertion failed ``` + ## console.count10+ count(label?: string): void -Adds a counter by the specified label name to count the number of times **console.count()** is called. The default value is **default**. +Maintains an internal counter. When this counter is invoked, its label name and the corresponding call count are printed. **System capability**: SystemCapability.Utils.Lang @@ -137,10 +176,11 @@ Adds a counter by the specified label name to count the number of times **consol | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| label | string | No | Counter label name.| +| label | string | No | Counter label name. The default value is **default**.| + **Example** -``` +```js console.count() // default: 1 console.count('default') @@ -150,7 +190,7 @@ console.count('abc') console.count('xyz') // xyz: 1 console.count('abc') -abc: 2 +// abc: 2 console.count() // default: 3 ``` @@ -159,7 +199,7 @@ console.count() countReset(label?: string): void -Resets a counter by the specified label name. The default value is **default**. +Resets a counter based on the specified label name. **System capability**: SystemCapability.Utils.Lang @@ -167,10 +207,10 @@ Resets a counter by the specified label name. The default value is **default**. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| label | string | No | Counter label name.| +| label | string | No | Counter label name. The default value is **default**.| **Example** -``` +```js console.count('abc'); // abc: 1 console.countReset('abc'); @@ -190,13 +230,24 @@ Prints content of the specified object. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| dir | Object | No | Object whose content needs to be printed.| +| dir | Object | No | Object whose content needs to be printed. If this parameter is left blank, no information is printed.| + + +**Example** +```js +let a = { foo: { bar: { baz: true } }}; +console.dir(a); +// Object: {"foo":{"bar":{"baz":true}}} + +console.dir(); // No information is printed. +``` + ## console.dirxml10+ dirxml(...arguments: Object[]): void -Calls **console.log()** and passes the received parameters to it. This API does not produce any content of the XML format. +Displays an interactive tree of the descendant elements of the specified XML element. This API is implemented by calling **console.log()** internally. It does not produce any XML elements. The usage method is the same as that of **console.log()**. **System capability**: SystemCapability.Utils.Lang @@ -204,13 +255,24 @@ Calls **console.log()** and passes the received parameters to it. This API does | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| arguments | Object | No | Information to be printed.| +| arguments | Object | Yes | Information to be printed.| + +**Example** +```js +const number = 5; +console.dirxml('count: %d', number); +// count: 5 +console.dirxml('count:', number); +// count: 5 +console.dirxml('count:'); +// count: +``` ## console.group10+ group(...arguments: Object[]): void -Creates an inline group so that subsequent lines are indented by the value specified by **groupIndentation**. +Increases the indentation of subsequent lines by two spaces. If the information to be printed is provided, the information is printed without extra indentation. **System capability**: SystemCapability.Utils.Lang @@ -220,11 +282,26 @@ If the information to be printed is provided, the information is printed without | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | | arguments | Object | No | Information to be printed.| + +**Example** +```js +console.log("outter"); +// outter +console.group(); +console.log("level 1"); +// level 1 +console.group("in level1"); +// in level1 +console.log("level 2"); +// level 2 +``` + + ## console.groupCollapsed10+ groupCollapsed(...arguments: Object[]): void -Creates a collapsed inline group. +Creates a new inline group in collapsed mode. The usage and function of this API are the same as those of **console.group()**. **System capability**: SystemCapability.Utils.Lang @@ -234,14 +311,42 @@ Creates a collapsed inline group. | ------- | ------ | ---- | ----------- | | arguments | Object | No | Information to be printed.| + +**Example** +```js +console.groupCollapsed("outter"); +// outter +console.groupCollapsed(); +console.log("level 1"); +// level 1 +console.groupCollapsed("in level1"); +// in level1 +console.log("level 2"); +// level 2 +``` + ## console.groupEnd10+ groupEnd(): void -Exits an inline group so that subsequent lines are not indented by the value specified by **groupIndentation** . +Reduces the indentation of subsequent lines by two spaces. **System capability**: SystemCapability.Utils.Lang + +**Example** +```js +console.log("outter"); +// outter +console.group(); +console.log("level 1"); +// level 1 +console.groupEnd(); +console.log("outter"); +// outter +``` + + ## console.table10+ table(tableData?: Object): void @@ -254,10 +359,10 @@ Prints data in a table. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| tableData | Object | No | Data to be printed in a table.| +| tableData | Object | No | Data to be printed in a table. If this parameter is left blank, no information is printed.| **Example** -``` +```js console.table([1, 2, 3]); // ┌─────────┬────────┐ // │ (index) │ Values │ @@ -281,7 +386,7 @@ console.table({ a: [1, 2, 3, 4, 5], b: 5, c: { e: 5 } }); time(label?: string): void -Starts a timer to track the duration of an operation. The default value is **default**. You can use **console.timeEnd()** to disable the timer and print the result. +Starts a timer to track the duration of an operation. You can use **console.timeEnd()** to close the timer and print the elapsed time (in ms). **System capability**: SystemCapability.Utils.Lang @@ -289,13 +394,18 @@ Starts a timer to track the duration of an operation. The default value is **def | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| label | string | No | Timer label.| +| label | string | No | Timer label. The default value is **default**.| + +**Example** +```js +console.time('abc'); +``` ## console.timeEnd10+ timeEnd(label?: string): void -Stops the timer started by **console.time()** and prints the result. The default value is **default**. +Stops the timer started by calling **console.time()** and prints the elapsed time (in ms). **System capability**: SystemCapability.Utils.Lang @@ -303,10 +413,10 @@ Stops the timer started by **console.time()** and prints the result. The default | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| label | string | No | Timer label.| +| label | string | No | Timer label. The default value is **default**.| **Example** -``` +```js console.time('abc'); console.timeEnd('abc'); // abc: 225.438ms @@ -316,7 +426,7 @@ console.timeEnd('abc'); timeLog(label?: string, ...arguments: Object[]): void -Prints the elapsed time and other logs for the timer started by **console.time()**. +Prints the elapsed time and other data parameters for the timer started by **console.time()**. **System capability**: SystemCapability.Utils.Lang @@ -324,14 +434,13 @@ Prints the elapsed time and other logs for the timer started by **console.time() | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| label | string | No | Timer label.| +| label | string | No | Timer label. The default value is **default**.| | arguments | Object | No | Logs to be printed.| **Example** -``` +```js console.time('timer1'); -const value = aaa (); // Return 17. -console.timeLog('timer1', value); +console.timeLog('timer1', 17); // timer1: 365.227ms 17 console.timeEnd('timer1'); // timer1: 513.22ms @@ -349,10 +458,14 @@ Creates a stack trace. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| arguments | Object | No | Logs to be printed.| +| arguments | Object | No | Logs to be printed. If this parameter is left blank, only stack information is printed.| **Example** -``` +```js console.trace(); +// Trace: +// xxxxxxxxxx (current stack information) console.trace("Show the trace"); +// Trace: Show the trace +// xxxxxxxxxx (current stack information) ``` diff --git a/en/application-dev/reference/apis/js-apis-net-ethernet.md b/en/application-dev/reference/apis/js-apis-net-ethernet.md index ec15531de49c13ab4b2c85b0da9eacf37400d195..eca9a04d0e42791e19a3620f6582f3d7284dc6d4 100644 --- a/en/application-dev/reference/apis/js-apis-net-ethernet.md +++ b/en/application-dev/reference/apis/js-apis-net-ethernet.md @@ -55,8 +55,7 @@ ethernet.setIfaceConfig("eth0", { route: "192.168.xx.xxx", gateway: "192.168.xx.xxx", netMask: "255.255.255.0", - dnsServers: "1.1.1.1", - domain: "2.2.2.2" + dnsServers: "1.1.1.1" }, (error) => { if (error) { console.log("setIfaceConfig callback error = " + JSON.stringify(error)); @@ -115,8 +114,7 @@ ethernet.setIfaceConfig("eth0", { route: "192.168.xx.xxx", gateway: "192.168.xx.xxx", netMask: "255.255.255.0", - dnsServers: "1.1.1.1", - domain: "2.2.2.2" + dnsServers: "1.1.1.1" }).then(() => { console.log("setIfaceConfig promise ok "); }).catch(error => { @@ -168,7 +166,6 @@ ethernet.getIfaceConfig("eth0", (error, value) => { console.log("getIfaceConfig callback gateway = " + JSON.stringify(value.gateway)); console.log("getIfaceConfig callback netMask = " + JSON.stringify(value.netMask)); console.log("getIfaceConfig callback dnsServers = " + JSON.stringify(value.dnsServers)); - console.log("getIfaceConfig callback domain = " + JSON.stringify(value.domain)); } }); ``` @@ -219,7 +216,6 @@ ethernet.getIfaceConfig("eth0").then((data) => { console.log("getIfaceConfig promise gateway = " + JSON.stringify(data.gateway)); console.log("getIfaceConfig promise netMask = " + JSON.stringify(data.netMask)); console.log("getIfaceConfig promise dnsServers = " + JSON.stringify(data.dnsServers)); - console.log("getIfaceConfig promise domain = " + JSON.stringify(data.domain)); }).catch(error => { console.log("getIfaceConfig promise error = " + JSON.stringify(error)); }); diff --git a/en/application-dev/reference/apis/js-apis-net-policy.md b/en/application-dev/reference/apis/js-apis-net-policy.md deleted file mode 100644 index cb5f1624f6a3508d25ee1019525ebac8ea9c5475..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/apis/js-apis-net-policy.md +++ /dev/null @@ -1,1555 +0,0 @@ -# @ohos.net.policy (Network Policy Management) - -The **policy** module provides APIs for managing network policies, through which you can control and manage the data volume used. - -> **NOTE** -> -> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. - -## Modules to Import - -```js -import policy from '@ohos.net.policy' -``` - -## policy.setBackgroundAllowed - -setBackgroundAllowed(isAllowed: boolean, callback: AsyncCallback\): void - -Sets a background network policy. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| isAllowed | boolean | Yes | Whether applications running in the background are allowed to use mobile data.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.setBackgroundAllowed(Boolean(Number.parseInt(this.isBoolean)), (error) => { - console.log(JSON.stringify(error)) -}) -; -``` - -## policy.setBackgroundAllowed - -setBackgroundAllowed(isAllowed: boolean): Promise\ - -Sets a background network policy. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| isAllowed | boolean | Yes | Whether applications running in the background are allowed to use mobile data.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.| - -**Example** - -```js -policy.setBackgroundAllowed(Boolean(Number.parseInt(this.isBoolean))).then(function (error) { - console.log(JSON.stringify(error)) -}) -``` - -## policy.isBackgroundAllowed - -isBackgroundAllowed(callback: AsyncCallback\): void - -Obtains the background network policy. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, **true** is returned, which means that applications running in the background are allowed to use mobile data. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.isBackgroundAllowed((error, data) => { - this.callBack(error, data); - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}); -``` - -## policy.isBackgroundAllowed - -isBackgroundAllowed(): Promise\; - -Obtains the background network policy. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result. If the operation is successful, **true** is returned, which means that applications running in the background are allowed to use mobile data. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.isBackgroundAllowed().then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.setPolicyByUid - -setPolicyByUid(uid: number, policy: NetUidPolicy, callback: AsyncCallback\): void - -Sets an application-specific network policy. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes | Unique ID of the application.| -| policy | [NetUidPolicy](#netuidpolicy) | Yes| Application-specific network policy to set.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), policy: Number.parseInt(this.currentNetUidPolicy) -} -policy.setPolicyByUid(Number.parseInt(this.firstParam), Number.parseInt(this.currentNetUidPolicy), (error) => { - this.callBack(error); -}); -``` - -## policy.setPolicyByUid - -setPolicyByUid(uid: number, policy: NetUidPolicy): Promise\; - -Sets an application-specific network policy. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes | Unique ID of the application.| -| policy | [NetUidPolicy](#netuidpolicy) | Yes| Application-specific network policy to set.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), policy: Number.parseInt(this.currentNetUidPolicy) -} -policy.setPolicyByUid(Number.parseInt(this.firstParam), Number.parseInt(this.currentNetUidPolicy)).then(function (error) { - console.log(JSON.stringify(error)) -}) -``` - -## policy.getPolicyByUid - -getPolicyByUid(uid: number, callback: AsyncCallback\): void - -Obtains an application-specific network policy by **uid**. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| callback | AsyncCallback\<[NetUidPolicy](#netuidpolicy)> | Yes | Callback used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getPolicyByUid(Number.parseInt(this.firstParam), (error, data) => { - this.callBack(error, data); -}); -``` - -## policy.getPolicyByUid - -getPolicyByUid(uid: number): Promise\; - -Obtains an application-specific network policy by **uid**. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\<[NetUidPolicy](#netuidpolicy)> | Promise used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getPolicyByUid(Number.parseInt(this.firstParam)).then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.getUidsByPolicy - -getUidsByPolicy(policy: NetUidPolicy, callback: AsyncCallback\>): void - -Obtains the UID array of applications configured with a certain application-specific network policy. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| policy | [NetUidPolicy](#netuidpolicy) | Yes| Target application-specific network policy.| -| callback | AsyncCallback\> | Yes | Callback used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getUidsByPolicy(Number.parseInt(this.currentNetUidPolicy), (error, data) => { - this.callBack(error, data); -}); -``` - -## policy.getUidsByPolicy - -function getUidsByPolicy(policy: NetUidPolicy): Promise\>; - -Obtains the UID array of applications configured with a certain application-specific network policy. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| policy | [NetUidPolicy](#netuidpolicy) | Yes| Target application-specific network policy.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\> | Promise used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getUidsByPolicy(Number.parseInt(this.firstParam)).then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.getNetQuotaPolicies - -getNetQuotaPolicies(callback: AsyncCallback\>): void - -Obtains the network quota policies. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\> | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getNetQuotaPolicies((error, data) => { - this.callBack(error, data); -}); -``` - -## policy.getNetQuotaPolicies - -getNetQuotaPolicies(): Promise\>; - -Obtains the network quota policies. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\> | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getNetQuotaPolicies().then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) - -``` - -## policy.setNetQuotaPolicies - -setNetQuotaPolicies(quotaPolicies: Array\, callback: AsyncCallback\): void - -Sets an array of network quota policies. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| quotaPolicies | Array\<[NetQuotaPolicy](#netquotapolicy)> | Yes| An array of network quota policies to set.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - netType: Number.parseInt(this.netType), - iccid: this.iccid, - ident: this.ident, - periodDuration: this.periodDuration, - warningBytes: Number.parseInt(this.warningBytes), - limitBytes: Number.parseInt(this.limitBytes), - lastWarningRemind: this.lastWarningRemind, - lastLimitRemind: this.lastLimitRemind, - metered: Boolean(Number.parseInt(this.metered)), - limitAction: this.limitAction -}; -this.netQuotaPolicyList.push(param); - -policy.setNetQuotaPolicies(this.netQuotaPolicyList, (error) => { - console.log(JSON.stringify(error)) -}); -``` - -## policy.setNetQuotaPolicies - -setNetQuotaPolicies(quotaPolicies: Array\): Promise\; - -Sets an array of network quota policies. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| quotaPolicies | Array\<[NetQuotaPolicy](#netquotapolicy)> | Yes| An array of network quota policies to set.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -let param = { - netType: Number.parseInt(this.netType), - iccid: this.iccid, - ident: this.ident, - periodDuration: this.periodDuration, - warningBytes: Number.parseInt(this.warningBytes), - limitBytes: Number.parseInt(this.limitBytes), - lastWarningRemind: this.lastWarningRemind, - lastLimitRemind: this.lastLimitRemind, - metered: Boolean(Number.parseInt(this.metered)), - limitAction: this.limitAction -}; -this.netQuotaPolicyList.push(param); - -policy.setNetQuotaPolicies(this.netQuotaPolicyList).then(function (error) { - console.log(JSON.stringify(error)) -}) -``` - -## policy.restoreAllPolicies - -restoreAllPolicies(iccid: string, callback: AsyncCallback\): void - -Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| iccid | string | Yes| SIM card ID.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -this.firstParam = iccid; -policy.restoreAllPolicies(this.firstParam, (error) => { - console.log(JSON.stringify(error)) -}); -``` - -## policy.restoreAllPolicies - -restoreAllPolicies(iccid: string): Promise\; - -Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| iccid | string | Yes| SIM card ID.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -this.firstParam = iccid; -policy.restoreAllPolicies(this.firstParam).then(function (error) { - console.log(JSON.stringify(error)) -}) -``` - -## policy.isUidNetAllowed - -isUidNetAllowed(uid: number, isMetered: boolean, callback: AsyncCallback\): void - -Checks whether an application is allowed to access metered networks. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| isMetered | boolean | Yes| Whether the network is a metered network.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. The value **true** means that the application is allowed to access metered networks, and **false** means the opposite.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), isMetered: Boolean(Number.parseInt(this.isBoolean)) -} -policy.isUidNetAllowed(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (error, data) => { - this.callBack(error, data); -}); -``` - -## policy.isUidNetAllowed - -isUidNetAllowed(uid: number, isMetered: boolean): Promise\; - -Checks whether an application is allowed to access metered networks. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| isMetered | boolean | Yes| Whether the network is a metered network.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), isMetered: Boolean(Number.parseInt(this.isBoolean)) -} -policy.isUidNetAllowed(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean))).then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.isUidNetAllowed - -isUidNetAllowed(uid: number, iface: string, callback: AsyncCallback\): void - -Checks whether an application is allowed to access the given network. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| iface | string | Yes| Name of the target network.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. The value **true** means that the application is allowed to access the given network, and **false** means the opposite.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), iface: this.secondParam -} -policy.isUidNetAllowed(Number.parseInt(this.firstParam), this.secondParam, (error, data) => { - this.callBack(error, data); -}); -``` - -## policy.isUidNetAllowed - -isUidNetAllowed(uid: number, iface: string): Promise\; - -Checks whether an application is allowed to access the given network. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| iface | string | Yes| Name of the target network.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), iface: this.secondParam -} -policy.isUidNetAllowed(Number.parseInt(this.firstParam), this.secondParam).then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.setDeviceIdleAllowList - -setDeviceIdleAllowList(uid: number, isAllowed: boolean, callback: AsyncCallback\): void - -Sets whether to add an application to the device idle allowlist. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| isAllowed | boolean | Yes| Whether to add the application to the allowlist.| -| callback | callback: AsyncCallback\ | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean)) -} -policy.setDeviceIdleAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (error) => { - console.log(JSON.stringify(error)) -}); -``` - -## policy.setDeviceIdleAllowList - -setDeviceIdleAllowList(uid: number, isAllowed: boolean): Promise\; - -Sets whether to add an application to the device idle allowlist. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| isAllowed | boolean | Yes| Whether to add the application to the allowlist.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean)) -} -policy.setDeviceIdleAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean))).then(function (error) { - console.log(JSON.stringify(error)) -}) -``` - -## policy.getDeviceIdleAllowList - -getDeviceIdleAllowList(callback: AsyncCallback\>): void - -Obtains the UID array of applications that are on the device idle allowlist. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\> | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getDeviceIdleAllowList((error, data) => { - this.callBack(error, data); -}); -``` - -## policy.getDeviceIdleAllowList - -getDeviceIdleAllowList(): Promise\>; - -Obtains the UID array of applications that are on the device idle allowlist. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\> | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getDeviceIdleAllowList().then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.getBackgroundPolicyByUid - -getBackgroundPolicyByUid(uid: number, callback: AsyncCallback\): void - -Obtains the background network policies configured for the given application. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| callback | AsyncCallback\<[NetBackgroundPolicy](#netbackgroundpolicy)> | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -this.firstParam = uid -policy.getBackgroundPolicyByUid(Number.parseInt(this.firstParam), (error, data) => { - this.callBack(error, data); -}); -``` - -## policy.getBackgroundPolicyByUid - -getBackgroundPolicyByUid(uid: number): Promise\; - -Obtains the background network policies configured for the given application. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\<[NetBackgroundPolicy](#netbackgroundpolicy)> | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -this.firstParam = uid -policy.getBackgroundPolicyByUid(Number.parseInt(this.firstParam)).then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.resetPolicies - -resetPolicies(iccid: string, callback: AsyncCallback\): void - -Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| iccid | string | Yes| SIM card ID.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -this.firstParam = iccid -policy.resetPolicies(this.firstParam, (error) => { - console.log(JSON.stringify(error)) -}); -``` - -## policy.resetPolicies - -resetPolicies(iccid: string): Promise\; - -Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| iccid | string | Yes| SIM card ID.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getUidsByPolicy(Number.parseInt(this.firstParam)).then(function (error, data) { - -}) -this.firstParam = iccid -policy.resetPolicies(this.firstParam).then(function (error) { - console.log(JSON.stringify(error)) -}) -``` - -## policy.updateRemindPolicy - -updateRemindPolicy(netType: NetBearType, iccid: string, remindType: RemindType, callback: AsyncCallback\): void - -Updates a reminder policy. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| netType | [NetBearType](js-apis-net-connection.md#netbeartype) | Yes| Network type.| -| iccid | string | Yes| SIM card ID.| -| remindType | [RemindType](#remindtype) | Yes| Reminder type.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - netType: Number.parseInt(this.netType), iccid: this.firstParam, remindType: this.currentRemindType -} -policy.updateRemindPolicy(Number.parseInt(this.netType), this.firstParam, Number.parseInt(this.currentRemindType), (error) => { - console.log(JSON.stringify(error)) -}); -``` - -## policy.updateRemindPolicy - -updateRemindPolicy(netType: NetBearType, iccid: string, remindType: RemindType): Promise\; - -Updates a reminder policy. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| netType | [NetBearType](js-apis-net-connection.md#netbeartype) | Yes| Network type.| -| iccid | string | Yes| SIM card ID.| -| remindType | [RemindType](#remindtype) | Yes| Reminder type.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - netType: Number.parseInt(this.netType), iccid: this.firstParam, remindType: this.currentRemindType -} -policy.updateRemindPolicy(Number.parseInt(this.netType), this.firstParam, Number.parseInt(this.currentRemindType)).then(function (error) { - console.log(JSON.stringify(error)) -}) -``` - -## policy.setPowerSaveAllowList - -setPowerSaveAllowList(uid: number, isAllowed: boolean, callback: AsyncCallback\): void - -Sets whether to add an application to the power-saving allowlist. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| isAllowed | boolean | Yes| Whether to add the application to the allowlist.| -| callback | callback: AsyncCallback\ | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean)) -} -policy.setPowerSaveAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (error) => { - console.log(JSON.stringify(error)) -}); -``` - -## policy.setPowerSaveAllowList - -setPowerSaveAllowList(uid: number, isAllowed: boolean): Promise\; - -Sets whether to add an application to the power-saving allowlist. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| isAllowed | boolean | Yes| Whether to add the application to the allowlist.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean)) -} -policy.setPowerSaveAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean))).then(function (error) { - console.log(JSON.stringify(error)) -}) -``` - -## policy.getPowerSaveAllowList - -getPowerSaveAllowList(callback: AsyncCallback\>): void - -Obtains the UID array of applications that are on the power-saving allowlist. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\> | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getPowerSaveAllowList((error, data) => { - this.callBack(error, data); -}); -``` - -## policy.getPowerSaveAllowList - -getPowerSaveAllowList(): Promise\>; - -Obtains the UID array of applications that are on the device idle allowlist. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\> | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getPowerSaveAllowList().then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.on - -Functions as the handle to a network policy. - -### on('netUidPolicyChange') - -on(type: "netUidPolicyChange", callback: Callback\<{ uid: number, policy: NetUidPolicy }>): void - -Subscribes to policy changes. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | netUidPolicyChange | Yes| Event type. The value **netUidPolicyChange** indicates a policy change event.| -| callback | Callback\<{ uid: number, policy: [NetUidPolicy](#netuidpolicy) }> | Yes | Callback used to return the result. It is called when the registered network policy changes.| - -**Example** - -```js -policy.on('netUidPolicyChange', (data) => { - this.log('on netUidPolicyChange: ' + JSON.stringify(data)); -}) -``` - -### on('netUidRuleChange') - -on(type: "netUidRuleChange", callback: Callback\<{ uid: number, rule: NetUidRule }>): void - -Subscribes to rule changes. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | netUidRuleChange | Yes| Event type. The value **netUidRuleChange** indicates a rule change event.| -| callback | Callback\<{ uid: number, rule: [NetUidRule](#netuidrule) }> | Yes | Callback used to return the result. It is called when the registered rule changes.| - -**Example** - -```js -policy.on('netUidRuleChange', (data) => { - this.log('on netUidRuleChange: ' + JSON.stringify(data)); -}) -``` - -### on('netMeteredIfacesChange') - -on(type: "netMeteredIfacesChange", callback: Callback\>): void - -Subscribes to metered **iface** changes. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | netMeteredIfacesChange | Yes| Event type. The value **netMeteredIfacesChange** indicates a metered **iface** change event.| -| callback | Callback\> | Yes | Callback used to return the result. It is called when the registered metered **iface** changes.| - -**Example** - -```js -policy.on('netMeteredIfacesChange', (data) => { - this.log('on netMeteredIfacesChange: ' + JSON.stringify(data)); -}) -``` - -### on('netQuotaPolicyChange') - -on(type: "netQuotaPolicyChange", callback: Callback\>): void - -Subscribes to network quota policy changes. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | netQuotaPolicyChange | Yes| Event type. The value **netQuotaPolicyChange** indicates a network quota policy change event.| -| callback | Callback\> | Yes | Callback used to return the result. It is called when the registered network quota policy changes.| - -**Example** - -```js -policy.on('netQuotaPolicyChange', (data) => { - this.log('on netQuotaPolicyChange: ' + JSON.stringify(data)); -}) -``` - -### on('netBackgroundPolicyChange') - -on(type: "netBackgroundPolicyChange", callback: Callback\): void - -Subscribes to background network policy changes. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | netBackgroundPolicyChange | Yes| Event type. The value **netBackgroundPolicyChange** indicates a background network policy change event.| -| callback | Callback\ | Yes | Callback used to return the result. It is called when the registered background network policy changes.| - -**Example** - -```js -policy.on('netBackgroundPolicyChange', (data) => { - this.log('on netBackgroundPolicyChange: ' + JSON.stringify(data)); -}) -``` - -## NetBackgroundPolicy - -Enumerates the background network policies. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Value | Description | -| ------------------------ | ---- | ---------------------- | -| NET_BACKGROUND_POLICY_NONE | 0 | Default policy.| -| NET_BACKGROUND_POLICY_ENABLE | 1 | Applications running in the background are allowed to access metered networks.| -| NET_BACKGROUND_POLICY_DISABLE | 2 | Applications running in the background are not allowed to access metered networks.| -| NET_BACKGROUND_POLICY_ALLOW_LIST | 3 | Only applications on the allowlist are allowed to access metered networks when they are running in the background.| - -## NetQuotaPolicy - -Defines a network quota policy. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Type | Description | -| ----------------------- | ----------------------------------- | ------------------------------------------------------------ | -| netType | [NetBearType](js-apis-net-connection.md#netbeartype) | Network type.| -| iccid | string | Identifier of the SIM card on the metered cellular network. It is not used for Wi-Fi networks.| -| ident | string | Identifier of the SIM card on the metered cellular network. It is used for Wi-Fi networks. It is used together with **iccid**.| -| periodDuration | string | Start time of metering.| -| warningBytes | number | Data volume threshold for generating an alarm.| -| limitBytes | number | Data volume quota.| -| lastWarningRemind | string | Last time when an alarm was generated.| -| lastLimitRemind | string | Last time when the quota was exhausted.| -| metered | string | Whether the network is a metered network.| -| limitAction | [LimitAction](#limitaction) | Action to take when the data volume quota is reached.| - -## LimitAction - -Enumerates the actions that can be taken when the data volume quota is reached. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Value| Description | -| ---------------------- | ----- | ------------ | -| LIMIT_ACTION_NONE | -1 | Default policy.| -| LIMIT_ACTION_DISABLE | 0 | Internet access is disabled.| -| LIMIT_ACTION_AUTO_BILL| 1 | Users will be automatically charged for the data volume they use.| - -## NetUidRule - -Enumerates the metered network rules. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Value| Description | -| ---------------------- | ----- | ------------ | -| NET_RULE_NONE | 0 | Default rule.| -| NET_RULE_ALLOW_METERED_FOREGROUND | 1 | Applications running in the foreground are allowed to access metered networks.| -| NET_RULE_ALLOW_METERED | 2 | Applications are allowed to access metered networks.| -| NET_RULE_REJECT_METERED | 4 | Applications are not allowed to access metered networks.| -| NET_RULE_ALLOW_ALL | 32 | Applications are allowed to access all networks (metered or non-metered).| -| NET_RULE_REJECT_ALL | 64 | Applications are not allowed to access any networks (metered or non-metered).| - -## RemindType - -Enumerates the reminder types. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name| Value| Description| -| ---------------------- | - | ------- | -| REMIND_TYPE_WARNING | 1 | Warning.| -| REMIND_TYPE_LIMIT | 2 | Limit.| - -## NetUidPolicy - -Enumerates the application-specific network policies. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Value| Description | -| ---------------------- | ----- | ------------ | -| NET_POLICY_NONE | 0 | Default network policy.| -| NET_POLICY_ALLOW_METERED_BACKGROUND | 1 | Applications running in the background are allowed to access metered networks.| -| NET_POLICY_REJECT_METERED_BACKGROUND | 2 | Applications running in the background are not allowed to access metered networks.| diff --git a/en/application-dev/reference/apis/js-apis-reminderAgent.md b/en/application-dev/reference/apis/js-apis-reminderAgent.md index 3f9387defec0e68dc6414fdb4b21c5bca9cb1490..dc0a33ab0c33f9978b1985e5962067c2f2097cc2 100644 --- a/en/application-dev/reference/apis/js-apis-reminderAgent.md +++ b/en/application-dev/reference/apis/js-apis-reminderAgent.md @@ -1,4 +1,4 @@ -# @ohos.reminderAgent (Reminder Agent) +# @ohos.reminderAgent (reminderAgent) The **reminderAgent** module provides APIs for publishing scheduled reminders through the reminder agent. @@ -18,14 +18,18 @@ import reminderAgent from'@ohos.reminderAgent'; ``` -## reminderAgent.publishReminder +## reminderAgent.publishReminder(deprecated) ```ts -publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback): void +publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback\): void ``` Publishes a reminder through the reminder agent. This API uses an asynchronous callback to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8). +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.publishReminder](js-apis-reminderAgentManager.md#reminderagentmanagerpublishreminder). + **Required permissions**: ohos.permission.PUBLISH_AGENT_REMINDER **System capability**: SystemCapability.Notification.ReminderAgent @@ -50,14 +54,18 @@ Publishes a reminder through the reminder agent. This API uses an asynchronous c ``` -## reminderAgent.publishReminder +## reminderAgent.publishReminder(deprecated) ```ts -publishReminder(reminderReq: ReminderRequest): Promise +publishReminder(reminderReq: ReminderRequest): Promise\ ``` Publishes a reminder through the reminder agent. This API uses a promise to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8). +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.publishReminder](js-apis-reminderAgentManager.md#reminderagentmanagerpublishreminder-1). + **Required permissions**: ohos.permission.PUBLISH_AGENT_REMINDER **System capability**: SystemCapability.Notification.ReminderAgent @@ -85,14 +93,18 @@ Publishes a reminder through the reminder agent. This API uses a promise to retu ``` -## reminderAgent.cancelReminder +## reminderAgent.cancelReminder(deprecated) ```ts -cancelReminder(reminderId: number, callback: AsyncCallback): void +cancelReminder(reminderId: number, callback: AsyncCallback\): void ``` Cancels the reminder with the specified ID. This API uses an asynchronous callback to return the cancellation result. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.cancelReminder](js-apis-reminderAgentManager.md#reminderagentmanagercancelreminder). + **System capability**: SystemCapability.Notification.ReminderAgent **Parameters** @@ -100,7 +112,7 @@ Cancels the reminder with the specified ID. This API uses an asynchronous callba | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | reminderId | number | Yes| ID of the reminder to cancel. The value is obtained by calling [publishReminder](#reminderagentpublishreminder).| -| callback | AsyncCallback\ | Yes| Asynchronous callback used to return the result.| +| callback | AsyncCallback\ | Yes| Callback used to return the result.| **Example** @@ -111,14 +123,18 @@ reminderAgent.cancelReminder(1, (err, data) => { ``` -## reminderAgent.cancelReminder +## reminderAgent.cancelReminder(deprecated) ```ts -cancelReminder(reminderId: number): Promise +cancelReminder(reminderId: number): Promise\ ``` Cancels the reminder with the specified ID. This API uses a promise to return the cancellation result. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.cancelReminder](js-apis-reminderAgentManager.md#reminderagentmanagercancelreminder-1). + **System capability**: SystemCapability.Notification.ReminderAgent **Parameters** @@ -141,21 +157,25 @@ reminderAgent.cancelReminder(1).then(() => { }); ``` -## reminderAgent.getValidReminders +## reminderAgent.getValidReminders(deprecated) ```ts -getValidReminders(callback: AsyncCallback>): void +getValidReminders(callback: AsyncCallback\>): void ``` Obtains all valid (not yet expired) reminders set by the current application. This API uses an asynchronous callback to return the reminders. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.getValidReminders](js-apis-reminderAgentManager.md#reminderagentmanagergetvalidreminders). + **System capability**: SystemCapability.Notification.ReminderAgent **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| callback | AsyncCallback\\> | Yes| Asynchronous callback used to return an array of all valid reminders set by the current application.| +| callback | AsyncCallback\\> | Yes| Callback used to return an array of all valid reminders set by the current application.| **Example** @@ -187,14 +207,18 @@ reminderAgent.getValidReminders((err, reminders) => { ``` -## reminderAgent.getValidReminders +## reminderAgent.getValidReminders(deprecated) ```ts -getValidReminders(): Promise> +getValidReminders(): Promise\> ``` Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the reminders. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.getValidReminders](js-apis-reminderAgentManager.md#reminderagentmanagergetvalidreminders-1). + **System capability**: SystemCapability.Notification.ReminderAgent **Return value** @@ -233,21 +257,25 @@ reminderAgent.getValidReminders().then((reminders) => { ``` -## reminderAgent.cancelAllReminders +## reminderAgent.cancelAllReminders(deprecated) ```ts -cancelAllReminders(callback: AsyncCallback): void +cancelAllReminders(callback: AsyncCallback\): void ``` Cancels all reminders set by the current application. This API uses an asynchronous callback to return the cancellation result. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.cancelAllReminders](js-apis-reminderAgentManager.md#reminderagentmanagercancelallreminders). + **System capability**: SystemCapability.Notification.ReminderAgent **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| callback | AsyncCallback\ | Yes| Asynchronous callback used to return the result.| +| callback | AsyncCallback\ | Yes| Callback used to return the result.| **Example** @@ -258,14 +286,18 @@ reminderAgent.cancelAllReminders((err, data) =>{ ``` -## reminderAgent.cancelAllReminders +## reminderAgent.cancelAllReminders(deprecated) ```ts -cancelAllReminders(): Promise +cancelAllReminders(): Promise\ ``` Cancels all reminders set by the current application. This API uses a promise to return the cancellation result. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.cancelAllReminders](js-apis-reminderAgentManager.md#reminderagentmanagercancelallreminders-1). + **System capability**: SystemCapability.Notification.ReminderAgent **Return value** @@ -282,14 +314,18 @@ reminderAgent.cancelAllReminders().then(() => { }) ``` -## reminderAgent.addNotificationSlot +## reminderAgent.addNotificationSlot(deprecated) ```ts -addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback): void +addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback\): void ``` Adds a notification slot. This API uses an asynchronous callback to return the result. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.addNotificationSlot](js-apis-reminderAgentManager.md#reminderagentmanageraddnotificationslot). + **System capability**: SystemCapability.Notification.ReminderAgent **Parameters** @@ -297,7 +333,7 @@ Adds a notification slot. This API uses an asynchronous callback to return the r | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | slot | [NotificationSlot](js-apis-notification.md#notificationslot) | Yes| Notification slot, whose type can be set.| -| callback | AsyncCallback\ | Yes| Asynchronous callback used to return the result.| +| callback | AsyncCallback\ | Yes| Callback used to return the result.| **Example** @@ -313,14 +349,18 @@ reminderAgent.addNotificationSlot(mySlot, (err, data) => { ``` -## reminderAgent.addNotificationSlot +## reminderAgent.addNotificationSlot(deprecated) ```ts -addNotificationSlot(slot: NotificationSlot): Promise +addNotificationSlot(slot: NotificationSlot): Promise\ ``` Adds a notification slot. This API uses a promise to return the result. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.addNotificationSlot](js-apis-reminderAgentManager.md#reminderagentmanageraddnotificationslot-1). + **System capability**: SystemCapability.Notification.ReminderAgent **Parameters** @@ -349,7 +389,7 @@ reminderAgent.addNotificationSlot(mySlot).then(() => { ``` -## reminderAgent.removeNotificationSlot +## reminderAgent.removeNotificationSlot(deprecated) ```ts removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback): void @@ -357,6 +397,10 @@ removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback< Removes a notification slot of a specified type. This API uses an asynchronous callback to return the result. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.removeNotificationSlot](js-apis-reminderAgentManager.md#reminderagentmanagerremovenotificationslot). + **System capability**: SystemCapability.Notification.ReminderAgent **Parameters** @@ -364,7 +408,7 @@ Removes a notification slot of a specified type. This API uses an asynchronous c | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | slotType | [notification.SlotType](js-apis-notification.md#slottype) | Yes| Type of the reminder notification slot to remove.| -| callback | AsyncCallback\ | Yes| Asynchronous callback used to return the result.| +| callback | AsyncCallback\ | Yes| Callback used to return the result.| **Example** @@ -377,7 +421,7 @@ reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, ``` -## reminderAgent.removeNotificationSlot +## reminderAgent.removeNotificationSlot(deprecated) ```ts removeNotificationSlot(slotType: notification.SlotType): Promise @@ -385,6 +429,10 @@ removeNotificationSlot(slotType: notification.SlotType): Promise Removes a notification slot of a specified type. This API uses a promise to return the result. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.removeNotificationSlot](js-apis-reminderAgentManager.md#reminderagentmanagerremovenotificationslot-1). + **System capability**: SystemCapability.Notification.ReminderAgent **Parameters** @@ -410,10 +458,14 @@ reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION). ``` -## ActionButtonType +## ActionButtonType(deprecated) Enumerates button types. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.ActionButtonType](js-apis-reminderAgentManager.md#ActionButtonType). + **System capability**: SystemCapability.Notification.ReminderAgent | Name| Value| Description| @@ -422,10 +474,14 @@ Enumerates button types. | ACTION_BUTTON_TYPE_SNOOZE | 1 | Button for snoozing the reminder.| -## ReminderType +## ReminderType(deprecated) Enumerates reminder types. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.ReminderType](js-apis-reminderAgentManager.md#ReminderType). + **System capability**: SystemCapability.Notification.ReminderAgent | Name| Value| Description| @@ -435,10 +491,14 @@ Enumerates reminder types. | REMINDER_TYPE_ALARM | 2 | Alarm reminder.| -## ActionButton +## ActionButton(deprecated) Defines a button displayed in the reminder notification. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.ActionButton](js-apis-reminderAgentManager.md#ActionButton). + **System capability**: SystemCapability.Notification.ReminderAgent | Name| Type| Mandatory| Description| @@ -447,10 +507,14 @@ Defines a button displayed in the reminder notification. | type | [ActionButtonType](#actionbuttontype) | Yes| Button type.| -## WantAgent +## WantAgent(deprecated) Sets the package and ability that are redirected to when the reminder notification is clicked. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.WantAgent](js-apis-reminderAgentManager.md#WantAgent). + **System capability**: SystemCapability.Notification.ReminderAgent | Name| Type| Mandatory| Description| @@ -459,10 +523,14 @@ Sets the package and ability that are redirected to when the reminder notificati | abilityName | string | Yes| Name of the ability that is redirected to when the reminder notification is clicked.| -## MaxScreenWantAgent +## MaxScreenWantAgent(deprecated) Provides the information about the target package and ability to start automatically when the reminder is displayed in full-screen mode. This API is reserved. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.MaxScreenWantAgent](js-apis-reminderAgentManager.md#MaxScreenWantAgent). + **System capability**: SystemCapability.Notification.ReminderAgent | Name| Type| Mandatory| Description| @@ -471,10 +539,14 @@ Provides the information about the target package and ability to start automatic | abilityName | string | Yes| Name of the ability that is automatically started when the reminder arrives and the device is not in use.| -## ReminderRequest +## ReminderRequest(deprecated) Defines the reminder to publish. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.ReminderRequest](js-apis-reminderAgentManager.md#ReminderRequest). + **System capability**: SystemCapability.Notification.ReminderAgent | Name| Type| Mandatory| Description| @@ -494,12 +566,16 @@ Defines the reminder to publish. | slotType | [notification.SlotType](js-apis-notification.md#slottype) | No| Type of the slot used by the reminder.| -## ReminderRequestCalendar +## ReminderRequestCalendar(deprecated) ReminderRequestCalendar extends ReminderRequest Defines a reminder for a calendar event. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.ReminderRequestCalendar](js-apis-reminderAgentManager.md#ReminderRequestCalendar). + **System capability**: SystemCapability.Notification.ReminderAgent | Name| Type| Mandatory| Description| @@ -509,12 +585,16 @@ Defines a reminder for a calendar event. | repeatDays | Array\ | No| Date on which the reminder repeats.| -## ReminderRequestAlarm +## ReminderRequestAlarm(deprecated) ReminderRequestAlarm extends ReminderRequest Defines a reminder for an alarm. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.ReminderRequestAlarm](js-apis-reminderAgentManager.md#ReminderRequestAlarm). + **System capability**: SystemCapability.Notification.ReminderAgent | Name| Type| Mandatory| Description| @@ -524,12 +604,16 @@ Defines a reminder for an alarm. | daysOfWeek | Array\ | No| Days of a week when the reminder repeats. The value ranges from 1 to 7, corresponding to the data from Monday to Sunday.| -## ReminderRequestTimer +## ReminderRequestTimer(deprecated) ReminderRequestTimer extends ReminderRequest Defines a reminder for a scheduled timer. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.ReminderRequestTimer](js-apis-reminderAgentManager.md#ReminderRequestTimer). + **System capability**: SystemCapability.Notification.ReminderAgent | Name| Type| Mandatory| Description| @@ -537,10 +621,14 @@ Defines a reminder for a scheduled timer. | triggerTimeInSeconds | number | Yes| Number of seconds in the countdown timer.| -## LocalDateTime +## LocalDateTime(deprecated) Sets the time information for a calendar reminder. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [reminderAgentManager.LocalDateTime](js-apis-reminderAgentManager.md#LocalDateTime). + **System capability**: SystemCapability.Notification.ReminderAgent | Name| Type| Mandatory| Description| diff --git a/en/application-dev/reference/apis/js-apis-reminderAgentManager.md b/en/application-dev/reference/apis/js-apis-reminderAgentManager.md index 4380dd084573117be6f2ea5db284969884cad0a3..7ec9eeb2c2070acee07603811e0bbd6417590555 100644 --- a/en/application-dev/reference/apis/js-apis-reminderAgentManager.md +++ b/en/application-dev/reference/apis/js-apis-reminderAgentManager.md @@ -18,9 +18,7 @@ import reminderAgentManager from'@ohos.reminderAgentManager'; ## reminderAgentManager.publishReminder -```ts -publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback): void -``` +publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback\): void Publishes a reminder through the reminder agent. This API uses an asynchronous callback to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8). @@ -33,7 +31,7 @@ Publishes a reminder through the reminder agent. This API uses an asynchronous c | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.| - | callback | AsyncCallback\ | Yes| Callback used to return the published reminder's ID.| + | callback | AsyncCallback\ | Yes| Callback used to return the published reminder's ID.| **Error codes** @@ -67,9 +65,7 @@ try { ## reminderAgentManager.publishReminder -```ts -publishReminder(reminderReq: ReminderRequest): Promise -``` +publishReminder(reminderReq: ReminderRequest): Promise\ Publishes a reminder through the reminder agent. This API uses a promise to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8). @@ -85,7 +81,7 @@ Publishes a reminder through the reminder agent. This API uses a promise to retu **Return value** | Type| Description| | -------- | -------- | - | Promise\ | Promise used to return the published reminder's ID.| + | Promise\ | Promise used to return the published reminder's ID.| **Error codes** @@ -117,9 +113,7 @@ try { ## reminderAgentManager.cancelReminder -```ts -cancelReminder(reminderId: number, callback: AsyncCallback): void -``` +cancelReminder(reminderId: number, callback: AsyncCallback\): void Cancels the reminder with the specified ID. This API uses an asynchronous callback to return the cancellation result. @@ -130,7 +124,7 @@ Cancels the reminder with the specified ID. This API uses an asynchronous callba | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | reminderId | number | Yes| ID of the reminder to cancel.| -| callback | AsyncCallback\ | Yes| Asynchronous callback used to return the result.| +| callback | AsyncCallback\ | Yes| Callback used to return the result.| **Error codes** @@ -160,9 +154,7 @@ try { ## reminderAgentManager.cancelReminder -```ts -cancelReminder(reminderId: number): Promise -``` +cancelReminder(reminderId: number): Promise\ Cancels the reminder with the specified ID. This API uses a promise to return the cancellation result. @@ -178,7 +170,7 @@ Cancels the reminder with the specified ID. This API uses a promise to return th | Type| Description| | -------- | -------- | -| Promise\ | Promise used to return the result.| +| PPromise\ | Promise used to return the result.| **Error codes** @@ -205,10 +197,8 @@ try { ## reminderAgentManager.getValidReminders -```ts -getValidReminders(callback: AsyncCallback>): void +getValidReminders(callback: AsyncCallback>): void -``` Obtains all valid (not yet expired) reminders set by the current application. This API uses an asynchronous callback to return the reminders. @@ -218,7 +208,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| callback | AsyncCallback\\> | Yes| Asynchronous callback used to return an array of all valid reminders set by the current application.| +| callback | AsyncCallback\> | Yes| Asynchronous callback used to return an array of all valid reminders set by the current application.| **Error codes** @@ -267,9 +257,7 @@ try { ## reminderAgentManager.getValidReminders -```ts -getValidReminders(): Promise> -``` +getValidReminders(): Promise\> Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the reminders. @@ -279,7 +267,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th | Type| Description| | -------- | -------- | -| Promise\\> | Promise used to return an array of all valid reminders set by the current application.| +| Promise\> | Promise used to return an array of all valid reminders set by the current application.| **Error codes** @@ -327,9 +315,7 @@ try { ## reminderAgentManager.cancelAllReminders -```ts -cancelAllReminders(callback: AsyncCallback): void -``` +cancelAllReminders(callback: AsyncCallback\): void Cancels all reminders set by the current application. This API uses an asynchronous callback to return the cancellation result. @@ -339,7 +325,7 @@ Cancels all reminders set by the current application. This API uses an asynchron | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| callback | AsyncCallback\ | Yes| Asynchronous callback used to return the result.| +| callback | AsyncCallback\ | Yes| Callback used to return the result.| **Error codes** @@ -368,9 +354,7 @@ try { ## reminderAgentManager.cancelAllReminders -```ts -cancelAllReminders(): Promise -``` +cancelAllReminders(): Promise\ Cancels all reminders set by the current application. This API uses a promise to return the cancellation result. @@ -380,7 +364,7 @@ Cancels all reminders set by the current application. This API uses a promise to | Type| Description| | -------- | -------- | -| Promise\ | Promise used to return the result.| +| Promise\ | Promise used to return the result.| **Error codes** @@ -407,9 +391,7 @@ try { ## reminderAgentManager.addNotificationSlot -```ts -addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback): void -``` +addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback\): void Adds a notification slot. This API uses an asynchronous callback to return the result. @@ -420,7 +402,7 @@ Adds a notification slot. This API uses an asynchronous callback to return the r | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | slot | [NotificationSlot](js-apis-notification.md#notificationslot) | Yes| Notification slot, whose type can be set.| -| callback | AsyncCallback\ | Yes| Asynchronous callback used to return the result.| +| callback | AsyncCallback\ | Yes| Callback used to return the result.| **Example** @@ -446,9 +428,7 @@ try { ## reminderAgentManager.addNotificationSlot -```ts -addNotificationSlot(slot: NotificationSlot): Promise -``` +addNotificationSlot(slot: NotificationSlot): Promise\ Adds a notification slot. This API uses a promise to return the result. @@ -464,7 +444,7 @@ Adds a notification slot. This API uses a promise to return the result. | Type| Description| | -------- | -------- | -| Promise\ | Promise used to return the result.| +| Promise\ | Promise used to return the result.| **Example** @@ -488,9 +468,7 @@ try { ## reminderAgentManager.removeNotificationSlot -```ts -removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback): void -``` +removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\): void Removes a notification slot of a specified type. This API uses an asynchronous callback to return the result. @@ -501,7 +479,7 @@ Removes a notification slot of a specified type. This API uses an asynchronous c | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | slotType | [notification.SlotType](js-apis-notification.md#slottype) | Yes| Type of the notification slot to remove.| -| callback | AsyncCallback\ | Yes| Asynchronous callback used to return the result.| +| callback | AsyncCallback\ | Yes| Callback used to return the result.| **Example** @@ -524,9 +502,7 @@ try { ## reminderAgentManager.removeNotificationSlot -```ts -removeNotificationSlot(slotType: notification.SlotType): Promise -``` +removeNotificationSlot(slotType: notification.SlotType): Promise\ Removes a notification slot of a specified type. This API uses a promise to return the result. @@ -542,7 +518,7 @@ Removes a notification slot of a specified type. This API uses a promise to retu | Type| Description| | -------- | -------- | -| Promise\ | Promise used to return the result.| +| Promise\ | Promise used to return the result.| **Example** @@ -570,7 +546,7 @@ Enumerates button types. | -------- | -------- | -------- | | ACTION_BUTTON_TYPE_CLOSE | 0 | Button for closing the reminder.| | ACTION_BUTTON_TYPE_SNOOZE | 1 | Button for snoozing the reminder.| -| ACTION_BUTTON_TYPE_CUSTOM10+ | 2 | Custom button. (This is a system API.)| +| ACTION_BUTTON_TYPE_CUSTOM10+ | 2 | Custom button.
**System API**: This is a system API and cannot be called by third-party applications.| ## ReminderType @@ -590,13 +566,14 @@ Enumerates reminder types. Defines a button displayed for the reminder in the notification panel. + **System capability**: SystemCapability.Notification.ReminderAgent | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | title | string | Yes| Text on the button.| | type | [ActionButtonType](#actionbuttontype) | Yes| Button type.| -| wantAgent10+ | [WantAgent](#wantagent) | No| Ability information that is displayed after the button is clicked. (This is a system API.)| +| wantAgent10+ | [WantAgent](#wantagent) | No| Ability information that is displayed after the button is clicked.
**System API**: This is a system API and cannot be called by third-party applications.| ## WantAgent @@ -605,10 +582,12 @@ Defines the information about the redirected-to ability. **System capability**: SystemCapability.Notification.ReminderAgent + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | pkgName | string | Yes| Name of the target package.| | abilityName | string | Yes| Name of the target ability.| +| uri10+ | string | No| URI of the target ability.
**System API**: This is a system API and cannot be called by third-party applications.| ## MaxScreenWantAgent @@ -632,7 +611,7 @@ Defines the reminder to publish. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | reminderType | [ReminderType](#remindertype) | Yes| Type of the reminder.| -| actionButton | [ActionButton](#actionbutton) | No| Button displayed for the reminder in the notification panel. For common applications, a maximum of two buttons are supported. For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions. | +| actionButton10+ | [ActionButton](#actionbutton) | No| Button displayed for the reminder in the notification panel. For common applications, a maximum of two buttons are supported. For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions. | | wantAgent | [WantAgent](#wantagent) | No| Information about the ability that is redirected to when the reminder is clicked.| | maxScreenWantAgent | [MaxScreenWantAgent](#maxscreenwantagent) | No| Information about the ability that is automatically started when the reminder arrives. If the device is in use, a notification will be displayed.| | ringDuration | number | No| Ringing duration, in seconds. The default value is **1**.| @@ -659,8 +638,8 @@ Defines a reminder for a calendar event. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dateTime | [LocalDateTime](#localdatetime) | Yes| Reminder time.| -| repeatMonths | Array\ | No| Month in which the reminder repeats.| -| repeatDays | Array\ | No| Date on which the reminder repeats.| +| repeatMonths | Array\ | No| Month in which the reminder repeats.| +| repeatDays | Array\ | No| Date on which the reminder repeats.| ## ReminderRequestAlarm @@ -675,7 +654,7 @@ Defines a reminder for an alarm. | -------- | -------- | -------- | -------- | | hour | number | Yes| Hour portion of the reminder time.| | minute | number | Yes| Minute portion of the reminder time.| -| daysOfWeek | Array\ | No| Days of a week when the reminder repeats. The value ranges from 1 to 7, corresponding to the data from Monday to Sunday.| +| daysOfWeek | Array\ | No| Days of a week when the reminder repeats. The value ranges from 1 to 7, corresponding to the data from Monday to Sunday.| ## ReminderRequestTimer diff --git a/en/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md b/en/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md index ab02ed0f2c5bf6bf553f6a36f6a94442db2bb378..9118b8b56684cc021cbd83511a905e28d5ddaead 100644 --- a/en/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md +++ b/en/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md @@ -39,7 +39,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes | 9700001 | Memory operation failed. | | 9700002 | Parcel operation failed. | | 9700003 | System service operation failed. | -| 9700004 | Checking workInfo failed. | +| 9700004 | Check workInfo failed. | | 9700005 | StartWork failed. | @@ -80,7 +80,7 @@ Instructs the **WorkSchedulerService** to stop the specified task. | Name | Type | Mandatory | Description | | ---------- | --------------------- | ---- | ---------- | | work | [WorkInfo](#workinfo) | Yes | Task to stop. | -| needCancel | boolean | Yes | Whether to cancel the task.| +| needCancel | boolean | No | Whether to cancel the task. The default value is **false**.| **Error codes** @@ -91,7 +91,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes | 9700001 | Memory operation failed. | | 9700002 | Parcel operation failed. | | 9700003 | System service operation failed. | -| 9700004 | Checking workInfo failed. | +| 9700004 | Check workInfo failed. | **Example** @@ -118,7 +118,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes } ``` -## workScheduler.getWorkStatus:callback +## workScheduler.getWorkStatus getWorkStatus(workId: number, callback : AsyncCallback\): void Obtains the latest task status. This API uses an asynchronous callback to return the result. @@ -141,7 +141,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes | 9700001 | Memory operation failed. | | 9700002 | Parcel operation failed. | | 9700003 | System service operation failed. | -| 9700004 | Checking workInfo failed. | +| 9700004 | Check workInfo failed. | **Example** @@ -161,7 +161,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes } ``` -## workScheduler.getWorkStatus:promise +## workScheduler.getWorkStatus getWorkStatus(workId: number): Promise\ Obtains the latest task status. This API uses a promise to return the result. @@ -189,7 +189,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes | 9700001 | Memory operation failed. | | 9700002 | Parcel operation failed. | | 9700003 | System service operation failed. | -| 9700004 | Checking workInfo failed. | +| 9700004 | Check workInfo failed. | **Example** @@ -207,7 +207,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes } ``` -## workScheduler.obtainAllWorks:callback +## workScheduler.obtainAllWorks obtainAllWorks(callback : AsyncCallback\): Array\ Obtains all tasks associated with this application. This API uses an asynchronous callback to return the result. @@ -252,8 +252,8 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes } ``` -## workScheduler.obtainAllWorks:promise -obtainAllWorks(): Promise> +## workScheduler.obtainAllWorks +obtainAllWorks(): Promise\> Obtains all tasks associated with this application. This API uses a promise to return the result. @@ -317,7 +317,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes } ``` -## workScheduler.isLastWorkTimeOut:callback +## workScheduler.isLastWorkTimeOut isLastWorkTimeOut(workId: number, callback : AsyncCallback\): boolean Checks whether the last execution of the specified task timed out. This API uses an asynchronous callback to return the result. @@ -346,7 +346,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes | 9700001 | Memory operation failed. | | 9700002 | Parcel operation failed. | | 9700003 | System service operation failed. | -| 9700004 | Checking workInfo failed. | +| 9700004 | Check workInfo failed. | **Example** @@ -364,7 +364,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes } ``` -## workScheduler.isLastWorkTimeOut:promise +## workScheduler.isLastWorkTimeOut isLastWorkTimeOut(workId: number): Promise\ Checks whether the last execution of the specified task timed out. This API uses a promise to return the result. @@ -392,7 +392,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes | 9700001 | Memory operation failed. | | 9700002 | Parcel operation failed. | | 9700003 | System service operation failed. | -| 9700004 | Checking workInfo failed. | +| 9700004 | Check workInfo failed. | **Example** @@ -432,7 +432,7 @@ Provides detailed information about the task. For details about the constraints | isPersisted | boolean | No | Whether to enable persistent storage for the task. | | isDeepIdle | boolean | No | Whether the device needs to enter the idle state. | | idleWaitTime | number | No | Time to wait in the idle state. | -| parameters | {[key: string]: number | string | boolean} | No | Carried parameters. | +| parameters | {[key: string]: number \| string \| boolean} | No | Carried parameters. | ## NetworkType Enumerates the network types that can trigger the task. diff --git a/en/application-dev/reference/apis/js-apis-rpc.md b/en/application-dev/reference/apis/js-apis-rpc.md index c4688c804e2ea21de453a25cf2ad543193f9d2ed..e444fd018a529d7c2901c25ed1b6b24630eb54d9 100644 --- a/en/application-dev/reference/apis/js-apis-rpc.md +++ b/en/application-dev/reference/apis/js-apis-rpc.md @@ -45,9 +45,9 @@ During RPC or IPC, the sender can use the **write()** method provided by **Messa ### create - static create(): MessageSequence +static create(): MessageSequence - Creates a **MessageSequence** object. This API is a static method. +Creates a **MessageSequence** object. This API is a static method. **System capability**: SystemCapability.Communication.IPC.Core @@ -6821,8 +6821,8 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode } let deathRecipient = new MyDeathRecipient(); try { - proxy.registerDeathRecippient(deathRecipient, 0); - proxy.unregisterDeathRecippient(deathRecipient, 0); + proxy.registerDeathRecipient(deathRecipient, 0); + proxy.unregisterDeathRecipient(deathRecipient, 0); } catch(error) { console.info("proxy register deathRecipient fail, errorCode " + error.code); console.info("proxy register deathRecipient fail, errorMessage " + error.message); @@ -6893,7 +6893,7 @@ Removes the callback used to receive death notifications of the remote object. } } let deathRecipient = new MyDeathRecipient(); - proxy.addDeathRecippient(deathRecipient, 0); + proxy.addDeathRecipient(deathRecipient, 0); proxy.removeDeathRecipient(deathRecipient, 0); ``` diff --git a/en/application-dev/reference/apis/js-apis-shortKey.md b/en/application-dev/reference/apis/js-apis-shortKey.md new file mode 100644 index 0000000000000000000000000000000000000000..79a8ce26644ead2c634af316ab5e191fc6955442 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-shortKey.md @@ -0,0 +1,81 @@ +# @ohos.multimodalInput.shortKey (Shortcut Key) + +The **shortKey** module provides APIs to set the delay for starting an ability using a shortcut key. For example, you can set the delay to 3 seconds so that a screenshot is taken when you press and hold the shortcut key for 3 seconds. + +> **NOTE** +> +> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> - The APIs provided by this module are system APIs. + +## Modules to Import + +``` +import shortKey from '@ohos.multimodalInput.shortKey'; +``` + +## shortKey.setKeyDownDuration + +setKeyDownDuration(businessId: string, delay: number, callback: AsyncCallback<void>): void + +Sets the delay for starting an ability using the shortcut key. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.ShortKey + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------- | ---- | ------------------------------------------------------------ | +| businessId | string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.| +| delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example** + +``` +try { + shortKey.setKeyDownDuration("screenshot", 500, (error) => { + if (error) { + console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + return; + } + console.log(`Set key down duration success`); + }); +} catch (error) { + console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + + + +## shortKey.setKeyDownDuration + +setKeyDownDuration(businessId: string, delay: number): Promise<void> + +Sets the delay for starting an ability using the shortcut key. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.ShortKey + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ------------------------------------------------------------ | +| businessId | string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.| +| delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.| + +**Return value** + +| Parameters | Description | +| ------------- | ------------- | +| Promise<void> | Promise used to return the result.| + +**Example** + +``` +try { + shortKey.setKeyDownDuration("screenshot", 500).then(() => { + console.log(`Set key down duration success`); + }); +} catch (error) { + console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` diff --git a/en/application-dev/reference/apis/js-apis-stationary.md b/en/application-dev/reference/apis/js-apis-stationary.md index e05d0be7fb9f7e3a8329f28c1fc54c1d2a45ca63..7f732445123bce8a0fafde50b26a36548be0eb8e 100644 --- a/en/application-dev/reference/apis/js-apis-stationary.md +++ b/en/application-dev/reference/apis/js-apis-stationary.md @@ -123,7 +123,7 @@ Unsubscribes from the device status. | -------------------- | -------------------------------------------------- | ---- | ---------------------------- | | activity | [ActivityType](#activitytype) | Yes | Device status type. | | event | [ActivityEvent](#activityevent) | Yes | Event type. | -| callback | Callback<[ActivityResponse](#activityresponse)\> | No | Callback used to receive reported data, if the callback parameter is not passed, all callbacks subscribed to this type under this process will be removed. | +| callback | Callback<[ActivityResponse](#activityresponse)\> | No | Callback used to receive reported data. If this parameter is not passed, all callbacks associated with the specified event in the process will be unregistered. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-system-battery.md b/en/application-dev/reference/apis/js-apis-system-battery.md index efeb9caec59a04362b80c6f3502dc5a34b8e7f34..8eef0562cdedb91214d4eb9e688445eb6d8ff9b8 100644 --- a/en/application-dev/reference/apis/js-apis-system-battery.md +++ b/en/application-dev/reference/apis/js-apis-system-battery.md @@ -27,7 +27,7 @@ Obtains the current charging state and battery level. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [GetStatusOptions](#getstatusoptions) | No| Object that contains the API calling result.| +| options | [GetStatusOptions](#getstatusoptions) | No| Object that contains the API calling result. This parameter is optional and is left blank by default.| **Example** @@ -50,9 +50,9 @@ Object that contains the API calling result. | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | -| success | (data: [BatteryResponse](#batteryresponse)) => void | No | Called when API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponse) type.| -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when API call is complete. | +| success | (data: [BatteryResponse](#batteryresponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponse) type.| +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. | +| complete | () => void | No | Called when an API call is complete. | ## BatteryResponse diff --git a/en/application-dev/reference/apis/js-apis-system-brightness.md b/en/application-dev/reference/apis/js-apis-system-brightness.md index 8053c8f0c73d190d33e547ff9f0227df5c6db06a..01a1defec2d87411735e0ffcf30b08beb93faccf 100644 --- a/en/application-dev/reference/apis/js-apis-system-brightness.md +++ b/en/application-dev/reference/apis/js-apis-system-brightness.md @@ -28,7 +28,7 @@ Obtains the current screen brightness. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [GetBrightnessOptions](#getbrightnessoptions) | No | Options for obtaining the screen brightness.| +| options | [GetBrightnessOptions](#getbrightnessoptions) | No | Options for obtaining the screen brightness. This parameter is optional and is left blank by default.| **Example** @@ -56,7 +56,7 @@ Sets the screen brightness. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [SetBrightnessOptions](#setbrightnessoptions) | No | Options for setting the screen brightness.| +| options | [SetBrightnessOptions](#setbrightnessoptions) | No | Options for setting the screen brightness. This parameter is optional and is left blank by default.| **Example** @@ -85,7 +85,7 @@ Obtains the screen brightness adjustment mode. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [GetBrightnessModeOptions](#getbrightnessmodeoptions) | No| Options for obtaining the screen brightness mode.| +| options | [GetBrightnessModeOptions](#getbrightnessmodeoptions) | No| Options for obtaining the screen brightness mode. This parameter is optional and is left blank by default.| **Example** @@ -112,7 +112,7 @@ Sets the screen brightness adjustment mode. **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [SetBrightnessModeOptions](#setbrightnessmodeoptions) | No | Options for setting the screen brightness mode.| +| options | [SetBrightnessModeOptions](#setbrightnessmodeoptions) | No | Options for setting the screen brightness mode. This parameter is optional and is left blank by default.| **Example** @@ -143,7 +143,7 @@ Sets whether to always keep the screen on. Call this API in **onShow()**. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [SetKeepScreenOnOptions](#setkeepscreenonoptions) | No| Options for setting the screen to be steady on.| +| options | [SetKeepScreenOnOptions](#setkeepscreenonoptions) | No| Options for setting the screen to be steady on. This parameter is optional and is left blank by default.| **Example** @@ -166,9 +166,9 @@ Defines the options for obtaining the screen brightness. | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| success | (data: [BrightnessResponse](#brightnessresponse)) => void | No | Called when API call is successful. **data** is a return value of the [BrightnessResponse](#brightnessresponse) type.| -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when the API call is complete. | +| success | (data: [BrightnessResponse](#brightnessresponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BrightnessResponse](#brightnessresponse) type.| +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. | +| complete | () => void | No | Called when an API call is complete. | ## SetBrightnessOptions @@ -178,10 +178,10 @@ Defines the options for setting the screen brightness. | Name | Type | Mandatory| Description | | -------- | ------------------------------------ | ---- | ------------------------------------------------------------ | -| value | number | Yes | Screen brightness. The value is an integer ranging from **1** to **255**.
- If the value is less than or equal to **0**, value **1** will be used.
- If the value is greater than **255**, value **255** will be used.
- If the value contains decimals, the integral part of the value will be used. For example, if value **8.1** is set, value **8** will be used.| -| success | () => void | No | Callback upon a successful API call. | -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when the API call is complete. | +| value | number | Yes | Screen brightness. The value is an integer ranging from **1** to **255**.
- If the value is less than or equal to **0**, value **1** will be used.
- If the value is greater than **255**, value **255** will be used.
- If the value contains decimals, the integral part of the value will be used. For example, if value **8.1** is set, value **8** will be used.| +| success | () => void | No | Called when an API call is successful. | +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. | +| complete | () => void | No | Called when an API call is complete. | ## BrightnessResponse @@ -201,9 +201,9 @@ Defines the options for obtaining the screen brightness mode. | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| success | (data: [BrightnessModeResponse](#brightnessmoderesponse)) => void | No | Called when API call is successful. **data** is a return value of the [BrightnessModeResponse](#brightnessmoderesponse) type.| -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when the API call is complete. | +| success | (data: [BrightnessModeResponse](#brightnessmoderesponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BrightnessModeResponse](#brightnessmoderesponse) type.| +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. | +| complete | () => void | No | Called when an API call is complete. | ## SetBrightnessModeOptions @@ -214,9 +214,9 @@ Defines the options for setting the screen brightness mode. | Name | Type | Mandatory| Description | | -------- | ------------------------------------ | ---- | ------------------------------------------------------ | | mode | number | Yes | The value **0** indicates the manual adjustment mode, and the value **1** indicates the automatic adjustment mode.| -| success | () => void | No | Callback upon a successful API call. | -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.| -| complete | () => void | No | Called when the API call is complete. | +| success | () => void | No | Called when an API call is successful. | +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code.| +| complete | () => void | No | Called when an API call is complete. | ## BrightnessModeResponse @@ -237,6 +237,6 @@ Defines the options for setting the screen to be steady on. | Name | Type | Mandatory| Description | | ------------ | ------------------------------------ | ---- | ------------------------------------------------------ | | keepScreenOn | boolean | Yes | The value **true** means to keep the screen steady on, and the value **false** indicates the opposite. | -| success | () => void | No | Callback upon a successful API call. | -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.| -| complete | () => void | No | Called when the API call is complete. | +| success | () => void | No | Called when an API call is successful. | +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code.| +| complete | () => void | No | Called when an API call is complete. | diff --git a/en/application-dev/reference/apis/js-apis-system-fetch.md b/en/application-dev/reference/apis/js-apis-system-fetch.md index 96bc642f5214e48b09df204a314bd694677a77f4..316e9ca1b3a083d9fdb277b6d910019d229cbce7 100644 --- a/en/application-dev/reference/apis/js-apis-system-fetch.md +++ b/en/application-dev/reference/apis/js-apis-system-fetch.md @@ -16,47 +16,15 @@ import fetch from '@system.fetch'; ## fetch.fetch3+ -fetch(options:{ - /** - * Resource URL. - * @since 3 - */ - url: string; - /** - * Request parameter, which can be of the string type or a JSON object. - * @since 3 - */ - data?: string | object; - /** - * Request header, which accommodates all attributes of the request. - * @since 3 - */ - header?: Object; - /** - * Request methods available: OPTIONS, GET, HEAD, POST, PUT, DELETE and TRACE. The default value is GET. - * @since 3 - */ - method?: string; - /** - * The return type can be text, or JSON. By default, the return type is determined based on Content-Type in the header returned by the server. - * @since 3 - */ - responseType?: string; - /** - * Called when the network data is obtained successfully. - * @since 3 - */ - success?: (data: FetchResponse) => void; - /** - * Called when the network data fails to be obtained. - * @since 3 - */ - fail?: (data: any, code: number) => void; - /** - * Called when the execution is completed. - * @since 3 - */ - complete?: () => void; +fetch(options:{
+  url: string;
+  data?: string | object;
+  header?: Object;
+  method?: string;
+  responseType?: string;
+  success?: (data: FetchResponse) => void;
+  fail?: (data: any, code: number) => void;
+  complete?: () => void;
} ): void Obtains data through a network. diff --git a/en/application-dev/reference/apis/js-apis-system-network.md b/en/application-dev/reference/apis/js-apis-system-network.md index 232c2be8d60b3b893fbebc1119b7d9e807d80ddf..e0cc9a177547c86910db7b3ba4c8ac5e8eb97e75 100644 --- a/en/application-dev/reference/apis/js-apis-system-network.md +++ b/en/application-dev/reference/apis/js-apis-system-network.md @@ -1,8 +1,6 @@ # @system.network (Network State) > **NOTE** -> - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.telephony.observer`](js-apis-observer.md). -> > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -23,23 +21,11 @@ ohos.permission.GET_NETWORK_INFO ## network.getType3+ -getType(options?: { - /** - * Called when the network type is obtained. - * @since 3 - */ - success?: (data: NetworkResponse) => void; - /** - * Called when the network type fails to be obtained. - * @since 3 - */ - fail?: (data: any, code: number) => void; - /** - * Called when the execution is completed. - * @since 3 - */ - complete?: () => void; - }): void +getType(options?: {
+  success?: (data: NetworkResponse) => void;
+  fail?: (data: any, code: number) => void;
+  complete?: () => void;
+}): void Obtains the network type. @@ -79,17 +65,9 @@ export default { ## network.subscribe3+ -subscribe(options?:{ - /** - * Called when the network connection state changes. - * @since 3 - */ - success?: (data: NetworkResponse) => void; - /** - * Called when the listening fails. - * @since 3 - */ - fail?: (data: any, code: number) => void; +subscribe(options?:{
+  success?: (data: NetworkResponse) => void;
+  fail?: (data: any, code: number) => void;
}): void Listens to the network connection state. If this method is called multiple times, the last call takes effect. diff --git a/en/application-dev/reference/apis/js-apis-thermal.md b/en/application-dev/reference/apis/js-apis-thermal.md index d9914d9c865911380d57548e94d068956e690ec9..add214749c1dc31c0c477ba48180a1c9d8bd1808 100644 --- a/en/application-dev/reference/apis/js-apis-thermal.md +++ b/en/application-dev/reference/apis/js-apis-thermal.md @@ -1,6 +1,6 @@ # @ohos.thermal (Thermal Management) -The **thermal** module provides thermal level-related callback and query APIs to obtain the information required for thermal control. +This module provides thermal level-related callback and query APIs to obtain the information required for thermal control. > **NOTE** > @@ -90,7 +90,7 @@ Obtains the current thermal level. **System capability:** SystemCapability.PowerManager.ThermalManager -**Return value** +**Return value**: | Type | Description | | ------------ | ------------ | @@ -173,7 +173,7 @@ Obtains the current thermal level. **System capability:** SystemCapability.PowerManager.ThermalManager -**Return value** +**Return value**: | Type | Description | | ------------ | ------ | diff --git a/en/application-dev/reference/apis/js-apis-zlib.md b/en/application-dev/reference/apis/js-apis-zlib.md index 96eacdacfb44cc7dc157f640fae81be96df42da1..05a99a8f76cf5195fed45d270945b9dc0aa8f25a 100644 --- a/en/application-dev/reference/apis/js-apis-zlib.md +++ b/en/application-dev/reference/apis/js-apis-zlib.md @@ -142,6 +142,7 @@ Compresses a file. This API uses an asynchronous callback to return the result. **Error codes** For details about the error codes, see [zlib Error Codes](../errorcodes/errorcode-zlib.md). + | ID| Error Message | | -------- | --------------------------------------| | 900001 | The input source file is invalid. | diff --git a/en/application-dev/reference/arkui-js-lite/figures/#000000.png b/en/application-dev/reference/arkui-js-lite/figures/000000.png similarity index 100% rename from en/application-dev/reference/arkui-js-lite/figures/#000000.png rename to en/application-dev/reference/arkui-js-lite/figures/000000.png diff --git a/en/application-dev/reference/arkui-js-lite/js-common-styles.md b/en/application-dev/reference/arkui-js-lite/js-common-styles.md index 15d76dc7b93a04aa82644b52f3a69f834d9aa1c8..52b7e4c81ed17f40e65b8dcfcc0a359729453429 100644 --- a/en/application-dev/reference/arkui-js-lite/js-common-styles.md +++ b/en/application-dev/reference/arkui-js-lite/js-common-styles.md @@ -4,21 +4,21 @@ You can set universal styles for components in the **style** attribute or **.css** files. -| Name| Type| Default Value| Mandatory| Description| -| -------- | -------- | -------- | -------- | -------- | -| width | <length> \| <percentage>5+ | - | No| Component width.

If this attribute is not set, the default value **0** is used.| -| height | <length> \| <percentage>5+ | - | No| Component height.

If this attribute is not set, the default value **0** is used.| -| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides in a declaration.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| -| padding-[left\|top\|right\|bottom] | <length> | 0 | No| Left, top, right, and bottom padding.| -| margin | <length> \| <percentage>5+ | 0 | No| Shorthand attribute to set the margin for all sides in a declaration. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| -| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No| Left, top, right, and bottom margins.| -| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| -| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| -| border-radius | <length> | - | No| Radius of round-corner borders. | -| background-color | <color> | - | No| Background color.| -| opacity5+ | number | 1 | No| Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent.| -| display | string | flex | No| Type of the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| -| [left\|top] | <length> \| <percentage>6+ | - | No| Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element. | +| Name | Type | Default Value | Mandatory | Description | +| ---------------------------------- | ---------------------------------------- | ----- | ---- | ---------------------------------------- | +| width | <length> \| <percentage>5+ | - | No | Component width.

If this attribute is not set, the default value **0** is used. | +| height | <length> \| <percentage>5+ | - | No | Component height.

If this attribute is not set, the default value **0** is used. | +| padding | <length> | 0 | No | Shorthand attribute to set the padding for all sides in a declaration.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No | Left, top, right, and bottom padding. | +| margin | <length> \| <percentage>5+ | 0 | No | Shorthand attribute to set the margin for all sides in a declaration. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No | Left, top, right, and bottom margins. | +| border-width | <length> | 0 | No | Shorthand attribute to set the margin for all sides. | +| border-color | <color> | black | No | Shorthand attribute to set the color for all borders. | +| border-radius | <length> | - | No | Radius of round-corner borders. | +| background-color | <color> | - | No | Background color. | +| opacity5+ | number | 1 | No | Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent. | +| display | string | flex | No | Type of the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No | Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element.| > **NOTE** @@ -37,152 +37,152 @@ You can set universal styles for components in the **style** attribute or **.css **Table 1** Color enums -| Name| Hexadecimal Code| Color| -| -------- | -------- | -------- | -| aliceblue | \#f0f8ff | ![aliceblue](figures/aliceblue.png) | -| antiquewhite | \#faebd7 | ![antiquewhite](figures/antiquewhite.png) | -| aqua | \#00ffff | ![aqua](figures/aqua.png) | -| aquamarine | \#7fffd4 | ![aquamarine](figures/aquamarine.png) | -| azure | \#f0ffff | ![azure](figures/azure.png) | -| beige | \#f5f5dc | ![beige](figures/beige.png) | -| bisque | \#ffe4c4 | ![bisque](figures/bisque.png) | -| black | \#000000 | ![#000000](figures/#000000.png) | -| blanchedalmond | \#ffebcd | ![blanchedalmond](figures/blanchedalmond.png) | -| blue | \#0000ff | ![blue](figures/blue.png) | -| blueviolet | \#8a2be2 | ![blueviolet](figures/blueviolet.png) | -| brown | \#a52a2a | ![brown](figures/brown.png) | -| burlywood | \#deB887 | ![burlywood](figures/burlywood.png) | -| cadetblue | \#5f9ea0 | ![cadetblue](figures/cadetblue.png) | -| chartreuse | \#7fff00 | ![chartreuse](figures/chartreuse.png) | -| chocolate | \#d2691e | ![chocolate](figures/chocolate.png) | -| coral | \#ff7f50 | ![coral](figures/coral.png) | -| cornflowerblue | \#6495ed | ![cornflowerblue](figures/cornflowerblue.png) | -| cornsilk | \#fff8dc | ![cornsilk](figures/cornsilk.png) | -| crimson | \#dc143c | ![crimson](figures/crimson.png) | -| cyan | \#00ffff | ![cyan](figures/cyan.png) | -| darkblue | \#00008b | ![darkblue](figures/darkblue.png) | -| darkcyan | \#008b8b | ![darkcyan](figures/darkcyan.png) | -| darkgoldenrod | \#b8860b | ![darkgoldenrod](figures/darkgoldenrod.png) | -| darkgray | \#a9a9a9 | ![darkgray](figures/darkgray.png) | -| darkgreen | \#006400 | ![darkgreen](figures/darkgreen.png) | -| darkgrey | \#a9a9a9 | ![darkgrey](figures/darkgrey.png) | -| darkkhaki | \#bdb76b | ![darkkhaki](figures/darkkhaki.png) | -| darkmagenta | \#8b008b | ![darkmagenta](figures/darkmagenta.png) | -| darkolivegreen | \#556b2f | ![darkolivegreen](figures/darkolivegreen.png) | -| darkorange | \#ff8c00 | ![darkorange](figures/darkorange.png) | -| darkorchid | \#9932cc | ![darkorchid](figures/darkorchid.png) | -| darkred | \#8b0000 | ![darkred](figures/darkred.png) | -| darksalmon | \#e9967a | ![darksalmon](figures/darksalmon.png) | -| darkseagreen | \#8fbc8f | ![darkseagreen](figures/darkseagreen.png) | -| darkslateblue | \#483d8b | ![darkslateblue](figures/darkslateblue.png) | -| darkslategray | \#2f4f4f | ![darkslategray](figures/darkslategray.png) | -| darkslategrey | \#2f4f4f | ![darkslategrey](figures/darkslategrey.png) | -| darkturquoise | \#00ced1 | ![darkturquoise](figures/darkturquoise.png) | -| darkviolet | \#9400d3 | ![darkviolet](figures/darkviolet.png) | -| deeppink | \#ff1493 | ![deeppink](figures/deeppink.png) | -| deepskyblue | \#00bfff | ![deepskyblue](figures/deepskyblue.png) | -| dimgray | \#696969 | ![dimgray](figures/dimgray.png) | -| dimgrey | \#696969 | ![dimgrey](figures/dimgrey.png) | -| dodgerblue | \#1e90ff | ![dodgerblue](figures/dodgerblue.png) | -| firebrick | \#b22222 | ![firebrick](figures/firebrick.png) | -| floralwhite | \#fffaf0 | ![floralwhite](figures/floralwhite.png) | -| forestgreen | \#228b22 | ![forestgreen](figures/forestgreen.png) | -| fuchsia | \#ff00ff | ![fuchsia](figures/fuchsia.png) | -| gainsboro | \#dcdcdc | ![gainsboro](figures/gainsboro.png) | -| ghostwhite | \#f8f8ff | ![ghostwhite](figures/ghostwhite.png) | -| gold | \#ffd700 | ![gold](figures/gold.png) | -| goldenrod | \#daa520 | ![goldenrod](figures/goldenrod.png) | -| gray | \#808080 | ![gray](figures/gray.png) | -| green | \#008000 | ![green](figures/green.png) | -| greenyellow | \#adff2f | ![greenyellow](figures/greenyellow.png) | -| grey | \#808080 | ![grey](figures/grey.png) | -| honeydew | \#f0fff0 | ![honeydew](figures/honeydew.png) | -| hotpink | \#ff69b4 | ![hotpink](figures/hotpink.png) | -| indianred | \#cd5c5c | ![indianred](figures/indianred.png) | -| indigo | \#4b0082 | ![indigo](figures/indigo.png) | -| ivory | \#fffff0 | ![ivory](figures/ivory.png) | -| khaki | \#f0e68c | ![khaki](figures/khaki.png) | -| lavender | \#e6e6fa | ![lavender](figures/lavender.png) | -| lavenderblush | \#fff0f5 | ![lavenderblush](figures/lavenderblush.png) | -| lawngreen | \#7cfc00 | ![lawngreen](figures/lawngreen.png) | -| lemonchiffon | \#fffacd | ![lemonchiffon](figures/lemonchiffon.png) | -| lightblue | \#add8e6 | ![lightblue](figures/lightblue.png) | -| lightcoral | \#f08080 | ![lightcoral](figures/lightcoral.png) | -| lightcyan | \#e0ffff | ![lightcyan](figures/lightcyan.png) | +| Name | Hexadecimal Code | Color | +| -------------------- | -------- | ---------------------------------------- | +| aliceblue | \#f0f8ff | ![aliceblue](figures/aliceblue.png) | +| antiquewhite | \#faebd7 | ![antiquewhite](figures/antiquewhite.png) | +| aqua | \#00ffff | ![aqua](figures/aqua.png) | +| aquamarine | \#7fffd4 | ![aquamarine](figures/aquamarine.png) | +| azure | \#f0ffff | ![azure](figures/azure.png) | +| beige | \#f5f5dc | ![beige](figures/beige.png) | +| bisque | \#ffe4c4 | ![bisque](figures/bisque.png) | +| black | \#000000 | ![000000](figures/000000.png) | +| blanchedalmond | \#ffebcd | ![blanchedalmond](figures/blanchedalmond.png) | +| blue | \#0000ff | ![blue](figures/blue.png) | +| blueviolet | \#8a2be2 | ![blueviolet](figures/blueviolet.png) | +| brown | \#a52a2a | ![brown](figures/brown.png) | +| burlywood | \#deB887 | ![burlywood](figures/burlywood.png) | +| cadetblue | \#5f9ea0 | ![cadetblue](figures/cadetblue.png) | +| chartreuse | \#7fff00 | ![chartreuse](figures/chartreuse.png) | +| chocolate | \#d2691e | ![chocolate](figures/chocolate.png) | +| coral | \#ff7f50 | ![coral](figures/coral.png) | +| cornflowerblue | \#6495ed | ![cornflowerblue](figures/cornflowerblue.png) | +| cornsilk | \#fff8dc | ![cornsilk](figures/cornsilk.png) | +| crimson | \#dc143c | ![crimson](figures/crimson.png) | +| cyan | \#00ffff | ![cyan](figures/cyan.png) | +| darkblue | \#00008b | ![darkblue](figures/darkblue.png) | +| darkcyan | \#008b8b | ![darkcyan](figures/darkcyan.png) | +| darkgoldenrod | \#b8860b | ![darkgoldenrod](figures/darkgoldenrod.png) | +| darkgray | \#a9a9a9 | ![darkgray](figures/darkgray.png) | +| darkgreen | \#006400 | ![darkgreen](figures/darkgreen.png) | +| darkgrey | \#a9a9a9 | ![darkgrey](figures/darkgrey.png) | +| darkkhaki | \#bdb76b | ![darkkhaki](figures/darkkhaki.png) | +| darkmagenta | \#8b008b | ![darkmagenta](figures/darkmagenta.png) | +| darkolivegreen | \#556b2f | ![darkolivegreen](figures/darkolivegreen.png) | +| darkorange | \#ff8c00 | ![darkorange](figures/darkorange.png) | +| darkorchid | \#9932cc | ![darkorchid](figures/darkorchid.png) | +| darkred | \#8b0000 | ![darkred](figures/darkred.png) | +| darksalmon | \#e9967a | ![darksalmon](figures/darksalmon.png) | +| darkseagreen | \#8fbc8f | ![darkseagreen](figures/darkseagreen.png) | +| darkslateblue | \#483d8b | ![darkslateblue](figures/darkslateblue.png) | +| darkslategray | \#2f4f4f | ![darkslategray](figures/darkslategray.png) | +| darkslategrey | \#2f4f4f | ![darkslategrey](figures/darkslategrey.png) | +| darkturquoise | \#00ced1 | ![darkturquoise](figures/darkturquoise.png) | +| darkviolet | \#9400d3 | ![darkviolet](figures/darkviolet.png) | +| deeppink | \#ff1493 | ![deeppink](figures/deeppink.png) | +| deepskyblue | \#00bfff | ![deepskyblue](figures/deepskyblue.png) | +| dimgray | \#696969 | ![dimgray](figures/dimgray.png) | +| dimgrey | \#696969 | ![dimgrey](figures/dimgrey.png) | +| dodgerblue | \#1e90ff | ![dodgerblue](figures/dodgerblue.png) | +| firebrick | \#b22222 | ![firebrick](figures/firebrick.png) | +| floralwhite | \#fffaf0 | ![floralwhite](figures/floralwhite.png) | +| forestgreen | \#228b22 | ![forestgreen](figures/forestgreen.png) | +| fuchsia | \#ff00ff | ![fuchsia](figures/fuchsia.png) | +| gainsboro | \#dcdcdc | ![gainsboro](figures/gainsboro.png) | +| ghostwhite | \#f8f8ff | ![ghostwhite](figures/ghostwhite.png) | +| gold | \#ffd700 | ![gold](figures/gold.png) | +| goldenrod | \#daa520 | ![goldenrod](figures/goldenrod.png) | +| gray | \#808080 | ![gray](figures/gray.png) | +| green | \#008000 | ![green](figures/green.png) | +| greenyellow | \#adff2f | ![greenyellow](figures/greenyellow.png) | +| grey | \#808080 | ![grey](figures/grey.png) | +| honeydew | \#f0fff0 | ![honeydew](figures/honeydew.png) | +| hotpink | \#ff69b4 | ![hotpink](figures/hotpink.png) | +| indianred | \#cd5c5c | ![indianred](figures/indianred.png) | +| indigo | \#4b0082 | ![indigo](figures/indigo.png) | +| ivory | \#fffff0 | ![ivory](figures/ivory.png) | +| khaki | \#f0e68c | ![khaki](figures/khaki.png) | +| lavender | \#e6e6fa | ![lavender](figures/lavender.png) | +| lavenderblush | \#fff0f5 | ![lavenderblush](figures/lavenderblush.png) | +| lawngreen | \#7cfc00 | ![lawngreen](figures/lawngreen.png) | +| lemonchiffon | \#fffacd | ![lemonchiffon](figures/lemonchiffon.png) | +| lightblue | \#add8e6 | ![lightblue](figures/lightblue.png) | +| lightcoral | \#f08080 | ![lightcoral](figures/lightcoral.png) | +| lightcyan | \#e0ffff | ![lightcyan](figures/lightcyan.png) | | lightgoldenrodyellow | \#fafad2 | ![lightgoldenrodyellow](figures/lightgoldenrodyellow.png) | -| lightgray | \#d3d3d3 | ![lightgray](figures/lightgray.png) | -| lightgreen | \#90ee90 | ![lightgreen](figures/lightgreen.png) | -| lightpink | \#ffb6c1 | ![lightpink](figures/lightpink.png) | -| lightsalmon | \#ffa07a | ![lightsalmon](figures/lightsalmon.png) | -| lightseagreen | \#20b2aa | ![lightseagreen](figures/lightseagreen.png) | -| lightskyblue | \#87cefa | ![lightskyblue](figures/lightskyblue.png) | -| lightslategray | \#778899 | ![lightslategray](figures/lightslategray.png) | -| lightslategrey | \#778899 | ![lightslategrey](figures/lightslategrey.png) | -| lightsteelblue | \#b0c4de | ![lightsteelblue](figures/lightsteelblue.png) | -| lightyellow | \#ffffe0 | ![lightyellow](figures/lightyellow.png) | -| lime | \#00ff00 | ![lime](figures/lime.png) | -| limegreen | \#32cd32 | ![limegreen](figures/limegreen.png) | -| linen | \#faf0e6 | ![linen](figures/linen.png) | -| magenta | \#ff00ff | ![magenta](figures/magenta.png) | -| maroon | \#800000 | ![maroon](figures/maroon.png) | -| mediumaquamarine | \#66cdaa | ![mediumaquamarine](figures/mediumaquamarine.png) | -| mediumblue | \#0000cd | ![mediumblue](figures/mediumblue.png) | -| mediumorchid | \#ba55d3 | ![mediumorchid](figures/mediumorchid.png) | -| mediumpurple | \#9370db | ![mediumpurple](figures/mediumpurple.png) | -| mediumseagreen | \#3cb371 | ![mediumseagreen](figures/mediumseagreen.png) | -| mediumslateblue | \#7b68ee | ![mediumslateblue](figures/mediumslateblue.png) | -| mediumspringgreen | \#00fa9a | ![mediumspringgreen](figures/mediumspringgreen.png) | -| mediumturquoise | \#48d1cc | ![mediumturquoise](figures/mediumturquoise.png) | -| mediumvioletred | \#c71585 | ![mediumvioletred](figures/mediumvioletred.png) | -| midnightblue | \#191970 | ![midnightblue](figures/midnightblue.png) | -| mintcream | \#f5fffa | ![mintcream](figures/mintcream.png) | -| mistyrose | \#ffe4e1 | ![mistyrose](figures/mistyrose.png) | -| moccasin | \#ffe4b5 | ![moccasin](figures/moccasin.png) | -| navajowhite | \#ffdead | ![navajowhite](figures/navajowhite.png) | -| navy | \#000080 | ![navy](figures/navy.png) | -| oldlace | \#fdf5e6 | ![oldlace](figures/oldlace.png) | -| olive | \#808000 | ![olive](figures/olive.png) | -| olivedrab | \#6b8e23 | ![olivedrab](figures/olivedrab.png) | -| orange | \#ffa500 | ![orange](figures/orange.png) | -| orangered | \#ff4500 | ![orangered](figures/orangered.png) | -| orchid | \#da70d6 | ![orchid](figures/orchid.png) | -| palegoldenrod | \#eee8aa | ![palegoldenrod](figures/palegoldenrod.png) | -| palegreen | \#98fb98 | ![palegreen](figures/palegreen.png) | -| paleturquoise | \#afeeee | ![paleturquoise](figures/paleturquoise.png) | -| palevioletred | \#db7093 | ![palevioletred](figures/palevioletred.png) | -| papayawhip | \#ffefd5 | ![papayawhip](figures/papayawhip.png) | -| peachpuff | \#ffdab9 | ![peachpuff](figures/peachpuff.png) | -| peru | \#cd853f | ![peru](figures/peru.png) | -| pink | \#ffc0cb | ![pink](figures/pink.png) | -| plum | \#dda0dd | ![plum](figures/plum.png) | -| powderblue | \#b0e0e6 | ![powderblue](figures/powderblue.png) | -| purple | \#800080 | ![purple](figures/purple.png) | -| rebeccapurple | \#663399 | ![rebeccapurple](figures/rebeccapurple.png) | -| red | \#ff0000 | ![red](figures/red.png) | -| rosybrown | \#bc8f8f | ![rosybrown](figures/rosybrown.png) | -| royalblue | \#4169e1 | ![royalblue](figures/royalblue.png) | -| saddlebrown | \#8b4513 | ![saddlebrown](figures/saddlebrown.png) | -| salmon | \#fa8072 | ![salmon](figures/salmon.png) | -| sandybrown | \#f4a460 | ![sandybrown](figures/sandybrown.png) | -| seagreen | \#2e8b57 | ![seagreen](figures/seagreen.png) | -| seashell | \#fff5ee | ![seashell](figures/seashell.png) | -| sienna | \#a0522d | ![sienna](figures/sienna.png) | -| silver | \#c0c0c0 | ![silver](figures/silver.png) | -| skyblue | \#87ceeb | ![skyblue](figures/skyblue.png) | -| slateblue | \#6a5acd | ![slateblue](figures/slateblue.png) | -| slategray | \#708090 | ![slategray](figures/slategray.png) | -| slategrey | \#708090 | ![slategray](figures/slategray.png) | -| snow | \#fffafa | ![snow](figures/snow.png) | -| springgreen | \#00ff7f | ![springgreen](figures/springgreen.png) | -| steelblue | \#4682b4 | ![steelblue](figures/steelblue.png) | -| tan | \#d2b48c | ![tan](figures/tan.png) | -| teal | \#008080 | ![teal](figures/teal.png) | -| thistle | \#d8Bfd8 | ![thistle](figures/thistle.png) | -| tomato | \#ff6347 | ![tomato](figures/tomato.png) | -| turquoise | \#40e0d0 | ![turquoise](figures/turquoise.png) | -| violet | \#ee82ee | ![violet](figures/violet.png) | -| wheat | \#f5deb3 | ![wheat](figures/wheat.png) | -| white | \#ffffff | ![white](figures/white.png) | -| whitesmoke | \#f5f5f5 | ![whitesmoke](figures/whitesmoke.png) | -| yellow | \#ffff00 | ![yellow](figures/yellow.png) | -| yellowgreen | \#9acd32 | ![yellowgreen](figures/yellowgreen.png) | +| lightgray | \#d3d3d3 | ![lightgray](figures/lightgray.png) | +| lightgreen | \#90ee90 | ![lightgreen](figures/lightgreen.png) | +| lightpink | \#ffb6c1 | ![lightpink](figures/lightpink.png) | +| lightsalmon | \#ffa07a | ![lightsalmon](figures/lightsalmon.png) | +| lightseagreen | \#20b2aa | ![lightseagreen](figures/lightseagreen.png) | +| lightskyblue | \#87cefa | ![lightskyblue](figures/lightskyblue.png) | +| lightslategray | \#778899 | ![lightslategray](figures/lightslategray.png) | +| lightslategrey | \#778899 | ![lightslategrey](figures/lightslategrey.png) | +| lightsteelblue | \#b0c4de | ![lightsteelblue](figures/lightsteelblue.png) | +| lightyellow | \#ffffe0 | ![lightyellow](figures/lightyellow.png) | +| lime | \#00ff00 | ![lime](figures/lime.png) | +| limegreen | \#32cd32 | ![limegreen](figures/limegreen.png) | +| linen | \#faf0e6 | ![linen](figures/linen.png) | +| magenta | \#ff00ff | ![magenta](figures/magenta.png) | +| maroon | \#800000 | ![maroon](figures/maroon.png) | +| mediumaquamarine | \#66cdaa | ![mediumaquamarine](figures/mediumaquamarine.png) | +| mediumblue | \#0000cd | ![mediumblue](figures/mediumblue.png) | +| mediumorchid | \#ba55d3 | ![mediumorchid](figures/mediumorchid.png) | +| mediumpurple | \#9370db | ![mediumpurple](figures/mediumpurple.png) | +| mediumseagreen | \#3cb371 | ![mediumseagreen](figures/mediumseagreen.png) | +| mediumslateblue | \#7b68ee | ![mediumslateblue](figures/mediumslateblue.png) | +| mediumspringgreen | \#00fa9a | ![mediumspringgreen](figures/mediumspringgreen.png) | +| mediumturquoise | \#48d1cc | ![mediumturquoise](figures/mediumturquoise.png) | +| mediumvioletred | \#c71585 | ![mediumvioletred](figures/mediumvioletred.png) | +| midnightblue | \#191970 | ![midnightblue](figures/midnightblue.png) | +| mintcream | \#f5fffa | ![mintcream](figures/mintcream.png) | +| mistyrose | \#ffe4e1 | ![mistyrose](figures/mistyrose.png) | +| moccasin | \#ffe4b5 | ![moccasin](figures/moccasin.png) | +| navajowhite | \#ffdead | ![navajowhite](figures/navajowhite.png) | +| navy | \#000080 | ![navy](figures/navy.png) | +| oldlace | \#fdf5e6 | ![oldlace](figures/oldlace.png) | +| olive | \#808000 | ![olive](figures/olive.png) | +| olivedrab | \#6b8e23 | ![olivedrab](figures/olivedrab.png) | +| orange | \#ffa500 | ![orange](figures/orange.png) | +| orangered | \#ff4500 | ![orangered](figures/orangered.png) | +| orchid | \#da70d6 | ![orchid](figures/orchid.png) | +| palegoldenrod | \#eee8aa | ![palegoldenrod](figures/palegoldenrod.png) | +| palegreen | \#98fb98 | ![palegreen](figures/palegreen.png) | +| paleturquoise | \#afeeee | ![paleturquoise](figures/paleturquoise.png) | +| palevioletred | \#db7093 | ![palevioletred](figures/palevioletred.png) | +| papayawhip | \#ffefd5 | ![papayawhip](figures/papayawhip.png) | +| peachpuff | \#ffdab9 | ![peachpuff](figures/peachpuff.png) | +| peru | \#cd853f | ![peru](figures/peru.png) | +| pink | \#ffc0cb | ![pink](figures/pink.png) | +| plum | \#dda0dd | ![plum](figures/plum.png) | +| powderblue | \#b0e0e6 | ![powderblue](figures/powderblue.png) | +| purple | \#800080 | ![purple](figures/purple.png) | +| rebeccapurple | \#663399 | ![rebeccapurple](figures/rebeccapurple.png) | +| red | \#ff0000 | ![red](figures/red.png) | +| rosybrown | \#bc8f8f | ![rosybrown](figures/rosybrown.png) | +| royalblue | \#4169e1 | ![royalblue](figures/royalblue.png) | +| saddlebrown | \#8b4513 | ![saddlebrown](figures/saddlebrown.png) | +| salmon | \#fa8072 | ![salmon](figures/salmon.png) | +| sandybrown | \#f4a460 | ![sandybrown](figures/sandybrown.png) | +| seagreen | \#2e8b57 | ![seagreen](figures/seagreen.png) | +| seashell | \#fff5ee | ![seashell](figures/seashell.png) | +| sienna | \#a0522d | ![sienna](figures/sienna.png) | +| silver | \#c0c0c0 | ![silver](figures/silver.png) | +| skyblue | \#87ceeb | ![skyblue](figures/skyblue.png) | +| slateblue | \#6a5acd | ![slateblue](figures/slateblue.png) | +| slategray | \#708090 | ![slategray](figures/slategray.png) | +| slategrey | \#708090 | ![slategray](figures/slategray.png) | +| snow | \#fffafa | ![snow](figures/snow.png) | +| springgreen | \#00ff7f | ![springgreen](figures/springgreen.png) | +| steelblue | \#4682b4 | ![steelblue](figures/steelblue.png) | +| tan | \#d2b48c | ![tan](figures/tan.png) | +| teal | \#008080 | ![teal](figures/teal.png) | +| thistle | \#d8Bfd8 | ![thistle](figures/thistle.png) | +| tomato | \#ff6347 | ![tomato](figures/tomato.png) | +| turquoise | \#40e0d0 | ![turquoise](figures/turquoise.png) | +| violet | \#ee82ee | ![violet](figures/violet.png) | +| wheat | \#f5deb3 | ![wheat](figures/wheat.png) | +| white | \#ffffff | ![white](figures/white.png) | +| whitesmoke | \#f5f5f5 | ![whitesmoke](figures/whitesmoke.png) | +| yellow | \#ffff00 | ![yellow](figures/yellow.png) | +| yellowgreen | \#9acd32 | ![yellowgreen](figures/yellowgreen.png) | diff --git a/en/application-dev/reference/arkui-js-lite/js-components-basic-chart.md b/en/application-dev/reference/arkui-js-lite/js-components-basic-chart.md index 7a0a07fe1bee64329c6fe292f881856b941e6ee1..2c8f4c0550f7794d975eb7014e30506c034e9a1d 100644 --- a/en/application-dev/reference/arkui-js-lite/js-components-basic-chart.md +++ b/en/application-dev/reference/arkui-js-lite/js-components-basic-chart.md @@ -14,118 +14,118 @@ Not supported ## Attributes -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | No| Chart type. Dynamic modification is not supported. Available values include:
- **bar**: bar chart
- **line**: line chart
Default value: **line**| -| options | ChartOptions | Yes| Chart parameters. You can set the minimum value, maximum value, scale, and line width of the x-axis or y-axis, whether to display the x-axis and y-axis, and whether the line is smooth. Dynamic modification is not supported.| -| datasets | Array<ChartDataset> | Yes| Data sets. You can set multiple datasets and their background colors.| -| id | string | No| Unique ID of the component.| -| style | string | No| Style declaration of the component.| -| class | string | No| Style class of the component, which is used to refer to a style table.| -| ref | string | No| Reference information of child elements, which is registered with the parent component on **$refs**.| +| Name | Type | Mandatory | Description | +| -------- | ------------------------- | ---- | ---------------------------------------- | +| type | string | No | Chart type. Dynamic modification is not supported. Available values include:
- **bar**: bar chart
- **line**: line chart
Default value: **line**| +| options | ChartOptions | Yes | Chart parameters. You can set the minimum value, maximum value, scale, and line width of the x-axis or y-axis, whether to display the x-axis and y-axis, and whether the line is smooth. Dynamic modification is not supported.| +| datasets | Array<ChartDataset> | Yes | Data sets. You can set multiple datasets and their background colors. | +| id | string | No | Unique ID of the component. | +| style | string | No | Style declaration of the component. | +| class | string | No | Style class of the component, which is used to refer to a style table. | +| ref | string | No | Reference information of child elements, which is registered with the parent component on **$refs**.| **Table 1** ChartOptions -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| xAxis | ChartAxis | Yes| X-axis parameters. You can set the minimum value, maximum value, and scale of the x-axis, and whether to display the x-axis.| -| yAxis | ChartAxis | Yes| Y-axis parameters. You can set the minimum value, maximum value, and scale of the y-axis, and whether to display the y-axis.| -| series | ChartSeries | No| Data series parameters which cover the following:
- Line style, such as the line width and whether the line is smooth.
- Style and size of the white point at the start of the line.
**NOTE**
Only line charts support this attribute. | +| Name | Type | Mandatory | Description | +| ------ | ----------- | ---- | ---------------------------------------- | +| xAxis | ChartAxis | Yes | X-axis parameters. You can set the minimum value, maximum value, and scale of the x-axis, and whether to display the x-axis. | +| yAxis | ChartAxis | Yes | Y-axis parameters. You can set the minimum value, maximum value, and scale of the y-axis, and whether to display the y-axis. | +| series | ChartSeries | No | Data series parameters which cover the following:
- Line style, such as the line width and whether the line is smooth.
- Style and size of the white point at the start of the line.
**NOTE**
Only line charts support this attribute.| **Table 2** ChartDataset -| Name| Type| Default Value| Mandatory| Description| -| -------- | -------- | -------- | -------- | -------- | -| backgroundColor(deprecated) | <color> | \#ff6384 | No| Color of a line or bar. This attribute is not recommended.| -| strokeColor | <color> | \#ff6384 | No| Line color. Only line charts support this attribute.| -| fillColor | <color> | \#ff6384 | No| Fill color. For line charts, the value indicates the gradient color to fill.| -| data | Array<number> | - | Yes| Data of the drawn line or bar.| -| gradient | boolean | false | No| Whether to display the gradient color. Only line charts support this attribute.| +| Name | Type | Default Value | Mandatory | Description | +| --------------------------- | ------------------- | -------- | ---- | -------------------- | +| backgroundColor(deprecated) | <color> | \#ff6384 | No | Color of a line or bar. This attribute is not recommended. | +| strokeColor | <color> | \#ff6384 | No | Line color. Only line charts support this attribute. | +| fillColor | <color> | \#ff6384 | No | Fill color. For line charts, the value indicates the gradient color to fill. | +| data | Array<number> | - | Yes | Data of the drawn line or bar. | +| gradient | boolean | false | No | Whether to display the gradient color. Only line charts support this attribute.| **Table 3** ChartAxis -| Name| Type| Default Value| Mandatory| Description| -| -------- | -------- | -------- | -------- | -------- | -| min | number | 0 | No| Minimum value of the axis.
Negative numbers are not supported. Only line charts support this attribute.| -| max | number | 100 | No| Maximum value of the axis.
Negative numbers are not supported. Only line charts support this attribute.| -| axisTick | number | 10 | No| Number of scales displayed on the axis.
**NOTE**
The value ranges from 1 to 20. The display effect depends on the calculation result of Number of pixels occupied by the image width/(**max**-**min**).
Lite wearables support integer calculation, and an error may occur in the case of inexhaustible division. Specifically, a segment of space may be left at the end of the x-axis.
In the bar chart, the number of bars in each group of data is the same as the number of scales, and the bars are displayed at the scales.| -| display | boolean | false | No| Whether to display the axis.| -| color | <color> | \#c0c0c0 | No| Axis color.| +| Name | Type | Default Value | Mandatory | Description | +| -------- | ------------- | -------- | ---- | ---------------------------------------- | +| min | number | 0 | No | Minimum value of the axis.
Negative numbers are not supported. Only line charts support this attribute. | +| max | number | 100 | No | Maximum value of the axis.
Negative numbers are not supported. Only line charts support this attribute. | +| axisTick | number | 10 | No | Number of scales displayed on the axis.
**NOTE**
The value ranges from 1 to 20. The display effect depends on the calculation result of Number of pixels occupied by the image width/(**max**-**min**).
Lite wearables support integer calculation, and an error may occur in the case of inexhaustible division. Specifically, a segment of space may be left at the end of the x-axis.
In the bar chart, the number of bars in each group of data is the same as the number of scales, and the bars are displayed at the scales.| +| display | boolean | false | No | Whether to display the axis. | +| color | <color> | \#c0c0c0 | No | Axis color. | **Table 4** ChartSeries -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| lineStyle | ChartLineStyle | No| Line style, such as the line width and whether the line is smooth.| -| headPoint | PointStyle | No| Style and size of the white point at the start of the line.| -| topPoint | PointStyle | No| Style and size of the top point.| -| bottomPoint | PointStyle | No| Style and size of the bottom point.| -| loop | ChartLoop | No| Whether to start drawing again when the screen is looped.| +| Name | Type | Mandatory | Description | +| ----------- | -------------- | ---- | -------------------- | +| lineStyle | ChartLineStyle | No | Line style, such as the line width and whether the line is smooth. | +| headPoint | PointStyle | No | Style and size of the white point at the start of the line. | +| topPoint | PointStyle | No | Style and size of the top point. | +| bottomPoint | PointStyle | No | Style and size of the bottom point. | +| loop | ChartLoop | No | Whether to start drawing again when the screen is looped.| **Table 5** ChartLineStyle -| Name| Type| Default Value| Mandatory| Description| -| -------- | -------- | -------- | -------- | -------- | -| width | <length> | 1px | No| Line width.| -| smooth | boolean | false | No| Whether the line is smooth.| +| Name | Type | Default Value | Mandatory | Description | +| ------ | -------------- | ----- | ---- | ----- | +| width | <length> | 1px | No | Line width.| +| smooth | boolean | false | No | Whether the line is smooth.| **Table 6** PointStyle -| Name| Type| Default Value| Mandatory| Description| -| -------- | -------- | -------- | -------- | -------- | -| shape | string | circle | No| Shape of the highlight point. Available values are as follows:
- circle| -| size | <length> | 5px | No| Size of the highlight point.| -| strokeWidth | <length> | 1px | No| Stroke width.| -| strokeColor | <color> | \#ff0000 | No| Stroke color.| -| fillColor | <color> | \#ff0000 | No| Fill color.| -| display | boolean | true | No| Whether to display the highlight spot.| +| Name | Type | Default Value | Mandatory | Description | +| ----------- | -------------- | -------- | ---- | ---------------------------------- | +| shape | string | circle | No | Shape of the highlight point. Available values are as follows:
- circle| +| size | <length> | 5px | No | Size of the highlight point. | +| strokeWidth | <length> | 1px | No | Stroke width. | +| strokeColor | <color> | \#ff0000 | No | Stroke color. | +| fillColor | <color> | \#ff0000 | No | Fill color. | +| display | boolean | true | No | Whether to display the highlight spot. | **Table 7** ChartLoop -| Name| Type| Default Value| Mandatory| Description| -| -------- | -------- | -------- | -------- | -------- | -| margin | <length> | 1 | No| Number of erased points (horizontal distance between the latest drawn point and the earliest point). You are not advised to use **margin** together with **topPoint**, **bottomPoint**, or **headPoint** for mini-, small- and standard-system devices. If you do so, there is a possibility that the point is in the erase area and invisible.| +| Name | Type | Default Value | Mandatory | Description | +| ------ | -------------- | ---- | ---- | ---------------------------------------- | +| margin | <length> | 1 | No | Number of erased points (horizontal distance between the latest drawn point and the earliest point). You are not advised to use **margin** together with **topPoint**, **bottomPoint**, or **headPoint** for mini-, small- and standard-system devices. If you do so, there is a possibility that the point is in the erase area and invisible.| ## Methods -| Methods| Parameter| Description| -| -------- | -------- | -------- | +| Methods | Parameter | Description | +| ------ | ---------------------------------------- | ---------------------------------------- | | append | {
serial: number, // Set the data subscript of the line chart to be updated.
data: Array<number>, // Set the new data.
} | Dynamically add data to an existing data series. The target series is specified based on **serial**, which is the subscript of the datasets array and starts from 0. **datasets[index].data** is not updated. Only line charts support this attribute. The value is incremented by 1 based on the horizontal coordinate and is related to the **xAxis min/max** setting.| ## Events -| Name| Parameter| Description| -| -------- | -------- | -------- | -| click | - | Triggered when the component is clicked. | -| longpress | - | Triggered when the component is long pressed. | -| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component. | +| Name | Parameter | Description | +| ------------------ | --------------------------------- | ----------- | +| click | - | Triggered when the component is clicked. | +| longpress | - | Triggered when the component is long pressed. | +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component.| ## Styles -| Name| Type| Default Value| Mandatory| Description| -| -------- | -------- | -------- | -------- | -------- | -| width | <length> \| <percentage>5+ | - | No| Component width.
If this attribute is not set, the default value **0** is used. | -| height | <length> \| <percentage>5+ | - | No| Component height.
If this attribute is not set, the default value **0** is used. | -| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| -| padding-[left\|top\|right\|bottom] | <length> | 0 | No| Left, top, right, and bottom padding.| -| margin | <length> \| <percentage>5+ | 0 | No| Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| -| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No| Left, top, right, and bottom margins.| -| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| -| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| -| border-radius | <length> | - | No| Radius of round-corner borders. | -| background-color | <color> | - | No| Background color.| -| display | string | flex | No| How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| -| [left\|top] | <length> \| <percentage>6+ | - | No| Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element. | +| Name | Type | Default Value | Mandatory | Description | +| ---------------------------------- | ---------------------------------------- | ----- | ---- | ---------------------------------------- | +| width | <length> \| <percentage>5+ | - | No | Component width.

If this attribute is not set, the default value **0** is used. | +| height | <length> \| <percentage>5+ | - | No | Component height.

If this attribute is not set, the default value **0** is used. | +| padding | <length> | 0 | No | Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No | Left, top, right, and bottom padding. | +| margin | <length> \| <percentage>5+ | 0 | No | Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No | Left, top, right, and bottom margins. | +| border-width | <length> | 0 | No | Shorthand attribute to set the margin for all sides. | +| border-color | <color> | black | No | Shorthand attribute to set the color for all borders. | +| border-radius | <length> | - | No | Radius of round-corner borders. | +| background-color | <color> | - | No | Background color. | +| display | string | flex | No | How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No | Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element.| ## Example 1. Line chart - + ```html
@@ -134,7 +134,7 @@ Not supported
``` - + ```css /* xxx.css */ .container { @@ -155,7 +155,7 @@ Not supported } ``` - + ```js // xxx.js export default { @@ -211,7 +211,7 @@ Not supported ![lite_line](figures/lite_line.PNG) 2. Bar chart - + ```html
@@ -219,7 +219,7 @@ Not supported
``` - + ```css /* xxx.css */ .container { @@ -236,7 +236,7 @@ Not supported } ``` - + ```js // xxx.js export default { diff --git a/en/application-dev/reference/arkui-js-lite/js-components-basic-image-animator.md b/en/application-dev/reference/arkui-js-lite/js-components-basic-image-animator.md index 97383611f9b1228304aa47ebe97a5d0610f18ee8..226eff9f6c284140b5c671d2135dbe212b609590 100644 --- a/en/application-dev/reference/arkui-js-lite/js-components-basic-image-animator.md +++ b/en/application-dev/reference/arkui-js-lite/js-components-basic-image-animator.md @@ -14,68 +14,68 @@ Not supported ## Attributes -| Name| Type| Default Value| Mandatory| Description| -| -------- | -------- | -------- | -------- | -------- | -| images | Array<ImageFrame> | - | Yes| Image frame information. The frame information includes the image path, size, and location. The supported image formats include PNG, JPG, and BMP. For details about **ImageFrame**, see Table 1.
**NOTE**
Use data binding, for example, **images = {{images}}**, to specify the image. Declare the corresponding variable in the JavaScript: **images: [{src: "/common/heart-rate01.png"}, {src: "/common/heart-rate02.png"}]**. | -| iteration | number \| string | infinite | No| Number of times that the frame animation is played. **number** indicates a fixed number of playback operations, and **infinite** indicates an unlimited number of playback operations.| -| reverse | boolean | false | No| Playback sequence.
- **true**: Images are played from the last one to the first one.
- **false**: Images are played from the first one to the last one. | -| fixedsize | boolean | true | No| Whether the image size is the same as the component size.
- **true**: The image size is the same as the component size. In this case, the width, height, top, and left attributes of the image are invalid.
- **false**: The image size is different from the component size. In this case, the width, height, top, and left attributes of each image must be set separately. | -| duration | string | - | Yes| Single video playback duration, in seconds (s) or milliseconds (ms). The default unit is ms. If the value is **0**, no image is played. The value change takes effect only at the start of the next cycle. | -| fillmode5+ | string | forwards | No| Status of the frame animation after its playback is complete. Available values are as follows:
- **none**: restores to the initial status.
- **forwards**: retains the ending status defined for the last key frame.| -| id | string | - | No| Unique ID of the component.| -| style | string | - | No| Style declaration of the component.| -| class | string | - | No| Style class of the component, which is used to refer to a style table.| -| ref | string | - | No| Reference information of child elements, which is registered with the parent component on **$refs**.| +| Name | Type | Default Value | Mandatory | Description | +| --------------------- | -------------------------- | -------- | ---- | ---------------------------------------- | +| images | Array<ImageFrame> | - | Yes | Image frame information. The frame information includes the image path, size, and location. The supported image formats include PNG, JPG, and BMP. For details about **ImageFrame**, see Table 1.
**NOTE**
Use data binding, for example, **images = {{images}}**, to specify the image. Declare the corresponding variable in the JavaScript: **images: [{src: "/common/heart-rate01.png"}, {src: "/common/heart-rate02.png"}]**.| +| iteration | number \| string | infinite | No | Number of times that the frame animation is played. **number** indicates a fixed number of playback operations, and **infinite** indicates an unlimited number of playback operations.| +| reverse | boolean | false | No | Playback sequence.
- **true**: Images are played from the last one to the first one.
- **false**: Images are played from the first one to the last one.| +| fixedsize | boolean | true | No | Whether the image size is the same as the component size.
- **true**: The image size is the same as the component size. In this case, the width, height, top, and left attributes of the image are invalid.
- **false**: The image size is different from the component size. In this case, the width, height, top, and left attributes of each image must be set separately.| +| duration | string | - | Yes | Single video playback duration, in seconds (s) or milliseconds (ms). The default unit is ms. If the value is **0**, no image is played. The value change takes effect only at the start of the next cycle.| +| fillmode5+ | string | forwards | No | Status of the frame animation after its playback is complete. Available values are as follows:
- **none**: restores to the initial status.
- **forwards**: retains the ending status defined for the last key frame.| +| id | string | - | No | Unique ID of the component. | +| style | string | - | No | Style declaration of the component. | +| class | string | - | No | Style class of the component, which is used to refer to a style table. | +| ref | string | - | No | Reference information of child elements, which is registered with the parent component on **$refs**.| **Table 1** ImageFrame -| Name| Type| Default Value| Mandatory| Description| -| -------- | -------- | -------- | -------- | -------- | -| src | <uri> | - | Yes| Image path.| -| width | <length> | 0 | No| Image width.| -| height | <length> | 0 | No| Image height.| -| top | <length> | 0 | No| Vertical coordinate of the image relative to the upper left corner of the component.| -| left | <length> | 0 | No| Horizontal coordinate of the image relative to the upper left corner of the component.| +| Name | Type | Default Value | Mandatory | Description | +| ------ | -------------- | ---- | ---- | ---------------- | +| src | <uri> | - | Yes | Image path. | +| width | <length> | 0 | No | Image width. | +| height | <length> | 0 | No | Image height. | +| top | <length> | 0 | No | Vertical coordinate of the image relative to the upper left corner of the component.| +| left | <length> | 0 | No | Horizontal coordinate of the image relative to the upper left corner of the component.| ## Events -| Name| Parameter| Description| -| -------- | -------- | -------- | -| stop | - | Triggered when the frame animation stops| -| click | - | Triggered when the component is clicked. | -| longpress | - | Triggered when the component is long pressed. | -| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component. | +| Name | Parameter | Description | +| ------------------ | --------------------------------- | ----------- | +| stop | - | Triggered when the frame animation stops | +| click | - | Triggered when the component is clicked. | +| longpress | - | Triggered when the component is long pressed. | +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component.| ## Styles -| Name| Type| Default Value| Mandatory| Description| -| -------- | -------- | -------- | -------- | -------- | -| width | <length> \| <percentage>5+ | - | No| Component width.

If this attribute is not set, the default value **0** is used.| -| height | <length> \| <percentage>5+ | - | No| Component height.

If this attribute is not set, the default value **0** is used.| -| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| -| padding-[left\|top\|right\|bottom] | <length> | 0 | No| Left, top, right, and bottom padding.| -| margin | <length> \| <percentage>5+ | 0 | No| Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| -| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No| Left, top, right, and bottom margins.| -| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| -| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| -| border-radius | <length> | - | No| Radius of round-corner borders.| -| background-color | <color> | - | No| Background color.| -| opacity5+ | number | 1 | No| Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent.| -| display | string | flex | No| How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| -| [left\|top] | <length> \| <percentage>6+ | - | No| left\|Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element.| +| Name | Type | Default Value | Mandatory | Description | +| ---------------------------------- | ---------------------------------------- | ----- | ---- | ---------------------------------------- | +| width | <length> \| <percentage>5+ | - | No | Component width.

If this attribute is not set, the default value **0** is used. | +| height | <length> \| <percentage>5+ | - | No | Component height.

If this attribute is not set, the default value **0** is used. | +| padding | <length> | 0 | No | Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No | Left, top, right, and bottom padding. | +| margin | <length> \| <percentage>5+ | 0 | No | Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No | Left, top, right, and bottom margins. | +| border-width | <length> | 0 | No | Shorthand attribute to set the margin for all sides. | +| border-color | <color> | black | No | Shorthand attribute to set the color for all borders. | +| border-radius | <length> | - | No | Radius of round-corner borders. | +| background-color | <color> | - | No | Background color. | +| opacity5+ | number | 1 | No | Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent. | +| display | string | flex | No | How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No | left\|Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element.| ## Methods -| Name| Parameter| Description| -| -------- | -------- | -------- | -| start | - | Starts to play the frame animation of an image. If this method is called again, the playback starts from the first frame.| -| pause | - | Pauses the frame animation playback of an image.| -| stop | - | Stops the frame animation playback of an image.| -| resume | - | Resumes the frame animation playback of an image.| -| getState | - | Obtains the playback state. Available values are as follows:
- playing
- paused
- stopped| +| Name | Parameter | Description | +| -------- | ---- | ---------------------------------------- | +| start | - | Starts to play the frame animation of an image. If this method is called again, the playback starts from the first frame. | +| pause | - | Pauses the frame animation playback of an image. | +| stop | - | Stops the frame animation playback of an image. | +| resume | - | Resumes the frame animation playback of an image. | +| getState | - | Obtains the playback state. Available values are as follows:
- playing
- paused
- stopped| ## Example diff --git a/en/application-dev/reference/arkui-js-lite/js-components-basic-slider.md b/en/application-dev/reference/arkui-js-lite/js-components-basic-slider.md index 8e69b18afe816c1691743976bf7ab72c2b124a36..14a1804c4b47d769b5020fb820ac768a3f434316 100644 --- a/en/application-dev/reference/arkui-js-lite/js-components-basic-slider.md +++ b/en/application-dev/reference/arkui-js-lite/js-components-basic-slider.md @@ -14,52 +14,52 @@ Not supported ## Attributes -| Name| Type| Default Value| Mandatory| Description| -| -------- | -------- | -------- | -------- | -------- | -| min | number | 0 | No| Minimum value of the slider.| -| max | number | 100 | No| Maximum value of the slider.| -| value | number | 0 | No| Initial value of the slider.| -| id | string | - | No| Unique ID of the component.| -| style | string | - | No| Style declaration of the component.| -| class | string | - | No| Style class of the component, which is used to refer to a style table.| -| ref | string | - | No| Reference information of child elements, which is registered with the parent component on **$refs**.| +| Name | Type | Default Value | Mandatory | Description | +| ----- | ------ | ---- | ---- | ---------------------------------------- | +| min | number | 0 | No | Minimum value of the slider. | +| max | number | 100 | No | Maximum value of the slider. | +| value | number | 0 | No | Initial value of the slider. | +| id | string | - | No | Unique ID of the component. | +| style | string | - | No | Style declaration of the component. | +| class | string | - | No | Style class of the component, which is used to refer to a style table. | +| ref | string | - | No | Reference information of child elements, which is registered with the parent component on **$refs**.| ## Events -| Name| Parameter| Description| -| -------- | -------- | -------- | -| change | ChangeEvent | Triggered when the value changes.| -| click | - | Triggered when the component is clicked. | -| longpress | - | Triggered when the component is long pressed. | -| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component. | +| Name | Parameter | Description | +| ------------------ | --------------------------------- | -------------- | +| change | ChangeEvent | Triggered when the value changes.| +| click | - | Triggered when the component is clicked. | +| longpress | - | Triggered when the component is long pressed. | +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component. | - **Table 2** ChangeEvent + **Table 1** ChangeEvent -| Attribute| Type| Description| -| -------- | -------- | -------- | +| Attribute | Type | Description | +| ---------------------------------------- | ------ | ------------- | | progress(deprecated5+) | string | Current value of the slider.| -| value5+ | number | Current value of the slider.| +| value5+ | number | Current value of the slider.| ## Styles -| Name| Type| Default Value| Mandatory| Description| -| -------- | -------- | -------- | -------- | -------- | -| color | <color> | \#000000 | No| Background color of the slider.| -| selected-color | <color> | \#ffffff | No| Selected color of the slider.| -| width | <length> \| <percentage>5+ | - | No| Component width.
If this attribute is not set, the default value **0** is used. | -| height | <length> \| <percentage>5+ | - | No| Component height.
If this attribute is not set, the default value **0** is used. | -| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| -| padding-[left\|top\|right\|bottom] | <length> | 0 | No| Left, top, right, and bottom padding.| -| margin | <length> \| <percentage>5+ | 0 | No| Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| -| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No| Left, top, right, and bottom margins.| -| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| -| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| -| border-radius | <length> | - | No| Radius of round-corner borders.| -| background-color | <color> | - | No| Background color.| -| display | string | flex | No| How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| -| [left\|top] | <length> \| <percentage>6+ | - | No| Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element. | +| Name | Type | Default Value | Mandatory | Description | +| ---------------------------------- | ---------------------------------------- | -------- | ---- | ---------------------------------------- | +| color | <color> | \#000000 | No | Background color of the slider. | +| selected-color | <color> | \#ffffff | No | Selected color of the slider. | +| width | <length> \| <percentage>5+ | - | No | Component width.
If this attribute is not set, the default value **0** is used. | +| height | <length> \| <percentage>5+ | - | No | Component height.
If this attribute is not set, the default value **0** is used. | +| padding | <length> | 0 | No | Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No | Left, top, right, and bottom padding. | +| margin | <length> \| <percentage>5+ | 0 | No | Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No | Left, top, right, and bottom margins. | +| border-width | <length> | 0 | No | Shorthand attribute to set the margin for all sides. | +| border-color | <color> | black | No | Shorthand attribute to set the color for all borders. | +| border-radius | <length> | - | No | Radius of round-corner borders. | +| background-color | <color> | - | No | Background color. | +| display | string | flex | No | How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No | Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element.| ## Example diff --git a/en/application-dev/reference/arkui-js-lite/js-components-common-animation.md b/en/application-dev/reference/arkui-js-lite/js-components-common-animation.md index 8533e8dd7830abc31d5bd362ed115b083161fb69..ef2c39dc69ef2779e3e70c8ca61ff713f726e3d9 100644 --- a/en/application-dev/reference/arkui-js-lite/js-components-common-animation.md +++ b/en/application-dev/reference/arkui-js-lite/js-components-common-animation.md @@ -4,44 +4,44 @@ Components support dynamic rotation, translation, and scaling effects. These effects can be set in the **style** attribute or **.css** files. -| Name| Type| Default Value| Description| -| -------- | -------- | -------- | -------- | -| transform | string | - | Translation, rotation, and scaling attributes. For details, see Table 1. | -| animation-name | string | - | @keyframes rule. For details, see Table 2. | -| animation-delay | <time> | 0 | Delay for playing the animation, in ms or s, for example, **1000 ms** or **1s**. The default unit is ms. | -| animation-duration | <time> | 0 | Animation duration, in ms or s, for example, **1000 ms** or **1s**. The default unit is ms.
**NOTE**
**animation-duration** must be specified. Otherwise, the duration is **0**, which means the animation will not be played. | -| animation-iteration-count | number \| infinite | 1 | Number of times that an animation is played. The animation is played once by default. You can set the value to **infinite** to play the animation infinitely.| -| animation-timing-function | string |
linear | Speed curve of an animation, which makes the animation more fluent.
- **linear**: The animation speed keeps unchanged.
- **ease-in**: The animation starts at a low speed. The cubic-bezier curve (0.42, 0.0, 1.0, 1.0) is used
- **ease-out**: The animation ends at a low speed. The cubic-bezier curve (0.0, 0.0, 0.58, 1.0) is used.
- **ease-in-out**: The animation starts and ends at a low speed. The cubic-bezier curve (0.42, 0.0, 0.58, 1.0) is used. | -| animation-fill-mode | string | none | Start and end styles of the animation.
- **none**: No style is applied to the target before or after the animation is executed.
- **forwards**: The target keeps the state at the end of the animation (defined in the last key frame) after the animation is executed.| +| Name | Type | Default Value | Description | +| ------------------------- | ---------------------------------- | ----------- | ---------------------------------------- | +| transform | string | - | Translation, rotation, and scaling attributes. For details, see Table 1. | +| animation-name | string | - | \@keyframes rule. For details, see Table 2. | +| animation-delay | <time> | 0 | Delay for playing the animation, in ms or s, for example, **1000 ms** or **1s**. \|The default unit is ms.| +| animation-duration | <time> | 0 | Animation duration, in ms or s, for example, **1000 ms** or **1s**. \|The default unit is ms.
**NOTE**
**animation-duration** must be specified. Otherwise, the duration is **0**, which means the animation will not be played.| +| animation-iteration-count | number \| infinite | 1 | Number of times that an animation is played. The animation is played once by default. You can set the value to **infinite** to play the animation infinitely. | +| animation-timing-function | string |
linear | Speed curve of an animation, which makes the animation more fluent.
Available values are as follows:
- **linear**: The animation speed keeps unchanged.
- **ease-in**: The animation starts at a low speed. The cubic-bezier curve (0.42, 0.0, 1.0, 1.0) is used
- **ease-out**: The animation ends at a low speed. The cubic-bezier curve (0.0, 0.0, 0.58, 1.0) is used.
- **ease-in-out**: The animation starts and ends at a low speed. The cubic-bezier curve (0.42, 0.0, 0.58, 1.0) is used.| +| animation-fill-mode | string | none | Start and end styles of the animation.
- **none**: No style is applied to the target before or after the animation is executed.
- **forwards**: The target keeps the state at the end of the animation (defined in the last key frame) after the animation is executed.| **Table 1** transform -| Name| Type| Description| -| -------- | -------- | -------- | -| translateX | <length> | Moves an element along the x-axis.| -| translateY | <length> | Moves an element along the y-axis.| -| rotate | <deg> \| <rad> | Rotates an element.| +| Name | Type | Description | +| ---------- | ------------------------------------ | ---------- | +| translateX | <length> | Moves an element along the x-axis.| +| translateY | <length> | Moves an element along the y-axis.| +| rotate | <deg> \| <rad> | Rotates an element. | > **NOTE** > > Only images of the original size can be rotated on lite wearables. - **Table 2** @keyframes + **Table 2** \@keyframes -| Name| Type| Default Value| Description| -| -------- | -------- | -------- | -------- | -| background-color | <color> | - | Background color applied to the component after the animation is played.| -| width | <length> | - | Width value applied to the component after the animation is played.| -| height | <length> | - | Height value applied to the component after the animation is played.| -| transform | string | - | Transformation type applied to a component. For details, see Table 1.| +| Name | Type | Default Value | Description | +| ---------------- | -------------- | ---- | ------------------ | +| background-color | <color> | - | Background color applied to the component after the animation is played. | +| width | <length> | - | Width value applied to the component after the animation is played. | +| height | <length> | - | Height value applied to the component after the animation is played. | +| transform | string | - | Transformation type applied to a component. For details, see Table 1.| If there is no default value for when an animation will start or end, use **from** and **to** to specify the start and end of the display. The following is an example: -``` +```css @keyframes Go { from { diff --git a/en/application-dev/reference/arkui-js-lite/js-components-common-mediaquery.md b/en/application-dev/reference/arkui-js-lite/js-components-common-mediaquery.md index c01a9c145991b2cf4eabc971d718cb8132c9ee97..43a11aa1f7a691186eb436a19383913f0471ffa5 100644 --- a/en/application-dev/reference/arkui-js-lite/js-components-common-mediaquery.md +++ b/en/application-dev/reference/arkui-js-lite/js-components-common-mediaquery.md @@ -45,8 +45,8 @@ You can use media logical operators to implement complex media query. The follow **Table 1** Media logical operators -| Type | Description | -| --------------- | ------------------------------------------------------------ | +| Type | Description | +| --------------- | ---------------------------------------- | | and | The **and** operator is used to combine multiple media features into one media query, in a logical AND operation. The query is valid only when all media features are true. It can also combine media types and media functions.
For example, **screen and (device-type: liteWearable) and (max-height: 454)** evaluates to **true** when the device type is wearable and the maximum height of the application is 454 pixel units.| | or9+ | The **or** operator is used to combine multiple media features into one media query, in a logical OR operation. The query is valid if a media feature is true.
For example, **screen and (max-height: 454) or (round-screen: true)** evaluates to **true** when the maximum height of the application is 454 pixel units or the device screen is round.| @@ -55,18 +55,18 @@ You can use media logical operators to implement complex media query. The follow ## Media Features -| Type | Description | -| ---------------- | ------------------------------------------------------------ | -| height | Height of the display area on the application page. | -| min-height | Minimum height of the display area on the application page. | -| max-height | Maximum height of the display area on the application page. | -| width | Width of the display area on the application page. | -| min-width | Minimum width of the display area on the application page. | -| max-width | Maximum width of the display area on the application page. | +| Type | Description | +| ---------------- | ---------------------------------------- | +| height | Height of the display area on the application page. | +| min-height | Minimum height of the display area on the application page. | +| max-height | Maximum height of the display area on the application page. | +| width | Width of the display area on the application page. | +| min-width | Minimum width of the display area on the application page. | +| max-width | Maximum width of the display area on the application page. | | aspect-ratio | Ratio of the width to the height of the display area on the application page.
Example: **aspect-ratio: 1/2**| | min-aspect-ratio | Minimum ratio of the width to the height of the display area on the application page. | | max-aspect-ratio | Maximum ratio of the width to the height of the display area on the application page. | -| round-screen | Screen type. The value **true** means that the screen is round, and **false** means the opposite. | +| round-screen | Screen type. The value **true** means that the screen is round, and **false** means the opposite.| ## Sample Code for the Common Media Feature diff --git a/en/application-dev/reference/arkui-js-lite/js-components-container-stack.md b/en/application-dev/reference/arkui-js-lite/js-components-container-stack.md index 2ce76b90cf9ad62ad1b95c0e08af46ee79d7d096..c099a46be788de55f5832bc94614c569ba2b0bad 100644 --- a/en/application-dev/reference/arkui-js-lite/js-components-container-stack.md +++ b/en/application-dev/reference/arkui-js-lite/js-components-container-stack.md @@ -9,47 +9,47 @@ The **\** component provides a stack container where child components are ## Child Components -Supported +Supported. ## Attributes -| Name| Type| Default Value| Mandatory| Description| -| -------- | -------- | -------- | -------- | -------- | -| id | string | - | No| Unique ID of the component.| -| style | string | - | No| Style declaration of the component.| -| class | string | - | No| Style class of the component, which is used to refer to a style table.| -| ref | string | - | No| Reference information of child elements, which is registered with the parent component on **$refs**.| +| Name | Type | Default Value | Mandatory | Description | +| ----- | ------ | ---- | ---- | ---------------------------------------- | +| id | string | - | No | Unique ID of the component. | +| style | string | - | No | Style declaration of the component. | +| class | string | - | No | Style class of the component, which is used to refer to a style table. | +| ref | string | - | No | Reference information of child elements, which is registered with the parent component on **$refs**.| ## Events -| Name| Parameter| Description| -| -------- | -------- | -------- | -| click | - | Triggered when the component is clicked.| -| longpress | - | Triggered when the component is long pressed.| +| Name | Parameter | Description | +| ------------------ | --------------------------------- | ----------- | +| click | - | Triggered when the component is clicked. | +| longpress | - | Triggered when the component is long pressed. | | swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component.| ## Styles -| Name| Type| Default Value| Mandatory| Description| -| -------- | -------- | -------- | -------- | -------- | -| width | <length> \| <percentage>5+ | - | No| Component width.
If this attribute is not set, the default value **0** is used. | -| height | <length> \| <percentage>5+ | - | No| Component height.
If this attribute is not set, the default value **0** is used. | -| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| -| padding-[left\|top\|right\|bottom] | <length> | 0 | No| Left, top, right, and bottom padding.| -| margin | <length> \| <percentage>5+ | 0 | No| Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| -| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No| Left, top, right, and bottom margins.| -| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| -| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| -| border-radius | <length> | - | No| Radius of round-corner borders.| -| background-color | <color> | - | No| Background color.| -| opacity5+ | number | 1 | No| Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent.| -| display | string | flex | No| How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| -| [left\|top] | <length> \| <percentage>6+ | - | No| Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element. | - -> **NOTE** +| Name | Type | Default Value | Mandatory | Description | +| ---------------------------------- | ---------------------------------------- | ----- | ---- | ---------------------------------------- | +| width | <length> \| <percentage>5+ | - | No | Component width.

If this attribute is not set, the default value **0** is used. | +| height | <length> \| <percentage>5+ | - | No | Component height.

If this attribute is not set, the default value **0** is used. | +| padding | <length> | 0 | No | Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No | Left, top, right, and bottom padding. | +| margin | <length> \| <percentage>5+ | 0 | No | Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No | Left, top, right, and bottom margins. | +| border-width | <length> | 0 | No | Shorthand attribute to set the margin for all sides. | +| border-color | <color> | black | No | Shorthand attribute to set the color for all borders. | +| border-radius | <length> | - | No | Radius of round-corner borders. | +| background-color | <color> | - | No | Background color. | +| opacity5+ | number | 1 | No | Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent. | +| display | string | flex | No | How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No | Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element.| + +> **NOTE** > > The absolute positioning does not support a percentage. Therefore, **margin** cannot be set for the child components of the **\** component. diff --git a/en/application-dev/reference/arkui-js-lite/js-framework-file.md b/en/application-dev/reference/arkui-js-lite/js-framework-file.md index ade304c4d50a1aacac56a140c1bf3a3669165580..e03caae24cb2ddfd8c20c7517baef2420160bedc 100644 --- a/en/application-dev/reference/arkui-js-lite/js-framework-file.md +++ b/en/application-dev/reference/arkui-js-lite/js-framework-file.md @@ -50,7 +50,7 @@ Application resources can be accessed via an absolute or relative path. In this > > - If code files A and B are in the same directory, you can use either a relative or absolute path in code file B to reference resource files. > -> - If code files A and B are in different directories, you must use an absolute path in code file B to reference resource files. The reason is that the directory of code file B changes during Webpack packaging. +> - If code files A and B are in different directories, you must use an absolute path in code file B to reference resource files, because the directory of code file B changes during Webpack packaging. > diff --git a/en/application-dev/reference/arkui-js-lite/js-framework-js-tag.md b/en/application-dev/reference/arkui-js-lite/js-framework-js-tag.md index 37d08081341fb43d1228d2cd9b211b14cf39f35a..868e668195e277d512bd98c99b0404261b198eab 100644 --- a/en/application-dev/reference/arkui-js-lite/js-framework-js-tag.md +++ b/en/application-dev/reference/arkui-js-lite/js-framework-js-tag.md @@ -4,10 +4,10 @@ The "js" tag contains the instance name and page route information. -| Tag| Type| Default Value| Mandatory| Description| -| -------- | -------- | -------- | -------- | -------- | -| name | string | default | Yes| Name of the JavaScript instance.| -| pages | Array | - | Yes| Route information. For details, see ["pages"](#pages).| +| Tag | Type | Default Value | Mandatory | Description | +| ----- | ------ | ------- | ---- | ----------------------------- | +| name | string | default | Yes | Name of the JavaScript instance. | +| pages | Array | - | Yes | Route information. For details, see ["pages"](#pages).| > **NOTE** @@ -34,10 +34,10 @@ The **"pages"** defines the route information of each page. Each page consists o > **NOTE** > -> -> - The application home page is fixed to **pages/index/index**. -> -> - The page name should not be a component name, for example, **text.hml** or **button.hml**. +> +> - The application home page is fixed to **pages/index/index**. +> +> - The page name should not be a component name, for example, **text.hml** or **button.hml**. ## Example @@ -46,7 +46,7 @@ The **"pages"** defines the route information of each page. Each page consists o ``` { "app": { - "bundleName": "com.huawei.player", + "bundleName": "com.example.player", "version": { "code": 1, "name": "1.0" diff --git a/en/application-dev/reference/arkui-js-lite/js-framework-syntax-css.md b/en/application-dev/reference/arkui-js-lite/js-framework-syntax-css.md index 79b1d9938cac9f7f804a85407a74d6bd08931628..7e3bf96dde9606c86a70d75f1c89fe62a47d155d 100644 --- a/en/application-dev/reference/arkui-js-lite/js-framework-syntax-css.md +++ b/en/application-dev/reference/arkui-js-lite/js-framework-syntax-css.md @@ -14,16 +14,16 @@ CSS files can be imported using the **\@import** statement. This facilitates mod The **.css** file with the same name as the **.hml** file in each page directory describes the styles of components on the HML page, determining how the components will be displayed. 1. Internal style: The **style** and **class** attributes can be used to specify the component style. Sample code: - - ``` + + ```html
Hello World
``` - - ``` + + ```css /* index.css */ .container { justify-content: center; @@ -31,16 +31,16 @@ The **.css** file with the same name as the **.hml** file in each page directory ``` 2. External style files: You need to import the files. For example, create a **style.css** file in the **common** directory and import the file at the beginning of **index.css**. - - ``` + + ```css /* style.css */ .title { font-size: 50px; } ``` - - ``` + + ```css /* index.css */ @import '../../common/style.css'; .container { @@ -53,16 +53,16 @@ The **.css** file with the same name as the **.hml** file in each page directory A CSS selector is used to select elements for which styles need to be added to. The following table lists the supported selectors. -| Selector| Example| Description| -| -------- | -------- | -------- | -| .class | .container | Selects all components whose **class** is **container**.| -| \#id | \#titleId | Selects all components whose **id** is **titleId**.| -| , | .title, .content | Selects all components whose **class** is **title** or **content**.| +| Selector | Example | Description | +| ------ | --------------------- | ------------------------------------- | +| .class | .container | Selects all components whose **class** is **container**. | +| \#id | \#titleId | Selects all components whose **id** is **titleId**. | +| , | .title, .content | Selects all components whose **class** is **title** or **content**.| Example: -``` +```html
Title @@ -73,7 +73,7 @@ Example: ``` -``` +```css /* Page style xxx.css */ /* Set the style for the components whose class is title. */ .title { @@ -95,15 +95,17 @@ Example: A CSS pseudo-class is a keyword added to a selector that specifies a special state of the selected elements. -| Name| Available Components| Description| -| -------- | -------- | -------- | -| :active |
input[type="button"] | Selects the element activated by a user, for example, a pressed button. Only the **background-color** and **background-image** attributes can be set for the pseudo-class selector on lite wearables.| + + +| Name | Available Components | Description | +| -------- | ----------------------------------- | ---------------------------------------- | +| :active |
input[type="button"] | Selects the element activated by a user, for example, a pressed button. Only the **background-color** and **background-image** attributes can be set for the pseudo-class selector on lite wearables.| | :checked | input[type="checkbox", type="radio"]| Selects the element whose **checked** attribute is **true**. Only the **background-color** and **background-image** attributes can be set for the pseudo-class selector on lite wearables.| The following is an example for you to use the **:active** pseudo-class to control the style when a user presses the button. -``` +```html
@@ -111,7 +113,7 @@ The following is an example for you to use the **:active** pseudo-class to contr ``` -``` +```css /* index.css */ .button:active { background-color: #888888;/* After the button is activated, the background color is changed to #888888. */ @@ -124,8 +126,8 @@ The following is an example for you to use the **:active** pseudo-class to contr Precompilation is a program that uses specific syntax to generate CSS files. It provides variables and calculation, helping you define component styles more conveniently. Currently, Less, Sass, and Scss are supported. To use precompiled styles, change the suffix of the original **.css** file. For example, change **index.css** to **index.less**, **index.sass**, or **index.scss**. - The following **index.less** file is changed from **index.css**. - - ``` + + ```css /* index.less */ /* Define a variable. */ @colorBackground: #000000; @@ -135,8 +137,8 @@ Precompilation is a program that uses specific syntax to generate CSS files. It ``` - Reference a precompiled style file. For example, if the **style.scss** file is located in the **common** directory, change the original **index.css** file to **index.scss** and import **style.scss**. - - ``` + + ```css /* style.scss */ /* Define a variable. */ $colorBackground: #000000; @@ -144,8 +146,8 @@ Precompilation is a program that uses specific syntax to generate CSS files. It Reference the precompiled style file in **index.scss**: - - ``` + + ```css /* index.scss */ /* Import style.scss. */ @import '../../common/style.scss'; @@ -154,7 +156,7 @@ Precompilation is a program that uses specific syntax to generate CSS files. It } ``` - + > **NOTE** > > Place precompiled style files in the **common** directory. diff --git a/en/application-dev/reference/arkui-js-lite/js-framework-syntax-hml.md b/en/application-dev/reference/arkui-js-lite/js-framework-syntax-hml.md index b9f5bec1e13aaf9bc2112fdee9e43cdcc322641d..b111895cb5421d3b5d4310c56f85929c216615ec 100644 --- a/en/application-dev/reference/arkui-js-lite/js-framework-syntax-hml.md +++ b/en/application-dev/reference/arkui-js-lite/js-framework-syntax-hml.md @@ -7,7 +7,7 @@ The OpenHarmony Markup Language (HML) is an HTML-like language that allows you t ## HML Page Structure -``` +```html
Image Show @@ -21,7 +21,7 @@ The OpenHarmony Markup Language (HML) is an HTML-like language that allows you t ## Data Binding -``` +```html
{{content[1]}} @@ -29,7 +29,7 @@ The OpenHarmony Markup Language (HML) is an HTML-like language that allows you t ``` -``` +```js // xxx.js export default { data: { @@ -42,9 +42,9 @@ export default { ``` > **NOTE** -> - To make the array data modification take effect, use the **splice** method to change array items. -> -> - ECMAScript 6.0 syntax is not supported in HML. +> - To make the array data modification take effect, use the **splice** method to change array items. +> +> - ECMAScript 6.0 syntax is not supported in HML. ## Event Binding @@ -52,7 +52,7 @@ export default { The callback bound to an event receives an event object parameter, which can be used to obtain the event information. -``` +```html
@@ -73,7 +73,7 @@ The callback bound to an event receives an event object parameter, which can be ``` -``` +```js // xxx.js export default { data: { @@ -88,11 +88,11 @@ export default { > **NOTE** > -> Event bubbling is supported since API version 5. After you upgrade the SDK and run an existing JavaScript application, events bound using a traditional statement (such as **onclick**) will not bubble. However, if you use the new SDK to repack the JavaScript application, such events will bubble. To avoid service logic errors, replace the traditional statement with one supported by the new SDK. For example, replace **onclick** with **grab:click**. +> Event bubbling is supported since API version 5. After you upgrade the SDK and run an existing JavaScript application, events bound using a traditional statement (such as **onclick**) will not bubble. However, if you use the new SDK to repack the JavaScript application, such events will bubble. To avoid service logic errors, replace the traditional statement with one supported by the new SDK. For example, replace **onclick** with **grab:click**. **Example:** -``` +```html
{{count}} @@ -108,8 +108,8 @@ export default { ``` -``` -/* xxx.js */ +```js +// xxx.js export default { data: { count: 0 @@ -127,7 +127,7 @@ export default { ``` -``` +```css /* xxx.css */ .container { display: flex; @@ -164,7 +164,7 @@ export default { ## Loop Rendering -``` +```html
@@ -184,7 +184,7 @@ export default { ``` -``` +```js // xxx.js export default { data: { @@ -211,11 +211,12 @@ The **tid** attribute accelerates the **for** loop and improves the re-rendering - for="(i, v) in array": **i** indicates the element index, and **v** indicates the element variable. All elements of the array object will be looped through. -> **NOTE** +> **NOTE** +> > - Each element in the array must have the data attribute specified by **tid**. Otherwise, an exception may occur. -> +> > - The attribute specified by **tid** in the array must be unique. Otherwise, performance loss occurs. In the above example, only **id** and **name** can be used as **tid** because they are unique fields. -> +> > - The **tid** field does not support expressions. @@ -224,7 +225,7 @@ The **tid** attribute accelerates the **for** loop and improves the re-rendering There are two ways to implement conditional rendering: **if-elif-else** or **show**. In **if-elif-else**, when the **if** statement evaluates to **false**, the component is not built in the VDOM and is not rendered. For **show**, when show is **false**, the component is not rendered but is built in the VDOM. In addition, the **if-elif-else** statements must be used in sibling nodes. Otherwise, the compilation fails. The following example uses both ways to implement conditional rendering: -``` +```html
@@ -236,8 +237,8 @@ There are two ways to implement conditional rendering: **if-elif-else** or **sho ``` -``` -// xxx.css +```css +/* xxx.css */ .container{ flex-direction: column; align-items: center; @@ -250,7 +251,7 @@ There are two ways to implement conditional rendering: **if-elif-else** or **sho ``` -``` +```js // xxx.js export default { data: { @@ -269,7 +270,7 @@ export default { In the optimized rendering (**show**), if **show** is **true**, the node is rendered properly; if it is **false**, the display style will be **none**. -``` +```html
@@ -278,8 +279,8 @@ In the optimized rendering (**show**), if **show** is **true**, the node is rend ``` -``` -// xxx.css +```css +/* xxx.css */ .container{ flex-direction: column; align-items: center; @@ -292,7 +293,7 @@ In the optimized rendering (**show**), if **show** is **true**, the node is rend ``` -``` +```js // xxx.js export default { data: { @@ -305,4 +306,5 @@ export default { ``` > **NOTE** -> Do not use **for** and **if** attributes at the same time in an element. +> +> Do not use **for** and **if** attributes at the same time in an element. diff --git a/en/application-dev/reference/arkui-js-lite/js-framework-syntax-js.md b/en/application-dev/reference/arkui-js-lite/js-framework-syntax-js.md index 3ce76d4463643c979cf619749b2a8a5c80dae1c1..e9d71fc2ff680dfba5b95e7bae676854a1e68a28 100644 --- a/en/application-dev/reference/arkui-js-lite/js-framework-syntax-js.md +++ b/en/application-dev/reference/arkui-js-lite/js-framework-syntax-js.md @@ -31,7 +31,7 @@ The ECMAScript 6.0 syntax is supported. Lite wearables only support the followin - Module declaration Import functionality modules. - + ``` import router from '@system.router'; ``` @@ -39,7 +39,7 @@ The ECMAScript 6.0 syntax is supported. Lite wearables only support the followin - Code reference Import JavaScript code. - + ``` import utils from '../../common/utils.js'; ``` @@ -48,17 +48,17 @@ The ECMAScript 6.0 syntax is supported. Lite wearables only support the followin ## Objects - Page objects - | Attribute| Type| Description| - | -------- | -------- | -------- | - | data | Object/Function | Data model of the page. If the attribute is of the function type, the return value must be of the object type. The name cannot start with a dollar sign ($) or underscore (_). Do not use reserved words (**for**, **if**, **show**, and **tid**). | - | $refs | Object | DOM elements or child component instances that have registered the **ref** attribute. For an example, see [Obtaining a DOM Element](#obtaining-a-dom-element).| + | Attribute | Type | Description | + | ----- | --------------- | ---------------------------------------- | + | data | Object/Function | Data model of the page. If the attribute is of the function type, the return value must be of the object type. The name cannot start with a dollar sign ($) or underscore (_). Do not use reserved words (**for**, **if**, **show**, and **tid**).
| + | $refs | Object | DOM elements or child component instances that have registered the **ref** attribute. For an example, see [Obtaining a DOM Element](#obtaining-a-dom-element). | ## Obtaining a DOM Element Use **$refs** to obtain a DOM element. -``` +```html
@@ -66,57 +66,57 @@ Use **$refs** to obtain a DOM element. ``` -``` -// index.js -export default { - data: { - images: [ - { src: '/common/frame1.png' }, - { src: '/common/frame2.png' }, - { src: '/common/frame3.png' }, - ], - }, - handleClick() { - const animator = this.$refs.animator; // Obtain the DOM element whose $refs attribute is animator. - const state = animator.getState(); - if (state === 'paused') { - animator.resume(); - } else if (state === 'stopped') { - animator.start(); - } else { - animator.pause(); - } - }, -}; -``` + ```js + // index.js + export default { + data: { + images: [ + { src: '/common/frame1.png' }, + { src: '/common/frame2.png' }, + { src: '/common/frame3.png' }, + ], + }, + handleClick() { + const animator = this.$refs.animator; // Obtain the DOM element whose $refs attribute is animator. + const state = animator.getState(); + if (state === 'paused') { + animator.resume(); + } else if (state === 'stopped') { + animator.start(); + } else { + animator.pause(); + } + }, + }; + ``` ## Lifecycle APIs - Page lifecycle APIs - | Name | Type| Parameter| Return Value| Description| Triggered When| - | -------- | -------- | -------- | -------- | -------- | -------- | - | onInit | Function | N/A| N/A| Listens for page initialization.| Page initialization is complete. This API is called only once in the page lifecycle.| - | onReady | Function | N/A| N/A| Listens for page creation.| A page is created. This API is called only once in the page lifecycle.| - | onShow | Function | N/A| N/A| Listens for page display. | The page is displayed.| - | onHide | Function | N/A| N/A| Listens for page disappearance.| The page disappears.| - | onDestroy | Function | N/A| N/A| Listens for page destruction.| The page is destroyed.| - + | Name | Type | Parameter | Return Value | Description | Triggered When | + | --------- | -------- | ---- | ---- | ------ | ------------------- | + | onInit | Function | N/A | N/A | Listens for page initialization. | Page initialization is complete. This API is called only once in the page lifecycle.| + | onReady | Function | N/A | N/A | Listens for page creation.| A page is created. This API is called only once in the page lifecycle. | + | onShow | Function | N/A | N/A | Listens for page display. | The page is displayed. | + | onHide | Function | N/A | N/A | Listens for page disappearance. | The page disappears. | + | onDestroy | Function | N/A | N/A | Listens for page destruction. | The page is destroyed. | + The lifecycle APIs of page A are called in the following sequence: - Open page A: onInit() -> onReady() -> onShow() - + - Open page B on page A: onHide() -> onDestroy() - + - Go back to page A from page B: onInit() -> onReady() -> onShow() - + - Exit page A: onHide() -> onDestroy() - + - Hide page A: onHide() - + - Show background page A on the foreground: onShow() - Application lifecycle APIs - | Name | Type| Parameter| Return Value| Description| Triggered When| - | -------- | -------- | -------- | -------- | -------- | -------- | - | onCreate | Function | N/A| N/A| Listens for application creation.| The application is created.| - | onDestroy | Function | N/A| N/A| Listens for application exit.| The application exits.| + | Name | Type | Parameter | Return Value | Description | Triggered When | + | --------- | -------- | ---- | ---- | ---- | --------- | + | onCreate | Function | N/A | N/A | Listens for application creation.| The application is created.| + | onDestroy | Function | N/A | N/A | Listens for application exit.| The application exits.| diff --git a/en/application-dev/reference/arkui-js/js-components-container-div.md b/en/application-dev/reference/arkui-js/js-components-container-div.md index e35eb42639301cfb6ce1a9a45880217ce1daf54b..295e0bd4d35d6ec824471b745fd7320b517d4ba6 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-div.md +++ b/en/application-dev/reference/arkui-js/js-components-container-div.md @@ -385,25 +385,25 @@ In addition to the [universal methods](js-components-common-methods.md), the fol ```js // xxx.js - import prompt from '@system.prompt'; + import promptAction from '@ohos.promptAction'; export default { pinchstart(e){ - prompt.showToast({ + promptAction.showToast({ message: 'pinchstart!!!' }) }, pinchupdate(e){ - prompt.showToast({ + promptAction.showToast({ message: 'Two-finger pinch update' }) }, pinchend(e){ - prompt.showToast({ + promptAction.showToast({ message: 'Finished with two fingers pinching' }) }, pinchcancel(e){ - prompt.showToast({ + promptAction.showToast({ message: 'Finger pinching is interrupted' }) } diff --git a/en/application-dev/reference/arkui-ts/figures/LinearGradientDataPanel.PNG b/en/application-dev/reference/arkui-ts/figures/LinearGradientDataPanel.PNG new file mode 100644 index 0000000000000000000000000000000000000000..5dbe4fdeef5f231fd2145da2bbaa82b433458d6c Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/LinearGradientDataPanel.PNG differ diff --git a/en/application-dev/reference/arkui-ts/figures/animationComponent1.png b/en/application-dev/reference/arkui-ts/figures/animationComponent1.png deleted file mode 100644 index b2aa53b14b112434bb736d2dc2f301bac3b46043..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/animationComponent1.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/animationComponent2.png b/en/application-dev/reference/arkui-ts/figures/animationComponent2.png deleted file mode 100644 index c348c9305503698fab2f6b401450048a653e581a..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/animationComponent2.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/animationComponent3.png b/en/application-dev/reference/arkui-ts/figures/animationComponent3.png deleted file mode 100644 index b53d8f308a879d4b4ce84db7adac1289c8b85cfa..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/animationComponent3.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/animationComponent4.png b/en/application-dev/reference/arkui-ts/figures/animationComponent4.png deleted file mode 100644 index a93f8390861d3638a35de13f38e2ab51816b8083..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/animationComponent4.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/dataPanel.PNG b/en/application-dev/reference/arkui-ts/figures/dataPanel.PNG index b360ca62d5d961ff107b2a703621123b3b48aa46..559a2370feae57233fb39cad218a8ca77241fed9 100644 Binary files a/en/application-dev/reference/arkui-ts/figures/dataPanel.PNG and b/en/application-dev/reference/arkui-ts/figures/dataPanel.PNG differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058460.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058460.gif deleted file mode 100644 index f70d75a50c028de29ab4b60075b7644316927eab..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058460.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978335.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978335.gif deleted file mode 100644 index 7a0a33ad1f90625edd3f24f7c8702ada65d6febd..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978335.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/pageTransition1.gif b/en/application-dev/reference/arkui-ts/figures/pageTransition1.gif new file mode 100644 index 0000000000000000000000000000000000000000..a8a8623279b5a93ca40461d522ccdb48eede1c42 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/pageTransition1.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/pageTransition2.gif b/en/application-dev/reference/arkui-ts/figures/pageTransition2.gif new file mode 100644 index 0000000000000000000000000000000000000000..d1ef2f2889cac0428733478c6d81cc8e0b1ad84c Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/pageTransition2.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/transitionComponent1.gif b/en/application-dev/reference/arkui-ts/figures/transitionComponent1.gif new file mode 100644 index 0000000000000000000000000000000000000000..6b5dd0f0ca7d09218af2641e4ae2900eb394623d Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/transitionComponent1.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/transitionComponent2.gif b/en/application-dev/reference/arkui-ts/figures/transitionComponent2.gif new file mode 100644 index 0000000000000000000000000000000000000000..80b08806d4cdf08effc321bf64bba653d4a7398b Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/transitionComponent2.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/transitionComponent3.gif b/en/application-dev/reference/arkui-ts/figures/transitionComponent3.gif new file mode 100644 index 0000000000000000000000000000000000000000..2ff38b3e852bb8bcfabe5dc4e924cec0fa363c39 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/transitionComponent3.gif differ diff --git a/en/application-dev/reference/arkui-ts/ts-appendix-enums.md b/en/application-dev/reference/arkui-ts/ts-appendix-enums.md index 020c9d6eb2f6828712a97cfe64deb347d43cc8bf..bf4d48665a378934f14c413db9408fa09fb5705f 100644 --- a/en/application-dev/reference/arkui-ts/ts-appendix-enums.md +++ b/en/application-dev/reference/arkui-ts/ts-appendix-enums.md @@ -293,12 +293,12 @@ Since API version 9, this API is supported in ArkTS widgets. | Name | Description | | -------- | ------------------------------------------------------------ | -| Auto | The default configuration of the container (**\** or **\**) is used. | -| Start | The items in the container (**\** or **\**) are aligned with the cross-start edge. | -| Center | The items in the container (**\** or **\**) are centered along the cross axis. | -| End | The items in the container (**\** or **\**) are aligned with the cross-end edge. | -| Stretch | The items in the container (**\** or **\**) are stretched and padded along the cross axis. If the flex container has the **Wrap** attribute set to **FlexWrap.Wrap** or **FlexWrap.WrapReverse**, the items are stretched to the cross size of the widest element on the current row or column. In other cases, the items with no size set are stretched to the container size.| -| Baseline | The items in the container (**\** or **\**) are aligned in such a manner that their text baselines are aligned along the cross axis. | +| Auto | The default configuration of the flex container is used. | +| Start | The items in the flex container are aligned with the cross-start edge. | +| Center | The items in the flex container are centered along the cross axis. | +| End | The items in the flex container are aligned with the cross-end edge. | +| Stretch | The items in the flex container are stretched and padded along the cross axis. If the flex container has the **Wrap** attribute set to **FlexWrap.Wrap** or **FlexWrap.WrapReverse**, the items are stretched to the cross size of the widest element on the current row or column. In other cases, the items with no size set are stretched to the container size.| +| Baseline | The items in the flex container are aligned in such a manner that their text baselines are aligned along the cross axis. | ## FlexDirection @@ -414,7 +414,7 @@ Since API version 9, this API is supported in ArkTS widgets. | Name | Description | | --------------------- | -------------------------------------- | -| None | No clipping or ellipsis is used for text overflow. | +| None | Extra-long text is clipped. | | Clip | Extra-long text is clipped. | | Ellipsis | An ellipsis (...) is used to represent text overflow.| | Marquee10+ | Text continuously scrolls when text overflow occurs. | @@ -528,3 +528,11 @@ This API is supported in ArkTS widgets. | MAX_LINES_FIRST | Prioritize the **maxLines** settings. | | MIN_FONT_SIZE_FIRST | Prioritize the **minFontSize** settings. | | LAYOUT_CONSTRAINT_FIRST | Prioritize the layout constraint settings in terms of height.| + +## TransitionEdge10+ +| Name| Description| +| -------- | -------- | +| TOP | Top edge of the window.| +| BOTTOM | Bottom edge of the window.| +| START | Left edge of the window.| +| END | Right edge of the window.| diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md b/en/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md index 41db34a3c7167bc08af84c54586af4981a265efc..3a56d0d8d44bc724a4290556f25d3366e5e7c339 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md @@ -24,7 +24,7 @@ Since API version 9, this API is supported in ArkTS widgets. | Name | Type | Mandatory | Description| | ----------------- | -------- | ----- | -------- | -| values | number[] | Yes | Data value list. A maximum of nine values are supported. If more than nine values are set, only the first nine ones are used. A value less than 0 evaluates to the value **0**. | +| values | number[] | Yes | Data value list. A maximum of nine values are supported. If more than nine values are set, only the first nine ones are used. A value less than 0 evaluates to the value **0**.| | max | number | No | - When set to a value greater than 0, this parameter indicates the maximum value in the **values** list.
- When set to a value equal to or smaller than 0, this parameter indicates the sum of values in the **values** list. The values are displayed in proportion.
Default value: **100**| | type8+ | [DataPanelType](#datapaneltype) | No| Type of the data panel (dynamic modification is not supported).
Default value: **DataPanelType.Circle**| @@ -46,20 +46,20 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name | Type| Mandatory| Description| | ------------- | ------- | ---- | -------- | -| closeEffect | boolean | Yes| Whether to disable the rotation effect for the component.
Default value: **false**.| +| closeEffect | boolean | Yes| Whether to disable the rotation and shadow effects for the component.
Default value: **false**
**NOTE**
This attribute enables or disables the shadow effect only when **trackShadow** is not set.
The shadow effect enabled through this attribute is in the default style.| | valueColors10+ | Array<[ResourceColor](ts-types.md#resourcecolor) \| [LinearGradient](#lineargradient10)> | Yes| Array of data segment colors. A value of the **ResourceColor** type indicates a solid color, and A value of the **LinearGradient** type indicates a color gradient.| -| trackBackgroundColor10+ | [ResourceColor](ts-types.md#resourcecolor) | Yes| Background color.| -| strokeWidth10+ | [Length](ts-types.md#Length) | Yes| Stroke width of the border.| -| trackShadow10+ | [DataPanelShadowOption](#datapanelshadowoption10) | Yes| Shadow style. If this attribute is not set, the shadow effect is disabled.| +| trackBackgroundColor10+ | [ResourceColor](ts-types.md#resourcecolor) | Yes| Background color.
Default value: **'#081824'**| +| strokeWidth10+ | [Length](ts-types.md#Length) | Yes| Stroke width of the border.
Default value: **24**
Unit: vp
**NOTE**
A value less than 0 evaluates to the default value.
This attribute does not take effect when the data panel type is **DataPanelType.Line**.| +| trackShadow10+ | [DataPanelShadowOption](#datapanelshadowoption10) | Yes| Shadow style.
**NOTE**
If this attribute is set to **null**, the shadow effect is disabled.| ## DataPanelShadowOption10+ | Name | Type| Mandatory| Description| | ------------- | ------- | ---- | -------- | -| radius | number \| [Resource](ts-types.md#resource)| No| Shadow blur radius.
Default value: **5vp**| -| colors | Array<[ResourceColor](ts-types.md#resourcecolor) \| [LinearGradient](#lineargradient10)> | No| Array of shadow colors for data segments.
Default value: same as the value of **valueColors**.| -| offsetX | number \| [Resource](ts-types.md#resource)| No| Offset on the x-axis.
Default value: **5vp**| -| offsetY | number \| [Resource](ts-types.md#resource)| No| Offset on the y-axis.
Default value: **5vp**| +| radius | number \| [Resource](ts-types.md#resource)| No| Shadow blur radius.
Default value: **5**
Unit: vp
**NOTE**
A value less than or equal to 0 evaluates to the default value.| +| colors | Array<[ResourceColor](ts-types.md#resourcecolor) \| [LinearGradient](#lineargradient10)> | No| Array of shadow colors for data segments.
Default value: same as the value of **valueColors**
**NOTE**
If the number of the set shadow colors is less than that of the data segments, the number of the displayed shadow colors is the same as the former.
If the number of the set shadow colors is greater than that of the data segments, the number of the displayed shadow colors is the same as the latter.| +| offsetX | number \| [Resource](ts-types.md#resource)| No| Offset on the x-axis.
Default value: **5**
Unit: vp| +| offsetY | number \| [Resource](ts-types.md#resource)| No| Offset on the y-axis.
Default value: **5**
Unit: vp| ## LinearGradient10+ @@ -79,12 +79,14 @@ Describes the gradient color stop. | Name | Type| Mandatory| Description| | ------------- | ------- | ---- | -------- | | color | [ResourceColor](ts-types.md#resourcecolor) | Yes| Color value.| -| offset | [Length](ts-types.md#Length) | Yes| Gradient color stop (proportion value between 0 and 1).| +| offset | [Length](ts-types.md#Length) | Yes| Gradient color stop (proportion value between 0 and 1). A value less than 0 evaluates to the value **0**. A value greater than 1 evaluates to the value **1**.| ## Example +### Example 1 + ```ts // xxx.ets @Entry @@ -133,3 +135,48 @@ struct DataPanelExample { ``` ![dataPanel](figures/dataPanel.PNG) + +### Example 2 + +```ts +// xxx.ets +@Entry +@Component +struct LinearGradientDataPanelExample { + public values1: number[] = [20, 20, 20, 20] + public color1: LinearGradient = new LinearGradient([{ color: "#65EEC9A3", offset: 0 }, { color: "#FFEF629F", offset: 1 }]) + public color2: LinearGradient = new LinearGradient([{ color: "#FF67F9D4", offset: 0 }, { color: "#FFFF9554", offset: 1 }]) + public colorShadow1: LinearGradient = new LinearGradient([{ color: "#65EEC9A3", offset: 0 }, { color: "#65EF629F", offset: 1 }]) + public colorShadow2: LinearGradient = new LinearGradient([{ color: "#65e26709", offset: 0 }, { color: "#65efbd08", offset: 1 }]) + public colorShadow3: LinearGradient = new LinearGradient([{ color: "#6572B513", offset: 0 }, { color: "#6508efa6", offset: 1 }]) + public colorShadow4: LinearGradient = new LinearGradient([{ color: "#65ed08f5", offset: 0 }, { color: "#65ef0849", offset: 1 }]) + @State color3: string = '#00FF00' + @State color4: string = '#20FF0000' + @State bgColor: string = '#08182431' + @State offsetX: number = 15 + @State offsetY: number = 15 + @State radius: number = 5 + @State colorArray: Array = [this.color1, this.color2, this.color3, this.color4] + @State shadowColorArray: Array = [this.colorShadow1, this.colorShadow2, this.colorShadow3, this.colorShadow4] + + build() { + Column({ space: 5 }) { + Text('LinearGradient').fontSize(9).fontColor(0xCCCCCC).textAlign(TextAlign.Start).width('100%').margin({ top: 20, left: 20}) + DataPanel({ values: this.values1, max: 100, type: DataPanelType.Circle }) + .width(300) + .height(300) + .valueColors(this.colorArray) + .trackShadow({ + radius: this.radius, + colors: this.shadowColorArray, + offsetX: this.offsetX, + offsetY: this.offsetY + }) + .strokeWidth(30) + .trackBackgroundColor(this.bgColor) + }.width('100%').margin({ top: 5 }) + } +} +``` + +![LinearGradientDataPanel](figures/LinearGradientDataPanel.PNG) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md b/en/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md index 1b4f2c165ed231af18e4ad15a9588247fd60d161..e5aa84e29ece1a1a11f91a0a66fc6526bdc1b2ab 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md @@ -20,11 +20,11 @@ Creates a date picker in the given date range. **Parameters** -| Name | Type| Mandatory | Description | -| -------- | ---- | ---- | -------------------------------------- | -| start | Date | No | Start date of the picker.
Default value: **Date('1970-1-1')** | -| end | Date | No | End date of the picker.
Default value: **Date('2100-12-31')**| -| selected | Date | No | Date of the selected item.
Default value: current system date | +| Name | Type| Mandatory| Description | +| -------- | -------- | ---- | ------------------------------------------------------------ | +| start | Date | No | Start date of the picker.
Default value: **Date('1970-1-1')** | +| end | Date | No | End date of the picker.
Default value: **Date('2100-12-31')** | +| selected | Date | No | Date of the selected item.
Default value: current system date
Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| ## Attributes diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-menu.md b/en/application-dev/reference/arkui-ts/ts-basic-components-menu.md index 594bf9fe6a1e8107e29a4dffc3b4b8c444ff92af..0136146723cecb5883d6300b006450922d7f2b00 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-menu.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-menu.md @@ -4,7 +4,9 @@ The **\** component is a vertical list of items presented to the user. > **NOTE** > -> This component is supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> - This component is supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> - The **\** component must be used together with the [bindMenu](ts-universal-attributes-menu.md) or [bindContextMenu](ts-universal-attributes-menu.md) method. It does not work when used alone. ## Child Components diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-menuitem.md b/en/application-dev/reference/arkui-ts/ts-basic-components-menuitem.md index a4616a22ad0712d5fe1d419f5d3a981c1fb6876f..305f14aa458274050f5c182ab8131d921ff91bf6 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-menuitem.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-menuitem.md @@ -36,7 +36,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name | Type | Description | | ------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -| selected | boolean | Whether the menu item is selected.
Default value: **false** | +| selected | boolean | Whether the menu item is selected.
Default value: **false**
Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| | selectIcon | boolean \| [ResourceStr](ts-types.md#resourcestr)10+ | Whether to display the selected icon for a menu item is selected.
Default value: **false**
**true**: When a menu item is selected, the default tick icon is displayed.
**false**: When a menu item is selected, no icon is displayed.
**ResourceStr**: When a menu item is selected, the specified icon is displayed.| | contentFont10+ | [Font](ts-types.md#font) | Font style of the menu item content. | | contentFontColor10+ | [ResourceColor](ts-types.md#resourcecolor) | Font color of the menu item content. | @@ -47,7 +47,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name | Type | Description | | -------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| onChange | (selected: boolean) => void | Triggered when the selection status of the menu item is changed manually.
The value **true** means that the menu item is selected, and **false** means the opposite. | +| onChange | (selected: boolean) => void | Triggered when the selection status of the menu item is changed manually.
The value **true** means that the menu item is selected, and **false** means the opposite.| ## Example diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-navdestination.md b/en/application-dev/reference/arkui-ts/ts-basic-components-navdestination.md index 45fcd8c2bb0b7667f96dd869c19614a3981e0881..e637a22e1193f0fdb727b8ffe91e042ff167b6fd 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-navdestination.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-navdestination.md @@ -9,10 +9,9 @@ ## Child Components -> **NOTE** -> -> - Supported types of child components: built-in components and custom components, with support for ([if/else](../../quick-start/arkts-rendering-control-ifelse.md), [ForEach](../../quick-start/arkts-rendering-control-foreach.md), and [LazyForEach](../../quick-start/arkts-rendering-control-lazyforeach.md)) rendering control. -> - Number of child components: multiple. +Supported types of child components: built-in components and custom components, with support for ([if/else](../../quick-start/arkts-rendering-control-ifelse.md), [ForEach](../../quick-start/arkts-rendering-control-foreach.md), and [LazyForEach](../../quick-start/arkts-rendering-control-lazyforeach.md)) rendering control. + +Number of child components: multiple. ## APIs @@ -31,4 +30,11 @@ In addition to the [backgroundColor](ts-universal-attributes-background.md) attr ## Events -The [universal events](ts-universal-events-click.md) are supported. +In addition to the [universal events](ts-universal-events-click.md), the following events are supported. + + +| Name | Description | +| ---------------------------------------- | ---------------------------------------- | +| onShown(callback: (param: unknown) => void)10+ | Called when the navigation destination page is displayed. **param**: parameter information of the navigation destination page.
**NOTE**
The **onShown** API will be changed to **onShown(callback: () => void)**.| +| onHidden(callback: () => void)10+ | Called when the navigation destination page is hidden.| +| onBackPressed(callback: () => boolean)10+ | Called when the back button is pressed.
The value **true** means that the back button logic is overridden, and **false** means that the previous page is displayed.
| diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-navigation.md b/en/application-dev/reference/arkui-ts/ts-basic-components-navigation.md index b761ae46e7409a709b37f39af778581f06186e96..72b9bb67da9e44ca5298039151dbe5b929ce408d 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-navigation.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-navigation.md @@ -16,8 +16,17 @@ Since API version 9, it is recommended that this component be used together with ## APIs -Navigation() +**API 1**: Navigation() +**API 2**: Navigation(pathInfos: NavPathStack)10+ + +Binds a navigation stack to the **\** component. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------- | ----------------------------------- | ---- | ------------- | +| pathInfos | [NavPathStack](#navpathstack10) | No | Information about the navigation stack.| ## Attributes @@ -32,13 +41,215 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | toolBar | [object](#object) \| [CustomBuilder](ts-types.md#custombuilder8)8+ | Content of the toolbar. If this attribute is not set, no toolbar is displayed.
**items**: items on the toolbar.
**NOTE**
Items are evenly distributed on the toolbar at the bottom. Text and icons are evenly distributed in each content area. If the text is too long, it is scaled down level by level, wrapped in two lines, and then clipped with an ellipsis (...).| | hideToolBar | boolean | Whether to hide the toolbar.
Default value: **false**
**true**: Hide the toolbar.
**false**: Display the toolbar.| | hideTitleBar | boolean | Whether to hide the title bar.
Default value: **false**
**true**: Hide the title bar.
**false**: Display the title bar.| -| hideBackButton | boolean | Whether to hide the Back button.
Default value: **false**
**true**: Hide the Back button.
**false**: Display the Back button.
The Back button in the title bar of the **\** component cannot be hidden.
**NOTE**
The Back button is available only when **titleMode** is set to **NavigationTitleMode.Mini**.| +| hideBackButton | boolean | Whether to hide the back button.
Default value: **false**
**true**: Hide the back button.
**false**: Display the back button.
The back button in the title bar of the **\** component cannot be hidden.
**NOTE**
The back button is available only when **titleMode** is set to **NavigationTitleMode.Mini**.| | navBarWidth9+ | [Length](ts-types.md#length) | Width of the navigation bar.
Default value: **200**
Unit: vp
**NOTE**
This attribute is valid only when the **\** component is split.| -| navBarPosition9+ | [NavBarPosition](#navbarposition) | Position of the navigation bar.
Default value: **NavBarPosition.Start**
**NOTE**
This attribute is valid only when the **\** component is split.| -| mode9+ | [NavigationMode](#navigationmode) | Display mode of the navigation bar.
Default value: **NavigationMode.Auto**
At the default settings, the component adapts to a single column or two columns based on the component width.| -| backButtonIcon9+ | string \| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](ts-types.md#resource) | Back button icon on the navigation bar. The Back button in the title bar of the **\** component cannot be hidden.| +| navBarPosition9+ | [NavBarPosition](#navbarposition) | Position of the navigation bar.
Default value: **NavBarPosition.Start**
**NOTE**
This attribute is valid only when the **\** component is split.| +| mode9+ | [NavigationMode](#navigationmode) | Display mode of the navigation bar.
Default value: **NavigationMode.Auto**
At the default settings, the component adapts to a single column or two columns based on the component width.| +| backButtonIcon9+ | string \| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](ts-types.md#resource) | Back button icon on the navigation bar. The back button in the title bar of the **\** component cannot be hidden.| | hideNavBar9+ | boolean | Whether to hide the navigation bar. This attribute is valid only when **mode** is set to **NavigationMode.Split**.| +| navDestination10+ | builder: (name: string, param: unknown) => void | Creates a **\** component.
**NOTE**
The **builder** function is used, with the **name** and **param** parameters passsed in. In the builder, a layer of custom components can be included outside the **\** component. However, no attributes or events can be set for the custom components. Otherwise, only blank components are displayed.| + +## NavPathStack10+ + +Implements a navigation stack. + +### push10+ + +push(info: NavPathInfo): void + +Pushes the NavDestination page information specified by **info** to the stack. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------ | ----------------------- | ---- | --------------- | +| info | [NavPathInfo](#navpathinfo10) | Yes | Information about the navigation destination page. | + +### pushName10+ + +pushName(name: string, param: unknown): void + +Pushes the navigation destination page specified by **name** to the navigation stack. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------ | ----------------------- | ---- | --------------- | +| name | string | Yes | Name of the navigation destination page. | +| param | unknown | Yes | Parameter information of the navigation destination page. | + +### pop10+ + +pop(): NavPathInfo | undefined + +Pops the top element out of the navigation stack. + +**Return value** + +| Type | Description | +| ------ | -------- | +| NavPathInfo | Returns the information about the navigation destination page at the top of the stack.| +| undefined | Returns **undefined** if the navigation stack is empty.| + +### popTo10+ + +popTo(name: string): number + +Returns the navigation stack to the first navigation destination page that matches the value of **name**. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------ | ----------------------- | ---- | --------------- | +| name | string | Yes | Name of the navigation destination page. | + +**Return value** + +| Type | Description | +| ------ | -------- | +| number | Returns the index of the first navigation destination page that matches the value of **name** if it exists in the navigation stack; returns **-1** otherwise.| + +### popToIndex10+ + +popToIndex(index: number): void + +Returns the navigation stack to the navigation destination page that matches the value of **index**. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------ | ----------------------- | ---- | --------------- | +| index | number | Yes | Index of the navigation destination page. | + +### moveToTop10+ + +moveToTop(name: string): number + +Moves to the top of the navigation stack the first navigation destination page that matches the value of **name**. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------ | ----------------------- | ---- | --------------- | +| name | string | Yes | Name of the navigation destination page. | + +**Return value** + +| Type | Description | +| ------ | -------- | +| number | Returns the index of the first navigation destination page that matches the value of **name** if it exists in the navigation stack; returns **-1** otherwise.| + +### moveIndexToTop10+ + +moveIndexToTop(index: number): void + +Moves to the top of the navigation stack the navigation destination page that matches the value of **index**. +**Parameters** + +| Name | Type | Mandatory | Description | +| ------ | ----------------------- | ---- | --------------- | +| index | number | Yes | Index of the navigation destination page. | + +### clear10+ + +clear(): void + +Clears the navigation stack. + +### getAllPathName10+ + +getAllPathName(): Array + +Obtains the names of all navigation destination pages in the navigation stack. + +**Return value** + +| Type | Description | +| ------ | -------- | +| Array | Names of all navigation destination pages in the navigation stack.| + +### getParamByIndex10+ + +getParamByIndex(index: number): unknown | undefined + +Obtains the parameter information of the navigation destination page that matches the value of **index**. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------ | ----------------------- | ---- | --------------- | +| index | number | Yes | Index of the navigation destination page. | + +**Return value** + +| Type | Description | +| ------ | -------- | +| unknown | Returns the parameter information of the matching navigation destination page.| +| undefined | Returns **undefined** if the passed index is invalid.| + +### getParamByName10+ + +getParamByName(name: string): Array + +Obtains the parameter information of all the navigation destination pages that match the value of **name**. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------ | ----------------------- | ---- | --------------- | +| name | string | Yes | Name of the navigation destination page. | + +**Return value** + +| Type | Description | +| ------ | -------- | +| Array | Parameter information of all the matching navigation destination pages.| + +### getIndexByName10+ + +getIndexByName(name: string): Array + +Obtains the indexes information of all the navigation destination pages that match the value of **name**. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------ | ----------------------- | ---- | --------------- | +| name | string | Yes | Name of the navigation destination page. | + +**Return value** + +| Type | Description | +| ------ | -------- | +| Array | Indexes of all the matching navigation destination pages.| + +### size10+ + +size(): number + +Obtains the stack size. + +**Return value** + +| Type | Description | +| ------ | -------- | +| number | Stack size.| + +## NavPathInfo10+ + +Describes the navigation page information. + +### constructor + +constructor(name: string, param: unknown) + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------ | ----------------------- | ---- | --------------- | +| name | string | Yes | Name of the navigation destination page. | +| param | unknown | No | Parameter information of the navigation destination page. | ## NavigationMenuItem @@ -102,6 +313,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the > **NOTE** +> > Among the scrollable components, only **\** is supported. @@ -109,8 +321,8 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name | Description | | ---------------------------------------- | ---------------------------------------- | -| onTitleModeChange(callback: (titleMode: NavigationTitleMode) => void) | Triggered when **titleMode** is set to **NavigationTitleMode.Free** and the title bar mode changes as content scrolls.| -| onNavBarStateChange(callback: (isVisible: boolean) => void) | Triggered when the navigation bar visibility status changes. The value **true** means that the navigation bar is displayed, and **false** means the opposite.| +| onTitleModeChange(callback: (titleMode: NavigationTitleMode) => void) | Called when **titleMode** is set to **NavigationTitleMode.Free** and the title bar mode changes as content scrolls.| +| onNavBarStateChange(callback: (isVisible: boolean) => void) | Called when the navigation bar visibility status changes. The value **true** means that the navigation bar is displayed, and **false** means the opposite.| ## Example diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-navrouter.md b/en/application-dev/reference/arkui-ts/ts-basic-components-navrouter.md index 8d35b928f71ec67a97fa45c7815cdd0387f3b0dd..3c1eba412a0dbe734c74ba07e586ffd8bf81e9b6 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-navrouter.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-navrouter.md @@ -1,6 +1,6 @@ # NavRouter -The **\** component provides default logic for click response processing, eliminating the need for manual logic definition. +The **\** component provides default processing logic for responding to clicks, eliminating the need for manual logic definition. > **NOTE** > @@ -10,16 +10,56 @@ The **\** component provides default logic for click response process This component must contain two child components, the second of which must be **[\](ts-basic-components-navdestination.md)**. +> **NOTE** +> +> 1. If there is only one child component, the navigation to the **\** component does not work. +> 2. If there is only the **\** child component, the navigation is not performed. +> 3. If there are more than two child components, the excess child components are not displayed. +> 4. If the second child component is not **\**, the navigation does not work. + ## APIs -NavRouter() +**API 1**: NavRouter() + +**API 2**: NavRouter(value: RouteInfo)10+ + +Provides route information so that clicking the **\** component redirects the user to the specified navigation destination page. + + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------- | ----------------------------------- | ---- | ------------- | +| value | [RouteInfo](#routeinfo10) | No | Route information.| + +## Attributes + +In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported. + +| Name | Type | Description | +| ----------------------------- | ---------------------------------------- | ---------------------------------------- | +| mode | [NavRouteMode](#navroutemode) | Route mode used for redirection.
Default value: **NavRouteMode.PUSH_WITH_RECREATE**
| + +## RouteInfo10+ + +| Name | Type | Mandatory| Description | +| -------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| name | string | Yes | Name of the navigation destination page to be redirected to.| +| param | unknown | No | Parameter transferred during redirection.| + +## NavRouteMode +| Name | Description | +| ----- | ---------------- | +| PUSH_WITH_RECREATE | The new navigation destination page replaces the current one. The current page is destroyed, but the information about this page is retained in the navigation stack.| +| PUSH | The new navigation destination page overwrites the current one. The current page is not destroyed, and the information about this page is retained in the navigation stack.| +| REPLACE | The new navigation destination page replaces the current one. The current page is destroyed, and the information about this page is removed from the navigation stack.| ## Events -| Name | Description | -| ---------------------------------------- | ---------------------------------------- | -| onStateChange(callback: (isActivated: boolean) => void) | Invoked when the component activation status changes. The value **true** means that component is activated, and **false** means the opposite.
**NOTE**
After the user clicks **NavRouter**, if the **\** component is activated and the corresponding **\** child component loaded, **onStateChange(true)** is called. If the corresponding **\** child component is no longer displayed, **onStateChange(false)** is called. | +| Name | Description | +| ------------------------------------------------------- | ------------------------------------------------------------ | +| onStateChange(callback: (isActivated: boolean) => void) | Called when the component activation status changes. The value **true** means that component is activated, and **false** means the opposite.
**NOTE**
**onStateChange(true)** is called when the **\** component is activated and its **\** child component is loaded. **onStateChange(false)** is called when the **\** child component is not displayed.| ## Example diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-radio.md b/en/application-dev/reference/arkui-ts/ts-basic-components-radio.md index ee4275214beebdb3abd55b5eab9a8934f5f0226c..b76cb22dd303044b2e7456859da454cd815d957a 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-radio.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-radio.md @@ -31,7 +31,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name| Type| Description| | -------- | -------- | -------- | -| checked | boolean | Whether the radio button is selected.
Default value: **false**
Since API version 9, this API is supported in ArkTS widgets.| +| checked | boolean | Whether the radio button is selected.
Default value: **false**
Since API version 9, this API is supported in ArkTS widgets.
Since API version 10, this attribute supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| | radioStyle10+ | [RadioStyle](#radiostyle) | Style of the radio button in selected or deselected state.
Since API version 10, this API is supported in ArkTS widgets.| ## Events diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-rating.md b/en/application-dev/reference/arkui-ts/ts-basic-components-rating.md index 1b7b256be8889e800345b24a58d1b4d56afca3dc..efc15c08f744eb3cf89c534a2bc21d8397d729b2 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-rating.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-rating.md @@ -20,10 +20,10 @@ Since API version 9, this API is supported in ArkTS widgets. **Parameters** -| Name | Type | Mandatory | Description | -| --------- | ------- | ---- | ---------------------------------------- | -| rating | number | Yes | Value to rate.
Default value: **0**
Value range: [0, stars]
A value less than 0 evaluates to the value **0**. A value greater than the value of **stars** evaluates to the value of **stars**.| -| indicator | boolean | No | Whether the component is used only as an indicator and cannot be operated.
Default value: **false**
**NOTE**
When **indicator** is set to **true**, the default component height is 12.0 vp, and the component width is calculated as follows: Height x Value of **stars**.
When **indicator** is set to **false**, the default component height is 28.0 vp, and the component width is calculated as follows: Height x Value of **stars**.| +| Name | Type| Mandatory| Description | +| --------- | -------- | ---- | ------------------------------------------------------------ | +| rating | number | Yes | Value to rate.
Default value: **0**
Value range: [0, stars]
A value less than 0 evaluates to the value **0**. A value greater than the value of **stars** evaluates to the value of **stars**.
Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| +| indicator | boolean | No | Whether the component is used only as an indicator and cannot be operated.
Default value: **false**
**NOTE**
When **indicator** is set to **true**, the default component height is 12.0 vp, and the component width is calculated as follows: Height x Value of **stars**.
When **indicator** is set to **false**, the default component height is 28.0 vp, and the component width is calculated as follows: Height x Value of **stars**.| ## Attributes diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-search.md b/en/application-dev/reference/arkui-ts/ts-basic-components-search.md index 9ad4212ae53e93d286b2bdb4816bfa84b85ac39c..16a4df18ac1ff7b20ba22b935418ddeb710f3bab 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-search.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-search.md @@ -20,7 +20,7 @@ Search(options?: { value?: string; placeholder?: ResourceStr; icon?: string; con | ----------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | | value | string | No | Text input in the search text box.
Since API version 10, this parameter supports two-way binding through [$$](../../quick-start/arkts-two-way-sync.md).| | placeholder | [ResourceStr](ts-types.md#resourcestr)10+ | No | Text displayed when there is no input. | -| icon | string | No | Path to the search icon. By default, the system search icon is used.
For details about the supported image types, see [Image](ts-basic-components-image.md).| +| icon | string | No | Path to the search icon. By default, the system search icon is used.
**NOTE**
The icon data source can be a local or online image.
- The supported formats include PNG, JPG, BMP, SVG, GIF, and pixelmap.
- The Base64 string is supported in the following format: data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data], where [base64 data] is a Base64 string.| | controller | SearchController | No | Controller of the **\** component. | ## Attributes diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-select.md b/en/application-dev/reference/arkui-ts/ts-basic-components-select.md index 8bb39f7eaa9cad64eb6c56936a42ddd88eaa75c6..06ea2a8cfc12b54048c6a91c70313fcc48c876f9 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-select.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-select.md @@ -23,24 +23,35 @@ Select(options: Array\<[SelectOption](#selectoption)\>) ## Attributes +In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported. + | Name | Type | Description | | ----------------------- | ------------------------------------- | --------------------------------------------- | -| selected | number | Index of the initial selected option in the drop-down list box. The index of the first option is **0**.
If this attribute is not set, the default value **-1** is used, indicating that no option is selected.| -| value | string | Text of the drop-down button. | -| font | [Font](ts-types.md#font) | Text font of the drop-down button. | -| fontColor | [ResourceColor](ts-types.md#resourcecolor) | Text color of the drop-down button. | -| selectedOptionBgColor | [ResourceColor](ts-types.md#resourcecolor) | Background color of the selected option in the drop-down list box. | -| selectedOptionFont | [Font](ts-types.md#font) | Text font of the selected option in the drop-down list box. | -| selectedOptionFontColor | [ResourceColor](ts-types.md#resourcecolor) | Text color of the selected option in the drop-down list box. | -| optionBgColor | [ResourceColor](ts-types.md#resourcecolor) | Background color of an option in the drop-down list box. | -| optionFont | [Font](ts-types.md#font) | Text font of an option in the drop-down list box. | -| optionFontColor | [ResourceColor](ts-types.md#resourcecolor) | Text color of an option in the drop-down list box. | +| selected | number | Index of the initial selected option in the drop-down list box. The index of the first option is **0**.
If this attribute is not set, the default value **-1** is used, indicating that no option is selected.
Since API version 10, this attribute supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| +| value | string | Text of the drop-down button. By default, it will be replaced by the content of the selected option.
Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| +| font | [Font](ts-types.md#font) | Text font of the drop-down button.
Default value:
{
size: '16fp',
weight: FontWeight.Medium
} | +| fontColor | [ResourceColor](ts-types.md#resourcecolor) | Text color of the drop-down button.
Default value: **'\#E6FFFFFF'**| +| selectedOptionBgColor | [ResourceColor](ts-types.md#resourcecolor) | Background color of the selected option in the drop-down list box.
Default value: **'\#33007DFF'**| +| selectedOptionFont | [Font](ts-types.md#font) | Text font of the selected option in the drop-down list box.
Default value:
{
size: '16fp',
weight: FontWeight.Regular
} | +| selectedOptionFontColor | [ResourceColor](ts-types.md#resourcecolor) | Text color of the selected option in the drop-down list box.
Default value: **'\#ff007dff'**| +| optionBgColor | [ResourceColor](ts-types.md#resourcecolor) | Background color of an option in the drop-down list box.
Default value: **'\#ffffffff'**| +| optionFont | [Font](ts-types.md#font) | Text font of an option in the drop-down list box.
Default value:
{
size: '16fp',
weight: FontWeight.Regular
} | +| optionFontColor | [ResourceColor](ts-types.md#resourcecolor) | Text color of an option in the drop-down list box.
Default value: **'\#ff182431'**| +| space10+ | [Length](ts-types.md#length) | Spacing between the text and arrow of an option.
**NOTE**
This attribute cannot be set in percentage.| +| arrowPosition10+ | [ArrowPosition](#arrowposition10) | Alignment between the text and arrow of an option.
Default value: **ArrowPosition.END**| + +## ArrowPosition10+ + +| Name | Description | +| ------------------- | ------------------ | +| END10+ | The text is in front of the arrow.| +| START10+ | The arrow is in front of the text.| ## Events -| Name | Description | -| ----------------------------------------------------------- | ------------------------------------------------------------ | -| onSelect(callback: (index: number, value?: string) => void) | Invoked when an option in the drop-down list box is selected.
**index**: index of the selected option.
**value**: value of the selected option. | +| Name | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| onSelect(callback: (index: number, value?: string) => void) | Invoked when an option in the drop-down list box is selected.
**index**: index of the selected option.
**value**: value of the selected option.| ## Example @@ -49,20 +60,28 @@ Select(options: Array\<[SelectOption](#selectoption)\>) @Entry @Component struct SelectExample { + @State text: string = "TTTTT" + @State index: number = 2 + @State space: number = 8 + @State arrowPosition: ArrowPosition = ArrowPosition.END build() { Column() { Select([{ value: 'aaa', icon: "/common/public_icon.svg" }, { value: 'bbb', icon: "/common/public_icon.svg" }, { value: 'ccc', icon: "/common/public_icon.svg" }, { value: 'ddd', icon: "/common/public_icon.svg" }]) - .selected(2) - .value('TTTTT') + .selected(this.index) + .value(this.text) .font({ size: 16, weight: 500 }) .fontColor('#182431') .selectedOptionFont({ size: 16, weight: 400 }) .optionFont({ size: 16, weight: 400 }) - .onSelect((index: number) => { + .space(this.space) + .arrowPosition(this.arrowPosition) + .onSelect((index:number, text: string)=>{ console.info('Select:' + index) + this.index = index; + this.text = text; }) }.width('100%') } diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-slider.md b/en/application-dev/reference/arkui-ts/ts-basic-components-slider.md index efc17049a39e3a97e1ae038ac7f18c7b3b255fd2..4958173d84c8894bd661ddfd0cdfd05f9041b251 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-slider.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-slider.md @@ -22,7 +22,7 @@ Since API version 9, this API is supported in ArkTS widgets. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| value | number | No| Current progress.
Default value: **0**| +| value | number | No| Current progress.
Default value: min
Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| | min | number | No| Minimum value.
Default value: **0**| | max | number | No| Maximum value.
Default value: **100**
**NOTE**
If the value of **min** is greater than or equal to the value of **max**, the default value **0** is used for **min** and the default value **100** is used for **max**.
If the value is not within the [min, max] range, the value of **min** or **max**, whichever is closer.| | step | number | No| Step of the slider.
Default value: **1**
Value range: [0.01, max]
**NOTE**
If this parameter is set to a value less than 0 or a percentage, the default value is used.| diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-stepper.md b/en/application-dev/reference/arkui-ts/ts-basic-components-stepper.md index 5b29d3de61a0454ec72890a778ffd61420fe3ad9..fac942c34194b86dbb92ce27f21a85c57f5fa409 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-stepper.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-stepper.md @@ -22,7 +22,7 @@ Stepper(value?: { index?: number }) | Name| Type| Mandatory | Description| | ------| -------- | --------------- | -------- | -| index | number | No| Index of the **\** that is currently displayed.
Default value: **0**| +| index | number | No| Index of the **\** that is currently displayed.
Default value: **0**
Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| ## Attributes diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-text.md b/en/application-dev/reference/arkui-ts/ts-basic-components-text.md index 2c6e87d2812bb855b685d3176c5f1fed68eee3e6..9a52243939d77e88ba48b793830784aa51ebc608 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-text.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-text.md @@ -26,28 +26,31 @@ Since API version 9, this API is supported in ArkTS widgets. ## Attributes -In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported. +In addition to the [universal attributes](ts-universal-attributes-size.md) and [universal text attributes](ts-universal-attributes-text-style.md), the following attributes are supported. | Name | Type | Description | | ----------------------- | ----------------------------------- | ------------------------------------------- | -| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | Horizontal alignment mode of the text.
Default value: **TextAlign.Start**
**NOTE**
The text takes up the full width of the **\** component. To set the vertical alignment for the text, use the [align](ts-universal-attributes-location.md) attribute.
Since API version 9, this API is supported in ArkTS widgets.| -| textOverflow | {overflow: [TextOverflow](ts-appendix-enums.md#textoverflow)} | Display mode when the text is too long.
Default value: **{overflow: TextOverflow.Clip}**
**NOTE**
Text is clipped at the transition between words. To clip text in the middle of a word, add **\u200B** between characters.
If **overflow** is set to **TextOverflow.None**, **TextOverflow.Clip**, or **TextOverflow.Ellipsis**, this attribute must be used with **maxLines**. Otherwise, the setting does not take effect. If **overflow** is set to **TextOverflow.Marquee**, the text scrolls in a line, and therefore **maxLines** does not need to be set.
Since API version 9, this API is supported in ArkTS widgets. | -| maxLines | number | Maximum number of lines in the text.
Default value: **Infinity**
**NOTE**
By default, text is automatically folded. If this attribute is specified, the text will not exceed the specified number of lines. If there is extra text, you can use **textOverflow** to specify how it is displayed.
Since API version 9, this API is supported in ArkTS widgets.| +| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | Horizontal alignment mode of the text.
Default value: **TextAlign.Start**
**NOTE**
The text takes up the full width of the **\** component. To set vertical alignment for the text, use the [align](ts-universal-attributes-location.md) attribute. The **align** attribute alone does not control the horizontal position of the text. In other words, **Alignment.TopStart**, **Alignment.Top**, and **Alignment.TopEnd** produce the same effect, top-aligning the text; **Alignment.Start**, **Alignment.Center**, and **Alignment.End** produce the same effect, centered-aligning the text vertically; **Alignment.BottomStart**, **Alignment.Bottom**, and **Alignment.BottomEnd** produce the same effect, bottom-aligning the text. Yet, it can work with the **textAlign** attribute to jointly determine the horizontal position of the text.
Since API version 9, this API is supported in ArkTS widgets.| +| textOverflow | {overflow: [TextOverflow](ts-appendix-enums.md#textoverflow)} | Display mode when the text is too long.
Default value: **{overflow: TextOverflow.Clip}**
**NOTE**
Text is clipped at the transition between words. To clip text in the middle of a word, add **\u200B** between characters.
If **overflow** is set to **TextOverflow.None**, **TextOverflow.Clip**, or **TextOverflow.Ellipsis**, this attribute must be used with **maxLines**. Otherwise, the setting does not take effect. **TextOverflow.None** produces the same effect as **TextOverflow.Clip**. If **overflow** is set to **TextOverflow.Marquee**, the text scrolls in a line, and neither **maxLines** nor **copyOption** takes effect.
Since API version 9, this API is supported in ArkTS widgets.| +| maxLines | number | Maximum number of lines in the text.
Default value: **Infinity**
**NOTE**
By default, text is automatically folded. If this attribute is specified, the text will not exceed the specified number of lines. If there is extra text, you can use **textOverflow** to specify how it is displayed.
Since API version 9, this API is supported in ArkTS widgets. | | lineHeight | string \| number \| [Resource](ts-types.md#resource) | Text line height. If the value is less than or equal to **0**, the line height is not limited and the font size is adaptive. If the value of the number type, the unit fp is used.
Since API version 9, this API is supported in ArkTS widgets.| | decoration | {
type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype),
color?: [ResourceColor](ts-types.md#resourcecolor)
} | Style and color of the text decorative line.
Default value: {
type: TextDecorationType.None,
color: Color.Black
}
Since API version 9, this API is supported in ArkTS widgets.| | baselineOffset | number \| string | Baseline offset of the text. The default value is **0**.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**

If this attribute is set to a percentage, the default value is used.| -| letterSpacing | number \| string | Letter spacing.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**

If this attribute is set to a percentage, the default value is used.| +| letterSpacing | number \| string | Letter spacing.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If this attribute is set to a percentage, the default value is used.
If this attribute is set to a negative value, the letters will overlap each other. | | minFontSize | number \| string \| [Resource](ts-types.md#resource) | Minimum font size.
For the setting to take effect, this attribute must be used together with **maxFontSize**, **maxLines**, or layout constraint settings.
Since API version 9, this API is supported in ArkTS widgets. | | maxFontSize | number \| string \| [Resource](ts-types.md#resource) | Maximum font size.
For the setting to take effect, this attribute must be used together with **minFontSize**, **maxLines**, or layout constraint settings.
Since API version 9, this API is supported in ArkTS widgets. | | textCase | [TextCase](ts-appendix-enums.md#textcase) | Text case.
Default value: **TextCase.Normal**
Since API version 9, this API is supported in ArkTS widgets.| | copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.
Default value: **CopyOptions.None**
This API is supported in ArkTS widgets.| +| draggable9+ | boolean | Drag effect of the selected text.
This attribute cannot be used with the [onDragStart](ts-universal-events-drag-drop.md) event.
It must be used with **copyOption** to enable the selected text to be dragged and copied.
Default value: **false**| | textShadow10+ | [ShadowOptions](ts-universal-attributes-image-effect.md#shadowoptions) | Text shadow.| -| heightAdaptivePolicy10+ | [TextHeightAdaptivePolicy](ts-appendix-enums.md#TextHeightAdaptivePolicy10) | How the adaptive height is determined for the text.| +| heightAdaptivePolicy10+ | [TextHeightAdaptivePolicy](ts-appendix-enums.md#textheightadaptivepolicy10) | How the adaptive height is determined for the text.
Default value: **TextHeightAdaptivePolicy.MAX_LINES_FIRST**
**NOTE**
When this attribute is set to **TextHeightAdaptivePolicy.MAX_LINES_FIRST**, the **maxLines** attribute takes precedence for adjusting the text height. If the **maxLines** setting results in a layout beyond the layout constraints, the text will shrink to a font size between `minFontSize` and `maxFontSize` to allow for more content to be shown.
When this attribute is set to **TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST**, the **minFontSize** attribute takes precedence for adjusting the text height. If the text can fit in one line with the `minFontSize` setting, the text will enlarge to the largest possible font size between `minFontSize` and `maxFontSize`.
When this attribute is set to **TextHeightAdaptivePolicy.LAYOUT_CONSTRAINT_FIRST**, the layout constraints take precedence for adjusting the text height. If the resultant layout is beyond the layout constraints, the text will shrink to a font size between `minFontSize` and `maxFontSize` to respect the layout constraints. If the layout still exceeds the layout constraints after the font size is reduced to **minFontSize**, the lines that exceed the layout constraints are deleted. | | textIndent10+ | number \| string | Indentation of the first line.
Default value: **0**| > **NOTE** > > The **\** component cannot contain both the text and the child component **\** or **\**. If both of them exist, only the content in **\** or **\** is displayed. +> +> For the **\** component, the default value of the [clip](ts-universal-attributes-sharp-clipping.md) attribute is **true**. ## Events @@ -112,7 +115,7 @@ struct TextExample1 { Text('TextOverflow+maxLines').fontSize(9).fontColor(0xCCCCCC) // Clip the text when the value of maxLines is exceeded. Text('This is the setting of textOverflow to Clip text content This is the setting of textOverflow to None text content. This is the setting of textOverflow to Clip text content This is the setting of textOverflow to None text content.') - .textOverflow({ overflow: TextOverflow.None }) + .textOverflow({ overflow: TextOverflow.Clip }) .maxLines(1) .fontSize(12) .border({ width: 1 }) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md b/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md index 244b6990bba8d9ccc0817e5eb96b8769d38530df..f3af7b67cb3eb17ada3be85777566ce874b1a72e 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md @@ -21,7 +21,7 @@ TextArea(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Tex | Name | Type | Mandatory | Description | | ----------------------- | ---------------------------------------- | ---- | -------------- | | placeholder | [ResourceStr](ts-types.md#resourcestr) | No | Placeholder text displayed when there is no input. It is not displayed once there is any input. | -| text | [ResourceStr](ts-types.md#resourcestr) | No | Current text input.
If the component has [stateStyles](ts-universal-attributes-polymorphic-style.md) or any other attribute that may trigger updating configured, you are advised to bind the state variable to the text in real time through the **onChange** event,
so as to prevent display errors when the component is updated. | +| text | [ResourceStr](ts-types.md#resourcestr) | No | Current text input.
If the component has [stateStyles](ts-universal-attributes-polymorphic-style.md) or any other attribute that may trigger updating configured, you are advised to bind the state variable to the text in real time through the **onChange** event,
so as to prevent display errors when the component is updated.
Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| | controller8+ | [TextAreaController](#textareacontroller8) | No | Text area controller.| @@ -36,7 +36,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | textAlign | [TextAlign](ts-appendix-enums.md#textalign) | Horizontal alignment of the text.
Default value: **TextAlign.Start**| | caretColor | [ResourceColor](ts-types.md#resourcecolor) | Color of the caret in the text box. | | inputFilter8+ | {
value: [ResourceStr](ts-types.md#resourcestr),
error?: (value: string) => void
} | Regular expression for input filtering. Only inputs that comply with the regular expression can be displayed. Other inputs are filtered out. The specified regular expression can match single characters, but not strings.
- **value**: regular expression to set.
- **error**: filtered-out content to return when regular expression matching fails.| -| copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.
If this attribute is set to **CopyOptions.None**, the paste operation is allowed, but not the copy or cut operation.| +| copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.
If this attribute is set to **CopyOptions.None**, the paste operation is allowed, but the copy and cut operations are not.| > **NOTE** > @@ -47,13 +47,13 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the In addition to the [universal events](ts-universal-events-click.md), the following events are supported. -| Name | Description | +| Name | Description | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| onChange(callback: (value: string) => void) | Triggered when the input in the text box changes.
- **value**: text entered. | -| onEditChange(callback: (isEditing: boolean) => void)10+ | Triggered when the input status changes. When the cursor is placed in the text box, it is in the editing state. Otherwise, it is in the non-editing state. If the value of **isEditing** is **true**, text input is in progress. | -| onCopy8+(callback:(value: string) => void) | Triggered when the copy button on the pasteboard, which displays when the text box is long pressed, is clicked.
- **value**: text to be copied. | -| onCut8+(callback:(value: string) => void) | Triggered when the cut button on the pasteboard, which displays when the text box is long pressed, is clicked.
- **value**: text to be cut. | -| onPaste8+(callback:(value: string) => void) | Triggered when the paste button on the pasteboard, which displays when the text box is long pressed, is clicked.
- **value**: text to be pasted. | +| onChange(callback: (value: string) => void) | Triggered when the input in the text box changes.
- **value**: text entered.| +| onEditChange(callback: (isEditing: boolean) => void)10+ | Triggered when the input status changes. When the cursor is placed in the text box, it is in the editing state. Otherwise, it is in the non-editing state. If the value of **isEditing** is **true**, text input is in progress.| +| onCopy8+(callback:(value: string) => void) | Triggered when the copy button on the pasteboard, which displays when the text box is long pressed, is clicked.
- **value**: text to be copied.| +| onCut8+(callback:(value: string) => void) | Triggered when the cut button on the pasteboard, which displays when the text box is long pressed, is clicked.
- **value**: text to be cut.| +| onPaste8+(callback:(value: string) => void) | Triggered when the paste button on the pasteboard, which displays when the text box is long pressed, is clicked.
- **value**: text to be pasted.| ## TextAreaController8+ @@ -81,14 +81,14 @@ Sets the position of the caret. setTextSelection(selectionStart: number, selectionEnd: number): void -Sets the text selection range. +Sets the text selection range and highlights the selected text when the component is focused. This API works only when the value of **selectionStart** is less than that of **selectionEnd**. **Parameters** -| Name | Type| Mandatory| Description | -| -------------- | -------- | ---- | ------------------ | -| selectionStart | number | Yes | Start of the selection range.| -| selectionEnd | number | Yes | End of the selection range.| +| Name | Type| Mandatory| Description | +| -------------- | -------- | ---- | ------------------------------------------------------------ | +| selectionStart | number | Yes | Start position of the text selection range. The start position of text in the text box is 0.
A value less than 0 evaluates to the value **0**. A value greater than the maximum text length evaluates to the maximum text length.
| +| selectionEnd | number | Yes | End position of the text selection range.
A value less than 0 evaluates to the value **0**. A value greater than the maximum text length evaluates to the maximum text length.
| ## Example diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md b/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md index cf42e030a17593607b5d4ff4a5c0711ed9dc22ad..588f88057abe66a553dd25dc8337503b8786e65a 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md @@ -21,7 +21,7 @@ TextInput(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Te | Name | Type | Mandatory | Description | | ----------------------- | ---------------------------------------- | ---- | --------------- | | placeholder | [ResourceStr](ts-types.md#resourcestr) | No | Placeholder text displayed when there is no input. | -| text | [ResourceStr](ts-types.md#resourcestr) | No | Current text input.
If the component has [stateStyles](ts-universal-attributes-polymorphic-style.md) or any other attribute that may trigger updating configured, you are advised to bind the state variable to the text in real time through the **onChange** event,
so as to prevent display errors when the component is updated. | +| text | [ResourceStr](ts-types.md#resourcestr) | No | Current text input.
If the component has [stateStyles](ts-universal-attributes-polymorphic-style.md) or any other attribute that may trigger updating configured, you are advised to bind the state variable to the text in real time through the **onChange** event,
so as to prevent display errors when the component is updated.
Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| | controller8+ | [TextInputController](#textinputcontroller8) | No | Text input controller.| @@ -42,7 +42,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | showPasswordIcon9+ | boolean | Whether to display the show password icon at the end of the password text box.
Default value: **true**| | style9+ | [TextInputStyle](#textinputstyle9) | Text input style.
Default value: **TextInputStyle.Default**| | textAlign9+ | [TextAlign](ts-appendix-enums.md#textalign) | Alignment mode of the text in the text box.
Default value: **TextAlign.Start** | -| selectedBackgroundColor10+ | [ResourceColor](ts-types.md#resourcecolor) | Background color of the selected text.| +| selectedBackgroundColor10+ | [ResourceColor](ts-types.md#resourcecolor) | Background color of the selected text.
If the opacity is not set, the color is opaque. For example, **0x80000000** indicates black with 50% opacity.| | caretStyle10+ | {
width: [Length](ts-types.md#length)
} | Caret style. | | caretPosition10+ | number | Caret position.| @@ -81,15 +81,15 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the In addition to the [universal events](ts-universal-events-click.md), the following events are supported. -| Name | Description | +| Name | Description | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| onChange(callback: (value: string) => void) | Triggered when the input changes.
**value**: text content.
This event is triggered when any of the following conditions is met:
1. Keyboard input is received.
2. Paste and cut is performed.
3. Ctrl+V is pressed. | -| onSubmit(callback: (enterKey: EnterKeyType) => void) | Triggered when the Enter key on the keyboard is pressed. The return value is the current type of the Enter key.
**enterKeyType**: type of the Enter key. For details, see [EnterKeyType](#enterkeytype). | -| onEditChanged(callback: (isEditing: boolean) => void)(deprecated) | Triggered when the input status changes. Since API version 8, **onEditChange** is recommended. | -| onEditChange(callback: (isEditing: boolean) => void)8+ | Triggered when the input status changes. When the cursor is placed in the text box, it is in the editing state. Otherwise, it is in the non-editing state. If the value of **isEditing** is **true**, text input is in progress. | -| onCopy(callback:(value: string) => void)8+ | Triggered when the copy button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be copied. | -| onCut(callback:(value: string) => void)8+ | Triggered when the cut button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be cut. | -| onPaste(callback:(value: string) => void)8+ | Triggered when the paste button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be pasted. | +| onChange(callback: (value: string) => void) | Triggered when the input changes.
**value**: text content.
This event is triggered when any of the following conditions is met:
1. Keyboard input is received.
2. Paste and cut is performed.
3. Ctrl+V is pressed.| +| onSubmit(callback: (enterKey: EnterKeyType) => void) | Triggered when the Enter key on the keyboard is pressed. The return value is the current type of the Enter key.
**enterKeyType**: type of the Enter key. For details, see [EnterKeyType](#enterkeytype).| +| onEditChanged(callback: (isEditing: boolean) => void)(deprecated) | Triggered when the input status changes. Since API version 8, **onEditChange** is recommended.| +| onEditChange(callback: (isEditing: boolean) => void)8+ | Triggered when the input status changes. When the cursor is placed in the text box, it is in the editing state. Otherwise, it is in the non-editing state. If the value of **isEditing** is **true**, text input is in progress.| +| onCopy(callback:(value: string) => void)8+ | Triggered when the copy button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be copied.| +| onCut(callback:(value: string) => void)8+ | Triggered when the cut button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be cut.| +| onPaste(callback:(value: string) => void)8+ | Triggered when the paste button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be pasted.| ## TextInputController8+ diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-timepicker.md b/en/application-dev/reference/arkui-ts/ts-basic-components-timepicker.md index 831d427ccc5e558a6119408f105a0277a888323b..633e92d812e4aca2db4c68842a0e6745732c52b1 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-timepicker.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-timepicker.md @@ -20,9 +20,9 @@ Creates a time picker, which is in 24-hour format by default. **Parameters** -| Name | Type| Mandatory | Description | -| -------- | ---- | ---- | ------------------------ | -| selected | Date | No | Time of the selected item.
Default value: current system time| +| Name | Type| Mandatory| Description | +| -------- | -------- | ---- | ------------------------------------------------------------ | +| selected | Date | No | Time of the selected item.
Default value: current system time
Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| ## Attributes diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-toggle.md b/en/application-dev/reference/arkui-ts/ts-basic-components-toggle.md index 191c4839533806a43c41e2c27f500dd10ca18e8d..7a78929dca57da1194d9454042286393f8a773b2 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-toggle.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-toggle.md @@ -22,7 +22,7 @@ Since API version 9, this API is supported in ArkTS widgets. | Name| Type| Mandatory | Description | | ---- | ---------- | -----| -------------- | | type | [ToggleType](#toggletype) | Yes | Type of the toggle.| -| isOn | boolean | No | Whether the toggle is turned on. The value **true** means that the toggle is turned on, and **false** means the opposite.
Default value: **false**| +| isOn | boolean | No | Whether the toggle is turned on. The value **true** means that the toggle is turned on, and **false** means the opposite.
Default value: **false**
Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| ## ToggleType @@ -31,9 +31,9 @@ Since API version 9, this API is supported in ArkTS widgets. | Name | Description | | -------- | ---------------- | -| Checkbox | Check box type.
**NOTE**
The default value of the universal attribute [margin](ts-universal-attributes-size.md) is as follows:
{
top: 12 vp,
right: 12 vp,
bottom: 12 vp,
left: 12 vp
} | +| Checkbox | Check box type.
**NOTE**
The default value of the universal attribute [margin](ts-universal-attributes-size.md) is as follows:
{
top: 12 px,
right: 12 px,
bottom: 12 px,
left: 12 px
} | | Button | Button type. The set string, if any, will be displayed inside the button. | -| Switch | Switch type.
**NOTE**
The default value of the universal attribute [margin](ts-universal-attributes-size.md) is as follows:
{
top: 14 vp,
right:6 vp,
bottom: 6 vp,
left: 14 vp
} | +| Switch | Switch type.
**NOTE**
The default value of the universal attribute [margin](ts-universal-attributes-size.md) is as follows:
{
top: 6px,
right: 14px,
bottom: 6 px,
left: 14 px
} | ## Attributes diff --git a/en/application-dev/reference/arkui-ts/ts-components-canvas-canvasgradient.md b/en/application-dev/reference/arkui-ts/ts-components-canvas-canvasgradient.md index 35211ab1665ca4dbee56199a3c449ae9ff2a8a0b..8801033ff3864cef03d0271db00a8d1dfb92d3da 100644 --- a/en/application-dev/reference/arkui-ts/ts-components-canvas-canvasgradient.md +++ b/en/application-dev/reference/arkui-ts/ts-components-canvas-canvasgradient.md @@ -22,7 +22,7 @@ Since API version 9, this API is supported in ArkTS widgets. | Name | Type | Mandatory | Default Value | Description | | ------ | ------ | ---- | --------- | ---------------------------- | | offset | number | Yes | 0 | Relative position of the gradient stop along the gradient vector. The value ranges from 0 to 1.| -| color | string | Yes | '#ffffff' | Gradient color to set. | +| color | string | Yes | '#ffffff' | Gradient color to set. For details about the color notation, see the description of the string type in [ResourceColor](ts-types.md#resourcecolor). | **Example** diff --git a/en/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md b/en/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md index ed5df7b82fd0f73742ca53af4920172c90398fe5..df19454da7610c2d52acfd958c7c35e0e3073e33 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md +++ b/en/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md @@ -21,7 +21,7 @@ AlphabetIndexer(value: {arrayValue: Array<string>, selected: number}) | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | arrayValue | Array<string> | Yes| Array of strings to be displayed in the alphabetic index bar. The value cannot be null.| -| selected | number | Yes | Index of the initially selected item. If the value exceeds the value range, the default value 0 is used. | +| selected | number | Yes | Index of the initially selected item. If the value exceeds the value range, the default value 0 is used.
Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| ## Attributes @@ -38,9 +38,9 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | selectedFont | [Font](ts-types.md#font) | Font style of the selected text.
Default value:
{
size:10,
style:FontStyle.Normal,
weight:FontWeight.Normal,
family:'HarmonyOS Sans'
} | | popupFont | [Font](ts-types.md#font) | Font style of the pop-up text.
Default value:
{
size:10,
style:FontStyle.Normal,
weight:FontWeight.Normal,
family:'HarmonyOS Sans'
} | | font | [Font](ts-types.md#font) | Default font style of the alphabetic index bar.
Default value:
{
size:10,
style:FontStyle.Normal,
weight:FontWeight.Normal,
family:'HarmonyOS Sans'
} | -| itemSize | string \| number | Size of an item in the alphabetic index bar. The item is a square, and the side length needs to be set. This attribute cannot be set to a percentage.
Default value: **24.0** | +| itemSize | string \| number | Size of an item in the alphabetic index bar. The item is a square, and the side length needs to be set. This attribute cannot be set to a percentage.
Default value: **24.0**
Unit: vp| | alignStyle | value: [IndexerAlign](#indexeralign),
offset10+?: [Length](ts-types.md#length) | Alignment style of the alphabetic index bar.
**value**: alignment of the alphabetic index bar with the pop-up window, which can be left-aligned or right-aligned.
Default value: **IndexerAlign.Right**
**offset**: spacing between the pop-up window and the alphabetic index bar. A value greater than or equal to 0 is valid. If this attribute is set to a value less than 0 or is not set, the spacing is the same as **popupPosition.x**.| -| selected | number | Index of the selected item.
Default value: **0**| +| selected | number | Index of the selected item.
Default value: **0**
Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| | popupPosition | [Position](ts-types.md#position8) | Position of the pop-up window relative to the center of the indexer bar's top border.
Default value: **{x:96.0, y:48.0}**| | popupSelectedColor10+ | [ResourceColor](ts-types.md#resourcecolor) | Color of the selected text excluding the initial letter in the pop-up window.
Default value: **#FF182431**| | popupUnselectedColor10+ | [ResourceColor](ts-types.md#resourcecolor) | Color of the unselected text in the pop-up window.
Default value: **#FF182431**| @@ -56,7 +56,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ## Events -Only the following events are supported. +In addition to the [universal events](ts-universal-events-click.md), the following events are supported. | Name| Description| | -------- | -------- | diff --git a/en/application-dev/reference/arkui-ts/ts-container-panel.md b/en/application-dev/reference/arkui-ts/ts-container-panel.md index 14fe7d33b3a061db80c361c620bd1010c4624806..bc38624a2bfaa00817283a74515a1ecfd647f2cd 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-panel.md +++ b/en/application-dev/reference/arkui-ts/ts-container-panel.md @@ -33,7 +33,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name| Type| Description| | -------- | -------- | -------- | | type | [PanelType](#paneltype)| Type of the panel.
Default value: **PanelType.Foldable**| -| mode | [PanelMode](#panelmode) | Initial status of the panel.
Default value for the Minibar type: **PanelMode.Mini**
Default value for other types: **PanelMode.Half**
Since API version 10, this attribute supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables. | +| mode | [PanelMode](#panelmode) | Initial status of the panel.
Default value for the Minibar type: **PanelMode.Mini**
Default value for other types: **PanelMode.Half**
Since API version 10, this attribute supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| | dragBar | boolean | Whether to enable a drag bar. The value **true** means that the drag bar will be displayed, and **false** means the opposite.
Default value: **true**| | fullHeight | string \| number | Panel height in the **PanelMode.Full** mode.
Default value: main axis height of the panel minus 8 vp
**NOTE**
This attribute cannot be set in percentage.| | halfHeight | string \| number | Panel height in the **PanelMode.Half** mode.
Default value: half of the main axis height of the panel
**NOTE**
This attribute cannot be set in percentage.| diff --git a/en/application-dev/reference/arkui-ts/ts-container-swiper.md b/en/application-dev/reference/arkui-ts/ts-container-swiper.md index fdf1227af8f71876d7d1207bf2f205e3fcc053e3..6900431ed2d867680b5f6135325a1c6565b9a430 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-swiper.md +++ b/en/application-dev/reference/arkui-ts/ts-container-swiper.md @@ -44,7 +44,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | displayMode | SwiperDisplayMode | Mode in which elements are displayed along the main axis. This attribute takes effect only when **displayCount** is not set.
Default value: **SwiperDisplayMode.Stretch**| | cachedCount8+ | number | Number of child components to be cached.
Default value: **1**
**NOTE**
**cachedCount** has caching optimized. You are advised not to use it together with [LazyForEach](../../quick-start/arkts-rendering-control-lazyforeach.md).| | disableSwipe8+ | boolean | Whether to disable the swipe feature.
Default value: **false** | -| curve8+ | [Curve](ts-appendix-enums.md#curve) \| string | Animation curve. The ease-in/ease-out curve is used by default. For details about common curves, see [Curve](ts-appendix-enums.md#curve). You can also create custom curves (interpolation curve objects) by using the API provided by the [interpolation calculation](../apis/js-apis-curve.md) module.
Default value: **Curve.Ease**| +| curve8+ | [Curve](ts-appendix-enums.md#curve) \| string | Animation curve. The ease-in/ease-out curve is used by default. For details about common curves, see [Curve](ts-appendix-enums.md#curve). You can also create custom curves (interpolation curve objects) by using the API provided by the [interpolation calculation](../apis/js-apis-curve.md) module.
Default value: **Curve.Linear**| | indicatorStyle8+ | {
left?: [Length](ts-types.md#length),
top?: [Length](ts-types.md#length),
right?: [Length](ts-types.md#length),
bottom?: [Length](ts-types.md#length),
size?: [Length](ts-types.md#length),
mask?: boolean,
color?: [ResourceColor](ts-types.md),
selectedColor?: [ResourceColor](ts-types.md)
} | Style of the navigation point indicator.
\- **left**: distance between the navigation point indicator and the left edge of the **\** component.
\- **top**: distance between the navigation point indicator and the top edge of the **\** component.
\- **right**: distance between the navigation point indicator and the right edge of the **\** component.
\- **bottom**: distance between the navigation point indicator and the bottom edge of the **\** component.
\- **size**: diameter of the navigation point indicator.
\- **mask**: whether to enable the mask for the navigation point indicator.
\- **color**: color of the navigation point indicator.
\- **selectedColor**: color of the selected navigation dot.| | displayCount8+ | number \| string | Number of elements to display per page.
Default value: **1**
**NOTE**
If the value is of the string type, it can only be **'auto'**, whose display effect is the same as that of **SwiperDisplayMode.AutoLinear**.
If the value is of the number type, child components stretch (shrink) on the main axis after the swiper width [deducting the result of itemSpace x (displayCount – 1)] is evenly distributed among them on the main axis.| | effectMode8+ | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | Swipe effect. For details, see **EdgeEffect**.
Default value: **EdgeEffect.Spring**
**NOTE**
The spring effect does not take effect when the controller API is called.| diff --git a/en/application-dev/reference/arkui-ts/ts-custom-component-lifecycle.md b/en/application-dev/reference/arkui-ts/ts-custom-component-lifecycle.md index 8c0149ffd66fd3269d0bd28189a25e70f96cf89e..148129e651983ba9ba54a017cd6d30d79272571d 100644 --- a/en/application-dev/reference/arkui-ts/ts-custom-component-lifecycle.md +++ b/en/application-dev/reference/arkui-ts/ts-custom-component-lifecycle.md @@ -113,6 +113,63 @@ Since API version 9, this API is supported in ArkTS widgets. | children | Array<[LayoutChild](#layoutchild9)> | Child component layout information. | | constraint | [ConstraintSizeOptions](ts-types.md#constraintsizeoptions) | Size constraint information of the parent component.| +## onRecycle10+ + +onRecycle?(params: { [key: string]: unknown }): void + +Invoked when a custom component previously placed in the cache for future reuse is re-added to the node tree, with the parameters used for constructing the component passed in. + +Since API version 10, this API is supported in ArkTS widgets. + +**Parameters** + +| Name| Type | Description | +| ------ | -------------------------- | -------------------- | +| params | { [key: string]: unknown } | Parameters used for constructing the custom component.| + + +```ts +// xxx.ets +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + @State switch: boolean = true + + build() { + Column() { + Button(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.switch = !this.switch + }) + if (this.switch) { + Child() + } + } + .height("100%") + .width('100%') + } +} + +@Recycle +@Component +struct Child { + onRecycle(params) { + console.info("Recycle Child") + } + + build() { + Column() { + Text("Child Component") + .fontSize(20) + } + .borderWidth(2) + .height(100) + } +} +``` ## LayoutChild9+ diff --git a/en/application-dev/reference/arkui-ts/ts-page-transition-animation.md b/en/application-dev/reference/arkui-ts/ts-page-transition-animation.md index 5cd36a45df7a1b6720be03d6ca9fe59d5f555cbf..e0a3bb339e1db622d902737a7f3a1d4f61d2cf64 100644 --- a/en/application-dev/reference/arkui-ts/ts-page-transition-animation.md +++ b/en/application-dev/reference/arkui-ts/ts-page-transition-animation.md @@ -1,6 +1,6 @@ # Page Transition -The page transition navigates users between pages. You can customize page transitions by configuring the page entrance and exit components in the **pageTransition** API. +You can customize the page entrance and exit animations in the **pageTransition** API for transition between pages. > **NOTE** > @@ -10,8 +10,8 @@ The page transition navigates users between pages. You can customize page transi | Name | Parameter | Mandatory| Description | | ------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| PageTransitionEnter | {
type?: RouteType,
duration?: number,
curve?: [Curve](ts-appendix-enums.md#curve) \| string,
delay?: number
} | No | Page entrance animation.
- **type**: route type for the page transition effect to take effect.
Default value: **RouteType.None**
**NOTE**
If no match is found, the default page transition effect is used (which may vary according to the device). To disable the default page transition effect, set **duration** to **0**.
- **duration**: animation duration.
Unit: ms
- **curve**: animation curve. The value of the string type can be any of the following: "ease", "ease-in", "ease-out", "ease-in-out", "extreme-deceleration", "fast-out-linear-in", "fast-out-slow-in", "friction", "linear", "linear-out-slow-in", "rhythm", "sharp", "smooth".
Default value: **Curve.Linear**
- **delay**: animation delay.
Default value: **0**
Unit: ms| -| PageTransitionExit | {
type?: RouteType,
duration?: number,
curve?: [Curve](ts-appendix-enums.md#curve) \| string,
delay?: number
} | No | Page exit animation.
- **type**: route type for the page transition effect to take effect.
Default value: **RouteType.None**
**NOTE**
If no match is found, the default page transition effect is used (which may vary according to the device). To disable the default page transition effect, set **duration** to **0**.
- **duration**: animation duration, in milliseconds.
- **curve**: animation curve. The value range of the string type is the same as that of **PageTransitionEnter**.
Default value: **Curve.Linear**
- **delay**: animation delay.
Default value: **0**
Unit: ms| +| PageTransitionEnter | {
type?: RouteType,
duration?: number,
curve?: [Curve](ts-appendix-enums.md#curve) \| string,
delay?: number
} | No | Page entrance animation.
- **type**: route type for the page transition effect to take effect.
Default value: **RouteType.None**
- **duration**: animation duration.
Unit: ms
Default value: **1000**
- **curve**: animation curve. The value of the string type can be any of the following: "ease", "ease-in", "ease-out", "ease-in-out", "extreme-deceleration", "fast-out-linear-in", "fast-out-slow-in", "friction", "linear", "linear-out-slow-in", "rhythm", "sharp", "smooth".
Default value: **Curve.Linear**
- **delay**: animation delay.
Unit: ms
Default value: **0**
**NOTE**
If no match is found, the default page transition effect is used (which may vary according to the device). To disable the default page transition effect, set **duration** to **0**.| +| PageTransitionExit | {
type?: RouteType,
duration?: number,
curve?: [Curve](ts-appendix-enums.md#curve) \| string,
delay?: number
} | No | Page exit animation.
- **type**: route type for the page transition effect to take effect.
Default value: **RouteType.None**
- **duration**: animation duration.
Unit: ms
Default value: **1000**
- **curve**: animation curve. The value range of the string type is the same as that of **PageTransitionEnter**.
Default value: **Curve.Linear**
- **delay**: animation delay.
Unit: ms
Default value: **0**
**NOTE**
If no match is found, the default page transition effect is used (which may vary according to the device). To disable the default page transition effect, set **duration** to **0**.| ## RouteType @@ -26,10 +26,10 @@ The page transition navigates users between pages. You can customize page transi | Name | Type | Mandatory| Description | | --------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| slide | [SlideEffect](#slideeffect) | No | Slide effect during page transition.
Default value: **SlideEffect.Right**| +| slide | [SlideEffect](#slideeffect) | No | Slide effect during page transition.| | translate | {
x? : number \| string,
y? : number \| string,
z? : number \| string
} | No | Translation effect during page transition, which is the value of the start point of entrance and the end point of exit. When this parameter is set together with **slide**, the latter takes effect by default.
- **x**: translation distance along the x-axis.
- **y**: translation distance along the y-axis.
- **z**: translation distance along the y-axis.| -| scale | {
x? : number,
y? : number,
z? : number,
centerX? : number \| string,
centerY? : number \| string
} | No | Scaling effect during page transition, which is the value of the start point of entrance and the end point of exit.
- **x**: scale ratio along the x-axis.
- **y**: scale ratio along the y-axis.
- **z**: scale ratio along the z-axis.
- **centerX** and **centerY**: scale center point.
- If the center point is 0, it refers to the upper left corner of the component. | -| opacity | number | No | Opacity, which is the opacity value of the start point of entrance or the end point of exit.
Default value: **1**| +| scale | {
x? : number,
y? : number,
z? : number,
centerX? : number \| string,
centerY? : number \| string
} | No | Scaling effect during page transition, which is the value of the start point of entrance and the end point of exit.
- **x**: scale ratio along the x-axis.
- **y**: scale ratio along the y-axis.
- **z**: scale ratio along the z-axis.
- **centerX** and **centerY**: scale center point. The default values are both **"50%"**, indicating that the center point of the page.
- If the center point is (0, 0), it refers to the upper left corner of the component.
| +| opacity | number | No | Opacity, which is the opacity value of the start point of entrance or the end point of exit.| ## SlideEffect @@ -43,15 +43,15 @@ The page transition navigates users between pages. You can customize page transi ## Events -| Name | Description | +| Name | Description | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| onEnter(event: (type?: RouteType, progress?: number) => void) | Invoked once every animation frame until the entrance animation ends, when the value of **progress** changes from 0 to 1. The input parameter is the normalized progress of the current entrance animation. The value range is 0–1.
- **type**: route type.
- **progress**: current progress. | -| onExit(event: (type?: RouteType, progress?: number) => void) | Invoked once every animation frame until the exit animation ends, when the value of **progress** changes from 0 to 1. The input parameter is the normalized progress of the current exit animation. The value range is 0–1.
- **type**: route type.
- **progress**: current progress. | +| onEnter(event: (type?: RouteType, progress?: number) => void) | Invoked once every animation frame until the entrance animation ends, when the value of **progress** changes from 0 to 1. The input parameter is the normalized progress of the current entrance animation. The value range is 0–1.
- **type**: route type.
- **progress**: current progress.

| +| onExit(event: (type?: RouteType, progress?: number) => void) | Invoked once every animation frame until the exit animation ends, when the value of **progress** changes from 0 to 1. The input parameter is the normalized progress of the current exit animation. The value range is 0–1.
- **type**: route type.
- **progress**: current progress.

| ## Example -Customization method 1: The entrance animation of the current page is configured as fade-in, and the exit animation is configured as zoom-out. +Example 1: Apply the entrance animation of fade-in and the exit animation of zoom-out. ```ts // index.ets @@ -68,14 +68,14 @@ struct PageTransitionExample1 { } }.scale({ x: this.scale1 }).opacity(this.opacity1) } - // Customization method 1: Customize the transition process. + // Customize the transition process. pageTransition() { PageTransitionEnter({ duration: 1200, curve: Curve.Linear }) .onEnter((type: RouteType, progress: number) => { this.scale1 = 1 this.opacity1 = progress }) // The onEnter callback is triggered frame by frame during the entrance process. The input parameter is the normalized progress of the animation (0% to 100%). - PageTransitionExit({ duration: 1500, curve: Curve.Ease }) + PageTransitionExit({ duration: 1200, curve: Curve.Ease }) .onExit((type: RouteType, progress: number) => { this.scale1 = 1 - progress this.opacity1 = 1 @@ -99,14 +99,14 @@ struct AExample { } }.width('100%').height('100%').scale({ x: this.scale2 }).opacity(this.opacity2) } - // Customization method 1: Customize the transition process. + // Customize the transition process. pageTransition() { PageTransitionEnter({ duration: 1200, curve: Curve.Linear }) .onEnter((type: RouteType, progress: number) => { this.scale2 = 1 this.opacity2 = progress }) // The onEnter callback is triggered frame by frame during the entrance process. The input parameter is the normalized progress of the animation (0% to 100%). - PageTransitionExit({ duration: 1500, curve: Curve.Ease }) + PageTransitionExit({ duration: 1200, curve: Curve.Ease }) .onExit((type: RouteType, progress: number) => { this.scale2 = 1 - progress this.opacity2 = 1 @@ -115,31 +115,30 @@ struct AExample { } ``` -![en-us_image_0000001256978335](figures/en-us_image_0000001256978335.gif) +![pageTransition1](figures/pageTransition1.gif) -Customization method 2: The entrance animation of the current page is configured to slide in from the left, and the exit animation is configured to zoom out with opacity change. +Example 2: Apply the entrance animation of sliding in from the left and the exit animation of translating with opacity change. ```ts // index.ets @Entry @Component struct PageTransitionExample { - @State scale1: number = 1 - @State opacity1: number = 1 - build() { Column() { Navigator({ target: 'pages/page1', type: NavigationType.Push }) { Image($r('app.media.bg1')).width('100%').height('100%') // Store the image in the media folder. } - }.scale({ x: this.scale1 }).opacity(this.opacity1) + } } - // Customization method 2: Use the default effects provided by the system, such as translation, scaling, and opacity. + // Use the default effects provided by the system, such as translation, scaling, and opacity. pageTransition() { + // Set the duration of the entrance animation to 1200 ms, in the purpose of matching the duration of the exit animation of the other page. PageTransitionEnter({ duration: 1200 }) .slide(SlideEffect.Left) - PageTransitionExit({ delay: 100 }) + // Set the duration of the exit animation to 1000 ms, in the purpose of matching the duration of the entrance animation of the other page. + PageTransitionExit({ duration: 1000 }) .translate({ x: 100.0, y: 100.0 }) .opacity(0) } @@ -151,26 +150,25 @@ struct PageTransitionExample { @Entry @Component struct PageTransitionExample1 { - @State scale2: number = 1 - @State opacity2: number = 1 - build() { Column() { Navigator({ target: 'pages/index', type: NavigationType.Push }) { Image($r('app.media.bg2')).width('100%').height('100%') // Store the image in the media folder. } - }.scale({ x: this.scale2 }).opacity(this.opacity2) + } } - // Customization method 2: Use the default effects provided by the system, such as translation, scaling, and opacity. + // Use the default effects provided by the system, such as translation, scaling, and opacity. pageTransition() { - PageTransitionEnter({ duration: 1200 }) + // Set the duration of the entrance animation to 1000 ms, in the purpose of matching the duration of the exit animation of the other page. + PageTransitionEnter({ duration: 1000 }) .slide(SlideEffect.Left) - PageTransitionExit({ delay: 100 }) + // Set the duration of the exit animation to 1200 ms, in the purpose of matching the duration of the entrance animation of the other page. + PageTransitionExit({ duration: 1200 }) .translate({ x: 100.0, y: 100.0 }) .opacity(0) } } ``` -![en-us_image_0000001212058460](figures/en-us_image_0000001212058460.gif) +![pageTransition2](figures/pageTransition2.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-transition-animation-component.md b/en/application-dev/reference/arkui-ts/ts-transition-animation-component.md index cd072648a81f68b080ae88b9a90cf6a157376dc6..8018ee5d626d0fcb04dd36f3d70e2081736b189d 100644 --- a/en/application-dev/reference/arkui-ts/ts-transition-animation-component.md +++ b/en/application-dev/reference/arkui-ts/ts-transition-animation-component.md @@ -1,6 +1,6 @@ # Component Transition -Configure the component transition animations for when a component is inserted or deleted. This feature takes effect only when [animateTo](ts-explicit-animation.md) is used. The animation duration, curve, and delay are the same as those configured in **animateTo**. +You can configure the component transition animations through the **transition** attribute for when a component is inserted or deleted. > **NOTE** > @@ -12,21 +12,54 @@ Configure the component transition animations for when a component is inserted o | Name| Type| Description| | -------- | -------- | -------- | -| transition | TransitionOptions | Transition effects when the component is inserted, displayed, deleted, or hidden.
If no transition effect is set, an opacity transition from 0 to 1 is applied.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
Transition parameters, which are all optional. For details, see **TransitionOptions**.| +| transition | TransitionOptions \| TransitionEffect10+ | Transition effects when the component is inserted, displayed, deleted, or hidden.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
For details, see the description of **TransitionOptions** and **TransitionEffect**.| ## TransitionOptions - +Defines the transition effect by setting parameters in the struct. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| type | [TransitionType](ts-appendix-enums.md#transitiontype) | No| Transition type, which includes component addition and deletion by default.
Default value: **TransitionType.All**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If **type** is not specified, insertion and deletion use the same transition type.| -| opacity | number | No| Opacity of the component during transition, which is the value of the start point of insertion and the end point of deletion.
Default value: **1**
Value range: [0, 1]
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
A value less than 0 evaluates to the value **0**. A value greater than 1 evaluates to the value **1**.| +| type | [TransitionType](ts-appendix-enums.md#transitiontype) | No| Transition type.
Default value: **TransitionType.All**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If **type** is not specified, the default value **TransitionType.All** is used, which means that the transition effect works for both component addition and deletion.| +| opacity | number | No| Opacity of the component during transition, which is the value of the start point of insertion and the end point of deletion.
Value range: [0, 1]
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
A value less than 0 or greater than 1 evaluates to the value **1**.| | translate | {
x? : number \| string,
y? : number \| string,
z? : number \| string
} | No| Translation of the component during transition, which is the value of the start point of insertion and the end point of deletion.
-**x**: distance to translate along the x-axis.
-**y**: distance to translate along the y-axis.
-**z**: distance to translate along the z-axis.
Since API version 9, this API is supported in ArkTS widgets.| -| scale | {
x? : number,
y? : number,
z? : number,
centerX? : number \| string,
centerY? : number \| string
} | No| Scaling of the component during transition, which is the value of the start point of insertion and the end point of deletion.
- **x**: scale factor along the x-axis.
- **y**: scale factor along the y-axis.
- **z**: scale factor along the z-axis.
- **centerX** and **centerY**: x coordinate and y coordinate of the scale center, respectively. The default values are both **"50%"**.
- If the center point is 0, it indicates the upper left corner of the component.
Since API version 9, this API is supported in ArkTS widgets.| -| rotate | {
x?: number,
y?: number,
z?: number,
angle?: number \| string,
centerX?: number \| string,
centerY?: number \| string
} | No| Rotation of the component during transition, which is the value of the start point of insertion and the end point of deletion.
- **x**: rotation vector along the x-axis.
- **y**: rotation vector along the y-axis.
- **z**: rotation vector along the z-axis.
- **centerX** and **centerY**: x coordinate and y coordinate of the rotation center, respectively. The default values are both **"50%"**.
- If the center point is (0, 0), it indicates the upper left corner of the component.
Since API version 9, this API is supported in ArkTS widgets.| +| scale | {
x? : number,
y? : number,
z? : number,
centerX? : number \| string,
centerY? : number \| string
} | No| Scaling of the component during transition, which is the value of the start point of insertion and the end point of deletion.
- **x**: scale factor along the x-axis.
- **y**: scale factor along the y-axis.
- **z**: scale factor along the z-axis.
- **centerX** and **centerY**: scale center point. The default values are both **"50%"**, indicating that the center point of the page.
- If the center point is (0, 0), it refers to the upper left corner of the component.
Since API version 9, this API is supported in ArkTS widgets.| +| rotate | {
x?: number,
y?: number,
z?: number,
angle: number \| string,
centerX?: number \| string,
centerY?: number \| string
} | No| Rotation of the component during transition, which is the value of the start point of insertion and the end point of deletion.
- **x**: X-component of the rotation vector.
- **y**: Y-component of the rotation vector.
- **z**: Z-component of the rotation vector.
- **centerX** and **centerY**: rotation center point. The default values are both **"50%"**, indicating that the center point of the page.
- If the center point is (0, 0), it refers to the upper left corner of the component.
Since API version 9, this API is supported in ArkTS widgets.| +> **NOTE** +> +> 1. When set to a value of the **TransitionOptions** type, the **transition** attribute must work with [animateTo](ts-explicit-animation.md). The animation duration, curve, and delay follow the settings in **animateTo**. +> 2. If the value of the **TransitionOptions** type has only **type** specified, the transition effect will take on the default opacity. For example, **{type: TransitionType.Insert}** produces the same effect as **{type: TransitionType.Insert, opacity: 0}**. If a specific style is specified, the transition effect will not take on the default opacity. +> 3. For details about the scale and rotate effects, see [Transformation](ts-universal-attributes-transformation.md). + +## TransitionEffect10+ +Defines the transition effect by using the provided APIs, as listed below. +| API| Type| Static Function| Description| +| -------- | ---------- | -------- | -------- | +| opacity | number | Yes| Opacity of the component during transition, which is the value of the start point of insertion and the end point of deletion.
Value range: [0, 1]
**NOTE**
A value less than 0 or greater than 1 evaluates to the value **1**.| +| translate | {
x? : number \| string,
y? : number \| string,
z? : number \| string
} | Yes| Translation of the component during transition, which is the value of the start point of insertion and the end point of deletion.
-**x**: distance to translate along the x-axis.
-**y**: distance to translate along the y-axis.
-**z**: distance to translate along the z-axis.| +| scale | {
x? : number,
y? : number,
z? : number,
centerX? : number \| string,
centerY? : number \| string
} | Yes| Scaling of the component during transition, which is the value of the start point of insertion and the end point of deletion.
- **x**: scale factor along the x-axis.
- **y**: scale factor along the y-axis.
- **z**: scale factor along the z-axis.
- **centerX** and **centerY**: scale center point. The default values are both **"50%"**, indicating that the center point of the page.
- If the center point is (0, 0), it refers to the upper left corner of the component.| +| rotate | {
x?: number,
y?: number,
z?: number,
angle: number \| string,
centerX?: number \| string,
centerY?: number \| string
} | Yes| Rotation of the component during transition, which is the value of the start point of insertion and the end point of deletion.
- **x**: rotation vector along the x-axis.
- **y**: Y-component of the rotation vector.
- **z**: Z-component of the rotation vector.
- **centerX** and **centerY**: rotation center point. The default values are both **"50%"**, indicating that the center point of the page.
- If the center point is (0, 0), it refers to the upper left corner of the component.| +| move | [TransitionEdge](ts-appendix-enums.md#transitionedge10) | Yes| Slide-in and slide-out of the component from the screen edge during transition. It is essentially a translation effect, which is the value of the start point of insertion and the end point of deletion.| +| asymmetric | appear: TransitionEffect,
disappear: TransitionEffect
| Yes| Asymmetric transition effect.
The first parameter indicates the transition effect for appearance, and the second parameter indicates the transition effect for disappearance.
If the **asymmetric** function is not used for **TransitionEffect**, the transition effect takes effect for both appearance and disappearance of the component.| +| combine | TransitionEffect | No| Combination of transition effects.| +| animation | [AnimateParam](ts-explicit-animation.md#animateparam) | No| Animation settings.
The **onFinish** callback in **AnimateParam** does not work here.
If **combine** is used for combining transition effects, the animation settings of a transition effect are applicable to the one following it.| + +The static functions listed in the preceding table are used to create a **TransitionEffect** object, while the non-static functions apply to the created **TransitionEffect** object. +**TransitionEffect** also provides some static member variables for transition effects: +| Static Member Variable| Description| +| -------- | -------- | +| IDENTITY | Disables the transition effect.| +| OPACITY | Applies a transition effect with the opacity of 0. It is equivalent to **TransitionEffect.opacity(0)**.| +| SLIDE | Applies a transition effect of sliding in from the left when the component appears and sliding out from the right when the component disappears. It is equivalent to **TransitionEffect.asymmetric(TransitionEffect.START, TrasitionEffect.END)**.| -## Example +> **NOTE** +> +> 1. For transition effects combined through the **combine** function, animation settings can be configured through the **animation** parameter on a one-on-one basis. In addition, the animation settings of a transition effect are applicable to the one following it. For example, with **TransitionEffect.OPACITY.animation({duration: 1000}).combine(TransitionEffect.translate({x: 100}))**, the **duration** settings (1000 ms) apply to both the OPACITY and translate effects. +> 2. The animation settings take effect in the following sequence: animation settings specified in the current **TransitionEffect** > animation settings specified in the previous **TransitionEffect** > animation settings specified in **animateTo** that triggers the component to appear and disappear. +> 3. If **animateTo** is not used and **TransitionEffect** does not have the **animation** parameter specified, the component will appear or disappear without any transition animation. +> 4. If the value of an attribute specified in **TransitionEffect** is the same as the default value, no transition animation is applied for the attribute. For example, with **TransitionEffect.opacity(1).animation({duration:1000})**, because the default value of **opacity** is also **1**, no opacity animation will be applied, and the component appears or disappears without any transition animation. +## Example +The following is an example of using **TransitionOptions** for appearance and disappearance of the component. ```ts // xxx.ets @Entry @@ -40,40 +73,121 @@ struct TransitionExample { Button(this.show).width(80).height(30).margin(30) .onClick(() => { // Click the button to show or hide the image. + if (this.flag) { + this.show = 'hide'; + } else { + this.show = 'show'; + } + // When set to a value of the TransitionOptions type, the transition attribute must work with animateTo. animateTo({ duration: 1000 }, () => { - if (this.flag) { - this.show = 'hide' - } else { - this.show = 'show' - } this.flag = !this.flag }) }) if (this.flag) { - // Apply different transition effects to the showing and hiding of the image. - Image($r('app.media.testImg')).width(300).height(300) + // Apply different transition effects to the appearance and disappearance of the image. + // When the image appears, it changes from the state where the scale factor is 0 along the x-axis and 1 along the y-axis to the state where the scale factor is both 1 along x-axis and y-axis. + // When the image disappears, it rotates from 0° to 180° clockwise around the z-axis. + Image($r('app.media.testImg')).width(200).height(200) .transition({ type: TransitionType.Insert, scale: { x: 0, y: 1.0 } }) - .transition({ type: TransitionType.Delete, rotate: { angle: 180 } }) + .transition({ type: TransitionType.Delete, rotate: { z: 1, angle: 180 } }) } }.width('100%') } } ``` -Diagrams: - -When the image is completely displayed: - -![animationComponent1](figures/animationComponent1.png) - -When the transition effect of 180° clockwise rotation is applied to the hiding of the image: - -![animationComponent3](figures/animationComponent3.png) +Below you can see the example in action.
+![transitionComponent1](figures/transitionComponent1.gif) -When the image disappears completely: +The following is an example of using the same transition effect for the appearance and disappearance (which are inverse processes) of the component. +```ts +// xxx.ets +@Entry +@Component +struct TransitionEffectExample1 { + @State flag: boolean = true; + @State show: string = 'show'; -![animationComponent2](figures/animationComponent2.png) + build() { + Column() { + Button(this.show).width(80).height(30).margin(30) + .onClick(() => { + // Click the button to show or hide the image. + if (this.flag) { + this.show = 'hide'; + } else { + this.show = 'show'; + } + this.flag = !this.flag; + }) + if (this.flag) { + // Apply the same transition effect to the appearance and disappearance of the image. + // When the image appears, it changes from the state where the opacity is 0 and the rotation angle is 180° around the z-axis to the state where the opacity is 1 and the rotation angle is 0°. The durations of the opacity and rotation animations are both 2000 ms. + // When the image disappears, it changes from the state where the opacity is 1 and the rotation angle is 0° to the state where the opacity is 0 and the rotation angle is 180° around the z-axis. The durations of the opacity and rotation animations are both 2000 ms. + Image($r('app.media.testImg')).width(200).height(200) + .transition(TransitionEffect.OPACITY.animation({ duration: 2000, curve: Curve.Ease }).combine( + TransitionEffect.rotate({ z: 1, angle: 180 }) + )) + } + }.width('100%') + } +} +``` +Below you can see the example in action.
+![transitionComponent2](figures/transitionComponent2.gif) -When the transition effect of zooming in twice horizontally is applied to the image displayed: +The following is an example of using different transition effects for the appearance and disappearance of the component. +```ts +// xxx.ets +@Entry +@Component +struct TransitionEffectExample2 { + @State flag: boolean = true; + @State show: string = 'show'; -![animationComponent4](figures/animationComponent4.png) + build() { + Column() { + Button(this.show).width(80).height(30).margin(30) + .onClick(() => { + // Click the button to show or hide the image. + if (this.flag) { + this.show = 'hide'; + } else { + this.show = 'show'; + } + animateTo({ duration: 2000 }, () => { + // In the first image, **TransitionEffect** contains **animation**, and therefore the animation settings are those configured in **TransitionEffect**. + // In the second image, **TransitionEffect** does not contain **animation**, and therefore the animation settings are those configured in **animateTo**. + this.flag = !this.flag; + }); + }) + if (this.flag) { + // Apply different transition effects to the appearance and disappearance of the image. + // When the image appears, its opacity changes 0 to 1 (default value) over the duration of 1000 ms, and after 1000 ms has elapsed, its rotation angle changes from 180° around the z-axis to 0° (default value) over the duration of 1000 ms. + // When the image disappears, after 1000 ms has elapsed, its opacity changes 1 (default value) to 0 over the duration of 1000 ms, and its rotation angle changes from 0° (default value) to 180° around the z-axis over the duration of 1000 ms. + Image($r('app.media.testImg')).width(200).height(200) + .transition( + TransitionEffect.asymmetric( + TransitionEffect.OPACITY.animation({ duration: 1000 }).combine( + TransitionEffect.rotate({ z: 1, angle: 180 }).animation({ delay: 1000, duration: 1000 })) + , + TransitionEffect.OPACITY.animation({ delay: 1000, duration: 1000 }).combine( + TransitionEffect.rotate({ z: 1, angle: 180 }).animation({ duration: 1000 })) + ) + ) + // When the image appears, the scale along the x- and y- axes is changed from 0 to 1 (default value). The animation duration is 2000 ms specified in **animateTo**. + // When the image disappears, no transition effect is applied. + Image($r('app.media.testImg')).width(200).height(200).margin({ top: 100 }) + .transition( + TransitionEffect.asymmetric( + TransitionEffect.scale({ x: 0, y: 0 }), + TransitionEffect.IDENTITY + ) + ) + } + }.width('100%') + } +} +``` +Below you can see the example in action.
+![transitionComponent3](figures/transitionComponent3.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md index 11394a20c84757bfff4fc3d95fc72a7f2c3ee428..8032455b78bf4a4e5654dfc939f23cfbdeafc2e3 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md @@ -12,9 +12,9 @@ Create a more gorgeous look for a component by applying a gradient color effect | Name | Type | Description | | -------------- | -------------------------------------------- | ----------------------------------- | -| linearGradient | {
angle?: number \| string,
direction?: [GradientDirection](ts-appendix-enums.md#gradientdirection),
colors: Array<[ColorStop](ts-basic-components-gauge.md#colorstop)>,
repeating?: boolean
} | Linear gradient.
- **angle**: start angle of the linear gradient. A positive value indicates a clockwise rotation from the origin, (0, 0).
Default value: **180**
- **direction**: direction of the linear gradient. It does not take effect when **angle** is set.
Default value: **GradientDirection.Bottom**
- **colors**: colors of the linear gradient.
- **repeating**: whether the colors are repeated.
Default value: **false**
Since API version 9, this API is supported in ArkTS widgets.| -| sweepGradient | {
center: Point,
start?: number \| string,
end?: number \| string,
rotation?: number\|string,
colors: Array<[ColorStop](ts-basic-components-gauge.md#colorstop)>,
repeating?: boolean
} | Sweep gradient, which can sweep around the specified center point in the 0–360 degree range. If the rotation angle exceeds the range, a monochrome color instead of a gradient will be drawn.
- **center**: center point of the sweep gradient, that is, the coordinates relative to the upper left corner of the current component.
- **start**: start point of the sweep gradient.
Default value: **0**
- **end**: end point of the sweep gradient.
Default value: **0**
- **rotation**: rotation angle of the sweep gradient.
Default value: **0**
- **colors**: colors of the sweep gradient.
- **repeating**: whether the colors are repeated.
Default value: **false**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
A value less than 0 evaluates to the value **0**. A value greater than 360 evaluates to the value **1**.
When the data type of **start**, **end**, and **rotation** is string, the value **"90"** or **"90%"** is equivalent to **90**. | -| radialGradient | {
center: Point,
radius: number \| string,
colors: Array<[ColorStop](ts-basic-components-gauge.md#colorstop)>,
repeating?: boolean
} | Radial gradient.
- **center**: center point of the radial gradient, that is, the coordinates relative to the upper left corner of the current component.
- **radius**: radius of the radial gradient.
Value range: [0, +∞)
**NOTE**
A value less than 0 evaluates to the value **0**.
- **colors**: colors of the radial gradient.
- **repeating**: whether the colors are repeated.
Default value: **false**
Since API version 9, this API is supported in ArkTS widgets. | +| linearGradient | {
angle?: number \| string,
direction?: [GradientDirection](ts-appendix-enums.md#gradientdirection),
colors: Array<[ColorStop](ts-basic-components-gauge.md#colorstop)>,
repeating?: boolean
} | Linear gradient.
- **angle**: start angle of the linear gradient. A positive value indicates a clockwise rotation from the origin, (0, 0).
Default value: **180**
- **direction**: direction of the linear gradient. It does not take effect when **angle** is set.
Default value: **GradientDirection.Bottom**
- **colors**: colors of the linear gradient.
- **repeating**: whether the colors are repeated.
Default value: **false**
Since API version 9, this API is supported in ArkTS widgets.| +| sweepGradient | {
center: [Point](./ts-drawing-components-polygon.md#point),
start?: number \| string,
end?: number \| string,
rotation?: number\|string,
colors: Array<[ColorStop](ts-basic-components-gauge.md#colorstop)>,
repeating?: boolean
} | Sweep gradient, which can sweep around the specified center point in the 0–360 degree range. If the rotation angle exceeds the range, a monochrome color instead of a gradient will be drawn.
- **center**: center point of the sweep gradient, that is, the coordinates relative to the upper left corner of the current component.
- **start**: start point of the sweep gradient.
Default value: **0**
- **end**: end point of the sweep gradient.
Default value: **0**
- **rotation**: rotation angle of the sweep gradient.
Default value: **0**
- **colors**: colors of the sweep gradient.
- **repeating**: whether the colors are repeated.
Default value: **false**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
A value less than 0 evaluates to the value **0**. A value greater than 360 evaluates to the value **1**.
When the data type of **start**, **end**, and **rotation** is string, the value **"90"** or **"90%"** is equivalent to **90**.| +| radialGradient | {
center: [Point](./ts-drawing-components-polygon.md#point),
radius: number \| string,
colors: Array<[ColorStop](ts-basic-components-gauge.md#colorstop)>,
repeating?: boolean
} | Radial gradient.
- **center**: center point of the radial gradient, that is, the coordinates relative to the upper left corner of the current component.
- **radius**: radius of the radial gradient.
Value range: [0, +∞)
**NOTE**
A value less than 0 evaluates to the value **0**.
- **colors**: colors of the radial gradient.
- **repeating**: whether the colors are repeated.
Default value: **false**
Since API version 9, this API is supported in ArkTS widgets.| ## Example diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md index c58595fb1861bfb73d5f7700af3cf7d0c130c53e..f5780d429c83b008ec2bdfec8a078d9a260df878 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md @@ -4,7 +4,9 @@ A context menu – a vertical list of items – can be bound to a component and > **NOTE** > -> The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +> - The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +> +> - **CustomBuilder** does not support the use of **bindMenu** and **bindContextMenu** methods. To display a multi-level menu, use the [\](ts-basic-components-menu.md) component instead. ## Attributes @@ -29,7 +31,7 @@ A context menu – a vertical list of items – can be bound to a component and | ------ | -------------------------------- | ---- | ------------------------------------------------------ | | title | string | No | Menu title. | | offset | [Position](ts-types.md#position8) | No | Offset for showing the context menu, which should not cause the menu to extend beyond the screen.| -| placement | [Placement](ts-appendix-enums.md#placement8) | No| Preferred position of the context menu. If the set position is insufficient for holding the component, it will be automatically adjusted.
Default value: **Placement.Bottom**| +| placement | [Placement](ts-appendix-enums.md#placement8) | No| Preferred position of the context menu. If the set position is insufficient for holding the component, it will be automatically adjusted.
**NOTE**
Setting **placement** to **undefined** or **null** is equivalent to not setting it at all.| | onAppear | () => void | No| Callback triggered when the menu is displayed.| | onDisappear | () => void | No| Callback triggered when the menu is hidden.| @@ -38,7 +40,7 @@ A context menu – a vertical list of items – can be bound to a component and | Name | Type | Mandatory| Description | | ----------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | | offset | [Position](ts-types.md#position8) | No | Offset for showing the context menu, which should not cause the menu to extend beyond the screen. | -| placement | [Placement](ts-appendix-enums.md#placement8) | No | Preferred position of the context menu. If the set position is insufficient for holding the component, it will be automatically adjusted.
Default value: **Placement.Bottom**| +| placement | [Placement](ts-appendix-enums.md#placement8) | No | Preferred position of the context menu. If the set position is insufficient for holding the component, it will be automatically adjusted.
**NOTE**
Setting **placement** to **undefined** or **null** is equivalent to not setting it at all.| | onAppear | () => void | No | Callback triggered when the menu is displayed. | | onDisappear | () => void | No | Callback triggered when the menu is hidden. | diff --git a/en/application-dev/reference/errorcodes/Readme-EN.md b/en/application-dev/reference/errorcodes/Readme-EN.md index a9e53ed27e739a1accada2bfd497a7966003ad31..ee41df889eef61bce0b3fa4f57d19814036f51e5 100644 --- a/en/application-dev/reference/errorcodes/Readme-EN.md +++ b/en/application-dev/reference/errorcodes/Readme-EN.md @@ -55,7 +55,6 @@ - [Network Connection Management Error Codes](errorcode-net-connection.md) - [Ethernet Connection Error Codes](errorcode-net-ethernet.md) - [Network Sharing Error Codes](errorcode-net-sharing.md) - - [Policy Management Error Codes](errorcode-net-policy.md) - [mDNS Error Codes](errorcode-net-mdns.md) - Connectivity - [Bluetooth Error Codes](errorcode-bluetoothManager.md) @@ -68,6 +67,7 @@ - [Application Event Logging Error Codes](errorcode-hiappevent.md) - [HiSysEvent Error Codes](errorcode-hisysevent.md) - [HiDebug Error Codes](errorcode-hiviewdfx-hidebug.md) + - [Log Library Error Codes](errorcode-loglibrary.md) - [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) - [Pasteboard Error Codes](errorcode-pasteboard.md) - [Screen Lock Management Error Codes](errorcode-screenlock.md) @@ -83,7 +83,8 @@ - [Thermal Manager Error Codes](errorcode-thermal.md) - [Device Management Error Codes](errorcode-device-manager.md) - [Location Subsystem Error Codes](errorcode-geoLocationManager.md) - - [Screen Hopping Error Codes](errorcode-multimodalinput.md) + - [Screen Hopping Error Codes](errorcode-devicestatus.md) + - [Screen Hopping Error Codes (to Be Deprecated)](errorcode-multimodalinput.md) - [Sensor Error Codes](errorcode-sensor.md) - [Vibrator Error Codes](errorcode-vibrator.md) - [System Parameter Error Codes](errorcode-system-parameterV9.md) diff --git a/en/application-dev/reference/errorcodes/errorcode-ability.md b/en/application-dev/reference/errorcodes/errorcode-ability.md index b8ca0fb14876dadf9b5e925f715430c1f6a26e24..fa1aea9015cd83a9ba19c7c5c0c4f75610d15c73 100644 --- a/en/application-dev/reference/errorcodes/errorcode-ability.md +++ b/en/application-dev/reference/errorcodes/errorcode-ability.md @@ -204,7 +204,7 @@ The system has a large number of concurrent requests. No action is required. Wait for the previous abilities to finish startup. -## 100001 Internal Error +## 16000050 Internal Error **Error Message** @@ -519,7 +519,7 @@ The method has registered. **Description** -THis error code is reported when the method has been registered. +This error code is reported when the method has been registered. **Possible Causes** @@ -583,6 +583,24 @@ The mission listener does not exist. Check the mission listener ID. +## 16300003 Target Application Is Not the Invoker Application + +**Error Message** + +The target application is not self application. + +**Description** + +This error code is reported when the application to start is not the application that calls the API. + +**Possible Causes** + +The application to start and the invoker application are not the same application. + +**Solution** + +Ensure that the application to start is the invoker application. + ## 18500001 Invalid Bundle Name **Error Message** @@ -638,7 +656,7 @@ This error code is reported when the patch package fails to be deployed. 4. If a patch package has been deployed, the **versionCode** of the new patch package is not later than that of the previous patch package. 5. If the **type** field is set to **patch**, the signature information is different from that of the application. 6. If the **type** field is set to **patch** and a debug version is to be installed, a **hotreload** patch is in use. -7. If the **type** field is set to **hotreload** and a debug version is to be installed, a **patch** patch is in use. If the **type** field is set to **hotreload**, a release version is to be installed. +7. If the **type** field is set to **hotreload** and a debug version is to be installed, a **patch** package is in use. If the **type** field is set to **hotreload**, a release version is to be installed. **Solution** @@ -656,7 +674,7 @@ This error code is reported when the patch package fails to be enabled. **Possible Causes** -The patch package is in an incorect state. +The patch package is in an incorrect state. **Solution** @@ -706,7 +724,7 @@ Failed to unload the patch. **Description** -This error code is reported when when the Ark engine fails to uninstall the patch. +This error code is reported when the Ark engine fails to uninstall the patch. **Possible Causes** @@ -733,3 +751,21 @@ Common kernel errors such as memory application and multi-thread processing erro **Solution** Ensure sufficient sytem memory. + +## 18500009 Application Has a Quick Fix Task Being Processed + +**Error Message** + +The application has a apply quick fix task that is being processed. + +**Description** + +This error code is reported when the application has a quick fix task that is under processing. + +**Possible Causes** + +When you try to cancel a quick fix task for an application, the application has a quick repair task that is under processing. + +**Solution** + +Wait until the quick fix task is complete. diff --git a/en/application-dev/reference/errorcodes/errorcode-backgroundTaskMgr.md b/en/application-dev/reference/errorcodes/errorcode-backgroundTaskMgr.md index a92c890358492459fdf13ef213ac3a392628a5b7..d2bd2b2bab4cce2b073012354999b2d2d706c0dd 100644 --- a/en/application-dev/reference/errorcodes/errorcode-backgroundTaskMgr.md +++ b/en/application-dev/reference/errorcodes/errorcode-backgroundTaskMgr.md @@ -38,7 +38,7 @@ Try again later or restart the device. **Error Message** -IPC failed. +Inner transact failed. **Possible Causes** @@ -67,7 +67,7 @@ Try again later or restart the device. **Error Message** -Continuous task verification failed. +Background task verification failed. **Possible Causes** @@ -120,7 +120,7 @@ Task storage failed. **Error Message** -Caller information verification failed for a transient task. +Caller information verification failed. **Possible Causes** @@ -138,7 +138,7 @@ Caller information verification failed for a transient task. **Error Message** -Transient task verification failed. +Background task verification failed. **Possible Causes** @@ -157,7 +157,7 @@ Transient task verification failed. **Error Message** -Caller information verification failed when applying for efficiency resources. +Caller information verification failed. **Possible Causes** diff --git a/en/application-dev/reference/errorcodes/errorcode-i18n.md b/en/application-dev/reference/errorcodes/errorcode-i18n.md index e78abf39b82bf0e4da3f35c0dfc14aaa78e31165..6b269c17442bcd97f5235ac85079356c9964cb46 100644 --- a/en/application-dev/reference/errorcodes/errorcode-i18n.md +++ b/en/application-dev/reference/errorcodes/errorcode-i18n.md @@ -26,7 +26,7 @@ Check whether the parameter type is correct. **Error Message** -Unspported option value. +param value not valid **Description** diff --git a/en/application-dev/reference/errorcodes/errorcode-loglibrary.md b/en/application-dev/reference/errorcodes/errorcode-loglibrary.md new file mode 100644 index 0000000000000000000000000000000000000000..8bfe5c124182b09a65543eb27dfbf3ba085d8e5c --- /dev/null +++ b/en/application-dev/reference/errorcodes/errorcode-loglibrary.md @@ -0,0 +1,24 @@ +# Log Library Error Codes + +> **NOTE** +> +> This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md). + +## 21300001 Specified File Not Exist + +**Error Message** + +The specified file does not exist. + +**Description** + +When the **copy**, **move**, or **delete** API is called to perform file operations, the file with the specified name does not exist in the specified type of logs. + +**Possible Cause** + +1. The input file name is incorrect. +2. The file with the input file name does not exist. + +**Procedure** + +Check whether the input file name is correct. diff --git a/en/application-dev/reference/errorcodes/errorcode-media.md b/en/application-dev/reference/errorcodes/errorcode-media.md index 154e8bebb06101e414eed77a18042f5653d1691e..0a0c34817377a4df2808ac9dba79566c96e4d96e 100644 --- a/en/application-dev/reference/errorcodes/errorcode-media.md +++ b/en/application-dev/reference/errorcodes/errorcode-media.md @@ -1,4 +1,4 @@ -# Media Error Codes +# Media Error Codes > **NOTE** > @@ -27,7 +27,7 @@ Destroy this instance and re-create it. If the re-creation fails, stop related o **Error Message** -Operate not permit. +Operation not allowed. **Description** @@ -45,7 +45,7 @@ Switch the instance to the correct state and perform the operation. **Error Message** -IO error. +I/O error. **Description** @@ -63,7 +63,7 @@ Ensure that the network is normal, destroy this instance, and re-create it. If t **Error Message** -Time out. +Operation timeout. **Description** @@ -71,7 +71,7 @@ The operation timed out. **Possible Causes** -1. The network connection times out. +1. The network connection times out. (The default network timeout period is 15 seconds, and the timer starts after the buffered event is reported.) 2. Accessing other modules times out. **Solution** diff --git a/en/application-dev/reference/errorcodes/errorcode-multimodalinput.md b/en/application-dev/reference/errorcodes/errorcode-multimodalinput.md index 6933bfcf7075ca21cf7a63959f11059da061ff36..4c269a4a723459598a3f1117b820881619be648f 100644 --- a/en/application-dev/reference/errorcodes/errorcode-multimodalinput.md +++ b/en/application-dev/reference/errorcodes/errorcode-multimodalinput.md @@ -1,4 +1,4 @@ -# Screen Hopping Error Codes +# Screen Hopping Error Codes (To Be Deprecated) > **NOTE** > diff --git a/en/application-dev/reference/errorcodes/errorcode-net-policy.md b/en/application-dev/reference/errorcodes/errorcode-net-policy.md deleted file mode 100644 index 594f498f72ce70daaf714111b411ac704baf0b1c..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/errorcodes/errorcode-net-policy.md +++ /dev/null @@ -1,63 +0,0 @@ -# Policy Management Error Codes - -> **NOTE** -> -> This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md). - -## 2100001 Invalid Parameter Value - -**Error Message** - -Invalid parameter value. - -**Description** - -Invalid parameter value - -**Cause** - -The input parameter value is not within the valid value range. - -**Procedure** - -Check whether the input parameter value is within the valid value range. - -## 2100002 Service Connection Failure - -**Error Message** - -Operation failed. Cannot connect to service. - -**Description** - -This error code is reported if a service connection failure occurs. - -**Cause** - -The service is abnormal. - -**Procedure** - -Check whether system services are running properly. - -## 2100003 System Internal Error - -**Error Message** - -System internal error. - -**Description** - -This error code is reported if a system internal error occurs. - -**Cause** - -1. The memory is abnormal. - -2. A null pointer is present. - -**Procedure** - -1. Check whether the memory space is sufficient. If not, clear the memory and try again. - -2. Check whether the system is normal. If not, try again later or restart the device. diff --git a/en/application-dev/reference/errorcodes/errorcode-workScheduler.md b/en/application-dev/reference/errorcodes/errorcode-workScheduler.md index 34e8a080061c3c7be0c0eb64c0c9bf617ff26d05..24b92da43813930c24a0215744f6130179f58074 100644 --- a/en/application-dev/reference/errorcodes/errorcode-workScheduler.md +++ b/en/application-dev/reference/errorcodes/errorcode-workScheduler.md @@ -53,7 +53,7 @@ Try again later or restart the device. **Error Message** -Checking workInfo failed. +Check workInfo failed. **Possible Causes** diff --git a/en/application-dev/reference/js-service-widget-ui/js-service-widget-common-gradient.md b/en/application-dev/reference/js-service-widget-ui/js-service-widget-common-gradient.md index fbfe2c4db91511503d37bba3ad2100a912aee020..2c338d915e21c6a66ba684824739914c86966ff8 100644 --- a/en/application-dev/reference/js-service-widget-ui/js-service-widget-common-gradient.md +++ b/en/application-dev/reference/js-service-widget-ui/js-service-widget-common-gradient.md @@ -33,54 +33,52 @@ background: repeating-linear-gradient(direction/angle, color, color, ...); The color can be specified in any of the following formats: \#ff0000, \#ffff0000, rgb(255, 0, 0), and rgba(255, 0, 0, 1). At least two colors must be specified. -- Parameters +**Parameters** - | Name | Type | Default Value | Mandatory | Description | - | --------- | ---------------------------------------- | ---------------------------- | ---- | ---------------------------------------- | - | direction | to <side-or-corner> <side-or-corner> = [left \| right] \|\| [top \| bottom] | to bottom (gradient from top to bottom)| No | Transition direction. For example, **to left** (gradient from right to left) or **to bottom right** (gradient from upper left corner to lower right corner).| - | angle | <deg> | 180deg | No | Transition direction, which is the angle between the gradient line and the y-axis (in the clockwise direction), with the geometric center of the element being the origin of coordinates and the horizontal axis being the x-axis.| - | color | <color> [<length>\|<percentage>] | - | Yes | Colors among which smooth transitions are rendered. | +| Name | Type | Default Value | Mandatory | Description | +| --------- | ---------------------------------------- | ---------------------------- | ---- | ---------------------------------------- | +| direction | to <side-or-corner> <side-or-corner> = [left \| right] \|\| [top \| bottom] | to bottom (gradient from top to bottom)| No | Transition direction. For example, **to left** (gradient from right to left) or **to bottom right** (gradient from upper left corner to lower right corner).| +| angle | <deg> | 180deg | No | Transition direction, which is the angle between the gradient line and the y-axis (in the clockwise direction), with the geometric center of the element being the origin of coordinates and the horizontal axis being the x-axis.| +| color | <color> [<length>\|<percentage>] | - | Yes | Colors among which smooth transitions are rendered. | -- Example +**Example** - 1. Gradient from top to bottom (default) +1. Gradient from top to bottom (default) - ```css - #gradient { - height: 300px; - width: 600px; - /* Gradient starts from red at the top to green at the bottom. */ - background: linear-gradient(red, #00ff00); - } - ``` + ```css + #gradient { + height: 300px; + width: 600px; + /* Gradient starts from red at the top to green at the bottom. */ + background: linear-gradient(red, #00ff00); + } + ``` - ![111](figures/111.PNG) + ![111](figures/111.PNG) - 2. Gradient at an angle of 45° +2. Gradient at an angle of 45° + ```css + /* Gradient at an angle of 45°, changing from red to green */ + background: linear-gradient(45deg, rgb(255, 0, 0),rgb(0, 255, 0)); + ``` - ```css - /* Gradient at an angle of 45°, changing from red to green */ - background: linear-gradient(45deg, rgb(255, 0, 0),rgb(0, 255, 0)); - ``` + ![222](figures/222.PNG) - ![222](figures/222.PNG) +3. Gradient from left to right - 3. Gradient from left to right + ```css + /* Gradient from left to right, which is available in the 270 px width between the left 90 px and the left 360 px (600*0.6) */ + background: linear-gradient(to right, rgb(255, 0, 0) 90px, rgb(0, 255, 0) 60%); + ``` - ```css - /* Gradient from left to right, which is available in the 270 px width between the left 90 px and the left 360 px (600*0.6) */ - background: linear-gradient(to right, rgb(255, 0, 0) 90px, rgb(0, 255, 0) 60%); - ``` + ![333](figures/333.PNG) +4. Repeating gradient - ![333](figures/333.PNG) + ```css + /* Repeating gradient from left to right, the area of which is 30 px (60 – 30) and the opacity is 0.5 */ + background: repeating-linear-gradient(to right, rgba(255, 255, 0, 1) 30vp,rgba(0, 0, 255, .5) 60vp); + ``` - 4. Repeating gradient - - ```css - /* Repeating gradient from left to right, the area of which is 30 px (60 – 30) and the opacity is 0.5 */ - background: repeating-linear-gradient(to right, rgba(255, 255, 0, 1) 30vp,rgba(0, 0, 255, .5) 60vp); - ``` - - ![444](figures/444.PNG) + ![444](figures/444.PNG) diff --git a/en/application-dev/reference/native-apis/_mind_spore.md b/en/application-dev/reference/native-apis/_mind_spore.md index 7e546e8f958341e55b9f59cd4123b274c78cc0f1..ded41297291a904a08793bd2cd94e2ab667a10a0 100644 --- a/en/application-dev/reference/native-apis/_mind_spore.md +++ b/en/application-dev/reference/native-apis/_mind_spore.md @@ -5,14 +5,6 @@ Provides APIs related to MindSpore Lite model inference. -Copyright 2021 Huawei Technologies 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](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. - \@Syscap SystemCapability.Ai.MindSpore **Since:** diff --git a/en/application-dev/reference/native-apis/_native_window.md b/en/application-dev/reference/native-apis/_native_window.md index 7a6f7d6f1cf6f344106543e35a5b01e2f7185521..e6fdaf9f4eb24b20ffe2620dbf3298b57c558e0b 100644 --- a/en/application-dev/reference/native-apis/_native_window.md +++ b/en/application-dev/reference/native-apis/_native_window.md @@ -1,13 +1,15 @@ # NativeWindow -## Overview - Provides the native window capability for connection to the EGL. + \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow -**Since:** + +**Since** + + 8 @@ -16,58 +18,61 @@ Provides the native window capability for connection to the EGL. ### Files -| Name | Description | + | Name| Description| | -------- | -------- | -| [external_window.h](external__window_8h.md) | Defines the functions for obtaining and using a native window.
File to Include: | +| [external_window.h](external__window_8h.md) | Defines the functions for obtaining and using a native window.
File to include: | ### Structs -| Name | Description | + | Name| Description| | -------- | -------- | -| [Region](_region.md) | Defines the rectangle (dirty region) where the content is to be updated in the local native window. | -| [OHHDRMetaData](_o_h_h_d_r_meta_data.md) | Defines the HDR metadata. | -| [OHExtDataHandle](_o_h_ext_data_handle.md) | Defines the extended data handle. | +| [Region](_region.md) | Defines the rectangle (dirty region) where the content is to be updated in the local native window.| +| [OHHDRMetaData(deprecated)](_o_h_h_d_r_meta_data.md) | Defines the HDR metadata. This struct is deprecated since API version 9 and is expected to be deleted from API version 14.| +| [OHExtDataHandle(deprecated)](_o_h_ext_data_handle.md) | Defines the extended data handle. This struct is deprecated since API version 9 and is expected to be deleted from API version 14.| ### Types -| Name | Description | + | Name| Description| | -------- | -------- | -| OHNativeWindow | Provides the function of accessing the **NativeWindow**. | -| OHNativeWindowBuffer | Provides the function of accessing the **NativeWindowBuffer**. | -| Region | Defines the rectangle (dirty region) where the content is to be updated in the local native window. | +| OHNativeWindow | Provides the function of accessing the **NativeWindow**.| +| OHNativeWindowBuffer | Provides the function of accessing the **NativeWindow**.| +| Region | Defines the rectangle (dirty region) where the content is to be updated in the local native window.| ### Enums -| Name | Description | + | Name| Description| | -------- | -------- | -| [NativeWindowOperation](#nativewindowoperation) {
SET_BUFFER_GEOMETRY, GET_BUFFER_GEOMETRY, GET_FORMAT, SET_FORMAT,
GET_USAGE, SET_USAGE, SET_STRIDE, GET_STRIDE,
SET_SWAP_INTERVAL, GET_SWAP_INTERVAL, SET_TIMEOUT, GET_TIMEOUT,
SET_COLOR_GAMUT, GET_COLOR_GAMUT, SET_TRANSFORM, GET_TRANSFORM,
SET_UI_TIMESTAMP
} | Enumerates the operation codes in the **OH_NativeWindow_NativeWindowHandleOpt** function. | -| [OHScalingMode](#ohscalingmode) { OH_SCALING_MODE_FREEZE = 0, OH_SCALING_MODE_SCALE_TO_WINDOW, OH_SCALING_MODE_SCALE_CROP, OH_SCALING_MODE_NO_SCALE_CROP } | Enumerates the scaling modes. | -| [OHHDRMetadataKey](#ohhdrmetadatakey) {
OH_METAKEY_RED_PRIMARY_X = 0, OH_METAKEY_RED_PRIMARY_Y = 1, OH_METAKEY_GREEN_PRIMARY_X = 2, OH_METAKEY_GREEN_PRIMARY_Y = 3,
OH_METAKEY_BLUE_PRIMARY_X = 4, OH_METAKEY_BLUE_PRIMARY_Y = 5, OH_METAKEY_WHITE_PRIMARY_X = 6, OH_METAKEY_WHITE_PRIMARY_Y = 7,
OH_METAKEY_MAX_LUMINANCE = 8, OH_METAKEY_MIN_LUMINANCE = 9, OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL = 10, OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,
OH_METAKEY_HDR10_PLUS = 12, OH_METAKEY_HDR_VIVID = 13
} | Enumerates the HDR metadata keys. | +| [NativeWindowOperation](#nativewindowoperation) { SET_BUFFER_GEOMETRY, GET_BUFFER_GEOMETRY, GET_FORMAT, SET_FORMAT, GET_USAGE, SET_USAGE, SET_STRIDE, GET_STRIDE, SET_SWAP_INTERVAL, GET_SWAP_INTERVAL, SET_TIMEOUT, GET_TIMEOUT, SET_COLOR_GAMUT, GET_COLOR_GAMUT, SET_TRANSFORM, GET_TRANSFORM, SET_UI_TIMESTAMP } | Enumerates the operation codes in the **OH_NativeWindow_NativeWindowHandleOpt** function.| +| [OHScalingMode(deprecated)](#ohscalingmode) { OH_SCALING_MODE_FREEZE = 0, OH_SCALING_MODE_SCALE_TO_WINDOW, OH_SCALING_MODE_SCALE_CROP, OH_SCALING_MODE_NO_SCALE_CROP } | Enumerates the scaling modes. This enum is deprecated since API version 9 and is expected to be deleted from API version 14.| +| [OHHDRMetadataKey(deprecated)](#ohhdrmetadatakey) { OH_METAKEY_RED_PRIMARY_X = 0, OH_METAKEY_RED_PRIMARY_Y = 1, OH_METAKEY_GREEN_PRIMARY_X = 2, OH_METAKEY_GREEN_PRIMARY_Y = 3, OH_METAKEY_BLUE_PRIMARY_X = 4, OH_METAKEY_BLUE_PRIMARY_Y = 5, OH_METAKEY_WHITE_PRIMARY_X = 6, OH_METAKEY_WHITE_PRIMARY_Y = 7, OH_METAKEY_MAX_LUMINANCE = 8, OH_METAKEY_MIN_LUMINANCE = 9, OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL = 10, OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11, OH_METAKEY_HDR10_PLUS = 12, OH_METAKEY_HDR_VIVID = 13 } | Enumerates the HDR metadata keys. This enum is deprecated since API version 9 and is expected to be deleted from API version 14.| ### Functions -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_NativeWindow_CreateNativeWindow](#oh_nativewindow_createnativewindow) (void \*pSurface) | Creates a **NativeWindow** instance. A new **NativeWindow** instance is created each time this function is called. | -| [OH_NativeWindow_DestroyNativeWindow](#oh_nativewindow_destroynativewindow) (OHNativeWindow \*window) | Decreases the reference count of a **NativeWindow** instance by 1 and when the reference count reaches 0, destroys the instance. | -| [OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer](#oh_nativewindow_createnativewindowbufferfromsurfacebuffer) (void \*pSurfaceBuffer) | Creates a **NativeWindowBuffer** instance. A new **NativeWindowBuffer** instance is created each time this function is called. | -| [OH_NativeWindow_DestroyNativeWindowBuffer](#oh_nativewindow_destroynativewindowbuffer) (OHNativeWindowBuffer \*buffer) | Decreases the reference count of a **NativeWindowBuffer** instance by 1 and when the reference count reaches 0, destroys the instance. | -| [OH_NativeWindow_NativeWindowRequestBuffer](#oh_nativewindow_nativewindowrequestbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*\*buffer, int \*fenceFd) | Requests a **NativeWindowBuffer** through a **NativeWindow** instance for content production. | -| [OH_NativeWindow_NativeWindowFlushBuffer](#oh_nativewindow_nativewindowflushbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer, int fenceFd, [Region](_region.md) region) | Flushes the **NativeWindowBuffer** filled with the content to the buffer queue through a **NativeWindow** instance for content consumption. | -| [OH_NativeWindow_NativeWindowAbortBuffer](#oh_nativewindow_nativewindowabortbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer) | Returns the **NativeWindowBuffer** to the buffer queue through a **NativeWindow** instance, without filling in any content. The **NativeWindowBuffer** can be used for another request. | -| [OH_NativeWindow_NativeWindowHandleOpt](#oh_nativewindow_nativewindowhandleopt) (OHNativeWindow \*window, int code,...) | Sets or obtains the attributes of a native window, including the width, height, and content format. | -| [OH_NativeWindow_GetBufferHandleFromNative](#oh_nativewindow_getbufferhandlefromnative) (OHNativeWindowBuffer \*buffer) | Obtains the pointer to a **BufferHandle** of a **NativeWindowBuffer** instance. | -| [OH_NativeWindow_NativeObjectReference](#oh_nativewindow_nativeobjectreference) (void \*obj) | Adds the reference count of a native object. | -| [OH_NativeWindow_NativeObjectUnreference](#oh_nativewindow_nativeobjectunreference) (void \*obj) | Decreases the reference count of a native object and when the reference count reaches 0, destroys this object. | -| [OH_NativeWindow_GetNativeObjectMagic](#oh_nativewindow_getnativeobjectmagic) (void \*obj) | Obtains the magic ID of a native object. | -| [OH_NativeWindow_NativeWindowSetScalingMode](#oh_nativewindow_nativewindowsetscalingmode) (OHNativeWindow \*window, uint32_t sequence, [OHScalingMode](#ohscalingmode) scalingMode) | Sets the scaling mode for a native window. | -| [OH_NativeWindow_NativeWindowSetMetaData](#oh_nativewindow_nativewindowsetmetadata) (OHNativeWindow \*window, uint32_t sequence, int32_t size, const [OHHDRMetaData](_o_h_h_d_r_meta_data.md) \*metaData) | Sets the metadata for a native window. | -| [OH_NativeWindow_NativeWindowSetMetaDataSet](#oh_nativewindow_nativewindowsetmetadataset) (OHNativeWindow \*window, uint32_t sequence, [OHHDRMetadataKey](#ohhdrmetadatakey) key, int32_t size, const uint8_t \*metaData) | Sets the metadata set for a native window. | -| [OH_NativeWindow_NativeWindowSetTunnelHandle](#oh_nativewindow_nativewindowsettunnelhandle) (OHNativeWindow \*window, const [OHExtDataHandle](_o_h_ext_data_handle.md) \*handle) | Sets a tunnel handle for a native window. | +| [OH_NativeWindow_CreateNativeWindow](#oh_nativewindow_createnativewindow) (void \*pSurface) | Creates a **NativeWindow** instance. A new **NativeWindow** instance is created each time this function is called.| +| [OH_NativeWindow_DestroyNativeWindow](#oh_nativewindow_destroynativewindow) (OHNativeWindow \*window) | Decreases the reference count of a **NativeWindow** instance by 1 and when the reference count reaches 0, destroys the instance.| +| [OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer](#oh_nativewindow_createnativewindowbufferfromsurfacebuffer) (void \*pSurfaceBuffer) | Creates a **NativeWindowBuffer** instance. A new **NativeWindowBuffer** instance is created each time this function is called.| +| [OH_NativeWindow_DestroyNativeWindowBuffer](#oh_nativewindow_destroynativewindowbuffer) (OHNativeWindowBuffer \*buffer) | Decreases the reference count of a **NativeWindowBuffer** instance by 1 and when the reference count reaches 0, destroys the instance.| +| [OH_NativeWindow_NativeWindowRequestBuffer](#oh_nativewindow_nativewindowrequestbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*\*buffer, int \*fenceFd) | Requests a **NativeWindowBuffer** through a **NativeWindow** instance for content production.| +| [OH_NativeWindow_NativeWindowFlushBuffer](#oh_nativewindow_nativewindowflushbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer, int fenceFd, [Region](_region.md) region) | Flushes the **NativeWindowBuffer** filled with the content to the buffer queue through a **NativeWindow** instance for content consumption.| +| [OH_NativeWindow_NativeWindowAbortBuffer](#oh_nativewindow_nativewindowabortbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer) | Returns the **NativeWindowBuffer** to the buffer queue through a **NativeWindow** instance, without filling in any content. The **NativeWindowBuffer** can be used for another request.| +| [OH_NativeWindow_NativeWindowHandleOpt](#oh_nativewindow_nativewindowhandleopt) (OHNativeWindow \*window, int code,...) | Sets or obtains the attributes of a native window, including the width, height, and content format.| +| [OH_NativeWindow_GetBufferHandleFromNative](#oh_nativewindow_getbufferhandlefromnative) (OHNativeWindowBuffer \*buffer) | Obtains the pointer to a **BufferHandle** of a **NativeWindowBuffer** instance.| +| [OH_NativeWindow_NativeObjectReference](#oh_nativewindow_nativeobjectreference) (void \*obj) | Adds the reference count of a native object.| +| [OH_NativeWindow_NativeObjectUnreference](#oh_nativewindow_nativeobjectunreference) (void \*obj) | Decreases the reference count of a native object and when the reference count reaches 0, destroys this object.| +| [OH_NativeWindow_GetNativeObjectMagic](#oh_nativewindow_getnativeobjectmagic) (void \*obj) | Obtains the magic ID of a native object.| +| [OH_NativeWindow_NativeWindowSetScalingMode(deprecated)](#oh_nativewindow_nativewindowsetscalingmode) (OHNativeWindow \*window, uint32_t sequence, [OHScalingMode](#ohscalingmode) scalingMode) | Sets the scaling mode for a native window. This function is deprecated since API version 9 and is expected to be deleted from API version 14.| +| [OH_NativeWindow_NativeWindowSetMetaData(deprecated)](#oh_nativewindow_nativewindowsetmetadata) (OHNativeWindow \*window, uint32_t sequence, int32_t size, const [OHHDRMetaData](_o_h_h_d_r_meta_data.md) \*metaData) | Sets the metadata for a native window. This function is deprecated since API version 9 and is expected to be deleted from API version 14.| +| [OH_NativeWindow_NativeWindowSetMetaDataSet(deprecated)](#oh_nativewindow_nativewindowsetmetadataset) (OHNativeWindow \*window, uint32_t sequence, [OHHDRMetadataKey](#ohhdrmetadatakey) key, int32_t size, const uint8_t \*metaData) | Sets the metadata set for a native window. This function is deprecated since API version 9 and is expected to be deleted from API version 14.| +| [OH_NativeWindow_NativeWindowSetTunnelHandle(deprecated)](#oh_nativewindow_nativewindowsettunnelhandle) (OHNativeWindow \*window, const [OHExtDataHandle](_o_h_ext_data_handle.md) \*handle) | Sets a tunnel handle for a native window. This function is deprecated since API version 9 and is expected to be deleted from API version 14.| + + +## Detailed Description ## Enum Description @@ -79,72 +84,78 @@ Provides the native window capability for connection to the EGL. ``` enum NativeWindowOperation ``` -**Description**
+ +**Description** + Enumerates the operation codes in the **OH_NativeWindow_NativeWindowHandleOpt** function. -| Name | Description | + | Value| Description| | -------- | -------- | -| SET_BUFFER_GEOMETRY | Setting the geometry for the local window buffer. Variable arguments in the function: [Input] int32_t height and [Input] int32_t width. | -| GET_BUFFER_GEOMETRY | Obtaining the geometry of the local window buffer. Variable arguments in the function: [Output] int32_t \*height and [Output] int32_t \*width. | -| GET_FORMAT | Obtaining the format of the local window buffer. Variable argument in the function: [Output] int32_t \*format. | -| SET_FORMAT | Setting the format for the local window buffer. Variable argument in the function: [Input] int32_t format. | -| GET_USAGE | Obtaining the usage mode of the local window buffer. Variable argument in the function: [Output] int32_t \*usage. | -| SET_USAGE | Setting the usage mode for the local window buffer. Variable argument in the function: [Input] int32_t usage. | -| SET_STRIDE | Setting the stride for the local window buffer. Variable argument in the function: [Input] int32_t stride. | -| GET_STRIDE | Obtaining the stride of the local window buffer. Variable argument in the function: [Output] int32_t \*stride. | -| SET_SWAP_INTERVAL | Setting the swap interval for the local window buffer. Variable argument in the function: [Input] int32_t interval. | -| GET_SWAP_INTERVAL | Obtaining the swap interval of the local window buffer. Variable argument in the function: [Output] int32_t \*interval. | -| SET_TIMEOUT | Setting the timeout duration for requesting the local window buffer. Variable argument in the function: [Input] int32_t timeout. | -| GET_TIMEOUT | Obtaining the timeout duration for requesting the local window buffer. Variable argument in the function: [Output] int32_t \*timeout. | -| SET_COLOR_GAMUT | Setting the color gamut for the local window buffer. Variable argument in the function: [Input] int32_t colorGamut. | -| GET_COLOR_GAMUT | Obtaining the color gamut of the local window buffer. Variable argument in the function: [out int32_t \*colorGamut]. | -| SET_TRANSFORM | Setting the transform for the local window buffer. Variable argument in the function: [Input] int32_t transform. | -| GET_TRANSFORM | Obtaining the transform of the local window buffer. Variable argument in the function: [Output] int32_t \*transform. | -| SET_UI_TIMESTAMP | Setting the UI timestamp for the local window buffer. Variable argument in the function: [Input] uint64_t uiTimestamp. | - - -### OHHDRMetadataKey +| SET_BUFFER_GEOMETRY | Setting the geometry for the local window buffer.
Variable arguments in the function: [Input] int32_t height and [Input] int32_t width.| +| GET_BUFFER_GEOMETRY | Obtaining the geometry of the local window buffer.
Variable arguments in the function: [Output] int32_t *height and [Output] int32_t *width.| +| GET_FORMAT | Obtaining the format of the local window buffer.
Variable argument in the function: [Output] int32_t *format.| +| SET_FORMAT | Setting the format for the local window buffer.
Variable argument in the function: [Input] int32_t format.| +| GET_USAGE | Obtaining the usage mode of the local window buffer.
Variable argument in the function: [Output] int32_t *usage.| +| SET_USAGE | Setting the usage mode of the local window buffer.
Variable argument in the function: [Input] int32_t usage.| +| SET_STRIDE | Setting the stride for the local window buffer.
Variable argument in the function: [Input] int32_t stride.| +| GET_STRIDE | Obtaining the stride of the local window buffer.
Variable argument in the function: [Output] int32_t *stride.| +| SET_SWAP_INTERVAL | Setting the swap interval for the local window buffer.
Variable argument in the function: [Input] int32_t interval.| +| GET_SWAP_INTERVAL | Obtaining the swap interval of the local window buffer.
Variable argument in the function: [Output] int32_t *interval.| +| SET_TIMEOUT | Setting the timeout duration for requesting the local window buffer.
Variable argument in the function: [Input] int32_t timeout.| +| GET_TIMEOUT | Obtaining the timeout duration for requesting the local window buffer.
Variable argument in the function: [Output] int32_t *timeout.| +| SET_COLOR_GAMUT | Setting the color gamut for the local window buffer.
Variable argument in the function: [Input] int32_t colorGamut.| +| GET_COLOR_GAMUT | Obtaining the color gamut of the local window buffer.
Variable argument in the function: [Output] int32_t *colorGamut.| +| SET_TRANSFORM | Setting the transform for the local window buffer.
Variable argument in the function: [Input] int32_t transform.| +| GET_TRANSFORM | Obtaining the transform of the local window buffer.
Variable argument in the function: [Output] int32_t *transform.| +| SET_UI_TIMESTAMP | Setting the UI timestamp for the local window buffer.
Variable argument in the function: [Input] uint64_t uiTimestamp.| + + +### OHHDRMetadataKey(deprecated) ``` enum OHHDRMetadataKey ``` -**Description**
-Enumerates the HDR metadata keys. -| Name | Description | +**Description** + +Enumerates the HDR metadata keys. This enum is deprecated since API version 9 and is expected to be deleted from API version 14. + + | Value| Description| | -------- | -------- | -| OH_METAKEY_RED_PRIMARY_X | X coordinate of the red primary color. | -| OH_METAKEY_RED_PRIMARY_Y | Y coordinate of the red primary color. | -| OH_METAKEY_GREEN_PRIMARY_X | X coordinate of the green primary color. | -| OH_METAKEY_GREEN_PRIMARY_Y | Y coordinate of the green primary color. | -| OH_METAKEY_BLUE_PRIMARY_X | X coordinate of the blue primary color. | -| OH_METAKEY_BLUE_PRIMARY_Y | Y coordinate of the blue primary color. | -| OH_METAKEY_WHITE_PRIMARY_X | X coordinate of the white point. | -| OH_METAKEY_WHITE_PRIMARY_Y | Y coordinate of the white point. | -| OH_METAKEY_MAX_LUMINANCE | Maximum luminance. | -| OH_METAKEY_MIN_LUMINANCE | Minimum luminance. | -| OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL | Maximum content light level (MaxCLL). | -| OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL | Maximum frame average light level (MaxFALLL). | -| OH_METAKEY_HDR10_PLUS | HDR10+. | -| OH_METAKEY_HDR_VIVID | Vivid. | - - -### OHScalingMode +| OH_METAKEY_RED_PRIMARY_X | X coordinate of the red primary color.| +| OH_METAKEY_RED_PRIMARY_Y | Y coordinate of the red primary color.| +| OH_METAKEY_GREEN_PRIMARY_X | X coordinate of the green primary color.| +| OH_METAKEY_GREEN_PRIMARY_Y | Y coordinate of the green primary color.| +| OH_METAKEY_BLUE_PRIMARY_X | X coordinate of the blue primary color.| +| OH_METAKEY_BLUE_PRIMARY_Y | Y coordinate of the blue primary color.| +| OH_METAKEY_WHITE_PRIMARY_X | X coordinate of the white point.| +| OH_METAKEY_WHITE_PRIMARY_Y | Y coordinate of the white point.| +| OH_METAKEY_MAX_LUMINANCE | Maximum luminance.| +| OH_METAKEY_MIN_LUMINANCE | Minimum luminance.| +| OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL | Maximum content light level (MaxCLL).| +| OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL | Maximum frame average light level (MaxFALLL).| +| OH_METAKEY_HDR10_PLUS | HDR10 Plus | +| OH_METAKEY_HDR_VIVID | Vivid | + + +### OHScalingMode(deprecated) ``` enum OHScalingMode ``` -**Description**
-Enumerates the scaling modes. -| Name | Description | +**Description** + +Enumerates the scaling modes. This enum is deprecated since API version 9 and is expected to be deleted from API version 14. + + | Value| Description| | -------- | -------- | -| OH_SCALING_MODE_FREEZE | The window content cannot be updated before the buffer of the window size is received. | -| OH_SCALING_MODE_SCALE_TO_WINDOW | The buffer is scaled in two dimensions to match the window size. | -| OH_SCALING_MODE_SCALE_CROP | The buffer is scaled uniformly so that its smaller size can match the window size. | -| OH_SCALING_MODE_NO_SCALE_CROP | The window is cropped to the size of the buffer's cropping rectangle. Pixels outside the cropping rectangle are considered completely transparent. | +| OH_SCALING_MODE_FREEZE | The window content cannot be updated before the buffer of the window size is received.| +| OH_SCALING_MODE_SCALE_TO_WINDOW | The buffer is scaled in two dimensions to match the window size.| +| OH_SCALING_MODE_SCALE_CROP | The buffer is scaled uniformly so that its smaller size can match the window size.| +| OH_SCALING_MODE_NO_SCALE_CROP | The window is cropped to the size of the buffer's cropping rectangle. Pixels outside the cropping rectangle are considered completely transparent.| ## Function Description @@ -156,21 +167,27 @@ Enumerates the scaling modes. ``` OHNativeWindow* OH_NativeWindow_CreateNativeWindow (void * pSurface) ``` -**Description**
+ +**Description** + Creates a **NativeWindow** instance. A new **NativeWindow** instance is created each time this function is called. \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| pSurface | Indicates the pointer to a **ProduceSurface**. The type is **sptr<OHOS::Surface>**. | +| pSurface | Indicates the pointer to a **ProduceSurface**. The type is **sptr<OHOS::Surface>**.| **Returns** Returns the pointer to the **NativeWindow** instance created. +**Since** + +8 + ### OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer() @@ -178,21 +195,27 @@ Returns the pointer to the **NativeWindow** instance created. ``` OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer (void * pSurfaceBuffer) ``` -**Description**
+ +**Description** + Creates a **NativeWindowBuffer** instance. A new **NativeWindowBuffer** instance is created each time this function is called. \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| pSurfaceBuffer | Indicates the pointer to a produce buffer. The type is **sptr<OHOS::SurfaceBuffer>**. | +| pSurfaceBuffer | Indicates the pointer to a **ProduceSurface**. The type is **sptr<OHOS::SurfaceBuffer>**.| **Returns** Returns the pointer to the **NativeWindowBuffer** instance created. +**Since** + +8 + ### OH_NativeWindow_DestroyNativeWindow() @@ -200,16 +223,22 @@ Returns the pointer to the **NativeWindowBuffer** instance created. ``` void OH_NativeWindow_DestroyNativeWindow (OHNativeWindow * window) ``` -**Description**
+ +**Description** + Decreases the reference count of a **NativeWindow** instance by 1 and when the reference count reaches 0, destroys the instance. \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| window | Indicates the pointer to a **NativeWindow** instance. | +| window | Indicates the pointer to a **NativeWindow** instance.| + +**Since** + +8 ### OH_NativeWindow_DestroyNativeWindowBuffer() @@ -218,16 +247,22 @@ Decreases the reference count of a **NativeWindow** instance by 1 and when the r ``` void OH_NativeWindow_DestroyNativeWindowBuffer (OHNativeWindowBuffer * buffer) ``` -**Description**
+ +**Description** + Decreases the reference count of a **NativeWindowBuffer** instance by 1 and when the reference count reaches 0, destroys the instance. \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| buffer | Indicates the pointer to a **NativeWindowBuffer** instance. | +| buffer | Indicates the pointer to a **NativeWindowBuffer** instance.| + +**Since** + +8 ### OH_NativeWindow_GetBufferHandleFromNative() @@ -236,21 +271,27 @@ Decreases the reference count of a **NativeWindowBuffer** instance by 1 and when ``` BufferHandle* OH_NativeWindow_GetBufferHandleFromNative (OHNativeWindowBuffer * buffer) ``` -**Description**
+ +**Description** + Obtains the pointer to a **BufferHandle** of a **NativeWindowBuffer** instance. \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| buffer | Indicates the pointer to a **NativeWindowBuffer** instance. | +| buffer | Indicates the pointer to a **NativeWindowBuffer** instance.| **Returns** Returns the pointer to the **BufferHandle** instance obtained. +**Since** + +8 + ### OH_NativeWindow_GetNativeObjectMagic() @@ -258,21 +299,27 @@ Returns the pointer to the **BufferHandle** instance obtained. ``` int32_t OH_NativeWindow_GetNativeObjectMagic (void * obj) ``` -**Description**
+ +**Description** + Obtains the magic ID of a native object. \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| obj | Indicates the pointer to a **NativeWindow** or **NativeWindowBuffer** instance. | +| obj | Indicates the pointer to a **NativeWindow** or **NativeWindowBuffer** instance.| **Returns** Returns the magic ID, which is unique for each native object. +**Since** + +8 + ### OH_NativeWindow_NativeObjectReference() @@ -280,21 +327,27 @@ Returns the magic ID, which is unique for each native object. ``` int32_t OH_NativeWindow_NativeObjectReference (void * obj) ``` -**Description**
+ +**Description** + Adds the reference count of a native object. \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| obj | Indicates the pointer to a **NativeWindow** or **NativeWindowBuffer** instance. | +| obj | Indicates the pointer to a **NativeWindow** or **NativeWindowBuffer** instance.| **Returns** Returns an error code defined in **GSError**. +**Since** + +8 + ### OH_NativeWindow_NativeObjectUnreference() @@ -302,21 +355,27 @@ Returns an error code defined in **GSError**. ``` int32_t OH_NativeWindow_NativeObjectUnreference (void * obj) ``` -**Description**
+ +**Description** + Decreases the reference count of a native object and when the reference count reaches 0, destroys this object. \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| obj | Indicates the pointer to a **NativeWindow** or **NativeWindowBuffer** instance. | +| obj | Indicates the pointer to a **NativeWindow** or **NativeWindowBuffer** instance.| **Returns** Returns an error code defined in **GSError**. +**Since** + +8 + ### OH_NativeWindow_NativeWindowAbortBuffer() @@ -324,22 +383,28 @@ Returns an error code defined in **GSError**. ``` int32_t OH_NativeWindow_NativeWindowAbortBuffer (OHNativeWindow * window, OHNativeWindowBuffer * buffer ) ``` -**Description**
+ +**Description** + Returns the **NativeWindowBuffer** to the buffer queue through a **NativeWindow** instance, without filling in any content. The **NativeWindowBuffer** can be used for another request. \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| window | Indicates the pointer to a **NativeWindow** instance. | -| buffer | Indicates the pointer to a **NativeWindowBuffer** instance. | +| window | Indicates the pointer to a **NativeWindow** instance.| +| buffer | Indicates the pointer to a **NativeWindowBuffer** instance.| **Returns** Returns an error code defined in **GSError**. +**Since** + +8 + ### OH_NativeWindow_NativeWindowFlushBuffer() @@ -347,24 +412,30 @@ Returns an error code defined in **GSError**. ``` int32_t OH_NativeWindow_NativeWindowFlushBuffer (OHNativeWindow * window, OHNativeWindowBuffer * buffer, int fenceFd, Region region ) ``` -**Description**
+ +**Description** + Flushes the **NativeWindowBuffer** filled with the content to the buffer queue through a **NativeWindow** instance for content consumption. \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| window | Indicates the pointer to a **NativeWindow** instance. | -| buffer | Indicates the pointer to a **NativeWindowBuffer** instance. | -| fenceFd | Indicates a file descriptor handle, which is used for timing synchronization. | -| region | Indicates a dirty region where content is updated. | +| window | Indicates the pointer to a **NativeWindow** instance.| +| buffer | Indicates the pointer to a **NativeWindowBuffer** instance.| +| fenceFd | Indicates a file descriptor handle, which is used for timing synchronization.| +| region | Indicates a dirty region where content is updated.| **Returns** Returns an error code defined in **GSError**. +**Since** + +8 + ### OH_NativeWindow_NativeWindowHandleOpt() @@ -372,23 +443,29 @@ Returns an error code defined in **GSError**. ``` int32_t OH_NativeWindow_NativeWindowHandleOpt (OHNativeWindow * window, int code, ... ) ``` -**Description**
+ +**Description** + Sets or obtains the attributes of a native window, including the width, height, and content format. \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| window | Indicates the pointer to a **NativeWindow** instance. | -| code | Indicates the operation code. For details, see [NativeWindowOperation](#nativewindowoperation). | -| ... | Indicates the variable argument, which must correspond to the operation code. | +| window | Indicates the pointer to a **NativeWindow** instance.| +| code | Indicates the operation code. For details, see [NativeWindowOperation](#nativewindowoperation).| +| ... | Indicates the variable argument, which must correspond to the operation code.| **Returns** Returns an error code defined in **GSError**. +**Since** + +8 + ### OH_NativeWindow_NativeWindowRequestBuffer() @@ -396,117 +473,151 @@ Returns an error code defined in **GSError**. ``` int32_t OH_NativeWindow_NativeWindowRequestBuffer (OHNativeWindow * window, OHNativeWindowBuffer ** buffer, int * fenceFd ) ``` -**Description**
+ +**Description** + Requests a **NativeWindowBuffer** through a **NativeWindow** instance for content production. \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| window | Indicates the pointer to a **NativeWindow** instance. | -| buffer | Indicates the double pointer to a **NativeWindowBuffer** instance. | -| fenceFd | Indicates the pointer to a file descriptor handle. | +| window | Indicates the pointer to a **NativeWindow** instance.| +| buffer | Indicates the double pointer to a **NativeWindowBuffer** instance.| +| fenceFd | Indicates the pointer to a file descriptor handle.| **Returns** Returns an error code defined in **GSError**. +**Since** + +8 + -### OH_NativeWindow_NativeWindowSetMetaData() +### OH_NativeWindow_NativeWindowSetMetaData()(deprecated) ``` int32_t OH_NativeWindow_NativeWindowSetMetaData (OHNativeWindow * window, uint32_t sequence, int32_t size, const OHHDRMetaData * metaData ) ``` -**Description**
+ +**Description** + Sets the metadata for a native window. +This function is deprecated since API version 9 and is expected to be deleted from API version 14. \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| window | Indicates the pointer to a **NativeWindow** instance. | -| sequence | Indicates the sequence of the producer buffer. | -| size | Indicates the size of the **[OHHDRMetaData](_o_h_h_d_r_meta_data.md)** array. | -| metaData | Indicates the pointer to the **[OHHDRMetaData](_o_h_h_d_r_meta_data.md)** array. | +| window | Indicates the pointer to a **NativeWindow** instance.| +| sequence | Indicates the sequence of the producer buffer.| +| size | Indicates the size of the **OHHDRMetaData** array.| +| metaData| Indicates the pointer to the **OHHDRMetaData** array.| **Returns** Returns an error code defined in **GSError**. +**Since** + +9 + -### OH_NativeWindow_NativeWindowSetMetaDataSet() +### OH_NativeWindow_NativeWindowSetMetaDataSet()(deprecated) ``` int32_t OH_NativeWindow_NativeWindowSetMetaDataSet (OHNativeWindow * window, uint32_t sequence, OHHDRMetadataKey key, int32_t size, const uint8_t * metaData ) ``` -**Description**
+ +**Description** + Sets the metadata set for a native window. +This function is deprecated since API version 9 and is expected to be deleted from API version 14. \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| window | Indicates the pointer to a **NativeWindow** instance. | -| sequence | Indicates the sequence of the producer buffer. | -| key | Indicates a metadata key. For details, see **OHHDRMetadataKey**. | -| size | Indicates the size of the uint8_t vector. | -| metaData | Indicates the pointer to the uint8_t vector. | +| window | Indicates the pointer to a **NativeWindow** instance.| +| sequence | Indicates the sequence of the producer buffer.| +| key | Indicates a metadata key. For details, see [OHHDRMetadataKey](#ohhdrmetadatakey).| +| size | Indicates the size of the uint8_t vector.| +| metaData| Indicates the pointer to the uint8_t vector.| **Returns** Returns an error code defined in **GSError**. +**Since** -### OH_NativeWindow_NativeWindowSetScalingMode() +9 + + +### OH_NativeWindow_NativeWindowSetScalingMode()(deprecated) ``` int32_t OH_NativeWindow_NativeWindowSetScalingMode (OHNativeWindow * window, uint32_t sequence, OHScalingMode scalingMode ) ``` -**Description**
+ +**Description** + Sets the scaling mode for a native window. +This function is deprecated since API version 9 and is expected to be deleted from API version 14. \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| window | Indicates the pointer to a **NativeWindow** instance. | -| sequence | Indicates the sequence of the producer buffer. | -| scalingMode | Indicates the scaling mode to set. For details, see **OHScalingMode**. | +| window | Indicates the pointer to a **NativeWindow** instance.| +| sequence | Indicates the sequence of the producer buffer.| +| scalingMode | Indicates the scaling mode to set. For details, see [OHScalingMode](#ohscalingmode).| **Returns** Returns an error code defined in **GSError**. +**Since** + +9 -### OH_NativeWindow_NativeWindowSetTunnelHandle() + +### OH_NativeWindow_NativeWindowSetTunnelHandle()(deprecated) ``` int32_t OH_NativeWindow_NativeWindowSetTunnelHandle (OHNativeWindow * window, const OHExtDataHandle * handle ) ``` -**Description**
+ +**Description** + Sets a tunnel handle for a native window. +This function is deprecated since API version 9 and is expected to be deleted from API version 14. \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| window | Indicates the pointer to a **NativeWindow** instance. | -| handle | Indicates the pointer to an **[OHExtDataHandle](_o_h_ext_data_handle.md)**. | +| window | Indicates the pointer to a **NativeWindow** instance.| +| handle | Indicates the pointer to an [OHExtDataHandle](_o_h_ext_data_handle.md).| **Returns** Returns an error code defined in **GSError**. + +**Since** + +9 diff --git a/en/application-dev/reference/native-apis/image.md b/en/application-dev/reference/native-apis/image.md index 365d04c8dca0a1b718593337237a8e5fb4f0bcb9..828deade6aa8c410facb355dd9669d4b8489862c 100644 --- a/en/application-dev/reference/native-apis/image.md +++ b/en/application-dev/reference/native-apis/image.md @@ -19,7 +19,7 @@ To use the APIs in this file, **libpixelmap_ndk.z.so** is required. | Name| Description| | -------- | -------- | -| [image_pixel_map_napi.h](image__pixel__map__napi_8h.md) | Declares the APIs that can lock, access, and unlock a pixel map.
File to include:: | +| [image_pixel_map_napi.h](image__pixel__map__napi_8h.md) | Declares the APIs that can lock, access, and unlock a pixel map.
File to include: | ### Structs diff --git a/en/application-dev/security/permission-list.md b/en/application-dev/security/permission-list.md index f598c23376424ab5dbcb99e99691584ce444dc7d..4fb1f38e88257a8e2dc9ad8e4a64da851a9d20b6 100644 --- a/en/application-dev/security/permission-list.md +++ b/en/application-dev/security/permission-list.md @@ -26,7 +26,7 @@ Allows an application to configure Bluetooth on a device, initiate or cancel a s ## ohos.permission.MANAGE_BLUETOOTH -Allows an application to pair with a Bluetooth device and access the contacts or messages of the device. +Allows an application to pair with a Bluetooth device and access the Contacts or messages of the device. **Permission level**: system_basic @@ -994,6 +994,16 @@ Allows the device administrator application to set application running policies. **Enable via ACL**: TRUE +## ohos.permission.ENTERPRISE_SET_SCREENOFF_TIME + +Allows the device administrator application to set the screen off time. + +**Permission level**: system_basic + +**Authorization mode**: system_grant + +**Enable via ACL**: TRUE + ## ohos.permission.NFC_TAG Allows an application to read NFC tag information. @@ -1076,7 +1086,7 @@ Allows an application to read cell broadcast messages received by the device. ## ohos.permission.READ_CONTACTS -Allows an application to read contacts. +Allows an application to read the Contacts. **Permission level**: system_basic @@ -1506,7 +1516,7 @@ Allows an application to install, uninstall, enable, and disable certificates an **Authorization mode**: system_grant -**Enable ACL**: FALSE +**Enable via ACL**: TRUE ## ohos.permission.ACCESS_CERT_MANAGER @@ -1877,3 +1887,33 @@ Allows an application to modify HiView data. **Authorization mode**: system_grant **Enable via ACL**: TRUE + +## ohos.permission.ACCESS_CAST_ENGINE_MIRROR + +Allows an application to use the mirror projection capability. + +**Permission level**: system_basic + +**Authorization mode**: system_grant + +**Enable via ACL**: TRUE + +## ohos.permission.ACCESS_CAST_ENGINE_STREAM + +Allows an application to invoke the local or online media resource projection capability. + +**Permission level**: system_basic + +**Authorization mode**: system_grant + +**Enable via ACL**: TRUE + +## ohos.permission.CLOUDDATA_CONFIG + +Allows an application to obtain the device-cloud information of the configuration database. + +**Permission level**: system_basic + +**Authorization mode**: system_grant + +**Enable via ACL**: TRUE diff --git a/en/application-dev/task-management/transient-task-dev-guide.md b/en/application-dev/task-management/transient-task-dev-guide.md index a83ba2094138e2271f55758484f483a9a7ddbaed..cb540210efac85a45f709b878b6b85dcf9024084 100644 --- a/en/application-dev/task-management/transient-task-dev-guide.md +++ b/en/application-dev/task-management/transient-task-dev-guide.md @@ -6,7 +6,7 @@ By default, an application can run for a period of 6 to 12 seconds after it swit You are advised not to call the [requestSuspendDelay()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagerrequestsuspenddelay) method to apply for delayed suspension after the application is running in the background. Instead, you need to call this interface to declare the execution time of the extended application to the system before performing any time-consuming operation. It is recommended that an application calls [requestSuspendDelay()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagerrequestsuspenddelay) when it is running in the foreground, so as not to affect the transient task quota of the application. -An application can obtain the remaining duration before being suspended by calling [getRemainingDelayTime()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagergetremainingdelaytimecallback). Each application has a daily time quota for transient tasks. Therefore, after the time-consuming task finishes execution, the application should call [cancelSuspendDelay()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagercancelsuspenddelay) to cancel the transient task in a timely manner. +An application can obtain the remaining duration before being suspended by calling [getRemainingDelayTime()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagergetremainingdelaytime). Each application has a daily time quota for transient tasks. Therefore, after the time-consuming task finishes execution, the application should call [cancelSuspendDelay()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagercancelsuspenddelay) to cancel the transient task in a timely manner. Typical time-consuming tasks include saving status data to the local database, opening and processing a large file, and synchronizing data to the cloud server. diff --git a/en/application-dev/telephony/telephony-sms.md b/en/application-dev/telephony/telephony-sms.md index 714d2f182b9e5452065db19f171b5dc45e522f73..400f06ac804cbbcf5875cdca518dec3cf978cc2a 100644 --- a/en/application-dev/telephony/telephony-sms.md +++ b/en/application-dev/telephony/telephony-sms.md @@ -31,11 +31,11 @@ The Short Messaging Service (SMS) module provides basic SMS management functions | Name | Description | | ------------------------------------------------------------ | ------------------------------------------------------- | -| createMessage(pdu: Array, specification: string, callback: AsyncCallback): void | Creates an SMS message instance based on the PDU and the specified SMS protocol.| +| createMessage(pdu: Array, specification: string, callback: AsyncCallback\): void | Creates an SMS message instance based on the PDU and the specified SMS protocol.| | sendMessage(options: SendMessageOptions): void | Sends text or data SMS messages. | -| getDefaultSmsSlotId(callback: AsyncCallback): void | Obtains the ID of the default SIM card used to send SMS messages. | -| setSmscAddr(slotId: number, smscAddr: string, callback: AsyncCallback): void | Sets the SMSC address based on the specified slot ID. | -| getSmscAddr(slotId: number, callback: AsyncCallback): void | Obtains the SMSC address based on the specified slot ID. | +| getDefaultSmsSlotId(callback: AsyncCallback\): void | Obtains the ID of the default SIM card used to send SMS messages. | +| setSmscAddr(slotId: number, smscAddr: string, callback: AsyncCallback\): void | Sets the SMSC address based on the specified slot ID. | +| getSmscAddr(slotId: number, callback: AsyncCallback\): void | Obtains the SMSC address based on the specified slot ID. | ## How to Develop diff --git a/en/application-dev/tools/packing-tool.md b/en/application-dev/tools/packing-tool.md index 36b5c7fdc295604d7bc46db5e01300e517514ade..db0f232d6c53cdb7bf47c540010c2aea3f83d06c 100644 --- a/en/application-dev/tools/packing-tool.md +++ b/en/application-dev/tools/packing-tool.md @@ -1,90 +1,617 @@ -# Packaging Tool - - -The packaging tool is a commissioning tool provided by OpenHarmony. It can generate HAP files in command line mode, pack multiple HAP files into an App Pack, or pack multiple HAP files and App Packs into an App Pack. App Pack is the application package format required for releasing an application on AppGallery. - - -The **app_packing_tool.jar** package can be found in the OpenHarmony SDK downloaded locally. - - -- Packing folders into an HAP file - -The command in the stage model is as follows: - - - ```bash - java -jar app_packing_tool.jar --mode