diff --git a/en/application-dev/ability/ability-brief.md b/en/application-dev/ability/ability-brief.md index 06cf48ff0213a6bae33e0cd5d0a2c2cf4b5d042d..283037aedc8c219bee48511898dd300a0c05dc3b 100644 --- a/en/application-dev/ability/ability-brief.md +++ b/en/application-dev/ability/ability-brief.md @@ -1,20 +1,20 @@ # Ability Framework Overview -An ability is the abstraction of a functionality that an application can provide. It is the minimum unit for the system to schedule applications. An application can contain one or more **Ability** instances. +An ability is the abstraction of a functionality that an application can provide. It is the minimum unit for the system to schedule applications. An application can contain one or more `Ability` instances. The ability framework model has two forms. -- FA model, which applies to application development using API 8 and earlier versions. In the FA model, there are Feature Ability (FA) and Particle Ability (PA). The FA supports Page abilities, and the PA supports Service, Data, and Form abilities. -- Stage model, which is introduced since API 9. In the stage model, there are Ability and ExtensionAbility. The ExtensionAbility is further extended to ServiceExtensionAbility, FormExtensionAbility, DataShareExtensionAbility, and more. +- FA model, which applies to application development using API version 8 and earlier versions. In the FA model, there are Feature Ability (FA) and Particle Ability (PA). The FA supports Page abilities, and the PA supports Service, Data, and Form abilities. +- Stage model, which is introduced since API version 9. In the stage model, there are Ability and ExtensionAbility. The ExtensionAbility is further extended to ServiceExtensionAbility, FormExtensionAbility, DataShareExtensionAbility, and more. The stage model is designed to make it easier to develop complex applications in the distributed environment. The table below lists the design differences between the two models. | Item | FA Model | Stage Model | | -------------- | ------------------------------------------------------------ | -------------------------------------------------------- | -| Development mode | Web-like APIs are provided. The UI development is the same as that of the stage model. | Object-oriented development mode is provided. The UI development is the same as that of the FA model. | +| Development mode | Web-like APIs are provided. The UI development is the same as that of the stage model. | Object-oriented development mode is provided. The UI development is the same as that of the FA model. | | Engine instance | Each ability in a process exclusively uses a JS VM engine instance. | Multiple abilities in a process share one JS VM engine instance. | -| Intra-process object sharing| Not supported. | Supported. | -| Bundle description file | The **config.json** file is used to describe the HAP and component information. The component must use a fixed file name.| The **module.json** file is used to describe the HAP and component information. The entry file name can be specified.| +| Intra-process object sharing| Not supported. | Supported. | +| Bundle description file | The `config.json` file is used to describe the HAP and component information. Each component must use a fixed file name.| The `module.json` file is used to describe the HAP and component information. The entry file name can be specified.| | Component | Four types of components are provided: Page ability (used for UI page display), Service ability (used to provide services), Data ability (used for data sharing), and Form ability (used to provide widgets).| Two types of components are provided: Ability (used for UI page display) and Extension (scenario-based service extension). | In addition, the following differences exist in the development process: @@ -29,3 +29,6 @@ In addition, the following differences exist in the development process: For details about the two models, see [FA Model Overview](fa-brief.md) and [Stage Model Overview](stage-brief.md). +## Samples +The following sample is provided to help you better understand how to develop abilities: +- [Intra- and Inter-page Navigation](https://gitee.com/openharmony/codelabs/tree/master/Ability/PageAbility) diff --git a/en/application-dev/ability/ability-delegator.md b/en/application-dev/ability/ability-delegator.md index cc7547e3806385f9bfba6d21314065d788032cae..5fd0293efde6d6d264be28b6c30123e7697bee6b 100644 --- a/en/application-dev/ability/ability-delegator.md +++ b/en/application-dev/ability/ability-delegator.md @@ -22,20 +22,23 @@ To start the test framework, specify the **TestRunner** and the package name or An example command in the FA model is as follows: ```javascript -aa test -p com.example.myapplicationfaets -s unittest OpenHarmonyTestRunner -s class ActsAbilityTest -w 20 +aa test -b BundleName -p com.example.myapplicationfaets -s unittest OpenHarmonyTestRunner -s class ActsAbilityTest -w 20 ``` An example command in the stage model is as follows: ```javascript -aa test -m com.example.myapplicationfaets -s unittest OpenHarmonyTestRunner -s class ActsAbilityTest -w 20 +aa test -b BundleName -m com.example.myapplicationfaets -s unittest OpenHarmonyTestRunner -s class ActsAbilityTest -w 20 ``` | Parameter | Mandatory| Description | | --------------- | -------- | ------------------------------------------------------------ | +| -b | Yes | Bundle name of the HAP where the **TestRunner** is located. | | -p | Yes | Package name of the HAP where the **TestRunner** is located. This parameter is used by the FA model. | | -m | Yes | Module name of the HAP where the **TestRunner** is located. This parameter is used by the stage model. | | -s unittest | Yes | Name of the **TestRunner** to be used. The TestRunner name must be the same as the file name. | -| -w | No | Timeout interval of a test case, in seconds. If this parameter is not specified, the test framework exits only after **finishTest** is invoked.| -| -s \\ | No | It can be any parameter in the key-value format. The entered parameters can be obtained in key-value mode through **AbilityDelegatorArgs.parameters**. For example, in **-s classname myTest**, **classname** is the key and **myTest** is the value.| +| -w | No | Timeout interval of a test case, in seconds. If this parameter is not specified or is set to a value less than or equal to **0**, the test framework exits only after **finishTest** is invoked.| +| -s \\ | No | **-s** can be followed by any key-value pair obtained through **AbilityDelegatorArgs.parameters**. For example, in **-s classname myTest**, **-s classname** is the key and **myTest** is the value.| +| -D | No | Debug mode for starting the tested application.| +| -h | No | Help information.| ### Using DevEco Studio @@ -45,6 +48,14 @@ For details about how to use DevEco Studio to start the test framework, see [Ope **TestRunner** is the entry class of the test framework test process. When the test process is started, the system calls related APIs in **TestRunner**. You need to inherit this class and override the **onPrepare** and **onRun** APIs. When creating an application template, DevEco Studio initializes the default **TestRunner** and starts the default **TestAbility** in the **onRun** API. You can modify the test code of **TestAbility** or override **onPrepare** and **onRun** in **TestRunner** to implement your own test code. For details, see [TestRunner](../reference/apis/js-apis-testRunner.md). +## Introduction to AbilityDelegatorRegistry + +**AbilityDelegatorRegistry** is the **AbilityDelegator** repository class provided by the test framework. You can use **AbilityDelegatorRegistry** to obtain an **AbilityDelegator** instance and the input and generated parameters **AbilityDelegatorArgs** during the test. You can use **AbilityDelegator** to invoke the function set provided by the test framework for testing and verification. For details, see [AbilityDelegatorRegistry](../reference/apis/js-apis-abilityDelegatorRegistry.md). + +## Introduction to AbilityDelegatorArgs + +**AbilityDelegatorArgs** is a test parameter class provided by the test framework. You can use **AbilityDelegatorArgs** to obtain the parameters passed and generated during the test. For details, see [AbilityDelegatorArgs](../reference/apis/js-apis-application-abilityDelegatorArgs.md). + ## Introduction to AbilityMonitor **AbilityMonitor** is provided by the test framework for binding to and listening for abilities. You can use **AbilityMonitor** to bind to an **Ability** instance and add **AbilityMonitor** to the listening list. When **AbilityMonitor** is bound to an ability, the creation and lifecycle changes of the ability will trigger the related callback in **AbilityMonitor**. You can test and verify the ability in these callbacks. For details, see [AbilityMonitor](../reference/apis/js-apis-application-abilityMonitor.md). @@ -54,7 +65,7 @@ For details about how to use DevEco Studio to start the test framework, see [Ope ```javascript import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -function onAbilityCreateCallback() { +function onAbilityCreateCallback(data) { console.info("onAbilityCreateCallback"); } @@ -64,7 +75,7 @@ var monitor = { } var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); -abilityDelegator.addAbilityMonitor(monitor).then((void) => { +abilityDelegator.addAbilityMonitor(monitor).then(() => { console.info("addAbilityMonitor promise"); }); ``` @@ -94,7 +105,7 @@ var abilityDelegator; var ability; var timeout = 100; -function onAbilityCreateCallback() { +function onAbilityCreateCallback(data) { console.info("onAbilityCreateCallback"); } @@ -113,8 +124,6 @@ var want = { bundleName: "bundleName", abilityName: "abilityName" }; - -abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.startAbility(want, (err, data) => { console.info("startAbility callback"); }); @@ -126,14 +135,47 @@ abilityDelegator.startAbility(want, (err, data) => { ### Running a Shell Command -**AbilityDelegator** provides APIs to run shell commands. You can run a shell command in the test code. This feature takes effect only in the test environment. +**AbilityDelegator** provides APIs to run shell commands in the test environment. + **Example** ```javascript - var abilityDelegator; - var cmd = "cmd"; - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); - abilityDelegator.executeShellCommand(cmd, (err,data) => { +var abilityDelegator; +var cmd = "cmd"; +abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +abilityDelegator.executeShellCommand(cmd, (err, data) => { console.info("executeShellCommand callback"); - }); +}); +``` + +### Printing Log Information + +**AbilityDelegator** provides APIs for printing log information. You can call any API in the test code to print process logs to the unit test console. + +**Example** + +```javascript +var abilityDelegator; +var msg = "msg"; + +abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +abilityDelegator.print(msg, (err) => { + console.info("print callback"); +}); +``` + +### Finishing the Test and Printing Log Information + +**AbilityDelegator** provides the APIs for actively finishing the test. You can call any API in test code to finish the test and print logs to the unit test console. + +**Example** + +```javascript +var abilityDelegator; +var msg = "msg"; + +abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +abilityDelegator.finishTest(msg, 0, (err) => { + console.info("finishTest callback"); +}); ``` diff --git a/en/application-dev/ability/fa-brief.md b/en/application-dev/ability/fa-brief.md index 670c741d84218a261df7fa09d88e42c9b69a693f..cca353bb06253a17bbc7cfec2b823c67b8568ad0 100644 --- a/en/application-dev/ability/fa-brief.md +++ b/en/application-dev/ability/fa-brief.md @@ -3,14 +3,15 @@ ## Overall Architecture The development of an OpenHarmony application is essentially the development of one or more abilities. By scheduling abilities and managing their lifecycle, OpenHarmony implements application scheduling. -The Feature Ability (FA) model applies to application development using API 8 and earlier versions. In this model, there are Page, Service, Data, and Form abilities. +The Feature Ability (FA) model applies to application development using API version 8 and earlier versions. In this model, there are Page, Service, Data, and Form abilities. - The Page ability implements the ArkUI and provides the capability of interacting with users. - The Service ability does not have a UI. It runs in the background and provides custom services for other abilities to invoke. -- The Data ability does not have a UI. It also runs in the background and enables other abilities to insert, delete, and query data. +- The Data ability does not have a UI. It runs in the background and enables other abilities to insert, delete, and query data. - The Form ability provides a widget, which is a UI display mode. ## Application Package Structure -**The following figure shows the application package structure.** + +The following figure shows the application package structure. ![fa-package-info](figures/fa-package-info.png) @@ -18,7 +19,7 @@ For details about the application package structure, see [Description of the App ## Lifecycle -Among all abilities, the Page ability has the most complex lifecycle, because it has a UI and is the interaction entry of applications. +Among all abilities, the Page ability has the most complex lifecycle, because it has a UI and acts as a touchpoint for interacting with users. **The following figure shows the lifecycle of the Page ability.** ![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png) @@ -30,6 +31,20 @@ Currently, the **app.js** file provides only the **onCreate** and **onDestroy** ## Process and Thread Model -An application exclusively uses an independent process, and an ability exclusively uses an independent thread. An application process is created when an ability is started for the first time, and a thread is created for this ability too. After the application is started, other abilities in the application are started, and a thread is created for every of these started abilities. Each ability is bound to an independent JSRuntime instance. Therefore, abilities are isolated from each other. +An application exclusively uses an independent process, and an ability exclusively uses an independent thread. When an ability is started for the first time, an application process as well as a thread for this ability is created. After the application is started, other abilities in the application are started, and a thread is created for every of these started abilities. Each ability is bound to an independent JSRuntime instance. In this way, abilities are isolated from each other. ![fa-threading-model](figures/fa-threading-model.png) +## Samples +The following sample is provided to help you better understand how to develop abilities: + +- [`DistributeCalc`: Distributed Calculator (eTS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/Preset/DistributeCalc) +- [`DistributeGraffiti`: Distributed Graffiti (eTS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/ability/DistributedGraffiti) + +- [Remote FA Startup](https://gitee.com/openharmony/codelabs/tree/master/Distributed/RemoteStartFA) +- [Distributed News App](https://gitee.com/openharmony/codelabs/tree/master/Distributed/NewsDemo) +- [Synced Sketchpad (eTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/DistributeDatabaseDrawEts) +- [Distributed Authentication (JS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/GameAuthOpenH) +- [Distributed Game Controller (eTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/HandleGameApplication) +- [Distributed Mail System (eTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/OHMailETS) +- [Distributed Jigsaw Puzzle (eTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/OpenHarmonyPictureGame) +- [Distributed Control (eTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/RemoteControllerETS) diff --git a/en/application-dev/ability/fa-dataability.md b/en/application-dev/ability/fa-dataability.md index b9488903ccc6369a0caa56fcb7493c08e611a66b..c2a72cef31d5416c5a062689bac28af2d7e41c5b 100644 --- a/en/application-dev/ability/fa-dataability.md +++ b/en/application-dev/ability/fa-dataability.md @@ -9,19 +9,19 @@ Data ability providers can customize data access-related APIs such as data inser **Table 1** Data ability lifecycle APIs |API|Description| |:------|:------| -|onInitialized|Called during ability initialization to initialize the relational database (RDB).| -|update|Updates data in the database.| -|query|Queries data in the database.| -|delete|Deletes one or more data records from the database.| -|normalizeUri|Normalizes the URI. A normalized URI applies to cross-device use, persistence, backup, and restore. When the context changes, it ensures that the same data item can be referenced.| -|batchInsert|Inserts multiple data records into the database.| -|denormalizeUri|Converts a normalized URI generated by **normalizeUri** into a denormalized URI.| -|insert|Inserts a data record into the database.| -|openFile|Opens a file.| -|getFileTypes|Obtains the MIME type of a file.| -|getType|Obtains the MIME type matching the data specified by the URI.| -|executeBatch|Operates data in the database in batches.| -|call|Calls a custom API.| +|onInitialized?(info: AbilityInfo): void|Called during ability initialization to initialize the relational database (RDB).| +|update?(uri: string, valueBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Updates data in the database.| +|query?(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Queries data in the database.| +|delete?(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Deletes one or more data records from the database.| +|normalizeUri?(uri: string, callback: AsyncCallback\): void|Normalizes the URI. A normalized URI applies to cross-device use, persistence, backup, and restore. When the context changes, it ensures that the same data item can be referenced.| +|batchInsert?(uri: string, valueBuckets: Array\, callback: AsyncCallback\): void|Inserts multiple data records into the database.| +|denormalizeUri?(uri: string, callback: AsyncCallback\): void|Converts a normalized URI generated by **normalizeUri** into a denormalized URI.| +|insert?(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback\): void|Inserts a data record into the database.| +|openFile?(uri: string, mode: string, callback: AsyncCallback\): void|Opens a file.| +|getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback\>): void|Obtains the MIME type of a file.| +|getType?(uri: string, callback: AsyncCallback\): void|Obtains the MIME type matching the data specified by the URI.| +|executeBatch?(ops: Array\, callback: AsyncCallback\>): void|Operates data in the database in batches.| +|call?(method: string, arg: string, extras: PacMap, callback: AsyncCallback\): void|Calls a custom API.| ## How to Develop diff --git a/en/application-dev/ability/fa-formability.md b/en/application-dev/ability/fa-formability.md index ba5279cd72999b994bbc306b93a019592dcf1fbe..8a790318cf11494e519496096993bee63d567ce8 100644 --- a/en/application-dev/ability/fa-formability.md +++ b/en/application-dev/ability/fa-formability.md @@ -10,25 +10,26 @@ Basic concepts: - Widget host: an application that displays the widget content and controls the position where the widget is displayed in the host application. - Widget Manager: a resident agent that manages widgets added to the system and provides functions such as periodic widget update. -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE** +> > The widget host and provider do not keep running all the time. The Widget Manager starts the widget provider to obtain widget information when a widget is added, deleted, or updated. You only need to develop widget content as the widget provider. The system automatically handles the work done by the widget host and Widget Manager. The widget provider controls the widget content to display, component layout, and click events bound to components. -## Scenario +## Development Overview -Form ability development refers to the development conducted by the widget provider based on the [Feature Ability (FA) model](fa-brief.md). As a widget provider, you need to carry out the following operations: +In FA widget development, you need to carry out the following operations as a widget provider based on the [Feature Ability (FA) model](fa-brief.md). - Develop the lifecycle callbacks in **LifecycleForm**. - Create a **FormBindingData** instance. - Update a widget through **FormProvider**. -- Develop the widget UI page. +- Develop the widget UI pages. ## Available APIs -The table below describes the lifecycle callbacks provided **LifecycleForm**. +The table below describes the lifecycle callbacks provided in **LifecycleForm**. **Table 1** LifecycleForm APIs @@ -37,7 +38,7 @@ The table below describes the lifecycle callbacks provided **LifecycleForm**. | onCreate(want: Want): formBindingData.FormBindingData | Called to notify the widget provider that a **Form** instance (widget) has been created. | | onCastToNormal(formId: string): void | Called to notify the widget provider that a temporary widget has been converted to a normal one.| | onUpdate(formId: string): void | Called to notify the widget provider that a widget has been updated. | -| onVisibilityChange(newStatus: { [key: string]: number }): void | Called to notify the widget provider of the change of widget visibility. | +| onVisibilityChange(newStatus: { [key: string]: number }): void | Called to notify the widget provider of the change in widget visibility. | | onEvent(formId: string, message: string): void | Called to instruct the widget provider to receive and process a widget event. | | onDestroy(formId: string): void | Called to notify the widget provider that a **Form** instance (widget) has been destroyed. | | onAcquireFormState?(want: Want): formInfo.FormState | Called when the widget provider receives the status query result of a widget. | @@ -73,7 +74,7 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li export default { onCreate(want) { console.log('FormAbility onCreate'); - // Persistently store widget information for subsequent use, such as during widget instance retrieval or update. + // Persistently store widget information for subsequent use, such as widget instance retrieval or update. let obj = { "title": "titleOnCreate", "detail": "detailOnCreate" @@ -120,7 +121,7 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li Configure the **config.json** file for the widget. -- The **js** module in the **config.json** file provides the JavaScript resources of the widget. The internal field structure is described as follows: +- The **js** module in the **config.json** file provides the JavaScript resources of the widget. The internal structure is described as follows: | Field| Description | Data Type| Default | | -------- | ------------------------------------------------------------ | -------- | ------------------------ | @@ -144,7 +145,7 @@ Configure the **config.json** file for the widget. }] ``` -- The **abilities** module in the **config.json** file corresponds to the **LifecycleForm** of the widget. The internal field structure is described as follows: +- The **abilities** module in the **config.json** file corresponds to the **LifecycleForm** of the widget. The internal structure is described as follows: | Field | Description | Data Type | Default | | ------------------- | ------------------------------------------------------------ | ---------- | ------------------------ | @@ -195,7 +196,7 @@ Configure the **config.json** file for the widget. ``` -### Persistently Store Widget Data +### Persistently Storing Widget Data Mostly, the widget provider is started only when it needs to obtain information about a widget. The Widget Manager supports multi-instance management and uses the widget ID to identify an instance. If the widget provider supports widget data modification, it must persistently store the data based on the widget ID, so that it can access the data of the target widget when obtaining, updating, or starting a widget. @@ -206,7 +207,7 @@ Mostly, the widget provider is started only when it needs to obtain information let formId = want.parameters["ohos.extra.param.key.form_identity"]; let formName = want.parameters["ohos.extra.param.key.form_name"]; let tempFlag = want.parameters["ohos.extra.param.key.form_temporary"]; - // Persistently store widget information for subsequent use, such as widget instance retrieval and update. + // Persistently store widget information for subsequent use, such as widget instance retrieval or update. // The storeFormInfo API is not implemented here. For details about the implementation, see "FA Model Widget" provided in "Samples". storeFormInfo(formId, formName, tempFlag, want); @@ -233,7 +234,7 @@ You should override **onDestroy** to delete widget data. For details about the persistence method, see [Lightweight Data Store Development](../database/database-storage-guidelines.md). -Note that the **Want** passed by the widget host to the widget provider contains a temporary flag, indicating whether the requested widget is a temporary one. +Note that the **Want** passed by the widget host to the widget provider contains a flag that indicates whether the requested widget is a temporary one. - Normal widget: a widget that will be persistently used by the widget host @@ -241,13 +242,35 @@ Note that the **Want** passed by the widget host to the widget provider contains Data of a temporary widget is not persistently stored. If the widget framework is killed and restarted, data of a temporary widget will be deleted. However, the widget provider is not notified of which widget is deleted, and still keeps the data. Therefore, the widget provider should implement data clearing. In addition, the widget host may convert a temporary widget into a normal one. If the conversion is successful, the widget provider should process the widget ID and store the data persistently. This prevents the widget provider from deleting persistent data when clearing temporary widgets. -### Developing the Widget UI Page +### Updating Widget Data + +When a widget application initiates a data update upon a scheduled or periodic update, the application obtains the latest data and calls **updateForm** to update the widget. The code snippet is as follows: + +```javascript +onUpdate(formId) { + // To support scheduled update, periodic update, or update requested by the widget host, override this method for widget data update. + console.log('FormAbility onUpdate'); + let obj = { + "title": "titleOnUpdate", + "detail": "detailOnUpdate" + }; + let formData = formBindingData.createFormBindingData(obj); + // Call the updateForm method to update the widget. Only the data passed through the input parameter is updated. Other information remains unchanged. + formProvider.updateForm(formId, formData).catch((error) => { + console.log('FormAbility updateForm, error:' + JSON.stringify(error)); + }); +} +``` + +### Developing Widget UI Pages + You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programmed widget. -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE** +> > Currently, only the JavaScript-based web-like development paradigm can be used to develop the widget UI. - - HML: + - In the HML file: ```html
@@ -262,7 +285,7 @@ You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programme
``` - - CSS: + - In the CSS file: ```css .container { @@ -303,7 +326,7 @@ You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programme } ``` - - JSON: + - In the JSON file: ```json { "data": { diff --git a/en/application-dev/ability/fa-pageability.md b/en/application-dev/ability/fa-pageability.md index 2f0e8feb991316d640f70b8c2acd988701676807..fe6010900e373ea5f570c6ffa753e070ff79a915 100644 --- a/en/application-dev/ability/fa-pageability.md +++ b/en/application-dev/ability/fa-pageability.md @@ -131,8 +131,8 @@ You can also include **parameters** in the **want** parameter and set its value }, ); ``` -### Starting a Remote Page Ability (Applying only to System Applications) ->Note: The **getTrustedDeviceListSync** API of the **DeviceManager** class is open only to system applications. Therefore, remote Page ability startup applies only to system applications. +### Starting a Remote Page Ability +>Note: This feature applies only to system applications, since the **getTrustedDeviceListSync** API of the **DeviceManager** class is open only to system applications. **Modules to Import** @@ -261,4 +261,5 @@ export default { ``` ## Samples The following sample is provided to help you better understand how to develop a Page ability: -- [`DMS`: Distributed Demo (eTS) (API7)](https://gitee.com/openharmony/app_samples/tree/master/ability/DMS) + +- [`DMS`: Distributed Demo (eTS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/ability/DMS) diff --git a/en/application-dev/ability/fa-serviceability.md b/en/application-dev/ability/fa-serviceability.md index 3da62ebeb92859e586ff319cc70ebc5cf759ba80..d6cc920a70e514e685c3cd4207cd1dc0e55ebf09 100644 --- a/en/application-dev/ability/fa-serviceability.md +++ b/en/application-dev/ability/fa-serviceability.md @@ -8,11 +8,11 @@ A Service ability is used to run tasks in the background, such as playing music **Table 1** Service ability lifecycle APIs |API|Description| |:------|:------| -|onStart|Called to initialize a Service ability being created. This callback is invoked only once in the entire lifecycle of a Service ability. The **Want** object passed to this callback must be null.| -|onCommand|Called every time a Service ability is created on a client. You can collect calling statistics and perform initialization operations in this callback.| -|onConnect|Called when another ability is connected to the Service ability.| -|onDisconnect|Called when another ability is disconnected from the Service ability.| -|onStop|Called when the Service ability is being destroyed. You should override this callback for your Service ability to clear its resources, such as threads and registered listeners.| +|onStart?(): void|Called to initialize a Service ability being created. This callback is invoked only once in the entire lifecycle of a Service ability. The **Want** object passed to this callback must be null.| +|onCommand?(want: Want, startId: number): void|Called every time a Service ability is created on a client. You can collect calling statistics and perform initialization operations in this callback.| +|onConnect?(want: Want): rpc.RemoteObject|Called when another ability is connected to the Service ability.| +|onDisconnect?(want: Want): void|Called when another ability is disconnected from the Service ability.| +|onStop?(): void|Called when the Service ability is being destroyed. You should override this callback for your Service ability to clear its resources, such as threads and registered listeners.| ## How to Develop @@ -43,7 +43,7 @@ A Service ability is used to run tasks in the background, such as playing music 2. Register a Service ability. - You must declare your Service ability in the **config.json** file by setting its **type** attribute to **service**. + Declare the Service ability in the **config.json** file by setting its **type** attribute to **service**. ```javascript { @@ -214,8 +214,8 @@ export default { } ``` -### Connecting to a Remote Service Ability (Applying only to System Applications) ->NOTE +### Connecting to a Remote Service Ability +>**NOTE** > >This feature applies only to system applications, since the **getTrustedDeviceListSync** API of the **DeviceManager** class is open only to system applications. diff --git a/en/application-dev/ability/stage-ability-continuation.md b/en/application-dev/ability/stage-ability-continuation.md index 0e070f2fee46ba41aa1f7c342b202010a9b58d10..83e3e524d36fd98a930577558c0c7689eca5a274 100644 --- a/en/application-dev/ability/stage-ability-continuation.md +++ b/en/application-dev/ability/stage-ability-continuation.md @@ -2,18 +2,18 @@ ## When to Use -Ability continuation is to continue the current mission of an application, including the UI component status variables and distributed objects, on another device. The UI component status variables are used to synchronize page data, and the distributed objects are used to synchronize data in the memory. +Ability continuation is to continue the current mission of an application, including the UI component state variables and distributed objects, on another device. The UI component state variables are used to synchronize UI data, and the distributed objects are used to synchronize memory data. ## Available APIs -The following table lists the APIs used for ability continuation. For details about the APIs, see [Ability](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-application-ability.md). +The following table lists the APIs used for ability continuation. For details about the APIs, see [Ability](../reference/apis/js-apis-application-ability.md). **Table 1** Ability continuation APIs |API| Description| |:------ | :------| -| onContinue(wantParam : {[key: string]: any}): OnContinueResult | Called by the **initiator** to save data during the ability continuation preparation process. The return value **0** means that the continuation request is accepted, and an error code means that the continuation request is denied.| -| onCreate(want: Want, param: LaunchParam): void| Called by the **target** to restore the data and page.| +| onContinue(wantParam : {[key: string]: any}): OnContinueResult | Called by the initiator to store the data required for continuation and request continuation. The value **AGREE** means that the continuation is accepted, and **REJECT** means the continuation is rejected, and **MISMATCH** means a version mismatch.| +| onCreate(want: Want, param: LaunchParam): void | Called by the target to restore the data and UI page.| | **enum** OnContinueResult | Enumerates the return values of **onContinue**. The options are as follows: **AGREE** (request accepted), **REJECT** (request denied), and **MISMATCH** (version mismatch).| @@ -38,9 +38,9 @@ The following table lists the APIs used for ability continuation. For details ab - * Configure the application startup type. + - Configure the application startup type. - Set **launchType** in the **module.json5** to **standard**. Currently, only multi-instance applications can be continued on another device. + Set **launchType** in the **module.json5** file to **standard** to add multi-instance support to the application. ```javascript "launchType": "standard" @@ -48,7 +48,7 @@ The following table lists the APIs used for ability continuation. For details ab - * Apply for the distributed permissions. + - Apply for the distributed permissions. Declare the **DISTRIBUTED_DATASYNC** permission in the **module.json5** file for the application. @@ -100,9 +100,9 @@ The following table lists the APIs used for ability continuation. For details ab -2. Implement the **onContinue** API. +2. Implement the **onContinue()** API. - The **onContinue** API is called by the **initiator** to save the UI component status variables and memory data and prepare for continuation. After the application completes the continuation preparation, the system must return **OnContinueResult.AGREE** to accept the continuation request. If an error code is returned, the request is denied. If this API is not implemented, the system rejects the continuation request by default. + The **onContinue()** API is called by the initiator to save the UI component state variables and memory data and prepare for continuation. After the application completes the continuation preparation, the system must return **OnContinueResult.AGREE(0)** to accept the continuation request. If an error code is returned, the request is rejected. If this API is not implemented, the system rejects the continuation request by default. Modules to import: @@ -111,10 +111,10 @@ The following table lists the APIs used for ability continuation. For details ab import AbilityConstant from '@ohos.application.AbilityConstant'; ``` - - To implement ability continuation, you must implement this API and have the value **AGREE** returned. + To implement ability continuation, you must implement this API and have the value **AGREE** returned. - - Example + Example ```javascript onContinue(wantParam : {[key: string]: any}) { @@ -128,24 +128,24 @@ The following table lists the APIs used for ability continuation. For details ab -3. Implement the continuation logic in the **onCreate** API. +3. Implement the continuation logic in the **onCreate()** API. - The **onCreate** API is called by the **target**. When the ability is started on the target device, this API is called to instruct the application to synchronize the memory data and UI component status, and triggers page restoration after the synchronization is complete. If the continuation logic is not implemented, the ability will be started in common startup mode and the page cannot be restored. + The **onCreate()** API is called by the target. When the ability is started on the target device, this API is called to instruct the application to synchronize the memory data and UI component state, and triggers page restoration after the synchronization is complete. If the continuation logic is not implemented, the ability will be started in common startup mode and the page cannot be restored. - - The target device determines whether the startup is **LaunchReason.CONTINUATION** based on **launchReason** in **onCreate**. + The target device determines whether the startup is **LaunchReason.CONTINUATION** based on **launchReason** in **onCreate()**. - - After data restore is complete, call **restoreWindowStage** to trigger page restoration. + After data restore is complete, call **restoreWindowStage** to trigger page restoration. - * Example + Example ```javascript onCreate(want, launchParam) { Logger.info(`MainAbility onCreate ${AbilityConstant.LaunchReason.CONTINUATION}`) globalThis.abilityWant = want; if (launchParam.launchReason == AbilityConstant.LaunchReason.CONTINUATION) { - let input = want.parameters.input // get user data from want params + let input = want.parameters.input // Obtain user data from want params. AppStorage.SetOrCreate('ContinueInput', input) Logger.info(`onCreate for continuation sessionId: ${this.sessionId}`) @@ -159,13 +159,13 @@ The following table lists the APIs used for ability continuation. For details ab ### Data Continuation -1. Use distributed objects. +Use distributed objects. - Distributed data objects allow cross-device data synchronization like local variables. For two devices that form a Super Device, when data in the distributed data object of an application is added, deleted, or modified on a device, the data for the same application is also updated on the other device. Both devices can listen for the data changes and online and offline states of the other. For details, see [Distributed Data Object Development](https://gitee.com/openharmony/docs/blob/master/en/application-dev/database/database-distributedobject-guidelines.md). +Distributed objects allow cross-device data synchronization like local variables. For two devices that form a Super Device, when data in the distributed data object of an application is added, deleted, or modified on a device, the data for the same application is also updated on the other device. Both devices can listen for the data changes and online and offline states of the other. For details, see [Distributed Data Object Development](../database/database-distributedobject-guidelines.md). - In the ability continuation scenario, the distributed data object is used to synchronize the memory data from the local device to the target device. +In the ability continuation scenario, the distributed data object is used to synchronize the memory data from the local device to the target device. - - In **onContinue**, the initiator saves the data to be continued to the distributed object, sets the session ID, and sends the session ID to the target device through **wantParam**. +- In **onContinue()**, the initiator saves the data to be continued to the distributed object, sets the session ID, and sends the session ID to the target device through **wantParam**. ```javascript import Ability from '@ohos.application.Ability'; @@ -190,7 +190,7 @@ The following table lists the APIs used for ability continuation. For details ab ``` - - The target device obtains the session ID from **onCreate**, creates a distributed object, and associates the distributed object with the session ID. In this way, the distributed object can be synchronized. Before calling **restoreWindowStage**, ensure that all distributed objects required for continuation have been associated for correct data retrieval. +- The target device obtains the session ID from **onCreate()**, creates a distributed object, and associates the distributed object with the session ID. In this way, the distributed object can be synchronized. Before calling **restoreWindowStage**, ensure that all distributed objects required for continuation have been associated. ```javascript import Ability from '@ohos.application.Ability'; @@ -227,3 +227,6 @@ The following table lists the APIs used for ability continuation. For details ab For details about the complete example, see the sample. + + + diff --git a/en/application-dev/ability/stage-ability.md b/en/application-dev/ability/stage-ability.md index 4dfe6cf0e1ef001bdd72d4ae362baadc5d155d63..4b05e88f1ccdb990a454a538a001aadb7bc45a80 100644 --- a/en/application-dev/ability/stage-ability.md +++ b/en/application-dev/ability/stage-ability.md @@ -208,7 +208,6 @@ export default class MainAbility extends Ability { The `Ability` class has the `context` attribute, which belongs to the `AbilityContext` class. The `AbilityContext` class has the `abilityInfo`, `currentHapModuleInfo`, and other attributes and the APIs used for starting abilities. For details, see [AbilityContext](../reference/apis/js-apis-ability-context.md). **Table 3** AbilityContext APIs - |API|Description| |:------|:------| |startAbility(want: Want, callback: AsyncCallback\): void|Starts an ability.| @@ -249,7 +248,7 @@ var want = { context.startAbility(want).then((data) => { console.log("Succeed to start remote ability with data: " + JSON.stringify(data)) }).catch((error) => { - console.error("Failed to start remote ability with error: "+ JSON.stringify(error)) + console.error("Failed to start remote ability with error: " + JSON.stringify(error)) }) ``` Obtain the ID of a specified device from `DeviceManager`. The sample code is as follows: diff --git a/en/application-dev/ability/stage-brief.md b/en/application-dev/ability/stage-brief.md index 8d4ab32e671a3364776317f724d7ce51c218bfcf..0b4bfe8e3ec2943528e3bd2e8b640dea4ffbd070 100644 --- a/en/application-dev/ability/stage-brief.md +++ b/en/application-dev/ability/stage-brief.md @@ -1,6 +1,6 @@ # Stage Model Overview -### Design Ideas +## Design Ideas The stage model is designed to make it easier to develop complex applications in the distributed environment. @@ -20,10 +20,10 @@ The stage model is designed based on the following considerations: - **Support for multiple device types and window forms** - To support multiple device types and facilitate the implementation of different window forms, the component manager and window manager must be decoupled at the architecture layer for easier tailoring. To achieve this goal, the stage model redefines the ability lifecycle and implements unidirectional dependency of the component manager and window manager. + To support multiple device types and facilitate the implementation of different window forms, the component manager and window manager must be decoupled at the architecture layer for easier tailoring. To achieve this goal, the stage model redefines the ability lifecycle and implements unidirectional dependency for the component manager and window manager. -### Basic Concepts +## Basic Concepts The following figure shows the basic concepts in the stage model. @@ -33,24 +33,24 @@ The following figure shows the basic concepts in the stage model. - **Bundle**: an OpenHarmony application identified by **appid**. A bundle can contain multiple HAP files. Each application has a **bundleName**. However, **bundleName** must be used together with **appid** and other information to uniquely identify an application. - **AbilityStage**: runtime class of an HAP. It is created when the HAP is loaded to the process for the first time and is visible to developers in the runtime. - **Application**: runtime class of a bundle, which is invisible to developers in the runtime. -- **Context**: provides various capabilities that can be invoked by developers during the runtime. The **Ability** and **ExtensionAbility** classes have their own context classes, which inherit the base class **Context**. The base class provides information such as the bundle name, module name, and path. -- **Ability**: provides lifecycle callback, holds the **AbilityContext** class, and supports component continuation and collaboration. +- **Context**: base class that the context classes of **Ability** and **ExtensionAbility** classes inherit. This class provides various capabilities that can be invoked by developers in the runtime, and various information such as the bundle name, module name, and path. +- **Ability**: class that provides lifecycle callbacks, holds the **AbilityContext** class, and supports component continuation and collaboration. - **ExtensionAbility**: general name of scenario-based service extension abilities. The system defines multiple scenario-based **ExtensionAbility** classes, each of which has its own **ExtensionContext**. - **WindowStage**: local window manager. - **Window**: basic unit managed by the window manager. It has an ArkUI engine instance. -- **ArkUI Page**: displays declarative ArkUI. +- **ArkUI Page**: ArkUI development framework page. -### Lifecycle +## Lifecycle -The ability and ability stage lifecycles are the most important concepts in the basic process of an application. The comparison between the FA model lifecycle and stage model lifecycle is provided in [Ability Framework Overview](ability-brief.md). This section focuses on the ability lifecycle transition and the scheduling relationships between the ability, ability stage, and window stage. +The ability and ability stage lifecycles are the rudiments of the basic process of an application. For details about how these lifecycles differ from those in the FA model, see [Ability Framework Overview](ability-brief.md). This section focuses on the ability lifecycle transition and the scheduling relationships between the ability, ability stage, and window stage. ![stageabilitylifecyclecallback](figures/stageabilitylifecyclecallback.png) -To implement multi-device-form tailoring and multi-window scalability, OpenHarmony decouples the component manager from the window manager. The ability lifecycle defined in the stage model includes only the creation, destruction, foreground, and background states. The gain focus and lose focus states that are closely related to UI content are defined in the window stage. This implements weak coupling between the abilities and windows. On the service side, the window manager notifies the component manager of the foreground and background changes, so the component manager only senses the foreground and background changes but not the focus changes. +To implement device-specific tailoring and multi-window scalability, OpenHarmony decouples the component manager from the window manager. The ability lifecycle defined in the stage model includes only the creation, destruction, foreground, and background states. The gain focus and lose focus states that are closely related to UI content are defined in the window stage. This implements weak coupling between the abilities and windows. On the service side, the window manager notifies the component manager of the foreground and background changes, so the component manager only senses the foreground and background changes but not the focus changes. -### Ability Instances and Missions +## Ability Instances and Missions Abilities can be started in any of the following modes: @@ -62,11 +62,11 @@ Abilities can be started in any of the following modes: Each ability instance corresponds to a mission in **Launcher Recent**. -The mission corresponding to each ability instance has a snapshot of the ability instance. After the ability instance is destroyed, the ability class information and snapshot are retained in the mission until the user deletes the information or the storage space exceeds the upper limit. +The mission corresponding to an ability instance has a snapshot of the ability instance. After the ability instance is destroyed, the ability class information and snapshot are retained in the mission until the user deletes the information or the storage space reaches the upper limit. ![AbilityComponentInstanceMission](figures/AbilityComponentInstanceMission.png) -### ExtensionAbility Mechanism +## ExtensionAbility Mechanism Different from the ability used for page display, the extension ability provides a restricted service running environment. It has the following features: @@ -82,9 +82,9 @@ The following figure uses the widget scenario as an example. You can inherit fro ![ExtensionAbility](figures/ExtensionAbility.png) -### Process Model +## Process Model -All OpenHarmony applications are designed to meet the single-process model. In the single-process model, an application is not allowed to configure multiple processes, and all processes in the application are created and managed by the system. Each application supports a maximum of three types of processes: +All OpenHarmony applications are designed to meet the single-process model. In the single-process model, all processes in the application are created and managed by the system. Each application supports a maximum of three types of processes: - Main process: runs all ability components, pages, and service logic. diff --git a/en/application-dev/ability/stage-formextension.md b/en/application-dev/ability/stage-formextension.md index 8ff179ff5f617a2d5c1f1a432528eef3cf7e58ec..8879d41bac5f97f855bb934f6f6ab86bc6b698c9 100644 --- a/en/application-dev/ability/stage-formextension.md +++ b/en/application-dev/ability/stage-formextension.md @@ -187,7 +187,7 @@ To create a widget in the stage model, implement the lifecycle callbacks of **Fo { "forms": [{ "name": "widget", - "description": "This is a service widget.", + "description": "This is a widget.", "src": "./js/widget/pages/index/index", "window": { "autoDesignWidth": true, @@ -252,7 +252,28 @@ Note that the **Want** passed by the widget host to the widget provider contains Data of a temporary widget is not persistently stored. If it is deleted from the Widget Manager due to exceptions, such as crash of the widget framework, the widget provider will not be notified of which widget is deleted, and still keeps the data. In light of this, the widget provider should implement data clearing. If the widget host successfully converts a temporary widget into a normal one, the widget provider should also process the widget ID and store the data persistently. This prevents the widget provider from deleting the widget data when clearing temporary widgets. +### Updating Widget Data + +When a widget application initiates a data update upon a scheduled or periodic update, the application obtains the latest data and calls **updateForm** to update the widget. The code snippet is as follows: + +```javascript +onUpdate(formId) { + // To support scheduled update, periodic update, or update requested by the widget host, override this method for widget data update. + console.log('FormAbility onUpdate'); + let obj = { + "title": "titleOnUpdate", + "detail": "detailOnUpdate" + }; + let formData = formBindingData.createFormBindingData(obj); + // Call the updateForm method to update the widget. Only the data passed through the input parameter is updated. Other information remains unchanged. + formProvider.updateForm(formId, formData).catch((error) => { + console.log('FormAbility updateForm, error:' + JSON.stringify(error)); + }); +} +``` + ### Developing the Widget UI Page + You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programmed widget. > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** diff --git a/en/application-dev/ability/stage-serviceextension.md b/en/application-dev/ability/stage-serviceextension.md index 90448c52428af38b8128477c24eec4911b88b827..6db6090457adb753c277c74560011ddfd91d88d3 100644 --- a/en/application-dev/ability/stage-serviceextension.md +++ b/en/application-dev/ability/stage-serviceextension.md @@ -1,7 +1,7 @@ # Service Extension Ability Development ## When to Use -**ExtensionAbility** is the base class of the new Extension component in the stage model. It is used to process missions without UIs. The lifecycle of an Extension ability is simple, and it does not involve foreground or background. **ServiceExtensionAbility** is extended from **ExtensionAbility**. +**ExtensionAbility** is the base class of the new Extension component in the stage model. It is used to process missions without UIs. The lifecycle of an Extension ability is simple and does not involve foreground or background. **ServiceExtensionAbility** is extended from **ExtensionAbility**. You can customize a class that inherits from **ServiceExtensionAbility** and override the lifecycle callbacks in the base class to perform service logic operations during the initialization, connection, and disconnection processes. @@ -80,7 +80,5 @@ Declare the Service Extension ability in the **module.json** file by setting its The following sample is provided to help you better understand how to develop a Service Extension ability: -- [ServiceExtensionAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/ServiceExtAbility) - -This sample shows how to create a Service Extension ability in the **ServiceExtAbility.ts** file in the **ServiceExtensionAbility** directory. +- [`ServiceExtAbility`: Stage Extension Ability Creation and Usage (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/ability/ServiceExtAbility) diff --git a/en/application-dev/database/database-relational-guidelines.md b/en/application-dev/database/database-relational-guidelines.md index 571442b3a561e9466fa72a664fcd5785a5bdddc0..1fd3bbff852ed5333345214b05a20c1388614c48 100644 --- a/en/application-dev/database/database-relational-guidelines.md +++ b/en/application-dev/database/database-relational-guidelines.md @@ -202,7 +202,7 @@ You can obtain the distributed table name for a remote device based on the local const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"; const STORE_CONFIG = {name: "rdbstore.db",} data_rdb.getRdbStore(STORE_CONFIG, 1, function (err, rdbStore) { - rdbStore.executeSql(SQL_CREATE_TABLE) + rdbStore.executeSql(CREATE_TABLE_TEST) console.info('create table done.') }) ``` diff --git a/en/application-dev/device/device-location-info.md b/en/application-dev/device/device-location-info.md index 6c1fa0e7dc3dd930a75daef8cf4e33ddd13002b5..e3d2e4155798eb69904ec7c819ef3702604dd1bf 100644 --- a/en/application-dev/device/device-location-info.md +++ b/en/application-dev/device/device-location-info.md @@ -12,44 +12,44 @@ Real-time location of the device is recommended for location-sensitive services. The following table describes APIs available for obtaining device location information. - **Table1** APIs for obtaining device location information + **Table 1** APIs for obtaining device location information -| API | Description | +| API| Description| | -------- | -------- | -| on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>) : void | Registers a listener for location changes with a location request initiated. | -| off(type: 'locationChange', callback?: Callback<Location>) : void | Unregisters the listener for location changes with the corresponding location request deleted. | -| on(type: 'locationServiceState', callback: Callback<boolean>) : void | Registers a listener for location service status change events. | -| off(type: 'locationServiceState', callback: Callback<boolean>) : void | Unregisters the listener for location service status change events. | -| on(type: 'cachedGnssLocationsReporting', request: CachedGnssLoactionsRequest, callback: Callback<Array<Location>>) : void; | Registers a listener for cached GNSS location reports. | -| off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Location>>) : void; | Unregisters the listener for cached GNSS location reports. | -| on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>) : void; | Registers a listener for satellite status change events. | -| off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>) : void; | Unregisters the listener for satellite status change events. | -| on(type: 'nmeaMessageChange', callback: Callback<string>) : void; | Registers a listener for GNSS NMEA message change events. | -| off(type: 'nmeaMessageChange', callback?: Callback<string>) : void; | Unregisters the listener for GNSS NMEA message change events. | -| on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Registers a listener for status change events of the specified geofence. | -| off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Unregisters the listener for status change events of the specified geofence. | -| getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>) : void | Obtains the current location. This function uses an asynchronous callback to return the result. | -| getCurrentLocation(request?: CurrentLocationRequest) : Promise<Location> | Obtains the current location. This function uses a promise to return the result. | -| getLastLocation(callback: AsyncCallback<Location>) : void | Obtains the previous location. This function uses an asynchronous callback to return the result. | -| getLastLocation() : Promise<Location> | Obtains the previous location. This function uses a promise to return the result. | -| isLocationEnabled(callback: AsyncCallback<boolean>) : void | Checks whether the location service is enabled. This function uses an asynchronous callback to return the result. | -| isLocationEnabled() : Promise<boolean> | Checks whether the location service is enabled. This function uses a promise to return the result. | -| requestEnableLocation(callback: AsyncCallback<boolean>) : void | Requests to enable the location service. This function uses an asynchronous callback to return the result. | -| requestEnableLocation() : Promise<boolean> | Requests to enable the location service. This function uses a promise to return the result. | -| enableLocation(callback: AsyncCallback<boolean>) : void | Enables the location service. This function uses an asynchronous callback to return the result. | -| enableLocation() : Promise<boolean> | Enables the location service. This function uses a promise to return the result. | -| disableLocation(callback: AsyncCallback<boolean>) : void | Disables the location service. This function uses an asynchronous callback to return the result. | -| disableLocation() : Promise<boolean> | Disables the location service. This function uses a promise to return the result. | -| getCachedGnssLocationsSize(callback: AsyncCallback<number>) : void; | Obtains the number of cached GNSS locations. This function uses an asynchronous callback to return the result. | -| getCachedGnssLocationsSize() : Promise<number>; | Obtains the number of cached GNSS locations. This function uses a promise to return the result. | -| flushCachedGnssLocations(callback: AsyncCallback<boolean>) : void; | Obtains all cached GNSS locations and clears the GNSS cache queue. This function uses an asynchronous callback to return the result. | -| flushCachedGnssLocations() : Promise<boolean>; | Obtains all cached GNSS locations and clears the GNSS cache queue. This function uses a promise to return the result. | -| sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>) : void; | Sends extended commands to the location subsystem. This function uses an asynchronous callback to return the result. | -| sendCommand(command: LocationCommand) : Promise<boolean>; | Sends extended commands to the location subsystem. This function uses a promise to return the result. | -| isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback<boolean>) : void; | Checks whether a user agrees with the privacy statement of the location service. This function uses an asynchronous callback to return the result. | -| isLocationPrivacyConfirmed(type : LocationPrivacyType,) : Promise<boolean>; | Checks whether a user agrees with the privacy statement of the location service. This function uses a promise to return the result. | -| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean, callback: AsyncCallback<boolean>) : void; | Sets the user confirmation status for the privacy statement of the location service. This function uses an asynchronous callback to return the result. | -| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean) : Promise<boolean>; | Sets the user confirmation status for the privacy statement of the location service. This function uses a promise to return the result. | +| on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>) : void | Registers a listener for location changes with a location request initiated.| +| off(type: 'locationChange', callback?: Callback<Location>) : void | Unregisters the listener for location changes with the corresponding location request deleted.| +| on(type: 'locationServiceState', callback: Callback<boolean>) : void | Registers a listener for location service status change events.| +| off(type: 'locationServiceState', callback: Callback<boolean>) : void | Unregisters the listener for location service status change events.| +| on(type: 'cachedGnssLocationsReporting', request: CachedGnssLoactionsRequest, callback: Callback<Array<Location>>) : void; | Registers a listener for cached GNSS location reports.| +| off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Location>>) : void; | Unregisters the listener for cached GNSS location reports.| +| on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>) : void; | Registers a listener for satellite status change events.| +| off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>) : void; | Unregisters the listener for satellite status change events.| +| on(type: 'nmeaMessageChange', callback: Callback<string>) : void; | Registers a listener for GNSS NMEA message change events.| +| off(type: 'nmeaMessageChange', callback?: Callback<string>) : void; | Unregisters the listener for GNSS NMEA message change events.| +| on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Registers a listener for status change events of the specified geofence.| +| off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Unregisters the listener for status change events of the specified geofence.| +| getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>) : void | Obtains the current location. This API uses an asynchronous callback to return the result. | +| getCurrentLocation(request?: CurrentLocationRequest) : Promise<Location> | Obtains the current location. This API uses a promise to return the result. | +| getLastLocation(callback: AsyncCallback<Location>) : void | Obtains the previous location. This API uses an asynchronous callback to return the result.| +| getLastLocation() : Promise<Location> | Obtains the previous location. This API uses a promise to return the result. | +| isLocationEnabled(callback: AsyncCallback<boolean>) : void | Checks whether the location service is enabled. This API uses an asynchronous callback to return the result.| +| isLocationEnabled() : Promise<boolean> | Checks whether the location service is enabled. This API uses a promise to return the result.| +| requestEnableLocation(callback: AsyncCallback<boolean>) : void | Requests to enable the location service. This API uses an asynchronous callback to return the result.| +| requestEnableLocation() : Promise<boolean> | Requests to enable the location service. This API uses a promise to return the result.| +| enableLocation(callback: AsyncCallback<boolean>) : void | Enables the location service. This API uses an asynchronous callback to return the result.| +| enableLocation() : Promise<boolean> | Enables the location service. This API uses a promise to return the result.| +| disableLocation(callback: AsyncCallback<boolean>) : void | Disables the location service. This function uses an asynchronous callback to return the result.| +| disableLocation() : Promise<boolean> | Disables the location service. This function uses a promise to return the result.| +| getCachedGnssLocationsSize(callback: AsyncCallback<number>) : void; | Obtains the number of cached GNSS locations. This function uses an asynchronous callback to return the result.| +| getCachedGnssLocationsSize() : Promise<number>; | Obtains the number of cached GNSS locations. This function uses a promise to return the result.| +| flushCachedGnssLocations(callback: AsyncCallback<boolean>) : void; | Obtains all cached GNSS locations and clears the GNSS cache queue. This function uses an asynchronous callback to return the result.| +| flushCachedGnssLocations() : Promise<boolean>; | Obtains all cached GNSS locations and clears the GNSS cache queue. This function uses a promise to return the result.| +| sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>) : void; | Sends extended commands to the location subsystem. This function uses an asynchronous callback to return the result.| +| sendCommand(command: LocationCommand) : Promise<boolean>; | Sends extended commands to the location subsystem. This function uses a promise to return the result.| +| isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback<boolean>) : void; | Checks whether a user agrees with the privacy statement of the location service. This function uses an asynchronous callback to return the result.| +| isLocationPrivacyConfirmed(type : LocationPrivacyType,) : Promise<boolean>; | Checks whether a user agrees with the privacy statement of the location service. This function uses a promise to return the result.| +| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean, callback: AsyncCallback<boolean>) : void; | Sets the user confirmation status for the privacy statement of the location service. This function uses an asynchronous callback to return the result.| +| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean) : Promise<boolean>; | Sets the user confirmation status for the privacy statement of the location service. This function uses a promise to return the result.| ## How to Develop @@ -64,40 +64,38 @@ The following table describes APIs available for obtaining device location infor If your application needs to access the device location information when running on the background, it must be allowed to run on the background in the configuration file and also granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information even when your application moves to the background. - To allow your application to access device location information, you can declare the required permissions in the **config.json** file of your application. The sample code is as follows: + To allow your application to access device location information, declare the required permissions in the **module.json** file of your application. The sample code is as follows: - + ``` { "module": { - "reqPermissions": [{ + "reqPermissions": [ "name": "ohos.permission.LOCATION", "reason": "$string:reason_description", "usedScene": { "ability": ["com.myapplication.LocationAbility"], "when": "inuse" - }, { - ... } ] } } ``` - For details about the fields, see . + For details about the configuration fields, see the description of the **module.json** file. 2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities. - + ``` import geolocation from '@ohos.geolocation'; ``` -3. Instantiate the **LocationRequest** object. This object provides APIs to notify the system of the location service type and the interval of reporting location information. +3. Instantiate the **LocationRequest** object. This object provides APIs to notify the system of the location service type and the interval of reporting location information.
**Method 1:** To better serve your needs for using APIs, the system has categorized APIs into different packages to match your common use cases of the location function. In this way, you can directly use the APIs specific to a certain use case, making application development much easier. The following table lists the use cases currently supported. - + ``` export enum LocationRequestScenario { UNSET = 0x300, @@ -109,19 +107,19 @@ The following table describes APIs available for obtaining device location infor } ``` + + **Table 2** Common use cases of the location function - **Table2** Common use cases of the location function - - | Use Case | Constant | Description | + | Use Case| Constant| Description| | -------- | -------- | -------- | - | Navigation | NAVIGATION | Applicable when your application needs to obtain the real-time location of a mobile device outdoors, such as navigation for driving or walking. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy. However, due to its limitations, the technology may be unable to provide the location service when navigation is just started or when the user moves into a shielded environment such as indoors or a garage. To resolve this issue, the system uses the network positioning technology as an alternative to provide the location service for your application until the GNSS can provide stable location results. This helps achieve a smooth navigation experience for users.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Trajectory tracking | TRAJECTORY_TRACKING | Applicable when your application needs to record user trajectories, for example, the track recording function of sports applications. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Ride hailing | CAR_HAILING | Applicable when your application needs to obtain the current location of a user who is hailing a taxi.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Life service | DAILY_LIFE_SERVICE | Applicable when your application only needs the approximate user location for recommendations and push notifications in scenarios such as when the user is browsing news, shopping online, and ordering food.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Power efficiency | NO_POWER | Applicable when your application does not proactively start the location service for a higher battery efficiency. When responding to another application requesting the same location service, the system marks a copy of the location result to your application. In this way, your application will not consume extra power for obtaining the user location.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | + | Navigation| NAVIGATION | Applicable when your application needs to obtain the real-time location of a mobile device outdoors, such as navigation for driving or walking. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy. However, due to its limitations, the technology may be unable to provide the location service when navigation is just started or when the user moves into a shielded environment such as indoors or a garage. To resolve this issue, the system uses the network positioning technology as an alternative to provide the location service for your application until the GNSS can provide stable location results. This helps achieve a smooth navigation experience for users.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Trajectory tracking| TRAJECTORY_TRACKING | Applicable when your application needs to record user trajectories, for example, the track recording function of sports applications. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Ride hailing| CAR_HAILING | Applicable when your application needs to obtain the current location of a user who is hailing a taxi.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Life service| DAILY_LIFE_SERVICE | Applicable when your application only needs the approximate user location for recommendations and push notifications in scenarios such as when the user is browsing news, shopping online, and ordering food.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Power efficiency| NO_POWER | Applicable when your application does not proactively start the location service for a higher battery efficiency. When responding to another application requesting the same location service, the system marks a copy of the location result to your application. In this way, your application will not consume extra power for obtaining the user location.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| The following example instantiates the **RequestParam** object for navigation: - + ``` var requestInfo = {'scenario': 0x301, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; ``` @@ -130,7 +128,7 @@ The following table describes APIs available for obtaining device location infor If the predefined use cases do not meet your needs, you can also use the basic location priority policies provided by the system. - + ``` export enum LocationRequestPriority { UNSET = 0x200, @@ -140,23 +138,23 @@ The following table describes APIs available for obtaining device location infor } ``` + + **Table 3** Location priority policies - **Table3** Location priority policies - - | Policy | Constant | Description | + | Policy| Constant| Description| | -------- | -------- | -------- | - | Location accuracy priority | ACCURACY | This policy mainly uses the GNSS positioning technology. In an open area, the technology can achieve the meter-level location accuracy, depending on the hardware performance of the device. However, in a shielded environment, the location accuracy may significantly decrease.
To use this policy, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Fast location priority | FAST_FIRST_FIX | This policy uses the GNSS positioning, base station positioning, WLAN positioning, and Bluetooth positioning technologies simultaneously to obtain the device location in both the indoor and outdoor scenarios. When all positioning technologies provide a location result, the system provides the most accurate location result for your application. This policy can lead to significant hardware resource consumption and power consumption.
To use this policy, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Power efficiency priority | LOW_POWER | This policy mainly uses the base station positioning, WLAN positioning, and Bluetooth positioning technologies to obtain device location in both indoor and outdoor scenarios. The location accuracy depends on the distribution of surrounding base stations, visible WLANs, and Bluetooth devices and therefore may fluctuate greatly. This policy is recommended and can reduce power consumption when your application does not require high location accuracy or when base stations, visible WLANs, and Bluetooth devices are densely distributed.
To use this policy, you must declare at least the **ohos.permission.LOCATION** permission and obtain users' authorization. | + | Location accuracy priority| ACCURACY | This policy mainly uses the GNSS positioning technology. In an open area, the technology can achieve the meter-level location accuracy, depending on the hardware performance of the device. However, in a shielded environment, the location accuracy may significantly decrease.
To use this policy, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Fast location priority| FAST_FIRST_FIX | This policy uses the GNSS positioning, base station positioning, WLAN positioning, and Bluetooth positioning technologies simultaneously to obtain the device location in both the indoor and outdoor scenarios. When all positioning technologies provide a location result, the system provides the most accurate location result for your application. This policy can lead to significant hardware resource consumption and power consumption.
To use this policy, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Power efficiency priority| LOW_POWER | This policy mainly uses the base station positioning, WLAN positioning, and Bluetooth positioning technologies to obtain device location in both indoor and outdoor scenarios. The location accuracy depends on the distribution of surrounding base stations, visible WLANs, and Bluetooth devices and therefore may fluctuate greatly. This policy is recommended and can reduce power consumption when your application does not require high location accuracy or when base stations, visible WLANs, and Bluetooth devices are densely distributed.
To use this policy, you must declare at least the **ohos.permission.LOCATION** permission and obtain users' authorization.| The following example instantiates the **RequestParam** object for the location accuracy priority policy: - + ``` var requestInfo = {'priority': 0x201, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; ``` 4. Instantiate the **Callback** object for the system to report location results. - Your application needs to implement the callback interface defined by the system. When the system successfully obtains the real-time location of a device, it will report the location result to your application through the callback interface. Your application can implement the callback interface in such a way to complete your own service logic. + Your application needs to implement the callback defined by the system. When the system successfully obtains the real-time location of a device, it will report the location result to your application through the callback interface. Your application can implement the callback interface in such a way to complete your own service logic. ``` var locationChange = (location) => { @@ -165,19 +163,19 @@ The following table describes APIs available for obtaining device location infor ``` 5. Start device location. - + ``` geolocation.on('locationChange', requestInfo, locationChange); ``` 6. (Optional) Stop device location. - + ``` geolocation.off('locationChange', locationChange); ``` If your application does not need the real-time device location, it can use the last known device location cached in the system instead. - + ``` geolocation.getLastLocation((data) => { console.log('getLastLocation: data: ' + JSON.stringify(data)); diff --git a/en/application-dev/device/usb-guidelines.md b/en/application-dev/device/usb-guidelines.md index 651ac2b64fa7d7e7cd815e09cd0e9d0514179755..5e3e6ba1c139a6bf5717865a040884d8ce6e40a4 100644 --- a/en/application-dev/device/usb-guidelines.md +++ b/en/application-dev/device/usb-guidelines.md @@ -21,7 +21,7 @@ The following table lists the USB APIs currently available. For details, see the | setConfiguration(pipe: USBDevicePipe, config: USBConfig): 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. | -| function bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise\ | Performs bulk transfer. | +| 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. | diff --git a/en/application-dev/media/video-playback.md b/en/application-dev/media/video-playback.md index c0a0163b000e1d2a87081476307a153e0fdd723c..3aab853a699f7ac9b2d9fe2a6f7da9bf03d994cd 100644 --- a/en/application-dev/media/video-playback.md +++ b/en/application-dev/media/video-playback.md @@ -43,7 +43,7 @@ The full video playback process includes creating an instance, setting the URL, For details about the **url** types supported by **VideoPlayer**, see the [url attribute](../reference/apis/js-apis-media.md#videoplayer_attributes). -For details about how to create an XComponent, see [XComponent](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md). +For details about how to create an XComponent, see [XComponent]( ../reference/arkui-ts/ts-basic-components-xcomponent.md). *Note: **setSurface** must be called after the URL is set but before **prepare** is called. diff --git a/en/application-dev/napi/Readme-EN.md b/en/application-dev/napi/Readme-EN.md index 9ab337ed1c29e18772ff4e348c47e3202f74815f..b34a02ddc209ad3c0c4feec76bce3247fbdb5b27 100644 --- a/en/application-dev/napi/Readme-EN.md +++ b/en/application-dev/napi/Readme-EN.md @@ -2,5 +2,6 @@ - [Using Native APIs in Application Projects](napi-guidelines.md) - [Drawing Development](drawing-guidelines.md) +- [Native Window Development](native_window-guidelines.md) - [Raw File Development](rawfile-guidelines.md) diff --git a/en/application-dev/napi/native_window-guidelines.md b/en/application-dev/napi/native_window-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..f86fdb78ed8d0c111c1c2a1eb8b80ca2de5409bf --- /dev/null +++ b/en/application-dev/napi/native_window-guidelines.md @@ -0,0 +1,107 @@ +# NativeWindow Development + +## When to Use + +`NativeWindow` is a local platform window of OpenHarmony. It provides APIs for you to create a native window from `Surface`, create a native window buffer from `SurfaceBuffer`, and request and flush a buffer. +The following scenarios are common for native window development: + +* Drawing content using native C++ code and displaying the content on the screen +* Requesting and flushing a buffer when adapting to EGL `eglswapbuffer` + +## Available APIs + +| API| Description| +| -------- | -------- | +| OH_NativeWindow_CreateNativeWindowFromSurface (void \*pSurface) | Creates a `NativeWindow` instance. A new `NativeWindow` instance is created each time this function is called.| +| OH_NativeWindow_DestroyNativeWindow (struct NativeWindow \*window) | Decreases the reference count of a `NativeWindow` instance by 1 and, when the reference count reaches 0, destroys the instance.| +| OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer (void \*pSurfaceBuffer) | Creates a `NativeWindowBuffer` instance. A new `NativeWindowBuffer` instance is created each time this function is called.| +| OH_NativeWindow_DestroyNativeWindowBuffer (struct NativeWindowBuffer \*buffer) | Decreases the reference count of a `NativeWindowBuffer` instance by 1 and, when the reference count reaches 0, destroys the instance.| +| OH_NativeWindow_NativeWindowRequestBuffer (struct NativeWindow \*window struct NativeWindowBuffer \*\*buffer, int \*fenceFd) | Requests a `NativeWindowBuffer` through a `NativeWindow` instance for content production.| +| OH_NativeWindow_NativeWindowFlushBuffer (struct NativeWindow \*window, struct NativeWindowBuffer \*buffer, int fenceFd, Region region) | Flushes the `NativeWindowBuffer` filled with the content to the buffer queue through a `NativeWindow` instance for content consumption.| +| OH_NativeWindow_NativeWindowCancelBuffer (struct NativeWindow \*window, struct NativeWindowBuffer \*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 (struct NativeWindow \*window, int code,...) | Sets or obtains the attributes of a native window, including the width, height, and content format.| +| OH_NativeWindow_GetBufferHandleFromNative (struct NativeWindowBuffer \*buffer) | Obtains the pointer to a `BufferHandle` of a `NativeWindowBuffer` instance.| +| OH_NativeWindow_NativeObjectReference (void \*obj) | Adds the reference count of a native object.| +| 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 (void \*obj) | Obtains the magic ID of a native object.| + + + +## How to Develop + +The following steps describe how to use `OH_NativeXComponent` in OpenHarmony to draw content using native C++ code and display the content on the screen. + +1. Define an `XComponent` of the `texture` type in `index.ets` for content display. + ```js + XComponent({ id: 'xcomponentId', type: 'texture', libraryname: 'nativerender'}) + .borderColor(Color.Red) + .borderWidth(5) + .onLoad(() => {}) + .onDestroy(() => {}) + ``` + +2. Obtain an `OH_NativeXComponent` instance (named `nativeXComponent` in this example) by calling `napi_get_named_property`, and obtain a `NativeWindow` instance by registering the callback of the `OH_NativeXComponent` instance. + + ```c++ + // Define a NAPI instance. + napi_value exportInstance = nullptr; + // Define an OH_NativeXComponent instance. + OH_NativeXComponent *nativeXComponent = nullptr; + // Use the OH_NATIVE_XCOMPONENT_OBJ export instance. + napi_getname_property(env, exports, OH_NATIVE_XCOMPONENT_OBJ, &exportInstance); + // Convert the NAPI instance to the OH_NativeXComponent instance. + napi_unwarp(env, exportInstance, reinterpret_cast(&nativeXComponent)); + ``` + +3. Define the callback `OnSurfaceCreated`. During the creation of a `Surface`, the callback is used to initialize the rendering environment, for example, the `Skia` rendering environment, and write the content to be displayed to `NativeWindow`. + + ```c++ + void OnSufaceCreatedCB(NativeXComponent* component, void* window) { + // Obtain the width and height of the native window. + uint64_t width_ = 0, height_ = 0; + OH_NativeXComponent_GetXComponentSize(nativeXComponent, window, &width_, &height_); + // Convert void* into a NativeWindow instance. NativeWindow is defined in native_window/external_window.h. + NativeWindow* nativeWindow_ = (NativeWindow*)(window); + + // Set or obtain the NativeWindow attributes by calling OH_NativeWindow_NativeWindowHandleOpt. + // 1. Use SET_USAGE to set the usage attribute of the native window, for example, to HBM_USE_CPU_READ. + OH_NativeWindow_NativeWindowHandleOpt(nativeWindow_, SET_USAGE, HBM_USE_CPU_READ | HBM_USE_CPU_WRITE |HBM_USE_MEM_DMA); + // 2. Use SET_BUFFER_GEOMETRY to set the width and height attributes of the native window. + OH_NativeWindow_NativeWindowHandleOpt(nativeWindow_, SET_BUFFER_GEOMETRY, width_, height_); + // 3. Use SET_FORMAT to set the format attribute of the native window, for example, to PIXEL_FMT_RGBA_8888. + OH_NativeWindow_NativeWindowHandleOpt(nativeWindow_, SET_FORMAT, PIXEL_FMT_RGBA_8888); + // 4. Use SET_STRIDE to set the stride attribute of the native window. + OH_NativeWindow_NativeWindowHandleOpt(nativeWindow_, SET_STRIDE, 0x8); + + // Obtain the NativeWindowBuffer instance by calling OH_NativeWindow_NativeWindowRequestBuffer. + struct NativeWindowBuffer* buffer = nullptr; + int fenceFd; + OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow_, &buffer, &fenceFd); + + // Obtain the buffer handle by calling OH_NativeWindow_GetNativeBufferHandleFromNative. + BufferHandle* bufferHandle = OH_NativeWindow_GetNativeBufferHandleFromNative(buffer); + + // Create a Skia bitmap using BufferHandle. + SkBitmap bitmap; + SkImageInfo imageInfo = ... + bitmap.setInfo(imageInfo, bufferHandle->stride); + bitmap.setPixels(bufferHandle->virAddr); + // Create Skia Canvas and write the content to the native window. + ... + + // After the write operation is complete, flush the buffer by using OH_NativeWindwo_NativeWindowFlushBuffer so that the data is displayed on the screen. + Regoin region{nullptr, 0}; + OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow_, buffer, fenceFd, region) + } + ``` + +4. Register the callback `OnSurfaceCreated` by using `OH_NativeXComponent_RegisterCallback`. + + ```c++ + OH_NativeXComponent_Callback &callback_; + callback_->OnSurfaceCreated = OnSufaceCreatedCB; + callback_->OnSurfaceChanged = OnSufaceChangedCB; + callback_->OnSurfaceDestoryed = OnSufaceDestoryedCB; + callback_->DispatchTouchEvent = DispatchTouchEventCB; + OH_NativeXComponent_RegisterCallback(nativeXComponent, callback_) + ``` diff --git a/en/application-dev/reference/apis/js-apis-arraylist.md b/en/application-dev/reference/apis/js-apis-arraylist.md index a887e9a02b24275e2574ea5fac7ecee0ac49f723..341295a167878f6c3696efe01f15a29415f91cd8 100644 --- a/en/application-dev/reference/apis/js-apis-arraylist.md +++ b/en/application-dev/reference/apis/js-apis-arraylist.md @@ -320,10 +320,10 @@ arrayList.add(2); arrayList.add(4); arrayList.add(5); arrayList.add(4); -arrayList.replaceAllElements((value, index) => { +arrayList.replaceAllElements((value: number, index: number)=> { return value = 2 * value; }); -arrayList.replaceAllElements((value, index) => { +arrayList.replaceAllElements((value: number, index: number) => { return value = value - 2; }); ``` @@ -394,8 +394,8 @@ arrayList.add(2); arrayList.add(4); arrayList.add(5); arrayList.add(4); -arrayList.sort((a, b) => a - b); -arrayList.sort((a, b) => b - a); +arrayList.sort((a: number, b: number) => a - b); +arrayList.sort((a: number, b: number) => b - a); arrayList.sort(); ``` diff --git a/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md b/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md index eaeeb4eed2bad246570487fdd2a8f542d0bbb09b..cbb0ff47c767fd26e499913f44ba88d7e6187f17 100644 --- a/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md +++ b/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md @@ -1,6 +1,14 @@ -# Background Task Management +# BackgroundTaskManager -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +This module provides background task management. + +If a service needs to be continued when the application or service module is running in the background (not visible to users), the application or service module can request a transient task or continuous task for delayed suspension based on the service type. + +If an application has a task that needs to be continued when the application is switched to the background and can be completed within a short period of time, the application can request a transient task. For example, if a user chooses to clear junk files in the **Files** application and exits the application, the application can request a transient task to complete the cleanup. + +If an application has a service that can be intuitively perceived by users and needs to run in the background for a long period of time (for example, music playback in the background), the application can request a continuous task. + +> **NOTE** > > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -26,7 +34,7 @@ The default duration of delayed suspension is 180000 when the battery level is h | Name | Type | Mandatory | Description | | -------- | -------------------- | ---- | ------------------------------ | | reason | string | Yes | Reason for delayed transition to the suspended state. | -| callback | Callback<void> | Yes | Invoked when a delay is about to time out. Generally, this callback is used to notify the application 6 seconds before the delay times out. | +| callback | Callback<void> | Yes | Invoked when a delay is about to time out. Generally, this callback is used to notify the application 6 seconds before the delay times out.| **Return value** | Type | Description | @@ -120,6 +128,7 @@ Cancels the suspension delay. **Example** ```js + let id = 1; backgroundTaskManager.cancelSuspendDelay(id); ``` @@ -187,16 +196,16 @@ Requests a continuous task from the system. This API uses a promise to return th **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | --------- | ---------------------------------- | ---- | ----------------------- | -| context | [Context](js-apis-Context.md) | Yes | Application context. | -| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. | -| wantAgent | [WantAgent](js-apis-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. | +| context | [Context](js-apis-Context.md) | Yes | Application context. | +| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. | +| wantAgent | [WantAgent](js-apis-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked.| **Return value** -| Type | Description | +| Type | Description | | -------------- | ---------------- | -| Promise\ | Promise used to return the result. | +| Promise\ | Promise used to return the result.| **Example** ```js @@ -236,10 +245,10 @@ Requests to cancel a continuous task. This API uses an asynchronous callback to **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | -------- | ----------------------------- | ---- | ---------------------- | -| context | [Context](js-apis-Context.md) | Yes | Application context. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| context | [Context](js-apis-Context.md) | Yes | Application context. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** ```js @@ -267,14 +276,14 @@ Requests to cancel a continuous task. This API uses a promise to return the resu **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ------- | ----------------------------- | ---- | --------- | -| context | [Context](js-apis-Context.md) | Yes | Application context. | +| context | [Context](js-apis-Context.md) | Yes | Application context.| **Return value** -| Type | Description | +| Type | Description | | -------------- | ---------------- | -| Promise\ | Promise used to return the result. | +| Promise\ | Promise used to return the result.| **Example** ```js @@ -305,14 +314,14 @@ Provides the information about the suspension delay. **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask -| Name | Value| Description | -| ----------------------- | ------ | ---------------------------- | -| DATA_TRANSFER | 1 | Data transfer. | -| AUDIO_PLAYBACK | 2 | Audio playback. | -| AUDIO_RECORDING | 3 | Audio recording. | -| LOCATION | 4 | Positioning and navigation. | -| BLUETOOTH_INTERACTION | 5 | Bluetooth-related task. | -| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection. | -| WIFI_INTERACTION | 7 | WLAN-related (reserved). | -| VOIP | 8 | Voice and video call (reserved). | -| TASK_KEEPING | 9 | Computing task (effective only for specific devices).| +| Name | Value| Description | +| ----------------------- | ------ | ------------------------------------------------------------ | +| DATA_TRANSFER | 1 | Data transfer. | +| AUDIO_PLAYBACK | 2 | Audio playback. | +| AUDIO_RECORDING | 3 | Audio recording. | +| LOCATION | 4 | Positioning and navigation. | +| BLUETOOTH_INTERACTION | 5 | Bluetooth-related task. | +| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection. | +| WIFI_INTERACTION | 7 | WLAN-related.
This is a system API and cannot be called by third-party applications.| +| VOIP | 8 | Audio and video calls.
This is a system API and cannot be called by third-party applications.| +| TASK_KEEPING | 9 | Computing task (effective only for specific devices). | diff --git a/en/application-dev/reference/apis/js-apis-data-ability.md b/en/application-dev/reference/apis/js-apis-data-ability.md index 5e13507952dec34e32f7a4e49a75669ccc16fd82..b801f7038e84713dd3096a7c7c63f3a03314e2a5 100644 --- a/en/application-dev/reference/apis/js-apis-data-ability.md +++ b/en/application-dev/reference/apis/js-apis-data-ability.md @@ -1,6 +1,6 @@ # DataAbilityPredicates -> **NOTE**
+> **NOTE** > > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -24,15 +24,15 @@ Creates an **RdbPredicates** object from a **DataAbilityPredicates** object. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | name | string | Yes| Table name in the RDB store.| - | dataAbilityPredicates | [DataAbilityPredicates](#dataabilitypredicates) | Yes| **DataAbilityPredicates** object. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Table name in the RDB store.| +| dataAbilityPredicates | [DataAbilityPredicates](#dataabilitypredicates) | Yes| **DataAbilityPredicates** object. | **Return value** - | Type| Description| - | -------- | -------- | - | rdb.[RdbPredicates](js-apis-data-rdb.md#rdbpredicates) | **RdbPredicates** object created.| +| Type| Description| +| -------- | -------- | +| rdb.[RdbPredicates](js-apis-data-rdb.md#rdbpredicates) | **RdbPredicates** object created.| **Example** ```js @@ -58,15 +58,15 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -85,15 +85,15 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -112,9 +112,9 @@ Adds a left parenthesis to this **DataAbilityPredicates**. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a left parenthesis.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a left parenthesis.| **Example** ```js @@ -138,9 +138,9 @@ Adds a right parenthesis to this **DataAbilityPredicates**. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a right parenthesis.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a right parenthesis.| **Example** ```js @@ -164,9 +164,9 @@ Adds the OR condition to this **DataAbilityPredicates**. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the OR condition.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the OR condition.| **Example** ```js @@ -187,9 +187,9 @@ Adds the AND condition to this **DataAbilityPredicates**. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the AND condition.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the AND condition.| **Example** ```js @@ -210,15 +210,15 @@ Sets a **DataAbilityPredicates** object to match a string containing the specifi **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | string | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | string | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -237,15 +237,15 @@ Sets a **DataAbilityPredicates** object to match a string that starts with the s **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | string | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | string | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -264,15 +264,15 @@ Sets a **DataAbilityPredicates** object to match a string that ends with the spe **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | string | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | string | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ``` @@ -291,14 +291,14 @@ Sets a **DataAbilityPredicates** object to match the field whose value is null. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -317,14 +317,14 @@ Sets a **DataAbilityPredicates** object to match the field whose value is not nu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -343,15 +343,15 @@ Sets a **DataAbilityPredicates** object to match a string that is similar to the **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | string | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | string | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -370,15 +370,15 @@ Sets a **DataAbilityPredicates** object to match the specified string. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | string | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | string | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -397,16 +397,16 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.| - | high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.| +| high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -425,16 +425,16 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.| - | high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.| +| high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -453,15 +453,15 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -480,15 +480,15 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -507,15 +507,15 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -534,15 +534,15 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -561,14 +561,14 @@ Sets a **DataAbilityPredicates** object to match the column with values sorted i **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -587,14 +587,14 @@ Sets a **DataAbilityPredicates** object to match the column with values sorted i **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -613,9 +613,9 @@ Sets a **DataAbilityPredicates** object to filter out duplicate records. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that can filter out duplicate records.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that can filter out duplicate records.| **Example** ```js @@ -634,14 +634,14 @@ Set a **DataAbilityPredicates** object to specify the maximum number of records. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | number | Yes| Maximum number of records.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | number | Yes| Maximum number of records.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the maximum number of records.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the maximum number of records.| **Example** ```js @@ -660,14 +660,14 @@ Sets a **DataAbilityPredicates** object to specify the start position of the ret **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | rowOffset | number | Yes| Number of rows to offset from the beginning. The value is a positive integer.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| rowOffset | number | Yes| Number of rows to offset from the beginning. The value is a positive integer.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the start position of the returned result.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the start position of the returned result.| **Example** ```js @@ -686,14 +686,14 @@ Sets a **DataAbilityPredicates** object to group rows that have the same value i **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fields | Array<string> | Yes| Names of columns to group.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| fields | Array<string> | Yes| Names of columns to group.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that groups rows with the same value.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that groups rows with the same value.| **Example** ```js @@ -705,19 +705,20 @@ Sets a **DataAbilityPredicates** object to group rows that have the same value i indexedBy(field: string): DataAbilityPredicates - Sets a **DataAbilityPredicates** object to specify the index column. +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | indexName | string | Yes| Name of the index column.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| indexName | string | Yes| Name of the index column.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the index column.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the index column.| **Example** ```js @@ -736,16 +737,16 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array< **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | Array<[ValueType](#valuetype)> | Yes| Array of **ValueType**s to match.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | Array<[ValueType](#valuetype)> | Yes| Array of **ValueType**s to match.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -764,16 +765,16 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array< **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | Array<[ValueType](#valuetype)> | Yes| Array of **ValueType**s to match.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | Array<[ValueType](#valuetype)> | Yes| Array of **ValueType**s to match.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js diff --git a/en/application-dev/reference/apis/js-apis-display.md b/en/application-dev/reference/apis/js-apis-display.md index 994fe3a673ca9d505c0a6f96df6f007fe6d027d4..ffbc73ff530a4d8f9ec39fd6e824760df9448644 100644 --- a/en/application-dev/reference/apis/js-apis-display.md +++ b/en/application-dev/reference/apis/js-apis-display.md @@ -1,6 +1,8 @@ # Display +Provides APIs for managing displays, such as obtaining information about the default display, obtaining information about all displays, and listening for the addition and removal of displays. -> **NOTE**
+> **NOTE** +> > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -139,7 +141,7 @@ Obtains all the display objects. | Type | Description | | ----------------------------------------------- | ------------------------------------------------------- | - | Promise<Array<[Display](#display)>> | Promise used to return an array containing all the display objects.| + | Promise<Array<[Display](#display)>> | Promise used to return all the display objects.| **Example** @@ -163,7 +165,7 @@ Enables listening. **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Listening type. The available values are as follows:
- **add**: listening for whether a display is added
- **remove**: listening for whether a display is removed
- **change**: listening for whether a display is changed| + | type | string | Yes| Listening type. The available values are as follows:
- **add**: listening for whether a display is added
- **remove**: listening for whether a display is removed
- **change**: listening for whether a display is changed| | callback | Callback<number> | Yes| Callback used to return the ID of the display.| **Example** @@ -186,7 +188,7 @@ Disables listening. **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Listening type. The available values are as follows:
- **add**: listening for whether a display is added
- **remove**: listening for whether a display is removed
- **change**: listening for whether a display is changed| + | type | string | Yes| Listening type. The available values are as follows:
- **add**: listening for whether a display is added
- **remove**: listening for whether a display is removed
- **change**: listening for whether a display is changed| | callback | Callback<number> | No| Callback used to return the ID of the display.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-distributed-data.md b/en/application-dev/reference/apis/js-apis-distributed-data.md index b8ed7361d1d9c88fc69c4109c19bd64ef0948783..24571aaf04fe72804e5060a3a39e62ce3b794f7d 100644 --- a/en/application-dev/reference/apis/js-apis-distributed-data.md +++ b/en/application-dev/reference/apis/js-apis-distributed-data.md @@ -576,13 +576,12 @@ Provides KV store configuration. Defines the KV store types. -**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | Name | Default Value| Description | | --- | ---- | ----------------------- | -| DEVICE_COLLABORATION | 0 | Device KV store. | -| SINGLE_VERSION | 1 | Single KV store. | -| MULTI_VERSION | 2 | Multi-version KV store. This type is not supported currently. | +| DEVICE_COLLABORATION | 0 | Device KV store.
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | +| SINGLE_VERSION | 1 | Single KV store.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | +| MULTI_VERSION | 2 | Multi-version KV store. This type is not supported currently.
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore| ## SecurityLevel diff --git a/en/application-dev/reference/apis/js-apis-hiappevent.md b/en/application-dev/reference/apis/js-apis-hiappevent.md index 4ec4c1062d7915888ae6d13037aa0ff9235e6c2c..936a25c49fd8ec4ac1164f819635d855e0df852f 100644 --- a/en/application-dev/reference/apis/js-apis-hiappevent.md +++ b/en/application-dev/reference/apis/js-apis-hiappevent.md @@ -1,12 +1,14 @@ # HiAppEvent -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +This module provides the application event logging functions, such as writing application events to the event file and managing the event logging configuration. + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import -``` +```js import hiAppEvent from '@ohos.hiAppEvent'; ``` @@ -23,14 +25,14 @@ Writes event information to the event file of the current day. This API supports | Name | Type | Mandatory| Description | | --------- | ------------------------- | ---- | ------------------------------------------------------------ | -| eventName | string | Yes | App event name.
You need to customize the event name. It can contain a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter.| +| eventName | string | Yes | Application event name.
You need to customize the event name. It can contain a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter. | | eventType | [EventType](#eventtype) | Yes | Application event type. | -| keyValues | object | Yes | Parameter key-value pair. For a variable-length parameter, enter each pair of parameter name and value in sequence. For a JSON parameter, enter the parameter name as the key and parameter value as the value.
- A key must be a string, and a value must be a string, number, boolean, or Array (which can only be a string, number, or boolean).
- The number of event parameters must be less than or equal to 32.
- The parameter name can contain a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter and cannot end with an underscore (\_).
- A string value can contain a maximum of 8*1024 characters.
- An array value can contain a maximum of 100 elements. Excess elements will be truncated.| -| callback | AsyncCallback<void> | No | Callback used to process the received return value.
-  Value **0** indicates that the event verification is successful, and the event will be written to the event file asynchronously.
-  A value greater than **0** indicates that invalid parameters are present in the event, and the event will be written to the event file asynchronously after the invalid parameters are ignored.
-  A value smaller than **0** indicates that the event verification fails, and the event will not be written to the event file.| +| keyValues | object | Yes | Parameter key-value pair. For a variable-length parameter, enter each pair of parameter name and value in sequence. For a JSON parameter, enter the parameter name as the key and parameter value as the value.
- A key must be a string, and a value must be a string, number, boolean, or Array (which can only be a string, number, or boolean).
- The number of event parameters must be less than or equal to 32.
- The parameter name can contain a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter and cannot end with an underscore (\_).
- A string value can contain a maximum of 8*1024 characters.
- An array value can contain a maximum of 100 elements. Excess elements will be truncated. | +| callback | AsyncCallback<void> | No | Callback used to process the received return value.
-  Value **0** indicates that the event verification is successful, and the event will be written to the event file asynchronously.
-  A value greater than **0** indicates that invalid parameters are present in the event, and the event will be written to the event file asynchronously after the invalid parameters are ignored.
-  A value smaller than **0** indicates that the event verification fails, and the event will not be written to the event file. | **Example** -``` +```js hiAppEvent.write("test_event", hiAppEvent.EventType.FAULT, {"int_data":100, "str_data":"strValue"}, (err, value) => { if (err) { // Event writing exception: Write the event to the event file after the invalid parameters in the event are ignored, or stop writing the event if the event verification fails. @@ -56,19 +58,19 @@ Writes event information to the event file of the current day. This API supports | Name | Type | Mandatory| Description | | --------- | ----------------------- | ---- | ------------------------------------------------------------ | -| eventName | string | Yes | App event name.
You need to customize the event name. It can contain a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter.| +| eventName | string | Yes | Application event name.
You need to customize the event name. It can contain a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter. | | eventType | [EventType](#eventtype) | Yes | Application event type. | -| keyValues | object | Yes | Parameter key-value pair. For a variable-length parameter, enter each pair of parameter name and value in sequence. For a JSON parameter, enter the parameter name as the key and parameter value as the value.
- A key must be a string, and a value must be a string, number, boolean, or Array (which can only be a string, number, or boolean).
- The number of event parameters must be less than or equal to 32.
- The parameter name can contain a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter and cannot end with an underscore (\_).
- A string value can contain a maximum of 8*1024 characters.
- An array value can contain a maximum of 100 elements. Excess elements will be truncated.| +| keyValues | object | Yes | Parameter key-value pair. For a variable-length parameter, enter each pair of parameter name and value in sequence. For a JSON parameter, enter the parameter name as the key and parameter value as the value.
- A key must be a string, and a value must be a string, number, boolean, or Array (which can only be a string, number, or boolean).
- The number of event parameters must be less than or equal to 32.
- The parameter name can contain a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter and cannot end with an underscore (\_).
- A string value can contain a maximum of 8*1024 characters.
- An array value can contain a maximum of 100 elements. Excess elements will be truncated. | **Return value** | Type | Description | | ------------------- | ------------------------------------------------------------ | -| Promise<void> | Promise used to process the callback in the then() and catch() methods when event writing succeeded or failed.| +| Promise<void> | Promise used to process the callback in the then() and catch() methods when event writing succeeded or failed. | **Example** -``` +```js hiAppEvent.write("test_event", hiAppEvent.EventType.FAULT, {"int_data":100, "str_data":"strValue"}) .then((value) => { // Event writing succeeded. @@ -92,16 +94,16 @@ Configures the application event logging function, such as setting the event log | Name| Type | Mandatory| Description | | ------ | ----------------------------- | ---- | ------------------------ | -| config | [ConfigOption](#configoption) | Yes | Configuration items for application event logging.| +| config | [ConfigOption](#configoption) | Yes | Configuration items for application event logging. | **Return value** | Type | Description | | ------- | ----------------------------------------------------------- | -| boolean | Returns **true** if the configuration is successful; returns **false** otherwise.| +| boolean | Returns **true** if the configuration is successful; returns **false** otherwise. | **Example** -``` +```js // Set the application event logging switch. hiAppEvent.configure({ disable: true @@ -122,8 +124,8 @@ Provides the configuration items for application event logging. | Name | Type | Mandatory| Description | | ---------- | ------- | ---- | ------------------------------------------------------------ | -| disable | boolean | No | Application event logging switch. The value true means to disable the application event logging function, and the value false means the opposite.| -| maxStorage | string | No | Maximum size of the event file storage directory. The default value is **10M**. If the specified size is exceeded, the oldest event logging files in the storage directory will be deleted to free up space.| +| disable | boolean | No | Application event logging switch. The value true means to disable the application event logging function, and the value false means the opposite. | +| maxStorage | string | No | Maximum size of the event file storage directory. The default value is **10M**. If the specified size is exceeded, the oldest event logging files in the storage directory will be deleted to free up space. | ## EventType @@ -150,7 +152,7 @@ Provides constants that define the names of all predefined events. | ------------------------- | -------- | ---- | ---- | -------------------- | | USER_LOGIN | string | Yes | No | User login event. | | USER_LOGOUT | string | Yes | No | User logout event. | -| DISTRIBUTED_SERVICE_START | string | Yes | No | Distributed service startup event.| +| DISTRIBUTED_SERVICE_START | string | Yes | No | Distributed service startup event. | ## Param @@ -159,8 +161,8 @@ Provides constants that define the names of all predefined event parameters. **System capability**: SystemCapability.HiviewDFX.HiAppEvent -| Name | Type| Readable| Writable| Description | +| Name | Type | Readable | Writable | Description | | ------------------------------- | -------- | ---- | ---- | ------------------ | | USER_ID | string | Yes | No | Custom user ID. | -| DISTRIBUTED_SERVICE_NAME | string | Yes | No | Distributed service name. | -| DISTRIBUTED_SERVICE_INSTANCE_ID | string | Yes | No | Distributed service instance ID.| +| DISTRIBUTED_SERVICE_NAME | string | Yes | No | Distributed service name. | +| DISTRIBUTED_SERVICE_INSTANCE_ID | string | Yes | No | Distributed service instance ID. | \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-hitracechain.md b/en/application-dev/reference/apis/js-apis-hitracechain.md index 485eddc0fbfb59946228e859760885ad0ce1b633..cbaf898f75c37ba8921fe3d8ffd11e5484ec28e8 100644 --- a/en/application-dev/reference/apis/js-apis-hitracechain.md +++ b/en/application-dev/reference/apis/js-apis-hitracechain.md @@ -1,5 +1,7 @@ # Distributed Call Chain Tracing +This module implements call chain tracing throughout a service process. It provides functions such as starting and stopping call chain tracing and configuring trace points. + > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. diff --git a/en/application-dev/reference/apis/js-apis-hitracemeter.md b/en/application-dev/reference/apis/js-apis-hitracemeter.md index 656063edf90a71a74e8f7b5e90375acfccfdae9c..e856ee20a4c8956ff0f05707b596935b68ca9e7a 100644 --- a/en/application-dev/reference/apis/js-apis-hitracemeter.md +++ b/en/application-dev/reference/apis/js-apis-hitracemeter.md @@ -1,5 +1,7 @@ # Performance Tracing +This module provides the functions of tracing service processes and monitoring the system performance. It provides the data needed for hiTraceMeter to carry out performance analysis. + > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. diff --git a/en/application-dev/reference/apis/js-apis-list.md b/en/application-dev/reference/apis/js-apis-list.md index dfd940b660fe213cf114a7a2b3391c75eb608c5e..0b839a5a0baae3fa58e4592485c3b9e959183530 100644 --- a/en/application-dev/reference/apis/js-apis-list.md +++ b/en/application-dev/reference/apis/js-apis-list.md @@ -364,10 +364,10 @@ list.add(2); list.add(4); list.add(5); list.add(4); -list.replaceAllElements((value, index) => { +list.replaceAllElements((value: number, index: number) => { return value = 2 * value; }); -list.replaceAllElements((value, index) => { +list.replaceAllElements((value: number, index: number) => { return value = value - 2; }); ``` @@ -439,8 +439,8 @@ list.add(2); list.add(4); list.add(5); list.add(4); -list.sort((a, b) => a - b); -list.sort((a, b) => b - a); +list.sort((a: number, b: number) => a - b); +list.sort((a: number, b: number) => b - a); ``` ### getSubList @@ -472,9 +472,9 @@ list.add(2); list.add(4); list.add(5); list.add(4); -let result = list.subList(2, 4); -let result1 = list.subList(4, 3); -let result2 = list.subList(2, 6); +let result = list.getSubList(2, 4); +let result1 = list.getSubList(4, 3); +let result2 = list.getSubList(2, 6); ``` ### clear diff --git a/en/application-dev/reference/apis/js-apis-mediaquery.md b/en/application-dev/reference/apis/js-apis-mediaquery.md index 1f754aa69bee3f93a3420df473d06e915a673c4f..2f052176253fbbe14159bb8551aecbce13cc7de2 100644 --- a/en/application-dev/reference/apis/js-apis-mediaquery.md +++ b/en/application-dev/reference/apis/js-apis-mediaquery.md @@ -23,15 +23,17 @@ matchMediaSync(condition: string): MediaQueryListener Sets the media query criteria and returns the corresponding listening handle. +**System capability**: SystemCapability.ArkUI.ArkUI.Full + **Parameters** -| Name | Type | Mandatory | Description | -| --------- | ------ | ---- | ---------- | -| condition | string | Yes | Matching condition of a media event.| +| Name | Type | Mandatory | Description | +| --------- | ------ | ---- | ---------------------------------------- | +| condition | string | Yes | Matching condition of a media event. For details, see [Syntax of Media Query Conditions](../../ui/ui-ts-layout-mediaquery.md#syntax-of-media-query-conditions).| **Return value** | Type | Description | | ------------------ | ---------------------- | -| MediaQueryListener | Listening handle to a media event, which is used to register or unregister the listening callback.| +| MediaQueryListener | Listening handle to a media event, which is used to register or deregister the listening callback.| **Example** ```js @@ -43,6 +45,7 @@ listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for Media query handle, including the first query result when the handle is applied for. +**System capability**: SystemCapability.ArkUI.ArkUI.Full ### Attributes @@ -58,6 +61,8 @@ on(type: 'change', callback: Callback<MediaQueryResult>): void Registers a callback with the corresponding query condition by using the handle. This callback is triggered when the media attributes change. +**System capability**: SystemCapability.ArkUI.ArkUI.Full + **Parameters** | Name | Type | Mandatory | Description | | -------- | -------------------------------- | ---- | ---------------- | @@ -72,12 +77,15 @@ Registers a callback with the corresponding query condition by using the handle. off(type: 'change', callback?: Callback<MediaQueryResult>): void -Unregisters a callback with the corresponding query condition by using the handle, so that no callback is triggered when the media attributes change. +Deregisters a callback with the corresponding query condition by using the handle, so that no callback is triggered when the media attributes change. + +**System capability**: SystemCapability.ArkUI.ArkUI.Full + **Parameters** | Name | Type | Mandatory | Description | | -------- | -------------------------------- | ---- | ----------------------------- | | type | boolean | Yes | Must enter the string **change**. | -| callback | Callback<MediaQueryResult> | No | Callback to be unregistered. If the default value is used, all callbacks of the handle are unregistered.| +| callback | Callback<MediaQueryResult> | No | Callback to be deregistered. If the default value is used, all callbacks of the handle are deregistered.| **Example** ```js @@ -92,7 +100,7 @@ Unregisters a callback with the corresponding query condition by using the handl } } listener.on('change', onPortrait) // Register a callback. - listener.off('change', onPortrait) // Unregister a callback. + listener.off('change', onPortrait) // Deregister a callback. ``` diff --git a/en/application-dev/reference/apis/js-apis-router.md b/en/application-dev/reference/apis/js-apis-router.md index b17d29151d7c1c9a9ee53de976cd4c0f77ea838a..40076077bd258dab549dbcb46e16a7137961c107 100644 --- a/en/application-dev/reference/apis/js-apis-router.md +++ b/en/application-dev/reference/apis/js-apis-router.md @@ -1,6 +1,6 @@ # Page Routing -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE** > > - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - Page routing APIs can be invoked only after page rendering is complete. Do not call the APIs in **onInit** and **onReady** when the page is still in the rendering phase. @@ -190,6 +190,8 @@ getLength(): string Obtains the number of pages in the current stack. +**System capability**: SystemCapability.ArkUI.ArkUI.Full + **Return value** | Type| Description| | -------- | -------- | @@ -275,7 +277,7 @@ Enables the display of a confirm dialog box before returning to the previous pag Describes the confirm dialog box. -**System capability**: SystemCapability.ArkUI.ArkUI.Lite +**System capability**: SystemCapability.ArkUI.ArkUI.Full | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | diff --git a/en/application-dev/reference/apis/js-apis-screenshot.md b/en/application-dev/reference/apis/js-apis-screenshot.md index f9e0dc56a201863394209db59095b0d04628045b..d3a129c401e466113cc335cb2ce0e63e9a6ce62f 100644 --- a/en/application-dev/reference/apis/js-apis-screenshot.md +++ b/en/application-dev/reference/apis/js-apis-screenshot.md @@ -1,8 +1,11 @@ # Screenshot +Provides APIs for you to set information such as the region to capture and the size of the screen region when capturing a screen. > **NOTE** > > The initial APIs of this module are supported since API version 7. 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 @@ -17,11 +20,12 @@ Describes screenshot options. **System capability**: SystemCapability.WindowManager.WindowManager.Core -| Name | Type | Mandatory| Description | -| ---------- | ------------- | ---- | ------------------------------------------------------------ | -| screenRect | [Rect](#rect) | No | Region of the screen to capture. If this parameter is null, the full screen will be captured.| -| imageSize | [Size](#size) | No | Size of the screen region to capture. If this parameter is null, the full screen will be captured.| -| rotation | number | No | Rotation angle of the screenshot. Currently, the value can be **0** only. The default value is **0**.| +| Name | Type | Mandatory| Description | +| ---------------------- | ------------- | ---- | ------------------------------------------------------------ | +| screenRect | [Rect](#rect) | No | Region of the screen to capture. If this parameter is null, the full screen will be captured. | +| imageSize | [Size](#size) | No | Size of the screen region to capture. If this parameter is null, the full screen will be captured. | +| rotation | number | No | Rotation angle of the screenshot. Currently, the value can be **0** only. The default value is **0**. | +| displayId8+ | number | No | ID of the [display](js-apis-display.md#display) device on which the screen region is to be captured.| ## Rect @@ -63,7 +67,7 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal | Name | Type | Mandatory| Description | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | -| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| +| options | [ScreenshotOptions](#screenshotoptions) | No | Consists of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set them separately.| | callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return a **PixelMap** object. | **Example** @@ -78,7 +82,8 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal "imageSize": { "width": 300, "height": 300}, - "rotation": 0 + "rotation": 0, + "displayId": 0 }; screenshot.save(ScreenshotOptions, (err, data) => { if (err) { @@ -103,13 +108,13 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro | Name | Type | Mandatory| Description | | ------- | --------------------------------------- | ---- | ------------------------------------------------------------ | -| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| +| options | [ScreenshotOptions](#screenshotoptions) | No | Consists of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set them separately.| **Return value** | Type | Description | | ----------------------------- | ----------------------------------------------- | -| Promise<image.PixelMap> | Promise used to return an **image.PixelMap** object.| +| Promise<image.PixelMap> | Promise used to return a **PixelMap** object.| **Example** @@ -123,7 +128,8 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro "imageSize": { "width": 300, "height": 300}, - "rotation": 0 + "rotation": 0, + "displayId": 0 }; let promise = screenshot.save(ScreenshotOptions); promise.then(() => { diff --git a/en/application-dev/reference/apis/js-apis-system-time.md b/en/application-dev/reference/apis/js-apis-system-time.md index 4e35097eef25a1e7276efef9d477cf0abc8c4022..35e09c4168db955cf6a5d5741a536dcd0711c3b7 100644 --- a/en/application-dev/reference/apis/js-apis-system-time.md +++ b/en/application-dev/reference/apis/js-apis-system-time.md @@ -190,7 +190,7 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This **Example** ```js - systemTime.getCurrentTime().then((data) => { + systemTime.getRealActiveTime().then((data) => { console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); }).catch((error) => { console.error(`failed to systemTime.getRealActiveTime because ` + JSON.stringify(error)); diff --git a/en/application-dev/reference/apis/js-apis-update.md b/en/application-dev/reference/apis/js-apis-update.md index 251c1d59b610f4d01372186d0e40d0521cf62ca8..cba0c8a1ce4f475c5b60964ba37c8beee9454fc7 100644 --- a/en/application-dev/reference/apis/js-apis-update.md +++ b/en/application-dev/reference/apis/js-apis-update.md @@ -134,11 +134,11 @@ Obtains the new version information. This function uses an asynchronous callback **Example** ``` -updater.getNewVersionInfo(info => { +updater.getNewVersionInfo((err, info) => { console.log("getNewVersionInfo success " + info.status); - console.log(`info versionName = ` + info.checkResult[0].versionName); - console.log(`info versionCode = ` + info.checkResult[0].versionCode); - console.log(`info verifyInfo = ` + info.checkResult[0].verifyInfo); + console.log(`info versionName = ` + info.checkResults[0].versionName); + console.log(`info versionCode = ` + info.checkResults[0].versionCode); + console.log(`info verifyInfo = ` + info.checkResults[0].verifyInfo); }); ``` @@ -160,9 +160,9 @@ Obtains the new version information. This function uses a promise to return the ``` updater.getNewVersionInfo().then(value => { - console.log(`info versionName = ` + value.checkResult[0].versionName); - console.log(`info versionCode = ` + value.checkResult[0].versionCode); - console.log(`info verifyInfo = ` + value.checkResult[0].verifyInfo); + console.log(`info versionName = ` + value.checkResults[0].versionName); + console.log(`info versionCode = ` + value.checkResults[0].versionCode); + console.log(`info verifyInfo = ` + value.checkResults[0].verifyInfo); }).catch(err => { console.log("getNewVersionInfo promise error: " + err.code); }); @@ -185,11 +185,11 @@ Checks whether the current version is the latest. This function uses an asynchro **Example** ``` -updater.checkNewVersion(info => { +updater.checkNewVersion((err, info) => { console.log("checkNewVersion success " + info.status); - console.log(`info versionName = ` + info.checkResult[0].versionName); - console.log(`info versionCode = ` + info.checkResult[0].versionCode); - console.log(`info verifyInfo = ` + info.checkResult[0].verifyInfo); + console.log(`info versionName = ` + info.checkResults[0].versionName); + console.log(`info versionCode = ` + info.checkResults[0].versionCode); + console.log(`info verifyInfo = ` + info.checkResults[0].verifyInfo); }); ``` @@ -211,9 +211,9 @@ Checks whether the current version is the latest. This function uses a promise t ``` updater.checkNewVersion().then(value => { - console.log(`info versionName = ` + value.checkResult[0].versionName); - console.log(`info versionCode = ` + value.checkResult[0].versionCode); - console.log(`info verifyInfo = ` + value.checkResult[0].verifyInfo); + console.log(`info versionName = ` + value.checkResults[0].versionName); + console.log(`info versionCode = ` + value.checkResults[0].versionCode); + console.log(`info verifyInfo = ` + value.checkResults[0].verifyInfo); }).catch(err => { console.log("checkNewVersion promise error: " + err.code); }); @@ -284,7 +284,7 @@ Reboots the device and clears the user partition data. This function uses a prom **Example** ``` -updater.rebootAndCleanUserData(result => { +updater.rebootAndCleanUserData((err, result) => { console.log("rebootAndCleanUserData ", result) }); ``` @@ -330,7 +330,7 @@ Installs the update package. This function uses a promise to return the result. **Example** ``` -updater.applyNewVersion(result => { +updater.applyNewVersion((err, result) => { console.log("applyNewVersion ", result) }); ``` @@ -399,7 +399,7 @@ let policy = { autoUpgradeInterval: [ 2, 3 ], autoUpgradeCondition: 2 } -updater.setUpdatePolicy(policy, result => { +updater.setUpdatePolicy(policy, (err, result) => { console.log("setUpdatePolicy ", result) }); ``` @@ -458,7 +458,7 @@ Obtains the update policy. This function uses an asynchronous callback to return **Example** ``` -updater.getUpdatePolicy(policy => { +updater.getUpdatePolicy((err, policy) => { console.log("getUpdatePolicy success"); console.log(`policy autoDownload = ` + policy.autoDownload); console.log(`policy autoDownloadNet = ` + policy.autoDownloadNet); diff --git a/en/application-dev/reference/apis/js-apis-url.md b/en/application-dev/reference/apis/js-apis-url.md index b3d39d36eb25fb1e43e8f503e8933cb58e008e58..d97e984d438c8b18febfae5e578cf73dbff244d3 100755 --- a/en/application-dev/reference/apis/js-apis-url.md +++ b/en/application-dev/reference/apis/js-apis-url.md @@ -1,6 +1,7 @@ # URL String Parsing -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE** +> > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -10,10 +11,6 @@ import Url from '@ohos.url' ``` -## System Capabilities - -SystemCapability.Utils.Lang - ## URLSearchParams @@ -23,20 +20,22 @@ constructor(init?: string[][] | Record<string, string> | string | URLSearc Creates a **URLSearchParams** instance. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| init | string[][] \| Record<string, string> \| string \| URLSearchParams | No| Input parameter objects, which include the following:
- **string[][]**: two-dimensional string array
- **Record<string, string>**: list of objects
- **string**: string
- **URLSearchParams**: object| +| init | string[][] \| Record<string, string> \| string \| URLSearchParams | No| Input parameter objects, which include the following:
- **string[][]**: two-dimensional string array
- **Record<string, string>**: list of objects
- **string**: string
- **URLSearchParams**: object | **Example** ```js -var objectParams = new URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]); -var objectParams1 = new URLSearchParams({"fod" : 1 , "bard" : 2}); -var objectParams2 = new URLSearchParams('?fod=1&bard=2'); -var urlObject = new URL('https://developer.mozilla.org/?fod=1&bard=2'); -var params = new URLSearchParams(urlObject.search); +var objectParams = new Url.URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]); +var objectParams1 = new Url.URLSearchParams({"fod" : 1 , "bard" : 2}); +var objectParams2 = new Url.URLSearchParams('?fod=1&bard=2'); +var urlObject = new Url.URL('https://developer.mozilla.org/?fod=1&bard=2'); +var params = new Url.URLSearchParams(urlObject.search); ``` @@ -46,18 +45,20 @@ append(name: string, value: string): void Appends a key-value pair into the query string. +**System capability**: SystemCapability.Utils.Lang + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| name | string | Yes| Key of the key-value pair to append.| -| value | string | Yes| Value of the key-value pair to append.| +| name | string | Yes | Key of the key-value pair to append. | +| value | string | Yes | Value of the key-value pair to append. | **Example** ```js -let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); -let paramsObject = new URLSearchParams(urlObject.search.slice(1)); +let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); +let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1)); paramsObject.append('fod', 3); ``` @@ -68,17 +69,19 @@ delete(name: string): void Deletes key-value pairs of the specified key. +**System capability**: SystemCapability.Utils.Lang + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| name | string | Yes| Key of the key-value pairs to delete.| +| name | string | Yes | Key of the key-value pairs to delete. | **Example** ```js -let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); -let paramsobject = new URLSearchParams(urlObject.search.slice(1)); +let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); +let paramsobject = new Url.URLSearchParams(urlObject.search.slice(1)); paramsobject.delete('fod'); ``` @@ -89,23 +92,25 @@ getAll(name: string): string[] Obtains all the key-value pairs based on the specified key. +**System capability**: SystemCapability.Utils.Lang + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| name | string | Yes| Key specified to obtain all key-value pairs.| +| name | string | Yes | Key specified to obtain all key-value pairs. | **Return value** -| Type| Description| +| Type | Description | | -------- | -------- | -| string[] | All key-value pairs matching the specified key.| +| string[] | All key-value pairs matching the specified key. | **Example** ```js -let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); -let paramsObject = new URLSearchParams(urlObject.search.slice(1)); +let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); +let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1)); paramsObject.append('fod', 3); // Add a second value for the fod parameter. console.log(params.getAll('fod')) // Output ["1","3"]. ``` @@ -117,16 +122,18 @@ entries(): IterableIterator<[string, string]> Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively. +**System capability**: SystemCapability.Utils.Lang + **Return value** -| Type| Description| +| Type | Description | | -------- | -------- | -| IterableIterator<[string, string]> | ES6 iterator.| +| IterableIterator<[string, string]> | ES6 iterator. | **Example** ```js -var searchParamsObject = new URLSearchParams("keyName1=valueName1&keyName2=valueName2"); +var searchParamsObject = new Url.URLSearchParams("keyName1=valueName1&keyName2=valueName2"); for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pairs console.log(pair[0]+ ', '+ pair[1]); } @@ -139,25 +146,27 @@ forEach(callbackfn: (value: string, key: string, searchParams: this) => void, th Traverses the key-value pairs in the **URLSearchParams** instance by using a callback. +**System capability**: SystemCapability.Utils.Lang + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| callbackfn | function | Yes| Callback invoked to traverse the key-value pairs in the **URLSearchParams** instance.| -| thisArg | Object | No| Value to use when the callback is invoked.| +| callbackfn | function | Yes | Callback invoked to traverse the key-value pairs in the **URLSearchParams** instance. | +| thisArg | Object | No | Value to use when the callback is invoked. | **Table 1** callbackfn parameter description -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| value | string | Yes| Value that is currently traversed.| -| key | string | Yes| Key that is currently traversed.| -| searchParams | Object | Yes| Instance that invokes the **forEach** method.| +| value | string | Yes | Value that is currently traversed. | +| key | string | Yes | Key that is currently traversed. | +| searchParams | Object | Yes | Instance that invokes the **forEach** method. | **Example** ```js -const myURLObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); +const myURLObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); myURLObject.searchParams.forEach((value, name, searchParams) => { console.log(name, value, myURLObject.searchParams === searchParams); }); @@ -170,23 +179,25 @@ get(name: string): string | null Obtains the value of the first key-value pair based on the specified key. +**System capability**: SystemCapability.Utils.Lang + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| name | string | Yes| Key specified to obtain the value.| +| name | string | Yes | Key specified to obtain the value. | **Return value** -| Type| Description| +| Type | Description | | -------- | -------- | -| string | Returns the value of the first key-value pair if obtained.| -| null | Returns null if no value is obtained.| +| string | Returns the value of the first key-value pair if obtained. | +| null | Returns null if no value is obtained. | **Example** ```js -var paramsOject = new URLSearchParams(document.location.search.substring(1)); +var paramsOject = new Url.URLSearchParams(document.location.search.substring(1)); var name = paramsOject.get("name"); // is the string "Jonathan" var age = parseInt(paramsOject.get("age"), 10); // is the number 18 var address = paramsOject.get("address"); // null @@ -199,23 +210,25 @@ has(name: string): boolean Checks whether a key has a value. +**System capability**: SystemCapability.Utils.Lang + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| name | string | Yes| Key specified to search for its value.| +| name | string | Yes | Key specified to search for its value. | **Return value** -| Type| Description| +| Type | Description | | -------- | -------- | -| boolean | Returns **true** if the value exists; returns **false** otherwise.| +| boolean | Returns **true** if the value exists; returns **false** otherwise. | **Example** ```js -let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); -let paramsObject = new URLSearchParams(urlObject.search.slice(1)); +let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); +let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1)); paramsObject.has('bard') === true; ``` @@ -226,18 +239,20 @@ set(name: string, value: string): void Sets the value for a key. If key-value pairs matching the specified key exist, the value of the first key-value pair will be set to the specified value and other key-value pairs will be deleted. Otherwise, the key-value pair will be appended to the query string. +**System capability**: SystemCapability.Utils.Lang + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| name | string | Yes| Key of the value to set.| -| value | string | Yes| Value to set.| +| name | string | Yes | Key of the value to set. | +| value | string | Yes | Value to set. | **Example** ```js -let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); -let paramsObject = new URLSearchParams(urlObject.search.slice(1)); +let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); +let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1)); paramsObject.set('baz', 3); // Add a third parameter. ``` @@ -246,13 +261,14 @@ paramsObject.set('baz', 3); // Add a third parameter. sort(): void +Sorts all key-value pairs contained in this object based on the Unicode code points of the keys and returns undefined. This method uses a stable sorting algorithm, that is, the relative order between key-value pairs with equal keys is retained. -Sorts all key-value pairs contained in this object based on the Unicode code points of the keys and returns undefined. This method uses a stable sorting algorithm, that is, the relative order between key-value pairs with equal keys is retained. +**System capability**: SystemCapability.Utils.Lang **Example** ```js -var searchParamsObject = new URLSearchParams("c=3&a=9&b=4&d=2"); // Create a test URLSearchParams object +var searchParamsObject = new Url.URLSearchParams("c=3&a=9&b=4&d=2"); // Create a test URLSearchParams object searchParamsObject.sort(); // Sort the key/value pairs console.log(searchParamsObject.toString()); // Display the sorted query string // Output a=9&b=2&c=3&d=4 ``` @@ -262,19 +278,20 @@ console.log(searchParamsObject.toString()); // Display the sorted query string / keys(): IterableIterator<string> - Obtains an ES6 iterator that contains the keys of all the key-value pairs. +**System capability**: SystemCapability.Utils.Lang + **Return value** -| Type| Description| +| Type | Description | | -------- | -------- | -| IterableIterator<string> | ES6 iterator that contains the keys of all the key-value pairs.| +| IterableIterator<string> | ES6 iterator that contains the keys of all the key-value pairs. | **Example** ```js -var searchParamsObject = new URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing +var searchParamsObject = new Url.URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing for (var key of searchParamsObject .keys()) { // Output key-value pairs console.log(key); } @@ -287,16 +304,18 @@ values(): IterableIterator<string> Obtains an ES6 iterator that contains the values of all the key-value pairs. +**System capability**: SystemCapability.Utils.Lang + **Return value** -| Type| Description| +| Type | Description | | -------- | -------- | -| IterableIterator<string> | ES6 iterator that contains the values of all the key-value pairs.| +| IterableIterator<string> | ES6 iterator that contains the values of all the key-value pairs. | **Example** ```js -var searchParams = new URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing +var searchParams = new Url.URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing for (var value of searchParams.values()) { console.log(value); } @@ -307,19 +326,20 @@ for (var value of searchParams.values()) { [Symbol.iterator]\(): IterableIterator<[string, string]> - Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively. +**System capability**: SystemCapability.Utils.Lang + **Return value** -| Type| Description| +| Type | Description | | -------- | -------- | -| IterableIterator<[string, string]> | ES6 iterator.| +| IterableIterator<[string, string]> | ES6 iterator. | **Example** ```js -const paramsObject = new URLSearchParams('fod=bay&edg=bap'); +const paramsObject = new Url.URLSearchParams('fod=bay&edg=bap'); for (const [name, value] of paramsObject) { console.log(name, value); } @@ -330,20 +350,21 @@ for (const [name, value] of paramsObject) { toString(): string - Obtains search parameters that are serialized as a string and, if necessary, percent-encodes the characters in the string. +**System capability**: SystemCapability.Utils.Lang + **Return value** -| Type| Description| +| Type | Description | | -------- | -------- | -| string | String of serialized search parameters, which is percent-encoded if necessary.| +| string | String of serialized search parameters, which is percent-encoded if necessary. | **Example** ```js -let url = new URL('https://developer.exampleUrl/?fod=1&bard=2'); -let params = new URLSearchParams(url.search.slice(1)); +let url = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); +let params = new Url.URLSearchParams(url.search.slice(1)); params.append('fod', 3); console.log(params.toString()); ``` @@ -351,9 +372,10 @@ console.log(params.toString()); ## URL - ### Attributes +**System capability**: SystemCapability.Utils.Lang + | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | | hash | string | Yes| Yes| String that contains a harsh mark (#) followed by the fragment identifier of a URL.| @@ -374,31 +396,32 @@ console.log(params.toString()); constructor(url: string, base?: string | URL) - Creates a URL. +**System capability**: SystemCapability.Utils.Lang + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| url | string | Yes| Input object.| -| base | string \| URL | No| Input parameter, which can be any of the following:
- **string**: string
- **URL**: string or object| +| url | string | Yes | Input object. | +| base | string \ |& URL | No | Input parameter, which can be any of the following:
- **string**: string
- **URL**: string or object | **Example** ```js var mm = 'http://username:password@host:8080'; -var a = new URL("/", mm); // Output 'http://username:password@host:8080/'; -var b = new URL(mm); // Output 'http://username:password@host:8080/'; -new URL('path/path1', b); // Output 'http://username:password@host:8080/path/path1'; -var c = new URL('/path/path1', b); // Output 'http://username:password@host:8080/path/path1'; -new URL('/path/path1', c); // Output 'http://username:password@host:8080/path/path1'; -new URL('/path/path1', a); // Output 'http://username:password@host:8080/path/path1'; -new URL('/path/path1', "https://www.exampleUrl/fr-FR/toto"); // Output https://www.exampleUrl/path/path1 -new URL('/path/path1', ''); // Raises a TypeError exception as '' is not a valid URL -new URL('/path/path1'); // Raises a TypeError exception as '/path/path1' is not a valid URL -new URL('http://www.shanxi.com', ); // Output http://www.shanxi.com/ -new URL('http://www.shanxi.com', b); // Output http://www.shanxi.com/ +var a = new Url.URL("/", mm); // Output 'http://username:password@host:8080/'; +var b = new Url.URL(mm); // Output 'http://username:password@host:8080/'; +new Url.URL('path/path1', b); // Output 'http://username:password@host:8080/path/path1'; +var c = new Url.URL('/path/path1', b); // Output 'http://username:password@host:8080/path/path1'; +new Url.URL('/path/path1', c); // Output 'http://username:password@host:8080/path/path1'; +new Url.URL('/path/path1', a); // Output 'http://username:password@host:8080/path/path1'; +new Url.URL('/path/path1', "https://www.exampleUrl/fr-FR/toto"); // Output https://www.exampleUrl/path/path1 +new Url.URL('/path/path1', ''); // Raises a TypeError exception as '' is not a valid URL +new Url.URL('/path/path1'); // Raises a TypeError exception as '/path/path1' is not a valid URL +new Url.URL('http://www.shanxi.com', ); // Output http://www.shanxi.com/ +new Url.URL('http://www.shanxi.com', b); // Output http://www.shanxi.com/ ``` @@ -408,16 +431,18 @@ toString(): string Converts the parsed URL into a string. +**System capability**: SystemCapability.Utils.Lang + **Return value** -| Type| Description| +| Type | Description | | -------- | -------- | -| string | Website address in a serialized string.| +| string | Website address in a serialized string. | **Example** ```js -const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); +const url = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); url.toString() ``` @@ -426,17 +451,18 @@ url.toString() toJSON(): string - Converts the parsed URL into a JSON string. +**System capability**: SystemCapability.Utils.Lang + **Return value** -| Type| Description| +| Type | Description | | -------- | -------- | -| string | Website address in a serialized string.| +| string | Website address in a serialized string. | **Example** ```js -const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); +const url = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); url.toJSON() -``` +``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-util.md b/en/application-dev/reference/apis/js-apis-util.md index ecc46e0c2d4b17d6d6a462c312a7860627b579a2..2ac8daeb3799908d57a5b7a2c5fd456dcfee8f59 100755 --- a/en/application-dev/reference/apis/js-apis-util.md +++ b/en/application-dev/reference/apis/js-apis-util.md @@ -1,11 +1,12 @@ # util -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE** +> > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. -This module provides common utility functions, such as **TextEncoder** and **TextDecoder** for string encoding and decoding, **RationalNumber** for rational number operations, **LruBuffer** for buffer management, **Scope** for range determination, **Base64** for Base64 encoding and decoding, and **types** for checks of built-in object types. +This module provides common utility functions, such as **TextEncoder** and **TextDecoder** for string encoding and decoding, **RationalNumber** for rational number operations, **LruBuffer** for buffer management, **Scope** for range determination, **Base64** for Base64 encoding and decoding, and **Types** for checks of built-in object types. ## Modules to Import @@ -140,7 +141,7 @@ Processes an asynchronous function and returns a promise version. | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| encoding | string | Yes| No| Encoding format.
- Supported formats: utf-8, ibm866, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, iso-8859-7, iso-8859-8, iso-8859-8-i, iso-8859-10, iso-8859-13, iso-8859-14, iso-8859-15, koi8-r, koi8-u, macintosh, windows-874, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, x-mac-cyrilli, gbk, gb18030, big5, euc-jp, iso-2022-jp, shift_jis, euc-kr, utf-16be, utf-16le| +| encoding | string | Yes| No| Encoding format.
- Supported formats: utf-8, ibm866, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, iso-8859-7, iso-8859-8, iso-8859-8-i, iso-8859-10, iso-8859-13, iso-8859-14, iso-8859-15, koi8-r, koi8-u, macintosh, windows-874, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, x-mac-cyrilli, gbk, gb18030, big5, euc-jp, iso-2022-jp, shift_jis, euc-kr, utf-16be, utf-16le| | fatal | boolean | Yes| No| Whether to display fatal errors.| | ignoreBOM | boolean | Yes| No| Whether to ignore the byte order marker (BOM). The default value is **false**, which indicates that the result contains the BOM.| @@ -208,9 +209,6 @@ Decodes the input content. result[4] = 0x62; result[5] = 0x63; console.log("input num:"); - for(var j= 0; j < 6; j++) { - console.log(result[j]); - } var retStr = textDecoder.decode( result , {stream: false}); console.log("retStr = " + retStr); ``` @@ -262,6 +260,7 @@ Encodes the input content. **Example** ```js var textEncoder = new util.TextEncoder(); + var buffer = new ArrayBuffer(20); var result = new Uint8Array(buffer); result = textEncoder.encode("\uD800¥¥"); ``` @@ -361,7 +360,6 @@ Compares this **RationalNumber** object with a given object. | number | Returns **0** if the two objects are equal; returns **1** if the given object is less than this object; return **-1** if the given object is greater than this object.| **Example** - ```js var rationalNumber = new util.RationalNumber(1,2); var rational = rationalNumer.creatRationalFromString("3/4"); @@ -484,7 +482,7 @@ Obtains the denominator of this **RationalNumber** object. ### isZero8+ -isZero​(): boolean +isZero​():boolean Checks whether this **RationalNumber** object is **0**. @@ -524,7 +522,7 @@ Checks whether this **RationalNumber** object is a Not a Number (NaN). ### isFinite8+ -isFinite​(): boolean +isFinite​():boolean Checks whether this **RationalNumber** object represents a finite value. @@ -825,7 +823,7 @@ Obtains the value of the specified key. **Return value** | Type| Description| | -------- | -------- | -| V \| undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.| +| V \| undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.| **Example** ```js @@ -872,7 +870,7 @@ Obtains all values in this buffer, listed from the most to the least recently ac **Return value** | Type| Description| | -------- | -------- | -| V [] | All values in the buffer, listed from the most to the least recently accessed.| +| V [] | All values in the buffer, listed from the most to the least recently accessed.| **Example** ```js @@ -895,7 +893,7 @@ Obtains all keys in this buffer, listed from the most to the least recently acce **Return value** | Type| Description| | -------- | -------- | -| K [] | All keys in the buffer, listed from the most to the least recently accessed.| +| K [] | All keys in the buffer, listed from the most to the least recently accessed.| **Example** ```js @@ -921,7 +919,7 @@ Removes the specified key and its value from this buffer. **Return value** | Type| Description| | -------- | -------- | -| V \| undefind | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown.| +| V \| undefind | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown.| **Example** ```js @@ -1038,7 +1036,7 @@ Obtains a new iterator object that contains all key-value pairs in this object. **Return value** | Type| Description| | -------- | -------- | -| [K, V] | Iterable array.| +| [K, V] | Iterable array.| **Example** ```js @@ -1059,7 +1057,7 @@ Obtains a two-dimensional array in key-value pairs. **Return value** | Type| Description| | -------- | -------- | -| [K, V] | Two-dimensional array in key-value pairs.| +| [K, V] | Two-dimensional array in key-value pairs.| **Example** ```js @@ -1092,6 +1090,8 @@ Example ```js class Temperature{ constructor(value){ + // If TS is used for development, add the following code: + // private readonly _temp: Temperature; this._temp = value; } comapreTo(value){ @@ -1183,7 +1183,7 @@ Obtains the intersection of this **Scope** and the given **Scope**. ### intersect8+ -intersect(lowerObj: ScopeType,upperObj: ScopeType): Scope +intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope Obtains the intersection of this **Scope** and the given lower and upper limits. @@ -1276,6 +1276,7 @@ Obtains the union set of this **Scope** and the given lower and upper limits. | [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits.| **Example** + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); @@ -1288,7 +1289,7 @@ Obtains the union set of this **Scope** and the given lower and upper limits. ### expand8+ -expand(range:Scope):Scope +expand(range: Scope): Scope Obtains the union set of this **Scope** and the given **Scope**. @@ -1510,7 +1511,7 @@ Decodes the input content. **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| src | Uint8Array \| string | Yes| Uint8Array or string to decode.| +| src | Uint8Array \| string | Yes| Uint8Array or string to decode.| **Return value** | Type| Description| @@ -1595,7 +1596,7 @@ Decodes the input content asynchronously. **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| src | Uint8Array \| string | Yes| Uint8Array or string to decode asynchronously.| +| src | Uint8Array \| string | Yes| Uint8Array or string to decode asynchronously.| **Return value** | Type| Description| @@ -1622,7 +1623,7 @@ Decodes the input content asynchronously. constructor() -A constructor used to create a **types** object. +A constructor used to create a **Types** object. **System capability**: SystemCapability.Utils.Lang diff --git a/en/application-dev/reference/apis/js-apis-vector.md b/en/application-dev/reference/apis/js-apis-vector.md index 9288f871d45e7a08a542221ddf561e6a4e4fe81b..5dd8e49bb0c2467b2885784b9c1281f61e46a003 100644 --- a/en/application-dev/reference/apis/js-apis-vector.md +++ b/en/application-dev/reference/apis/js-apis-vector.md @@ -319,10 +319,10 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.replaceAllElements((value, index) => { +vector.replaceAllElements((value: number, index: number) => { return value = 2 * value; }); -vector.replaceAllElements((value, index) => { +vector.replaceAllElements((value: number, index: number) => { return value = value - 2; }); ``` @@ -394,8 +394,8 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.sort((a, b) => a - b); -vector.sort((a, b) => b - a); +vector.sort((a: number, b: number) => a - b); +vector.sort((a: number, b: number) => b - a); vector.sort(); ``` @@ -620,7 +620,7 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -let result = vector.toSting(); +let result = vector.toString(); ``` ### copyToArray diff --git a/en/application-dev/reference/apis/js-apis-window.md b/en/application-dev/reference/apis/js-apis-window.md index 6c4890a972ef5426b2a4e6a57f41d426412b3736..b3db77cfbac7a3c195a6f2d88cf88977332457ca 100644 --- a/en/application-dev/reference/apis/js-apis-window.md +++ b/en/application-dev/reference/apis/js-apis-window.md @@ -1,8 +1,13 @@ # Window -The **Window** module provides basic capabilities for managing windows, including creating and destroying windows and setting serial port attributes. +The `Window` module provides basic window management capabilities, such as creating and destroying the current window, setting properties for the current window, and managing and scheduling windows. -> **NOTE**
+This module provides the following common window-related functions: + +- [Window](#window): the current window instance, which is the basic unit managed by the window manager. +- [WindowStage](#windowstage9): window manager that manages windows. + +> **NOTE** > > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > @@ -20,37 +25,38 @@ Enumerates the window types. **System capability**: SystemCapability.WindowManager.WindowManager.Core -| Name | Default Value | Description | +| Name | Value| Description | | ----------------- | ------ | ------------------ | -| TYPE_APP | 0 | Application subwindow. | +| TYPE_APP | 0 | Application subwindow.| | TYPE_SYSTEM_ALERT | 1 | System alert window.| + ## AvoidAreaType7+ Enumerates the types of the area where the window cannot be displayed. **System capability**: SystemCapability.WindowManager.WindowManager.Core -| Name | Default Value | Description | -| ----------- | ------ | ------------------ | -| TYPE_SYSTEM | 0 | Default area of the system.| -| TYPE_CUTOUT | 1 | Notch. | +| Name | Value | Description | +| ----------- | ---- | ------------------ | +| TYPE_SYSTEM | 0 | Default area of the system.| +| TYPE_CUTOUT | 1 | Notch. | ## WindowMode7+ -Enumerates the window modes of an application. +Enumerates the window modes. This is a system API and cannot be called by third-party applications. **System capability**: SystemCapability.WindowManager.WindowManager.Core -| Name | Default Value | Description | -| ---------- | ------ | ----------------------------- | -| UNDEFINED | 1 | The window mode is not defined by the application. | -| FULLSCREEN | 2 | The application is displayed in full screen. | -| PRIMARY | 3 | The application is displayed in the primary window in split-screen mode. | -| SECONDARY | 4 | The application is displayed in the secondary window in split-screen mode. | -| FLOATING | 5 | The application is displayed in a floating window.| +| Name | Value | Description | +| ---------- | ---- | ----------------------------- | +| UNDEFINED | 1 | The window mode is not defined by the application. | +| FULLSCREEN | 2 | The application is displayed in full screen. | +| PRIMARY | 3 | The application is displayed in the primary window in split-screen mode. | +| SECONDARY | 4 | The application is displayed in the secondary window in split-screen mode. | +| FLOATING | 5 | The application is displayed in a floating window.| ## SystemBarProperties @@ -60,10 +66,10 @@ Describes the properties of the status bar and navigation bar. | Name | Type| Readable| Writable| Description | | -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ | -| statusBarColor | string | Yes | Yes | Background color of the status bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, **\#00FF00** or **\#FF00FF00**.| +| statusBarColor | string | Yes | Yes | Background color of the status bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.| | isStatusBarLightIcon7+ | boolean | No | Yes | Whether any icon on the status bar is highlighted. | | statusBarContentColor8+ | string | No | Yes | Color of the text on the status bar. | -| navigationBarColor | string | Yes | Yes | Background color of the navigation bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, **\#00FF00** or **\#FF00FF00**.| +| navigationBarColor | string | Yes | Yes | Background color of the navigation bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.| | isNavigationBarLightIcon7+ | boolean | No | No | Whether any icon on the navigation bar is highlighted. | | navigationBarContentColor8+ | string | No | Yes | Color of the text on the navigation bar. | @@ -80,7 +86,7 @@ This is a system API and cannot be called by third-party applications. | type | [WindowType](#windowtype) | Yes | Yes | Type of the system bar whose properties are changed. Only the status bar and navigation bar are supported.| | isEnable | boolean | Yes | Yes | Whether the system bar is displayed. | | region | [Rect](#rect) | Yes | Yes | Current position and size of the system bar. | -| backgroundColor | string | Yes | Yes | Background color of the system bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, **\#00FF00** or **\#FF00FF00**.| +| backgroundColor | string | Yes | Yes | Background color of the system bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.| | contentColor | string | Yes | Yes | Color of the text on the system bar. | ## SystemBarTintState8+ @@ -91,14 +97,14 @@ This is a system API and cannot be called by third-party applications. **System capability**: SystemCapability.WindowManager.WindowManager.Core -| Name | Type | Readable| Writable| Description | -| ---------- | --------------------------------------------------- | ---- | ---- | -------------------------- | -| displayId | number | Yes | No | ID of the current physical screen. | -| regionTint | Array<[SystemBarRegionTint](#systembarregiontint8)> | Yes | Yes | All system bar information changed.| +| Name | Type | Readable| Writable| Description | +| ---------- | --------------------------------------------------- | ---- | ---- | ---------------------------- | +| displayId | number | Yes | No | ID of the current physical screen. | +| regionTint | Array<[SystemBarRegionTint](#systembarregiontint8)> | Yes | Yes | All system bar information that has been changed.| ## Rect7+ - Describes the rectangular area of the window. +Describes the rectangular area of the window. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -143,16 +149,16 @@ Describes the window properties. | ------------------------------- | ------------------------- | ---- | ---- | -------------------------------------------- | | windowRect7+ | [Rect](#rect) | Yes | Yes | Window size. | | type7+ | [WindowType](#windowtype) | Yes | Yes | Window type. | -| isFullScreen | boolean | Yes | Yes | Whether the window is displayed in full screen mode. The default value is **false**. | -| isLayoutFullScreen7+ | boolean | Yes | Yes | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is **false**. | -| focusable7+ | boolean | Yes | No | Whether the window can gain focus. The default value is **true**. | -| touchable7+ | boolean | Yes | No | Whether the window is touchable. The default value is **true**. | -| brightness | number | Yes | Yes | Screen brightness. The value ranges from 0 to 1. The value **1** indicates the maximum brightness. | -| dimBehindValue(deprecated) | number | Yes | Yes | Dimness of the window that is not on top. The value ranges from 0 to 1. The value **1** indicates the maximum dimness.
This attribute is supported since API version 7 and deprecated since API version 9.
| -| isKeepScreenOn | boolean | Yes | Yes | Whether the screen is always on. The default value is **false**. | -| isPrivacyMode7+ | boolean | Yes | Yes | Whether the window is in privacy mode. The default value is **false**. | -| isRoundCorner7+ | boolean | Yes | Yes | Whether the window has rounded corners. The default value is **false**. | -| isTransparent7+ | boolean | Yes | Yes | Whether the window is transparent. The default value is **false**. | +| isFullScreen | boolean | Yes | Yes | Whether the window is displayed in full screen mode. The default value is `false`. | +| isLayoutFullScreen7+ | boolean | Yes | Yes | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is `false`. | +| focusable7+ | boolean | Yes | No | Whether the window can gain focus. The default value is `true`. | +| touchable7+ | boolean | Yes | No | Whether the window is touchable. The default value is `true`. | +| brightness | number | Yes | Yes | Screen brightness. The value ranges from 0 to 1. The value `1` indicates the maximum brightness. | +| dimBehindValue(deprecated) | number | Yes | Yes | Dimness of the window that is not on top. The value ranges from 0 to 1. The value `1` indicates the maximum dimness.
This attribute is supported since API version 7 and deprecated since API version 9.
| +| isKeepScreenOn | boolean | Yes | Yes | Whether the screen is always on. The default value is `false`. | +| isPrivacyMode7+ | boolean | Yes | Yes | Whether the window is in privacy mode. The default value is `false`. | +| isRoundCorner7+ | boolean | Yes | Yes | Whether the window has rounded corners. The default value is `false`. | +| isTransparent7+ | boolean | Yes | Yes | Whether the window is transparent. The default value is `false`. | ## ColorSpace8+ @@ -171,32 +177,28 @@ create(id: string, type: WindowType, callback: AsyncCallback<Window>): voi Creates a subwindow. This API uses an asynchronous callback to return the result. -This API is deprecated since API version 8. You are advised to use [window.create8+](#windowcreate8) instead. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------------------------------------- | ---- | -------------------------- | -| id | string | Yes | Window ID. | -| type | [WindowType](#windowtype) | Yes | Window type. | +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | ------------------------------------ | +| id | string | Yes | Window ID. | +| type | [WindowType](#windowtype) | Yes | Window type. | | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created.| **Example** - ```js - var windowClass = null; - window.create("first", window.WindowType.TYPE_APP, (err, data) => { - if (err.code) { - console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('SubWindow created. Data: ' + JSON.stringify(data)) - windowClass.resetSize(500, 1000); - }); - ``` +```js +var windowClass = null; + let promise = window.create("first", window.WindowType.TYPE_APP); + promise.then((data)=> { + windowClass = data; + console.info('SubWindow created. Data: ' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); + }); +``` ## window.create7+ @@ -204,8 +206,6 @@ create(id: string, type: WindowType): Promise<Window> Creates a subwindow. This API uses a promise to return the result. -This API is deprecated since API version 8. You are advised to use [window.create8+](#windowcreate8) instead. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** @@ -217,22 +217,22 @@ This API is deprecated since API version 8. You are advised to use [window.creat **Return value** -| Type | Description | -| -------------------------------- | ------------------------------------------------- | +| Type | Description | +| -------------------------------- | --------------------------------------- | | Promise<[Window](#window)> | Promise used to return the subwindow created.| **Example** - ```js - var windowClass = null; - let promise = window.create("first", window.WindowType.TYPE_APP); - promise.then((data)=> { - windowClass = data; - console.info('SubWindow created. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +var windowClass = null; +let promise = window.create("first", window.WindowType.TYPE_APP); +promise.then((data)=> { + windowClass = data; + console.info('SubWindow created. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); +}); +``` ## window.create8+ @@ -246,25 +246,25 @@ Creates a subwindow (in API version 8) or a system window (from API version 9). | Name | Type | Mandatory| Description | | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | -| ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [ServiceExtensionContext](js-apis-service-extension-context.md). | +| ctx | Context | Yes | Current application context.
For the definition of `Context` of API version 8, see [Context](js-apis-Context.md).
For the definition of `Context` of API version 9, see [ServiceExtensionContext](js-apis-service-extension-context.md).| | id | string | Yes | Window ID. | | type | [WindowType](#windowtype) | Yes | Window type. | -| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the window created. | +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the window created. | **Example** - ```js - var windowClass = null; - window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { - if (err.code) { - console.error('Failed to create the Window. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Window created. Data: ' + JSON.stringify(data)) - windowClass.resetSize(500, 1000); - }); - ``` +```js +var windowClass = null; + window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { + if (err.code) { + console.error('Failed to create the Window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Window created. Data: ' + JSON.stringify(data)); + windowClass.resetSize(500, 1000); +}); +``` ## window.create8+ @@ -278,28 +278,28 @@ Creates a subwindow (in API version 8) or a system window (from API version 9). | Name| Type | Mandatory| Description | | ------ | ------------------------- | ---- | ------------------------------------------------------------ | -| ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [ServiceExtensionContext](js-apis-service-extension-context.md). | +| ctx | Context | Yes | Current application context.
For the definition of `Context` of API version 8, see [Context](js-apis-Context.md).
For the definition of `Context` of API version 9, see [ServiceExtensionContext](js-apis-service-extension-context.md).| | id | string | Yes | Window ID. | | type | [WindowType](#windowtype) | Yes | Window type. | **Return value** -| Type | Description | -| -------------------------------- | ----------------------------------------------- | +| Type | Description | +| -------------------------------- | --------------------------------------- | | Promise<[Window](#window)> | Promise used to return the window created.| **Example** - ```js - var windowClass = null; - let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT); - promise.then((data)=> { - windowClass = data; - console.info('Window created. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to create the Window. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +var windowClass = null; +let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT); +promise.then((data)=> { + windowClass = data; + console.info('Window created. Data:' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to create the Window. Cause:' + JSON.stringify(err)); +}); +``` ## window.find7+ @@ -311,24 +311,24 @@ Finds a window based on the ID. This API uses an asynchronous callback to return **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------------------------------------- | ---- | ---------------------------- | -| id | string | Yes | Window ID. | +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | ------------------------------------ | +| id | string | Yes | Window ID. | | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the window found.| **Example** - ```js - var windowClass = null; - window.find("alertWindow", (err, data) => { - if (err.code) { - console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('window found. Data: ' + JSON.stringify(data)) - }); - ``` +```js +var windowClass = null; + window.find("alertWindow", (err, data) => { + if (err.code) { + console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('window found. Data: ' + JSON.stringify(data)); +}); +``` ## window.find7+ @@ -346,22 +346,22 @@ Finds a window based on the ID. This API uses a promise to return the result. **Return value** -| Type | Description | -| -------------------------------- | ----------------------------------------------- | +| Type | Description | +| -------------------------------- | ------------------------------------- | | Promise<[Window](#window)> | Promise used to return the window found.| **Example** - ```js - var windowClass = null; - let promise = window.find("alertWindow"); - promise.then((data)=> { - windowClass = data; - console.info('window found. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +var windowClass = null; +let promise = window.find("alertWindow"); +promise.then((data)=> { + windowClass = data; + console.info('window found. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); +}); +``` ## window.getTopWindow @@ -369,29 +369,27 @@ getTopWindow(callback: AsyncCallback<Window>): void Obtains the top window of the current application. This API uses an asynchronous callback to return the result. -This API is deprecated since API version 8. You are advised to use [window.getTopWindow8+](#windowgettopwindow8) instead. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------------------------------------- | ---- | -------------------------------------- | +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | -------------------------------------------- | | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained.| **Example** - ```js - var windowClass = null; - window.getTopWindow((err, data) => { - if (err.code) { - console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); - }); - ``` +```js +var windowClass = null; +window.getTopWindow((err, data) => { + if (err.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); +}); +``` ## window.getTopWindow @@ -399,28 +397,26 @@ getTopWindow(): Promise<Window> Obtains the top window of the current application. This API uses a promise to return the result. -This API is deprecated since API version 8. You are advised to use [window.getTopWindow8+](#windowgettopwindow8) instead. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Return value** -| Type | Description | -| -------------------------------- | --------------------------------------------------------- | +| Type | Description | +| -------------------------------- | ----------------------------------------------- | | Promise<[Window](#window)> | Promise used to return the top window obtained.| **Example** - ```js - var windowClass = null; - let promise = window.getTopWindow(); - promise.then((data)=> { - windowClass = data; - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - }) - ``` +```js +var windowClass = null; +let promise = window.getTopWindow(); +promise.then((data)=> { + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); +}) +``` ## window.getTopWindow8+ @@ -434,22 +430,22 @@ Obtains the top window of the current application. This API uses an asynchronous | Name | Type | Mandatory| Description | | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | -| ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [AbilityContext](js-apis-ability-context.md). | -| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained. | +| ctx | Context | Yes | Current application context.
For the definition of `Context` of API version 8, see [Context](js-apis-Context.md).
For the definition of `Context` of API version 9, see [AbilityContext](js-apis-ability-context.md).| +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained. | **Example** - ```js - var windowClass = null; - window.getTopWindow(this.context, (err, data) => { - if (err.code) { - console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); - }); - ``` +```js +var windowClass = null; +window.getTopWindow(this.context, (err, data) => { + if (err.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); +}); +``` ## window.getTopWindow8+ @@ -463,26 +459,26 @@ Obtains the top window of the current application. This API uses a promise to re | Name| Type | Mandatory| Description | | ------ | ------- | ---- | ------------------------------------------------------------ | -| ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [AbilityContext](js-apis-ability-context.md). | +| ctx | Context | Yes | Current application context.
For the definition of `Context` of API version 8, see [Context](js-apis-Context.md).
For the definition of `Context` of API version 9, see [AbilityContext](js-apis-ability-context.md).| **Return value** -| Type | Description | -| -------------------------------- | --------------------------------------------------------- | +| Type | Description | +| -------------------------------- | ----------------------------------------------- | | Promise<[Window](#window)> | Promise used to return the top window obtained.| **Example** - ```js - var windowClass = null; - let promise = window.getTopWindow(this.context); - promise.then((data)=> { - windowClass = data; - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - }) - ``` +```js +var windowClass = null; +let promise = window.getTopWindow(this.context); +promise.then((data)=> { + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); +}) +``` ## on('systemBarTintChange')8+ @@ -498,17 +494,16 @@ This is a system API and cannot be called by third-party applications. | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of event to listen for. The value is fixed at **systemBarTintChange**, indicating the property change event of the status bar and navigation bar.| -| callback | Callback<[SystemBarTintState](#systembartintstate)> | Yes | Callback used to return the information. | +| type | string | Yes | Type of event to listen for. The value is fixed at `systemBarTintChange`, indicating the property change event of the status bar and navigation bar.| +| callback | Callback<[SystemBarTintState](#systembartintstate)> | Yes | Callback used to return the properties of the status bar and navigation bar. | **Example** - ```js - var type = 'systemBarTintChange'; - windowClass.on(type, (data) => { - console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data)); - }); - ``` +```js +window.on('systemBarTintChange', (data) => { + console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data)); +}); +``` ## off('systemBarTintChange')8+ @@ -524,19 +519,20 @@ This is a system API and cannot be called by third-party applications. | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of event to listen for. The value is fixed at **systemBarTintChange**, indicating the property change event of the status bar and navigation bar.| -| callback | Callback<[SystemBarTintState](#systembartintstate)> | No | Callback used to return the information. | +| type | string | Yes | Type of event to listen for. The value is fixed at `systemBarTintChange`, indicating the property change event of the status bar and navigation bar.| +| callback | Callback<[SystemBarTintState](#systembartintstate)> | No | Callback used to return the properties of the status bar and navigation bar. | **Example** - ```js - var type = 'systemBarTintChange'; - windowClass.off(type); - ``` +```js +window.off('systemBarTintChange'); +``` ## Window -In the following API examples, you must use [getTopWindow()](#windowgettopwindow), [create()](#windowcreate7), or [find()](#windowfind7) to obtain a **Window** instance and then call a method in this instance. +Represents the current window instance, which is the basic unit managed by the window manager. + +In the following API examples, you must use [getTopWindow()](#windowgettopwindow), [create()](#windowcreate7), or [find()](#windowfind7) to obtain a `Window` instance and then call a method in this instance. ### hide7+ @@ -552,19 +548,19 @@ This is a system API and cannot be called by third-party applications. | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ---------- | -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** - ```js - windowClass.hide((err, data) => { - if (err.code) { - console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); - return; - } - console.info('window hidden. data: ' + JSON.stringify(data)) - }) - ``` +```js +windowClass.hide((err, data) => { + if (err.code) { + console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); + return; + } + console.info('window hidden. data: ' + JSON.stringify(data)); +}) +``` ### hide7+ @@ -578,20 +574,20 @@ This is a system API and cannot be called by third-party applications. **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - let promise = windowClass.hide(); - promise.then((data)=> { - console.info('window hidden. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); - }) - ``` +```js +let promise = windowClass.hide(); +promise.then((data)=> { + console.info('window hidden. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); +}) +``` ### show7+ @@ -605,19 +601,19 @@ Shows this window. This API uses an asynchronous callback to return the result. | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ---------- | -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** - ```js - windowClass.show((err, data) => { - if (err.code) { - console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)) - }) - ``` +```js +windowClass.show((err, data) => { + if (err.code) { + console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); +}) +``` ### show7+ @@ -629,20 +625,20 @@ Shows this window. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - let promise = windowClass.show(); - promise.then((data)=> { - console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); - }) - ``` +```js +let promise = windowClass.show(); +promise.then((data)=> { + console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); +}) +``` ### destroy7+ @@ -656,19 +652,19 @@ Destroys this window. This API uses an asynchronous callback to return the resul | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ---------- | -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** - ```js - windowClass.destroy((err, data) => { - if (err.code) { - console.error('Failed to destroy the window. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)) - }) - ``` +```js +windowClass.destroy((err, data) => { + if (err.code) { + console.error('Failed to destroy the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)); +}) +``` ### destroy7+ @@ -680,20 +676,20 @@ Destroys this window. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - let promise = windowClass.destroy(); - promise.then((data)=> { - console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); - }) - ``` +```js +let promise = windowClass.destroy(); +promise.then((data)=> { + console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); +}) +``` ### moveTo7+ @@ -709,20 +705,20 @@ Moves this window. This API uses an asynchronous callback to return the result. | -------- | ------------------------- | ---- | ------------------------------------------------- | | x | number | Yes | Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right.| | y | number | Yes | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** - ```js - windowClass.moveTo(300, 300, (err, data)=>{ - if (err.code) { - console.error('Failed to move the window. Cause:' + JSON.stringify(err)); - return; - } - console.info('Window moved. Data: ' + JSON.stringify(data)) - - }); - ``` +```js +windowClass.moveTo(300, 300, (err, data)=>{ + if (err.code) { + console.error('Failed to move the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Window moved. Data: ' + JSON.stringify(data)); + +}); +``` ### moveTo7+ @@ -741,20 +737,20 @@ Moves this window. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - let promise = windowClass.moveTo(300, 300); - promise.then((data)=> { - console.info('Window moved. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); - }) - ``` +```js +let promise = windowClass.moveTo(300, 300); +promise.then((data)=> { + console.info('Window moved. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); +}) +``` ### resetSize7+ @@ -770,19 +766,19 @@ Changes the size of this window. This API uses an asynchronous callback to retur | -------- | ------------------------- | ---- | -------------------------- | | width | number | Yes | New width of the window, in px.| | height | number | Yes | New height of the window, in px.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** - ```js - windowClass.resetSize(500, 1000, (err, data) => { - if (err.code) { - console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); - return; - } - console.info('Window size changed. Data: ' + JSON.stringify(data)) - }); - ``` +```js +windowClass.resetSize(500, 1000, (err, data) => { + if (err.code) { + console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); + return; + } + console.info('Window size changed. Data: ' + JSON.stringify(data)); +}); +``` ### resetSize7+ @@ -801,20 +797,20 @@ Changes the size of this window. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - let promise = windowClass.resetSize(500, 1000); - promise.then((data)=> { - console.info('Window size changed. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to change the window size. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +let promise = windowClass.resetSize(500, 1000); +promise.then((data)=> { + console.info('Window size changed. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to change the window size. Cause: ' + JSON.stringify(err)); +}); +``` ### setWindowType7+ @@ -831,20 +827,20 @@ This is a system API and cannot be called by third-party applications. | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ---------- | | type | [WindowType](#windowtype) | Yes | Window type.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** - ```js - var type = window.TYPE_APP; - windowClass.setWindowType(type, (err, data) => { - if (err.code) { - console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)) - }); - ``` +```js +var type = window.WindowType.TYPE_APP; +windowClass.setWindowType(type, (err, data) => { + if (err.code) { + console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)); +}); +``` ### setWindowType7+ @@ -864,21 +860,21 @@ This is a system API and cannot be called by third-party applications. **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - var type = window.TYPE_APP; - let promise = windowClass.setWindowType(type); - promise.then((data)=> { - console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +var type = window.WindowType.TYPE_APP; +let promise = windowClass.setWindowType(type); +promise.then((data)=> { + console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); +}); +``` ### getProperties @@ -890,21 +886,21 @@ Obtains the properties of this window. This API uses an asynchronous callback to **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------------------------------- | ---- | ------------------ | +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------------------------- | ---- | ---------------------------- | | callback | AsyncCallback<[WindowProperties](#windowproperties)> | Yes | Callback used to return the window properties.| **Example** - ```js - windowClass.getProperties((err, data) => { - if (err.code) { - console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)); - }); - ``` +```js +windowClass.getProperties((err, data) => { + if (err.code) { + console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)); +}); +``` ### getProperties @@ -916,20 +912,20 @@ Obtains the properties of this window. This API uses a promise to return the res **Return value** -| Type | Description | -| ---------------------------------------------------- | ------------------------------------- | +| Type | Description | +| ---------------------------------------------------- | ------------------------------- | | Promise<[WindowProperties](#windowproperties)> | Promise used to return the window properties.| **Example** - ```js - let promise = windowClass.getProperties(); - promise.then((data)=> { - console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +let promise = windowClass.getProperties(); +promise.then((data)=> { + console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); +}); +``` ### getAvoidArea7+ @@ -943,21 +939,21 @@ Obtains the area where this window cannot be displayed, for example, the system | Name | Type | Mandatory| Description | | -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.| -| callback | AsyncCallback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the area. | +| type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. `TYPE_SYSTEM` indicates the default area of the system. `TYPE_CUTOUT` indicates the notch.| +| callback | AsyncCallback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the area. | **Example** - ```js - var type = window.AvoidAreaType.TYPE_SYSTEM; - windowClass.getAvoidArea(type, (err, data) => { - if (err.code) { - console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); - }); - ``` +```js +var type = window.AvoidAreaType.TYPE_SYSTEM; +windowClass.getAvoidArea(type, (err, data) => { + if (err.code) { + console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); +}); +``` ### getAvoidArea7+ @@ -971,24 +967,24 @@ Obtains the area where this window cannot be displayed, for example, the system | Name| Type | Mandatory| Description | | ------ | ------------------------------- | ---- | ------------------------------------------------------------ | -| type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.| +| type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. `TYPE_SYSTEM` indicates the default area of the system. `TYPE_CUTOUT` indicates the notch.| **Return value** -| Type | Description | -| -------------------------------------- | --------------------------------------------- | +| Type | Description | +| -------------------------------------- | ----------------------------------- | | Promise<[AvoidArea](#avoidarea)> | Promise used to return the area.| **Example** - ```js - let promise = windowClass.getAvoidArea(); - promise.then((data)=> { - console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); - }); - ``` +```js +let promise = windowClass.getAvoidArea(); +promise.then((data)=> { + console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); +}); +``` ### setFullScreen @@ -1003,20 +999,20 @@ Sets whether to enable the full-screen mode for this window. This API uses an as | Name | Type | Mandatory| Description | | ------------ | ------------------------- | ---- | ---------------------------------------------- | | isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** - ```js - var isFullScreen = true; - windowClass.setFullScreen(isFullScreen, (err, data) => { - if (err.code) { - console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)) - }); - ``` +```js +var isFullScreen = true; +windowClass.setFullScreen(isFullScreen, (err, data) => { + if (err.code) { + console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); +}); +``` ### setFullScreen @@ -1034,21 +1030,21 @@ Sets whether to enable the full-screen mode for this window. This API uses a pro **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - var isFullScreen = true; - let promise = windowClass.setFullScreen(isFullScreen); - promise.then((data)=> { - console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +var isFullScreen = true; +let promise = windowClass.setFullScreen(isFullScreen); +promise.then((data)=> { + console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); +}); +``` ### setLayoutFullScreen7+ @@ -1063,20 +1059,20 @@ Sets whether to enable the full-screen mode for the window layout. This API uses | Name | Type | Mandatory| Description | | ------------------ | ------------------------- | ---- | ------------------------------------------------------------ | | isLayoutFullScreen | boolean | Yes | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** - ```js - var isLayoutFullScreen= true; - windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { - if (err.code) { - console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)) - }); - ``` +```js +var isLayoutFullScreen= true; +windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { + if (err.code) { + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)); +}); +``` ### setLayoutFullScreen7+ @@ -1094,21 +1090,21 @@ Sets whether to enable the full-screen mode for the window layout. This API uses **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - var isLayoutFullScreen = true; - let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen); - promise.then((data)=> { - console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); - }); - ``` +```js +var isLayoutFullScreen = true; +let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen); +promise.then((data)=> { + console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); +}); +``` ### setSystemBarEnable7+ @@ -1122,21 +1118,21 @@ Sets whether to display the status bar and navigation bar in this window. This A | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | -| names | Array | Yes | Whether to display the status bar and navigation bar. For example, to display the status bar and navigation bar, set this parameter to **["status", "navigation"]**. By default, they are not displayed.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| names | Array | Yes | Whether to display the status bar and navigation bar.
For example, to display the status bar and navigation bar, set this parameter to `["status", "navigation"]`. By default, they are not displayed.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** - ```js - var names = ["status", "navigation"]; - windowClass.setSystemBarEnable(names, (err, data) => { - if (err.code) { - console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)) - }); - ``` +```js +var names = ["status", "navigation"]; +windowClass.setSystemBarEnable(names, (err, data) => { + if (err.code) { + console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)); +}); +``` ### setSystemBarEnable7+ @@ -1150,25 +1146,25 @@ Sets whether to display the status bar and navigation bar in this window. This A | Name| Type | Mandatory| Description | | ------ | ----- | ---- | ------------------------------------------------------------ | -| names | Array | Yes | Whether to display the status bar and navigation bar. For example, to display the status bar and navigation bar, set this parameter to **["status", "navigation"]**. By default, they are not displayed.| +| names | Array | Yes | Whether to display the status bar and navigation bar.
For example, to display the status bar and navigation bar, set this parameter to `["status", "navigation"]`. By default, they are not displayed.| **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - var names = ["status", "navigation"]; - let promise = windowClass.setSystemBarEnable(names); - promise.then((data)=> { - console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); - }); - ``` +```js +var names = ["status", "navigation"]; +let promise = windowClass.setSystemBarEnable(names); +promise.then((data)=> { + console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); +}); +``` ### setSystemBarProperties @@ -1180,32 +1176,32 @@ Sets the properties of the status bar and navigation bar in this window. This AP **Parameters** -| Name | Type | Mandatory| Description | -| ------------------- | ------------------------------------------- | ---- | -------------------- | +| Name | Type | Mandatory| Description | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | | SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | - -**Example** - - ```js - var SystemBarProperties={ - statusBarColor: '#ff00ff', - navigationBarColor: '#00ff00', - // The following properties are supported since API version 7. - isStatusBarLightIcon: true, - isNavigationBarLightIcon:false, - // The following properties are supported since API version 8. - statusBarContentColor:'#ffffff', - navigationBarContentColor:'#00ffff' - }; - windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => { - if (err.code) { - console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)) - }); - ``` +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example** + +```js +var SystemBarProperties={ + statusBarColor: '#ff00ff', + navigationBarColor: '#00ff00', + // The following properties are supported since API version 7. + isStatusBarLightIcon: true, + isNavigationBarLightIcon:false, + // The following properties are supported since API version 8. + statusBarContentColor:'#ffffff', + navigationBarContentColor:'#00ffff' +}; +windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => { + if (err.code) { + console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)); +}); +``` ### setSystemBarProperties @@ -1217,42 +1213,42 @@ Sets the properties of the status bar and navigation bar in this window. This AP **Parameters** -| Name | Type | Mandatory| Description | -| ------------------- | ------------------------------------------- | ---- | -------------------- | +| Name | Type | Mandatory| Description | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | | SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.| **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| - -**Example** - - ```js - var SystemBarProperties={ - statusBarColor: '#ff00ff', - navigationBarColor: '#00ff00', - // The following properties are supported since API version 7. - isStatusBarLightIcon: true, - isNavigationBarLightIcon:false, - // The following properties are supported since API version 8. - statusBarContentColor:'#ffffff', - navigationBarContentColor:'#00ffff' - }; - let promise = windowClass.setSystemBarProperties(SystemBarProperties); - promise.then((data)=> { - console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); - }); - ``` +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| + +**Example** + +```js +var SystemBarProperties={ + statusBarColor: '#ff00ff', + navigationBarColor: '#00ff00', + // The following properties are supported since API version 7. + isStatusBarLightIcon: true, + isNavigationBarLightIcon:false, + // The following properties are supported since API version 8. + statusBarContentColor:'#ffffff', + navigationBarContentColor:'#00ffff' +}; +let promise = windowClass.setSystemBarProperties(SystemBarProperties); +promise.then((data)=> { + console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); +}); +``` ### loadContent7+ loadContent(path: string, callback: AsyncCallback<void>): void -Loads content to this window. This API uses an asynchronous callback to return the result. +Loads content from a page to this window. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -1261,25 +1257,25 @@ Loads content to this window. This API uses an asynchronous callback to return t | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | -------------------- | | path | string | Yes | Path of the page from which the content will be loaded.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** - ```js - windowClass.loadContent("pages/page2/page2", (err, data) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) - }); - ``` +```js +windowClass.loadContent("pages/page2/page2", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); +}); +``` ### loadContent7+ loadContent(path: string): Promise<void> -Loads content to this window. This API uses a promise to return the result. +Loads content from a page to this window. This API uses a promise to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -1291,21 +1287,20 @@ Loads content to this window. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - let promise = windowClass.loadContent("pages/page2/page2"); - promise.then((data)=> { - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); - }); - ``` - +```js +let promise = windowClass.loadContent("pages/page2/page2"); +promise.then((data)=> { + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); +}); +``` ### isShowing7+ isShowing(callback: AsyncCallback<boolean>): void @@ -1316,21 +1311,21 @@ Checks whether this window is displayed. This API uses an asynchronous callback **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------------- | ---- | -------------------------------- | -| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the window is displayed.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value `true` means that this window is displayed, and `false` means the opposite.| **Example** - ```js - windowClass.isShowing((err, data) => { - if (err.code) { - console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)) - }); - ``` +```js +windowClass.isShowing((err, data) => { + if (err.code) { + console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); +}); +``` ### isShowing7+ @@ -1342,20 +1337,20 @@ Checks whether this window is displayed. This API uses a promise to return the r **Return value** -| Type | Description | -| ---------------------- | ----------------------------------------------------- | -| Promise<boolean> | Promise used to return whether the window is displayed.| +| Type | Description | +| ---------------------- | ------------------------------------------------------------ | +| Promise<boolean> | Promise used to return the result. The value `true` means that this window is displayed, and `false` means the opposite.| **Example** - ```js - let promise = windowClass.isShowing(); - promise.then((data)=> { - console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +let promise = windowClass.isShowing(); +promise.then((data)=> { + console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err)); +}); +``` ### on('windowSizeChange')7+ @@ -1367,19 +1362,18 @@ Enables listening for window size changes. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------------- | ---- | -------------------------------------------------------- | -| type | string | Yes | Type of event to listen for. The value is fixed at **windowSizeChange**, indicating the window size change event.| -| callback | Callback<[Size](#size)> | Yes | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------------ | ---- | -------------------------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at `windowSizeChange`, indicating the window size change event.| +| callback | Callback<[Size](#size7)> | Yes | Callback used to return the window size. | **Example** - ```js - var type = 'windowSizeChange'; - windowClass.on(type, (data) => { - console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); - }); - ``` +```js +windowClass.on('windowSizeChange', (data) => { + console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); +}); +``` ### off('windowSizeChange')7+ @@ -1393,15 +1387,14 @@ Disables listening for window size changes. | Name | Type | Mandatory| Description | | -------- | ----------------------------- | ---- | -------------------------------------------------------- | -| type | string | Yes | Type of event to listen for. The value is fixed at **windowSizeChange**, indicating the window size change event.| -| callback | Callback<[Size](#size)> | No | Callback used to return the information. | +| type | string | Yes | Type of event to listen for. The value is fixed at `windowSizeChange`, indicating the window size change event.| +| callback | Callback<[Size](#size)> | No | Callback used to return the window size. | **Example** - ```js - var type = 'windowSizeChange'; - windowClass.off(type); - ``` +```js +windowClass.off('windowSizeChange'); +``` ### on('systemAvoidAreaChange')7+ @@ -1415,17 +1408,16 @@ Enables listening for changes to the area where the window cannot be displayed. | Name | Type | Mandatory| Description | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of event to listen for. The value is fixed at **systemAvoidAreaChange**, indicating the event of changes to the area where the window cannot be displayed.| -| callback | Callback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the information. | +| type | string | Yes | Type of event to listen for. The value is fixed at `systemAvoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.| +| callback | Callback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the area. | **Example** - ```js - var type = 'systemAvoidAreaChange'; - windowClass.on(type, (data) => { - console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data)); - }); - ``` +```js +windowClass.on('systemAvoidAreaChange', (data) => { + console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data)); +}); +``` ### off('systemAvoidAreaChange')7+ @@ -1439,15 +1431,14 @@ Disables listening for changes to the area where the window cannot be displayed. | Name | Type | Mandatory| Description | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of event to listen for. The value is fixed at **systemAvoidAreaChange**, indicating the event of changes to the area where the window cannot be displayed.| -| callback | Callback<[AvoidArea](#avoidarea)> | No | Callback used to return the information. | +| type | string | Yes | Type of event to listen for. The value is fixed at `systemAvoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.| +| callback | Callback<[AvoidArea](#avoidarea)> | No | Callback used to return the area. | **Example** - ```js - var type = 'systemAvoidAreaChange'; - windowClass.off(type); - ``` +```js +windowClass.off('systemAvoidAreaChange'); +``` ### on('keyboardHeightChange')7+ @@ -1459,19 +1450,18 @@ Enables listening for keyboard height changes. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of event to listen for. The value is fixed at **keyboardHeightChange**, indicating the keyboard height change event.| -| callback | Callbacknumber> | Yes | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | ------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Type of event to listen for. The value is fixed at `keyboardHeightChange`, indicating the keyboard height change event.| +| callback | Callback { - console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); - }); - ``` +```js +windowClass.on('keyboardHeightChange', (data) => { + console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); +}); +``` ### off('keyboardHeightChange')7+ @@ -1485,15 +1475,14 @@ Disables listening for keyboard height changes. | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of event to listen for. The value is fixed at **keyboardHeightChange**, indicating the keyboard height change event.| -| callback | Callback<number> | No | Callback used to return the information. | +| type | string | Yes | Type of event to listen for. The value is fixed at `keyboardHeightChange`, indicating the keyboard height change event.| +| callback | Callback<number> | No | Callback used to return the current keyboard height. | **Example** - ```js - var type = 'keyboardHeightChange'; - windowClass.off(type); - ``` +```js +windowClass.off('keyboardHeightChange'); +``` ### isSupportWideGamut8+ @@ -1505,21 +1494,21 @@ Checks whether this window supports the wide color gamut mode. This API uses an **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------------- | ---- | -------------------------------- | -| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the wide color gamut mode is supported.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value `true` means that the wide color gamut mode is supported, and `false` means the opposite.| **Example** - ```js - windowClass.isSupportWideGamut((err, data) => { - if (err.code) { - console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data)) - }) - ``` +```js +windowClass.isSupportWideGamut((err, data) => { + if (err.code) { + console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data)); +}) +``` ### isSupportWideGamut8+ @@ -1533,18 +1522,18 @@ Checks whether this window supports the wide color gamut mode. This API uses a p | Type | Description | | ---------------------- | ------------------------------------------------------------ | -| Promise<boolean> | Promise used to return whether the wide color gamut mode is supported.| +| Promise<boolean> | Promise used to return the result. The value `true` means that the wide color gamut mode is supported, and `false` means the opposite.| **Example** - ```js - let promise = windowClass.isSupportWideGamut(); - promise.then((data)=> { - console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +let promise = windowClass.isSupportWideGamut(); +promise.then((data)=> { + console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err)); +}); +``` ### setColorSpace8+ @@ -1559,19 +1548,19 @@ Sets this window to the wide or default color gamut mode. This API uses an async | Name | Type | Mandatory| Description | | ---------- | ------------------------- | ---- | ------------ | | colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** - ```js - windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => { - if (err.code) { - console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)) - }) - ``` +```js +windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => { + if (err.code) { + console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)); +}) +``` ### setColorSpace8+ @@ -1583,26 +1572,26 @@ Sets this window to the wide or default color gamut mode. This API uses a promis **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------------------------- | ---- | ------------ | +| Name | Type | Mandatory| Description | +| ---------- | ------------------------- | ---- | -------------- | | colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.| **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - let promise = windowClass.isSupportWideGamut(window.ColorSpace.WIDE_GAMUT); - promise.then((data)=> { - console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +let promise = windowClass.isSupportWideGamut(window.ColorSpace.WIDE_GAMUT); +promise.then((data)=> { + console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err)); +}); +``` ### getColorSpace8+ @@ -1614,21 +1603,21 @@ Obtains the color gamut mode of this window. This API uses an asynchronous callb **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------------------- | ---- | -------------------------- | -| callback | AsyncCallback<[ColorSpace](#colorspace)> | Yes | Callback used to return the color gamut mode obtained.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------------- | ---- | ---------------------------------------------------------- | +| callback | AsyncCallback<[ColorSpace](#colorspace)> | Yes | Callback used to return the result. When the color gamut mode is obtained successfully, `err` is `undefined`, and `data` is the current color gamut mode.| **Example** - ```js - windowClass.getColorSpace((err, data) => { - if (err.code) { - console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data)) - }) - ``` +```js +windowClass.getColorSpace((err, data) => { + if (err.code) { + console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data)); +}) +``` ### getColorSpace8+ @@ -1640,20 +1629,20 @@ Obtains the color gamut mode of this window. This API uses a promise to return t **Return value** -| Type | Description | -| ---------------------------------------- | ----------------------------------------- | -| Promise<[ColorSpace](#colorspace)> | Promise used to return the color gamut mode obtained.| +| Type | Description | +| ---------------------------------------- | ------------------------------- | +| Promise<[ColorSpace](#colorspace)> | Promise used to return the current color gamut mode.| **Example** - ```js - let promise = windowClass.getColorSpace(); - promise.then((data)=> { - console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +let promise = windowClass.getColorSpace(); +promise.then((data)=> { + console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err)); +}); +``` ### setBackgroundColor @@ -1667,21 +1656,21 @@ Sets the background color for this window. This API uses an asynchronous callbac | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | -| color | string | Yes | Background color to set. The value is a hexadecimal color value and is case insensitive, for example, **#00FF00** or **#FF00FF00**.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| color | string | Yes | Background color to set. The value is a hexadecimal color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** - ```js - var color = '#00ff33'; - windowClass.setBackgroundColor(color, (err, data) => { - if (err.code) { - console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)); - }); - ``` +```js +var color = '#00ff33'; +windowClass.setBackgroundColor(color, (err, data) => { + if (err.code) { + console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)); +}); +``` ### setBackgroundColor @@ -1695,25 +1684,25 @@ Sets the background color for this window. This API uses a promise to return the | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| color | string | Yes | Background color to set. The value is a hexadecimal color value and is case insensitive, for example, **#00FF00** or **#FF00FF00**.| +| color | string | Yes | Background color to set. The value is a hexadecimal color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.| **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - var color = '#00ff33'; - let promise = windowClass.setBackgroundColor(color); - promise.then((data)=> { - console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +var color = '#00ff33'; +let promise = windowClass.setBackgroundColor(color); +promise.then((data)=> { + console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); +}); +``` ### setBrightness @@ -1727,21 +1716,21 @@ Sets the screen brightness for this window. This API uses an asynchronous callba | Name | Type | Mandatory| Description | | ---------- | ------------------------- | ---- | ------------------------------------ | -| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value `1` indicates the brightest.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** - ```js - var brightness = 1; - windowClass.setBrightness(brightness, (err, data) => { - if (err.code) { - console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)); - }); - ``` +```js +var brightness = 1; +windowClass.setBrightness(brightness, (err, data) => { + if (err.code) { + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)); +}); +``` ### setBrightness @@ -1755,25 +1744,25 @@ Sets the screen brightness for this window. This API uses a promise to return th | Name | Type | Mandatory| Description | | ---------- | ------ | ---- | ------------------------------------ | -| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.| +| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value `1` indicates the brightest.| **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - var brightness = 1; - let promise = windowClass.setBrightness(brightness); - promise.then((data)=> { - console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +var brightness = 1; +let promise = windowClass.setBrightness(brightness); +promise.then((data)=> { + console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); +}); +``` ### setDimBehind(deprecated) @@ -1783,7 +1772,7 @@ Sets the dimness of the window that is not on top. This API uses an asynchronous > **NOTE** > -> This API is supported since API version 7 and deprecated since API version 9. +> This API is supported since API version 7 and deprecated since API version 9. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -1791,20 +1780,20 @@ Sets the dimness of the window that is not on top. This API uses an asynchronous | Name | Type | Mandatory| Description | | -------------- | ------------------------- | ---- | -------------------------------------------------- | -| dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value **1** indicates the dimmest.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value `1` indicates the dimmest.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** - ```js - windowClass.setDimBehind(0.5, (err, data) => { - if (err.code) { - console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data)); - }); - ``` +```js +windowClass.setDimBehind(0.5, (err, data) => { + if (err.code) { + console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data)); +}); +``` ### setDimBehind(deprecated) @@ -1814,7 +1803,7 @@ Sets the dimness of the window that is not on top. This API uses a promise to re > **NOTE** > -> This API is supported since API version 7 and deprecated since API version 9. +> This API is supported since API version 7 and deprecated since API version 9. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -1822,24 +1811,24 @@ Sets the dimness of the window that is not on top. This API uses a promise to re | Name | Type | Mandatory| Description | | -------------- | ------ | ---- | -------------------------------------------------- | -| dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value **1** indicates the dimmest.| +| dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value `1` indicates the dimmest.| **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - let promise = windowClass.setDimBehind(0.5); - promise.then((data)=> { - console.info('Succeeded in setting the dimness. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +let promise = windowClass.setDimBehind(0.5); +promise.then((data)=> { + console.info('Succeeded in setting the dimness. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); +}); +``` ### setFocusable7+ @@ -1854,20 +1843,20 @@ Sets whether this window can gain focus. This API uses an asynchronous callback | Name | Type | Mandatory| Description | | ----------- | ------------------------- | ---- | ---------------------------- | | isFocusable | boolean | Yes | Whether the window can gain focus.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** - ```js - var isFocusable= true; - windowClass.setFocusable(isFocusable, (err, data) => { - if (err.code) { - console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); - }); - ``` +```js +var isFocusable= true; +windowClass.setFocusable(isFocusable, (err, data) => { + if (err.code) { + console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); +}); +``` ### setFocusable7+ @@ -1885,21 +1874,21 @@ Sets whether this window can gain focus. This API uses a promise to return the r **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - var isFocusable= true; - let promise = windowClass.setFocusable(isFocusable); - promise.then((data)=> { - console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +var isFocusable= true; +let promise = windowClass.setFocusable(isFocusable); +promise.then((data)=> { + console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err)); +}); +``` ### setKeepScreenOn @@ -1914,20 +1903,52 @@ Sets whether to keep the screen always on. This API uses an asynchronous callbac | Name | Type | Mandatory| Description | | -------------- | ------------------------- | ---- | ------------------------ | | isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example** + +```js +var isKeepScreenOn = true; +windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => { + 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. Data: ' + JSON.stringify(data)); +}); +``` + +### setKeepScreenOn + +setKeepScreenOn(isKeepScreenOn: boolean): Promise<void> + +Sets whether to keep the screen always on. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------- | ------- | ---- | ------------------------ | +| isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.| + +**Return value** + +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - var isKeepScreenOn = true; - windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => { - 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. Data: ' + JSON.stringify(data)); - }); - ``` +```js +var isKeepScreenOn = true; +let promise = windowClass.setKeepScreenOn(isKeepScreenOn); +promise.then((data) => { + console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); +}); +``` ### setOutsideTouchable(deprecated) @@ -1937,7 +1958,7 @@ Sets whether the area outside the subwindow is touchable. This API uses an async > **NOTE** > -> This API is supported since API version 7 and deprecated since API version 9. +> This API is supported since API version 7 and deprecated since API version 9. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -1945,20 +1966,20 @@ Sets whether the area outside the subwindow is touchable. This API uses an async | Name | Type | Mandatory| Description | | --------- | ------------------------- | ---- | ---------------- | -| touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value **true** means that such an area is touchable, and **false** means the opposite.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value `true` means that such an area is touchable, and `false` means the opposite.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** - ```js - windowClass.setOutsideTouchable(true, (err, data) => { - if (err.code) { - console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)) - }) - ``` +```js +windowClass.setOutsideTouchable(true, (err, data) => { + if (err.code) { + console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)); +}) +``` ### setOutsideTouchable(deprecated) @@ -1967,8 +1988,10 @@ setOutsideTouchable(touchable: boolean): Promise<void> Sets whether the area outside the subwindow is touchable. This API uses a promise to return the result. > **NOTE** -> +> > This API is supported since API version 7 and deprecated since API version 9. +> +> **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -1976,56 +1999,24 @@ Sets whether the area outside the subwindow is touchable. This API uses a promis | Name | Type | Mandatory| Description | | --------- | ------- | ---- | ---------------- | -| touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value **true** means that such an area is touchable, and **false** means the opposite.| +| touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value `true` means that such an area is touchable, and `false` means the opposite.| **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - let promise = windowClass.setOutsideTouchable(true); - promise.then((data)=> { - console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); - }); - ``` - -### setKeepScreenOn - -setKeepScreenOn(isKeepScreenOn: boolean): Promise<void> - -Sets whether to keep the screen always on. This API uses a promise to return the result. - -**System capability**: SystemCapability.WindowManager.WindowManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------------- | ------- | ---- | ------------------------ | -| isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.| - -**Return value** - -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| - -**Example** - - ```js - var isKeepScreenOn= true; - let promise = windowClass.setKeepScreenOn(isKeepScreenOn); - promise.then((data)=> { - console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +let promise = windowClass.setOutsideTouchable(true); +promise.then((data)=> { + console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); +}); +``` ### setPrivacyMode7+ @@ -2040,21 +2031,21 @@ Sets whether this window is in privacy mode. This API uses an asynchronous callb | Name | Type | Mandatory| Description | | ------------- | ------------------------- | ---- | -------------------- | | isPrivacyMode | boolean | Yes | Whether the window is in privacy mode.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** - ```js - var isPrivacyMode = true; - windowClass.setPrivacyMode(isPrivacyMode, (err, data) => { - if (err.code) { - console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the window to privacy mode. Data:' + JSON.stringify(data)); - - }); - ``` +```js +var isPrivacyMode = true; +windowClass.setPrivacyMode(isPrivacyMode, (err, data) => { + if (err.code) { + console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to privacy mode. Data:' + JSON.stringify(data)); + +}); +``` ### setPrivacyMode7+ @@ -2072,21 +2063,21 @@ Sets whether this window is in privacy mode. This API uses a promise to return t **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - var isPrivacyMode = true; - let promise = windowClass.setPrivacyMode(isPrivacyMode); - promise.then((data)=> { - console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +var isPrivacyMode = true; +let promise = windowClass.setPrivacyMode(isPrivacyMode); +promise.then((data)=> { + console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err)); +}); +``` ### setTouchable7+ @@ -2101,21 +2092,21 @@ Sets whether this window is touchable. This API uses an asynchronous callback to | Name | Type | Mandatory| Description | | ----------- | ------------------------- | ---- | -------------------- | | isTouchable | boolean | Yes | Whether the window is touchable.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** - ```js - var isTouchable = true; - windowClass.setTouchable(isTouchable, (err, data) => { - if (err.code) { - console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data)); - - }); - ``` +```js +var isTouchable = true; +windowClass.setTouchable(isTouchable, (err, data) => { + if (err.code) { + console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data)); + +}); +``` ### setTouchable7+ @@ -2133,21 +2124,21 @@ Sets whether this window is touchable. This API uses a promise to return the res **Return value** -| Type | Description | -| ------------------- | ----------------------------------------------- | -| Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - var isTouchable = true; - let promise = windowClass.setTouchable(isTouchable); - promise.then((data)=> { - console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err)); - }); - ``` +```js +var isTouchable = true; +let promise = windowClass.setTouchable(isTouchable); +promise.then((data)=> { + console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err)); +}); +``` ## WindowStageEventType9+ @@ -2155,8 +2146,8 @@ Describes the lifecycle of a window stage. **System capability**: SystemCapability.WindowManager.WindowManager.Core -| Name | Default Value | Description | -| ---------- | ------ | -------- | +| Name | Default Value | Description | +| ---------- | ------ | ---------- | | FOREGROUND | 1 | The window stage is running in the foreground.| | ACTIVE | 2 | The window stage gains focus.| | INACTIVE | 3 | The window stage loses focus.| @@ -2164,8 +2155,43 @@ Describes the lifecycle of a window stage. ## WindowStage9+ -Before calling any of the following APIs, you must use `[onWindowStageCreate()](js-apis-application-ability.md#abilityonwindowstagecreate)` to create a **WindowStage** instance. +Implements a window manager, which manages each basic window unit, that is, [Window](#window) instance. + +Before calling any of the following APIs, you must use `[onWindowStageCreate()](js-apis-application-ability.md#abilityonwindowstagecreate)` to create a `WindowStage` instance. + +### getMainWindow9+ + +getMainWindow(callback: AsyncCallback<Window>): void + +Obtains the main window of this window stage. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | --------------------------------------------- | +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the main window.| +**Example** + +```ts +import Ability from '@ohos.application.Ability'; +class myAbility extends Ability { + onWindowStageCreate(windowStage) { + console.log('onWindowStageCreate'); + var windowClass = null; + windowStage.getMainWindow((err, data) => { + if (err.code) { + console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); + }); + } +} +``` ### getMainWindow9+ getMainWindow(): Promise<Window> @@ -2176,61 +2202,63 @@ Obtains the main window of this window stage. This API uses a promise to return **Return value** -| Type | Description | -| -------------------------------- | ---------------------------------------------------------- | +| Type | Description | +| -------------------------------- | ------------------------------------------------ | | Promise<[Window](#window)> | Promise used to return the main window.| **Example** - ```ts - class myAbility extends Ability { - onWindowStageCreate(windowStage) { - console.log('onWindowStageCreate'); - var windowClass = null; - let promise = windowStage.getMainWindow(); - promise.then((data)=> { - windowClass = data; - console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); - }); - } - } - ``` - -### getMainWindow9+ +```ts +import Ability from '@ohos.application.Ability'; +class myAbility extends Ability { + onWindowStageCreate(windowStage) { + console.log('onWindowStageCreate'); + var windowClass = null; + let promise = windowStage.getMainWindow(); + promise.then((data)=> { + windowClass = data; + console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); + }); + } +} +``` +### createSubWindow9+ -getMainWindow(callback: AsyncCallback<Window>): void +createSubWindow(name: string, callback: AsyncCallback<Window>): void -Obtains the main window of this window stage. This API uses an asynchronous callback to return the result. +Creates a subwindow for this window stage. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------------------------------------- | ---- | --------------------------------------- | -| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the main window.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | --------------------------------------------- | +| name | String | Yes | Name of the subwindow. | +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow.| **Example** - ```ts - class myAbility extends Ability { - onWindowStageCreate(windowStage) { - console.log('onWindowStageCreate'); - var windowClass = null; - windowStage.getMainWindow((err, data) => { - if (err.code) { - console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); - }); - } - } - ``` - +```ts +import Ability from '@ohos.application.Ability'; +class myAbility extends Ability { + onWindowStageCreate(windowStage) { + console.log('onWindowStageCreate'); + var windowClass = null; + windowStage.createSubWindow("mySubWindow", (err, data) => { + if (err.code) { + console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); + windowClass.resetSize(500, 1000); + }); + } +} +``` ### createSubWindow9+ createSubWindow(name: string): Promise<Window> @@ -2247,63 +2275,61 @@ Creates a subwindow for this window stage. This API uses a promise to return the **Return value** -| Type | Description | -| -------------------------------- | ------------------------------------------------- | -| Promise<[Window](#window)> | Promise used to return the subwindow created.| - -**Example** - - ```ts - class myAbility extends Ability { - onWindowStageCreate(windowStage) { - console.log('onWindowStageCreate'); - var windowClass = null; - let promise = windowStage.createSubWindow("mySubWindow"); - promise.then((data)=> { - windowClass = data; - console.info('Succeeded in create sub window. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to create sub window. Cause: ' + JSON.stringify(err)); - }) - } - } - ``` - -### createSubWindow9+ +| Type | Description | +| -------------------------------- | ------------------------------------------------ | +| Promise<[Window](#window)> | Promise used to return the subwindow.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability'; +class myAbility extends Ability { + onWindowStageCreate(windowStage) { + console.log('onWindowStageCreate'); + var windowClass = null; + let promise = windowStage.createSubWindow("mySubWindow"); + promise.then((data)=> { + windowClass = data; + console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); + }) + } +} +``` +### getSubWindow9+ -createSubWindow(name: string, callback: AsyncCallback<Window>): void +getSubWindow(callback: AsyncCallback<Array<Window>>): void -Creates a subwindow for this window stage. This API uses an asynchronous callback to return the result. +Obtains all the subwindows of this window stage. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------------------------------------- | ---- | ------------------------------ | -| name | String | Yes | Name of the subwindow. | -| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created.| +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------- | ---- | ------------------------------------------------- | +| callback | AsyncCallback<Array<[Window](#window)>> | Yes | Callback used to return all the subwindows.| **Example** - ```ts - class myAbility extends Ability { - onWindowStageCreate(windowStage) { - console.log('onWindowStageCreate'); - var windowClass = null; - windowStage.createSubWindow("mySubWindow", (err, data) => { - if (err.code) { - console.error('Failed to create sub window. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in create sub window. Data: ' + JSON.stringify(data)); - windowClass.resetSize(500, 1000); - }); - } - } - ``` - +```ts +import Ability from '@ohos.application.Ability'; +class myAbility extends Ability { + onWindowStageCreate(windowStage) { + console.log('onWindowStageCreate'); + var windowClass = null; + windowStage.getSubWindow((err, data) => { + if (err.code) { + console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data)); + }); + } +} +``` ### getSubWindow9+ getSubWindow(): Promise<Array<Window>> @@ -2314,92 +2340,60 @@ Obtains all the subwindows of this window stage. This API uses a promise to retu **Return value** -| Type | Description | -| --------------------------------------------- | ------------------------------------------------------------ | +| Type | Description | +| --------------------------------------------- | ---------------------------------------------------- | | Promise<Array<[Window](#window)>> | Promise used to return all the subwindows.| **Example** - ```ts - class myAbility extends Ability { - onWindowStageCreate(windowStage) { - console.log('onWindowStageCreate'); - var windowClass = null; - let promise = windowStage.getSubWindow(); - promise.then((data)=> { - windowClass = data; - console.info('Succeeded in obtaining the sub window. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to obtain the sub window. Cause: ' + JSON.stringify(err)); - }) - } - } - ``` - -### getSubWindow9+ - -getSubWindow(callback: AsyncCallback<Array<Window>>): void - -Obtains all the subwindows of this window stage. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.WindowManager.WindowManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------------------- | ---- | ------------------------------------------- | -| callback | AsyncCallback<Array<[Window](#window)>> | Yes | Callback used to return all the subwindows.| - -**Example** - - ```ts - class myAbility extends Ability { - onWindowStageCreate(windowStage) { - console.log('onWindowStageCreate'); - var windowClass = null; - windowStage.getSubWindow((err, data) => { - if (err.code) { - console.error('Failed to obtain the sub window. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in obtaining the sub window. Data: ' + JSON.stringify(data)); - }); - } - } - ``` - +```ts +import Ability from '@ohos.application.Ability'; +class myAbility extends Ability { + onWindowStageCreate(windowStage) { + console.log('onWindowStageCreate'); + var windowClass = null; + let promise = windowStage.getSubWindow(); + promise.then((data)=> { + windowClass = data; + console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err)); + }) + } +} +``` ### loadContent9+ loadContent(path: string, callback: AsyncCallback<void>): void -Loads content to this window stage. This API uses an asynchronous callback to return the result. +Loads content from a page to this window stage. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.WindowManager.WindowManager.Coretype with the value **windowSizeChange** +**System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | -------------------- | | path | string | Yes | Path of the page from which the content will be loaded.| -| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | - -**Example** - - ```ts - class myAbility extends Ability { - onWindowStageCreate(windowStage) { - console.log('onWindowStageCreate'); - windowStage.loadContent("pages/page2", (err, data) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) - }); - } - } - ``` +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example** + +```ts +import Ability from '@ohos.application.Ability'; +class myAbility extends Ability { + onWindowStageCreate(windowStage) { + console.log('onWindowStageCreate'); + windowStage.loadContent("pages/page2", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); + }); + } +} +``` ### on('windowStageEvent')9+ @@ -2413,22 +2407,22 @@ Enables listening for window stage lifecycle changes. | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of event to listen for. The value is fixed at **windowStageEvent**, indicating the window stage lifecycle change event.| -| callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | Yes | Callback used to return the information. | +| type | string | Yes | Type of event to listen for. The value is fixed at `windowStageEvent`, indicating the window stage lifecycle change event.| +| callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | Yes | Callback used to return the window stage lifecycle state. | **Example** - ```ts - class myAbility extends Ability { - onWindowStageCreate(windowStage) { - console.log('onWindowStageCreate'); - var type = 'windowStageEvent'; - windowStage.on(type, (data) => { - console.info('Succeeded in enabling the listener for window stage event changes. Data: ' + JSON.stringify(data)); - }); - } - } - ``` +```ts +import Ability from '@ohos.application.Ability'; +class myAbility extends Ability { + onWindowStageCreate(windowStage) { + console.log('onWindowStageCreate'); + windowStage.on('windowStageEvent', (data) => { + console.info('Succeeded in enabling the listener for window stage event changes. Data: ' + JSON.stringify(data)); + }); + } +} +``` ### off('windowStageEvent')9+ @@ -2442,17 +2436,17 @@ Disables listening for window stage lifecycle changes. | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of event to listen for. The value is fixed at **windowStageEvent**, indicating the window stage lifecycle change event.| -| callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | No | Callback used to return the information. | +| type | string | Yes | Type of event to listen for. The value is fixed at `windowStageEvent`, indicating the window stage lifecycle change event.| +| callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | No | Callback used to return the window stage lifecycle state. | **Example** - ```ts - class myAbility extends Ability { - onWindowStageCreate(windowStage) { - console.log('onWindowStageCreate'); - var type = 'windowStageEvent'; - windowStage.off(type); - } - } - ``` +```ts +import Ability from '@ohos.application.Ability'; +class myAbility extends Ability { + onWindowStageCreate(windowStage) { + console.log('onWindowStageCreate'); + windowStage.off('windowStageEvent'); + } +} +``` diff --git a/en/application-dev/reference/apis/js-apis-xml.md b/en/application-dev/reference/apis/js-apis-xml.md index 124d845c0e1101346a0783b9e56cd74b089b2424..1175651b960bcc61cfef74c9c724d281487f6582 100644 --- a/en/application-dev/reference/apis/js-apis-xml.md +++ b/en/application-dev/reference/apis/js-apis-xml.md @@ -1,6 +1,7 @@ # XML Parsing and Generation -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE** +> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -10,10 +11,6 @@ import xml from '@ohos.xml'; ``` -## System Capabilities - -SystemCapability.Utils.Lang - ## XmlSerializer @@ -23,11 +20,13 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string) A constructor used to create an **XmlSerializer** instance. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| buffer | ArrayBuffer \| DataView | Yes| **ArrayBuffer** or **DataView** for storing the XML information to write.| +| buffer | ArrayBuffer \| DataView | Yes| **ArrayBuffer** or **DataView** for storing the XML information to write.| | encoding | string | No| Encoding format.| **Example** @@ -45,6 +44,8 @@ setAttributes(name: string, value: string): void Sets an attribute. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -55,6 +56,8 @@ Sets an attribute. **Example** ```js +var arrayBuffer = new ArrayBuffer(1024); +var bufView = new DataView(arrayBuffer); var thatSer = new xml.XmlSerializer(bufView); thatSer.setAttributes("importance", "high"); ``` @@ -66,6 +69,8 @@ addEmptyElement(name: string): void Adds an empty element. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -75,6 +80,8 @@ Adds an empty element. **Example** ```js +var arrayBuffer = new ArrayBuffer(1024); +var bufView = new DataView(arrayBuffer); var thatSer = new xml.XmlSerializer(bufView); thatSer.addEmptyElement("b"); // => ``` @@ -86,9 +93,13 @@ setDeclaration(): void Sets a declaration. +**System capability**: SystemCapability.Utils.Lang + **Example** ```js +var arrayBuffer = new ArrayBuffer(1024); +var bufView = new DataView(arrayBuffer); var thatSer = new xml.XmlSerializer(bufView); thatSer.setDeclaration() // => ; ``` @@ -100,6 +111,8 @@ startElement(name: string): void Writes the start tag based on the given element name. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -122,9 +135,13 @@ endElement(): void Writes the end tag of the element. +**System capability**: SystemCapability.Utils.Lang + **Example** ```js +var arrayBuffer = new ArrayBuffer(1024); +var bufView = new DataView(arrayBuffer); var thatSer = new xml.XmlSerializer(bufView); thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); thatSer.startElement("table"); @@ -140,6 +157,8 @@ setNamespace(prefix: string, namespace: string): void Sets the namespace for an element tag. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -164,6 +183,8 @@ setComment(text: string): void Sets the comment. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -187,6 +208,8 @@ setCDATA(text: string): void Sets CDATA attributes. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -208,6 +231,8 @@ setText(text: string): void Sets **Text**. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -232,6 +257,8 @@ setDocType(text: string): void Sets **DocType**. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -256,11 +283,13 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string) Creates and returns an **XmlPullParser** object. The **XmlPullParser** object passes two parameters. The first parameter is the memory of the **ArrayBuffer** or **DataView** type, and the second parameter is the file format (UTF-8 by default). +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| buffer | ArrayBuffer \| DataView | Yes| **ArrayBuffer** or **DataView** that contains XML text information.| +| buffer | ArrayBuffer \| DataView | Yes| **ArrayBuffer** or **DataView** that contains XML text information.| | encoding | string | No| Encoding format. Only UTF-8 is supported.| **Example** @@ -289,6 +318,8 @@ parse(option: ParseOptions): void Parses XML information. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -329,14 +360,16 @@ that.parse(options); Defines the XML parsing options. +**System capability**: SystemCapability.Utils.Lang + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | supportDoctype | boolean | No| Whether to ignore **Doctype**. The default value is **false**.| | ignoreNameSpace | boolean | No| Whether to ignore **Namespace**. The default value is **false**.| -| tagValueCallbackFunction | (name: string, value: string)=> boolean | No| Callback used to return **tagValue**.| -| attributeValueCallbackFunction | (name: string, value: string)=> boolean | No| Callback used to return **attributeValue**.| -| tokenValueCallbackFunction | (eventType: [EventType](#eventtype), value: [ParseInfo](#parseinfo))=> boolean | No| Callback used to return **tokenValue**.| +| tagValueCallbackFunction | (name: string, value: string)=> boolean | No| Callback used to return **tagValue**.| +| attributeValueCallbackFunction | (name: string, value: string)=> boolean | No| Callback used to return **attributeValue**.| +| tokenValueCallbackFunction | (eventType: [EventType](#eventtype), value: [ParseInfo](#parseinfo))=> boolean | No| Callback used to return **tokenValue**.| ## ParseInfo @@ -349,6 +382,8 @@ getColumnNumber(): number Obtains the column line number, which starts from 1. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -362,6 +397,8 @@ getDepth(): number Obtains the depth of this element. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -375,6 +412,8 @@ getLineNumber(): number Obtains the current line number, starting from 1. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -388,6 +427,8 @@ getName(): string Obtains the name of this element. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -401,6 +442,8 @@ getNamespace(): string Obtains the namespace of this element. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -414,6 +457,8 @@ getPrefix(): string Obtains the prefix of this element. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -427,6 +472,8 @@ getText(): string Obtains the text of the current event. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -440,6 +487,8 @@ isEmptyElementTag(): boolean Checks whether the current element is empty. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -453,6 +502,8 @@ isWhitespace(): boolean Checks whether the current text event contains only whitespace characters. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -466,6 +517,8 @@ getAttributeCount(): number Obtains the number of attributes for the current start tag. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| | -------- | -------- | @@ -476,6 +529,8 @@ Obtains the number of attributes for the current start tag. Enumerates the events. +**System capability**: SystemCapability.Utils.Lang + | Name| Value| Description| | -------- | -------- | -------- | | START_DOCUMENT | 0 | Indicates a start document event.| diff --git a/en/application-dev/reference/arkui-js/js-components-common-events.md b/en/application-dev/reference/arkui-js/js-components-common-events.md index b477f87918dc4f1ac030fbbf0d33e51b4c97248f..ff3370b891a40e1d0fdac79f8546348ffa649c42 100644 --- a/en/application-dev/reference/arkui-js/js-components-common-events.md +++ b/en/application-dev/reference/arkui-js/js-components-common-events.md @@ -1,116 +1,108 @@ # Universal Events +> **NOTE**
+> Universal events are supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + ## Event Description - Events are bound to components. When a component meets the event triggering condition, the corresponding event callback in the JS is executed to implement the interaction between the UI and the JS logic layer of the page. -- The event callback can carry additional information through parameters, such as the dataset on the component and event-specific callback parameters. - -Different from private events, universal events can be bound to most components. - - - -| Name | Parameter | Description | Support Bubbling | -| ------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ---------------- | -| touchstart | [TouchEvent](js-components-common-events.md) | Triggered when the tapping starts. | Yes5+ | -| touchmove | [TouchEvent](js-components-common-events.md) | Triggered when the tapping moves. | Yes5+ | -| touchcancel | [TouchEvent](js-components-common-events.md) | Triggered when the tapping is interrupted. | Yes5+ | -| touchend | [TouchEvent](js-components-common-events.md) | Triggered when the tapping ends. | Yes5+ | -| click | - | Triggered when a component is clicked. | Yes6+ | -| doubleclick7+ | | Triggered when a component is double-clicked. | No | -| longpress | - | Triggered when a component is long pressed. | No | -| swipe5+ | [SwipeEvent](js-components-common-events.md#table111811577714) | Triggered when a user quickly swipes on a component. | No | -| attached6+ | - | Triggered after the current component node is mounted to the render tree. | No | -| detached6+ | - | Triggered when the current component node is removed from the render tree. | No | -| pinchstart7+ | [PinchEvent](js-components-common-events.md) | Triggered when a pinch operation is started. | No | -| pinchupdate7+ | [PinchEvent](js-components-common-events.md) | Triggered when a pinch operation is in progress. | No | -| pinchend7+ | [PinchEvent](js-components-common-events.md) | Triggered when a pinch operation is ended. | No | -| pinchcancel7+ | [PinchEvent](js-components-common-events.md) | Triggered when the pinch operation is interrupted. | No | -| dragstart7+ | [DragEvent](js-components-common-events.md) | Triggered when dragging starts. | No | -| drag7+ | [DragEvent](js-components-common-events.md) | Triggered when dragging is in progress. | No | -| dragend7+ | [DragEvent](js-components-common-events.md) | Triggered when dragging is ended. | No | -| dragenter7+ | [DragEvent](js-components-common-events.md) | Triggered when the dragged component enters a drop target. | No | -| dragover7+ | [DragEvent](js-components-common-events.md) | Triggered when the dragged component is being dragged over a drop target. | No | -| dragleave7+ | [DragEvent](js-components-common-events.md) | Triggered when the dragged component leaves a drop target. | No | -| drop7+ | [DragEvent](js-components-common-events.md) | Triggered when a component is dropped on a drop target. | No | -> ![img](public_sys-resources/icon-note.gif) **NOTE:** Events not listed in the preceding table are non-bubbling events, such as the [change event](js-components-basic-input.md). For details, see the specific component. - -**Table 1** Attributes of the BaseEvent object - - - -| Attribute | Type | Description | -| --------- | ------ | ----------------------------------------------- | -| type | string | Event type, such as **click** and **longpress** | -| timestamp | number | Timestamp when the event is triggered | +- The event callback can carry additional information through parameters, such as the dataset on the component and event-specific callback parameters. -**Table 2** Attributes of the TouchEvent object (inherited from BaseEvent) +Different from private events, universal events can be bound to most components. -| Attribute | Type | Description | -| -------------- | ----------------- | ------------------------------------------------------------ | -| touches | Array\ | Attribute set of the touch event, including the information array of the touch points on the screen. | -| changedTouches | Array\ | Attribute set when a touch event occurs, including the information array of changed touch points on the screen. **changedTouches** has the same data format as **touches** and indicates touch point changes, such as from no touch point to newly generated touch points, from some touch points to no touch point, and location changes. For example, when the user's finger leaves the touchscreen, no data exists in the **touches** array, but **changedTouches** will save the generated data. | +| Name | Parameter | Description | Support Bubbling | +| ------------------------ | ---------- | ---------------------------------------- | ---------------------------------------- | +| touchstart | TouchEvent | Triggered when the tapping starts. For details about **TouchEvent**, see Table 2. | Yes5+ | +| touchmove | TouchEvent | Triggered when the tapping moves. | Yes5+ | +| touchcancel | TouchEvent | Triggered when the tapping is interrupted. | Yes5+ | +| touchend | TouchEvent | Triggered when the tapping ends. | Yes5+ | +| click | - | Triggered when a component is clicked. | Yes6+ | +| doubleclick7+ | - | Triggered when a component is double-clicked. | No
Bubbling is supported since API version 9. | +| longpress | - | Triggered when a component is long pressed. | No
Bubbling is supported since API version 9.| +| swipe5+ | SwipeEvent | Triggered when a user quickly swipes on a component.
For details about **SwipeEvent**, see Table 4. | No
Bubbling is supported since API version 9.| +| attached6+ | - | Triggered after the current component node is mounted to the render tree. | No | +| detached6+ | - | Triggered when the current component node is removed from the render tree. | No | +| pinchstart7+ | PinchEvent | Triggered when a pinch operation is started.
For details about **PinchEvent**, see Table 5.| No | +| pinchupdate7+ | PinchEvent | Triggered when a pinch operation is in progress. | No | +| pinchend7+ | PinchEvent | Triggered when a pinch operation is ended. | No | +| pinchcancel7+ | PinchEvent | Triggered when a pinch operation is interrupted. | No | +| dragstart7+ | DragEvent | Triggered when dragging starts.
For details about **DragEvent**, see Table 6. | No | +| drag7+ | DragEvent | Triggered when dragging is in progress. | No | +| dragend7+ | DragEvent | Triggered when dragging is ended. | No | +| dragenter7+ | DragEvent | Triggered when the dragged component enters a drop target. | No | +| dragover7+ | DragEvent | Triggered when the dragged component is being dragged over a drop target. | No | +| dragleave7+ | DragEvent | Triggered when the dragged component leaves a drop target. | No | +| drop7+ | DragEvent | Triggered when the dragged component is dropped on a drop target. | No | + + +> **NOTE**
+> Events not listed in the preceding table do not support bubbling, such as the [change event](../arkui-js/js-components-basic-input.md#events) of the **** component. For details, see the description of the specific component. + +**Table 1** BaseEvent + +| Attribute | Type | Description | +| --------------------- | -------------------- | --------------------------- | +| type | string | Event type, such as **click** and **longpress**.| +| timestamp | number | Timestamp when the event is triggered. | +| deviceId6+ | number | ID of the device that triggers the event. | +| target6+ | [Target](#target6)| Target object that triggers the event. | + +**Table 2** TouchEvent (inherited from BaseEvent) + +| Attribute | Type | Description | +| -------------- | ---------------------- | ---------------------------------------- | +| touches | Array<TouchInfo> | Attribute set of the touch event, including the information array of the touch points on the screen. | +| changedTouches | Array<TouchInfo> | Attribute set when a touch event occurs, including the information array of changed touch points on the screen. **changedTouches** has the same data format as **touches** and indicates touch point changes, including changes in the number and location of touch points. For example, when the user's finger leaves the screen, which means that the number of touch points changes from 1 to 0, **changedTouches** has the relevant data generated, but not **touches**.| **Table 3** TouchInfo +| Attribute | Type | Description | +| ------------------ | ------ | ------------------------------ | +| globalX | number | Horizontal distance from the upper left corner of the screen (excluding the status bar), which acts as the origin of coordinates.| +| globalY | number | Vertical distance from the upper left corner of the screen (excluding the status bar), which acts as the origin of coordinates.| +| localX | number | Horizontal distance from the upper left corner of the touched component, which acts as the origin of coordinates. | +| localY | number | Vertical distance from the upper left corner of the touched component, which acts as the origin of coordinates. | +| size | number | Touch area. | +| force6+ | number | Touch force. | +**Table 4** SwipeEvent (inherited from BaseEvent) -| Attribute | Type | Description | -| --------- | ------ | ------------------------------------------------------------ | -| globalX | number | Horizontal distance from the upper left corner of the screen (excluding the status bar). The upper left corner of the screen acts as the coordinate origin. | -| globalY | number | Vertical distance from the upper left corner of the screen (excluding the status bar). The upper left corner of the screen acts as the coordinate origin. | -| localX | number | Horizontal distance from the upper left corner of the touched component. The upper left corner of the component acts as the coordinate origin. | -| localY | number | Vertical distance from the upper left corner of the touched component. The upper left corner of the component acts as the coordinate origin. | -| size | number | Touch area. | -| force6+ | number | Touch force. | - -**Table 4** Attributes of the SwipeEvent object (inherited from BaseEvent) +| Attribute | Type | Description | +| --------------------- | ------ | ---------------------------------------- | +| direction | string | Swiping direction. The value can be one of the following:
- **left**: Swipe left.
- **right**: Swipe right.
- **up**: Swipe up.
- **down**: Swipe down.| +| distance6+ | number | Swiping distance in the swiping direction. | +**Table 5** PinchEvent7+ +| Attribute | Type | Description | +| ------------ | ------ | -------------- | +| scale | number | Scale factor. | +| pinchCenterX | number | X-coordinate of the pinch center, in px.| +| pinchCenterY | number | Y-coordinate of the pinch center, in px.| -| Attribute | Type | Description | -| ---------- | ------ | ------------------------------------------------------------ | -| direction | string | Swiping direction. The value can be one of the following:
- **left**: Swipe from right to left
- **right**: Swipe from left to right
- **up**: Swipe upwards
- **down**: Swipe downwards | -| distance6+ | number | Swiping distance in the swiping direction. | +**Table 6** DragEvent7+ (inherited from BaseEvent) -**Table 5** Attributes of the PinchEvent object7+ +| Attribute | Type | Description | +| ------------------------- | -------------------------------- | ---------------- | +| type | string | Event name. | +| globalX | number | Horizontal distance from the upper left corner of the screen, which acts as the origin of coordinates.| +| globalY | number | Vertical distance from the upper left corner of the screen, which acts as the origin of coordinates.| +| timestamp | number | Timestamp. | - - -| Attribute | Type | Description | -| ------------ | ------ | ---------------------------------------- | -| scale | number | Scale factor. | -| pinchCenterX | number | X-coordinate of the pinch center, in px. | -| pinchCenterY | number | Y-coordinate of the pinch center, in px. | - -**Table 6** Attributes of the DragEvent object (inherited from BaseEvent)7+ - - - -| Attribute | Type | Description | -| --------- | ------ | ------------------------------------------------------------ | -| type | string | Event name. | -| globalX | number | Horizontal distance from the origin of the coordinates in the upper left corner of the screen. | -| globalY | number | Vertical distance from the origin of the coordinates in the upper left corner of the screen. | -| timestamp | number | Timestamp. | - -## Event Object +## Target6+ When a component triggers an event, the event callback receives an event object by default. You can obtain the corresponding information through the event object. -**target object:** +| Attribute | Type | Description | +| -------------------- | ------ | ---------------------------------------- | +| dataSet6+ | Object | Custom attribute set defined through [data-*](../arkui-js/js-components-common-attributes.md).| +**Example** - -| Attribute | Type | Description | -| --------- | ------ | ------------------------------------------------------------ | -| dataSet6+ | Object | Custom attribute set defined through [data-*](js-components-common-attributes.md). | - -**Example:** - -``` +```html
``` -``` +```js // xxx.js export default { touchstartfunc(msg) { @@ -128,3 +120,5 @@ export default { } ``` + + diff --git a/en/application-dev/reference/arkui-ts/Readme-EN.md b/en/application-dev/reference/arkui-ts/Readme-EN.md index ca63e3b3af318da7c27e002e734fc874c9dbd199..57d3ea74dd257c40f0d4d67e5b5757884768abc1 100644 --- a/en/application-dev/reference/arkui-ts/Readme-EN.md +++ b/en/application-dev/reference/arkui-ts/Readme-EN.md @@ -61,8 +61,6 @@ - [LoadingProgress](ts-basic-components-loadingprogress.md) - [Marquee](ts-basic-components-marquee.md) - [Navigation](ts-basic-components-navigation.md) - - [PatternLock](ts-basic-components-patternlock.md) - - [PluginComponent](ts-basic-components-plugincomponent.md) - [Progress](ts-basic-components-progress.md) - [QRCode](ts-basic-components-qrcode.md) - [Radio](ts-basic-components-radio.md) @@ -98,7 +96,6 @@ - [List](ts-container-list.md) - [ListItem](ts-container-listitem.md) - [Navigator](ts-container-navigator.md) - - - [Panel](ts-container-panel.md) - [Refresh](ts-container-refresh.md) - [Row](ts-container-row.md) diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193499234.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193499234.gif index 52fed39eeae057043dbd00abce9ff29d2c35a56a..15849e6bc210ed2bb7f7a798b145c9794972643c 100644 Binary files a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193499234.gif and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193499234.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/patternlock.gif b/en/application-dev/reference/arkui-ts/figures/patternlock.gif deleted file mode 100644 index 5fb034ddcf247a1fecaaeb33e27d103bd8225a91..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/patternlock.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md b/en/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md index f4a4b6e72edeeac8f332e8f4027ad5dc7db4eeba..ebd0371eb673a6f460ff97b626595ffc6fc91f25 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md @@ -1,11 +1,11 @@ # ImageAnimator -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE** > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **<ImageAnimator>** component enables images to be played frame by frame. The list of images to be played can be configured, and the duration of each image can be configured. +The **\** component enables images to be played frame by frame. The list of images to be played can be configured, and the duration of each image can be configured. ## Required Permissions @@ -15,7 +15,7 @@ None ## Child Components -None +Not supported ## APIs @@ -37,7 +37,7 @@ ImageAnimator() | iterations | number | 1 | No | By default, the animation is played once. The value **-1** indicates that the animation is played for an unlimited number of times. | - AnimationStatus enums - | Name | Description | + | Name | Description | | -------- | -------- | | Initial | The animation is in the initial state. | | Running | The animation is being played. | @@ -45,7 +45,7 @@ ImageAnimator() | Stopped | The animation is stopped. | - FillMode enums - | Name | Description | + | Name | Description | | -------- | -------- | | None | After the playback is complete, the animation restores to the initial state. | | Forwards | After the playback is complete, the animation remains in the end state. | @@ -78,6 +78,7 @@ struct ImageAnimatorExample { ImageAnimator() .images([ { + // The comment folder is at the same level as the pages folder. src: '/comment/bg1.jpg', duration: 500, width: 325, diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md b/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md index 083c2b488d18ee29307065c55c10e4450d0d85c2..c0a513e8a78614652ef01a5d43476e5492a9dba9 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md @@ -1,7 +1,7 @@ # Marquee -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. @@ -15,7 +15,7 @@ None ## Child Components -None +Not supported ## APIs @@ -23,22 +23,22 @@ None Marquee(value: { start: boolean, step?: number, loop?: number, fromStart?: boolean, src: string }) - Parameters - | Name| Type| Mandatory| Default Value| Description| + | Name| Type| Mandatory| Default Value| Description| | -------- | -------- | -------- | -------- | -------- | - | start | boolean | Yes| - | Whether to start scrolling.| - | step | number | No| 6 | Scrolling step.| - | loop | number | No| -1 | Number of times the marquee will scroll. If the value is less than or equal to **0**, the marquee will scroll continuously.| - | fromStart | boolean | No| true | Whether the text scrolls from the start.| - | src | string | Yes| - | Text to scroll.| + | start | boolean | Yes| - | Whether to start scrolling.| + | step | number | No| 6 | Scrolling step.| + | loop | number | No| -1 | Number of times the marquee will scroll. If the value is less than or equal to **0**, the marquee will scroll continuously.| + | fromStart | boolean | No| true | Whether the text scrolls from the start.| + | src | string | Yes| - | Text to scroll.| ## Events - | Name| Description| +| Name| Description| | -------- | -------- | -| onStart(callback: () => void) | Triggered when the marquee starts scrolling.| -| onBounce(callback: () => void) | Triggered when the marquee has reached the end.| -| onFinish(callback: () => void) | Triggered when the marquee has finished scrolling.| +| onStart(callback: () => void) | Triggered when the marquee starts scrolling.| +| onBounce(callback: () => void) | Triggered when the marquee has reached the end.| +| onFinish(callback: () => void) | Triggered when the marquee has finished scrolling.| ## Example diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md b/en/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md deleted file mode 100644 index c25bc9421105bfed71546a442ee64fd2841afb89..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md +++ /dev/null @@ -1,108 +0,0 @@ -# PatternLock - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. - -The **\** component allows users to use a pattern password for authentication. It enters the input state once being touched, and exits the input state and sends the entered password to the application once the finger leaves the screen. - -## Required Permissions - -None - -## Child Components - -None - -## APIs - -PatternLock(controller?: PatternLockController) - -- Parameters - - | Name | Type | Mandatory| Default Value| Description | - | ---------- | ----------------------------------------------- | ---- | ------ | -------------------------------------------- | - | controller | [PatternLockController](#patternlockcontroller) | No | null | Controller of a component to reset the component status.| - -## Attributes - -Except for **backgroundColor**, universal attributes are not supported. - -| Name | Type | Default Value | Description | -| --------------- | --------------------------------------------------- | ----------- | ------------------------------------------------------------ | -| sideLength | Length | 300vp | Width and height (same value) of the component. The minimum value is **0**. | -| circleRadius | Length | 14vp | Radius of a grid dot. | -| regularColor | [ResourceColor](../../ui/ts-types.md) | Color.Black | Fill color of the grid dot in unselected state. | -| selectedColor | [ResourceColor](../../ui/ts-types.md) | Color.Black | Fill color of the grid dot in selected state. | -| activeColor | [ResourceColor](../../ui/ts-types.md) | Color.Black | Fill color of the grid dot in active state. | -| pathColor | [ResourceColor](../../ui/ts-types.md) | Color.Blue | Path color. | -| pathStrokeWidth | Length | 34vp | Width of the path stroke. The minimum value is **0**. | -| autoReset | boolean | true | Whether to allow the user to reset the component status (that is, clear the input) by touching the component again after the input is complete. The value **true** means that the user can reset the component status by touching the component again after the input is complete, and **false** means the opposite. | - -## Events - -| Name | Description | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| onPatternComplete(callback: (input: Array\) => void) | Invoked when the pattern password input is complete.
**input** is an array of digits that represent the connected dots in the pattern (0 to 8) and are arranged in the same sequence as the dots are connected.| - -## PatternLockController - -Controller bound to the **\** component for resetting the component status. - -### Objects to Import - -```typescript -patternLockController: PatternLockController = new PatternLockController() -``` - -### reset - -reset(): void - -Resets the component status. - -## Example - -```typescript -@Entry -@Component -struct PatternLockExample { - @State passwords: Number[] = [] - @State message: string = 'please input password' - private patternLockController: PatternLockController = new PatternLockController() - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(this.message).textAlign(TextAlign.Center) - PatternLock(this.patternLockController) - .sideLength(150) - .circleRadius(7) - .pathStrokeWidth(17) - .backgroundColor(Color.White) - .autoReset(true) - .onPatternComplete((input: Array) => { - if (input == null || input == undefined || input.length < 5) { - this.message = 'The password length needs to be greater than 5.' - return - } - if (this.passwords.length > 0) { - if (this.passwords.toString() == input.toString()) { - this.passwords = input - this.message = 'Set password successfully: ' + this.passwords.toString() - } else { - this.message = 'Inconsistent passwords, please enter again.' - } - } else { - this.passwords = input - this.message = "Please enter again." - } - }) - Button('reset button').margin(30).onClick(() => { - this.patternLockController.reset() - this.passwords = [] - this.message = 'Please input password' - }) - }.width('100%').height('100%') - } -} -``` - -![patternlock](figures/patternlock.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md b/en/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md deleted file mode 100644 index 71a8900fb67f95f6a7cbe4cc53f4ade6c82706a0..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md +++ /dev/null @@ -1,323 +0,0 @@ -# PluginComponent - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> - This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -> -> - The APIs of this module are system APIs and cannot be called by third-party applications. - - -**<PluginComponent>** allows the UI provided by an external application to be displayed in the application. - - -## Required Permissions - -None - - -## Child Components - -None - - -## APIs - -PluginComponent(value: { template: PluginComponentTemplate, data: any }) - -Creates a **PluginComponent** to display the UI provided by an external application. - -- Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | value | {
template: PluginComponentTemplate,
data: KVObject
} | Yes | - | **template**: template of the **PluginComponent**, which is bound to the component defined by the provider.
**data**: data passed to the **PluginComponent** provider. | - -- PluginComponentTemplate parameters - | Name | Type | Description | - | -------- | -------- | -------- | - | source | string | Component template name. | - | ability | string | Name of the provider ability. | - - -## Events - - | Name | Description | -| -------- | -------- | -| onComplete(callback: () => void) | Triggered when the component loading is complete. | -| onError(callback: (info: { errcode: number, msg: string }) => void) | Triggered when an error occurs during component loading.
**errcode**: error code.
**msg**: error information. | - - -## PluginComponentManager - -Provides APIs for the **PluginComponent**. You can use these APIs to request components and data and send component templates and data. - - -## Modules to Import - - -``` -import pluginComponentManager from '@ohos.plugincomponent' -``` - - -## Required Permissions - -None - - -## push - -push(param: PushParameters, callback: AsyncCallback<void>): void - -Used by the component provider to send the component and data to the component consumer. - - -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | param | PushParameters | Yes | Information about the component consumer. For details, see description of PushParameters. | - | callback | AsyncCallback<void> | Yes | Asynchronous callback used to return the result. | - -- Description of PushParameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | want | Want | Yes | Ability information of the component consumer. | - | name | string | Yes | Component name. | - | data | KVObject | No | Component data value. | - | extraData | KVObject | No | Additional data value. | - -- Example - For details, see [APIs Called by Component Consumers](#apis-called-by-component-consumers). - - -## request - -request(param: RequestParameters, callback: AsyncCallback<RequestCallbackParameters>): void - -Used by the component consumer to request the component from the component provider. - -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | param | RequestParameters | Yes | Information about the component request. For details, see  description of RequestParameters. | - | callback | AsyncCallback**"push"**: The component provider pushes data to the component consumer.
**"request"**: The component consumer proactively requests data from the component provider. | - | callback | OnPushEventCallback \| OnRequestEventCallback | Yes | Callback used to return the result. For details, see description of callback. | - -- Description of callback - | Name | Type | Description | - | -------- | -------- | -------- | - | OnRequestEventCallback | (source: Want,
name: string,
data: KVObject ) =>RequestEventResult | Callback for the data request event.
**source**: ability information of the component requester.
**name**: name of the requested component.
**data**: additional data.
Return value: request data and result. | - | OnPushEventCallback | (source: Want,
template: PluginComponentTemplate,
data: KVObject,
extraData: KVObject
) => void | Callback used to receive the data pushed by the component provider.
**source**: ability information of the component provider.
**template**: component template.
**data**: component update data.
**extraData**: additional data. | - -- Description of RequestEventResult - | Name | Type | Description | - | -------- | -------- | -------- | - | template | string | Component name. | - | data | KVObject | Component data. | - | extraData | KVObject | Additional data. | - -- Example - For details, see [APIs Called by Component Consumers](#apis-called-by-component-consumers). - - -## Example - - -### Using the PluginComponent - - -``` -import plugin from "../../test/plugin_component.js" -import plugincomponent from '@ohos.plugincomponent' - -@Entry -@Component -struct PluginComponentExample { - @StorageLink("plugincount") plugincount: Object[] = [ - { source: 'plugincomponent1', ability: 'com.example.plugin' }, - { source: 'plugintemplate', ability: 'com.example.myapplication' }, - { source: 'plugintemplate', ability: 'com.example.myapplication' }] - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('Hello World') - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button('Push') - .fontSize(50) - .width(400) - .height(100) - .onClick(() => { - plugin.Push() - console.log("Button('Push')") - }) - .margin({ top: 20 }) - Button('Request1') - .fontSize(50) - .width(400) - .height(100) - .margin({ top: 20 }) - .onClick(() => { - plugin.Request1() - console.log("Button('Request1')") - }) - Button('Request2') - .fontSize(50) - .width(400) - .height(100) - .margin({ top: 20 }) - .onClick(() => { - plugin.Request2() - console.log("Button('Request2')") - }) - ForEach(this.plugincount, item => { - PluginComponent({ - template: { source: 'plugincomponent1', ability: 'com.example.plugin' }, - data: { 'countDownStartValue': 'new countDownStartValue' } - }).size({ width: 500, height: 100 }) - .onComplete(() => { - console.log("onComplete") - }) - .onError(({errcode, msg}) => { - console.log("onComplete" + errcode + ":" + msg) - }) - }) - } - .width('100%') - .height('100%') -} -``` - - -### APIs Called by Component Consumers - - -``` -import pluginComponentManager from '@ohos.plugincomponent' - -function onPushListener(source, template, data, extraData) { - console.log("onPushListener template.source=" + template.source) - var jsonObject = JSON.parse(data.componentTemplate.source) - console.log("request_callback1:source json object" + jsonObject) - var jsonArry = jsonObject.ExternalComponent - for (var i in jsonArry) { - console.log(jsonArry[i]) - } - console.log("onPushListener:source json object" + jsonObject) - console.log("onPushListener:source json string" + JSON.stringify(jsonObject)) - console.log("onPushListener template.ability=" + template.ability) - console.log("onPushListener data=" + JSON.stringify(data)) - console.log("onPushListener extraData=" + JSON.stringify(extraData)) -} - -export default { - //register listener - onListener() { - pluginComponentManager.on("push", onPushListener) - }, - Request() { - //The component consumer proactively sends data. - pluginComponentManager.request({ - want: { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", - }, - name: "plugintemplate", - data: { - "key_1": "plugin component test", - "key_2": 34234 - }, - jsonPath: "assets/js", - }, - (err, data) => { - console.log("request_callback1: componentTemplate.ability=" + data.componentTemplate.ability) - console.log("request_callback1: componentTemplate.source=" + data.componentTemplate.source) - var jsonObject = JSON.parse(data.componentTemplate.source) - console.log("request_callback1:source json object" + jsonObject) - var jsonArry = jsonObject.ExternalComponent - for (var i in jsonArry) { - console.log(jsonArry[i]) - } - console.log("request_callback1:source json string" + JSON.stringify(jsonObject)) - console.log("request_callback1: data=" + JSON.stringify(data.data)) - console.log("request_callback1: extraData=" + JSON.stringify(data.extraData)) - } - ) - } -} - -// Example of the component provider using the API -import pluginComponentManager from '@ohos.plugincomponent' - -function onRequestListener(source, name, data) { - console.log("onRequestListener name=" + name) - console.log("onRequestListener data=" + JSON.stringify(data)) - return { template: "plugintemplate", data: data } -} - -export default { - //register listener - onListener() { - pluginComponentManager.on("request", onRequestListener) - }, - Push() { - // The component provider proactively sends data. - pluginComponentManager.push( - { - want: { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", - }, - name: "plugintemplate", - data: { - "key_1": "plugin component test", - "key_2": 34234 - }, - extraData: { - "extra_str": "this is push event" - }, - jsonPath: "assets/js", - }, - (err, data) => { - console.log("push_callback1: componentTemplate.ability=" + data.componentTemplate.ability) - console.log("push_callback1: componentTemplate.source=" + data.componentTemplate.source) - console.log("push ok!") - } - ) - }, -} -``` 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 776fa7633bdff72b2669c2eeddbb292972a5760b..c033e9067e75e8cb83522d3ca11254e98162ca88 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 @@ -1,7 +1,6 @@ # Toggle - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. @@ -12,7 +11,7 @@ None ## Child Components -None +Not supported ## APIs @@ -20,42 +19,43 @@ None Toggle(options: { type: ToggleType, isOn?: boolean }) - Parameters - | Name | Type | Mandatory | Default Value | Description | + | Name| Type| Mandatory| Default Value| Description| | -------- | -------- | -------- | -------- | -------- | - | type | ToggleType | Yes | - | Type of the toggle. | - | isOn | boolean | No | false | Initial state of the toggle.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> If **isOn** is not set during component creation, the selected state can be retained during component reuse. If **isOn** is set, the selected state needs to be retained during component reuse after the selected state is recorded using an event method. | + | type | ToggleType | Yes| - | Type of the toggle.| + | isOn | boolean | No| false | Whether the toggle is turned on. The value **true** means that the toggle is turned on, and **false** means the opposite.| - ToggleType enums - | Name | Description | + | Name| Description| | -------- | -------- | - | Checkbox | A checkbox is provided. The text setting of the child component does not take effect. If the text setting is required, you can place the **<Text>** component and the current component in the layout component. | - | Button | A button is provided. If the text setting is available, the corresponding text content is displayed inside the button. | - | Switch | A switch is provided. The text setting of the child component does not take effect. If the text setting is required, you can place the **<Text>** component and the current component in the layout component. | + | Checkbox | A checkbox is provided, where the **\** settings can take effect only when it is placed with the current component in a layout component.
> **NOTE**

> The default value of the universal attribute [padding](ts-universal-attributes-size.md) is as follows:
{
 top: 14 vp,
 right: 6 vp,
 bottom: 14 vp,
 left: 6 vp
} | + | Button | A button is provided. The set text string, if any, will be displayed inside the button.| + | Switch | A switch is provided, where the **\** settings can take effect only when it is placed with the current component in a layout component.
> **NOTE**

> The default value of the universal attribute [padding](ts-universal-attributes-size.md) is as follows:
{
 top: 12 vp,
 right: 12 vp,
 bottom: 12 vp,
 left: 12 vp
} | ## Attributes - | Name | Type | Default Value | Description | +| Name| Parameter| Default Value| Description| | -------- | -------- | -------- | -------- | -| selectedColor | Color | - | Background color of the toggle when it is enabled. | -| switchPointColor | Color | - | Color of the circular slider of the **Switch** type.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> This attribute is valid only when type is set to **ToggleType.Switch**. | +| selectedColor | Color | - | Background color of the component when it is turned on.| +| switchPointColor | Color | - | Color of the circular slider when the component is of the **Switch** type.
> **NOTE**
> This attribute is valid only when **type** is set to **ToggleType.Switch**. | ## Events - | Name | Description | +| Name| Description| | -------- | -------- | -| onChange(callback: (isOn: boolean) => void) | Triggered when the switch status changes. | +| onChange(callback: (isOn: boolean) => void) | Triggered when the toggle status changes.| ## Example - -``` +```ts +// xxx.ets @Entry @Component struct ToggleExample { + build() { Column({ space: 10 }) { Text('type: Switch').fontSize(12).fontColor(0xcccccc).width('90%') diff --git a/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md b/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md index d6c76db8635c77b616b0fe09484abe45349d86a6..5e13044ead75c6736820487408d519dcc49ffb87 100644 --- a/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md +++ b/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md @@ -1,11 +1,11 @@ # CanvasRenderingContext2D -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -Use **RenderingContext** to draw rectangles, text, images, and other objects on a canvas. +The **\** component is used to draw rectangles, text, images, and other objects on a canvas. ## APIs @@ -15,7 +15,7 @@ CanvasRenderingContext2D(setting: RenderingContextSetting) - Parameters | Name | Type | Mandatory | Default Value | Description | | ------- | ---------------------------------------- | --------- | ------------- | ----------------------------- | - | setting | [RenderingContextSettings](#renderingcontextsettings) | Yes | - | See RenderingContextSettings. | + | setting | [RenderingContextSettings](#renderingcontextsettings) | Yes | - | See [RenderingContextSettings](#renderingcontextsettings). | ### RenderingContextSettings @@ -34,15 +34,15 @@ Configures the settings of a **CanvasRenderingContext2D** object, including whet | Name | Type | Default Value | Description | | ---------------------------------------- | ---------------------------------------- | ------------------------------- | ---------------------------------------- | -| [fillStyle](#fillstyle) | <color> \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | - | Style used to fill an area.
- When the type is **<color>**, this attribute indicates the fill color.
- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the [createLinearGradient](#createlineargradient) method.
- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the [createPattern](#createpattern) method. | +| [fillStyle](#fillstyle) | <color> \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | - | Style used to fill an area.
- When the type is **<color>**, this attribute indicates the fill color.
- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the [createLinearGradient](#createlineargradient) method.
- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the [createPattern](#createpattern) method. | | [lineWidth](#linewidth) | number | - | Line width. | -| [strokeStyle](#strokestyle) | <color> \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | - | Stroke style.
- When the type is **<color>**, this attribute indicates the stroke color.
- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the [createLinearGradient](#createlineargradient) method.
- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the [createPattern](#createpattern) method. | -| [lineCap](#linecap) | string | 'butt' | Style of the line endpoints. The options are as follows:
- **'butt'**: The endpoints of the line are squared off.
- **'round'**: The endpoints of the line are rounded.
- **'square'**: The endpoints of the line are squared off by adding a box with an equal width and half the height of the line's thickness. | -| [lineJoin](#linejoin) | string | 'miter' | Style of the shape used to join line segments. The options are as follows:
- **'round'**: The shape used to join line segments is a rounded corner with the radius equal to the line width.
- **'bevel'**: The shape used to join line segments is a beveled corner. The rectangular corner of each line is independent.
- **'miter'**: The shape used to join line segments is a mitered corner. The corner is formed by extending the outside edges of the lines until they meet. You can adjust the effect of this attribute using **miterLimit**. | +| [strokeStyle](#strokestyle) | <color> \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | - | Stroke style.
- When the type is **<color>**, this attribute indicates the stroke color.
- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the [createLinearGradient](#createlineargradient) method.
- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the [createPattern](#createpattern) method. | +| [lineCap](#linecap) | string | 'butt' | Style of the line endpoints. The options are as follows:
- **'butt'**: The endpoints of the line are squared off.
- **'round'**: The endpoints of the line are rounded.
- **'square'**: The endpoints of the line are squared off by adding a box with an equal width and half the height of the line's thickness. | +| [lineJoin](#linejoin) | string | 'miter' | Style of the shape used to join line segments. The options are as follows:
- **'round'**: The shape used to join line segments is a rounded corner with the radius equal to the line width.
- **'bevel'**: The shape used to join line segments is a beveled corner. The rectangular corner of each line is independent.
- **'miter'**: The shape used to join line segments is a mitered corner. The corner is formed by extending the outside edges of the lines until they meet. You can adjust the effect of this attribute using **miterLimit**. | | [miterLimit](#miterlimit) | number | 10 | Maximum miter length. The miter length is the distance between the inner corner and the outer corner where two lines meet. | -| [font](#font) | string | 'normal normal 14px sans-serif' | Font style.
Syntax: ctx.font='font-size font-family'
- (Optional) **font-size**: font size and row height. The unit can only be px.
- (Optional) **font-family**: font family.
Syntax: ctx.font='font-style font-weight font-size font-family'
- (Optional) **font-style**: font style. Available values are **'normal'** and **'italic'**.
- (Optional) **font-weight**: font weight. Available values are as follows: **'normal'**, **'bold'**, **'bolder'**, **'lighter'**, **100**, **200**, **300**, **400**, **500**, **600**, **700**, **800**, **900**
- (Optional) **font-size**: font size and row height. The unit can only be px.
- (Optional) **font-family**: font family. Available values are **'sans-serif'**, **'serif'**, and **'monospace'**. | -| [textAlign](#textalign) | string | 'left' | Text alignment mode. Available values are as follows:
- **'left'**: The text is left-aligned.
- **'right'**: The text is right-aligned.
- **'center'**: The text is center-aligned.
- **'start'**: The text is aligned with the start bound.
- **'end'**: The text is aligned with the end bound.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> In the **ltr** layout mode, the value **'start'** equals **'left'**. In the **rtl** layout mode, the value **'start'** equals **'right'**. | -| [textBaseline](#textbaseline) | string | 'alphabetic' | Horizontal alignment mode of text. Available values are as follows:
- **'alphabetic'**: The text baseline is the normal alphabetic baseline.
- **'top'**: The text baseline is on the top of the text bounding box.
- **'hanging'**: The text baseline is a hanging baseline over the text.
- **'middle'**: The text baseline is in the middle of the text bounding box.
- **'ideographic'**: The text baseline is the ideographic baseline. If a character exceeds the alphabetic baseline, the ideographic baseline is located at the bottom of the excess character.
- **'bottom'**: The text baseline is at the bottom of the text bounding box. Its difference from the ideographic baseline is that the ideographic baseline does not consider letters in the next line. | +| [font](#font) | string | 'normal normal 14px sans-serif' | Font style.
Syntax: ctx.font='font-size font-family'
- (Optional) **font-size**: font size and row height. The unit can only be px.
- (Optional) **font-family**: font family.
Syntax: ctx.font='font-style font-weight font-size font-family'
- (Optional) **font-style**: font style. Available values are **'normal'** and **'italic'**.
- (Optional) **font-weight**: font weight. Available values are as follows: **'normal'**, **'bold'**, **'bolder'**, **'lighter'**, **100**, **200**, **300**, **400**, **500**, **600**, **700**, **800**, **900**
- (Optional) **font-size**: font size and row height. The unit can only be px.
- (Optional) **font-family**: font family. Available values are **'sans-serif'**, **'serif'**, and **'monospace'**. | +| [textAlign](#textalign) | string | 'left' | Text alignment mode. Available values are as follows:
- **'left'**: The text is left-aligned.
- **'right'**: The text is right-aligned.
- **'center'**: The text is center-aligned.
- **'start'**: The text is aligned with the start bound.
- **'end'**: The text is aligned with the end bound.
**NOTE**
In the **ltr** layout mode, the value **'start'** equals **'left'**. In the **rtl** layout mode, the value **'start'** equals **'right'**. | +| [textBaseline](#textbaseline) | string | 'alphabetic' | Horizontal alignment mode of text. Available values are as follows:
- **'alphabetic'**: The text baseline is the normal alphabetic baseline.
- **'top'**: The text baseline is on the top of the text bounding box.
- **'hanging'**: The text baseline is a hanging baseline over the text.
- **'middle'**: The text baseline is in the middle of the text bounding box.
- **'ideographic'**: The text baseline is the ideographic baseline. If a character exceeds the alphabetic baseline, the ideographic baseline is located at the bottom of the excess character.
- **'bottom'**: The text baseline is at the bottom of the text bounding box. Its difference from the ideographic baseline is that the ideographic baseline does not consider letters in the next line. | | [globalAlpha](#globalalpha) | number | - | Opacity. **0.0**: completely transparent; **1.0**: completely opaque. | | [lineDashOffset](#linedashoffset) | number | 0.0 | Offset of the dashed line. The precision is float. | | [globalCompositeOperation](#globalcompositeoperation) | string | 'source-over' | Composition operation type. Available values are as follows: **'source-over'**, **'source-atop'**, **'source-in'**, **'source-out'**, **'destination-over'**, **'destination-atop'**, **'destination-in'**, **'destination-out'**, **'lighter'**, **'copy'**, and **'xor'**. | @@ -53,14 +53,14 @@ Configures the settings of a **CanvasRenderingContext2D** object, including whet | [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | true | Whether to adjust the image smoothness during image drawing. The value **true** means to enable this feature, and **false** means the opposite. | | imageSmoothingQuality | string | 'low' | Image smoothness. The value can be **'low'**, **'medium'**, or **'high'**. | -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
> The value of the **<color>** type can be in 'rgb(255, 255, 255)', 'rgba(255, 255, 255, 1.0)', or '\#FFFFFF' format. ### fillStyle - -``` +```ts +// xxx.ets @Entry @Component struct FillStyleExample { @@ -89,8 +89,8 @@ struct FillStyleExample { ### lineWidth - -``` +```ts +// xxx.ets @Entry @Component struct LineWidthExample { @@ -119,8 +119,8 @@ struct LineWidthExample { ### strokeStyle - -``` +```ts +// xxx.ets @Entry @Component struct StrokeStyleExample { @@ -151,8 +151,8 @@ struct StrokeStyleExample { ### lineCap - -``` +```ts +// xxx.ets @Entry @Component struct LineCapExample { @@ -185,8 +185,8 @@ struct LineCapExample { ### lineJoin - -``` +```ts +// xxx.ets @Entry @Component struct LineJoinExample { @@ -220,8 +220,8 @@ struct LineJoinExample { ### miterLimit - -``` +```ts +// xxx.ets @Entry @Component struct MiterLimit { @@ -255,8 +255,8 @@ struct MiterLimit { ### font - -``` +```ts +// xxx.ets @Entry @Component struct Font { @@ -285,8 +285,8 @@ struct Font { ### textAlign - -``` +```ts +// xxx.ets @Entry @Component struct CanvasExample { @@ -330,8 +330,8 @@ struct CanvasExample { ### textBaseline - -``` +```ts +// xxx.ets @Entry @Component struct TextBaseline { @@ -375,8 +375,8 @@ struct TextBaseline { ### globalAlpha - -``` +```ts +// xxx.ets @Entry @Component struct GlobalAlpha { @@ -408,8 +408,8 @@ struct GlobalAlpha { ### lineDashOffset - -``` +```ts +// xxx.ets @Entry @Component struct LineDashOffset { @@ -453,8 +453,8 @@ struct LineDashOffset { | copy | Displays the new drawing and neglects the existing drawing. | | xor | Combines the new drawing and existing drawing using the XOR operation. | - -``` +```ts +// xxx.ets @Entry @Component struct GlobalCompositeOperation { @@ -491,8 +491,8 @@ struct GlobalCompositeOperation { ### shadowBlur - -``` +```ts +// xxx.ets @Entry @Component struct ShadowBlur { @@ -523,8 +523,8 @@ struct ShadowBlur { ### shadowColor - -``` +```ts +// xxx.ets @Entry @Component struct ShadowColor { @@ -555,8 +555,8 @@ struct ShadowColor { ### shadowOffsetX - -``` +```ts +// xxx.ets @Entry @Component struct ShadowOffsetX { @@ -588,8 +588,8 @@ struct ShadowOffsetX { ### shadowOffsetY - -``` +```ts +// xxx.ets @Entry @Component struct ShadowOffsetY { @@ -620,8 +620,8 @@ struct ShadowOffsetY { ### imageSmoothingEnabled - -``` +```ts +// xxx.ets @Entry @Component struct ImageSmoothingEnabled { @@ -668,7 +668,8 @@ Fills a rectangle on the canvas. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct FillRect { @@ -710,7 +711,8 @@ Draws an outlined rectangle on the canvas. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct StrokeRect { @@ -751,7 +753,8 @@ Clears the content in a rectangle on the canvas. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct ClearRect { @@ -793,7 +796,8 @@ Draws filled text on the canvas. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct FillText { @@ -834,7 +838,8 @@ Draws a text stroke on the canvas. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct StrokeText { @@ -883,7 +888,8 @@ Returns a **TextMetrics** object used to obtain the width of specified text. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct MeasureText { @@ -923,7 +929,8 @@ Strokes a path. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct Stroke { @@ -960,7 +967,8 @@ Creates a drawing path. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct BeginPath { @@ -1005,7 +1013,8 @@ Moves a drawing path to a target position on the canvas. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct MoveTo { @@ -1048,7 +1057,8 @@ Connects the current point to a target position using a straight line. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct LineTo { @@ -1085,7 +1095,8 @@ Draws a closed path. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct ClosePath { @@ -1130,7 +1141,8 @@ Creates a pattern for image filling based on a specified source image and repeti - Example - ``` + ```ts + // xxx.ets @Entry @Component struct CreatePattern { @@ -1177,7 +1189,8 @@ Draws a cubic bezier curve on the canvas. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct BezierCurveTo { @@ -1222,7 +1235,8 @@ Draws a quadratic curve on the canvas. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct QuadraticCurveTo { @@ -1313,7 +1327,8 @@ Draws an arc based on the radius and points on the arc. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct ArcTo { @@ -1362,7 +1377,8 @@ Draws an ellipse in the specified rectangular region. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct CanvasExample { @@ -1406,7 +1422,8 @@ Creates a rectangle. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct CanvasExample { @@ -1441,7 +1458,8 @@ Fills the area inside a closed path. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct Fill { @@ -1476,7 +1494,8 @@ Sets the current path to a clipping path. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct Clip { @@ -1519,7 +1538,8 @@ Rotates a canvas clockwise around its coordinate axes. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct Rotate { @@ -1560,7 +1580,8 @@ Scales a canvas based on scale factors. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct Scale { @@ -1594,7 +1615,7 @@ transform(scaleX: number, skewX: number, skewY: number, scaleY: number, translat Defines a transformation matrix. To transform a graph, you only need to set parameters of the matrix. The coordinates of the graph are multiplied by the matrix values to obtain new coordinates of the transformed graph. You can use the matrix to implement multiple transform effects. -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
> The following formulas calculate coordinates of the transformed graph. **x** and **y** represent coordinates before transformation, and **x'** and **y'** represent coordinates after transformation. > > - x' = scaleX \* x + skewY \* y + translateX @@ -1613,7 +1634,8 @@ Defines a transformation matrix. To transform a graph, you only need to set para - Example - ``` + ```ts + // xxx.ets @Entry @Component struct Transform { @@ -1664,7 +1686,8 @@ Resets the existing transformation matrix and creates a new transformation matri - Example - ``` + ```ts + // xxx.ets @Entry @Component struct SetTransform { @@ -1708,7 +1731,8 @@ Moves the origin of the coordinate system. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct Translate { @@ -1738,18 +1762,18 @@ Moves the origin of the coordinate system. ### drawImage -drawImage(image: ImageBitmap, dx: number, dy: number): void +drawImage(image: ImageBitmap | PixelMap, dx: number, dy: number): void -drawImage(image: ImageBitmap, dx: number, dy: number, dWidth: number, dHeight: number): void +drawImage(image: ImageBitmap | PixelMap, dx: number, dy: number, dWidth: number, dHeight: number): void -drawImage(image: ImageBitmap, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number):void +drawImage(image: ImageBitmap | PixelMap, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number):void Draws an image. - Parameters | Name | Type | Mandatory | Default Value | Description | | ------- | ---------------------------------------- | --------- | ------------- | ---------------------------------------- | - | image | [ImageBitmap](ts-components-canvas-imagebitmap.md) | Yes | null | Image resource. For details, see ImageBitmap | + | image | [ImageBitmap](ts-components-canvas-imagebitmap.md) or [PixelMap](../apis/js-apis-image.md#pixelmap7) | Yes | null | Image resource. For details, see ImageBitmap or PixelMap. | | sx | number | No | 0 | X-coordinate of the upper left corner of the rectangle used to crop the source image. | | sy | number | No | 0 | Y-coordinate of the upper left corner of the rectangle used to crop the source image. | | sWidth | number | No | 0 | Target width to crop the source image. | @@ -1762,7 +1786,8 @@ Draws an image. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct ImageExample { @@ -1812,12 +1837,24 @@ Creates an **ImageData** object. For details, see [ImageData](ts-components-canv | --------- | ------ | --------- | ------------- | ---------------------------------------- | | imagedata | Object | Yes | null | **ImageData** object with the same width and height copied from the original **ImageData** object. | +### getPixelMap + +getPixelMap(sx: number, sy: number, sw: number, sh: number): PixelMap + +Obtains the **[PixelMap](../apis/js-apis-image.md#pixelmap7)** object created with the pixels within the specified area on the canvas. +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | ---- | ---- | --------------- | + | sx | number | Yes | 0 | X-coordinate of the upper left corner of the output area.| + | sy | number | Yes | 0 | Y-coordinate of the upper left corner of the output area.| + | sw | number | Yes | 0 | Width of the output area. | + | sh | number | Yes | 0 | Height of the output area. | ### getImageData getImageData(sx: number, sy: number, sw: number, sh: number): Object - Creates an [ImageData](ts-components-canvas-imagebitmap.md) object with pixels in the specified area on the canvas. +Obtains the **[ImageData](ts-components-canvas-imagebitmap.md)** object created with the pixels within the specified area on the canvas. - Parameters | Name | Type | Mandatory | Default Value | Description | | ---- | ------ | --------- | ------------- | ---------------------------------------- | @@ -1831,7 +1868,7 @@ getImageData(sx: number, sy: number, sw: number, sh: number): Object putImageData(imageData: Object, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void -Puts the [ImageData](ts-components-canvas-imagebitmap.md) onto a rectangular area on the canvas. +Puts the **[ImageData](ts-components-canvas-imagebitmap.md)** onto a rectangular area on the canvas. - Parameters | Name | Type | Mandatory | Default Value | Description | @@ -1846,7 +1883,8 @@ Puts the [ImageData](ts-components-canvas-imagebitmap.md) onto a rectangular are - Example - ``` + ```ts + // xxx.ets @Entry @Component struct PutImageData { @@ -1887,7 +1925,8 @@ Restores the saved drawing context. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct CanvasExample { @@ -1919,7 +1958,8 @@ Saves the current drawing context. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct CanvasExample { @@ -1959,7 +1999,8 @@ Creates a linear gradient. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct CreateLinearGradient { @@ -2008,7 +2049,8 @@ Creates a linear gradient. - Example - ``` + ```ts + // xxx.ets @Entry @Component struct CreateRadialGradient { diff --git a/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md b/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md index 1395a2cf8dbf0ed99d20c74ab65d211df9f346c2..6e120cd42deb2de2e7388b56aaa0b5eef5ec799a 100644 --- a/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md +++ b/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md @@ -1,9 +1,7 @@ # OffscreenCanvasRenderingContext2D -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> -> The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. +> **NOTE**
The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. Use **OffscreenCanvasRenderingContext2D** to draw rectangles, images, and text offscreen onto a canvas. Drawing offscreen onto a canvas is a process where content to draw onto the canvas is first drawn in the buffer, and then converted into a picture, and finally the picture is drawn on the canvas. This process increases the drawing efficiency. @@ -44,14 +42,15 @@ OffscreenCanvasRenderingContext2D(width: number, height: number, setting: Render | [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | true | Whether to adjust the image smoothness during image drawing. The value **true** means to enable this feature, and **false** means the opposite. | | imageSmoothingQuality | string | 'low' | Image smoothness. The value can be **'low'**, **'medium'**, or **'high'**. | -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE** > The value of the **<color>** type can be in 'rgb(255, 255, 255)', 'rgba(255, 255, 255, 1.0)', or '\#FFFFFF' format. ### fillStyle -``` +```ts +// xxx.ets @Entry @Component struct FillStyleExample { @@ -84,7 +83,8 @@ struct FillStyleExample { ### lineWidth -``` +```ts +// xxx.ets @Entry @Component struct LineWidthExample { @@ -117,7 +117,8 @@ struct LineWidthExample { ### strokeStyle -``` +```ts +// xxx.ets @Entry @Component struct StrokeStyleExample { @@ -152,7 +153,8 @@ struct StrokeStyleExample { ### lineCap -``` +```ts +// xxx.ets @Entry @Component struct LineCapExample { @@ -189,7 +191,8 @@ struct LineCapExample { ### lineJoin -``` +```ts +// xxx.ets @Entry @Component struct LineJoinExample { @@ -227,7 +230,8 @@ struct LineJoinExample { ### miterLimit -``` +```ts +// xxx.ets @Entry @Component struct MiterLimit { @@ -265,7 +269,8 @@ struct MiterLimit { ### font -``` +```ts +// xxx.ets @Entry @Component struct Font { @@ -298,7 +303,8 @@ struct Font { ### textAlign -``` +```ts +// xxx.ets @Entry @Component struct CanvasExample { @@ -346,7 +352,8 @@ struct CanvasExample { ### textBaseline -``` +```ts +// xxx.ets @Entry @Component struct TextBaseline { @@ -394,7 +401,8 @@ struct TextBaseline { ### globalAlpha -``` +```ts +// xxx.ets @Entry @Component struct GlobalAlpha { @@ -430,7 +438,8 @@ struct GlobalAlpha { ### lineDashOffset -``` +```ts +// xxx.ets @Entry @Component struct LineDashOffset { @@ -478,7 +487,8 @@ struct LineDashOffset { | xor | Combines the new drawing and existing drawing using the XOR operation. | -``` +```ts +// xxx.ets @Entry @Component struct GlobalCompositeOperation { @@ -519,7 +529,8 @@ struct GlobalCompositeOperation { ### shadowBlur -``` +```ts +// xxx.ets @Entry @Component struct ShadowBlur { @@ -554,7 +565,8 @@ struct ShadowBlur { ### shadowColor -``` +```ts +// xxx.ets @Entry @Component struct ShadowColor { @@ -590,7 +602,8 @@ struct ShadowColor { ### shadowOffsetX -``` +```ts +// xxx.ets @Entry @Component struct ShadowOffsetX { @@ -626,7 +639,8 @@ struct ShadowOffsetX { ### shadowOffsetY -``` +```ts +// xxx.ets @Entry @Component struct ShadowOffsetY { @@ -662,7 +676,8 @@ struct ShadowOffsetY { ### imageSmoothingEnabled -``` +```ts +// xxx.ets @Entry @Component struct ImageSmoothingEnabled { @@ -712,7 +727,8 @@ Fills a rectangle on the canvas. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct FillRect { @@ -801,7 +817,8 @@ Clears the content in a rectangle on the canvas. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct ClearRect { @@ -846,7 +863,8 @@ Draws filled text on the canvas. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct FillText { @@ -942,7 +960,8 @@ Returns a **TextMetrics** object used to obtain the width of specified text. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct MeasureText { @@ -1024,7 +1043,8 @@ Creates a drawing path. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct BeginPath { @@ -1071,7 +1091,8 @@ Moves a drawing path to a target position on the canvas. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct MoveTo { @@ -1116,7 +1137,8 @@ Connects the current point to a target position using a straight line. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct LineTo { @@ -1155,7 +1177,8 @@ Draws a closed path. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct ClosePath { @@ -1202,7 +1225,8 @@ Creates a pattern for image filling based on a specified source image and repeti - Example - ``` + ```ts +// xxx.ets @Entry @Component struct CreatePattern { @@ -1251,7 +1275,8 @@ Draws a cubic bezier curve on the canvas. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct BezierCurveTo { @@ -1298,7 +1323,8 @@ Draws a quadratic curve on the canvas. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct QuadraticCurveTo { @@ -1347,7 +1373,8 @@ Draws an arc on the canvas. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct Arc { @@ -1394,7 +1421,8 @@ Draws an arc based on the radius and points on the arc. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct ArcTo { @@ -1445,7 +1473,8 @@ Draws an ellipse in the specified rectangular region. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct CanvasExample { @@ -1491,7 +1520,8 @@ Creates a rectangle. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct CanvasExample { @@ -1528,7 +1558,8 @@ Fills the area inside a closed path. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct Fill { @@ -1565,7 +1596,8 @@ Sets the current path to a clipping path. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct Clip { @@ -1610,7 +1642,8 @@ Rotates a canvas clockwise around its coordinate axes. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct Rotate { @@ -1653,7 +1686,8 @@ Scales a canvas based on scale factors. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct Scale { @@ -1689,7 +1723,7 @@ transform(scaleX: number, skewX: number, skewY: number, scaleY: number, translat Defines a transformation matrix. To transform a graph, you only need to set parameters of the matrix. The coordinates of the graph are multiplied by the matrix values to obtain new coordinates of the transformed graph. You can use the matrix to implement multiple transform effects. -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE** > The following formulas calculate coordinates of the transformed graph. **x** and **y** represent coordinates before transformation, and **x'** and **y'** represent coordinates after transformation. > > - x' = scaleX \* x + skewY \* y + translateX @@ -1708,7 +1742,8 @@ Defines a transformation matrix. To transform a graph, you only need to set para - Example - ``` + ```ts +// xxx.ets @Entry @Component struct Transform { @@ -1761,7 +1796,8 @@ Resets the existing transformation matrix and creates a new transformation matri - Example - ``` + ```ts +// xxx.ets @Entry @Component struct SetTransform { @@ -1807,7 +1843,8 @@ Moves the origin of the coordinate system. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct Translate { @@ -1839,18 +1876,18 @@ Moves the origin of the coordinate system. ### drawImage -drawImage(image: ImageBitmap, dx: number, dy: number): void +drawImage(image: ImageBitmap | PixelMap, dx: number, dy: number): void -drawImage(image: ImageBitmap, dx: number, dy: number, dWidth: number, dHeight: number): void +drawImage(image: ImageBitmap | PixelMap, dx: number, dy: number, dWidth: number, dHeight: number): void -drawImage(image: ImageBitmap, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number):void +drawImage(image: ImageBitmap | PixelMap, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number):void Draws an image. - Parameters | Name | Type | Mandatory | Default Value | Description | | ------- | ---------------------------------------- | --------- | ------------- | ---------------------------------------- | - | image | [ImageBitmap](ts-components-canvas-imagebitmap.md) | Yes | null | Image resource. For details, see ImageBitmap. | + | image | [ImageBitmap](ts-components-canvas-imagebitmap.md) or [PixelMap](../apis/js-apis-image.md#pixelmap7) | Yes | null | Image resource. For details, see ImageBitmap. | | sx | number | No | 0 | X-coordinate of the upper left corner of the rectangle used to crop the source image. | | sy | number | No | 0 | Y-coordinate of the upper left corner of the rectangle used to crop the source image. | | sWidth | number | No | 0 | Target width to crop the source image. | @@ -1863,7 +1900,8 @@ Draws an image. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct Index { @@ -1916,12 +1954,24 @@ Creates an **ImageData** object by copying an existing **ImageData** object. For | --------- | ---------------------------------------- | --------- | ------------- | ----------------------------- | | imagedata | [ImageData](ts-components-canvas-imagebitmap.md) | Yes | null | **ImageData** object to copy. | +### getPixelMap + +getPixelMap(sx: number, sy: number, sw: number, sh: number): PixelMap + +Obtains the **[PixelMap](../apis/js-apis-image.md#pixelmap7)** object created with the pixels within the specified area on the canvas. +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | sx | number | Yes | 0 | X-coordinate of the upper left corner of the output area. | + | sy | number | Yes | 0 | Y-coordinate of the upper left corner of the output area. | + | sw | number | Yes | 0 | Width of the output area. | + | sh | number | Yes | 0 | Height of the output area. | ### getImageData getImageData(sx: number, sy: number, sw: number, sh: number): Object -Creates an [ImageData](ts-components-canvas-imagebitmap.md) object with pixels in the specified area on the canvas. +Obtains the **[ImageData](ts-components-canvas-imagebitmap.md)** object created with the pixels within the specified area on the canvas. - Parameters | Name | Type | Mandatory | Default Value | Description | @@ -1951,7 +2001,8 @@ Puts the [ImageData](ts-components-canvas-imagebitmap.md) onto a rectangular are - Example - ``` + ```ts +// xxx.ets @Entry @Component struct PutImageData { @@ -1994,7 +2045,8 @@ Restores the saved drawing context. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct CanvasExample { @@ -2028,7 +2080,8 @@ Saves the current drawing context. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct CanvasExample { @@ -2070,7 +2123,8 @@ Creates a linear gradient. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct CreateLinearGradient { @@ -2122,7 +2176,8 @@ Creates a linear gradient. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct CreateRadialGradient { diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md index e7b2846ba9c5d98806745dcfc25a8c3234ce43bc..5efa02368bf4eb70bca06a7e6a71473853692571 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md @@ -1,7 +1,7 @@ # Image Effect Configuration -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE** > This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. @@ -25,7 +25,7 @@ None | invert | number | 0 | Inverts the input image. The input parameter is an image inversion ratio. The value **1** indicates complete inversion. The value **0** indicates that the image does not change. The unit is percentage. | | colorBlend 8+ | Color | - | Adds the color blend effect to the current component. The input parameter is the blended color. | | sepia | number | 0 | Converts the image color to sepia. The input parameter is an image inversion ratio. The value **1** indicates the image is completely sepia. The value **0** indicates that the image does not change. The unit is percentage. | -| hueRotate | Angle | 0deg | Adds the hue rotation effect to the current component. The input parameter is a rotation angle. If the input value is **0deg**, the image does not change (because the default rotation angle is **0deg**). The input parameter does not have the maximum value. If the value exceeds **360deg**, the image is rotated one ore more circles. | +| hueRotate | number \| string | '0deg' |Adds the hue rotation effect to the current component. The input parameter is a rotation angle. If the input value is **0deg**, the image does not change (because the default rotation angle is **0deg**). The input parameter does not have the maximum value. If the value exceeds **360deg**, the image is rotated for one more circle. In other words, the value **370deg** has the same effect as **10deg**.| ## Example diff --git a/en/application-dev/website.md b/en/application-dev/website.md index d7d839acb898346b720fd267a67557eed65e6e04..e9a6aae5430307592e968ac3b8f83f5b814a101b 100644 --- a/en/application-dev/website.md +++ b/en/application-dev/website.md @@ -462,8 +462,6 @@ - [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md) - [Marquee](reference/arkui-ts/ts-basic-components-marquee.md) - [Navigation](reference/arkui-ts/ts-basic-components-navigation.md) - - [PatternLock](reference/arkui-ts/ts-basic-components-patternlock.md) - - [PluginComponent](reference/arkui-ts/ts-basic-components-plugincomponent.md) - [Progress](reference/arkui-ts/ts-basic-components-progress.md) - [QRCode](reference/arkui-ts/ts-basic-components-qrcode.md) - [Radio](reference/arkui-ts/ts-basic-components-radio.md) @@ -706,7 +704,7 @@ - [@ohos.usb](reference/apis/js-apis-usb.md) - [@ohos.vibrator](reference/apis/js-apis-vibrator.md) - Account Management - + - [@ohos.account.appAccount](reference/apis/js-apis-appAccount.md) - [@ohos.account.distributedAccount](reference/apis/js-apis-distributed-account.md) - [@ohos.account.osAccount](reference/apis/js-apis-osAccount.md) diff --git a/zh-cn/application-dev/database/database-relational-guidelines.md b/zh-cn/application-dev/database/database-relational-guidelines.md index c1ba4f473c01d50d2e0bd3c071ae9187132e0045..9d6964bfcd54eee6618ebb6cc4c7f1d1b1a1ef7c 100644 --- a/zh-cn/application-dev/database/database-relational-guidelines.md +++ b/zh-cn/application-dev/database/database-relational-guidelines.md @@ -203,7 +203,7 @@ const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"; const STORE_CONFIG = {name: "rdbstore.db",} data_rdb.getRdbStore(STORE_CONFIG, 1, function (err, rdbStore) { - rdbStore.executeSql(SQL_CREATE_TABLE) + rdbStore.executeSql(CREATE_TABLE_TEST ) console.info('create table done.') }) ``` diff --git a/zh-cn/application-dev/device/device-location-geocoding.md b/zh-cn/application-dev/device/device-location-geocoding.md index ef55a0bf810ad992766a51b577276f46293cb39e..47de33675805b6e659f6b92b0254b5c41cf88d7c 100644 --- a/zh-cn/application-dev/device/device-location-geocoding.md +++ b/zh-cn/application-dev/device/device-location-geocoding.md @@ -45,7 +45,7 @@ }); ``` - 参考接口API说明,应用可以获得与此坐标匹配的GeoAddress列表,应用可以根据实际使用需求,读取相应的参数数据。 + 参考接口API说明[位置服务](../reference/apis/js-apis-geolocation.md),应用可以获得与此坐标匹配的GeoAddress列表,应用可以根据实际使用需求,读取相应的参数数据。 - 调用getAddressesFromLocationName位置描述转化坐标。 ``` @@ -55,6 +55,6 @@ }); ``` - 参考接口API说明,应用可以获得与位置描述相匹配的GeoAddress列表,其中包含对应的坐标数据,请参考API使用。 + 参考接口API说明[位置服务](../reference/apis/js-apis-geolocation.md),应用可以获得与位置描述相匹配的GeoAddress列表,其中包含对应的坐标数据,请参考API使用。 如果需要查询的位置描述可能出现多地重名的请求,可以设置GeoCodeRequest,通过设置一个经纬度范围,以高效地获取期望的准确结果。 diff --git a/zh-cn/application-dev/device/usb-guidelines.md b/zh-cn/application-dev/device/usb-guidelines.md index 97dbe7ec09977f5491f10846a64f9708e745e490..a4b96c2735fcca119917c6c1fcd24e892ac4a3a0 100644 --- a/zh-cn/application-dev/device/usb-guidelines.md +++ b/zh-cn/application-dev/device/usb-guidelines.md @@ -24,7 +24,7 @@ USB类开放能力如下,具体请查阅[API参考文档](../reference/apis/js | setConfiguration(pipe: USBDevicePipe, config: USBConfig): number | 设置设备的配置。 | | setInterface(pipe: USBDevicePipe, iface: USBInterface): number | 设置设备的接口。 | | claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number | 获取接口。 | -| function bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise<number> | 批量传输。 | +|bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise<number> | 批量传输。 | | closePipe(pipe: USBDevicePipe): number | 关闭设备消息控制通道。 | | releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | 释放接口。 | | getFileDescriptor(pipe: USBDevicePipe): number | 获取文件描述符。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-audio.md b/zh-cn/application-dev/reference/apis/js-apis-audio.md index cb5b35bf7c5c65b22aecfa855adb5a96d2421579..3820d4c5332d5efa0e3d10b88e04e4ad11f9c5b8 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -1,9 +1,6 @@ # 音频管理 -> **说明:** -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> -> API Version 9当前为Canary版本,仅供试用,不保证接口可稳定调用。 +音频管理提供管理音频的一些基础能力,包括对音频音量、音频设备的管理,以及对音频数据的采集和渲染等。 该模块提供以下音频相关的常用功能: @@ -11,6 +8,11 @@ - [AudioRenderer](#audiorenderer8):音频渲染,用于播放PCM(Pulse Code Modulation)音频数据。 - [AudioCapturer](#audiocapturer8):音频采集,用于录制PCM音频数据。 +> **说明:** +> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +> API Version 9当前为Canary版本,仅供试用,不保证接口可稳定调用。 + ## 导入模块 ``` @@ -551,7 +553,7 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => { 音量改变时,应用接收的事件。 -此接口为系统接口,三方应用不支持。 +此接口为系统接口,三方应用不支持调用。 **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Volume @@ -626,8 +628,8 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => { | 名称 | 默认值 | 描述 | | :--------------------- | :----- | :-------------------------------------------- | | AUDIO_SCENE_DEFAULT | 0 | 默认音频场景。 | -| AUDIO_SCENE_RINGING | 1 | 响铃模式。
系统接口,三方应用不支持调用。 | -| AUDIO_SCENE_PHONE_CALL | 2 | 电话模式。
系统接口,三方应用不支持调用。 | +| AUDIO_SCENE_RINGING | 1 | 响铃模式。
此接口为系统接口,三方应用不支持调用。 | +| AUDIO_SCENE_PHONE_CALL | 2 | 电话模式。
此接口为系统接口,三方应用不支持调用。 | | AUDIO_SCENE_VOICE_CHAT | 3 | 语音聊天模式。 | ## AudioManager @@ -640,6 +642,8 @@ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&l 设置指定流的音量,使用callback方式异步返回结果。 +**需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY + **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** @@ -668,6 +672,8 @@ setVolume(volumeType: AudioVolumeType, volume: number): Promise<void> 设置指定流的音量,使用Promise方式异步返回结果。 +**需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY + **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** @@ -1032,6 +1038,8 @@ setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void 设置铃声模式,使用callback方式异步返回结果。 +**需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY + **系统能力:** SystemCapability.Multimedia.Audio.Communication **参数:** @@ -1059,6 +1067,8 @@ setRingerMode(mode: AudioRingMode): Promise<void> 设置铃声模式,使用Promise方式异步返回结果。 +**需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY + **系统能力:** SystemCapability.Multimedia.Audio.Communication **参数:** @@ -1139,6 +1149,8 @@ setAudioParameter(key: string, value: string, callback: AsyncCallback<void> 本接口的使用场景为根据硬件设备支持能力扩展音频配置。在不同的设备平台上,所支持的音频参数会存在差异。示例代码内使用样例参数,实际支持的音频配置参数见具体设备平台的资料描述。 +**需要权限:** ohos.permission.MODIFY_AUDIO_SETTINGS + **系统能力:** SystemCapability.Multimedia.Audio.Core **参数:** @@ -1169,6 +1181,8 @@ setAudioParameter(key: string, value: string): Promise<void> 本接口的使用场景为根据硬件设备支持能力扩展音频配置。在不同的设备平台上,所支持的音频参数会存在差异。示例代码内使用样例参数,实际支持的音频配置参数见具体设备平台的资料描述。 +**需要权限:** ohos.permission.MODIFY_AUDIO_SETTINGS + **系统能力:** SystemCapability.Multimedia.Audio.Core **参数:** @@ -1425,6 +1439,8 @@ setMicrophoneMute(mute: boolean, callback: AsyncCallback<void>): void 设置麦克风静音状态,使用callback方式异步返回结果。 +**需要权限:** ohos.permission.MICROPHONE + **系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** @@ -1452,6 +1468,8 @@ setMicrophoneMute(mute: boolean): Promise<void> 设置麦克风静音状态,使用Promise方式异步返回结果。 +**需要权限:** ohos.permission.MICROPHONE + **系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** @@ -1480,6 +1498,8 @@ isMicrophoneMute(callback: AsyncCallback<boolean>): void 获取麦克风静音状态,使用callback方式异步返回结果。 +**需要权限:** ohos.permission.MICROPHONE + **系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** @@ -1506,6 +1526,8 @@ isMicrophoneMute(): Promise<boolean> 获取麦克风静音状态,使用Promise方式异步返回结果。 +**需要权限:** ohos.permission.MICROPHONE + **系统能力:** SystemCapability.Multimedia.Audio.Device **返回值:** @@ -1529,7 +1551,7 @@ on(type: 'volumeChange', callback: Callback\): void 监听系统音量变化事件。 -此接口为系统接口,三方应用不支持。 +此接口为系统接口,三方应用不支持调用。 **系统能力:** SystemCapability.Multimedia.Audio.Volume @@ -1556,7 +1578,7 @@ on(type: 'ringerModeChange', callback: Callback\): void 监听铃声模式变化事件。 -此接口为系统接口,三方应用不支持。 +此接口为系统接口,三方应用不支持调用。 **系统能力:** SystemCapability.Multimedia.Audio.Communication @@ -1698,7 +1720,7 @@ setAudioScene\(scene: AudioScene, callback: AsyncCallback\): void 设置音频场景模式,使用callback方式异步返回结果。 -此接口为系统接口,三方应用不支持。 +此接口为系统接口,三方应用不支持调用。 **系统能力:** SystemCapability.Multimedia.Audio.Communication @@ -1727,7 +1749,7 @@ setAudioScene\(scene: AudioScene\): Promise 设置音频场景模式,使用Promise方式返回异步结果。 -此接口为系统接口,三方应用不支持。 +此接口为系统接口,三方应用不支持调用。 **系统能力:** SystemCapability.Multimedia.Audio.Communication diff --git a/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md b/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md index edab2c029b5d1a90ff1e45bc42457af7b5ce8066..601341e7177bce6fe10987f2381db47181018562 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @@ -233,6 +233,8 @@ cancelPairedDevice(deviceId: string): boolean 删除配对的远程设备。 +此接口为系统接口。 + **需要权限**:ohos.permission.DISCOVER_BLUETOOTH **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -397,7 +399,7 @@ startBluetoothDiscovery(): boolean 开启蓝牙扫描,可以发现远端设备。 -**需要权限**:ohos.permission.USE_BLUETOOTH;ohos.permission.LOCATION +**需要权限**:ohos.permission.DISCOVER_BLUETOOTH;ohos.permission.LOCATION **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -1110,7 +1112,7 @@ getConnectedBLEDevices(): Array<string> | 类型 | 说明 | | ------------------- | ------------------- | -| Array<string> | 返回和当前设备连接BLE设备地址集合。 | +| Array<string> | 返回当前设备作为Server端时连接BLE设备地址集合。 | **示例:** @@ -1125,7 +1127,7 @@ startBLEScan(filters: Array<ScanFilter>, options?: ScanOptions): void 发起BLE扫描流程。 -**需要权限**:ohos.permission.DISCOVER_BLUETOOTH;ohos.permission.MANAGE_BLUETOOTH; ohos.permission.LOCATION +**需要权限**:ohos.permission.DISCOVER_BLUETOOTH;ohos.permission.MANAGE_BLUETOOTH;ohos.permission.LOCATION **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -1396,7 +1398,7 @@ A2dpSourceProfile.on('connectionStateChange', onReceiveEvent); ### A2dpSourceProfile.off('connectionStateChange')8+ -off(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void +off(type: "connectionStateChange", callback?: Callback<[StateChangeParam](#StateChangeParam)>): void 取消订阅a2dp连接状态变化事件。 @@ -1423,12 +1425,14 @@ A2dpSourceProfile.off('connectionStateChange', onReceiveEvent); ``` -### getPlayingState +### getPlayingState9+ getPlayingState(device: string): PlayingState 获取设备的播放状态。 +**需要权限**:ohos.permission.USE_BLUETOOTH + **系统能力**:SystemCapability.Communication.Bluetooth.Core。 **参数:** @@ -1551,7 +1555,7 @@ HandsFreeAudioGatewayProfile.on('connectionStateChange', onReceiveEvent); ### HandsFreeAudioGatewayProfile.off('connectionStateChange')8+ -off(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void +off(type: "connectionStateChange", callback?: Callback<[StateChangeParam](#StateChangeParam)>): void 取消订阅HFP连接状态变化事件。 @@ -1807,6 +1811,16 @@ server端特征值发生变化时,主动通知已连接的client设备。 **示例:** ```js +// 创建descriptors +let descriptors = []; +let arrayBuffer = new ArrayBuffer(8); +let descV = new Uint8Array(arrayBuffer); +descV[0] = 11; +let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', + characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', + descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; +descriptors[0] = descriptor; + let arrayBufferC = new ArrayBuffer(8); let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors}; @@ -2385,14 +2399,9 @@ client端获取蓝牙低功耗设备的所有服务,即服务发现。 ```js // Promise 模式 -let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX'); -device.connect(); -var services = device.getServices(); -console.log("bluetooth services size is ", services.length); - -for (let i = 0; i < services.length; i++) { - console.log('bluetooth serviceUuid is ' + services[i].serviceUuid); -} +gattClientDevice.getServices().then(result => { + console.info("getServices successfully:" + JSON.stringify(result)); +}); ``` @@ -2725,6 +2734,16 @@ setNotifyCharacteristicChanged(characteristic: BLECharacteristic, enable: boolea **示例:** ```js +// 创建descriptors +let descriptors = []; +let arrayBuffer = new ArrayBuffer(8); +let descV = new Uint8Array(arrayBuffer); +descV[0] = 11; +let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', + characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', + descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; +descriptors[0] = descriptor; + let arrayBufferC = new ArrayBuffer(8); let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors}; diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-ability.md b/zh-cn/application-dev/reference/apis/js-apis-data-ability.md index 96a39178a327547938daf1d43ab4bd599beaa20d..aa8b98db48cf52c477131f2cea304462f2271634 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-ability.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-ability.md @@ -1,5 +1,7 @@ # DataAbility 谓词 +DataAbility 谓词用于构造关系型数据库的谓词,提供用于实现不同查询方法的谓词。 + > **说明:** > > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-resultset.md b/zh-cn/application-dev/reference/apis/js-apis-data-resultset.md index 06ec113201daf460a291115807a8200db1ee114e..010dd4b5dbc1569b776a1ad9f446d7ab532eceb5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-resultset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-resultset.md @@ -1,6 +1,9 @@ # 结果集 +结果集是指用户调用关系型数据库查询接口之后返回的结果集合,提供了多种灵活的数据访问方式,以便用户获取各项数据。 + > **说明:** +> > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-device-manager.md b/zh-cn/application-dev/reference/apis/js-apis-device-manager.md index 81ee3cf000b335650a2bf6457fad449c07c678aa..d8996763d77f94da07f1eee160bdfc39fa58da3d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-device-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-device-manager.md @@ -1,5 +1,15 @@ # 设备管理 +本模块提供分布式设备管理能力。 + +系统应用可调用接口实现如下功能: + +- 注册和解除注册设备上下线变化监听 +- 发现周边不可信设备 +- 认证和取消认证设备 +- 查询可信设备列表 +- 查询本地设备信息,包括设备名称,设备类型和设备标识 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > - 本模块接口为系统接口,三方应用不支持调用。 @@ -38,19 +48,18 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager }); ``` +## DeviceInfo -## DeviceStateChangeAction - -表示设备状态变化的枚举。 +设备信息。 **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager -| 名称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| ONLINE | 0 | 设备上线。 | -| READY | 1 | 设备就绪,设备信息同步已完成。 | -| OFFLINE | 2 | 设备下线。 | -| CHANGE | 3 | 设备信息更改。 | +| 名称 | 类型 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | +| deviceId | string | 是 | 设备的唯一标识。 | +| deviceName | string | 是 | 设备名称。 | +| deviceType | [DeviceType](#deviceType) | 是 | 设备类型。 | +| networkId8+ | string | 是 | 设备网络标识。 | ## DeviceType @@ -70,17 +79,109 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager | UNKNOWN_TYPE | 0 | 未知设备 | -## DeviceInfo +## DeviceStateChangeAction -设备信息。 +表示设备状态变化的枚举。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager + +| 名称 | 默认值 | 说明 | +| -------- | -------- | -------- | +| ONLINE | 0 | 设备上线。 | +| READY | 1 | 设备就绪,设备信息同步已完成。 | +| OFFLINE | 2 | 设备下线。 | +| CHANGE | 3 | 设备信息更改。 | + +## SubscribeInfo + +发现信息。 **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager | 名称 | 类型 | 必填 | 描述 | | -------- | -------- | -------- | -------- | -| deviceId | number | 是 | 设备的唯一标识。 | -| deviceName | string | 是 | 设备名称。 | -| deviceType | number | 是 | 设备类型。 | +| subscribeId | number | 是 | 发现标识,用于标识不同的发现周期。 | +| mode | [DiscoverMode ](#discoverMode) | 否 | 发现模式。 | +| medium | [ExchangeMedium](#exchangeMedium) | 否 | 发现类型。 | +| freq | [ExchangeFreq](#exchangeFreq) | 否 | 发现频率。 | +| isSameAccount | boolean | 否 | 是否同账号。 | +| isWakeRemote | boolean | 否 | 是否唤醒设备。 | +| capability | [SubscribeCap](#subscribeCap) | 否 | 发现能力。 | + + +## DiscoverMode + +表示发现模式的枚举。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager + +| 名称 | 默认值 | 说明 | +| -------- | -------- | -------- | +| DISCOVER_MODE_PASSIVE | 0x55 | 被动模式。 | +| DISCOVER_MODE_ACTIVE | 0xAA | 主动模式。 | + + +## ExchangeMedium + +表示发现类型的枚举。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager + +| 名称 | 默认值 | 说明 | +| -------- | -------- | -------- | +| AUTO | 0 | 自动发现类型。 | +| BLE | 1 | 蓝牙发现类型。 | +| COAP | 2 | WiFi发现类型。 | +| USB | 3 | USB发现类型。 | + +## ExchangeFreq + +表示发现频率的枚举。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager + +| 名称 | 默认值 | 说明 | +| -------- | -------- | -------- | +| LOW | 0 | 低频率。 | +| MID | 1 | 中频率。 | +| HIGH | 2 | 高频率。 | +| SUPER_HIGH | 3 | 超高频率。 | + + +## SubscribeCap + +表示发现能力的枚举。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager + +| 名称 | 默认值 | 说明 | +| -------- | -------- | -------- | +| SUBSCRIBE_CAPABILITY_DDMP | 0 | DDMP能力,后续会被废弃。 | +| SUBSCRIBE_CAPABILITY_OSD | 1 | OSD能力。 | + + +## AuthParam + +认证参数。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager + +| 名称 | 类型 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | +| authType | number | 是 | 认证类型。 | +| extraInfo | {[key:string] : any} | 否 | 认证参数可扩展字段。 | + +## AuthInfo + +认证信息。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager + +| 名称 | 类型 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | +| authType | number | 是 | 认证类型。 | +| token | number | 是 | 认证Token。 | +| extraInfo | {[key:string] : any} | 否 | 认证信息可扩展字段。 | ## DeviceManager @@ -97,7 +198,7 @@ release(): void **系统能力**:SystemCapability.DistributedHardware.DeviceManager - 示例: - ``` + ```js dmInstance.release(); ``` @@ -116,11 +217,253 @@ getTrustedDeviceListSync(): Array<DeviceInfo> | Array<[DeviceInfo](#deviceinfo)> | 返回可信设备列表。 | - 示例: - ``` + ```js var deviceInfoList = dmInstance.getTrustedDeviceListSync(); ``` +### getTrustedDeviceList8+ + +getTrustedDeviceList(callback:AsyncCallback<Array<DeviceInfo>>): void + +获取所有可信设备列表。使用callback异步回调。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<Array<[DeviceInfo](#deviceinfo)>> | 是 | 获取所有可信设备列表的回调,返回设备信息。 | + +- 示例: + ```js + dmInstance.getTrustedDeviceList((err, data) => { + console.log("getTrustedDeviceList err: " + JSON.stringify(err)); + console.log('get trusted device info: ' + JSON.stringify(data)); + } + ); + ``` + +### getTrustedDeviceList8+ + +getTrustedDeviceList(): Promise<Array<DeviceInfo>> + +获取所有可信设备列表。使用Promise异步回调。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | Promise<Array<[DeviceInfo](#deviceinfo)>> | Promise实例,用于获取异步返回结果。 | + +- 示例: + ```js + dmInstance.getTrustedDeviceList().then((data) => { + console.log('get trusted device info: ' + JSON.stringify(data)); + }).catch((err) => { + console.log("getTrustedDeviceList err: " + JSON.stringify(err)); + }); + ``` + +### getLocalDeviceInfoSync8+ + +getLocalDeviceInfoSync(): [DeviceInfo](#deviceinfo) + +同步获取本地设备信息。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 返回值: + | 名称 | 说明 | + | -------- | -------- | + | Array<[DeviceInfo](#deviceinfo)> | 返回可信设备列表。 | + +- 示例: + ```js + var deviceInfo = dmInstance.getLocalDeviceInfoSync(); + ``` + + +### getLocalDeviceInfo8+ + +getLocalDeviceInfo(callback:AsyncCallback<DeviceInfo>): void + +获取本地设备信息。使用callback异步回调。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<[DeviceInfo](#deviceinfo)> | 是 | 获取本地设备信息。 | + +- 示例: + ```js + dmInstance.getLocalDeviceInfo((err, data) => { + console.log("getLocalDeviceInfo err: " + JSON.stringify(err)); + console.log('get local device info: ' + JSON.stringify(data)); + } + ); + ``` + +### getLocalDeviceInfo8+ + +getLocalDeviceInfo(): Promise<DeviceInfo> + +获取本地设备信息。使用Promise异步回调。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | Promise<[DeviceInfo](#deviceinfo)> | Promise实例,用于获取异步返回结果。 | + +- 示例: + ```js + dmInstance.getLocalDeviceInfo().then((data) => { + console.log('get local device info: ' + JSON.stringify(data)); + }).catch((err) => { + console.log("getLocalDeviceInfo err: " + JSON.stringify(err)); + }); + ``` + +### startDeviceDiscovery + +startDeviceDiscovery(subscribeInfo: SubscribeInfo): void + +发现周边设备。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | subscribeInfo | [SubscribeInfo](#subscribeInfo) | 是 | 发现信息。 | + +- 示例: + ```js + //生成发现标识,随机数确保每次调用发现接口的标识不一致 + var subscribeId = Math.floor(Math.random() * 10000 + 1000); + var subscribeInfo = { + "subscribeId": subscribeId, + "mode": 0xAA, //主动模式 + "medium": 0, //自动发现类型,同时支持多种发现类型 + "freq": 2, //高频率 + "isSameAccount": false, + "isWakeRemote": false, + "capability": 1 + }; + dmInstance.startDeviceDiscovery(subscribeInfo); //当有设备发现时,通过deviceFound回调通知给应用程序 + ``` + +### stopDeviceDiscovery + +stopDeviceDiscovery(subscribeId: number): void + +停止发现周边设备。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | subscribeId | number | 是 | 发现标识。 | + +- 示例: + ```js + //入参需要和startDeviceDiscovery接口传入的subscribeId配对使用 + dmInstance.stopDeviceDiscovery(subscribeId); + ``` + +### authenticateDevice + +authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: AsyncCallback<{deviceId: string, pinToken ?: number}>): void + +认证设备。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | deviceInfo | [DeviceInfo](#deviceInfo) | 是 | 设备信息。 | + | authParam | [AuthParam](#authParam) | 是 | 认证参数。 | + | callback | AsyncCallback<{ deviceId: string, pinToken ?: number }> | 是 | 认证结果回调。 | + +- 示例: + ```js + //认证的设备信息,可以从发现的结果中获取 + var deviceInfo ={ + "deviceId": "XXXXXXXX", + "deviceName": "", + deviceType: 0x0E + }; + let authParam = { + "authType": 1, //认证类型: 1 - 无账号PIN码认证 + "extraInfo": {} + } + dmInstance.authenticateDevice(deviceInfo, authParam, (err, data) => { + if (err) { + console.info(TAG + "authenticateDevice err:" + JSON.stringify(err)); + return; + } + console.info(TAG + "authenticateDevice result:" + JSON.stringify(data)); + token = data.pinToken; + }); + ``` + +### unAuthenticateDevice8+ + +unAuthenticateDevice(deviceInfo: DeviceInfo): void + +解除认证设备。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | deviceInfo | [DeviceInfo](#deviceInfo) | 是 | 设备信息。 | + +- 示例: + ```js + dmInstance.unAuthenticateDevice(deviceInfo); + ``` + + +### verifyAuthInfo + +verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, level: number}>): void + +验证认证信息。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | authInfo | [AuthInfo](#authInfo) | 是 | 认证信息。 | + | authInfo | AsyncCallback<{ deviceId: string, level: number }> | 是 | 验证结果回调。 | + +- 示例: + ```js + let authInfo = { + "authType": 1, + "token": xxxxxx, + "extraInfo": {} + } + dmInstance.verifyAuthInfo(authInfo, (err, data) => { + if (err) { + console.info(TAG + "verifyAuthInfo err:" + JSON.stringify(err)); + return; + } + console.info(TAG + "verifyAuthInfo result:" + JSON.stringify(data)); + }); + ``` + + ### on('deviceStateChange') on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChangeAction, device: DeviceInfo }>): void @@ -136,7 +479,7 @@ on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChange | callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }> | 是 | 指示要注册的设备状态回调,返回设备状态和设备信息。 | - 示例: - ``` + ```js dmInstance.on('deviceStateChange', (data) => { console.info("deviceStateChange on:" + JSON.stringify(data)); } @@ -146,7 +489,7 @@ on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChange ### off('deviceStateChange') -off(type: 'deviceStateChange', callback?: Call back<{ action: DeviceStateChangeAction, device: DeviceInfo }>): void +off(type: 'deviceStateChange', callback?: Callback<{ action: DeviceStateChangeAction, device: DeviceInfo }>): void 取消注册设备状态回调。 @@ -159,7 +502,7 @@ off(type: 'deviceStateChange', callback?: Call back<{ action: DeviceStateChan | callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo)  }> | 是 | 指示要取消注册的设备状态回调,返回设备状态和设备信息。 | - 示例: - ``` + ```js dmInstance.off('deviceStateChange', (data) => { console.info('deviceStateChange' + JSON.stringify(data)); } @@ -167,6 +510,95 @@ off(type: 'deviceStateChange', callback?: Call back<{ action: DeviceStateChan ``` +### on('deviceFound') + +on(type: 'deviceFound', callback: Callback<{ subscribeId: number, device: DeviceInfo }>): void + +注册发现设备回调监听。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 注册设备发现回调,以便在发现周边设备时通知应用程序。 | + | callback | Callback<{ subscribeId: number, device: DeviceInfo }> | 是 | 注册设备发现的回调方法。 | + +- 示例: + ```js + dmInstance.on('deviceFound', (data) => { + console.info("deviceFound:" + JSON.stringify(data)); + } + ); + ``` + +### off('deviceFound') + +off(type: 'deviceFound', callback?: Callback<{ subscribeId: number, device: DeviceInfo }>): void + +取消注册设备发现回调。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 取消注册设备发现回调。 | + | callback | Callback<{ subscribeId: number, device: DeviceInfo }> | 是 | 指示要取消注册的设备发现回调,返回设备状态和设备信息。 | + +- 示例: + ```js + dmInstance.off('deviceFound', (data) => { + console.info('deviceFound' + JSON.stringify(data)); + } + ); + ``` + +### on('discoverFail') + +on(type: 'discoverFail', callback: Callback<{ subscribeId: number, reason: number }>): void + +注册设备发现失败回调监听。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 注册设备发现失败回调,以便在发现周边设备失败时通知应用程序。 | + | callback | Callback<{ subscribeId: number, reason: number }> | 是 | 注册设备发现失败的回调方法。 | + +- 示例: + ```js + dmInstance.on('discoverFail', (data) => { + this.log("discoverFail on:" + JSON.stringify(data)); + } + ); + ``` + +### off('discoverFail') + +off(type: 'discoverFail', callback?: Callback<{ subscribeId: number, reason: number }>): void + +取消注册设备发现失败回调。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 取消注册设备发现失败回调。 | + | callback | Callback<{ subscribeId: number, reason: number }> | 是 | 指示要取消注册的设备发现失败回调。 | + +- 示例: + ```js + dmInstance.off('deviceFound', (data) => { + console.info('deviceFound' + JSON.stringify(data)); + } + ); + ``` + + ### on('serviceDie') on(type: 'serviceDie', callback: () => void): void @@ -182,7 +614,7 @@ on(type: 'serviceDie', callback: () => void): void | callback | () => void | 是 | 注册serviceDie的回调方法。 | - 示例: - ``` + ```js dmInstance.on("serviceDie", () => { console.info("serviceDie on"); } @@ -205,9 +637,9 @@ off(type: 'serviceDie', callback?: () => void): void | callback | () => void | 否 | 取消注册serviceDie的回调方法。 | - 示例: - ``` + ```js dmInstance.off("serviceDie", () => { console.info("serviceDie off"); } ); - ``` + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md b/zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md index 12e78431840fbcae2e471af3d2da1708c44280f7..850bf85772169a580ee097a2ae0bca8ac2ec5ba1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md +++ b/zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md @@ -144,6 +144,8 @@ queryBundleStateInfos(begin: number, end: number, callback: AsyncCallback<Bun **系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App +**系统API**:此接口为系统接口,三方应用不支持调用。 + **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -180,6 +182,8 @@ queryBundleStateInfos(begin: number, end: number): Promise<BundleActiveInfoRe **系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App +**系统API**:此接口为系统接口,三方应用不支持调用。 + **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -219,6 +223,8 @@ queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: num **系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App +**系统API**:此接口为系统接口,三方应用不支持调用。 + **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -254,6 +260,8 @@ queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: num **系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App +**系统API**:此接口为系统接口,三方应用不支持调用。 + **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -292,6 +300,8 @@ queryBundleActiveStates(begin: number, end: number, callback: AsyncCallback<A **系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App +**系统API**:此接口为系统接口,三方应用不支持调用。 + **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -326,6 +336,8 @@ queryBundleActiveStates(begin: number, end: number): Promise<Array<BundleA **系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App +**系统API**:此接口为系统接口,三方应用不支持调用。 + **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -446,8 +458,6 @@ merge(toMerge: BundleStateInfo): void 合并相同包名的应用使用信息。 -本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 - **系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App **参数**: diff --git a/zh-cn/application-dev/reference/apis/js-apis-display.md b/zh-cn/application-dev/reference/apis/js-apis-display.md index 5ec470ae38f772189656c0c6d209d38bf159b2ad..9e661a311f93f4324406d918035639195bf95390 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-display.md +++ b/zh-cn/application-dev/reference/apis/js-apis-display.md @@ -1,6 +1,8 @@ # 屏幕属性 +屏幕属性提供管理显示设备的一些基础能力,包括获取默认显示设备的信息,获取所有显示设备的信息以及监听显示设备的插拔行为。 > **说明:** +> > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 @@ -14,7 +16,7 @@ import display from '@ohos.display'; 用于表示显示设备的状态。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** SystemCapability.WindowManager.WindowManager.Core | 名称 | 默认值 | 说明 | | -------- | -------- | -------- | @@ -31,7 +33,7 @@ import display from '@ohos.display'; 描述display对象的属性。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** SystemCapability.WindowManager.WindowManager.Core | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -61,7 +63,7 @@ getDefaultDisplay(callback: AsyncCallback<Display>): void **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[Display](#display)> | 是 | 回调返回当前默认的display对象。 | + | callback | AsyncCallback<[Display](#display)> | 是 | 回调函数。返回当前默认的display对象。 | **示例:** ```js @@ -88,7 +90,7 @@ getDefaultDisplay(): Promise<Display> | 类型 | 说明 | | ---------------------------------- | ---------------------------------------------- | - | Promise<[Display](#display)> | 以Promise形式返回结果,返回默认的display对象。 | + | Promise<[Display](#display)> | Promise对象。返回当前默认的display对象。 | **示例:** @@ -113,7 +115,7 @@ getAllDisplay(callback: AsyncCallback<Array<Display>>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------------------- | ---- | ------------------------------- | - | callback | AsyncCallback<Array<[Display](#display)>> | 是 | 回调返回当前所有的display对象。 | + | callback | AsyncCallback<Array<[Display](#display)>> | 是 | 回调函数。返回当前所有的display对象。 | **示例:** @@ -139,7 +141,7 @@ getAllDisplay(): Promise<Array<Display>> | 类型 | 说明 | | ----------------------------------------------- | ------------------------------------------------------- | - | Promise<Array<[Display](#display)>> | 以Promise形式返回结果,返回包含所有Display对象的Array。 | + | Promise<Array<[Display](#display)>> | Promise对象。返回当前所有的display对象。 | **示例:** @@ -164,7 +166,7 @@ on(type: 'add'|'remove'|'change', callback: Callback<number>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置监听类型。
- type为"add",表示监听增加显示设备。
- type为"remove",表示监听移除显示设备。
- type为"change",表示监听改变显示设备。 | - | callback | Callback<number> | 是 | 回调返回监听到的显示设备的id。 | + | callback | Callback<number> | 是 | 回调函数。返回监听到的显示设备的id。 | **示例:** ```js @@ -187,7 +189,7 @@ off(type: 'add'|'remove'|'change', callback?: Callback<number>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置监听类型。
- type为"add",表示监听增加显示设备。
- type为"remove",表示监听移除显示设备。
- type为"change",表示监听改变显示设备。 | - | callback | Callback<number> | 否 | 回调返回监听到的显示设备的id。 | + | callback | Callback<number> | 否 | 回调函数。返回监听到的显示设备的id。 | **示例:** ```js diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md b/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md index b24c380f3546c3f3b1e4d2db409cfc98baa6e76e..89d0b8b9668f93108ed87946d88d19a82f28e53c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md @@ -585,13 +585,12 @@ try { KVStore数据库类型枚举。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | 名称 | 值 | 说明 | | --- | ---- | ----------------------- | -| DEVICE_COLLABORATION | 0 | 表示多设备协同数据库。 | -| SINGLE_VERSION | 1 | 表示单版本数据库。 | -| MULTI_VERSION | 2 | 表示多版本数据库。此类型当前不允许使用。 | +| DEVICE_COLLABORATION | 0 | 表示多设备协同数据库。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | +| SINGLE_VERSION | 1 | 表示单版本数据库。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | +| MULTI_VERSION | 2 | 表示多版本数据库。此类型当前不允许使用。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | ## SecurityLevel diff --git a/zh-cn/application-dev/reference/apis/js-apis-document.md b/zh-cn/application-dev/reference/apis/js-apis-document.md index 01d6e24a1c50a71f3e42bdf383315a6fc48e43d6..805b7039bbff3b483b3ab883b4c240b22336192d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-document.md +++ b/zh-cn/application-dev/reference/apis/js-apis-document.md @@ -12,17 +12,17 @@ import document from '@ohos.document'; ## document.choose -choose(type:string[]): Promise<string> +choose(types:string[]): Promise<string> 通过文件管理器选择文件,异步返回文件URI,使用promise形式返回结果。 -**系统能力**:SystemCapability.FileManagement.File.FileIO +**系统能力**:SystemCapability.FileManagement.UserFileService - 参数: | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ---------------------------- | - | type | string[] | 否 | 限定文件选择的类型 | + | types | string[] | 否 | 限定文件选择的类型 | - 返回值: @@ -33,7 +33,8 @@ choose(type:string[]): Promise<string> - 示例: ```js - await document.choose(type); + let tpyes = []; + document.choose(types); ``` ## document.choose @@ -41,7 +42,7 @@ choose(callback:AsyncCallback<string>): void 通过文件管理器选择文件,异步返回文件URI,使用callback形式返回结果。 -**系统能力**:SystemCapability.FileManagement.File.FileIO +**系统能力**:SystemCapability.FileManagement.UserFileService - 参数: @@ -52,47 +53,50 @@ choose(callback:AsyncCallback<string>): void - 示例: ```js - await document.choose(function(err, uri) { + let uri = ""; + document.choose(function(err, uri) { //do something with uri }); ``` ## document.choose -choose(type:string[], callback:AsyncCallback<string>): void +choose(types:string[], callback:AsyncCallback<string>): void 通过文件管理器选择文件,异步返回文件URI,使用callback形式返回结果。 -**系统能力**:SystemCapability.FileManagement.File.FileIO +**系统能力**:SystemCapability.FileManagement.UserFileService - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ---------------------------- | - | type | string[] | 否 | 限定选择文件的类型 | + | types | string[] | 否 | 限定选择文件的类型 | | callback | AsyncCallback<string> | 是 | 异步获取对应文件URI(注:当前返回错误码) | - 示例: ```js - await document.choose(type, function(err, uri) { + let types = []; + let uri = ""; + document.choose(types, function(err, uri) { //do something with uri }); ``` ## document.show -show(url:string, type:string):Promise<number> +show(uri:string, types:string):Promise<void> 异步打开URI对应的文件,使用promise形式返回结果。 -**系统能力**:SystemCapability.FileManagement.File.FileIO +**系统能力**:SystemCapability.FileManagement.UserFileService - 参数: | 参数 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ---------------------------- | | uri | string | 是 | 待打开的文件URI | - | type | string | 是 | 待打开文件的类型 | + | types | string | 是 | 待打开文件的类型 | - 返回值: @@ -103,29 +107,33 @@ show(url:string, type:string):Promise<number> - 示例: ```js - await document.show(uri, type); + let types = ""; + let uri = ""; + document.show(uri, types); ``` ## document.show -show(url:string, type:string, callback:AsyncCallback<void>): void +show(uri:string, types:string, callback:AsyncCallback<void>): void 异步打开URI对应的文件,使用callback形式返回结果。 -**系统能力**:SystemCapability.FileManagement.File.FileIO +**系统能力**:SystemCapability.FileManagement.UserFileService - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ---------------------------- | | uri | string | 是 | 待打开的文件URI | - | type | string | 是 | 待打开文件的类型 | + | types | string | 是 | 待打开文件的类型 | | callback | AsyncCallback<void> | 是 | 异步打开uri对应文件(注:当前返回错误码) | - 示例: ```js - await document.show(uri, type, function(err) { + let types = ""; + let uri = ""; + document.show(uri, types, function(err) { //do something }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileio.md b/zh-cn/application-dev/reference/apis/js-apis-fileio.md index 122562e487b0cba7f55bf38ae2a5a2bae7ef6e5e..819d2a52a696b95108ca4ff9c1286b79d213efbd 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-fileio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-fileio.md @@ -2977,7 +2977,7 @@ readSync(): Dirent ``` -### close +### close7+ close(): Promise<void> @@ -2994,7 +2994,7 @@ close(): Promise<void> ``` - ### close + ### close7+ close(callback: AsyncCallback<void>): void diff --git a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md index d2a521a9d6965e374b4dfd3e1222214ad3c9786e..2d3d39a2071b75e0145d35ab50a9fe0f294d3362 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md @@ -18,7 +18,7 @@ getRoot(options? : {dev? : DevInfo}) : Promise<FileInfo[]> 以异步方法获取第一层相册,目录信息。使用promise形式返回结果。 -**系统能力**:SystemCapability.FileManagement.FileManagerService +**系统能力**:SystemCapability.FileManagement.UserFileService - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -51,7 +51,7 @@ getRoot(options? : {dev? : DevInfo}, callback : AsyncCallback<FileInfo[]>) 以异步方法获取第一层相册,目录信息。使用callback形式返回结果。 -**系统能力**:SystemCapability.FileManagement.FileManagerService +**系统能力**:SystemCapability.FileManagement.UserFileService - 参数 @@ -84,7 +84,7 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num 以异步方法获取第二层相册,文件信息。使用promise形式返回结果。 -**系统能力**:SystemCapability.FileManagement.FileManagerService +**系统能力**:SystemCapability.FileManagement.UserFileService - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -111,7 +111,7 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num ```js // 获取目录下所有文件 // 通过listFile、getRoot获取的文件uri - let media_path = file.path + let media_path = "" filemanager.listFile(media_path, "file") .then((fileInfo) => { if(Array.isArray(fileInfo)) { @@ -120,6 +120,9 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num } } }).catch((err) => { + + + console.log(err) }); ``` @@ -130,7 +133,7 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num 以异步方法获取第二层相册,文件信息。使用callback形式返回结果。 -**系统能力**:SystemCapability.FileManagement.FileManagerService +**系统能力**:SystemCapability.FileManagement.UserFileService - 参数 @@ -152,7 +155,7 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num ```js // 通过listFile、getRoot获取的文件path - let fileInfos = await filemanager.getRoot(); + let fileInfos = filemanager.getRoot(); let media_path = ""; for (let i = 0; i < fileInfos.length; i++) { if (fileInfos[i].name == "image_album") { @@ -184,7 +187,7 @@ createFile(path : string, filename : string, options? : {dev? : DevInfo}) : P 以异步方法创建文件到指定路径,返回文件uri。使用promise形式返回结果。 -**系统能力**:SystemCapability.FileManagement.FileManagerService +**系统能力**:SystemCapability.FileManagement.UserFileService - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -197,7 +200,7 @@ createFile(path : string, filename : string, options? : {dev? : DevInfo}) : P | 类型 | 说明 | | --- | -- | - | Promise<string> | 文件uri | + | string | 文件uri | - 异常 | 错误名称 | 错误类型 | 错误码 |说明 | @@ -211,7 +214,7 @@ createFile(path : string, filename : string, options? : {dev? : DevInfo}) : P ```js // 创建文件,返回文件uri - let media_path = file.uri // 通过listFile、getRoot获取的文件uri + let media_path = "" // 通过listFile、getRoot获取的文件uri let name = "xxx.jpg" // 待保存文件的后缀 filemanager.createFile(media_path, name).then((uri) => { // 返回uri给应用 @@ -227,7 +230,7 @@ createFile(path : string, filename: string, options? : {dev? : DevInfo}, callbac 以异步方法创建文件到指定路径,返回文件uri。使用callback形式返回结果。 -**系统能力**:SystemCapability.FileManagement.FileManagerService +**系统能力**:SystemCapability.FileManagement.UserFileService - 参数 @@ -252,19 +255,21 @@ createFile(path : string, filename: string, options? : {dev? : DevInfo}, callbac ```js // 创建文件,返回文件uri // 通过listFile、getRoot获取的文件uri - let media_path = file.path + let media_path = "" // 待保存文件的后缀 let name = "xxx.jpg" - filemanager.createFile(media_path, name, (err, uri) => { + let dev = ""; + filemanager.createFile(media_path, name, { DevInfo: dev }, function(err, uri) { // 返回uri给应用 - console.log("file uri:"+uri); - }); + console.log("file uri:"+uri); + }); + ``` ## FileInfo 文件信息类型,通过getRoot, listFile等接口返回的类型。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.FileManagerService。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.UserFileService。 ### 属性 @@ -281,7 +286,7 @@ createFile(path : string, filename: string, options? : {dev? : DevInfo}, callbac 设备类型,配置接口访问的设备类型。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.FileManagerService。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.UserFileService。 ### 属性 diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md index 695d4ea99675c9133178811294d5cba7894987a3..148f65ff859f68222d335df7910d8a6fca870cc5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @@ -47,9 +47,10 @@ getInputMethodController(): InputMethodController | [InputMethodController](#InputMethodController) | 回调返回当前客户端实例。 | **示例:** - ```js + +```js var InputMethodController = inputMethod.getInputMethodController(); - ``` +``` ## inputMethod.getInputMethodSetting6+ @@ -67,9 +68,10 @@ getInputMethodSetting(): InputMethodSetting **示例:** - ```js + +```js var InputMethodSetting = inputMethod.getInputMethodSetting(); - ``` +``` ## InputMethodController @@ -115,8 +117,8 @@ stopInput(): Promise<boolean> ```js - var isSuccess = InputMethodController.stopInput(); - console.info('stopInput isSuccess = ' + isSuccess); + var isSuccess = InputMethodController.stopInput(); + console.info('stopInput isSuccess = ' + isSuccess); ``` ## InputMethodSetting6+ @@ -137,14 +139,15 @@ listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>) | callback | Array<[InputMethodProperty](#InputMethodProperty)> | 是 | 返回已安装输入法列表。 | **示例:** - ```js - InputMethodSetting.listInputMethod((properties)=>{ - for (var i = 0;i < properties.length; i++) { - var property = properties[i]; - console.info(property.packageName + "/" + property.methodId); - } + +```js + InputMethodSetting.listInputMethod((properties)=>{ + for (var i = 0;i < properties.length; i++) { + var property = properties[i]; + console.info(property.packageName + "/" + property.methodId); + } }); - ``` +``` ### listInputMethod @@ -160,13 +163,14 @@ listInputMethod(): Promise<Array<InputMethodProperty>> | Promise> | 返回已安装输入法列表。 | **示例:** - ```js - var properties = InputMethodSetting.listInputMethod(); - for (var i = 0;i < properties.length; i++) { - var property = properties[i]; - console.info(property.packageName + "/" + property.methodId); - } - ``` + +```js + var properties = InputMethodSetting.listInputMethod(); + for (var i = 0;i < properties.length; i++) { + var property = properties[i]; + console.info(property.packageName + "/" + property.methodId); + } +``` ### displayOptionalInputMethod @@ -183,11 +187,12 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void | callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** - ```js - InputMethodSetting.displayOptionalInputMethod(()=>{ - console.info('displayOptionalInputMethod is called'); + +```js + InputMethodSetting.displayOptionalInputMethod(()=>{ + console.info('displayOptionalInputMethod is called'); }); - ``` +``` ### displayOptionalInputMethod @@ -204,6 +209,7 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void | Promise<void> | 回调函数。 | **示例:** - ```js - InputMethodSetting.displayOptionalInputMethod(); - ``` \ No newline at end of file + +```js + InputMethodSetting.displayOptionalInputMethod(); +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-media.md b/zh-cn/application-dev/reference/apis/js-apis-media.md index fe5977972f79737f92051c2f6c240053f6113055..b717b0559e813237398cfe40c357422ce327d1f2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-media.md +++ b/zh-cn/application-dev/reference/apis/js-apis-media.md @@ -2,8 +2,7 @@ > **说明:** > 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> -> API Version 9当前为Canary版本,仅供试用,不保证接口可稳定调用。 + 媒体子系统为开发者提供一套简单且易于理解的接口,使得开发者能够方便接入系统并使用系统的媒体资源。 @@ -12,7 +11,6 @@ - 音频播放([AudioPlayer](#audioplayer)) - 视频播放([VideoPlayer](#videoplayer8)) - 音频录制([AudioRecorder](#audiorecorder)) -- 视频录制([VideoRecorder](#videorecorder9)) 后续将提供以下功能:DataSource音视频播放、音视频编解码、容器封装解封装、媒体能力查询等功能。 @@ -122,65 +120,6 @@ createAudioRecorder(): AudioRecorder let audioRecorder = media.createAudioRecorder(); ``` -## media.createVideoRecorder9+ - -createVideoRecorder(callback: AsyncCallback\<[VideoRecorder](#videorecorder9)>): void - -异步方式创建视频录制实例。通过注册回调函数获取返回值。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------------- | ---- | ------------------------------ | -| callback | AsyncCallback<[VideoRecorder](#videorecorder9)> | 是 | 异步创建视频录制实例回调方法。 | - -**示例:** - -```js -let videoRecorder - -media.createVideoRecorder((error, video) => { - if (typeof(video) != 'undefined') { - videoRecorder = video; - console.info('video createVideoRecorder success'); - } else { - console.info(`video createVideoRecorder fail, error:${error.message}`); - } -}); -``` - -## media.createVideoRecorder9+ - -createVideoRecorder(): Promise<[VideoRecorder](#videorecorder9)> - -异步方式创建视频录制实例。通过Promise获取返回值。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**返回值:** - -| 类型 | 说明 | -| ----------------------------------------- | ----------------------------------- | -| Promise<[VideoRecorder](#videorecorder9)> | 异步创建视频录制实例Promise返回值。 | - -**示例:** - -```js -let videoRecorder - -media.createVideoRecorder().then((video) => { - if (typeof(video) != 'undefined') { - videoRecorder = video; - console.info('video createVideoRecorder success'); - } else { - console.info('video createVideoRecorder fail'); - } -}).catch((error) => { - console.info(`video catchCallback, error:${error.message}`); -}); -``` @@ -1527,7 +1466,7 @@ prepare(config: AudioRecorderConfig): void | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------------------------------------- | ---- | ------------------------------------------------------------ | -| config | [AudioRecorderConfig](#audiorecorderconfig) | 是 | 配置录音的相关参数,包括音频输出URI、[编码格式](#audioencoder)、采样率、声道数、[输出格式](#audiooutputformat)等。 | +| config | [AudioRecorderConfig](#audiorecorderconfig) | 是 | 配置录音的相关参数,包括音频输出URI、编码格式、采样率、声道数、输出格式等。 | **示例:** @@ -1745,14 +1684,15 @@ audioRecorder.prepare(); // pre | 名称 | 参数类型 | 必填 | 说明 | | --------------------- | --------------------------------------- | ---- | ------------------------------------------------------------ | -| audioEncoder | [AudioEncoder](#audioencoder) | 否 | 音频编码格式,默认设置为AAC_LC。 | +| audioEncoder(deprecated) | [AudioEncoder](#audioencoder) | 否 | 音频编码格式,默认设置为AAC_LC。
**说明:** 从API Version 8 开始废弃,建议使用audioEncoderMime替代。 | | audioEncodeBitRate | number | 否 | 音频编码比特率,默认值为48000。 | | audioSampleRate | number | 否 | 音频采集采样率,默认值为48000。 | | numberOfChannels | number | 否 | 音频采集声道数,默认值为2。 | -| format | [AudioOutputFormat](#audiooutputformat) | 否 | 音频输出封装格式,默认设置为MPEG_4。 | +| format(deprecated) | [AudioOutputFormat](#audiooutputformat) | 否 | 音频输出封装格式,默认设置为MPEG_4。
**说明:** 从API Version 8 开始废弃,建议使用fileFormat替代。 | | location | [Location](#location) | 否 | 音频采集的地理位置。 | -| uri | string | 是 | 音频输出URI:fd://xx (fd number)
![zh-cn_image_0000001164217678](figures/zh-cn_image_url.png)
文件需要由调用者创建,并赋予适当的权限。 | -| audioEncoderMime | [CodecMimeType](#codecmimetype8) | 否 | 音频编码格式。 | +| uri | string | 是 | 音频输出URI:fd://xx (fd number)
![](figures/zh-cn_image_url.png)
文件需要由调用者创建,并赋予适当的权限。 | +| audioEncoderMime8+ | [CodecMimeType](#codecmimetype8) | 否 | 音频编码格式。 | +| fileFormat8+ | [ContainerFormatType](#containerformattype8) | 否 | 音频编码格式。 | ## AudioEncoder(deprecated) @@ -1790,643 +1730,6 @@ audioRecorder.prepare(); // pre | AMR_WB | 4 | 封装为AMR_WB格式。
仅做接口定义,暂不支持使用。 | | AAC_ADTS | 6 | 封装为ADTS(Audio Data Transport Stream)格式,是AAC音频的传输流格式。 | -## VideoRecorder9+ - -视频录制管理类,用于录制视频媒体。在调用VideoRecorder的方法前,需要先通过[createVideoRecorder()](#mediacreatevideorecorder9)构建一个[VideoRecorder](#videorecorder9)实例。 - -视频录制demo可参考:[视频录制开发指导](../../media/video-recorder.md) - -### 属性 - -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------------------ | -------------------------------------- | ---- | ---- | ---------------- | -| state8+ | [VideoRecordState](#videorecordstate9) | 是 | 否 | 视频录制的状态。 | - -### prepare9+ - -prepare(config: VideoRecorderConfig, callback: AsyncCallback\): void; - -异步方式进行视频录制的参数设置。通过注册回调函数获取返回值。 - -**需要权限:** ohos.permission.MICROPHONE - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------------------------------- | ---- | ----------------------------------- | -| config | [VideoRecorderConfig](#videorecorderconfig9) | 是 | 配置视频录制的相关参数。 | -| callback | AsyncCallback\ | 是 | 异步视频录制prepare方法的回调方法。 | - -**示例:** - -```js -let videoProfile = { - audioBitrate : 48000, - audioChannels : 2, - audioCodec : 'audio/mp4a-latm', - audioSampleRate : 48000, - fileFormat : 'mp4', - videoBitrate : 48000, - videoCodec : 'video/mp4v-es', - videoFrameWidth : 640, - videoFrameHeight : 480, - videoFrameRate : 30 -} - -let videoConfig = { - audioSourceType : 1, - videoSourceType : 0, - profile : videoProfile, - url : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限 - orientationHint : 0, - location : { latitude : 30, longitude : 130 }, -} - -// asyncallback -let videoRecorder = null; -let events = require('events'); -let eventEmitter = new events.EventEmitter(); - -eventEmitter.on('prepare', () => { - videoRecorder.prepare(videoConfig, (err) => { - if (typeof (err) == 'undefined') { - console.info('prepare success'); - } else { - console.info('prepare failed and error is ' + err.message); - } - }); -}); - -media.createVideoRecorder((err, recorder) => { - if (typeof (err) == 'undefined' && typeof (recorder) != 'undefined') { - videoRecorder = recorder; - console.info('createVideoRecorder success'); - eventEmitter.emit('prepare'); // prepare事件触发 - } else { - console.info('createVideoRecorder failed and error is ' + err.message); - } -}); -``` - -### prepare9+ - -prepare(config: VideoRecorderConfig): Promise\; - -异步方式进行视频录制的参数设置。通过Promise获取返回值。 - -**需要权限:** ohos.permission.MICROPHONE,ohos.permission.CAMERA - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------ | -------------------------------------------- | ---- | ------------------------ | -| config | [VideoRecorderConfig](#videorecorderconfig9) | 是 | 配置视频录制的相关参数。 | - -**返回值:** - -| 类型 | 说明 | -| -------------- | ---------------------------------------- | -| Promise\ | 异步视频录制prepare方法的Promise返回值。 | - -**示例:** - -```js -let videoProfile = { - audioBitrate : 48000, - audioChannels : 2, - audioCodec : 'audio/mp4a-latm', - audioSampleRate : 48000, - fileFormat : 'mp4', - videoBitrate : 48000, - videoCodec : 'video/mp4v-es', - videoFrameWidth : 640, - videoFrameHeight : 480, - videoFrameRate : 30 -} - -let videoConfig = { - audioSourceType : 1, - videoSourceType : 0, - profile : videoProfile, - url : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限 - orientationHint : 0, - location : { latitude : 30, longitude : 130 }, -} - -// promise -let videoRecorder = null; -media.createVideoRecorder().then((recorder) => { - if (typeof (recorder) != 'undefined') { - videoRecorder = recorder; - console.info('createVideoRecorder success'); - } else { - console.info('createVideoRecorder failed'); - } -}).catch((err) => { - console.info('catch err error message is ' + err.message); -}); - -videoRecorder.prepare(videoConfig).then(() => { - console.info('prepare success'); -}).catch((err) => { - console.info('prepare failed and catch error is ' + err.message); -}); -``` - -### getInputSurface9+ - -getInputSurface(callback: AsyncCallback\): void; - -异步方式获得录制需要的surface。此surface提供给调用者,调用者从此surface中获取surfaceBuffer,填入相应的数据。 - -应当注意,填入的视频数据需要携带时间戳(单位ns),buffersize。时间戳的起始时间请以系统启动时间为基准。 - -只能在[prepare()](#videorecorder_prepare1)接口调用后调用。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | --------------------------- | -| callback | AsyncCallback\ | 是 | 异步获得surface的回调方法。 | - -**示例:** - -```js -// asyncallback -let surfaceID = null; // 传递给外界的surfaceID -videoRecorder.getInputSurface((err, surfaceId) => { - if (typeof (err) == 'undefined') { - console.info('getInputSurface success'); - surfaceID = surfaceId; - } else { - console.info('getInputSurface failed and error is ' + err.message); - } -}); -``` - -### getInputSurface9+ - -getInputSurface(): Promise\; - - 异步方式获得录制需要的surface。此surface提供给调用者,调用者从此surface中获取surfaceBuffer,填入相应的数据。 - -应当注意,填入的视频数据需要携带时间戳(单位ns),buffersize。时间戳的起始时间请以系统启动时间为基准。 - -只能在[prepare()](#videorecorder_prepare1)接口调用后调用。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**返回值:** - -| 类型 | 说明 | -| ---------------- | -------------------------------- | -| Promise\ | 异步获得surface的Promise返回值。 | - -**示例:** - -```js -// promise -let surfaceID = null; // 传递给外界的surfaceID -videoRecorder.getInputSurface().then((surfaceId) => { - console.info('getInputSurface success'); - surfaceID = surfaceId; -}).catch((err) => { - console.info('getInputSurface failed and catch error is ' + err.message); -}); -``` - -### start9+ - -start(callback: AsyncCallback\): void; - -异步方式开始视频录制。通过注册回调函数获取返回值。 - -在[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)后调用,需要依赖数据源先给surface传递数据。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | 是 | 异步开始视频录制的回调方法。 | - -**示例:** - -```js -// asyncallback -videoRecorder.start((err) => { - if (typeof (err) == 'undefined') { - console.info('start videorecorder success'); - } else { - console.info('start videorecorder failed and error is ' + err.message); - } -}); -``` - -### start9+ - -start(): Promise\; - -异步方式开始视频录制。通过Promise获取返回值。 - -在[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)后调用,需要依赖数据源先给surface传递数据。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**返回值:** - -| 类型 | 说明 | -| -------------- | ------------------------------------- | -| Promise\ | 异步开始视频录制方法的Promise返回值。 | - -**示例:** - -```js -// promise -videoRecorder.start().then(() => { - console.info('start videorecorder success'); -}).catch((err) => { - console.info('start videorecorder failed and catch error is ' + err.message); -}); -``` - -### pause9+ - -pause(callback: AsyncCallback\): void; - -异步方式暂停视频录制。通过注册回调函数获取返回值。 - -在[start()](#videorecorder_start1)后调用。可以通过调用[resume()](#videorecorder_resume1)接口来恢复录制。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | 是 | 异步暂停视频录制的回调方法。 | - -**示例:** - -```js -// asyncallback -videoRecorder.pause((err) => { - if (typeof (err) == 'undefined') { - console.info('pause videorecorder success'); - } else { - console.info('pause videorecorder failed and error is ' + err.message); - } -}); -``` - -### pause9+ - -pause(): Promise\; - -异步方式暂停视频录制。通过Promise获取返回值。 - -在[start()](#videorecorder_start1)后调用。可以通过调用[resume()](#videorecorder_resume1)接口来恢复录制。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**返回值:** - -| 类型 | 说明 | -| -------------- | ------------------------------------- | -| Promise\ | 异步暂停视频录制方法的Promise返回值。 | - -**示例:** - -```js -// promise -videoRecorder.pause().then(() => { - console.info('pause videorecorder success'); -}).catch((err) => { - console.info('pause videorecorder failed and catch error is ' + err.message); -}); -``` - -### resume9+ - -resume(callback: AsyncCallback\): void; - -异步方式恢复视频录制。通过注册回调函数获取返回值。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | 是 | 异步恢复视频录制的回调方法。 | - -**示例:** - -```js -// asyncallback -videoRecorder.resume((err) => { - if (typeof (err) == 'undefined') { - console.info('resume videorecorder success'); - } else { - console.info('resume videorecorder failed and error is ' + err.message); - } -}); -``` - -### resume9+ - -resume(): Promise\; - -异步方式恢复视频录制。通过Promise获取返回值。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**返回值:** - -| 类型 | 说明 | -| -------------- | ------------------------------------- | -| Promise\ | 异步恢复视频录制方法的Promise返回值。 | - -**示例:** - -```js -// promise -videoRecorder.resume().then(() => { - console.info('resume videorecorder success'); -}).catch((err) => { - console.info('resume videorecorder failed and catch error is ' + err.message); -}); -``` - -### stop9+ - -stop(callback: AsyncCallback\): void; - -异步方式停止视频录制。通过注册回调函数获取返回值。 - -需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)接口才能重新录制。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | 是 | 异步停止视频录制的回调方法。 | - -**示例:** - -```js -// asyncallback -videoRecorder.stop((err) => { - if (typeof (err) == 'undefined') { - console.info('stop videorecorder success'); - } else { - console.info('stop videorecorder failed and error is ' + err.message); - } -}); -``` - -### stop9+ - -stop(): Promise\; - -异步方式停止视频录制。通过Promise获取返回值。 - -需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)接口才能重新录制。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**返回值:** - -| 类型 | 说明 | -| -------------- | ------------------------------------- | -| Promise\ | 异步停止视频录制方法的Promise返回值。 | - -**示例:** - -```js -// promise -videoRecorder.stop().then(() => { - console.info('stop videorecorder success'); -}).catch((err) => { - console.info('stop videorecorder failed and catch error is ' + err.message); -}); -``` - -### release9+ - -release(callback: AsyncCallback\): void; - -异步方式释放视频录制资源。通过注册回调函数获取返回值。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | -------------------------------- | -| callback | AsyncCallback\ | 是 | 异步释放视频录制资源的回调方法。 | - -**示例:** - -```js -// asyncallback -videoRecorder.release((err) => { - if (typeof (err) == 'undefined') { - console.info('release videorecorder success'); - } else { - console.info('release videorecorder failed and error is ' + err.message); - } -}); -``` - -### release9+ - -release(): Promise\; - -异步方式释放视频录制资源。通过Promise获取返回值。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**返回值:** - -| 类型 | 说明 | -| -------------- | ----------------------------------------- | -| Promise\ | 异步释放视频录制资源方法的Promise返回值。 | - -**示例:** - -```js -// promise -videoRecorder.release().then(() => { - console.info('release videorecorder success'); -}).catch((err) => { - console.info('release videorecorder failed and catch error is ' + err.message); -}); -``` - -### reset9+ - -reset(callback: AsyncCallback\): void; - -异步方式重置视频录制。通过注册回调函数获取返回值。 - -需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)接口才能重新录制。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | 是 | 异步重置视频录制的回调方法。 | - -**示例:** - -```js -// asyncallback -videoRecorder.reset((err) => { - if (typeof (err) == 'undefined') { - console.info('reset videorecorder success'); - } else { - console.info('reset videorecorder failed and error is ' + err.message); - } -}); -``` - -### reset9+ - -reset(): Promise\; - -异步方式重置视频录制。通过Promise获取返回值。 - -需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)接口才能重新录制。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**返回值:** - -| 类型 | 说明 | -| -------------- | ------------------------------------- | -| Promise\ | 异步重置视频录制方法的Promise返回值。 | - -**示例:** - -```js -// promise -videoRecorder.reset().then(() => { - console.info('reset videorecorder success'); -}).catch((err) => { - console.info('reset videorecorder failed and catch error is ' + err.message); -}); -``` - -### on('error')9+ - -on(type: 'error', callback: ErrorCallback): void - -开始订阅视频录制错误事件。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 录制错误事件回调类型'error'。
- 'error':视频录制过程中发生错误,触发该事件。 | -| callback | ErrorCallback | 是 | 录制错误事件回调方法。 | - -**示例:** - -```js -videoRecorder.on('error', (error) => { // 设置'error'事件回调 - console.info(`audio error called, errName is ${error.name}`); // 打印错误类型名称 - console.info(`audio error called, errCode is ${error.code}`); // 打印错误码 - console.info(`audio error called, errMessage is ${error.message}`); // 打印错误类型详细描述 -}); -// 当获取videoRecordState接口出错时通过此订阅事件上报 -``` - -## VideoRecordState9+ - -视频录制的状态机。可通过state属性获取当前状态。 - -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 - -| 名称 | 类型 | 描述 | -| -------- | ------ | ---------------------- | -| idle | string | 视频录制空闲。 | -| prepared | string | 视频录制参数设置完成。 | -| playing | string | 视频正在录制。 | -| paused | string | 视频暂停录制。 | -| stopped | string | 视频录制停止。 | -| error | string | 错误状态。 | - -## VideoRecorderConfig9+ - -表示视频录制的参数设置。 - -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 - -| 名称 | 参数类型 | 必填 | 说明 | -| --------------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ | -| audioSourceType | [AudioSourceType](#audiosourcetype9) | 是 | 视频录制的音频源类型。 | -| videoSourceType | [VideoSourceType](#videosourcetype9) | 是 | 视频录制的视频源类型。 | -| profile | [VideoRecorderProfile](#videorecorderprofile9) | 是 | 视频录制的profile。 | -| rotation | number | 否 | 录制视频的旋转角度。 | -| location | [Location](#location) | 否 | 录制视频的地理位置。 | -| url | string | 是 | 视频输出URL:fd://xx (fd number)
![](figures/zh-cn_image_url.png)
文件需要由调用者创建,并赋予适当的权限。 | - -## AudioSourceType9+ - -表示视频录制中音频源类型的枚举。 - -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 - -| 名称 | 值 | 说明 | -| ------------------------- | ---- | ---------------------- | -| AUDIO_SOURCE_TYPE_DEFAULT | 0 | 默认的音频输入源类型。 | -| AUDIO_SOURCE_TYPE_MIC | 1 | 表示MIC的音频输入源。 | - -## VideoSourceType9+ - -表示视频录制中视频源类型的枚举。 - -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 - -| 名称 | 值 | 说明 | -| ----------------------------- | ---- | ------------------------------- | -| VIDEO_SOURCE_TYPE_SURFACE_YUV | 0 | 输入surface中携带的是raw data。 | -| VIDEO_SOURCE_TYPE_SURFACE_ES | 1 | 输入surface中携带的是ES data。 | - -## VideoRecorderProfile9+ - -视频录制的配置文件。 - -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 - -| 名称 | 参数类型 | 必填 | 说明 | -| ---------------- | -------------------------------------------- | ---- | ---------------- | -| audioBitrate | number | 是 | 音频编码比特率。 | -| audioChannels | number | 是 | 音频采集声道数。 | -| audioCodec | [CodecMimeType](#codecmimetype8) | 是 | 音频编码格式。 | -| audioSampleRate | number | 是 | 音频采样率。 | -| fileFormat | [ContainerFormatType](#containerformattype8) | 是 | 文件的容器格式。 | -| videoBitrate | number | 是 | 视频编码比特率。 | -| videoCodec | [CodecMimeType](#codecmimetype8) | 是 | 视频编码格式。 | -| videoFrameWidth | number | 是 | 录制视频帧的宽。 | -| videoFrameHeight | number | 是 | 录制视频帧的高。 | -| videoFrameRate | number | 是 | 录制视频帧率。 | ## ContainerFormatType8+ diff --git a/zh-cn/application-dev/reference/apis/js-apis-notification.md b/zh-cn/application-dev/reference/apis/js-apis-notification.md index e22cdd5b09747c0d230aec781e51ea1abbb8c235..7c795819a06854f5109736fc52057f2901948c14 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-notification.md +++ b/zh-cn/application-dev/reference/apis/js-apis-notification.md @@ -2525,12 +2525,12 @@ function onConsumeCallback(data) { let wantAgent = data.wantAgent; wantAgent .getWant(wantAgent) .then((data1) => { - console.log('===> getWant success want:' + JSON.stringfy(data1)); + console.log('===> getWant success want:' + JSON.stringify(data1)); }) .catch((err) => { - console.error('===> getWant failed because' + JSON.stringfy(err)); + console.error('===> getWant failed because' + JSON.stringify(err)); }); - console.info('===> onConsume callback req.wantAgent:' + JSON.stringfy(req.wantAgent)); + console.info('===> onConsume callback req.wantAgent:' + JSON.stringify(req.wantAgent)); }; var subscriber = { diff --git a/zh-cn/application-dev/reference/apis/js-apis-screenshot.md b/zh-cn/application-dev/reference/apis/js-apis-screenshot.md index 80fb4d6513f144df309482ea15eac3d636d2c230..6871f0ce050609b9871ab727c4fae0a9e910494c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screenshot.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screenshot.md @@ -1,4 +1,5 @@ # 屏幕截图 +本模块提供屏幕截图的能力,截取屏幕时支持设置截取的区域、大小等图像信息。 > **说明:** > @@ -67,7 +68,7 @@ save(options?: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>) | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | options | [ScreenshotOptions](#screenshotoptions) | 否 | 该类型的参数包含screenRect,imageSize,rotation, displayId四个参数,可以分别设置这四个参数。 | -| callback | AsyncCallback<image.PixelMap> | 是 | 回调返回一个PixelMap对象。 | +| callback | AsyncCallback<image.PixelMap> | 是 | 回调函数。返回一个PixelMap对象。 | **示例:** @@ -113,7 +114,7 @@ save(options?: ScreenshotOptions): Promise<image.PixelMap> | 类型 | 说明 | | ----------------------------- | ----------------------------------------------- | -| Promise<image.PixelMap> | 以Promise形式返回结果,返回image.PixelMap对象。 | +| Promise<image.PixelMap> | Promise对象。返回一个PixelMap对象。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md b/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md new file mode 100644 index 0000000000000000000000000000000000000000..c8429742e2a6ff1e0812bc4cf2dfb8d25fe81fdd --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md @@ -0,0 +1,181 @@ +# 数据标签 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +该模块提供文件数据安全等级的相关功能:向应用程序提供查询、设置文件数据安全等级的JS接口。 + +## 导入模块 + +```js +import securityLabel from '@ohos.securityLabel'; +``` + +## 使用说明 + +使用该功能模块对文件/目录进行操作前,需要先获取其应用沙箱路径,获取方式及其接口用法请参考: + +```js +import featureAbility from '@ohos.ability.featureAbility'; +let context = featureAbility.getContext(); +let path = context.getFilesDir(); +``` + +## securityLabel.setSecurityLabel + +setSecurityLabel(path:string, type:dataLevel):Promise<void> + +以异步方法设置数据标签,以promise形式返回结果。 + +**系统能力**:SystemCapability.FileManagement.File.FileIO + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | -------------------------------------------- | +| path | string | 是 | 文件路径 | +| type | dataLevel | 是 | 文件等级属性,只支持"s0","s1","s2","s3","s4" | + +**返回值:** + + | 类型 | 说明 | + | ------------------- | ---------------- | + | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。| + +**示例:** + + ```js + let type = "s4"; + securityLabel.setSecurityLabel(path, type).then(function(){ + console.info("setSecurityLabel successfully"); + }).catch(function(error){ + console.info("setSecurityLabel failed with error:" + error); + }); + ``` + +## securityLabel.setSecurityLabel + +setSecurityLabel(path:string, type:dataLevel, callback: AsyncCallback<void>):void + +以异步方法设置数据标签,以callback形式返回结果。 + +**系统能力**:SystemCapability.FileManagement.File.FileIO + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | -------------------------------------------- | +| path | string | 是 | 文件路径 | +| type | dataLevel | 是 | 文件等级属性,只支持"s0","s1","s2","s3","s4" | +| callback | AsyncCallback<void> | 是 | 是否设置数据标签之后的回调 | + +**示例:** + + ```js + let type = "s4"; + securityLabel.setSecurityLabel(path, type, function(error){ + console.info("setSecurityLabel:" + JSON.stringify(error)); + }); + ``` +## securityLabel.setSecurityLabelSync + +setSecurityLabelSync(path:string, dataLevel:string):void + +以同步方法设置数据标签。 + +**系统能力**:SystemCapability.FileManagement.File.FileIO + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | -------------------------------------------- | +| path | string | 是 | 文件路径 | +| type | dataLevel | 是 | 文件等级属性,只支持"s0","s1","s2","s3","s4" | + +**示例:** + +```js +let type = "s4"; +securityLabel.setSecurityLabelSync(path, type); +``` + +## securityLabel.getSecurityLabel + +getSecurityLabel(path:string):Promise<string> + +异步方法获取数据标签,以promise形式返回结果。 + +**系统能力**:SystemCapability.FileManagement.File.FileIO + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | -------- | + | path | string | 是 | 文件路径 | + +**返回值:** + + | 类型 | 说明 | + | --------------------- | ------------ | + | Promise<string> | 返回数据标签 | + +**示例:** + + ```js + let type = "s4"; + securityLabel.getSecurityLabel(path).then(function(type){ + console.log("getSecurityLabel successfully:" + type); + }).catch(function(error){ + console.log("getSecurityLabel failed with error:" + error); + }); + ``` + +## securityLabel.getSecurityLabel + +getSecurityLabel(path:string, callback:AsyncCallback<string>): void + +异步方法获取数据标签,以callback形式返回结果。 + +**系统能力**:SystemCapability.FileManagement.File.FileIO + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------- | ---- | -------------------------- | + | path | string | 是 | 文件路径 | + | callback | AsyncCallback<string> | 是 | 异步获取数据标签之后的回调 | + +**示例:** + + ```js + let type = "s4"; + securityLabel.getSecurityLabel(path,function(error, type){ + console.log("getSecurityLabel successfully:" + type); + }); + ``` +## securityLabel.getSecurityLabelSync + +getSecurityLabelSync(path:string):string + +以同步方法获取数据标签。 + +**系统能力**:SystemCapability.FileManagement.File.FileIO + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------- | +| path | string | 是 | 文件路径 | + +**返回值:** + +| 类型 | 说明 | +| ------ | ------------ | +| string | 返回数据标签 | + +**示例:** + +```js +let result = securityLabel.getSecurityLabelSync(path); +console.log("getSecurityLabel successfully:" + result); +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md b/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md index 4a0c2748f211e444f436c7821de63772305d1343..06de83b67df6db0bfb6bc7cd2acf64059d5f5830 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md @@ -30,7 +30,7 @@ startAbility(want: Want, callback: AsyncCallback<void>): void; "abilityName": "com.example.myapp.MyAbility" }; this.context.startAbility(want, (err) => { - console.log('startAbility result:' + JSON.stringfy(err)); + console.log('startAbility result:' + JSON.stringify(err)); }); ``` @@ -63,9 +63,9 @@ startAbility(want: Want): Promise<void>; "abilityName": "com.example.myapp.MyAbility" }; this.context.startAbility(want).then((data) => { - console.log('success:' + JSON.stringfy(data)); + console.log('success:' + JSON.stringify(data)); }).catch((error) => { - console.log('failed:' + JSON.stringfy(error)); + console.log('failed:' + JSON.stringify(error)); }); ``` @@ -88,7 +88,7 @@ terminateSelf(callback: AsyncCallback<void>): void; ```js this.context.terminateSelf((err) => { - console.log('terminateSelf result:' + JSON.stringfy(err)); + console.log('terminateSelf result:' + JSON.stringify(err)); }); ``` @@ -111,9 +111,9 @@ terminateSelf(): Promise<void>; ```js this.context.terminateSelf(want).then((data) => { - console.log('success:' + JSON.stringfy(data)); + console.log('success:' + JSON.stringify(data)); }).catch((error) => { - console.log('failed:' + JSON.stringfy(error)); + console.log('failed:' + JSON.stringify(error)); }); ``` @@ -174,7 +174,7 @@ disconnectAbility(connection: number, callback:AsyncCallback<void>): void; ```js this.context.disconnectAbility(connection, (err) => { // connection为connectAbility中的返回值 - console.log('terminateSelf result:' + JSON.stringfy(err)); + console.log('terminateSelf result:' + JSON.stringify(err)); }); ``` @@ -203,9 +203,9 @@ disconnectAbility(connection: number): Promise<void>; ```js this.context.disconnectAbility(connection).then((data) => { // connection为connectAbility中的返回值 - console.log('success:' + JSON.stringfy(data)); + console.log('success:' + JSON.stringify(data)); }).catch((error) => { - console.log('failed:' + JSON.stringfy(error)); + console.log('failed:' + JSON.stringify(error)); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-serviceExtAbilityContext.md b/zh-cn/application-dev/reference/apis/js-apis-serviceExtAbilityContext.md index ecb3049364a35c7ab82ef4741b901c6c8ab753f7..3e9478ea680c493c2b3952819d8ca76aa2214fb2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-serviceExtAbilityContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-serviceExtAbilityContext.md @@ -239,7 +239,7 @@ terminateSelf(callback: AsyncCallback<void>): void ```js this.context.terminateSelf((err) => { - console.log('terminateSelf result:' + JSON.stringfy(err)); + console.log('terminateSelf result:' + JSON.stringify(err)); }); ``` @@ -261,9 +261,9 @@ terminateSelf(): Promise<void> ```js this.context.terminateSelf(want).then((data) => { - console.log('success:' + JSON.stringfy(data)); + console.log('success:' + JSON.stringify(data)); }).catch((error) => { - console.log('failed:' + JSON.stringfy(error)); + console.log('failed:' + JSON.stringify(error)); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md index dde71634ef505143dab3fad9920c71c5925282f3..498e21eeaa2b0f6ca0561f8ae61881c4c0291123 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md +++ b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md @@ -4,14 +4,13 @@ > > - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > - API 9当前为Canary版本,仅供试用,不保证接口可稳定调用。 -> - 本模块接口为系统接口,三方应用不支持调用。 该模块提供空间查询相关的常用功能:包括对内外卡的空间查询,对应用分类数据统计的查询,对应用数据的查询等。 ## 导入模块 ```js -import storagestatistics from "@ohos.storageStatistics"; +import storageStatistics from "@ohos.storageStatistics"; ``` ## storagestatistics.getTotalSizeOfVolume @@ -20,8 +19,12 @@ getTotalSizeOfVolume(volumeUuid: string): Promise<number> 异步获取指定卷的总空间大小,以promise方式返回。 +**需要权限**:ohos.permission.STORAGE_MANAGER + **系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics +该接口为系统接口,三方应用不支持调用 + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -51,8 +54,12 @@ getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):v 异步获取指定卷的总空间大小,以callback方式返回。 +**需要权限**:ohos.permission.STORAGE_MANAGER + **系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics +该接口为系统接口,三方应用不支持调用 + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -78,8 +85,12 @@ getFreeSizeOfVolume(volumeUuid: string): Promise<number> 异步获取指定卷的可用空间大小,以promise方式返回。 +**需要权限**:ohos.permission.STORAGE_MANAGER + **系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics +该接口为系统接口,三方应用不支持调用 + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -110,8 +121,12 @@ getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):vo 异步获取指定卷的可用空间大小,以callback方式返回。 +**需要权限**:ohos.permission.STORAGE_MANAGER + **系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics +该接口为系统接口,三方应用不支持调用 + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -135,8 +150,12 @@ getBundleStats(packageName: string): Promise<BundleStats> 异步获取应用存储数据,以promise方式返回。 +**需要权限**:ohos.permission.STORAGE_MANAGER + **系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics +该接口为系统接口,三方应用不支持调用 + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -166,8 +185,12 @@ getBundleStats(packageName: string, callback: AsyncCallback<BundleStats>) 异步获取应用存储数据,以callback方式返回。 +**需要权限**:ohos.permission.STORAGE_MANAGER + **系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics +该接口为系统接口,三方应用不支持调用 + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -185,14 +208,312 @@ getBundleStats(packageName: string, callback: AsyncCallback<BundleStats>) }); ``` + + +## storagestatistics.getCurrentBundleStats9+ + +getCurrentBundleStats(): Promise + +第三方应用异步获取占用空间,以promise方式返回。 + +**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics + +- 返回值 + + | 类型 | 说明 | + | ------------------------------------------ | -------------------------- | + | Promise<[Bundlestats](#bundlestats)> | 返回指定卷上的应用存储状态 | + +- 示例 + + ```js + let bundleStats = storageStatistics.getCurrentBundleStats(); + console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats)); + ``` + +## storagestatistics.getCurrentBundleStats9+ + +getCurrentBundleStats(callback: AsyncCallback): void + +第三方应用异步获取占用空间,以callback方式返回。 + +**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------------------------------------- | ---- | ------------------------------------ | + | callback | callback:AsyncCallback<[BundleStats](#bundlestats)> | 是 | 获取指定卷上的应用存储状态之后的回调 | + +- 示例 + + ```js + storagestatistics.getCurrentBundleStats(function(error, bundleStats){ + // do something + console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats)); + }); + ``` + + + ## BundleStats9+ **系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.StorageService.SpatialStatistics。 +该接口为系统接口,三方应用不支持调用 + +- 属性 + +| 名称 | 类型 | 说明 | +| --------- | ------ | -------------- | +| appSize | number | app数据大小 | +| cacheSize | number | 缓存数据大小 | +| dataSize | number | 应用总数据大小 | + + + + +## storagestatistics.getTotalSize9+ + +getTotalSize(): Promise + +获取内卡的总空间大小,以promise方式返回。 + +**需要权限**:ohos.permission.STORAGE_MANAGER + +**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics + +该接口为系统接口,三方应用不支持调用 + +- 返回值 + + | 类型 | 说明 | + | --------------------- | ------------------ | + | Promise<number> | 返回内卡的总空间大小 | + +- 示例 + + ```js + let number = storageStatistics.getTotalSize(); + console.info("getTotalSize successfully:"+ JSON.stringify(number)); + ``` + +## storagestatistics.getTotalSize9+ + +getTotalSize(callback: AsyncCallback): void + +获取内卡的总空间大小,以callback方式返回。 + +**需要权限**:ohos.permission.STORAGE_MANAGER + +**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics + +该接口为系统接口,三方应用不支持调用 + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------------ | ---- | ------------------------ | + | callback | callback:AsyncCallback<number> | 是 | 获取内卡的总空间大小之后的回调 | + +- 示例 + + ```js + storagestatistics.getTotalSize(function(error, number){ + // do something + console.info("getTotalSize successfully:"+ JSON.stringify(number)); + }); + ``` + + +## storagestatistics.getFreeSize9+ + +getFreeSize(): Promise + +获取内卡的可用空间大小,以promise方式返回。 + +**需要权限**:ohos.permission.STORAGE_MANAGER + +**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics + +该接口为系统接口,三方应用不支持调用 + +- 返回值 + + | 类型 | 说明 | + | --------------------- | ------------------ | + | Promise<number> | 返回内卡的可用空间大小 | + +- 示例 + + ```js + let number = storageStatistics.getFreeSize(); + console.info("getFreeSize successfully:"+ JSON.stringify(number)); + ``` + + +## storagestatistics.getFreeSize9+ + +getFreeSize(callback: AsyncCallback): void -### 属性 +获取内卡的可用空间大小,以callback方式返回。 + +**需要权限**:ohos.permission.STORAGE_MANAGER + +**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics + +该接口为系统接口,三方应用不支持调用 + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------------ | ---- | ------------------------- | + | callback | callback:AsyncCallback<number> | 是 | 获取内卡的可用空间大小之后的回调 | + +- 示例 + + ```js + storagestatistics.getFreeSize(function(error, number){ + // do something + console.info("getFreeSize successfully:"+ JSON.stringify(number)); + }); + ``` + + + +## storagestatistics.getSystemSize9+ + +getSystemSize(): Promise<number> + +异步获取系统空间大小,以promise方式返回。 + +**需要权限**:ohos.permission.STORAGE_MANAGER + +**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics + +该接口为系统接口,三方应用不支持调用 + +- 返回值 + + | 类型 | 说明 | + | --------------------- | ---------------- | + | Promise<number> | 返回系统空间大小 | + +- 示例 + + ```js + storagestatistics.getSystemSize().then(function(number){ + console.info("getSystemSize successfully:"+ number); + }).catch(function(err){ + console.info("getSystemSize failed with error:"+ err); + }); + ``` + +## storagestatistics.getSystemSize9+ + +getSystemSize(callback:AsyncCallback<number>):void + +异步获取系统空间大小,以callback方式返回。 + +**需要权限**:ohos.permission.STORAGE_MANAGER + +**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics + +该接口为系统接口,三方应用不支持调用 + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ---------- | ------------------------------------ | ---- | -------------------------- | + | callback | callback:AsyncCallback<number> | 是 | 获取系统空间大小之后的回调 | + +- 示例 + + ```js + storagestatistics.getSystemSize(function(error, number){ + // do something + console.info("getSystemSize successfully:"+ number); + }); + ``` + + + +## storagestatistics.getUserStorageStats9+ + +getUserStorageStats(userId?: number): Promise<StorageStats> + +异步获取用户各类别数据大小,以promise方式返回。 + +**需要权限**:ohos.permission.STORAGE_MANAGER + +**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics + +该接口为系统接口,三方应用不支持调用 + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ---------- | ------ | ---- | ---- | + | userId | string | 否 | 用户id
确认当前用户:
- 有值:表示指定用户。
- 无值:表示当前用户。| + +- 返回值 + + | 类型 | 说明 | + | --------------------- | ---------------- | + | Promise<[StorageStats](#StorageStats)> | 返回各类别数据大小 | + +- 示例 + + ```js + let userId = ""; + storagestatistics.getUserStorageStats(userId).then(function(StorageStats){ + console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats)); + }).catch(function(err){ + console.info("getUserStorageStats failed with error:"+ err); + }); + ``` + +## storagestatistics.getUserStorageStats9+ + +getUserStorageStats(userId?: number, callback:AsyncCallback<StorageStats>):void + +异步获取用户各类别数据大小,以callback方式返回。 + +**需要权限**:ohos.permission.STORAGE_MANAGER + +**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics + +该接口为系统接口,三方应用不支持调用 + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ---------- | ------------------------------------ | ---- | -------------------------- | + | userId | string | 否 | 用户id
确认当前用户:
- 有值:表示指定用户。
- 无值:表示当前用户。 | + | callback | callback:AsyncCallback<[StorageStats](#StorageStats)> | 是 | 返回各类别数据大小之后的回调 | + +- 示例 + + ```js + let userId = ""; + storagestatistics.getUserStorageStats(userId, function(error, StorageStats){ + // do something + console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats)); + }); + ``` + + + +## StorageStats9+ + +**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.StorageService.SpatialStatistics。 +该接口为系统接口,三方应用不支持调用 +- 属性 | 名称 | 类型 | 说明 | | --------- | ------ | -------------- | -| appSize9+ | number | app数据大小 | -| cacheSize9+ | number | 缓存数据大小 | -| dataSize9+ | number | 应用总数据大小 | \ No newline at end of file +| total | number | 内卡总空间大小 | +| audio | number | 音频数据大小 | +| video | number | 视频数据大小 | +| image | number | 图像数据大小 | +| file | number | 文件数据大小 | +| app | number | 应用数据大小 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md b/zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md index 56d31795e0c9eb29d9356f4aa74a9f975e21fbeb..8c47784a03e047c85daa9afe99fe0eab5eae886a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md @@ -130,19 +130,12 @@ ohos.permission.MANAGE_BLUETOOTH **示例:** ``` - bluetooth.startBLEScan({ - success() { - bluetooth.subscribeBLEFound({ - success(data) { - const [device] = data.devices; - if (!!device) { - bluetooth.stopBLEScan(); - } - } - }); + bluetooth.subscribeBLEFound({ + success(data) { + console.log('call bluetooth.subscribeBLEFound success, data: ${data}.'); }, - fail(code, data) { - console.log('Failed to start BLE device scan, code: ${code}, data: ${data}'); + fail(data, code) { + console.log('call bluetooth.startBLEScan failed, data: ${data}, code: ${code}.'); } }); ``` diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-media-video.md b/zh-cn/application-dev/reference/arkui-js/js-components-media-video.md index b6543f274240de6c854dc9ef0873f917bf0e75a0..ed78e584cda4e427b4e3f43a468d066a5ab295bf 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-media-video.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-media-video.md @@ -89,7 +89,7 @@ onpaues='pauesCallback' onfinish='finishCallback' onerror='errorCallback' onseeking='seekingCallback' onseeked='seekedCallback' ontimeupdate='timeupdateCallback' - style="object-fit:fit; width:80%; height:400px;" + style="object-fit:fill; width:80%; height:400px;" onclick="change_start_pause">
diff --git a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md index c222d894d5c06802e196e1bfe20cd15d9e2b29ed..476b00bf7175aa04eb12cc36ffae87f114df7e12 100644 --- a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md @@ -61,8 +61,6 @@ - [LoadingProgress](ts-basic-components-loadingprogress.md) - [Marquee](ts-basic-components-marquee.md) - [Navigation](ts-basic-components-navigation.md) - - [PatternLock](ts-basic-components-patternlock.md) - - [PluginComponent](ts-basic-components-plugincomponent.md) - [Progress](ts-basic-components-progress.md) - [QRCode](ts-basic-components-qrcode.md) - [Radio](ts-basic-components-radio.md) diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/patternlock.gif b/zh-cn/application-dev/reference/arkui-ts/figures/patternlock.gif deleted file mode 100644 index 5fb034ddcf247a1fecaaeb33e27d103bd8225a91..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/patternlock.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md deleted file mode 100644 index 696f156eac486c5ccbbd74bfa1ff0c3551c8af3d..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md +++ /dev/null @@ -1,109 +0,0 @@ -# PatternLock - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - -图案密码锁组件,以宫格图案的方式输入密码,用于密码验证。手指触碰图案密码锁时开始进入输入状态,手指离开屏幕时结束输入状态并向应用返回输入的密码。 - -## 权限列表 - -无 - -## 子组件 - -无 - -## 接口 - -PatternLock(controller?: PatternLockController) - -- 参数 - - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | ---------- | ----------------------------------------------- | ---- | ------ | -------------------------------------------- | - | controller | [PatternLockController](#patternlockcontroller) | 否 | null | 给组件绑定一个控制器,用来控制组件状态重置。 | - -## 属性 - -不支持`backgroundColor`以外的通用属性设置。 - -| 名称 | 参数类型 | 默认值 | 描述 | -| --------------- | --------------------------------------------------- | ----------- | ------------------------------------------------------------ | -| sideLength | Length | 300vp | 设置组件的宽度和高度(相同值)。最小可以设置为0。 | -| circleRadius | Length | 14vp | 设置宫格圆点的半径。 | -| regularColor | [ResourceColor](../../ui/ts-types.md) | Color.Black | 设置宫格圆点在“未选中”状态的填充颜色。 | -| selectedColor | [ResourceColor](../../ui/ts-types.md) | Color.Black | 设置宫格圆点在“选中”状态的填充颜色。 | -| activeColor | [ResourceColor](../../ui/ts-types.md) | Color.Black | 设置宫格圆点在“激活”状态的填充颜色。 | -| pathColor | [ResourceColor](../../ui/ts-types.md) | Color.Blue | 设置连线的颜色。 | -| pathStrokeWidth | Length | 34vp | 设置连线的宽度。最小可以设置为0。 | -| autoReset | boolean | true | 设置是否支持用户在完成输入后再次触屏重置组件状态。如果设置为true,用户可以通过触摸图案密码锁重置组件状态(清除之前的输入效果);如果设置为false,用户手指离开屏幕完成输入后,再次触摸图案密码锁(包括圆点)不能改变之前的输入状态。 | - -## 事件 - -| 名称 | 功能描述 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| onPatternComplete(callback: (input: Array\) => void) | 密码输入结束时被调用的回调函数。
input: 与选中宫格圆点顺序一致的数字数组,数字为选中宫格的索引(0到8)。 | - -## PatternLockController - -PatternLock组件的控制器,可以将此对象绑定至PatternLock组件,然后通过它进行状态重置。 - -### 导入对象 - -```typescript -patternLockController: PatternLockController = new PatternLockController() -``` - -### reset - -reset(): void - -重置组件状态。 - -## 示例 - -```typescript -@Entry -@Component -struct PatternLockExample { - @State passwords: Number[] = [] - @State message: string = 'please input password' - private patternLockController: PatternLockController = new PatternLockController() - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(this.message).textAlign(TextAlign.Center) - PatternLock(this.patternLockController) - .sideLength(150) - .circleRadius(7) - .pathStrokeWidth(17) - .backgroundColor(Color.White) - .autoReset(true) - .onPatternComplete((input: Array) => { - if (input == null || input == undefined || input.length < 5) { - this.message = 'The password length needs to be greater than 5.' - return - } - if (this.passwords.length > 0) { - if (this.passwords.toString() == input.toString()) { - this.passwords = input - this.message = 'Set password successfully: ' + this.passwords.toString() - } else { - this.message = 'Inconsistent passwords, please enter again.' - } - } else { - this.passwords = input - this.message = "Please enter again." - } - }) - Button('reset button').margin(30).onClick(() => { - this.patternLockController.reset() - this.passwords = [] - this.message = 'Please input password' - }) - }.width('100%').height('100%') - } -} -``` - -![patternlock](figures/patternlock.gif) - diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md deleted file mode 100644 index 7707e68d943582a05fe4c4d86183830b5a5a6224..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md +++ /dev/null @@ -1,318 +0,0 @@ -# PluginComponent - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -> -> - 本组件均为系统接口,三方应用不支持调用。 - - -提供外部应用组件嵌入式显示功能,即外部应用提供的UI可在本应用内显示。 - - -## 权限列表 - -无 - - -## 子组件 - -无 - - -## 接口 - -PluginComponent(value: { template: PluginComponentTemplate, data: any }) - -创建插件组件,用于显示外部应用提供的UI。 - -- 参数 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | value | {
template: PluginComponentTemplate,
data: KVObject
} | 是 | - | template:  组件模板,用于跟提供者定义的组件绑定。
data: 传给插件组件提供者使用的数据。 | - -- PluginComponentTemplate类型说明 - | 参数 | 类型 | 描述 | - | -------- | -------- | -------- | - | source | string | 组件模板名。 | - | ability | string | 提供者Ability的abilityname。 | - - -## 事件 - - | 名称 | 功能描述 | -| -------- | -------- | -| onComplete(callback: () => void) | 组件加载完成回调。 | -| onError(callback: (info: { errcode: number, msg: string }) => void) | 组件加载错误回调。
errcode: 错误码。
msg: 错误信息。 | - - -## PluginComponentManager - -提供配套插件组件使用的相关接口,用于给插件组件的使用者请求组件与数据,使用者发送组件模板和数据。 - - -## 导入模块 - - -``` -import pluginComponentManager from '@ohos.plugincomponent' -``` - - -## push - -push(param: PushParameters, callback: AsyncCallback<void>): void - -组件提供者向组件使用者主动发送组件与数据。 - - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | param | PushParameters | 是 | 组件使用者的详细信息,详见PushParameters参数说明。 | - | callback | AsyncCallback<void> | 是 | 此次接口调用的异步回调。 | - -- PushParameters参数说明 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | Want | 是 | 组件使用者Ability信息。 | - | name | string | 是 | 组件名称。 | - | data | KVObject | 否 | 组件数据值。 | - | extraData | KVObject | 否 | 附加数据值。 | - -- 示例 - 见[组件使用者调用接口](#组件使用者调用接口)示例。 - - -## request - -request(param: RequestParameters, callback: AsyncCallback<RequestCallbackParameters>): void - -组件使用者向组件提供者主动请求组件。 - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | param | RequestParameters | 是 | 组件模板的详细请求信息,详见RequestParameters参数说明。 | - | callback | AsyncCallback"push”:指组件提供者向使用者主动推送数据。
"request”:指组件使用者向提供者主动请求数据。 | - | callback | OnPushEventCallback \| OnRequestEventCallback | 是 | 见callback事件说明。 | - -- callback事件说明 - | 参数名 | 类型 | 说明 | - | -------- | -------- | -------- | - | OnRequestEventCallback | (source: Want,
name: string,
data: KVObject ) =>RequestEventResult | 数据请求事件的回调。
source: 组件请求方Ability信息。
name: 请求组件名称。
data: 附加数据。
返回值: 请求数据结果。 | - | OnPushEventCallback | (source: Want,
template: PluginComponentTemplate,
data: KVObject,
extraData: KVObject
) => void | 接收提供者主动推送的数据。
source: 组件提供者Ability信息。
template: 组件模板。
data: 组件更新数据。
extraData: 附加数据。 | - -- RequestEventResult类型说明 - | 参数 | 类型 | 说明 | - | -------- | -------- | -------- | - | template | string | 组件名称。 | - | data | KVObject | 组件数据。 | - | extraData | KVObjec | 附加数据。 | - -- 示例 - 见[组件使用者调用接口](#组件使用者调用接口)示例。 - - -## 示例 - - -### 使用PluginComponent组件 - - -``` -import plugin from "../../test/plugin_component.js" -import plugincomponent from '@ohos.plugincomponent' - -@Entry -@Component -struct PluginComponentExample { - @StorageLink("plugincount") plugincount: Object[] = [ - { source: 'plugincomponent1', ability: 'com.example.plugin' }, - { source: 'plugintemplate', ability: 'com.example.myapplication' }, - { source: 'plugintemplate', ability: 'com.example.myapplication' }] - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('Hello World') - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button('Push') - .fontSize(50) - .width(400) - .height(100) - .onClick(() => { - plugin.Push() - console.log("Button('Push')") - }) - .margin({ top: 20 }) - Button('Request1') - .fontSize(50) - .width(400) - .height(100) - .margin({ top: 20 }) - .onClick(() => { - plugin.Request1() - console.log("Button('Request1')") - }) - Button('Request2') - .fontSize(50) - .width(400) - .height(100) - .margin({ top: 20 }) - .onClick(() => { - plugin.Request2() - console.log("Button('Request2')") - }) - ForEach(this.plugincount, item => { - PluginComponent({ - template: { source: 'plugincomponent1', ability: 'com.example.plugin' }, - data: { 'countDownStartValue': 'new countDownStartValue' } - }).size({ width: 500, height: 100 }) - .onComplete(() => { - console.log("onComplete") - }) - .onError(({errcode, msg}) => { - console.log("onComplete" + errcode + ":" + msg) - }) - }) - } - .width('100%') - .height('100%') -} -``` - - -### 组件使用者调用接口 - - -``` -import pluginComponentManager from '@ohos.plugincomponent' - -function onPushListener(source, template, data, extraData) { - console.log("onPushListener template.source=" + template.source) - var jsonObject = JSON.parse(data.componentTemplate.source) - console.log("request_callback1:source json object" + jsonObject) - var jsonArry = jsonObject.ExternalComponent - for (var i in jsonArry) { - console.log(jsonArry[i]) - } - console.log("onPushListener:source json object" + jsonObject) - console.log("onPushListener:source json string" + JSON.stringify(jsonObject)) - console.log("onPushListener template.ability=" + template.ability) - console.log("onPushListener data=" + JSON.stringify(data)) - console.log("onPushListener extraData=" + JSON.stringify(extraData)) -} - -export default { - //register listener - onListener() { - pluginComponentManager.on("push", onPushListener) - }, - Request() { - // 组件使用者主动发送事件 - pluginComponentManager.request({ - want: { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", - }, - name: "plugintemplate", - data: { - "key_1": "plugin component test", - "key_2": 34234 - }, - jsonPath: "assets/js", - }, - (err, data) => { - console.log("request_callback1: componentTemplate.ability=" + data.componentTemplate.ability) - console.log("request_callback1: componentTemplate.source=" + data.componentTemplate.source) - var jsonObject = JSON.parse(data.componentTemplate.source) - console.log("request_callback1:source json object" + jsonObject) - var jsonArry = jsonObject.ExternalComponent - for (var i in jsonArry) { - console.log(jsonArry[i]) - } - console.log("request_callback1:source json string" + JSON.stringify(jsonObject)) - console.log("request_callback1: data=" + JSON.stringify(data.data)) - console.log("request_callback1: extraData=" + JSON.stringify(data.extraData)) - } - ) - } -} - -// 组件提供者使用接口示例 -import pluginComponentManager from '@ohos.plugincomponent' - -function onRequestListener(source, name, data) { - console.log("onRequestListener name=" + name) - console.log("onRequestListener data=" + JSON.stringify(data)) - return { template: "plugintemplate", data: data } -} - -export default { - //register listener - onListener() { - pluginComponentManager.on("request", onRequestListener) - }, - Push() { - // 组件提供者主动发送事件 - pluginComponentManager.push( - { - want: { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", - }, - name: "plugintemplate", - data: { - "key_1": "plugin component test", - "key_2": 34234 - }, - extraData: { - "extra_str": "this is push event" - }, - jsonPath: "assets/js", - }, - (err, data) => { - console.log("push_callback1: componentTemplate.ability=" + data.componentTemplate.ability) - console.log("push_callback1: componentTemplate.source=" + data.componentTemplate.source) - console.log("push ok!") - } - ) - }, -} -``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md index 1acb2860c210eb3d445c238c27bfcc3bb81e4cbf..412a9e92d689abe82a752e1e6aa76956218bc71b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md @@ -86,8 +86,8 @@ struct ProgressExample { Text('Capsule Progress').fontSize(9).fontColor(0xCCCCCC).width('90%') Row({ space: 40 }) { - Progress({ value: 10, type: ProgressType.Capsule }).width(100) - Progress({ value: 20, total: 150, type: ProgressType.Capsule }).color(Color.Grey).value(50).width(100) + Progress({ value: 10, type: ProgressType.Capsule }).width(100).height(50) + Progress({ value: 20, total: 150, type: ProgressType.Capsule }).color(Color.Grey).value(50).width(100).height(50) } }.width('100%').margin({ top: 30 }) } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md index f513523443f42d8038c2fc34ed5d3d4d40e1129a..4198db7e5be91587fb5a41102494ed813eb3c43f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md @@ -19,7 +19,7 @@ ## 接口 -TextArea(value?:{placeholder?: string controller?: TextAreaController}) +TextArea(value?:{placeholder?: string, controller?: TextAreaController}) - 参数 | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | @@ -89,10 +89,11 @@ caretPosition(value: number): void @Entry @Component struct TextAreaExample1 { + controller: TextAreaController = new TextAreaController() @State text: string = '' build() { Column() { - TextArea({ placeholder: 'input your word'}) + TextArea({ placeholder: 'input your word', controller: this.controller}) .placeholderColor("rgb(0,0,225)") .placeholderFont({ size: 30, weight: 100, family: 'cursive', style: FontStyle.Italic }) .textAlign(TextAlign.Center) @@ -108,6 +109,7 @@ struct TextAreaExample1 { }) .onChange((value: string) => { this.text = value + this.controller.caretPosition(-1) }) Text(this.text).width('90%') } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md index 279471bbf8ae99a48673addb5fd64e17c2f1a760..fbcf06c14522788f37289633f844ef4f5de7429c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md @@ -105,10 +105,9 @@ struct TextInputExample1 { build() { Column() { - TextArea({ placeholder: 'input your word' }) + TextInput({ placeholder: 'input your word' }) .placeholderColor("rgb(0,0,225)") .placeholderFont({ size: 30, weight: 100, family: 'cursive', style: FontStyle.Italic }) - .textAlign(TextAlign.Center) .caretColor(Color.Blue) .height(50) .fontSize(30) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md index b8afaa69fd71ca9e71ee62ddc6b4e7cfa9cf51b9..cab72748f3c7faa088f282a5a93ffc9eb1a5f554 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md @@ -53,12 +53,13 @@ Navigator(value?: {target: string, type?: NavigationType}) @Component struct NavigatorExample { @State active: boolean = false - @State Text: string = 'news' + @State Text: object = {name: 'news'} build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { Navigator({ target: 'pages/container/navigator/Detail', type: NavigationType.Push }) { - Text('Go to ' + this.Text + ' page').width('100%').textAlign(TextAlign.Center) + Text('Go to ' + this.Text['name'] + ' page') + .width('100%').textAlign(TextAlign.Center) }.params({ text: this.Text }) Navigator() { @@ -79,7 +80,7 @@ import router from '@system.router' @Entry @Component struct DetailExample { - @State text: string = router.getParams().text + @State text: any = router.getParams().text build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { @@ -87,7 +88,8 @@ struct DetailExample { Text('Go to back page').width('100%').height(20) } - Text('This is ' + this.text + ' page').width('100%').textAlign(TextAlign.Center) + Text('This is ' + this.text['name'] + ' page') + .width('100%').textAlign(TextAlign.Center) } .width('100%').height(200).padding({ left: 35, right: 35, top: 35 }) } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md index 66f26667443d157bbfb7aa9b59cf85eed8ceb66b..e0b41f791ecc55f34ef6fb2ab63d7557c591f1df 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md @@ -3,7 +3,9 @@ id为组件的唯一标识,在整个应用内唯一。本模块提供组件标识相关接口,可以获取指定id组件的属性,也提供向指定id组件发送事件的功能。 > **说明:** -> 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> - 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> - 本模块接口为系统接口。 ## 权限列表 @@ -13,9 +15,9 @@ id为组件的唯一标识,在整个应用内唯一。本模块提供组件标 ## 属性 -| 名称 | 参数说明 | 默认值 | 描述 | -| -------- | -------- | -------- | -------- | -| id | string | '' | 组件的唯一标识,唯一性由使用者保证。 | +| 名称 | 参数说明 | 默认值 | 描述 | +| ---- | ------ | ---- | ------------------ | +| id | string | '' | 组件的唯一标识,唯一性由使用者保证。 | ## 接口 @@ -28,14 +30,14 @@ getInspectorByKey(id: string): string 获取指定id的组件的所有属性,不包括子组件信息。 - 参数 - | 参数 | 类型 | 必填 | 默认值 | 描述 | - | -------- | -------- | -------- | -------- | -------- | - | id | string | 是 | - | 要获取属性的组件id。 | + | 参数 | 类型 | 必填 | 默认值 | 描述 | + | ---- | ------ | ---- | ---- | ----------- | + | id | string | 是 | - | 要获取属性的组件id。 | - 返回值 - | 类型 | 描述 | - | -------- | -------- | - | string | 组件属性列表的JSON字符串。 | + | 类型 | 描述 | + | ------ | --------------- | + | string | 组件属性列表的JSON字符串。 | ### getInspectorTree @@ -45,8 +47,8 @@ getInspectorTree(): string - 返回值 - | 类型 | 描述 | - | ------ | ---------------------------------- | + | 类型 | 描述 | + | ------ | ------------------- | | string | 组件树及组件属性列表的JSON字符串。 | ### sendEventByKey @@ -56,16 +58,16 @@ sendEventByKey(id: string, action: number, params: string): boolean 给指定id的组件发送事件。 - 参数 - | 参数 | 类型 | 必填 | 默认值 | 描述 | - | -------- | -------- | -------- | -------- | -------- | - | id | string | 是 | - | 要触发事件的组件的id。 | - | action | number | 是 | - | 要触发的事件类型,目前支持取值:
- 点击事件Click: 10
- 长按事件LongClick: 11。 | - | params | string | 是 | - | 事件参数,无参数传空字符串 ""。 | + | 参数 | 类型 | 必填 | 默认值 | 描述 | + | ------ | ------ | ---- | ---- | ---------------------------------------- | + | id | string | 是 | - | 要触发事件的组件的id。 | + | action | number | 是 | - | 要触发的事件类型,目前支持取值:
- 点击事件Click: 10
- 长按事件LongClick: 11。 | + | params | string | 是 | - | 事件参数,无参数传空字符串 ""。 | - 返回值 - | 类型 | 描述 | - | -------- | -------- | - | boolean | 找不到指定id的组件时返回false,其余情况返回true。 | + | 类型 | 描述 | + | ------- | ------------------------------ | + | boolean | 找不到指定id的组件时返回false,其余情况返回true。 | ### sendTouchEvent @@ -75,14 +77,14 @@ sendTouchEvent(event: TouchObject): boolean - 参数 - | 参数 | 类型 | 必填 | 默认值 | 描述 | - | ----- | ----------- | ---- | ------ | ------------------------------------------------------------ | - | event | TouchObject | 是 | - | 触发触摸事件的位置,event参数见[TouchEvent](ts-universal-events-touch.md#touchevent对象说明)中TouchObject的介绍。 | + | 参数 | 类型 | 必填 | 默认值 | 描述 | + | ----- | ----------- | ---- | ---- | ---------------------------------------- | + | event | TouchObject | 是 | - | 触发触摸事件的位置,event参数见[TouchEvent](ts-universal-events-touch.md#touchevent对象说明)中TouchObject的介绍。 | - 返回值 - | 类型 | 描述 | - | ------- | ------------------------------------------- | + | 类型 | 描述 | + | ------- | -------------------------- | | boolean | 事件发送失败时返回false,其余情况返回true。 | ### sendKeyEvent @@ -93,14 +95,14 @@ sendKeyEvent(event: KeyEvent): boolean - 参数 - | 参数 | 类型 | 必填 | 默认值 | 描述 | - | ----- | -------- | ---- | ------ | ------------------------------------------------------------ | - | event | KeyEvent | 是 | - | 按键事件,event参数见[KeyEvent](ts-universal-events-key.md#keyevent对象说明)介绍。 | + | 参数 | 类型 | 必填 | 默认值 | 描述 | + | ----- | -------- | ---- | ---- | ---------------------------------------- | + | event | KeyEvent | 是 | - | 按键事件,event参数见[KeyEvent](ts-universal-events-key.md#keyevent对象说明)介绍。 | - 返回值 - | 类型 | 描述 | - | ------- | --------------------------------------------- | + | 类型 | 描述 | + | ------- | --------------------------- | | boolean | 事件发送失败时时返回false,其余情况返回true。 | ### sendMouseEvent @@ -111,14 +113,14 @@ sendMouseEvent(event: MouseEvent): boolean - 参数 - | 参数 | 类型 | 必填 | 默认值 | 描述 | - | ----- | ---------- | ---- | ------ | ------------------------------------------------------------ | - | event | MouseEvent | 是 | - | 鼠标事件,event参数见[MouseEvent](ts-universal-mouse-key.md#mouseevent对象说明)介绍。 | + | 参数 | 类型 | 必填 | 默认值 | 描述 | + | ----- | ---------- | ---- | ---- | ---------------------------------------- | + | event | MouseEvent | 是 | - | 鼠标事件,event参数见[MouseEvent](ts-universal-mouse-key.md#mouseevent对象说明)介绍。 | - 返回值 - | 类型 | 描述 | - | ------- | --------------------------------------------- | + | 类型 | 描述 | + | ------- | --------------------------- | | boolean | 事件发送失败时时返回false,其余情况返回true。 | ## 示例 diff --git a/zh-cn/application-dev/website.md b/zh-cn/application-dev/website.md index 78b1d10e134ee101ca7b4b0db6ce23144d403c92..f0ad41f67ce1ff95e83c2c73df5f939a35e44c22 100644 --- a/zh-cn/application-dev/website.md +++ b/zh-cn/application-dev/website.md @@ -925,10 +925,6 @@ - [Navigation](reference/arkui-ts/ts-basic-components-navigation.md) - - [PatternLock](reference/arkui-ts/ts-basic-components-patternlock.md) - - - [PluginComponent](reference/arkui-ts/ts-basic-components-plugincomponent.md) - - [Progress](reference/arkui-ts/ts-basic-components-progress.md) - [QRCode](reference/arkui-ts/ts-basic-components-qrcode.md) diff --git a/zh-cn/device-dev/driver/driver-platform-rtc-develop.md b/zh-cn/device-dev/driver/driver-platform-rtc-develop.md index 3a2c2b4d7c59e3623b4b8a8daa3965bcc827f64e..516c6c212972e4a9513fc5f056e4e47de36ecc47 100755 --- a/zh-cn/device-dev/driver/driver-platform-rtc-develop.md +++ b/zh-cn/device-dev/driver/driver-platform-rtc-develop.md @@ -404,11 +404,11 @@ RTC模块适配HDF框架的三个环节是配置属性文件,实例化驱动 struct RtcHost *host = NULL; struct RtcConfigInfo *rtcInfo = NULL; ... - host = RtcHostFromDevice(device);//这里有HdfDeviceObject到RtcHost的强制转化 + host = RtcHostFromDevice(device);//这里是HdfDeviceObject到RtcHost的强制转化 rtcInfo = OsalMemCalloc(sizeof(*rtcInfo)); ... //HiRtcConfigData 会从设备配置树中读取属性填充rtcInfo 的supportAnaCtrl, supportLock, spiBaseAddr, regAddrLength, irq - //为HiRtcSwInit 和HiRtcSwInit 提供参数,...函数内部处理失败后内存释放等操作 + //为HiRtcSwInit 和HiRtcSwInit 提供参数,当函数HiRtcSwInit和HiRtcSwInit内部执行失败后进行内存释放等操作 if (HiRtcConfigData(rtcInfo, device->property) != 0) { ... } @@ -446,8 +446,8 @@ RTC模块适配HDF框架的三个环节是配置属性文件,实例化驱动 struct RtcHost *host = NULL; struct RtcConfigInfo *rtcInfo = NULL; ... - host = RtcHostFromDevice(device); //这里有HdfDeviceObject到RtcHost的强制转化 - rtcInfo = (struct RtcConfigInfo *)host->data;//这里有RtcHost到RtcConfigInfo的强制转化 + host = RtcHostFromDevice(device); //这里是HdfDeviceObject到RtcHost的强制转化 + rtcInfo = (struct RtcConfigInfo *)host->data;//这里是RtcHost到RtcConfigInfo的强制转化 if (rtcInfo != NULL) { HiRtcSwExit(rtcInfo); OsalMemFree(rtcInfo); //释放RtcConfigInfo diff --git a/zh-cn/device-dev/get-code/figure/zh-cn_image_0000001168212170.png b/zh-cn/device-dev/get-code/figure/zh-cn_image_0000001168212170.png new file mode 100644 index 0000000000000000000000000000000000000000..adeca0bde20f30a087fe0a6067d93d68d0f86e31 Binary files /dev/null and b/zh-cn/device-dev/get-code/figure/zh-cn_image_0000001168212170.png differ diff --git a/zh-cn/device-dev/get-code/sourcecode-acquire.md b/zh-cn/device-dev/get-code/sourcecode-acquire.md index e12561377977ced5d3118ca5756140246d35ce83..f0a8f61375ea17bac930d9a036b152967c7b776a 100644 --- a/zh-cn/device-dev/get-code/sourcecode-acquire.md +++ b/zh-cn/device-dev/get-code/sourcecode-acquire.md @@ -126,7 +126,7 @@ OpenHarmony当前为开发者提供了以下4种获取源码的方式,开发 4. 查找合适的发行版,点击查看发行版的详情介绍。 **图 1** 包管理 - ![](figure/包管理.png "包管理") + ![](figure/zh-cn_image_0000001168212170.png "包管理") 2. 了解发行版详情。