提交 31d11e03 编写于 作者: L LiAn 提交者: Gitee

Merge branch 'OpenHarmony-4.0-Beta2' of gitee.com:openharmony/docs into OpenHarmony-4.0-Beta2

Signed-off-by: NLiAn <lian15@huawei.com>
......@@ -16,7 +16,7 @@ Widget-related configuration includes **FormExtensionAbility** configuration and
"extensionAbilities": [
{
"name": "EntryFormAbility",
"srcEntry": "./ets/entryformability/EntryFormAbility.ts",
"srcEntry": "./ets/entryformability/EntryFormAbility.ets",
"label": "$string:EntryFormAbility_label",
"description": "$string:EntryFormAbility_desc",
"type": "form",
......@@ -42,9 +42,9 @@ Widget-related configuration includes **FormExtensionAbility** configuration and
| description | Description of the widget. The value can be a string or a resource index to descriptions in multiple languages. The value is a string with a maximum of 255 bytes.| String| Yes (initial value: left empty)|
| src | Full path of the UI code corresponding to the widget. For an ArkTS widget, the full path must contain the widget file name extension, for example, **./ets/widget/pages/WidgetCard.ets**. For a JS widget, the full path does not need to contain the widget file name extension, for example, **./js/widget/pages/WidgetCard**.| String| No|
| uiSyntax | Type of the widget.<br>- **arkts**: ArkTS widget<br>- **hml**: JS widget| String| Yes (initial value: **hml**)|
| window | Window-related configurations.| Object| Yes|
| window | Window-related configurations.| Object| YYes (initial value: see Table 2)|
| isDefault | Whether the widget is a default one. Each UIAbility has only one default widget.<br>- **true**: The widget is the default one.<br>- **false**: The widget is not the default one.| Boolean| No|
| colorMode | Color mode of the widget.<br>- **auto**: auto-adaptive color mode<br>- **dark**: dark color mode<br>- **light**: light color mode| String| Yes (initial value: **auto**)|
| colorMode | Color mode of the widget.<br>- **auto**: following the system color mode<br>- **dark**: dark color mode<br>- **light**: light color mode| String| Yes (initial value: **auto**)|
| supportDimensions | Grid styles supported by the widget.<br>- **1 * 2**: indicates a grid with one row and two columns.<br>- **2 * 2**: indicates a grid with two rows and two columns.<br>- **2 * 4**: indicates a grid with two rows and four columns.<br>- **4 * 4**: indicates a grid with four rows and four columns.| String array| No|
| defaultDimension | Default grid style of the widget. The value must be available in the **supportDimensions** array of the widget.| String| No|
| updateEnabled | Whether the widget can be updated periodically.<br>- **true**: The widget can be updated at a specified interval (**updateDuration**) or at the scheduled time (**scheduledUpdateTime**). **updateDuration** takes precedence over **scheduledUpdateTime**. If both are specified, the value specified by **updateDuration** is used.<br>- **false**: The widget cannot be updated periodically.| Boolean| No|
......@@ -56,6 +56,13 @@ Widget-related configuration includes **FormExtensionAbility** configuration and
| dataProxyEnabled | Whether the widget supports the [update-through-proxy](./arkts-ui-widget-update-by-proxy.md) feature.<br>- **true**: The widget supports the update-through-proxy feature.<br>- **false**: The widget does not support the update-through-proxy feature.<br>If this tag is set to **true**, the settings for the scheduled update time will still take effect, but the settings for the update interval and next update time will not.| Boolean| Yes (initial value: **false**)|
| isDynamic | Whether the widget is a dynamic widget. This tag only applies to ArkTS widgets.<br>- **true**: The widget is a dynamic widget.<br>- **false**: The widget is a static widget. In this case, the widget is displayed as a static image after being added.| Boolean| Yes (initial value: **true**)|
**Table 2** Internal structure of the window object
| Field| Description| Data Type| Default Value Allowed|
| -------- | -------- | -------- | -------- |
| designWidth | Baseline width for page design. The size of an element is scaled by the actual device width.| Number| Yes (initial value: **720px**)|
| autoDesignWidth | Whether to automatically calculate the baseline width for page design. If it is set to **true**, the **designWidth** attribute will be ignored, and the baseline width will be calculated based on the device width and screen density.| Boolean| Yes (initial value: **false**)|
Example configuration:
......
......@@ -2,7 +2,7 @@
- [Full SDK Compilation](full-sdk-compile-guide.md)
- [Switching to Full SDK](full-sdk-switch-guide.md)
- [Using Native APIs (NDK) of the OpenHarmony SDK in a CMake Project](cmake-with-ndk.md)
- [Using NDK in a CMake Project](cmake-with-ndk.md)
- [Application Model Development](faqs-ability.md)
- ArkUI Development (ArkTS)
- [ArkTS Syntax Usage](faqs-arkui-arkts.md)
......
# Using Native APIs (NDK) of the OpenHarmony SDK in a CMake Project
# Using NDK in a CMake Project
## What Is Native API
......@@ -10,34 +10,34 @@ You download the Native API Development Kit (NDK) by downloading the OHOS SDK, w
- (Recommended) Acquire source code from mirrors for an officially released version. For details, see [release notes](../../release-notes/OpenHarmony-v3.2-release.md).
- Download the SDK from the SDK Manager in DevEco Studio.
- Download the SDK from the [daily build](http://ci.openharmony.cn/dailys/dailybuilds), by clicking the download link to the **ohos-sdk-full** component.
- Download the SDK from the [daily build](http://ci.openharmony.cn/workbench/cicd/dailybuild/dailylist), by clicking the download link to the **ohos-sdk-full** component.
![Download from Daily Build](figures/ci_download.png)
![](figures/ci_download.png)
## Decompressing the NDK
Place the downloaded NDK in a folder you prefer and decompress it. Below shows the directory structure after decompression.
![SDK Directory Structure](figures/sdk-structure.png)
![](figures/sdk-structure.png)
Configure the Linux environment as follows: (Skip them if the NDK is downloaded from DevEco Studio.)
1. Add the CMake tool that comes with the NDK to the environment variables.
Add the CMake tool that comes with the NDK to the environment variables.
```
# Open the .bashrc file.
vim ~/.bashrc
# Append the custom CMake path to the file. Save the file and exit.
# Append the custom CMake path to the file.
export PATH=~/ohos-sdk/ohos-sdk/linux/native/build-tools/cmake/bin:$PATH
# Run the source ~/.bashrc command to make the environment variables take effect.
source ~/.bashrc
```
2. Check the default CMake path.
Check the default CMake path.
```
# Run the which cmake command.
which cmake
# The result should be the same as the custom path previously appended to the file.
# The result should be the same as the custom path previously appended to the .bashrc file.
~/ohos-sdk/ohos-sdk/linux/native/build-tools/cmake/bin/cmake
```
......
......@@ -73,8 +73,8 @@ BackupExtensionAbility is a class derived from the [ExtensionAbility](../applica
"data/storage/el2/base/files/",
"data/storage/el2/base/preferences/",
"data/storage/el2/base/haps/*/database/",
"data/storage/el2/base/haps/*/base/files/",
"data/storage/el2/base/haps/*/base/preferences/",
"data/storage/el2/base/haps/*/files/",
"data/storage/el2/base/haps/*/preferences/",
]
}
```
......@@ -42,7 +42,7 @@ let fetchOptions = {
};
```
Call **PhotoAccessHelper.getAssets** to obtain the image asset.
Call **PhotoAccessHelper.getAssets** to obtain image assets.
```ts
try {
......@@ -55,7 +55,7 @@ try {
}
```
### Obtaining an Image or Video by URI
### Obtaining an Image or Video Asset by URI
Example: Obtain the image with the file URI **file://media/Photo/1**.
......@@ -70,7 +70,7 @@ let fetchOptions = {
};
```
Call **PhotoAccessHelper.getAssets** to obtain the image asset.
Call **PhotoAccessHelper.getAssets** to obtain image assets.
```ts
try {
......@@ -103,7 +103,7 @@ let fetchOptions = {
};
```
Call **PhotoAccessHelper.getAssets** to obtain the image assets.
Call **PhotoAccessHelper.getAssets** to obtain image assets.
```ts
try {
......@@ -250,7 +250,7 @@ The files moved to the trash will be retained for 30 days, and deleted permanent
**Prerequisites**
- A **photoAccessHelper** instance is obtained
- A **photoAccessHelper** instance is obtained.
- The application has the **ohos.permission.WRITE_IMAGEVIDEO** and **ohos.permission.READ_IMAGEVIDEO** permissions.
Example: Move the first file in the result set to the trash.
......
......@@ -5,7 +5,7 @@ The **photoAccessHelper** module provides APIs for managing system albums, inclu
> **NOTE**
>
> Before you start, refer to [photoAccessHelper Overview](photoAccessHelper-overview.md) to learn how to obtain a **photoAccessHelper** instance and apply for permissions required.
> By default, the **photoAccessHelper** instance obtained in [photoAccessHelper Overview](photoAccessHelper-overview.md) is used when **photoAccessHelper** APIs are used. If the code for obtaining the **photoAccessHelper** instance is not added, an error indicating that **photoAccessHelper** is not defined is reported.
> By default, the **PhotoAccessHelper** instance obtained in [photoAccessHelper Overview](photoAccessHelper-overview.md) is used when **PhotoAccessHelper** APIs are used. If the code for obtaining the **PhotoAccessHelper** instance is not added, an error indicating that **PhotoAccessHelper** is not defined is reported.
To ensure application running efficiency, most **photoAccessHelper** calls are asynchronous in callback or promise mode. The following code samples use promise-based APIs. For details about the APIs, see [Album Management](../reference/apis/js-apis-photoAccessHelper.md).
Unless otherwise specified, all the media assets to be obtained in this document exist in the database. If no media asset is obtained when the sample code is executed, check whether the media assets exist in the database.
......@@ -133,8 +133,8 @@ Example: Unfavorite an image.
**How to Develop**
1. [Obtain the image and videos in **Favorites**](#obtaining-images-and-videos-in-favorites).
2. Set **isFavorite** to **false**.
3. Use **FileAsset.favorite** to remove the image from **Favorites**.
2. Set **favoriteState** to **false**.
3. Use **FileAsset.setFavorite** to remove the image from **Favorites**.
```ts
......
......@@ -2,55 +2,100 @@
When a user needs to download a file from the network to a local directory or save a user file into another directory, use **FilePicker** to save the file.
The operations for saving images, audio or video clips, and documents are similar. Call **save()** of the corresponding picker instance and pass in **saveOptions**.
The operations for saving images, audio or video clips, and documents are similar. Call **save()** of the corresponding picker instance and pass in **saveOptions**. No permission is required if **FilePicker** is used to access files.
The **save()** interface saves the file in the file manager, not in the Gallery.
The **save()** method saves the file in the file manager, not in the Gallery.
## Saving Images or Video Files
1. Import the **picker** module and **fs** module.
For example, select an image from **Gallery** and save it to the file manager.
1. Import the [picker](../reference/apis/js-apis-file-picker.md), [fs](../reference/apis/js-apis-file-fs.md), [photoAccessHelper](../reference/apis/js-apis-photoAccessHelper.md), and [dataSharePredicates](../reference/apis/js-apis-data-dataSharePredicates.md) modules.
```ts
import picker from '@ohos.file.picker';
import fs from '@ohos.file.fs';
import photoAccessHelper from '@ohos.file.photoAccessHelper';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
```
2. Create a **photoSaveOptions** instance.
2. Obtain the thumbnail of the first image on the device. Before performing this operation, ensure that at least one image exists on the device.
```ts
const photoSaveOptions = new picker.PhotoSaveOptions(); // Create a photoSaveOptions instance.
photoSaveOptions.newFileNames = ["PhotoViewPicker01.jpg"]; // (Optional) Set the names of the files to save.
const context = getContext(this);
let photoAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
let pixelmapArrayBuffer;
async getPixelmap() {
try {
let predicates = new dataSharePredicates.DataSharePredicates();
let fetchOption = {
fetchColumns: [],
predicates: predicates
};
let fetchResult = await photoAccessHelper.getAssets(fetchOption);
console.info('[picker] getThumbnail fetchResult: ' + fetchResult);
const asset = await fetchResult.getFirstObject();
console.info('[picker] getThumbnail asset displayName = ', asset.displayName);
asset.getThumbnail().then((pixelMap) => {
let pixelBytesNumber = pixelMap.getPixelBytesNumber();
const readBuffer = new ArrayBuffer(pixelBytesNumber);
pixelMap.readPixelsToBuffer(readBuffer).then(() => {
pixelmapArrayBuffer = readBuffer;
})
}).catch((err) => {
console.error('[picker] getThumbnail failed with error: ' + err);
});
} catch (error) {
console.error('[picker] getThumbnail error = ' + error);
}
}
```
3. Create a **photoViewPicker** instance and call [save()](../reference/apis/js-apis-file-picker.md#save) to open the **FilePicker** page to save the files. After the user selects the target folder, the file saving operation is complete. After the files are saved successfully, the URIs of the files saved are returned.
3. Create a **photoViewPicker** instance and call [save()](../reference/apis/js-apis-file-picker.md#save) to open the **FilePicker** page to save the image. After the user selects the target folder, the file saving operation is complete. After the image is saved successfully, the URI of the saved image is returned.
The permission on the URIs returned by **save()** is read/write. Further file operations can be performed based on the URIs in the result set. Note that the URI cannot be directly used in the **picker** callback to open a file. You need to define a global variable to save the URI and use a button to trigger file opening.
```ts
let uri = null;
const photoViewPicker = new picker.PhotoViewPicker();
photoViewPicker.save(photoSaveOptions).then((photoSaveResult) => {
uri = photoSaveResult[0];
console.info('photoViewPicker.save to file succeed and uri is:' + uri);
}).catch((err) => {
console.error(`Invoke photoViewPicker.save failed, code is ${err.code}, message is ${err.message}`);
})
The permission on the URI returned by **save()** is read/write. Further operations can be performed based on the URI in the result set. Note that the URI cannot be directly used in the **picker** callback to open a file. You need to define a global variable to save the URI and use a button to trigger file opening.
```ts
let uri:string;
async photoViewPickerSave() {
try {
const photoSaveOptions = new picker.PhotoSaveOptions(); // Create a photoSaveOptions instance.
photoSaveOptions.newFileNames = ["PhotoViewPicker01.png"]; // (Optional) Name of the file to be saved. The file name in the square brackets can be customized and must be unique. If the file name already exists on the device, change the file name. Otherwise, an error will be returned.
const photoViewPicker = new picker.PhotoViewPicker();
try {
let photoSaveResult = await photoViewPicker.save(photoSaveOptions);
if (photoSaveResult != undefined) {
console.info("[picker] photoViewPickerSave photoSaveResult = " + JSON.stringify(photoSaveResult));
this.uri = photoSaveResult[0];
console.info('photoViewPicker.save to file succeed and uri is:' + photoSaveResult[0]);
}
} catch (err) {
console.error(`[picker] Invoke photoViewPicker.save failed, code is ${err.code}, message is ${err.message}`);
}
} catch (error) {
console.info("[picker] photoViewPickerSave error = " + error);
}
}
```
4. Use a button to trigger invocation of other functions. Use [fs.openSync()](../reference/apis/js-apis-file-fs.md#fsopensync) to open the file based on the URI and obtain the FD. Note that the **mode** parameter of **fs.openSync()** must be **fs.OpenMode.READ_WRITE**.
```ts
let file = fs.openSync(uri, fs.OpenMode.READ_WRITE);
console.info('file fd: ' + file.fd);
```
5. Use [fs.writeSync()](../reference/apis/js-apis-file-fs.md#writesync) to edit the file based on the FD, and then close the FD.
Use [fs.write](../reference/apis/js-apis-file-fs.md#fswrite) to edit and modify the file based on the FD. After the modification is complete, close the FD.
```ts
let writeLen = fs.writeSync(file.fd, 'hello, world');
console.info('write data to file succeed and size is:' + writeLen);
fs.closeSync(file);
async writeOnly(uri) {
try {
let file = fs.openSync(uri, fs.OpenMode.WRITE_ONLY);
let writeLen = await fs.write(file.fd, pixelmapArrayBuffer);
fs.closeSync(file);
console.info("[picker] writeOnly writeLen = " + writeLen);
} catch (error) {
console.info("[picker] writeOnly error: " + error);
}
}
```
## Saving Documents
......
......@@ -265,7 +265,7 @@ Text($r('app.string.message_arrive', "five of the clock"))
.fontColor($r('app.color.color_hello'))
.fontSize($r('app.float.font_hello'))
// Reference plural resources. The first parameter of $r indicates the plural resource, the second parameter indicates the number of plural resources (for English, **one** indicates singular and is represented by **1**, and **other** indicates plural and is represented by an integer greater than or equal to 1; for Chinese, **other** indicates both singular and plural), and the third parameter is used to replace %d.
// Reference plural resources. The first parameter of $r indicates the plural resource, the second parameter indicates the number of plural resources (for English, one indicates singular and is represented by 1, and other indicates plural and is represented by an integer greater than or equal to 1; for Chinese, other indicates both singular and plural), and the third parameter is used to replace %d.
// In this example, the resultant value is "5 apples".
Text($r('app.plural.eat_apple', 5, 5))
.fontColor($r('app.color.color_world'))
......
......@@ -31,8 +31,8 @@ import config from '@ohos.accessibility.config';
| shortkeyTarget | [Config](#config)\<string>| Yes| Yes| Target application for the accessibility extension shortcut key. The value format is 'bundleName/abilityName'.|
| captions | [Config](#config)\<boolean>| Yes| Yes| Whether to enable captions.|
| captionsStyle | [Config](#config)\<[accessibility.CaptionsStyle](js-apis-accessibility.md#captionsstyle8)>| Yes| Yes| Captions style.|
| audioMono| [Config](#config)\<boolean>| Yes| Yes| Whether to enable mono audio. The value **True** means to enable mono audio, and **False** means the opposite.|
| audioBalance| [Config](#config)\<number>| Yes| Yes| Audio balance for the left and right audio channels. The value ranges from -1.0 to 1.0.|
| audioMono<sup>10+</sup>| [Config](#config)\<boolean>| Yes| Yes| Whether to enable mono audio. The value **True** means to enable mono audio, and **False** means the opposite.|
| audioBalance<sup>10+</sup>| [Config](#config)\<number>| Yes| Yes| Audio balance for the left and right audio channels. The value ranges from -1.0 to 1.0.|
## enableAbility
......
......@@ -353,7 +353,7 @@ A constructor used to create a **SessionBackup** instance.
```js
import fs from '@ohos.file.fs';
let generalCallbacks = backup.GeneralCallbacks({
let generalCallbacks = ({
onFileReady: (err, file) => {
if (err) {
console.error('onFileReady failed with err: ' + err);
......@@ -568,7 +568,7 @@ A constructor used to create a **SessionRestore** instance.
```js
import fs from '@ohos.file.fs';
let generalCallbacks = backup.GeneralCallbacks({
let generalCallbacks = ({
onFileReady: (err, file) => {
if (err) {
console.error('onFileReady failed with err: ' + err);
......
# @ohos.file.picker (File Picker)
**Picker** encapsulates the system applications such as **PhotoViewPicker**, **DocumentViewPicker** and **AudioViewPicker** to provide capabilities of selecting and saving files of different types. The application can select the picker as required.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**Picker** encapsulates the system applications such as **PhotoViewPicker**, **DocumentViewPicker** and **AudioViewPicker** to provide capabilities of selecting and saving files of different types. The application can select the picker as required.
## Modules to Import
```js
......@@ -138,7 +138,7 @@ async function example() {
save(option?: PhotoSaveOptions) : Promise&lt;Array&lt;string&gt;&gt;
Saves one or more images or videos in a **photoPicker** page. This API uses a promise to return the result. You can pass in **PhotoSaveOptions** to specify the file names of the images or videos to save.
Saves one or more images or videos in a **photoPicker** page. This API uses a promise to return the result. You can pass in **PhotoSaveOptions** to specify the file names of the images or videos to save. The **save()** API saves the file in the file manager, not in the Gallery.
**System capability**: SystemCapability.FileManagement.UserFileService
......@@ -177,7 +177,7 @@ async function example() {
save(option: PhotoSaveOptions, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;) : void
Saves one or more images or videos in a **photoPicker** page. This API uses an asynchronous callback to return the result. You can pass in **PhotoSaveOptions** to specify the file names of the images or videos to save.
Saves one or more images or videos in a **photoPicker** page. This API uses an asynchronous callback to return the result. You can pass in **PhotoSaveOptions** to specify the file names of the images or videos to save. The **save()** API saves the file in the file manager, not in the Gallery.
**System capability**: SystemCapability.FileManagement.UserFileService
......@@ -213,7 +213,7 @@ async function example() {
save(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;) : void
Saves one or more images or videos in a **photoPicker** page. This API uses an asynchronous callback to return the result.
Saves one or more images or videos in a **photoPicker** page. This API uses an asynchronous callback to return the result. The **save()** API saves the file in the file manager, not in the Gallery.
**System capability**: SystemCapability.FileManagement.UserFileService
......@@ -727,7 +727,7 @@ Defines information about the images or videos selected.
| Name | Type | Readable| Writable| Description |
| ----------------------- | ------------------- | ---- | ---- | ------------------------------ |
| photoUris | Array&lt;string&gt; | Yes | Yes | URIs of the media files selected.|
| isOriginalPhoto | boolean | Yes | Yes | Whether the selected media file is the original image.|
| isOriginalPhoto | boolean | Yes | Yes | Whether the selected media file is the original image.|
## PhotoSaveOptions
......
......@@ -18,15 +18,15 @@ import InputMethodSubtype from '@ohos.InputMethodSubtype';
**System capability**: SystemCapability.MiscServices.InputMethodFramework
| Name| Type| Readable| Writable| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | -------- |
| label | string | Yes| No| No| Label of the input method subtype.|
| labelId<sup>10+</sup> | string | Yes| No| No| Label ID of the input method subtype.|
| name | string | Yes| No| Yes| Bundle name of the input method.|
| id | string | Yes| No| Yes| ID of the input method subtype.|
| mode | string | Yes| No| No| Mode of the input method subtype, including **upper** (uppercase) and **lower** (lowercase).|
| locale | string | Yes| No| Yes| Locale of the input method subtype.|
| language | string | Yes| No| Yes| Language of the input method subtype.|
| icon | string | Yes| No| No| Icon of the input method subtype.|
| iconId | number | Yes| No| No| Icon ID of the input method subtype.|
| extra | object | Yes| Yes| No| Extra information of the input method subtype.<br>**NOTE**<br>This parameter is optional since API version 10.|
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| label | string | Yes| No| Optional. Label of the input method subtype.|
| labelId<sup>10+</sup> | string | Yes| No| Optional. Label ID of the input method subtype.|
| name | string | Yes| No| Mandatory. Bundle name of the input method.|
| id | string | Yes| No| Mandatory. ID of the input method subtype.|
| mode | string | Yes| No| Optional. Mode of the input method subtype, including **upper** (uppercase) and **lower** (lowercase).|
| locale | string | Yes| No| Mandatory. Locale of the input method subtype.|
| language | string | Yes| No| Mandatory. Language of the input method subtype.|
| icon | string | Yes| No| Optional. Icon of the input method subtype. It can be obtained by using **iconId**. This parameter is reserved.|
| iconId | number | Yes| No| Optional. Icon ID of the input method subtype.|
| extra | object | Yes| Yes| Optional. Extra information of the input method subtype. This parameter is reserved and currently has no specific meaning.<br>**NOTE**<br>This parameter is optional since API version 10.|
......@@ -923,6 +923,50 @@ inputMethodEngine.getKeyboardDelegate().off('textChange', (text) => {
});
```
### on('editorAttributeChanged')<sup>10+</sup>
on(type: 'editorAttributeChanged', callback: (attr: EditorAttribute) => void): void
Enables listening for the edit box attribute change event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'editorAttributeChanged'** indicates the edit box attribute change event.|
| callback | (attr: EditorAttribute) => void | Yes | Callback used to return the edit box attribute change.|
**Example**
```js
inputMethodEngine.getKeyboardDelegate().on('editorAttributeChanged', (attr) => {
console.log(`Succeeded in receiving attribute of editor, inputPattern = ${attr.inputPattern}, enterKeyType = ${attr.enterKeyType}`);
});
```
### off('editorAttributeChanged')<sup>10+</sup>
off(type: 'editorAttributeChanged', callback?: (attr: EditorAttribute) => void): void
Cancels listening for the edit box attribute change event.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'editorAttributeChanged'** indicates the edit box attribute change event.|
| callback | (attr: EditorAttribute) => void | No | Callback for the edit box attribute change event. It must correspond to the one in the **on** API.|
**Example**
```js
inputMethodEngine.getKeyboardDelegate().off('editorAttributeChanged');
```
## Panel<sup>10+</sup>
In the following API examples, you must first use **[createPanel](#createpanel10)** to obtain a **Panel** instance, and then call the APIs using the obtained instance.
......
......@@ -50,7 +50,7 @@ Creates a **PasteData** object of a custom type.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| mimeType | string | Yes| MIME type of custom data.|
| mimeType | string | Yes| MIME type of custom data. The value can a predefined MIME type listed in [Constants](#constants), including HTML, WANT, plain text, URI, and pixel map, or a custom MIME type.|
| value | [ValueType](#valuetype9) | Yes| Content of custom data.|
**Return value**
......@@ -59,13 +59,21 @@ Creates a **PasteData** object of a custom type.
| -------- | -------- |
| [PasteData](#pastedata) | **PasteData** object.|
**Example**
**Example 1**
```js
let dataXml = new ArrayBuffer(256);
let pasteData = pasteboard.createData('app/xml', dataXml);
let pasteData = pasteboard.createData('app/xml', dataXml);
```
**Example 2**
```js
let dataText = 'hello';
let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, dataText);
```
## pasteboard.createRecord<sup>9+</sup>
createRecord(mimeType: string, value: ValueType):PasteDataRecord;
......@@ -78,7 +86,7 @@ Creates a **PasteDataRecord** object of the custom type.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| mimeType | string | Yes| MIME type of custom data.|
| mimeType | string | Yes| MIME type of custom data. The value can a predefined MIME type listed in [Constants](#constants), including HTML, WANT, plain text, URI, and pixel map, or a custom MIME type. |
| value | [ValueType](#valuetype9) | Yes| Content of custom data.|
**Return value**
......@@ -87,13 +95,20 @@ Creates a **PasteDataRecord** object of the custom type.
| -------- | -------- |
| [PasteDataRecord](#pastedatarecord7) | New **PasteDataRecord** object of the custom type.|
**Example**
**Example 1**
```js
let dataXml = new ArrayBuffer(256);
let pasteDataRecord = pasteboard.createRecord('app/xml', dataXml);
```
**Example 2**
```js
let dataUri = 'dataability:///com.example.myapplication1/user.txt';
let record = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_URI, dataUri);
```
## pasteboard.getSystemPasteboard
getSystemPasteboard(): SystemPasteboard
......@@ -751,27 +766,53 @@ Sets a [PasteDataProperty](#pastedataproperty7) object.
let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_HTML, 'application/xml');
let prop = pasteData.getProperty();
prop.shareOption = pasteboard.ShareOption.INAPP;
prop.additions['TestOne'] = 123;
prop.additions['TestOne'] = {'Test' : 123};
prop.additions['TestTwo'] = {'Test' : 'additions'};
prop.tag = 'TestTag';
pasteData.setProperty(prop);
```
The **localOnly** and **shareOption** attributes of [PasteDataProperty](#pastedataproperty7) are mutually exclusive. The **shareOption** attribute prevails, and its value affect the value of **localOnly**.
```js
prop.shareOption = pasteboard.ShareOption.INAPP;
prop.localOnly = false;
pasteData.setProperty(prop);
pasteData.localOnly //true
prop.shareOption = pasteboard.ShareOption.LOCALDEVICE;
prop.localOnly = false;
pasteData.setProperty(prop);
pasteData.localOnly //true
prop.shareOption = pasteboard.ShareOption.CROSSDEVICE;
prop.localOnly = true;
pasteData.setProperty(prop);
pasteData.localOnly //false
(async function() {
let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'hello');
let prop = pasteData.getProperty();
prop.shareOption = pasteboard.ShareOption.INAPP;
prop.localOnly = false;
pasteData.setProperty(prop);
let systemPasteboard = pasteboard.getSystemPasteboard();
await systemPasteboard.setData(pasteData).then(async () => {
console.info('Succeeded in setting PasteData.');
await systemPasteboard.getData().then(pasteData => {
let prop = pasteData.getProperty();
prop.localOnly //true
});
});
prop.shareOption = pasteboard.ShareOption.LOCALDEVICE;
prop.localOnly = false;
pasteData.setProperty(prop);
await systemPasteboard.setData(pasteData).then(async () => {
console.info('Succeeded in setting PasteData.');
await systemPasteboard.getData().then(pasteData => {
let prop = pasteData.getProperty();
prop.localOnly; //true
});
});
prop.shareOption = pasteboard.ShareOption.CROSSDEVICE;
prop.localOnly = true;
pasteData.setProperty(prop);
await systemPasteboard.setData(pasteData).then(async () => {
console.info('Succeeded in setting PasteData.');
await systemPasteboard.getData().then(pasteData => {
let prop = pasteData.getProperty();
prop.localOnly; //false
});
});
})()
```
......@@ -1301,7 +1342,7 @@ For details about the error codes, see [Pasteboard Error Codes](../errorcodes/er
**Example**
```js
let pasteData = pasteboard.createPlainTextData('content');
let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'content');
let systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setData(pasteData, (err, data) => {
if (err) {
......@@ -1344,7 +1385,7 @@ For details about the error codes, see [Pasteboard Error Codes](../errorcodes/er
**Example**
```js
let pasteData = pasteboard.createPlainTextData('content');
let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'content');
let systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setData(pasteData).then((data) => {
console.info('Succeeded in setting PasteData.');
......
......@@ -4,7 +4,7 @@ The **photoAccessHelper** module provides APIs for album management, including c
> **NOTE**
>
> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
......@@ -341,7 +341,7 @@ For details about the error codes, see [File Management Error Codes](../errorcod
| ID| Error Message|
| -------- | ---------------------------------------- |
| 202 | Called by non-system application. |
| 202 | Called by non-system application. |
| 401 | if type displayName is not string. |
| 14000001 | if type of displayName is invalid. |
......@@ -401,9 +401,9 @@ async function example() {
let options = {
title: 'testPhoto'
}
phAccessHelper.createAsset(photoType, extension, options, (err, photoAsset) => {
if (photoAsset != undefined) {
console.info('createAsset file displayName' + photoAsset.displayName);
phAccessHelper.createAsset(photoType, extension, options, (err, uri) => {
if (uri != undefined) {
console.info('createAsset uri' + uri);
console.info('createAsset successfully');
} else {
console.error('createAsset failed, message = ', err);
......@@ -445,9 +445,9 @@ async function example() {
console.info('createAssetDemo');
let photoType = photoAccessHelper.PhotoType.IMAGE;
let extension = 'jpg';
phAccessHelper.createAsset(photoType, extension, (err, photoAsset) => {
if (photoAsset != undefined) {
console.info('createAsset file displayName' + photoAsset.displayName);
phAccessHelper.createAsset(photoType, extension, (err, uri) => {
if (uri != undefined) {
console.info('createAsset uri' + uri);
console.info('createAsset successfully');
} else {
console.error('createAsset failed, message = ', err);
......@@ -499,8 +499,8 @@ async function example() {
let options = {
title: 'testPhoto'
}
let photoAsset = await phAccessHelper.createAsset(photoType,extension, options);
console.info('createAsset file displayName' + photoAsset.displayName);
let uri = await phAccessHelper.createAsset(photoType, extension, options);
console.info('createAsset uri' + uri);
console.info('createAsset successfully');
} catch (err) {
console.error('createAsset failed, message = ', err);
......@@ -1077,15 +1077,15 @@ async function example() {
//file had changed, do something
}
// Register onCallback1.
phAccessHelper.registerChange(photoAsset.uri, false, onCallback1);
phAccessHelper.registerChange(photoAsset.uri, false, onCallback1);
// Register onCallback2.
phAccessHelper.registerChange(photoAsset.uri, false, onCallback2);
photoAsset.favorite(true, (err) => {
photoAsset.setFavorite(true, (err) => {
if (err == undefined) {
console.info('favorite successfully');
console.info('setFavorite successfully');
} else {
console.error('favorite failed with error:' + err);
console.error('setFavorite failed with error:' + err);
}
});
}
......@@ -1145,11 +1145,11 @@ async function example() {
phAccessHelper.registerChange(photoAsset.uri, false, onCallback2);
// Unregister the listening of onCallback1.
phAccessHelper.unRegisterChange(photoAsset.uri, onCallback1);
photoAsset.favorite(true, (err) => {
photoAsset.setFavorite(true, (err) => {
if (err == undefined) {
console.info('favorite successfully');
console.info('setFavorite successfully');
} else {
console.error('favorite failed with error:' + err);
console.error('setFavorite failed with error:' + err);
}
});
}
......@@ -1539,7 +1539,7 @@ For details about the error codes, see [Universal Error Codes](../errorcodes/err
| -------- | ---------------------------------------- |
| 401 | if values to commit is invalid. |
**Example**
**Example**
```ts
import dataSharePredicates from '@ohos.data.dataSharePredicates';
......@@ -2839,7 +2839,7 @@ Obtains image and video assets. This API uses an asynchronous callback to return
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| options | [FetchOptions](#fetchoptions) | Yes | Options for fetching the album files.|
| options | [FetchOptions](#fetchoptions) | Yes | Options for fetching the albums.|
| callback | AsyncCallback&lt;[FetchResult](#fetchresult)&lt;[PhotoAsset](#photoasset)&gt;&gt; | Yes | Callback invoked to return the image and video assets obtained.|
**Error codes**
......@@ -2856,17 +2856,17 @@ For details about the error codes, see [Universal Error Codes](../errorcodes/err
import dataSharePredicates from '@ohos.data.dataSharePredicates';
async function example() {
console.info('albumGetPhotoAssetsDemoCallback');
console.info('albumGetAssetsDemoCallback');
let predicates = new dataSharePredicates.DataSharePredicates();
let albumFetchOptions = {
fetchColumns: [],
predicates: predicates
};
let fetchOption = {
fetchColumns: [],
predicates: predicates
};
const albumList = await phAccessHelper.getAlbums(albumFetchOptions);
const albumList = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
const album = await albumList.getFirstObject();
album.getAssets(fetchOption, (err, albumFetchResult) => {
if (albumFetchResult != undefined) {
......@@ -2914,17 +2914,18 @@ For details about the error codes, see [Universal Error Codes](../errorcodes/err
import dataSharePredicates from '@ohos.data.dataSharePredicates';
async function example() {
console.info('albumGetPhotoAssetsDemoPromise');
console.info('albumGetAssetsDemoPromise');
let predicates = new dataSharePredicates.DataSharePredicates();
let albumFetchOptions = {
fetchColumns: [],
predicates: predicates
};
let fetchOption = {
fetchColumns: [],
predicates: predicates
};
const albumList = await phAccessHelper.getAlbums(albumFetchOptions);
const albumList = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
const album = await albumList.getFirstObject();
album.getAssets(fetchOption).then((albumFetchResult) => {
console.info('album getPhotoAssets successfully, getCount: ' + albumFetchResult.getCount());
......@@ -2967,9 +2968,10 @@ async function example() {
console.info('albumCommitModifyDemo');
let predicates = new dataSharePredicates.DataSharePredicates();
let albumFetchOptions = {
fetchColumns: [],
predicates: predicates
};
const albumList = await phAccessHelper.getAlbums(albumFetchOptions);
const albumList = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
const album = await albumList.getFirstObject();
album.albumName = 'hello';
album.commitModify((err) => {
......@@ -3015,9 +3017,10 @@ async function example() {
console.info('albumCommitModifyDemo');
let predicates = new dataSharePredicates.DataSharePredicates();
let albumFetchOptions = {
fetchColumns: [],
predicates: predicates
};
const albumList = await phAccessHelper.getAlbums(albumFetchOptions);
const albumList = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
const album = await albumList.getFirstObject();
album.albumName = 'hello';
album.commitModify().then(() => {
......@@ -3496,6 +3499,131 @@ async function example() {
}
```
### setCoverUri
setCoverUri(uri: string, callback: AsyncCallback&lt;void&gt;): void;
Sets the album cover. This API uses an asynchronous callback to return the result.
**NOTE**<br>This API can be used to set the user album cover, but not the system album cover.
**System API**: This is a system API.
**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| uri | string | Yes | URI of the file to be set as the album cover.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value.|
**Error codes**
For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md).
| ID| Error Message|
| -------- | ---------------------------------------- |
| 202 | Called by non-system application. |
| 401 | if parameter is invalid. |
**Example**
```ts
import dataSharePredicates from '@ohos.data.dataSharePredicates';
async function example() {
try {
console.info('setCoverUriDemoCallback');
let predicates = new dataSharePredicates.DataSharePredicates();
let fetchOption = {
fetchColumns: [],
predicates: predicates
};
let albumFetchResult = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
let album = await albumFetchResult.getFirstObject();
let fetchResult = await album.getAssets(fetchOption);
let asset = await fetchResult.getFirstObject();
album.setCoverUri(asset.uri, (err) => {
if (err === undefined) {
console.info('album setCoverUri successfully');
} else {
console.error('album setCoverUri failed with error: ' + err);
}
});
} catch (err) {
console.error('setCoverUriDemoCallback failed with error: ' + err);
}
}
```
### setCoverUri
setCoverUri(uri: string): Promise&lt;void&gt;;
Sets the album cover. This API uses a promise to return the result.
**NOTE**<br>This API can be used to set the user album cover, but not the system album cover.
**System API**: This is a system API.
**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| uri | string | Yes | URI of the file to be set as the album cover.|
**Return value**
| Type | Description |
| --------------------------------------- | ----------------- |
|Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md).
| ID| Error Message|
| -------- | ---------------------------------------- |
| 202 | Called by non-system application. |
| 401 | if parameter is invalid. |
**Example**
```ts
import dataSharePredicates from '@ohos.data.dataSharePredicates';
async function example() {
try {
console.info('setCoverUriDemoCallback');
let predicates = new dataSharePredicates.DataSharePredicates();
let fetchOption = {
fetchColumns: [],
predicates: predicates
};
let albumFetchResult = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
let album = await albumFetchResult.getFirstObject();
let fetchResult = await album.getAssets(fetchOption);
let asset = await fetchResult.getFirstObject();
album.setCoverUri(asset.uri, (err) => {
if (err === undefined) {
console.info('album setCoverUri successfully');
} else {
console.error('album setCoverUri failed with error: ' + err);
}
});
} catch (err) {
console.error('setCoverUriDemoCallback failed with error: ' + err);
}
}
```
## MemberType
Enumerates the member types.
......@@ -3597,6 +3725,7 @@ Defines the key information about an image or video file.
| POSITION | 'position' | File location type. **System API**: This is a system API. |
| DATE_TRASHED | 'date_trashed' | Date when the file was deleted. The value is the number of seconds between the time when the file is deleted and January 1, 1970. **System API**: This is a system API. |
| HIDDEN | 'hidden' | Whether the file is hidden. **System API**: This is a system API. |
| CAMERA_SHOT_KEY | 'camera_shot_key' | Key for the Untra Snamshot feature, which allows the camera to take photos or record videos with the screen off. (This parameter is available only for the system camera, and the key value is defined by the system camera.)<br/>**System API**: This is a system API. |
## AlbumKeys
......@@ -3618,6 +3747,7 @@ Defines the options for creating an image or video asset.
| Name | Type | Mandatory| Description |
| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
| subtype | [PhotoSubtype](#photosubtype) | No | Subtype of the image or video. **System API**: This is a system API. |
| cameraShotKey | string | No | Key for the Untra Snamshot feature, which allows the camera to take photos or record videos with the screen off. (This parameter is available only for the system camera, and the key value is defined by the system camera.)<br/>**System API**: This is a system API. |
## CreateOptions
......
......@@ -53,12 +53,12 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```js
import uriPermissionManager from '@ohos.application.uriPermissionManager';
import WantConstant from '@ohos.ability.wantConstant';
import fileio from '@ohos.fileio';
import fs from '@ohos.file.fs';
import fileUri from '@ohos.file.fileuri';
let targetBundleName = 'com.example.test_case1'
let path = "file://com.example.test_case1/data/storage/el2/base/haps/entry_test/files/newDir";
fileio.mkdir(path, function (err) {
fs.mkdir(path, function (err) {
if (err) {
console.log("mkdir error"+err.message)
} else {
......@@ -115,13 +115,13 @@ By default, an application can authorize its own URIs to another application. If
```js
import uriPermissionManager from '@ohos.application.uriPermissionManager';
import WantConstant from '@ohos.ability.wantConstant';
import fileio from '@ohos.fileio';
import fs from '@ohos.file.fs';
import fileUri from '@ohos.file.fileuri';
let targetBundleName = 'com.example.test_case1'
let path = "file://com.example.test_case1/data/storage/el2/base/haps/entry_test/files/newDir";
fileio.mkdir(path, function (err) {
fs.mkdir(path, function (err) {
if (err) {
console.log("mkdir error"+err.message)
} else {
......
......@@ -139,7 +139,7 @@ on : (name : AuthEventKey, callback : AuthEvent) => void
Subscribes to the user authentication events of the specified type.
> **NOTE**<br>
> This API is supported since API version 9 and deprecated since API version 10.
> This API is supported since API version 9.
> **NOTE**<br>
> Use the [AuthInstance](#authinstance9) instance obtained to invoke this API to subscribe to events.
......@@ -330,7 +330,7 @@ Cancels this authentication.
> This API is supported since API version 9.
> **NOTE**<br>
> Use the [AuthInstance](#authinstance9) instance obtained to invoke this API. The [AuthInstance](#authinstance9) instance must be the instance being authenticated.
> Use the [AuthInstance](#authinstance9) instance obtained to invoke this API. The [AuthInstance](#authinstance9) instance must be the one being authenticated.
**Required permissions**: ohos.permission.ACCESS_BIOMETRIC
......
......@@ -208,7 +208,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100010 | Can not post message using this port. |
### onMessageEventExt<sup>10+</sup>
onMessageEventExt(callback: (result: WebMessageExt) => void): void
......@@ -358,7 +357,7 @@ window.addEventListener('message', function(event) {
h5Port = event.ports[0]; // 1. Save the port number sent from the eTS side.
h5Port.onmessage = function(event) {
console.log("hwd In html got message");
// 2. Receive the message sent from the ArkTS side.
// 2. Receive the message sent from the eTS side.
var result = event.data;
console.log("In html got message, typeof: ", typeof(result));
console.log("In html got message, result: ", (result));
......@@ -401,7 +400,7 @@ window.addEventListener('message', function(event) {
}
})
// Use h5Port to send a message of the string type to the ArkTS side.
// Use h5Port to send a message of the string type to the ets side.
function postStringToApp() {
if (h5Port) {
console.log("In html send string message");
......@@ -638,7 +637,7 @@ struct WebComponent {
Button('loadUrl')
.onClick(() => {
try {
// The headers parameter is carried.
// The headers parameter is passed.
this.controller.loadUrl('www.example.com', [{headerKey: "headerKey", headerValue: "headerValue"}]);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
......@@ -999,7 +998,7 @@ struct WebComponent {
onActive(): void
Invoked to instruct the **\<Web>** component to enter the foreground, active state.
Invoked to instruct the **\<Web>** component to enter the active foreground state.
**System capability**: SystemCapability.Web.Webview.Core
......@@ -1348,12 +1347,14 @@ HTML file to be loaded:
<html>
<meta charset="utf-8">
<body>
Hello world!
<button type="button" onclick="htmlTest()">Click Me!</button>
<p id="demo"></p>
</body>
<script type="text/javascript">
function htmlTest() {
str = objName.test("test function")
console.log('objName.test result:'+ str)
let str=objName.test();
document.getElementById("demo").innerHTML=str;
console.log('objName.test result:'+ str)
}
</script>
</html>
......@@ -3866,7 +3867,7 @@ struct WebComponent {
getCertificate(): Promise<Array<cert.X509Cert>>
Obtains the certificate information of the current website. When the \<Web> component is used to load an HTTPS website, SSL certificate verification is performed. This API uses a promise to return the [X.509 certificate](./js-apis-cert.md) of the current website.
Obtains the certificate information of this website. When the **\<Web>** component is used to load an HTTPS website, SSL certificate verification is performed. This API uses a promise to return the [X.509 certificate](./js-apis-cert.md) of the current website.
**System capability**: SystemCapability.Web.Webview.Core
......@@ -3943,7 +3944,7 @@ struct Index {
}
.type(ButtonType.Capsule)
.onClick(() => {
//Load an HTTPS website and view the certificate information of the website.
// Load an HTTPS website and view the certificate information of the website.
this.webviewCtl.loadUrl('https://www.example.com')
})
.height(50)
......@@ -4023,7 +4024,7 @@ struct Index {
getCertificate(callback: AsyncCallback<Array<cert.X509Cert>>): void
Obtains the certificate information of the current website. When the \<Web> component is used to load an HTTPS website, SSL certificate verification is performed. This API uses an asynchronous callback to return the [X.509 certificate](./js-apis-cert.md) of the current website.
Obtains the certificate information of this website. When the **\<Web>** component is used to load an HTTPS website, SSL certificate verification is performed. This API uses an asynchronous callback to return the [X.509 certificate](./js-apis-cert.md) of the website.
**System capability**: SystemCapability.Web.Webview.Core
......@@ -4031,7 +4032,7 @@ Obtains the certificate information of the current website. When the \<Web> comp
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback<Array<cert.X509Cert>> | Yes | Callback used to obtain the X.509 certificate array of the current HTTPS website.|
| callback | AsyncCallback<Array<cert.X509Cert>> | Yes | Callback used to obtain the X.509 certificate array of the current website.|
**Error codes**
......@@ -4100,7 +4101,7 @@ struct Index {
}
.type(ButtonType.Capsule)
.onClick(() => {
//Load an HTTPS website and view the certificate information of the website.
// Load an HTTPS website and view the certificate information of the website.
this.webviewCtl.loadUrl('https://www.example.com')
})
.height(50)
......@@ -4222,10 +4223,111 @@ struct WebComponent {
}
```
### prefetchPage<sup>10+</sup>
prefetchPage(url: string, additionalHeaders?: Array\<WebHeader>): void
Prefetches resources in the background for a page that is likely to be accessed in the near future, without executing the page JavaScript code or presenting the page. This can significantly reduce the load time for the prefetched page.
**System capability**: SystemCapability.Web.Webview.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ------------------| --------------------------------| ---- | ------------- |
| url | string | Yes | URL to be preloaded.|
| additionalHeaders | Array\<[WebHeader](#webheader)> | No | Additional HTTP headers of the URL.|
**Error codes**
For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
| ID | Error Message |
| -------- | ------------------------------------------------------------ |
| 17100001 | Init error. The WebviewController must be associated with a Web component. |
| 17100002 | Invalid url. |
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('prefetchPopularPage')
.onClick(() => {
try {
// Replace 'https://www.example.com' with a real URL for the API to work.
this.controller.prefetchPage('https://www.example.com');
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
// Replace ''www.example1.com' with a real URL for the API to work.
Web({ src: 'www.example1.com', controller: this.controller })
}
}
}
```
### prepareForPageLoad<sup>10+</sup>
static prepareForPageLoad(url: string, preconnectable: boolean, numSockets: number): void
Preconnects to a URL. This API can be called before the URL is loaded, to resolve the DNS and establish a socket connection, without obtaining the resources.
**System capability**: SystemCapability.Web.Webview.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ---------------| ------- | ---- | ------------- |
| url | string | Yes | URL to be preconnected.|
| preconnectable | boolean | Yes | Whether to perform preconnection, which involves DNS resolution and socket connection establishment. The value **true** means to perform preconnection, and **false** means the opposite.|
| numSockets | number | Yes | Number of sockets to be preconnected. The value must be greater than 0. A maximum of six socket connections are allowed.|
**Error codes**
For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
| ID | Error Message |
| -------- | ------------------------------------------------------------ |
| 17100002 | Invalid url. |
| 171000013| The number of preconnect sockets is invalid. |
**Example**
```ts
// xxx.ts
import UIAbility from '@ohos.app.ability.UIAbility';
import web_webview from '@ohos.web.webview';
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
console.log("EntryAbility onCreate")
web_webview.WebviewController.initializeWebEngine()
// Replace 'https://www.example.com' with a real URL for the API to work.
web_webview.WebviewController.prepareForPageLoad("https://www.example.com", true, 2);
globalThis.abilityWant = want
console.log("EntryAbility onCreate done")
}
}
```
## WebCookieManager
Implements a **WebCookieManager** instance to manage behavior of cookies in **\<Web>** components. All **\<Web>** components in an application share a **WebCookieManager** instance.
> **NOTE**
>
> You must load the **\<Web>** component before calling APIs in **WebCookieManager**.
### getCookie
static getCookie(url: string): string
......@@ -4347,7 +4449,6 @@ Saves the cookies in the memory to the drive. This API uses an asynchronous call
| -------- | ---------------------- | ---- | :------------------------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return whether the cookies are successfully saved.|
**Example**
```ts
......@@ -4688,6 +4789,10 @@ struct WebComponent {
Implements a **WebStorage** object to manage the Web SQL database and HTML5 Web Storage APIs. All **\<Web>** components in an application share a **WebStorage** object.
> **NOTE**
>
> You must load the **\<Web>** component before calling the APIs in **WebStorage**.
### deleteOrigin
static deleteOrigin(origin : string): void
......@@ -5148,6 +5253,10 @@ struct WebComponent {
Implements a **WebDataBase** object.
> **NOTE**
>
> You must load the **\<Web>** component before calling the APIs in **WebDataBase**.
### getHttpAuthCredentials
static getHttpAuthCredentials(host: string, realm: string): Array\<string>
......@@ -5326,6 +5435,10 @@ struct WebComponent {
Implements a **GeolocationPermissions** object.
> **NOTE**
>
> You must load the **\<Web>** component before calling the APIs in **GeolocationPermissions**.
### Required Permissions
**ohos.permission.LOCATION**, **ohos.permission.APPROXIMATELY_LOCATION**, and **ohos.permission.LOCATION_IN_BACKGROUND**, which are required for accessing the location information. For details about the permissions, see [@ohos.geolocation (Geolocation)](./js-apis-geolocation.md).
......@@ -5739,7 +5852,6 @@ Describes the type of the returned result of script execution using [runJavaScir
| ARRAY_BUFFER | 4 |Raw binary data buffer.|
| ARRAY | 5 |Array type.|
## WebMessageType<sup>10+</sup>
Describes the data type supported by the [webMessagePort](#webmessageport) API.
......@@ -5796,7 +5908,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the result. |
### getNumber<sup>10+</sup>
getNumber(): number
......@@ -5841,7 +5952,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the result. |
### getArrayBuffer<sup>10+</sup>
getArrayBuffer(): ArrayBuffer
......@@ -5885,7 +5995,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the result. |
## WebMessageExt<sup>10+</sup>
Data object received and sent by the [webMessagePort](#webmessageport) interface.
......@@ -5904,7 +6013,6 @@ Obtains the type of the data object.
| --------------| --------------------------------------------------------- |
| [WebMessageType](#webmessagetype10) | Data type supported by the [webMessagePort](#webmessageport) API.|
### getString<sup>10+</sup>
getString(): string
......@@ -5927,7 +6035,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. |
### getNumber<sup>10+</sup>
getNumber(): number
......@@ -5950,7 +6057,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. |
### getBoolean<sup>10+</sup>
getBoolean(): boolean
......@@ -5973,7 +6079,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. |
### getArrayBuffer<sup>10+</sup>
getArrayBuffer(): ArrayBuffer
......@@ -6039,7 +6144,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. |
### setType<sup>10+</sup>
setType(type: WebMessageType): void
......@@ -6180,7 +6284,6 @@ Sets the error-object-type data for the data object. For the complete sample cod
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. |
## WebStorageOrigin
Provides usage information of the Web SQL Database.
......
......@@ -39,9 +39,9 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
In addition to the [universal events](ts-universal-events-click.md), the following attributes are supported.
| Name | Description |
| Name | Description |
| -------------------------------------------- | ------------------------------------------------------------ |
| onChange(callback: (value: boolean) => void) | Triggered when the selected status of the check box changes.<br>- The value **true** means that the check box is selected.<br>- The value **false** means that the check box is not selected.<br>Since API version 9, this API is supported in ArkTS widgets. |
| onChange(callback: (value: boolean) => void) | Triggered when the selected status of the check box changes.<br>- The value **true** means that the check box is selected.<br>- The value **false** means that the check box is not selected.<br>Since API version 9, this API is supported in ArkTS widgets.|
## MarkStyle<sup>10+</sup>
......@@ -53,6 +53,8 @@ In addition to the [universal events](ts-universal-events-click.md), the followi
## Example
### Example 1
```ts
// xxx.ets
@Entry
......@@ -80,3 +82,51 @@ struct CheckboxExample {
![](figures/checkbox.gif)
### Example 2
```ts
// xxx.ets
@Entry
@Component
struct Index {
build() {
Row() {
Column() {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox1 change is'+ value)
})
.mark({
strokeColor:Color.Black,
size: 50,
strokeWidth: 5
})
.unselectedColor(Color.Red)
.width(30)
.height(30)
Text('Checkbox1').fontSize(20)
}
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Checkbox({ name: 'checkbox2', group: 'checkboxGroup' })
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox2 change is' + value)
})
.width(30)
.height(30)
Text('Checkbox2').fontSize(20)
}
}
.width('100%')
}
.height('100%')
}
}
```
![](figures/checkbox2.gif)
......@@ -72,6 +72,8 @@ Since API version 9, this API is supported in ArkTS widgets.
## Example
### Example 1
```ts
// xxx.ets
@Entry
......@@ -124,4 +126,77 @@ struct CheckboxExample {
}
}
```
![checkboxgroup](figures/checkboxgroup.gif)
![checkboxGroup](figures/checkboxGroup.gif)
### Example 2
```ts
// xxx.ets
@Entry
@Component
struct Index {
build() {
Row() {
Column() {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
CheckboxGroup({ group: 'checkboxGroup' })
.selectedColor(Color.Orange)
.onChange((itemName: CheckboxGroupResult) => {
console.info("checkbox group content" + JSON.stringify(itemName))
})
.mark({
strokeColor:Color.Black,
size: 40,
strokeWidth: 5
})
.unselectedColor(Color.Red)
.width(30)
.height(30)
Text('Select All').fontSize(20)
}.margin({right:15})
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox1 change is'+ value)
})
.mark({
strokeColor:Color.Black,
size: 50,
strokeWidth: 5
})
.unselectedColor(Color.Red)
.width(30)
.height(30)
Text('Checkbox1').fontSize(20)
}
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Checkbox({ name: 'checkbox2', group: 'checkboxGroup' })
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox2 change is' + value)
})
.width(30)
.height(30)
Text('Checkbox2').fontSize(20)
}
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Checkbox({ name: 'checkbox3', group: 'checkboxGroup' })
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox3 change is' + value)
})
.width(30)
.height(30)
Text('Checkbox3').fontSize(20)
}
}
.width('100%')
}
.height('100%')
}
}
```
![checkboxGroup](figures/checkboxGroup2.gif)
......@@ -42,7 +42,7 @@ Creates a **FormComponent** instance to display the provided widget.
| Name | Type | Mandatory| Description |
| --------- | ------------------------------- | ---- | ----------------------------------------------------------------------- |
| id | number | Yes | Widget ID. Set this parameter to **0** for a new widget. |
| id | number | Yes | Widget ID. Set this parameter to **0** for a new widget.<br>**NOTE**<br>Different widget hosts cannot use the same ID.<br>If a widget host uses the same ID for two widgets, the one added later is displayed. |
| name | string | Yes | Widget name. |
| bundle | string | Yes | Bundle name of the widget. |
| ability | string | Yes | Ability name of the widget. |
......
......@@ -43,14 +43,14 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| hideToolBar | boolean | Whether to hide the toolbar.<br>Default value: **false**<br>**true**: Hide the toolbar.<br>**false**: Display the toolbar.|
| hideTitleBar | boolean | Whether to hide the title bar.<br>Default value: **false**<br>**true**: Hide the title bar.<br>**false**: Display the title bar.|
| hideBackButton | boolean | Whether to hide the back button.<br>Default value: **false**<br>**true**: Hide the back button.<br>**false**: Display the back button.<br>The back button in the title bar of the **\<NavDestination>** component cannot be hidden.<br>**NOTE**<br>The back button works only when **titleMode** is set to **NavigationTitleMode.Mini**.|
| navBarWidth<sup>9+</sup> | [Length](ts-types.md#length) | Width of the navigation bar.<br>Default value: **200**<br>Unit: vp<br>**NOTE**<br>This attribute is valid only when the **\<Navigation>** component is split.|
| navBarWidth<sup>9+</sup> | [Length](ts-types.md#length) | Width of the navigation bar.<br>Default value: **240**<br>Unit: vp<br>**NOTE**<br>This attribute is valid only when the **\<Navigation>** component is split.|
| navBarPosition<sup>9+</sup> | [NavBarPosition](#navbarposition) | Position of the navigation bar.<br>Default value: **NavBarPosition.Start**<br>**NOTE**<br>This attribute is valid only when the **\<Navigation>** component is split.|
| mode<sup>9+</sup> | [NavigationMode](#navigationmode) | Display mode of the navigation bar.<br>Default value: **NavigationMode.Auto**<br>At the default settings, the component adapts to a single column or two columns based on the component width.|
| mode<sup>9+</sup> | [NavigationMode](#navigationmode) | Display mode of the navigation bar.<br>Default value: **NavigationMode.Auto**<br>At the default settings, the component adapts to a single column or two columns based on the component width.<br>**NOTE**<br>Available options are **Stack**, **Split**, and **Auto**.|
| backButtonIcon<sup>9+</sup> | string \| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](ts-types.md#resource) | Back button icon on the navigation bar. The back button in the title bar of the **\<NavDestination>** component cannot be hidden.|
| hideNavBar<sup>9+</sup> | boolean | Whether to hide the navigation bar. This attribute is valid only when **mode** is set to **NavigationMode.Split**.|
| navDestination<sup>10+</sup> | builder: (name: string, param: unknown) => void | Creates a **\<NavDestination>** component.<br>**NOTE**<br>The **builder** function is used, with the **name** and **param** parameters passed in. In the builder, a layer of custom components can be included outside the **\<NavDestination>** component. However, no attributes or events can be set for the custom components. Otherwise, only blank components are displayed.|
| navBarWidthRange<sup>10+</sup> | [[Dimension](ts-types.md#dimension10), [Dimension](ts-types.md#dimension10)] | Minimum and maximum widths of the navigation bar.<br>Default value: **240** for the minimum value; 40% of the component width (not greater than 432) for the maximum value<br>Unit: vp<br>Priority rules:<br>Custom value > Default value<br>Minimum value > Maximum value<br>navBar > content<br>If values conflict, the global value takes precedence, and the local minimum value depends on the container size.|
| minContentWidth<sup>10+</sup> | [Dimension](ts-types.md#dimension10) | Minimum width of the navigation bar content area.<br>Default value: **360**<br>Unit: vp<br>Priority rules:<br>Custom value > Default value<br>Minimum value > Maximum value<br>navBar > content<br>If values conflict, the global value takes precedence, and the local minimum value depends on the container size.<br>Breakpoint calculation in Auto mode: default 600vp = minNavBarWidth (240vp) + minContentWidth (360vp)|
| navBarWidthRange<sup>10+</sup> | [[Dimension](ts-types.md#dimension10), [Dimension](ts-types.md#dimension10)] | Minimum and maximum widths of the navigation bar (valid in dual-column mode).<br>Default value: **240** for the minimum value; 40% of the component width (not greater than 432) for the maximum value<br>Unit: vp<br>Priority rules:<br>Custom value > Default value<br>Minimum value > Maximum value<br>navBar > content<br>If values conflict, the global value takes precedence, and the local minimum value depends on the container size.|
| minContentWidth<sup>10+</sup> | [Dimension](ts-types.md#dimension10) | Minimum width of the navigation bar content area (valid in dual-column mode).<br>Default value: **360**<br>Unit: vp<br>Priority rules:<br>Custom value > Default value<br>Minimum value > Maximum value<br>navBar > content<br>If values conflict, the global value takes precedence, and the local minimum value depends on the container size.<br>Breakpoint calculation in Auto mode: default 600 vp = minNavBarWidth (240 vp) + minContentWidth (360 vp)|
## NavPathStack<sup>10+</sup>
......@@ -319,11 +319,11 @@ constructor(name: string, param: unknown)
## NavigationMode
| Name | Description |
| ----- | ---------------------------------------- |
| Name | Description |
| ----- | ------------------------------------------------------------ |
| Stack | The navigation bar and content area are displayed independently of each other, which are equivalent to two pages. |
| Split | The navigation bar and content area are displayed in different columns. |
| Auto | When the window width is greater than or equal to 520 vp, Split mode is used. Otherwise, the Stack mode is used.|
| Split | The navigation bar and content area are displayed in different columns. |
| Auto | In API version 9 and earlier versions: When the window width is greater than or equal to 520 vp, the Split mode is used. In other cases, the Stack mode is used.<br>In API version 10 and later versions: When the window width is greater than or equal to 600 vp, the Split mode is used. In other cases, the Stack mode is used. 600 vp = minNavBarWidth (240 vp) + minContentWidth (360 vp).|
## TitleHeight
......
......@@ -107,32 +107,31 @@ Web(options: { src: ResourceStr, controller: WebviewController | WebController})
```
2. Modify the **EntryAbility.ts** file.
The following uses **filesDir** as an example to describe how to obtain the path of the sandbox. For details about how to obtain other paths, see [Obtaining Application File Paths](../../application-models/application-context-stage.md#obtaining-application-file-paths).
```ts
// xxx.ts
import UIAbility from '@ohos.app.ability.UIAbility';
import web_webview from '@ohos.web.webview';
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
// Bind filesDir to the globalThis object to implement data synchronization between the UIAbility component and the UI.
globalThis.filesDir = this.context.filesDir
console.log("Sandbox path is " + globalThis.filesDir)
}
}
```
The following uses **filesDir** as an example to describe how to obtain the path of the sandbox. For details about how to obtain other paths, see [Obtaining Application File Paths](../../application-models/application-context-stage.md#obtaining-application-file-paths).
```ts
// xxx.ts
import UIAbility from '@ohos.app.ability.UIAbility';
import web_webview from '@ohos.web.webview';
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
// Bind filesDir to the globalThis object to implement data synchronization between the UIAbility component and the UI.
globalThis.filesDir = this.context.filesDir
console.log("Sandbox path is " + globalThis.filesDir)
}
}
```
HTML file to be loaded:
```html
<!-- index.html -->
<!DOCTYPE html>
<html>
<body>
<p>Hello World</p>
</body>
</html>
```
HTML file to be loaded:
```html
<!-- index.html -->
<!DOCTYPE html>
<html>
<body>
<p>Hello World</p>
</body>
</html>
```
## Attributes
......@@ -672,12 +671,16 @@ Sets whether to display the vertical scrollbar, including the default system scr
</html>
```
### password
### password<sup>(deprecated)</sup>
password(password: boolean)
Sets whether the password should be saved. This API is a void API.
> **NOTE**
>
> This API is deprecated since API version 10, and no new API is provided as a substitute.
### cacheMode
cacheMode(cacheMode: CacheMode)
......@@ -993,7 +996,6 @@ Sets the minimum logical font size for the web page.
}
```
### webFixedFont<sup>9+</sup>
webFixedFont(family: string)
......@@ -1244,18 +1246,26 @@ Sets whether to enable forcible dark mode for the web page. By default, this fea
}
```
### tableData
### tableData<sup>(deprecated)</sup>
tableData(tableData: boolean)
Sets whether form data should be saved. This API is a void API.
### wideViewModeAccess
> **NOTE**
>
> This API is deprecated since API version 10, and no new API is provided as a substitute.
### wideViewModeAccess<sup>(deprecated)</sup>
wideViewModeAccess(wideViewModeAccess: boolean)
Sets whether to support the viewport attribute of the HTML **\<meta>** tag. This API is a void API.
> **NOTE**
>
> This API is deprecated since API version 10, and no new API is provided as a substitute.
### pinchSmooth<sup>9+</sup>
pinchSmooth(isEnabled: boolean)
......@@ -1386,7 +1396,6 @@ Sets the web-based media playback policy, including the validity period for auto
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
......@@ -1941,7 +1950,6 @@ Called when an HTTP error (the response code is greater than or equal to 400) oc
onPageBegin(callback: (event?: { url: string }) => void)
Called when the web page starts to be loaded. This API is called only for the main frame content, and not for the iframe or frameset content.
**Parameters**
......@@ -1976,7 +1984,6 @@ Called when the web page starts to be loaded. This API is called only for the ma
onPageEnd(callback: (event?: { url: string }) => void)
Called when the web page loading is complete. This API takes effect only for the main frame content.
**Parameters**
......@@ -2979,7 +2986,7 @@ If opening a new window is not needed, set the parameter to **null** when callin
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
// There are two <Web> components on the same page. When the WebComponent object opens a new window, the NewWebViewComp object is displayed.
@CustomDialog
struct NewWebViewComp {
......@@ -3335,8 +3342,8 @@ Called when the web page content is first rendered.
Column() {
Web({ src:'www.example.com', controller: this.controller })
.onFirstContentfulPaint(event => {
console.log("onFirstContentfulPaint:" + "[navigationStartTick]:" +
event.navigationStartTick + ", [firstContentfulPaintMs]:" +
console.log("onFirstContentfulPaint:" + "[navigationStartTick]:" +
event.navigationStartTick + ", [firstContentfulPaintMs]:" +
event.firstContentfulPaintMs)
})
}
......@@ -3415,7 +3422,156 @@ Called when the **\<Web>** component obtains the focus.
}
}
```
### onScreenCaptureRequest<sup>10+</sup>
onScreenCaptureRequest(callback: (event?: { handler: ScreenCaptureHandler }) => void)
Called when a screen capture request is received.
**Parameters**
| Name | Type | Description |
| ------- | ---------------------------------------- | -------------- |
| handler | [ScreenCaptureHandler](#screencapturehandler10) | User operation.|
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController()
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
.onScreenCaptureRequest((event) => {
AlertDialog.show({
title: 'title: ' + event.handler.getOrigin(),
message: 'text',
primaryButton: {
value: 'deny',
action: () => {
event.handler.deny()
}
},
secondaryButton: {
value: 'onConfirm',
action: () => {
event.handler.grant({ captureMode: WebCaptureMode.HOME_SCREEN })
}
},
cancel: () => {
event.handler.deny()
}
})
})
}
}
}
```
### onOverScroll<sup>10+</sup>
onOverScroll(callback: (event: {xOffset: number, yOffset: number}) => void)
Called to indicate the offset by which the web page overscrolls.
**Parameters**
| Name | Type | Description |
| ------- | ------ | ------------ |
| xOffset | number | Horizontal overscroll offset based on the leftmost edge of the web page.|
| yOffset | number | Vertical overscroll offset based on the top edge of the web page.|
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController()
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
.onOverScroll((event) => {
console.info("x = " + event.xOffset)
console.info("y = " + event.yOffset)
})
}
}
}
```
### onControllerAttached<sup>10+</sup>
onControllerAttached(callback: () => void)
Called when the controller is successfully bound to the **\<Web>** component. The controller must be WebviewController.
As the web page is not yet loaded when this callback is called, APIs for operating the web page cannot be used in the callback, for example, [zoomIn](../apis/js-apis-webview.md#zoomin) and [zoomOut]. (../apis/js-apis-webview.md#zoomout). Other APIs, such as [loadUrl] (../apis/js-apis-webview.md#loadurl) and [getWebId] (../apis/js-apis-webview.md#getwebid), which do not involve web page operations, can be used properly.
**Example**
The following example uses **loadUrl** in the callback to load the web page.
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController()
build() {
Column() {
Web({ src: '', controller: this.controller })
.onControllerAttached(() => {
this.controller.loadUrl($rawfile("index.html"));
})
}
}
}
```
The following example uses **getWebId** in the callback
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController()
build() {
Column() {
Web({ src: $rawfile("index.html"), controller: this.controller })
.onControllerAttached(() => {
try {
let id = this.controller.getWebId();
console.log("id: " + id);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
}
}
}
```
HTML file to be loaded:
```html
<!-- index.html -->
<!DOCTYPE html>
<html>
<body>
<p>Hello World</p>
</body>
</html>
```
## ConsoleMessage
Implements the **ConsoleMessage** object. For the sample code, see [onConsole](#onconsole).
......@@ -3470,7 +3626,7 @@ Obtains the path and name of the web page source file.
## JsResult
Implements the **JsResult** object, which indicates the result returned to the **\<Web>** component to indicate the user operation performed in the dialog box. For the sample code, see [onAlert](#onalert).
Implements the **JsResult** object, which indicates the result returned to the **\<Web>** component to indicate the user operation performed in the dialog box. For the sample code, see [onAlert Event](#onalert).
### handleCancel
......@@ -3635,7 +3791,6 @@ Describes the request/response header returned by the **\<Web>** component.
| headerKey | string | Key of the request/response header. |
| headerValue | string | Value of the request/response header.|
## WebResourceResponse
Implements the **WebResourceResponse** object. For the sample code, see [onHttpErrorReceive](#onhttperrorreceive).
......@@ -4010,6 +4165,42 @@ Grants the permission for resources requested by the web page.
| --------- | --------------- | ---- | ---- | ------------- |
| resources | Array\<string\> | Yes | - | List of resources that can be requested by the web page with the permission to grant.|
## ScreenCaptureHandler<sup>10+</sup>
Implements the **ScreenCaptureHandler** object for accepting or rejecting a screen capture request. For the sample code, see [onScreenCaptureRequest Event](#onscreencapturerequest10).
### deny<sup>10+</sup>
deny(): void
Rejects this screen capture request.
### getOrigin<sup>10+</sup>
getOrigin(): string
Obtains the origin of this web page.
**Return value**
| Type | Description |
| ------ | ------------ |
| string | Origin of the web page that requests the permission.|
### grant<sup>10+</sup>
grant(config: ScreenCaptureConfig): void
**Required permissions**: ohos.permission.MICROPHONE, ohos.permission.CAPTURE_SCREEN
Grants the screen capture permission.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| --------- | --------------- | ---- | ---- | ------------- |
| config | [ScreenCaptureConfig](#screencaptureconfig10) | Yes | - | Screen capture configuration.|
## ContextMenuSourceType<sup>9+</sup>
| Name | Description |
| -------------------- | ---------- |
......@@ -4327,6 +4518,7 @@ Enumerates the error codes returned by **onSslErrorEventReceive** API.
| --------- | ------------- | -------------------------- |
| MidiSysex | MIDI SYSEX resource.| Currently, only permission events can be reported. MIDI devices are not yet supported.|
| VIDEO_CAPTURE<sup>10+</sup> | Video capture resource, such as a camera.| |
| AUDIO_CAPTURE<sup>10+</sup> | Audio capture resource, such as a microphone.| |
## WebDarkMode<sup>9+</sup>
| Name | Description |
......@@ -4335,6 +4527,12 @@ Enumerates the error codes returned by **onSslErrorEventReceive** API.
| On | The web dark mode is enabled. |
| Auto | The web dark mode setting follows the system settings. |
## WebCaptureMode<sup>10+</sup>
| Name | Description |
| --------- | ------------- |
| HOME_SCREEN | Capture of the home screen.|
## WebMediaOptions<sup>10+</sup>
Describes the web-based media playback policy.
......@@ -4344,6 +4542,14 @@ Describes the web-based media playback policy.
| resumeInterval | number | Yes | Yes | No |Validity period for automatically resuming a paused web audio, in seconds. The maximum validity period is 60 seconds. Due to the approximate value, the validity period may have a deviation of less than 1 second.|
| audioExclusive | boolean | Yes | Yes | No | Whether the audio of multiple **\<Web>** instances in an application is exclusive. |
## ScreenCaptureConfig<sup>10+</sup>
Provides the web screen capture configuration.
| Name | Type | Readable| Writable| Mandatory| Description |
| -------------- | --------- | ---- | ---- | --- | ---------------------------- |
| captureMode | [WebCaptureMode](#webcapturemode10) | Yes | Yes | Yes | Web screen capture mode.|
## DataResubmissionHandler<sup>9+</sup>
Implements the **DataResubmissionHandler** object for resubmitting or canceling the web form data.
......@@ -4653,7 +4859,7 @@ This API is deprecated since API version 9. You are advised to use [forward<sup>
deleteJavaScriptRegister(name: string)
Deletes a specific application JavaScript object that is registered with the window through **registerJavaScriptProxy**. The deletion takes effect immediately, with no need for invoking the[refresh](#refreshdeprecated) API.
Deletes a specific application JavaScript object that is registered with the window through **registerJavaScriptProxy**. The deletion takes effect immediately, with no need for invoking the [refresh](#refreshdeprecated) API.
This API is deprecated since API version 9. You are advised to use [deleteJavaScriptRegister<sup>9+</sup>](../apis/js-apis-webview.md#deletejavascriptregister) instead.
......
......@@ -76,12 +76,11 @@ For a list in horizontal layout, it refers to the delete item displayed below (o
| Name | Type | Mandatory| Description |
| -------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| deleteAreaDistance | [Length](ts-types.md#length) | No| Swipe distance threshold for deleting the list item.<br>Default value: **56vp**<br>**NOTE**<br>This parameter cannot be set in percentage.<br>If the value is greater than the list item width minus the width of **swipeAction**, or is less than or equal to 0, the delete area will not be set.|
| onDelete | () => void | No| Callback invoked when the list item is released while in the delete area.<br>**NOTE**<br> This callback is invoked only when the list item is released in a position that meets or goes beyond the specified swipe distance threshold (which must be valid) for deleting the list item.|
| onEntryDeleteArea | () => void | No| Callback invoked each time the list item enters the delete area.|
| onExitDeleteArea | () => void | No|Callback invoked each time the list item exits the delete area.|
| actionAreaDistance | [Length](ts-types.md#length) | No| Swipe distance threshold for deleting the list item.<br>Default value: **56vp**<br>**NOTE**<br>This parameter cannot be set in percentage.<br>If the value is greater than the list item width minus the width of **swipeAction**, or is less than or equal to 0, the delete area will not be set.|
| onAction | () => void | No| Callback invoked when the list item is released while in the delete area.<br>**NOTE**<br> This callback is invoked only when the list item is released in a position that meets or goes beyond the specified swipe distance threshold (which must be valid) for deleting the list item.|
| onEnterActionArea | () => void | No| Callback invoked each time the list item enters the delete area.|
| onExitActionArea | () => void | No|Callback invoked each time the list item exits the delete area.|
| builder | CustomBuilder | No|Swipe action item displayed when the list item is swiped left or right (in vertical list layout) or up or down (in horizontal list layout).|
| useDefaultDeleteAnimation | boolean | No|Whether to use the default delete animation.<br>Default value: **true**|
## ListItemOptions<sup>10+</sup>
| Name | Type | Mandatory| Description |
......@@ -101,9 +100,10 @@ For a list in horizontal layout, it refers to the delete item displayed below (o
| -------- | -------- |
| onSelect(event: (isSelected: boolean) =&gt; void)<sup>8+</sup> | Triggered when the selected state of the **\<ListItem>** changes.<br>**isSelected**: Returns **true** if the **\<ListItem>** is selected by mouse drag; returns **false** otherwise.|
## Example
### Example 1
```ts
// xxx.ets
@Entry
......@@ -130,6 +130,8 @@ struct ListItemExample {
![en-us_image_0000001219864159](figures/en-us_image_0000001219864159.gif)
### Example 2
```ts
// xxx.ets
......@@ -165,19 +167,18 @@ struct ListItemExample2 {
.swipeAction({
end: {
builder: this.itemEnd.bind(this, item),
useDefaultDeleteAnimation: true,
onDelete: () => {
onAction: () => {
animateTo({ duration: 1000 }, () => {
let index = this.arr.indexOf(item)
this.arr.splice(index, 1)
})
},
deleteAreaDistance: 80,
onEnterDeleteArea: () => {
actionAreaDistance: 80,
onEnterActionArea: () => {
this.enterEndDeleteAreaString = "enterEndDeleteArea"
this.exitEndDeleteAreaString = "not exitEndDeleteArea"
},
onExitDeleteArea: () => {
onExitActionArea: () => {
this.enterEndDeleteAreaString = "not enterEndDeleteArea"
this.exitEndDeleteAreaString = "exitEndDeleteArea"
}
......@@ -196,3 +197,43 @@ struct ListItemExample2 {
}
```
![deleteListItem](figures/deleteListItem.gif)
### Example 3
```ts
// xxx.ets
@Entry
@Component
struct ListItemExample3 {
private arr: any = [ListItemStyle.CARD, ListItemStyle.CARD,ListItemStyle.NONE]
build() {
Column() {
List({ space: "4vp", initialIndex: 0 }) {
ListItemGroup({style:ListItemGroupStyle.CARD}){
ForEach(this.arr, (itemStyle,index) => {
ListItem({style:itemStyle}) {
Text(""+index)
.width("100%")
.textAlign(TextAlign.Center)
}
})
}
ForEach(this.arr, (itemStyle,index) => {
ListItem({style:itemStyle}) {
Text(""+index)
.width("100%")
.textAlign(TextAlign.Center)
}
})
}
.width('100%')
.multiSelectable(true)
.backgroundColor(0xDCDCDC) // List in light blue
}
.width('100%')
.padding({ top: 5 })
}
}
```
![ListItemStyle](figures/listItem3.jpeg)
......@@ -8,9 +8,9 @@ The **\<ListItemGroup>** component is used to display list item groups. It must
## Usage Guidelines
If the **listDirection** attribute of the parent **\<List>** component is set to **Axis.Vertical**, the **height** attribute of the **\<ListItemGroup>** component cannot be set. The height of a **\<ListItemGroup>** component is the sum of its header height, footer height, and total height of the list items. If the **listDirection** attribute of the parent **\<List>** component is set to **Axis.Horizontal**, the **width** attribute of the **\<ListItemGroup>** component cannot be set. The width of a **\<ListItemGroup>** component is the sum of its header width, footer width, and total width of the list items.
If the **listDirection** attribute of the parent **\<List>** component is set to **Axis.Vertical**, the **height** attribute of the **\<ListItemGroup>** component is fixed at the sum of the component's header height, footer height, and total height of the list items. If the **listDirection** attribute of the parent **\<List>** component is set to **Axis.Horizontal**, the **width** attribute of the **\<ListItemGroup>** component is fixed at the sum of the component's header width, footer width, and total width of the list items.
The list items in the **\<ListItemGroup>** component cannot be edited, selected, or dragged. That is, the **editable** and **selectable** attributes of these list items do not take effect.
The list items in the **\<ListItemGroup>** component cannot be edited or dragged. That is, their **editable** attribute does not take effect.
## Child Components
......@@ -27,8 +27,8 @@ ListItemGroup(options?: {header?: CustomBuilder, footer?: CustomBuilder, space?:
| ------------------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ |
| header | [CustomBuilder](ts-types.md#custombuilder8) | No | Header of the list item group. |
| footer | [CustomBuilder](ts-types.md#custombuilder8) | No | Footer of the list item group. |
| space | number \| string | No | Spacing between list items. This parameter is valid only between list items, but not between a header and list item or between a footer and list item.|
| style<sup>10+</sup> | [ListItemGroupStyle](#listitemgroupstyle10) | No | Style of the list item group.<br>Default value: **ListItemGroupStyle.NONE**<br>If this parameter is set to **ListItemGroupStyle.NONE**, no style is applied.<br>If this parameter is set to **ListItemGroupStyle.CARD**, the default card style is applied, but only when **ListItemStyle.CARD** is set for [\<ListItem>](ts-container-listitem.md).<br>It can be in focus, hover, press, selected, or disable style depending on the state.<br>**NOTE**<br>In the default card style, the list has its **listDirection** attribute fixed at **Axis.Vertical** and **alignListItem** attribute at **ListItemAlign.Center**; the **header** and **footer** parameters cannot be set for the list item group. |
| space | number \| string | No | Spacing between list items. This parameter is valid only between list items, but not between the header and list item or between the footer and list item.|
| style<sup>10+</sup> | [ListItemGroupStyle](#listitemgroupstyle10) | No | Style of the list item group.<br>Default value: **ListItemGroupStyle.NONE**<br>If this parameter is set to **ListItemGroupStyle.NONE**, no style is applied.<br>If this parameter is set to **ListItemGroupStyle.CARD**, the default card style is applied, but only when **ListItemStyle.CARD** is set for [\<ListItem>](ts-container-listitem.md).<br>In the default card style, list items can be in focus, hover, press, selected, or disable style depending on their state.<br>**NOTE**<br>In the default card style, the parent **\<List>** component has its **listDirection** attribute fixed at **Axis.Vertical** and its **alignListItem** attribute defaulted at **ListItemAlign.Center**; the **header** and **footer** parameters cannot be set for the list item group. |
## Attributes
......@@ -45,7 +45,7 @@ ListItemGroup(options?: {header?: CustomBuilder, footer?: CustomBuilder, space?:
> **NOTE**
>
> The **\<ListItemGroup>** component does not support the universal attribute **[aspectRatio](ts-universal-attributes-layout-constraints.md)**.
> The **\<ListItemGroup>** component does not support the universal attribute [aspectRatio](ts-universal-attributes-layout-constraints.md).
>
> If the main axis of **\<ListItemGroup>** runs in the vertical direction, the [height](ts-universal-attributes-size.md) setting does not take effect.
>
......@@ -54,6 +54,8 @@ ListItemGroup(options?: {header?: CustomBuilder, footer?: CustomBuilder, space?:
## Example
### Example 1
```ts
// xxx.ets
@Entry
......@@ -119,3 +121,55 @@ struct ListItemGroupExample {
```
![en-us_image_0000001219864159](figures/en-us_image_listitemgroup.gif)
### Example 2
```ts
// xxx.ets
@Entry
@Component
struct ListItemGroupExample2 {
private arr: any = [
{
style:ListItemGroupStyle.CARD,
itemStyles:[ListItemStyle.CARD, ListItemStyle.CARD, ListItemStyle.CARD]
},
{
style:ListItemGroupStyle.CARD,
itemStyles:[ListItemStyle.CARD, ListItemStyle.CARD, ListItemStyle.NONE]
},
{
style:ListItemGroupStyle.CARD,
itemStyles:[ListItemStyle.CARD, ListItemStyle.NONE, ListItemStyle.CARD]
},
{
style:ListItemGroupStyle.NONE,
itemStyles:[ListItemStyle.CARD, ListItemStyle.CARD, ListItemStyle.NONE]
}
]
build() {
Column() {
List({ space: "4vp", initialIndex: 0 }) {
ForEach(this.arr, (item,index) => {
ListItemGroup({ style:item.style }) {
ForEach(item.itemStyles, (itemStyle,itemIndex) => {
ListItem({style:itemStyle}) {
Text("Item "+(itemIndex+1)+" in group "+(index+1))
.width("100%")
.textAlign(TextAlign.Center)
}
}, item => item)
}
})
}
.width('100%')
.multiSelectable(true)
.backgroundColor(0xDCDCDC) // List in light blue
}
.width('100%')
.padding({ top: 5 })
}
}
```
![ListItemGroupStyle](figures/listItemGroup2.jpeg)
......@@ -45,13 +45,13 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| showSideBar | boolean | Whether to display the sidebar.<br>Default value: **true**<br>Since API version 10, this attribute supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.|
| controlButton | [ButtonStyle](#buttonstyle) | Attributes of the sidebar control button.|
| showControlButton | boolean | Whether to display the sidebar control button.<br>Default value: **true**|
| sideBarWidth | number \| [Length](ts-types.md#length)<sup>9+</sup> | Width of the sidebar.<br>Default value: **240vp**<br>Unit: vp<br>**NOTE**<br>In API version 9 and earlier versions, the default value is **200vp**. In API version 10, the default value is **240vp**.<br>A value less than 0 evaluates to the default value.<br>The value must comply with the width constraints. If it is not within the valid range, the value closest to the set one is used.<br>The width of the sidebar, whether it is specified or kept at the default, takes precedence over that of the sidebar child components.|
| minSideBarWidth | number \| [Length](ts-types.md#length)<sup>9+</sup> | Minimum width of the sidebar.<br>Default value: **240vp**<br>Unit: vp<br>**NOTE**<br>In API version 9 and earlier versions, the default value is **200vp**. In API version 10, the default value is **240vp**.<br>A value less than 0 evaluates to the default value.<br>The value cannot exceed the width of the sidebar container itself. Otherwise, the width of the sidebar container itself is used.<br>When set, the minimum width of the sidebar takes precedence over that of the sidebar child components. If it is not set, however, the minimum width of the sidebar child component takes precedence.|
| maxSideBarWidth | number \| [Length](ts-types.md#length)<sup>9+</sup> | Maximum width of the sidebar.<br>Default value: **280vp**<br>Unit: vp<br>**NOTE**<br>A value less than 0 evaluates to the default value.<br>The value cannot exceed the width of the sidebar container itself. Otherwise, the width of the sidebar container itself is used.<br>When set, the maximum width of the sidebar takes precedence over that of the sidebar child components. If it is not set, however, the maximum width of the sidebar child component takes precedence.|
| sideBarWidth | number \| [Length](ts-types.md#length)<sup>9+</sup> | Width of the sidebar.<br>Default value: **240vp**<br>Unit: vp<br>**NOTE**<br>In API version 9 and earlier versions, the default value is **200vp**. In API version 10, the default value is **240vp**.<br>A value less than 0 evaluates to the default value.<br>The value must comply with the width constraints. If it is not within the valid range, the value closest to the set one is used.<br>The width of the sidebar, whether it is specified or kept at the default value, takes precedence over that of the sidebar child components.|
| minSideBarWidth | number \| [Length](ts-types.md#length)<sup>9+</sup> | Minimum width of the sidebar.<br>Default value: **240vp**<br>Unit: vp<br>**NOTE**<br>In API version 9 and earlier versions, the default value is **200vp**. In API version 10, the default value is **240vp**.<br>A value less than 0 evaluates to the default value.<br>The value cannot exceed the width of the sidebar container itself. Otherwise, the width of the sidebar container itself is used.<br>**minSideBarWidth**, whether it is specified or kept at the default value, takes precedence over **minWidth** of the sidebar child components.|
| maxSideBarWidth | number \| [Length](ts-types.md#length)<sup>9+</sup> | Maximum width of the sidebar.<br>Default value: **280vp**<br>Unit: vp<br>**NOTE**<br>A value less than 0 evaluates to the default value.<br>The value cannot exceed the width of the sidebar container itself. Otherwise, the width of the sidebar container itself is used.<br>**maxSideBarWidth**, whether it is specified or kept at the default value, takes precedence over **maxWidth** of the sidebar child components.|
| autoHide<sup>9+</sup> | boolean | Whether to automatically hide the sidebar when it is dragged to be smaller than the minimum width.<br>Default value: **true**<br>**NOTE**<br>The value is subject to the **minSideBarWidth** attribute method. If it is not set in **minSideBarWidth**, the default value is used.<br>Whether the sidebar should be hidden is determined when it is being dragged. When its width is less than the minimum width, the damping effect is required to trigger hiding (a distance out of range).|
| sideBarPosition<sup>9+</sup> | [SideBarPosition](#sidebarposition9) | Position of the sidebar.<br>Default value: **SideBarPosition.Start**|
| divider<sup>10+</sup> | [DividerStyle](#dividerstyle10) \| null | Divider style.<br>- **DividerStyle** (default): The divider is displayed.<br>- **null**: The divider is not displayed.|
| minContentWidth<sup>10+</sup> | [Dimension](ts-types.md#dimension10) | Minimum width of the content area of the sidebar container.<br>Default value: **360vp**<br>Unit: vp<br>**NOTE**<br>A value less than 0 evaluates to the default value.<br>In Embed mode, when the component size is increased, only the content area is enlarged; when the component size is decreased, the content area is shrunk until its width reaches the value defined by **minContentWidth**, and then the sidebar is shrunk until its width reaches the value defined by **minSideBarWidth**; if the component size is further decreased, while respecting the minimum width of the sidebar, the content area is further shrunk until it is 0 vp large.<br>minContentWidth takes precedence over maxSideBarWidth and sideBarWidth of the sidebar. If minContentWidth is not set, the priority of the default value is lower than that of minSideBarWidth and maxSideBarWidth.|
| minContentWidth<sup>10+</sup> | [Dimension](ts-types.md#dimension10) | Minimum width of the content area of the sidebar container.<br>Default value: **360vp**<br>Unit: vp<br>**NOTE**<br>If this attribute is set to a value less than 0, the default value is used. If this attribute is not set, the value **0vp** is used.<br>In Embed mode, when the component size is increased, only the content area is enlarged; when the component size is decreased, the content area is shrunk until its width reaches the value defined by **minContentWidth**, and then the sidebar is shrunk until its width reaches the value defined by **minSideBarWidth**; if the component size is further decreased, while respecting the minimum width of the sidebar, the content area is further shrunk, with the content clipped, until it is 0 vp large.<br>**minContentWidth**, whether it is specified or kept at the default value, takes precedence over **minSideBarWidth** and **sideBarWidth** of the sidebar. |
## ButtonStyle
......@@ -83,7 +83,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
> The settings of the [universal size attributes](ts-universal-attributes-size.md) **width** and **height** do not take effect for the sidebar child component.
> The settings do not take effect for the sidebar content area either. By default, the sidebar content area takes up the remaining space of the sidebar container.
>
> If the attribute method is not used, the sidebar is displayed depending on the size.
> If the **showSideBar** attribute is not set, the sidebar's visibility is subject to its size.
>
> - If the size is less than 520 vp, the sidebar is not displayed by default.
> - If the size is greater than or equal to 520 vp, the sidebar is displayed by default.
......@@ -127,8 +127,6 @@ struct SideBarContainerExample {
}.width('100%')
.justifyContent(FlexAlign.SpaceEvenly)
.backgroundColor('#19000000')
Column() {
Text('SideBarContainer content text1').fontSize(25)
Text('SideBarContainer content text2').fontSize(25)
......@@ -148,6 +146,7 @@ struct SideBarContainerExample {
.onChange((value: boolean) => {
console.info('status:' + value)
})
.divider({strokeWidth: '1vp', color: Color.Gray, startMargin: '4vp', endMargin: '4vp'})
}
}
```
......
......@@ -22,7 +22,7 @@ Defines and shows the action sheet.
| ---------- | -------------------------- | ------- | ----------------------------- |
| title | [Resource](ts-types.md#resource) \| string | Yes | Title of the dialog box.|
| message | [Resource](ts-types.md#resource) \| string | Yes | Content of the dialog box. |
| autoCancel | boolean | No | Whether to close the dialog box when the overlay is clicked.<br>Default value: **true**|
| autoCancel | boolean | No | Whether to close the dialog box when the overlay is clicked.<br>Default value: **true**<br>The value **true** means to close the dialog box when the overlay is clicked, and **false** means the opposite.|
| confirm | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>action: () =&gt; void<br>} | No | Text content of the confirm button and callback upon button clicking.<br>Default value:<br>**value**: button text.<br>**action**: callback upon button clicking.|
| cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay is clicked. |
| alignment | [DialogAlignment](ts-methods-alert-dialog-box.md#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Bottom**|
......
......@@ -25,8 +25,8 @@ You can set the text content and response callback for an alert dialog box.
| confirm | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>fontColor?: [ResourceColor](ts-types.md#resourcecolor),<br>backgroundColor?: [ResourceColor](ts-types.md#resourcecolor),<br>action: () =&gt; void<br>} | No | Text content, text color, background color, and click callback of the confirm button.|
| cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay is clicked.|
| alignment | [DialogAlignment](#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Default**|
| offset | [Offset](ts-types.md#offset) | No | Offset of the dialog box relative to the alignment position.|
| gridCount | number | No | Number of grid columns occupied by the width of the dialog box.|
| offset | [Offset](ts-types.md#offset) | No | Offset of the dialog box relative to the alignment position.<br>Default value: **{ dx: 0 , dy: 0 }**|
| gridCount | number | No | Number of grid columns occupied by the width of the dialog box.<br>Default value: **4**|
## AlertDialogParamWithButtons
| Name | Type | Mandatory | Description |
......@@ -35,7 +35,7 @@ You can set the text content and response callback for an alert dialog box.
| message | [ResourceStr](ts-types.md#resourcestr) | Yes | Content of the dialog box. |
| autoCancel | boolean | No | Whether to close the dialog box when the overlay is clicked.<br>Default value: **true** |
| primaryButton | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>fontColor?: [ResourceColor](ts-types.md#resourcecolor),<br>backgroundColor?: [ResourceColor](ts-types.md#resourcecolor),<br>action: () =&gt; void;<br>} | No| Text content, text color, background color, and click callback of the primary button.|
| secondaryButton | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>fontColor?: [ResourceColor](ts-types.md#resourcecolor),<br>backgroundColor?: [ResourceColor](ts-types.md#resourcecolor),<br>action: () =&gt; void;<br>} | No | Text content, text color, background color, and click callback of the primary button.|
| secondaryButton | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>fontColor?: [ResourceColor](ts-types.md#resourcecolor),<br>backgroundColor?: [ResourceColor](ts-types.md#resourcecolor),<br>action: () =&gt; void;<br>} | No | Text content, text color, background color, and click callback of the secondary button.|
| cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay is clicked. |
| alignment | [DialogAlignment](#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Default**|
| offset | [Offset](ts-types.md#offset) | No | Offset of the dialog box relative to the alignment position.|
......
......@@ -11,9 +11,9 @@ You can set accessibility attributes and events for components.
| Name| Type| Description|
| -------- | -------- | -------- |
| accessibilityGroup | boolean | Accessibility group. If this attribute is set to **true**, the component and all its child components form an entire selectable component, and the accessibility service will no longer be available for the content of its child components.<br>Default value: **false**|
| accessibilityText | string | Accessibility text. If a component does not contain text information, it will not be read when the component is selected by the screen reader. In this case, the screen reader user cannot know which component is selected. To solve this problem, you can set this attribute for components without text information. When the component is selected by the screen reader, the specified accessibility text will be read, informing the user which component is selected.<br>**NOTE**<br>If a component with this attribute set contains text information, only the accessibility text will be read.<br>If a component with its **accessibilityGroup** attribute set to **true** does not have **accessibilityText** set and does not contain text information, text concatenation will be performed on its child components (depth first).|
| accessibilityDescription | string | Accessibility description. You can specify further explanation of the current component, for example, possible operation consequences, especially those that cannot be learned from component attributes and accessibility text. You can set a detailed description text for the attribute of the component to help users understand the operation to be performed. If a component contains both text information and the accessibility description, the text is read first and then the accessibility description, when the component is selected.|
| accessibilityLevel | string | Accessibility importance, which is used to decide whether a component can be identified by the accessibility service.<br>The options are as follows:<br>**"auto"**: The value is converted to **"yes"** or **"no"** based on the component.<br>**"yes"**: The current component is selectable for the accessibility service.<br>**"no"**: The current component is not selectable for the accessibility service.<br>**"no-hide-descendants"**: The current component and all its child components are not selectable for the accessibility service.<br>**Default value**: **"auto"**<br>**NOTE**<br>When the **accessibilityLevel** attribute of the following components is set to **"auto"**, they are selectable for the accessibility service: Checkbox, CheckboxGroup, Gauge, Marquee, MenuItem, MenuItemGroup, Menu, Navigation, DatePicker, Progress, Radio, Rating, ScrollBar, Select, Slider, Stepper, Text, TextClock, TextPicker, TextTimer, TimePicker, Toggle, Web. |
| accessibilityText | string | Accessibility text. If a component does not contain text information, it will not be read when the component is selected by the screen reader. In this case, the screen reader user cannot know which component is selected. To solve this problem, you can set this attribute for components without text information. When the component is selected by the screen reader, the specified accessibility text will be read, informing the user which component is selected.<br>Default value: **""**<br>**NOTE**<br>If a component with this attribute set contains text information, only the accessibility text will be read.<br>If a component with its **accessibilityGroup** attribute set to **true** does not have **accessibilityText** set and does not contain text information, text concatenation will be performed on its child components (depth first).|
| accessibilityDescription | string | Accessibility description. You can specify further explanation of the current component, for example, possible operation consequences, especially those that cannot be learned from component attributes and accessibility text. If a component contains both text information and the accessibility description, the text is read first and then the accessibility description, when the component is selected.<br>Default value: **""**|
| accessibilityLevel | string | Accessibility importance, which is used to decide whether a component can be identified by the accessibility service.<br>The options are as follows:<br>**"auto"**: The value is converted to **"yes"** or **"no"** based on the component.<br>**"yes"**: The current component is selectable for the accessibility service.<br>**"no"**: The current component is not selectable for the accessibility service.<br>**"no-hide-descendants"**: The current component and all its child components are not selectable for the accessibility service.<br>**Default value**: **"auto"**<br>**NOTE**<br>When the **accessibilityLevel** attribute of the following components is set to **"auto"**, they are selectable for the accessibility service: Checkbox, CheckboxGroup, Gauge, Marquee, MenuItem, MenuItemGroup, Menu, Navigation, DatePicker, Progress, Radio, Rating, ScrollBar, Select, Slider, Stepper, Text, TextClock, TextPicker, TextTimer, TimePicker, Toggle, Web.|
## Example
......
......@@ -11,7 +11,7 @@ The visible area change event of a component refers to the change in the visual
| Name | Description |
| ---------------------------------------- | ---------------------------------------- |
| onVisibleAreaChange(ratios: Array\<number>, event: (isVisible: boolean, currentRatio: number) => void) | Called when the visual area of the component changes.<br>- **ratios**: threshold array. Each threshold represents a ratio of the component's visible area (that is, the area of the component that is visible on screen) to the component's total area. This callback is invoked when the ratio of the component's visible area to its total area is greater than or less than the threshold. The value range of the threshold is [0.0, 1.0]. If the threshold set exceeds this range, the value **0.0** or **1.0** will be used.<br>- **isVisible**: indicates whether the ratio of the component's visible area to its total area is greater than the threshold. The value **true** means that the ratio is greater than the threshold, and **false** means that the ratio is less than the threshold.<br>- **currentRatio**: ratio of the component's visible area to its total area when this callback is invoked.|
| onVisibleAreaChange(ratios: Array\<number>, event: (isVisible: boolean, currentRatio: number) => void) | Called when the visual area of the component changes.<br>- **ratios**: threshold array. Each threshold represents a ratio of the component's visible area (that is, the area of the component that is visible on screen) to the component's total area. This callback is invoked when the ratio of the component's visible area to its total area is greater than or less than the threshold. The value range of the threshold is [0.0, 1.0]. If the threshold set exceeds this range, the value **0.0** or **1.0** will be used.<br>- **isVisible**: whether the ratio of the component's visible area to its total area is greater than the threshold. The value **true** means that the ratio is greater than the threshold, and **false** means that the ratio is less than the threshold.<br>- **currentRatio**: ratio of the component's visible area to its total area when this callback is invoked.<br>**NOTE**<br>This API applies only to the scenario where the component layout area exceeds or is not within the current screen display area. It does not apply to the scenario where the area becomes invisible due to component stacking or the visible area exceeds the allowed range as a result of calling transformation APIs such as **offset** or **translate**.|
## Example
......@@ -98,7 +98,7 @@ struct ScrollExample {
.scrollable(ScrollDirection.Vertical)
.scrollBar(BarState.On)
.scrollBarColor(Color.Gray)
.scrollBarWidth(30)
.scrollBarWidth(10)
.onScroll((xOffset: number, yOffset: number) => {
console.info(xOffset + ' ' + yOffset)
})
......
......@@ -230,23 +230,23 @@ The related JS database API is not used.
2. If the JS database API is used, find out the failure cause, for example, check whether **databaseAccess** is enabled.
## 17100013 Memory Allocation Failure
## 17100013 Invalid Number of Sockets During Preconnection
**Error Message**
New failed, out of memeory.
The number of preconnect sockets is invalid.
**Description**
Memory allocation failed due to insufficient memory.
This error code is reported when the number of sockets to be preconnected is invalid.
**Possible Causes**
The data to send is too large.
The number of sockets is less than or equal to 0 or greater than 6.
**Solution**
Check the length of the data to be sent.
Make sure the specified number of sockets is greater than 0 and less than or equal to 6.
## 17100014 Type and Value Mismatch
......@@ -257,7 +257,7 @@ The type does not match with the value of the message.
**Description**
The type and value of the message do not match.
This error code is reported when the type and value of the message do not match.
**Possible Causes**
......@@ -266,3 +266,22 @@ The value of the obtained message does not match the type of the message.
**Solution**
Call the API based on the message type to obtain the message value. For example, if the type is **BOOLEAN**, call the **GetBoolean** API to obtain the Boolean value.
## 17100015 Memory Allocation Failure
**Error Message**
New failed, out of memeory.
**Description**
This error code is reported when memory allocation failed due to insufficient memory.
**Possible Causes**
The data to send is too large.
**Solution**
Check the length of the data to be sent.
......@@ -951,10 +951,15 @@ Device security level management
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | No | Yes | No | No |
## SystemCapability.Security.Huks
Hardware Unique Key (HUK) management
## SystemCapability.Security.Huks.Core
Device key management - core capabilities
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | Yes | Yes | Yes | No | Yes | No | No |
## SystemCapability.Security.Huks.Extension
Device key management - extended capabilities
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | No | Yes | No | No |
......
......@@ -1004,7 +1004,7 @@ Allows a system application to obtain Wi-Fi parameters.
## ohos.permission.SET_WIFI_INFO
Allows an application to set Wi-Fi devices.
Allows an application to set a Wi-Fi device.
**Permission level**: normal
......@@ -1280,7 +1280,7 @@ Allows a device administrator application to set the screen-off time.
## ohos.permission.ENTERPRISE_INSTALL_BUNDLE
Allows a device administrator application to install and uninstall bundles.
Allows a device administrator application to install and uninstall applications.
**Permission level**: system_core
......@@ -2508,7 +2508,7 @@ Allows an application to manage the upload sessions.
## ohos.permission.PREPARE_APP_TERMINATE
Allows an application to perform customized pre-termination actions before being terminated.
Allows an application to perform customized actions before being terminated.
**Permission level**: normal
......@@ -2590,18 +2590,6 @@ Allows an application to access OpenHarmony Security Detection and Response Fram
**Start version**: 10
## ohos.permission.SUPPORT_USER_AUTH
Allows an application to interact with the user authentication framework and register ExtensionAbilities.
**Permission level**: system_basic
**Authorization mode**: system_grant
**Enable ACL**: FALSE
**Start version**: 10
## ohos.permission.ACCESS_BUNDLE_DIR
Allows an application to access the installation directory of another application.
......
......@@ -89,7 +89,7 @@ The following example registers the **test()** function with the frontend page.
> **NOTE**
>
> If you use [registerJavaScriptProxy()](../reference/apis/js-apis-webview.md#registerjavascriptproxy) to register a function, call **[refresh()]**(../reference/apis/js-apis-webview.md#refresh) for the function to take effect.
> If you use [registerJavaScriptProxy()](../reference/apis/js-apis-webview.md#registerjavascriptproxy) to register a function, call [refresh()](../reference/apis/js-apis-webview.md#refresh) for the function to take effect.
- Sample code for invoking application functions on the **index.html** frontend page:
......@@ -103,7 +103,7 @@ The following example registers the **test()** function with the frontend page.
<p id="demo"></p>
<script>
function callArkTS() {
let str = testObjName.test();
let str = objName.test();
document.getElementById("demo").innerHTML = str;
console.info('ArkTS Hello World! :' + str);
}
......
......@@ -22,8 +22,8 @@ New IP provides at least 1% higher payload transmission efficiency than IPv4 and
| Scenario | Header Overhead (Bytes) | Payload Transmission Efficiency<br>(Wi-Fi MTU = 1500 Bytes, BT MTU = 255 Bytes)|
| --------------- | ------------ | ------------------------------------------- |
| IPv4 for Wi-Fi | 30 + 8 + 20 = 58 | (1500 - 58)/1500 = 96.13% |
| IPv6 for Wi-Fi | 30 + 8 + 40 = 78 | (1500 - 78)/1500 = 94.8% |
| IPv4 for Wi-Fi | 30 + 8 + 20 = 58 | (1500 - 58)/1500 = 96.13% |
| IPv6 for Wi-Fi | 30 + 8 + 40 = 78 | (1500 - 78)/1500 = 94.8% |
| New IP for Wi-Fi | 30 + 8 + 5 = 43 | (1500 - 43)/1500 = 97.13% |
## Variable-Length Header Format
......@@ -97,7 +97,7 @@ Only the Linux 5.10 kernel of the RK3568 development board supports the New IP k
# kernel/linux/config/linux-5.10/arch/arm64/configs/rk3568_standard_defconfig
CONFIG_NEWIP=y // Enable the New IP kernel protocol stack.
CONFIG_NEWIP_HOOKS=y // Enable New IP stub functions to be dynamically registered non-disruptively. This feature must be enabled when New IP is enabled.
VENDOR_HOOKS=y // Enable the basic kernel instrumentation framework. New IP depends on this setting. It is enabled by default for the RK3568 development board.
HCK_VENDOR_HOOKS=y // Enable the basic kernel instrumentation framework. New IP depends on this framework. It is enabled by default on the RK3568 development board.
```
Run the following command to check whether the New IP protocol stack is successfully enabled:
......@@ -119,8 +119,18 @@ out/kernel/OBJ/linux-5.10/net/newip/tcp_nip_output.o
```c
/* Register the New IP ehash function with the kernel. */
register_trace_ninet_ehashfn_hook(&ninet_ehashfn_hook, NULL);
/* Call the newip hook function in sk_ehashfn function (net\ipv4\inet_hashtables.c):
*/
void nip_ninet_ehashfn(const struct sock *sk, u32 *ret)
{
*ret = ninet_ehashfn(sock_net(sk), &sk->SK_NIP_RCV_SADDR,
sk->sk_num, &sk->SK_NIP_DADDR, sk->sk_dport);
}
void nip_ninet_ehashfn_lhck_register(void)
{
REGISTER_HCK_LITE_HOOK(nip_ninet_ehashfn_lhck, nip_ninet_ehashfn);
}
/* Add the New IP stack processing to the general entry function of IPv4/IPv6 stacks. */
static u32 sk_ehashfn(const struct sock *sk)
......@@ -134,14 +144,12 @@ static u32 sk_ehashfn(const struct sock *sk)
&sk->sk_v6_daddr, sk->sk_dport);
#endif
if (trace_vendor_ninet_ehashfn_enabled()) {
if (sk->sk_family == AF_NINET) {
u32 ret = 0;
if (sk->sk_family == AF_NINET) {
u32 ret = 0;
/* Register the New IP ehash function. */
trace_vendor_ninet_ehashfn(sk, &ret);
return ret;
}
CALL_HCK_LITE_HOOK(nip_ninet_ehashfn_lhck, sk, &ret);
return ret;
}
/* IPv4 */
return inet_ehashfn(sock_net(sk),
......@@ -166,8 +174,8 @@ The user-mode application calls **socket()** to create a New IP socket and uses
| API | Input | Output | Return Value | Description |
| -------- | ------------------------------------------------------------ | ---------------------------------------------- | ---------------- | ------------------------------------------------------------ |
| socket | int **domain**, int type, int **protocol** | NA | Socket handle **sockfd**.| Creates a New IP socket. <br>**domain** must be **AF_NINET**, which indicates a New IP socket.<br>**protocol** can be **IPPROTO_TCP** or **IPPROTO_UDP**.<br>This API returns the handle of the **socket** instance created.|
| bind | int sockfd, const **struct sockaddr_nin** *myaddr, socklen_t addrlen | NA | Error code, which is an integer. | Binds the **socket** instance to the specified IP address and port.<br> **myaddr->sin_family** must be **AF_NINET**.|
| socket | int **domain**, int type, int **protocol** | NA | Socket handle **sockfd**.| Creates a New IP socket. <br>**domain** must be **AF_NINET**, which indicates a New IP socket.<br>**protocol** can be **IPPROTO_TCP** or **IPPROTO_UDP**.<br>This API returns the handle of the **socket** instance created. |
| bind | int sockfd, const **struct sockaddr_nin** *myaddr, socklen_t addrlen | NA | Error code, which is an integer. | Binds the **socket** instance to the specified IP address and port.<br>**myaddr->sin_family** must be **AF_NINET**. |
| listen | int socket, int backlog | NA | Error code, which is an integer. | Listens for the New IP address and port from the server. |
| connect | int sockfd, const **struct sockaddr_nin** *addr, aocklen_t addrlen | NA | Error code, which is an integer. | Sets up a connection between the client and the server. |
| accept | int sockfd, **struct sockaddr_nin** *address, socklen_t *address_len | NA | **sockfd**. | Accepts the connection request from the client. |
......
......@@ -2,11 +2,11 @@
## cl.arkui.1 Change in the \<Button> Component Hover Effect
The hover effect of the **\<Button>** component is changed from scale-up by 100% to 105% to overlay of 0% to 5% opacity. The pressed effect of the component is changed to overlay of 5% to 10% opacity.
Changed the hover effect of the **\<Button>** component from scale-up by 100% to 105% to overlay of 0% to 5% opacity, and the pressed effect to overlay of 5% to 10% opacity.
**Change Impact**
The visual effect of the **\<Button>** is affected.
The visual effect of the **\<Button>** component is affected.
## cl.arkui.2 Change in the Multi-line Text Alignment Mode of Toasts
......@@ -15,3 +15,13 @@ Changed the alignment mode of multi-line text in toasts from center-aligned to l
**Change Impact**
The visual effect of toasts is affected.
## cl.arkui.3 Change in \<SideBarContainer> Component Attributes and Display Modes
1. Added the **minContentWidth** attribute, whose default value is **360vp**. If this attribute is not set, the value **0vp** is used. If this attribute is set to a value less than 0, the default value is used. In Embed mode, when the component size is increased, only the content area is enlarged; when the component size is decreased, the content area is shrunk until its width reaches the value defined by **minContentWidth**, and then the sidebar is shrunk until its width reaches the value defined by **minSideBarWidth**; if the component size is further decreased, while respecting the minimum width of the sidebar, the content area is further shrunk, with the content clipped, until it is 0 vp large. **minContentWidth**, whether it is specified or kept at the default value, takes precedence over **minSideBarWidth** and **sideBarWidth** of the sidebar.
2. Changed the default value of **minSideBarWidth** and **SideBarWidth** to **200vp** in API version 9 and earlier versions, and **240vp** in API version 10.
3. Added the Auto display mode. The sidebar is displayed in Embed mode when the component size is greater than or equal to the sum of **minSideBarWidth** and **minContentWidth** and in Overlay mode otherwise. If **minSideBarWidth** or **minContentWidth** is not set, the default value will be used for calculation. If the calculation result is less than 600 vp, 600 vp will be used as the breakpoint value for mode switching.
**Change Impact**
The default visual effect of the **\<SideBarContainer>** component is affected in API version 10.
......@@ -97,3 +97,117 @@ N/A
When building a child component, do not assign values to the variables by **@LocalStorageLink** and **@LocalStorageProp** in the child component.
To change these variables from the parent component, use the API provided by the **LocalStorage** (such as the **set** API) to assign values to them.
## cl.arkui.3 Change of the bottom Definition in Toast Options in the PromptAction Module
Changed the definition of the **bottom** attribute in toast options from distance between the top of the toast and the bottom of the screen to distance between the bottom of the toast and the bottom of the screen.
**Example**
```ts
import promptAction from '@ohos.promptAction';
@Entry
@Component
struct Index {
build() {
Row() {
Button()
.onClick(() => {
try {
promptAction.showToast({
message: 'Message Info',
duration: 2000
});
} catch (error) {
console.error(`showToast args error code is ${error.code}, message is ${error.message}`);
};
})
}
}
}
```
**Change Impacts**
In the **PromptAction** module, the same value for the **bottom** attribute may result in different toast appearances, depending on whether the API version used by the compiler is earlier than 10 or not.
**Key API/Component Changes**
N/A
**Adaptation Guide**
When setting the **bottom** attribute, account for the definition change.
## cl.arkui.4 Content Layout Change of AlertDialog
The content layout of the alert dialog box varies according to the following conditions: 1. whether there is a title. 2. whether the text is on a single line.
Currently, only the single-line text without a title is centered. In other cases, the text is left-aligned.
**Example**
```ts
// xxx.ets
@Entry
@Component
struct AlertDialogExample {
build() {
Column({ space: 5 }) {
Button('one button dialog')
.onClick(() => {
AlertDialog.show(
{
title: 'title',
message: 'text'.repeat(20),
autoCancel: true,
alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: -20 },
gridCount: 3,
confirm: {
value: 'button',
action: () => {
console.info('Button-clicking callback')
}
},
cancel: () => {
console.info('Closed callbacks')
}
}
)
})
.backgroundColor(0x317aff)
}.width('100%').margin({ top: 5 })
}
}
```
**Change Impacts**
The layout for the text specified by the **message** attribute of the alert dialog box is subject to the title and number of lines of the text.
**Key API/Component Changes**
N/A
**Adaptation Guide**
No proactive adaptation is required. You can also use **customDialog** for related implementation.
## cl.arkui.5 Avoidance Behavior Optimization of Popup
Before the change, the popup preferentially uses the lower area for avoidance. As a result, it cannot be displayed in the upper area even if the space is sufficient.
After the change: The popup preferentially uses the upper area for avoidance when it is configured to show above the target component; it preferentially uses the upper or lower area for avoidance when it is configured to show below the target component.
**Change Impacts**
The optimized popup avoidance behavior occurs when the **bindpopup** attribute is used.
**Key API/Component Changes**
N/A
**Adaptation Guide**
If the popup position is not as expected, you can adjust the **placement** settings.
......@@ -442,3 +442,9 @@ export default class MySequenceable {
private str;
}
```
## 相关实例
针对IDL的使用,有以下相关实例可供参考:
- [Ability与ServiceExtensionAbility通信(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/IDL/AbilityConnectServiceExtension)
\ No newline at end of file
......@@ -138,5 +138,5 @@ onAccessibilityEvent(accessibilityEvent) {
针对AccessibilityExtensionAbility开发,有以下相关实例可供参考:
[AccessibilityExtAbility的创建和使用(ArkTS)(API 9)(Full SDK](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SystemFeature/ApplicationModels/AccessibilityExtAbility)
- [无障碍扩展(ArkTS)(Full SDK)(API9](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SystemFeature/ApplicationModels/AccessibilityExtAbility)
......@@ -60,3 +60,11 @@ ArkTS卡片相较于JS卡片具备了更加丰富的能力,但也增加了使
- 暂不支持Hot Reload热重载。
- 暂不支持setTimeOut。
## 相关实例
针对ArkTS卡片开发,有以下相关实例可供参考:
- [Stage模型卡片(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/Widget/FormExtAbility)
- [Stage模型卡片JS与C++通信(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/Widget/FormGame)
\ No newline at end of file
......@@ -118,5 +118,4 @@
针对StaticSubscriberExtensionAbility开发,可参考如下实例:
- [StaticSubscriber:静态订阅(ArkTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SystemFeature/ApplicationModels/StaticSubscriber)
- [静态订阅(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SystemFeature/ApplicationModels/StaticSubscriber)
......@@ -26,7 +26,7 @@
- 若目标组件exported字段配置为false,则需校验`ohos.permission.START_INVISIBLE_ABILITY`权限
- [组件exported配置参考](../quick-start/module-configuration-file.md#abilities标签)
- **位于后台的应用,启动组件需校验BACKGROUND权限**
- **位于后台的UIAbility应用,启动组件需校验BACKGROUND权限**
- 应用前后台判断标准:若应用进程获焦或所属的UIAbility位于前台则判定为前台应用,否则为后台应用
- 需校验`ohos.permission.START_ABILITIES_FROM_BACKGROUND`权限
......@@ -46,7 +46,9 @@
设备内启动组件,不同场景下的规则不同,可分为如下两种场景:
- 启动或连接组件:UIAbility、ServiceExtensionAbility、DataShareExtensionAbility。
- 启动UIAbility。
- 启动ServiceExtensionAbility、DataShareExtensionAbility。
- 通过startAbilityByCall接口启动UIAbility。
......@@ -57,7 +59,9 @@
跨设备启动组件,不同场景下的规则不同,可分为如下两种场景:
- 启动或连接组件:UIAbility、ServiceExtensionAbility、DataShareExtensionAbility。
- 启动UIAbility。
- 启动ServiceExtensionAbility、DataShareExtensionAbility。
- 通过startAbilityByCall接口启动UIAbility。
......
......@@ -109,5 +109,4 @@ export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbil
针对EnterpriseAdminExtensionAbility开发,有以下相关示例可供参考:
[EnterpriseAdminExtensionAbility:EnterpriseAdminExtensionAbility的创建与使用(ArkTS) (API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SystemFeature/ApplicationModels/EnterpriseAdminExtensionAbility)
- [企业设备管理扩展(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SystemFeature/ApplicationModels/EnterpriseAdminExtensionAbility)
\ No newline at end of file
......@@ -616,6 +616,8 @@ onUpdateForm(formId) {
针对卡片开发,有以下相关实例可供参考:
- [JS多设备自适应服务卡片(JS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/Widget/AdaptiveServiceWidget)
- [电影卡片(JS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/Card/MovieCard)
- [计步器卡片(JS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/Card/StepsCardJS)
\ No newline at end of file
......@@ -126,4 +126,8 @@
})
```
## 相关实例
针对任务管理开发,有以下相关实例可供参考:
- [任务管理(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SystemFeature/ApplicationModels/MissionManager)
\ No newline at end of file
......@@ -60,11 +60,12 @@ ArkTS卡片与JS卡片具备不同的实现原理及特征,在场景能力上
针对Stage模型卡片提供方的开发,有以下相关实例可供参考:
- [ArkTS音乐卡片(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/Widget/ArkTSCard/MusicControl)
- [基于Stage模型的JS卡片(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/Widget/FormExtAbility)
- [Stage模型卡片(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/Widget/FormExtAbility)
- [基于Stage模型的JS卡片(成语接龙小游戏)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/Widget/FormGame)
- [Stage模型卡片JS与C++通信(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/Widget/FormGame)
- [基于Stage模型的ArkTS卡片(Canvas绘制实现的五子棋游戏卡片)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/Widget/ArkTSCard/CanvasGame)
- [ArkTS卡片Canvas小游戏(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/Widget/ArkTSCard/CanvasGame)
- [基于Stage模型的ArkTS卡片(逻辑代码执行实现的计算器卡片)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/Widget/ArkTSCard/Calculator)
- [ArkTS卡片计算器(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/Widget/ArkTSCard/Calculator)
......@@ -453,5 +453,8 @@ ServiceExtensionAbility服务组件在[onConnect()](../reference/apis/js-apis-ap
针对ServiceExtensionAbility开发,有以下相关实例可供参考:
- [`AbilityConnectServiceExtension`:Ability与ServiceExtensionAbility通信(ArkTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/IDL/AbilityConnectServiceExtension)
- [`StageModel`:Stage模型(ArkTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/ApplicationModels/StageModel)
- [跨任务链返回(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack)
- [Ability与ServiceExtensionAbility通信(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/IDL/AbilityConnectServiceExtension)
- [Stage模型(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/ApplicationModels/StageModel)
......@@ -41,3 +41,9 @@
| 了解线程模型 | 本章节介绍了Stage模型的线程模型以及几种常用的线程间通信方式。 | -&nbsp;[Emitter](itc-with-emitter.md)<br/>-&nbsp;[Worker](itc-with-worker.md) |
| 任务管理 | 本章节介绍了Stage模型中任务管理的基本概念和典型场景。 | -&nbsp;[任务管理场景介绍](mission-management-overview.md)<br/>-&nbsp;[任务管理与启动模式](mission-management-launch-type.md)<br/>-&nbsp;[页面栈和任务链](page-mission-stack.md) |
| 应用配置文件 | 本章节介绍Stage模型中应用配置文件的开发要求。 | [Stage模型应用配置文件](config-file-stage.md) |
## 相关实例
针对Stage模型开发,有以下相关实例可供参考:
- [Stage模型(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/ApplicationModels/StageModel)
\ No newline at end of file
......@@ -151,3 +151,9 @@ specified启动模式为指定实例模式,针对一些特殊场景使用(
2. 在最近任务列表中关闭`文件A`的任务进程,此时`UIAbility实例1`被销毁,回到桌面,再次打开`文件A`,此时对应启动一个新的UIAbility实例,例如启动`UIAbility实例2`
3. 回到桌面,打开`文件B`,此时对应启动一个新的UIAbility实例,例如启动`UIAbility实例3`
4. 回到桌面,再次打开`文件A`,此时仍然启动之前的`UIAbility实例2`,因为系统会自动匹配UIAbility实例的Key值,如果存在与之匹配的Key,则会启动与之绑定的UIAbility实例。在此例中,之前启动的`UIAbility实例2``文件A`绑定的Key是相同的,因此系统会拉回`UIAbility实例2`并让其获焦,而不会创建新的实例。
## 相关实例
针对UIAbility组件启动模式,有以下相关实例可供参考:
- [Ability的启动模式(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/ApplicationModels/AbilityStartMode)
\ No newline at end of file
......@@ -48,6 +48,6 @@
> - 匹配到一个满足条件的应用组件:直接启动该应用组件。
> - 匹配到多个满足条件的应用组件(UIAbility):弹出选择框让用户选择。
>
> - 调用方传入的want参数中不带有abilityName和bundleName,则不允许通过隐式Want启动所有应用的ServiceExtensionAbility。
>
> - 调用方传入的want参数中带有bundleName,则允许使用startServiceExtensionAbility()方法隐式Want启动ServiceExtensionAbility,默认返回优先级最高的ServiceExtensionAbility,如果优先级相同,返回第一个。
> - 对于启动ServiceExtensionAbility的场景:
> - 调用方传入的want参数中带有abilityName,则不允许通过隐式Want启动ServiceExtensionAbility。
> - 调用方传入的want参数中带有bundleName,则允许使用startServiceExtensionAbility()方法隐式Want启动ServiceExtensionAbility,默认返回优先级最高的ServiceExtensionAbility,如果优先级相同,返回第一个。
......@@ -116,4 +116,4 @@ struct Index {
针对WindowExtensionAbility开发,有以下相关实例可供参考:
- [`WindowExtAbility`:WindowExtAbility的创建与使用(ArkTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SystemFeature/WindowManagement/WindowExtAbility)
- [窗口扩展应用(ArkTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SystemFeature/WindowManagement/WindowExtAbility)
......@@ -36,4 +36,4 @@ ArkTS语言基础类库是OpenHarmony系统上为应用开发者提供的常用
针对语言基础类库的开发,有以下相关实例可供参考:
- [LanguageBaseClassLibrary:语言基础类库](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary)
- [语言基础类库(ArkTS)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary)
......@@ -57,4 +57,4 @@ ArkTS提供了TaskPool和Worker两种并发能力供开发者选择,其具体
针对多线程开发,有以下相关实例可供参考:
- [ConcurrentModule:多线程任务](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/LaunguageBaseClassLibrary/ConcurrentModule)
- [多线程任务(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/LaunguageBaseClassLibrary/ConcurrentModule)
......@@ -52,7 +52,8 @@ httpRequest.on('headersReceive', (header) => {
console.info('header: ' + JSON.stringify(header));
});
httpRequest.request(
// 填写HTTP请求的URL地址,可以带参数也可以不带参数。URL地址需要开发者自定义。请求的参数可以在extraData中指定"EXAMPLE_URL",
// 填写HTTP请求的URL地址,可以带参数也可以不带参数。URL地址需要开发者自定义。请求的参数可以在extraData中指定
"EXAMPLE_URL",
{
method: http.RequestMethod.POST, // 可选,默认为http.RequestMethod.GET
// 开发者根据自身业务需要添加header字段
......@@ -81,7 +82,7 @@ httpRequest.request(
// 当该请求使用完毕时,调用destroy方法主动销毁
httpRequest.destroy();
} else {
console.info('error:' + JSON.stringify(err));
console.error('error:' + JSON.stringify(err));
// 取消订阅HTTP响应头事件
httpRequest.off('headersReceive');
// 当该请求使用完毕时,调用destroy方法主动销毁
......@@ -146,7 +147,7 @@ httpRequest.request2(
readTimeout: 60000, // 可选,默认为60000ms。若传输的数据较大,需要较长的时间,建议增大该参数以保证数据传输正常终止
usingProtocol: http.HttpProtocol.HTTP1_1, // 可选,协议类型默认值由系统自动指定
}, (err, data) => {
console.info('error:' + JSON.stringify(err));
console.error('error:' + JSON.stringify(err));
console.info('ResponseCode :' + JSON.stringify(data));
// 取消订阅HTTP响应头事件
httpRequest.off('headersReceive');
......@@ -166,5 +167,8 @@ httpRequest.request2(
针对HTTP数据请求,有以下相关实例可供参考:
- [`Http:`数据请求(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Connectivity/Http)
- [上传和下载(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SystemFeature/Connectivity/Upload)
- [Http(ArkTS)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Connectivity/Http)
- [新闻数据加载(ArkTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/NewsDataArkTS)
\ No newline at end of file
......@@ -355,3 +355,8 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
globalThis.context.disconnectServiceExtensionAbility(connectId);
```
## 相关实例
针对IPC与RPC通信开发,有以下相关实例可供参考:
- [RPC通信(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Connectivity/RPC)
......@@ -409,4 +409,4 @@ tlsTwoWay.close((err) => {
针对Socket连接开发,有以下相关实例可供参考:
- [`Socket`:Socket 连接(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Connectivity/Socket)
\ No newline at end of file
- [网络管理-Socket连接(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Connectivity/Socket)
\ No newline at end of file
......@@ -85,4 +85,4 @@ ws.connect(defaultIpAddress, (err, value) => {
针对WebSocket连接的开发,有以下相关实例可供参考:
- [`WebSocket`:WebSocket(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Connectivity/WebSocket)
\ No newline at end of file
- [WebSocket(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Connectivity/WebSocket)
\ No newline at end of file
......@@ -226,7 +226,11 @@
针对用户首选项开发,有以下相关实例可供参考:
- [`Preferences`:首选项(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/DataManagement/Preferences)
- [游戏2048(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/Solutions/Game/Game2048)
- [图案密码锁(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/Solutions/Tools/PatternLock)
- [首选项(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/DataManagement/Preferences)
- [首选项(ArkTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/Data/Preferences)
......
......@@ -304,4 +304,12 @@
localObject.setSessionId(() => {
console.info('leave all lession.');
});
```
\ No newline at end of file
```
## 相关实例
针对分布式数据对象开发,有以下相关实例可供参考:
- [分布式组网认证(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/DistributedAppDev/DistributedAuthentication)
- [分布式对象(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/DistributedAppDev/DistributedNote)
\ No newline at end of file
......@@ -281,4 +281,18 @@
针对键值型数据库开发,有以下相关实例可供参考:
- [分布式组网认证(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/DistributedAppDev/DistributedAuthentication)
- [分布式数据管理(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/DistributedAppDev/Kvstore)
- [分布式音乐播放(JS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/DistributedAppDev/JsDistributedMusicPlayer)
- [分布式音乐播放(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/DistributedAppDev/ArkTSDistributedMusicPlayer)
- [分布式计算器(JS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/DistributedAppDev/DistributeCalc)
- [分布式计算器(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/DistributedAppDev/ArkTSDistributedCalc)
- [分布式五子棋(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/Solutions/Game/DistributedDataGobang)
- [分布式手写板(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/DistributeDraw)
\ No newline at end of file
......@@ -171,3 +171,13 @@
)
})
```
## 相关实例
针对关系型数据库开发,有以下相关实例可供参考:
- [分布式组网认证(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/DistributedAppDev/DistributedAuthentication)
-[分布式关系型数据库(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/DistributedAppDev/DistributedRdb)
- [分布式帐号(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/DistributedAppDev/DistributedAccount)
\ No newline at end of file
......@@ -243,4 +243,4 @@
针对数据共享开发,有以下相关实例可供参考:
- [`CrossAppDataShare`:系统应用跨应用数据共享(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SystemFeature/DataManagement/CrossAppDataShare)
\ No newline at end of file
- [系统应用跨应用数据共享(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SystemFeature/DataManagement/CrossAppDataShare)
\ No newline at end of file
......@@ -37,3 +37,9 @@
## 跨设备同步访问控制机制
数据跨设备同步时,数据管理基于设备等级和数据安全标签进行访问控制,具体可见[跨设备同步访问控制机制](access-control-by-device-and-data-level.md#跨设备同步访问控制机制)
## 相关实例
针对分布式开发,有以下相关实例可供参考:
- [分布式组网认证(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/DistributedAppDev/DistributedAuthentication)
\ No newline at end of file
......@@ -538,5 +538,6 @@ import usageStatistics from '@ohos.resourceschedule.usageStatistics';
针对设备使用信息统计,有以下相关实例可供参考:
- [`DeviceUsageStatistics`:设备使用信息统计(ArkTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics)
- [存储空间统计(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SystemFeature/DeviceManagement/StorageStatistic)
- [设备使用信息统计(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics)
......@@ -406,4 +406,10 @@
});
```
5. 当设备进入或者退出该围栏时,系统会自动触发WantAgent的动作。
\ No newline at end of file
5. 当设备进入或者退出该围栏时,系统会自动触发WantAgent的动作。
## 相关实例
针对位置开发,有以下相关实例可供参考:
- [位置服务(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/DeviceManagement/Location)
\ No newline at end of file
......@@ -270,5 +270,6 @@ async function playCustomHaptic(fileName) {
针对振动开发,有以下相关实例可供参考:
- [`Vibrator`:振动(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/DeviceManagement/Vibrator/BasicVibration)
- [`CustomHaptic`:自定义振动(ArkTS)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic)
- [振动(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/DeviceManagement/Vibrator/BasicVibration)
- [自定义振动(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic)
......@@ -193,3 +193,9 @@ APP_LIFECYCLE_TIMEOUT:
![appfreeze_20230310105874](figures/appfreeze_20230310105874.png)
其他的日志信息可以参考[通用日志信息](#日志主干通用信息)进行分析。需要特别说明的是,一般情况下生命周期切换大概率主线程也会卡死。可以结合两个日志的三个堆栈、两个BinderCatcher信息,进行对比查看。
## 相关实例
针对故障日志获取,有以下相关实力可供参考:
- [故障日志获取(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/DFX/FaultLogger)
\ No newline at end of file
......@@ -103,3 +103,9 @@ Thread name:crasher <- 异常线程名
范例中的崩溃故障是由赋值给一块不可写的区域导致的,代码行为dfx_crasher.c文件的57行,修改后可以避免发生此崩溃。\
另外,使用addr2line后,如果得出的行号看起来不是很正确,可以考虑对地址进行微调(如减1),或者考虑关闭一些编译优化,已知使用LTO的二进制可能无法正确获得行号。
## 相关实例
针对故障日志获取,有以下相关实力可供参考:
- [故障日志获取(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/DFX/FaultLogger)
\ No newline at end of file
......@@ -151,4 +151,6 @@ HiAppEvent是在系统层面为应用开发者提供的一种事件打点机制
针对应用事件开发,有以下相关实例可供参考:
- [`DotTest`:测试打点(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/DFX/DotTest)
\ No newline at end of file
- [测试打点(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/DFX/DotTest)
- [日志打印(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/DFX/Logger)
\ No newline at end of file
......@@ -21,42 +21,6 @@ try {
}
```
## 如何隐藏状态栏实现沉浸式效果
适用于:OpenHarmony 3.2 Beta5,API 9
**解决措施**
1. 可以在onWindowStageCreate方法获取windowClass对象。
```
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate")
windowStage.getMainWindow((err, data) => {
if (err.code) {
console.error('Failed to obtain the main window.')
return;
}
// 获取到窗口对象
globalThis.windowClass = data;
})
}
```
2. 设置窗口全屏,隐藏状态栏。
```
globalThis.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));
});
```
## 如何获取窗口的宽高信息
适用于:OpenHarmony 3.2 Beta5,API 9 Stage模型
......
......@@ -78,3 +78,9 @@ BackupExtensionAbility,是[Stage模型](../../application-dev/application-mode
]
}
```
## 相关实例
针对应用接入数据的备份与恢复,有以下相关实例可供参考:
- [应用接入数据备份恢复(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/FileManagement/FileBackupExtension)
\ No newline at end of file
......@@ -23,3 +23,9 @@
**图1** 文件分类模型示意图
![File classification model](figures/file-classification-model.png)
## 相关实例
针对文件管理开发,有以下相关实例可供参考:
- [文件管理(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/FileManagement/FileManager)
\ No newline at end of file
......@@ -731,4 +731,12 @@ try {
```js
let order = I18n.I18NUtil.getDateOrder("zh-CN"); // order = "y-L-d",表示中文中年月日的顺序为年-月-日。
```
\ No newline at end of file
```
## 相关实例
针对I18n开发,有以下相关实例可供参考:
- [时区和语言设置(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SystemFeature/Internationalnation/International)
- [国际化(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/International/International)
\ No newline at end of file
......@@ -272,7 +272,7 @@ export default struct Home {
针对应用市场应用开发,有以下相关实例可以参考:
应用市场开发:[一多应用市场首页应用示例](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/MultiDeviceAppDev/AppMarket)
- [典型页面场景:应用市场首页(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/MultiDeviceAppDev/AppMarket)
......
......@@ -247,5 +247,5 @@ struct Index {
针对音乐专辑应用,有以下相关实例可供参考:
音乐专辑应用:[音乐专辑页应用示例](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/MultiDeviceAppDev/MusicAlbum)
- [典型页面场景:音乐专辑页(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/MultiDeviceAppDev/MusicAlbum)
......@@ -168,4 +168,4 @@ Navigation组件支持自动切换单栏和双栏的显示效果,同时可以
针对“设置”应用页面,有以下相关实例可以参考:
设置:[设置应用示例](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/MultiDeviceAppDev/Settings)
- [典型页面场景:设置应用页面(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SuperFeature/MultiDeviceAppDev/Settings)
......@@ -257,3 +257,9 @@ export default class VoiceCallDemoForAudioCapturer {
}
}
```
## 相关实例
针对音频通话开发,有以下相关实例可供参考:
- [音频通话示例(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Media/VoiceCallDemo)
\ No newline at end of file
......@@ -63,3 +63,11 @@ audio模块下的接口支持PCM编码,包括AudioRenderer、AudioCapturer、T
小尾数指的是小端模式,即数据的高字节保存在内存的高地址中,而数据的低字节保存在内存的低地址中。这种存储模式将地址的高低和数据的位权有效结合起来,高地址部分权值高,低地址部分权值低。
media模块下的接口支持的音视频格式将在[AVPlayer和AVRecorder](avplayer-avrecorder-overview.md)的介绍中承载。
## 相关实例
针对音视频开发,有以下相关实例可供参考:
- [音视频录制(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Media/AVRecorder)
- [音频管理(ArkTS)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Media/Audio)
\ No newline at end of file
......@@ -25,3 +25,9 @@
相机应用通过控制相机,实现图像显示(预览)、照片保存(拍照)、视频录制(录像)等基础操作。在实现基本操作过程中,相机服务会控制相机设备采集和输出数据,采集的图像数据在相机底层的设备硬件接口(HDI,Hardware Device Interfaces),直接通过BufferQueue传递到具体的功能模块进行处理。BufferQueue在应用开发中无需关注,用于将底层处理的数据及时送到上层进行图像显示。
以视频录制为例进行说明,相机应用在录制视频过程中,媒体录制服务先创建一个视频Surface用于传递数据,并提供给相机服务,相机服务可控制相机设备采集视频数据,生成视频流。采集的数据通过底层相机HDI处理后,通过Surface将视频流传递给媒体录制服务,媒体录制服务对视频数据进行处理后,保存为视频文件,完成视频录制。
## 相关实例
针对相机开发,有以下相关实例可供参考:
- [相机和媒体库(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/SystemFeature/Media/Camera)
\ No newline at end of file
......@@ -36,3 +36,13 @@
5. [图片编码](image-encoding.md):使用图片打包器类ImagePacker,将PixelMap或ImageSource进行压缩编码,生成一张新的图片。
除上述基本图片开发能力外,OpenHarmony还提供常用[图片工具](image-tool.md),供开发者选择使用。
## 相关实例
针对图片开发,有以下相关实例可供参考:
- [图片显示及处理(ArkTS)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Media/Image)
- [图片显示(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Media/ImageShow)
- [图片裁剪与分割(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Media/GamePuzzle)
\ No newline at end of file
......@@ -17,3 +17,13 @@
- 相机(camera):提供精确控制相机镜头,采集视觉信息的接口与服务。
- 图片(image):提供图片编解码、图片处理接口与服务。
## 相关实例
针对媒体开发,有以下相关实例可供参考:
- [媒体管理合集(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/FileManagement/MediaCollections)
- [相机和媒体库(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/Solutions/Media/MultiMedia)
- [二维码扫描(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Media/QRCodeScan)
\ No newline at end of file
......@@ -331,3 +331,9 @@ OpenHarmony系统预置的播控中心,作为媒体会话控制方与音视频
});
}
```
## 相关实例
针对媒体会话控制方开发,有以下相关实例可供参考:
- [媒体会话——控制方(仅对系统应用开放)(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Media/AVSession/MediaController)
\ No newline at end of file
......@@ -357,3 +357,9 @@
});
}
```
## 相关实例
针对媒体会话提供方开发,有以下相关实例可供参考:
- [媒体会话——提供方(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Media/AVSession/MediaProvider)
\ No newline at end of file
......@@ -264,4 +264,6 @@ export class AVPlayerDemo {
针对视频播放,有以下相关实例可供参考:
- [视频播放(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Media/VideoPlay)
- [`VideoPlayer`:视频播放器(ArkTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/Media/VideoPlayer)
\ No newline at end of file
......@@ -380,5 +380,7 @@
```
## 相关实例
- [`NdkRawfile`:获取Rawfile资源](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Native/NdkRawfile)
针对资源管理Rawfile开发,有以下相关实例可供参考:
- [获取Rawfile资源(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Native/NdkRawfile)
......@@ -899,4 +899,4 @@ XComponent({ id: 'xcomponentId1', type: 'surface', libraryname: 'nativerender' }
针对Native XComponent的使用,有以下相关实例可供参考:
- [使用Native XComponent接口绘制图形](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Native/NdkXComponent)
- [Native XComponent(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Native/NdkXComponent)
......@@ -31,4 +31,12 @@ OpenHarmony通过ANS(Advanced Notification Service,通知系统服务)对
基于通知的开发,有以下相关实例可供参考:
- [`CustomNotification`:自定义通知(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Notification/CustomNotification)
\ No newline at end of file
- [公共事件的订阅和发布(ArkTS)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Notification/CustomCommonEvent)
- [自定义通知推送(ArkTS)(Full SDK)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Notification/CustomNotificationPush)
- [自定义通知角标(ArkTS)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Notification/CustomNotificationBadge)
- [自定义通知(ArkTS)(API10)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Notification/CustomNotification)
- [自定义Emitter(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/BasicFeature/Notification/CustomEmitter)
\ No newline at end of file
......@@ -132,4 +132,6 @@ $$运算符:给内置组件提供TS变量的引用,使得TS变量和内置
针对页面状态管理,有以下相关实例可供参考:
- [状态管理(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/UI/ArkTsComponentCollection/StateManagement)
- [目标管理(ArkTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/TargetManagement)
\ No newline at end of file
......@@ -5,4 +5,10 @@
- 方便开发者将多HAP合理地组合并部署到不同的设备上。例如应用程序包含一个Entry包和两个Featrue包(Feature1和Feature2)。其中Entry包可以部署到设备A和设备B,Feature1只能部署到设备A,Feature2包只部署到设备B上,那么开发者就可以方便的组合Entry和Feature1部署到设备A上,组合Entry和Feature2部署到设备B上。
- 方便开发者按需加载所需模块,减少包大小。开发者可以将一个应用的某些HAP配置成按需加载。应用在启动阶段初始用不到的特性,可以配置暂不加载,当用户用到这些特性的时候,可由应用自动下载这些特性HAP,一定程度上减少应用包的大小。
\ No newline at end of file
- 方便开发者按需加载所需模块,减少包大小。开发者可以将一个应用的某些HAP配置成按需加载。应用在启动阶段初始用不到的特性,可以配置暂不加载,当用户用到这些特性的时候,可由应用自动下载这些特性HAP,一定程度上减少应用包的大小。
## 相关实例
针对多HAP开发,有以下相关实例可供参考:
- [多HAP(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-4.0-Beta2/code/Project/ApplicationHap/MultiHap)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册