提交 13977f10 编写于 作者: E ester.zhou

update docs

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 0bd2343c
......@@ -149,7 +149,7 @@ Notification.requestEnableNotification() .then((data) => {
To publish a notification, create a **NotificationRequest** object and set attributes such as the notification type, title, and content. In the following examples, a normal text notification and a notification containing a **WantAgent** are being published.
Normal Text Notification
Normal text notification:
```js
// Create a NotificationRequest object.
......@@ -175,7 +175,7 @@ Notification.publish(notificationRequest) .then((data) => {
Notification Containing WantAgent.
Notification containing **WantAgent**:
For details about how to use **WantAgent**, see [WantAgent Development](https://gitee.com/openharmony/docs/blob/master/en/application-dev/ability/wantagent.md).
......@@ -214,7 +214,7 @@ function getWantAgentCallback(err, data) {
wantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
```
- Publishes a notification.
- Publish the notification.
```js
// Create a NotificationRequest object.
......
......@@ -3,32 +3,33 @@
## Resource Definition
Application resources are defined in the project's resources directory, which is organized as follows:
Application resources are defined in the project's **resources** directory, which is organized as follows:
- Level-1: base sub-directory, qualifiers sub-directories, and rawfile sub-directory
- The base sub-directory is a default directory. If no qualifiers sub-directories in the resources directory of the application match the device status, the resource file in the base sub-directory will be automatically referenced.
- Level-1: **base** sub-directory, qualifiers sub-directories, and **rawfile** sub-directory
- The **base** sub-directory is a default directory. If no qualifiers sub-directories in the **resources** directory of the application match the device status, the resource file in the **base** sub-directory will be automatically referenced.
- You need to create qualifiers sub-directories on your own. The name of a qualifiers sub-directory consists of one or more qualifiers that represent the application scenarios or device characteristics, covering the mobile country code (MCC), mobile network code (MNC), language, script, country or region, screen orientation, device type, color mode, and screen density. The qualifiers are separated using underscores (_) or hyphens (-).
- When the resources in the rawfile sub-directory are referenced, resource files will not be matched based on the device status. You can directly store resource files in the rawfile sub-directory.
- When the resources in the **rawfile** sub-directory are referenced, resource files will not be matched based on the device status. You can directly store resource files in the **rawfile** sub-directory.
- Level-2: resource sub-directories
- Resource sub-directories store basic elements such as character strings, colors, and floating point numbers, and resource files such as media files.
- Supported files and resource types are listed in the table below:
| File Name | Resource Type |
- Supported files and resource types are listed in the table below.
| File Name| Resource Type|
| -------- | -------- |
| color.json | Color resource. |
| float.json | Resources such as spacing, rounded corners, and fonts. |
| string.json | String resource. |
| plural.json | String resource. |
| media directory | Image resource. |
| color.json | Color resource.|
| float.json | Resources such as spacing, rounded corners, and fonts.|
| string.json | String resource.|
| plural.json | String resource.|
| media directory| Image resource.|
## Referencing Resources
To reference an application resource in a project, use the ```"$r('app.type.name')"``` format. **app** indicates the resource defined in the resources directory of the application. **type** indicates the resource type (or the location where the resource is stored). The value can be color, float, string, plural, or media. **name** indicates the resource name, which you set when defining the resource.
To reference an application resource in a project, use the `"$r('app.type.name')"` format. **app** indicates the resource defined in the **resources** directory of the application. **type** indicates the resource type (or the location where the resource is stored). The value can be **color**, **float**, **string**, **plural**, or **media**. **name** indicates the resource name, which you set when defining the resource.
When referencing resources in the **rawfile** sub-directory, use the `"$rawfile('filename')"` format. Currently, **$rawfile** allows only the **\<Image>** component to reference image resources. **filename** indicates the relative path of a file in the **rawfile** directory, and the file name must contain the file name extension. Note that the relative path cannot start with a slash (/).
When referencing resources in the **rawfile** sub-directory, use the ```"$rawfile('filename')"``` format. Currently, **$rawfile** allows only the **\<Image>** component to reference image resources. In the format, **filename** indicates the relative path of a file in the **rawfile** directory, and the file name must contain the file name extension. Note that the relative path cannot start with a slash (/).
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> Resource descriptors cannot be combined.
> Resource descriptors accept only strings, such as `'app.type.name'`, and cannot be combined.
## Example
......@@ -51,7 +52,7 @@ Some custom resources in the **base** sub-directory are as follows:
└─ newTest.png
```
The content of the color.json file is as follows:
The content of the **color.json** file is as follows:
```
......@@ -69,7 +70,7 @@ The content of the color.json file is as follows:
}
```
The content of the float.json file is as follows:
The content of the **float.json** file is as follows:
```
......@@ -87,7 +88,7 @@ The content of the float.json file is as follows:
}
```
The content of the string.json file is as follows:
The content of the **string.json** file is as follows:
```
......@@ -109,7 +110,7 @@ The content of the string.json file is as follows:
}
```
The content of the plural.json file is as follows:
The content of the **plural.json** file is as follows:
```
......@@ -132,7 +133,7 @@ The content of the plural.json file is as follows:
}
```
In the .ets file, you can use the resources defined in the resources directory.
In the **.ets** file, you can use the resources defined in the **resources** directory.
```
Text($r('app.string.string_hello'))
......@@ -150,14 +151,21 @@ Text($r('app.string.message_arrive', "five of the clock")) // Reference string r
.fontSize($r('app.float.font_hello'))
}
Text($r('app.plural.eat_apple', 5, 5)) // Reference plural resources. The first parameter specifies the plural resource, and the second parameter specifies the number of plural resources. The third number indicates the substitute of %d.
Text($r('app.plural.eat_apple', 5, 5)) // Reference plural resources. The first parameter indicates the plural resource, and the second parameter indicates the number of plural resources. The third parameter indicates the substitute of %d.
.fontColor($r('app.color.color_world'))
.fontSize($r('app.float.font_world'))
}
Image($r(?app.media.my_background_image creation)) // Reference media resources.
Image($r('app.media.my_background_image')) // Reference media resources.
Image($rawfile( Femaletest.png loaded)) // Reference an image in the rawfile directory.
Image($rawfile('test.png')) // Reference an image in the rawfile directory.
Image($rawfile(newDir/newTest.png loaded)) // Reference an image in the rawfile directory.
Image($rawfile('newDir/newTest.png')) // Reference an image in the rawfile directory.
```
## Samples
The following sample is provided to help you better understand how to access application resources:
- [`ResourceManager`: eTS Resource Management (API 7)](https://gitee.com/openharmony/app_samples/tree/master/common/ResourceManager)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册