提交 6572184d 编写于 作者: 田雨 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/docs into master

Signed-off-by: N田雨 <tianyu55@huawei.com>
......@@ -243,7 +243,7 @@ zh-cn/application-dev/reference/apis/js-apis-data-preferences.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-data-storage.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-system-storage.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-data-rdb.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-settings.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-settings.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-data-resultset.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-document.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-environment.md @qinxiaowang
......@@ -261,15 +261,18 @@ zh-cn/application-dev/reference/apis/js-apis-sms.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-telephony-data.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-net-connection.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-http.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-request.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-request.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-socket.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-webSocket.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-connectedTag.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-nfcTag.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-nfcTech.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-tagSession.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-connectedTag.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-rpc.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-wifi.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-wifiext.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-accessibility.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-wifi.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-wifiext.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-accessibility.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-faultLogger.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-hiappevent.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-hichecker.md @zengyawen
......@@ -277,34 +280,34 @@ zh-cn/application-dev/reference/apis/js-apis-hidebug.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-hilog.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-hitracechain.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-hitracemeter.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-system-time.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-system-time.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-timer.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-battery-info.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-brightness.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-device-info.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-battery-info.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-brightness.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-device-info.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-device-manager.md
zh-cn/application-dev/reference/apis/js-apis-geolocation.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-power.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-runninglock.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-power.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-runninglock.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-sensor.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-system-sensor.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-system-parameter.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-thermal.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-system-parameter.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-thermal.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-update.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-usb.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-vibrator.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-appAccount.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-distributed-account.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-osAccount.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-appAccount.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-distributed-account.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-osAccount.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-convertxml.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-process.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-uri.md @zengyawen
......@@ -344,4 +347,5 @@ zh-cn/application-dev/quick-start/syscap.md @RayShih
zh-cn/application-dev/napi/napi-guidelines.md @RayShih
zh-cn/application-dev/napi/drawing-guidelines.md @ge-yafang
zh-cn/application-dev/napi/rawfile-guidelines.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-buffer.md @zengyawen
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-buffer.md @zengyawen
zh-cn/application-dev/reference/js-service-widget-ui @HelloCrease
\ No newline at end of file
......@@ -22,9 +22,11 @@ This repository stores device and application development documents provided by
- OpenHarmony 3.1 Release. [Learn more](en/release-notes/OpenHarmony-v3.1-release.md)
This version is upgraded to OpenHarmony 3.1.1 LTS. [Learn more](en/release-notes/OpenHarmony-v3.1.1-release.md)
- OpenHarmony 3.0 LTS. [Learn more](en/release-notes/OpenHarmony-v3.0-LTS.md)
This version is upgraded to OpenHarmony 3.0.3 LTS. [Learn more](en/release-notes/OpenHarmony-v3.0.3-LTS.md)
This version is upgraded to OpenHarmony 3.0.5 LTS. [Learn more](en/release-notes/OpenHarmony-v3.0.5-LTS.md)
- OpenHarmony 2.2 Beta2. [Learn more](en/release-notes/OpenHarmony-v2.2-beta2.md)
......@@ -41,10 +43,14 @@ OpenHarmony_v1.x_release: OpenHarmony v1.1.4 LTS. [Learn more](en/release-notes/
Third-party license: [Third-Party Open-Source Software and License Notice](en/contribute/third-party-open-source-software-and-license-notice.md)
## How to Contribute
## Contribution
A great open-source project wouldn't be possible without the hard work of many contributors. We'd like to invite anyone from around the world to [participate](en/contribute/how-to-contribute.md) in this exciting journey, and we're grateful for your time, passion, and efforts!
You can evaluate available documents, make simple modifications, provide feedback on document quality, and contribute your original content. For details, see [Documentation Contribution](en/contribute/documentation-contribution.md).
Excellent contributors will be awarded and the contributions will be publicized in the developer community.
- Mail list: docs@openharmony.io
- Zulip group: documentation_sig
\ No newline at end of file
......@@ -35,14 +35,15 @@ RUN sed -i "s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g" /etc/ap
&& pip3 install six --upgrade --ignore-installed six \
&& mkdir -p /home/tools \
&& mkdir -p /home/tools/gn \
&& wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/clang/10.0.1-62608/linux/llvm.tar.gz \
&& wget -P /home/tools https://repo.huaweicloud.com/openharmony/compiler/clang/12.0.1-530132/linux/clang-530132-linux-x86_64.tar.bz2 \
&& wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar \
&& wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz \
&& wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar \
&& wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/gn/1717/linux/gn-linux-x86-1717.tar.gz \
&& wget -P /home/tools https://mirrors.huaweicloud.com/nodejs/v14.15.4/node-v14.15.4-linux-x64.tar.xz \
&& wget -P /home/tools https://hm-verify.obs.cn-north-4.myhuaweicloud.com/qemu-5.2.0.tar.xz \
&& tar -xvf /home/tools/llvm.tar.gz -C /home/tools \
&& tar -jxvf /home/tools/clang-530132-linux-x86_64.tar.bz2 -C /home/tools \
&& mv /home/tools/clang-530132 /home/tools/llvm \
&& tar -xvf /home/tools/hc-gen-0.65-linux.tar -C /home/tools \
&& tar -xvf /home/tools/gcc_riscv32-linux-7.3.0.tar.gz -C /home/tools \
&& tar -xvf /home/tools/ninja.1.9.0.tar -C /home/tools \
......
......@@ -30,7 +30,7 @@ A Service ability is used to run tasks in the background, such as playing music
},
onConnect(want) {
console.log('ServiceAbility OnConnect');
return null;
return new FirstServiceAbilityStub('test');
},
onDisconnect(want) {
console.log('ServiceAbility OnDisConnect');
......@@ -113,8 +113,6 @@ let promise = featureAbility.startAbility(
Once created, the Service ability keeps running in the background. The system does not stop or destroy it unless memory resources must be reclaimed.
### Connecting to a Local Service Ability
If you need to connect a Service ability to a Page ability or to a Service ability in another application, you must first implement the **IAbilityConnection** API for the connection. A Service ability allows other abilities to connect to it through **connectAbility()**.
......@@ -124,7 +122,7 @@ You can use either of the following methods to connect to a Service ability:
1. Using the IDL to automatically generate code
Use OpenHarmony Interface Definition Language (IDL) to automatically generate the corresponding client, server, and **IRemoteObject** code. For details, see [“Development Using TS” in OpenHarmony IDL Specifications and User Guide](https://gitee.com/openharmony/docs/blob/master/en/application-dev/IDL/idl-guidelines.md#development-using-ts).
Use OpenHarmony Interface Definition Language (IDL) to automatically generate the corresponding client, server, and **IRemoteObject** code. For details, see “Development Using TS" in [OpenHarmony IDL Specifications and User Guide](../IDL/idl-guidelines.md).
2. Writing code in the corresponding file
......@@ -134,42 +132,37 @@ You can use either of the following methods to connect to a Service ability:
```javascript
import prompt from '@system.prompt'
let mRemote;
function onConnectCallback(element, remote){
console.log('onConnectLocalService onConnectDone element: ' + element);
console.log('onConnectLocalService onConnectDone remote: ' + remote);
mRemote = remote;
if (mRemote == null) {
prompt.showToast({
message: "onConnectLocalService not connected yet"
});
return;
}
let option = new rpc.MessageOption();
let data = new rpc.MessageParcel();
let reply = new rpc.MessageParcel();
data.writeInt(1);
data.writeInt(99);
mRemote.sendRequest(1, data, reply, option).then((result) => {
console.log('sendRequest success');
let msg = reply.readInt();
var option = {
onConnect: function onConnectCallback(element, proxy) {
console.log(`onConnectLocalService onConnectDone`)
if (proxy === null) {
prompt.showToast({
message: "Connect service failed"
})
return
}
let data = rpc.MessageParcel.create()
let reply = rpc.MessageParcel.create()
let option = new rpc.MessageOption()
data.writeInterfaceToken("connect.test.token")
proxy.sendRequest(0, data, reply, option)
prompt.showToast({
message: "onConnectLocalService connect result: " + msg,
duration: 3000
});
}).catch((e) => {
console.log('sendRequest error:' + e);
});
}
function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect Callback')
}
function onFailedCallback(code){
console.log('ConnectAbility onFailed Callback')
message: "Connect service success"
})
},
onDisconnect: function onDisconnectCallback(element) {
console.log(`onConnectLocalService onDisconnectDone element:${element}`)
prompt.showToast({
message: "Disconnect service success"
})
},
onFailed: function onFailedCallback(code) {
console.log(`onConnectLocalService onFailed errCode:${code}`)
prompt.showToast({
message: "Connect local service onFailed"
})
}
}
```
......@@ -196,45 +189,28 @@ You can use either of the following methods to connect to a Service ability:
```javascript
import rpc from "@ohos.rpc";
let mMyStub;
export default {
onStart() {
class MyStub extends rpc.RemoteObject{
constructor(des) {
if (typeof des === 'string') {
super(des);
}
return null;
}
onRemoteRequest(code, data, reply, option) {
console.log("ServiceAbility onRemoteRequest called");
if (code === 1) {
let op1 = data.readInt();
let op2 = data.readInt();
console.log("op1 = " + op1 + ", op2 = " + op2);
reply.writeInt(op1 + op2);
} else {
console.log("ServiceAbility unknown request code");
}
return true;
}
}
mMyStub = new MyStub("ServiceAbility-test");
},
onCommand(want, startId) {
console.log('ServiceAbility onCommand');
},
onConnect(want) {
console.log('ServiceAbility OnConnect');
return mMyStub;
},
onDisconnect(want) {
console.log('ServiceAbility OnDisConnect');
},
onStop() {
console.log('ServiceAbility onStop');
},
class FirstServiceAbilityStub extends rpc.RemoteObject {
constructor(des: any) {
if (typeof des === 'string') {
super(des)
} else {
return
}
}
onRemoteRequest(code: number, data: any, reply: any, option: any) {
console.log(printLog + ` onRemoteRequest called`)
if (code === 1) {
let string = data.readString()
console.log(printLog + ` string=${string}`)
let result = Array.from(string).sort().join('')
console.log(printLog + ` result=${result}`)
reply.writeString(result)
} else {
console.log(printLog + ` unknown request code`)
}
return true;
}
```
......@@ -253,40 +229,36 @@ The following code snippet shows how to implement the callbacks:
```ts
import prompt from '@system.prompt'
let mRemote;
function onConnectCallback(element, remote){
console.log('onConnectRemoteService onConnectDone element: ' + element);
console.log('onConnectRemoteService onConnectDone remote: ' + remote);
mRemote = remote;
if (mRemote == null) {
prompt.showToast({
message: "onConnectRemoteService not connected yet"
});
return;
}
let option = new rpc.MessageOption();
let data = new rpc.MessageParcel();
let reply = new rpc.MessageParcel();
data.writeInt(1);
data.writeInt(99);
mRemote.sendRequest(1, data, reply, option).then((result) => {
console.log('sendRequest success');
let msg = reply.readInt();
var option = {
onConnect: function onConnectCallback(element, proxy) {
console.log(`onConnectRemoteService onConnectDone`)
if (proxy === null) {
prompt.showToast({
message: "Connect service failed"
})
return
}
let data = rpc.MessageParcel.create()
let reply = rpc.MessageParcel.create()
let option = new rpc.MessageOption()
data.writeInterfaceToken("connect.test.token")
proxy.sendRequest(0, data, reply, option)
prompt.showToast({
message: "onConnectRemoteService connect result: " + msg,
duration: 3000
});
}).catch((e) => {
console.log('sendRequest error:' + e);
});
}
function onDisconnectCallback(element){
console.log('ConnectRemoteAbility onDisconnect Callback')
}
function onFailedCallback(code){
console.log('ConnectRemoteAbility onFailed Callback')
message: "Connect service success"
})
},
onDisconnect: function onDisconnectCallback(element) {
console.log(`onConnectRemoteService onDisconnectDone element:${element}`)
prompt.showToast({
message: "Disconnect service success"
})
},
onFailed: function onFailedCallback(code) {
console.log(`onConnectRemoteService onFailed errCode:${code}`)
prompt.showToast({
message: "Connect local service onFailed"
})
}
}
```
......@@ -372,23 +344,25 @@ The following code snippet shows how the Service ability instance returns itself
```ts
import rpc from "@ohos.rpc";
class FirstServiceAbilityStub extends rpc.RemoteObject{
constructor(des) {
class FirstServiceAbilityStub extends rpc.RemoteObject {
constructor(des: any) {
if (typeof des === 'string') {
super(des);
super(des)
} else {
return null;
return
}
}
onRemoteRequest(code, data, reply, option) {
console.log("ServiceAbility onRemoteRequest called");
onRemoteRequest(code: number, data: any, reply: any, option: any) {
console.log(printLog + ` onRemoteRequest called`)
if (code === 1) {
let op1 = data.readInt();
let op2 = data.readInt();
console.log("op1 = " + op1 + ", op2 = " + op2);
reply.writeInt(op1 + op2);
let string = data.readString()
console.log(printLog + ` string=${string}`)
let result = Array.from(string).sort().join('')
console.log(printLog + ` result=${result}`)
reply.writeString(result)
} else {
console.log("ServiceAbility unknown request code");
console.log(printLog + ` unknown request code`)
}
return true;
}
......
......@@ -3,12 +3,19 @@
- Distributed Data Service
- [Distributed Data Service Overview](database-mdds-overview.md)
- [Distributed Data Service Development](database-mdds-guidelines.md)
- Relational Database
- [RDB Overview](database-relational-overview.md)
- [RDB Development](database-relational-guidelines.md)
- Preferences
- [Preferences Overview](database-preference-overview.md)
- [Preferences Development](database-preference-guidelines.md)
- Distributed Data Object
- [Distributed Data Object Overview](database-distributedobject-overview.md)
- [Distributed Data Object Development](database-distributedobject-guidelines.md)
- Data Share
- [DataShare Overview](database-datashare-overview.md)
- [DataShare Development](database-datashare-guidelines.md)
# DataShare Development
The **DataShare** module allows an application to manage its own data and share data with other applications. Currently, data can be shared only between the applications on the same device.
## Available APIs
**Table 1** APIs of the data provider
|API|Description|
|:------|:------|
|onCreate?(want: Want, callback: AsyncCallback&lt;void&gt;): void|Called to initialize service logic when the data provider application is created, for example, when a database is created.|
|insert?(uri: string, valueBucket: ValuesBucket, callback: AsyncCallback&lt;number&gt;): void|Inserts data into the database.|
|update?(uri: string, predicates: DataSharePredicates, valueBucket: ValuesBucket, callback: AsyncCallback&lt;number&gt;): void|Updates data in the database.|
|query?(uri: string, predicates: DataSharePredicates, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;Object&gt;): void|Queries data from the database.|
|delete?(uri: string, predicates: DataSharePredicates, callback: AsyncCallback&lt;number&gt;): void|Deletes data from the database.|
For more details, see [DataShareExtensionAbility](../reference/apis/js-apis-application-DataShareExtensionAbility.md).
**Table 2** APIs of the data consumer
| API | Description |
| :----------------------------------------------------------- | :--------------------------------- |
| createDataShareHelper(context: Context, uri: string, callback: AsyncCallback&lt;DataShareHelper&gt;): void | Creates a **DataShareHelper** instance. |
| insert(uri: string, value: ValuesBucket, callback: AsyncCallback&lt;number&gt;): void | Inserts a single data record into the database. |
| update(uri: string, predicates: DataSharePredicates, value: ValuesBucket, callback: AsyncCallback&lt;number&gt;): void | Updates data in the database. |
| query(uri: string, predicates: DataSharePredicates, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;DataShareResultSet&gt;): void | Queries data from the database. |
| delete(uri: string, predicates: DataSharePredicates, callback: AsyncCallback&lt;number&gt;): void | Deletes one or more data records from the database.|
For more details, see [DataShareHelper](../reference/apis/js-apis-data-dataShare.md).
## When to Use
**DataShare** can be divided into the following:
- Data provider: Implement functions of adding, deleting, modifying, and querying data, and opening files, and share data.
- Data consumer: Access the data provided by the provider using **DataShareHelper**.
Examples are given below.
### Data Provider Application Development (Only for System Applications)
1. Import the dependencies.
```ts
import Extension from '@ohos.application.DataShareExtensionAbility'
import rdb from '@ohos.data.rdb';
import fileIo from '@ohos.fileio'
import dataSharePredicates from '@ohos.data.dataSharePredicates'
```
2. Override **DataShareExtensionAbility** APIs based on actual requirements. For example, if the data provider provides only data query, override only the query() API.
3. Implement the data provider services. For example, implement data storage of the data provider by using a database, reading and writing files, or accessing the network.
```ts
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS "
+ TBL_NAME
+ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, isStudent BOOLEAN, Binary BINARY)";
let rdbStore;
let result;
export default class DataShareExtAbility extends Extension {
private rdbStore_;
// Override the onCreate() API.
onCreate(want, callback) {
result = this.context.cacheDir + '/datashare.txt'
// Create an RDB.
rdb.getRdbStore(this.context, {
name: DB_NAME
}, 1, function (err, data) {
rdbStore = data;
rdbStore.executeSql(DDL_TBL_CREATE, [], function (err) {
console.log('DataShareExtAbility onCreate, executeSql done err:' + JSON.stringify(err));
});
callback();
});
}
// Override the query() API.
query(uri, predicates, columns, callback) {
if (predicates == null || predicates == undefined) {
console.info('invalid predicates');
}
try {
rdbStore.query(TBL_NAME, predicates, columns, function (err, resultSet) {
if (resultSet != undefined) {
console.info('resultSet.rowCount: ' + resultSet.rowCount);
}
if (callback != undefined) {
callback(err, resultSet);
}
});
} catch (err) {
console.error('error' + err);
}
}
// Override other APIs as required.
// ...
};
```
4. Define **DataShareExtensionAbility** in **module.json5**.
| Field| Description |
| ------------ | ------------------------------------------------------------ |
| "name" | Ability name, corresponding to the **ExtensionAbility** class name derived from **Ability**. |
| "type" | Ability type. The value is **dataShare**, indicating the development is based on the **Datashare** template.|
| "uri" | URI used for communication. It is the unique identifier for the client to connect to the server. |
| "visible" | Whether it is visible to other applications. Communication with other applications is allowed only when the value is **true**.|
**module.json5 example**
```json
"extensionAbilities": [
{
"srcEntrance": "./ets/DataShareExtAbility/DataShareExtAbility.ts",
"name": "DataShareExtAbility",
"icon": "$media:icon",
"description": "$string:description_datashareextability",
"type": "dataShare",
"uri": "datashare://com.samples.datasharetest.DataShare",
"visible": true
}
]
```
### Data Consumer Application Development
1. Import basic dependencies.
```ts
import Ability from '@ohos.application.Ability'
import dataShare from '@ohos.data.dataShare'
import dataSharePredicates from '@ohos.data.dataSharePredicates'
```
2. Define the URI string for communicating with the data provider.
```ts
// Different from the URI defined in the module.json5 file, the URI passed in the parameter has an extra slash (/), because there is a DeviceID parameter between the second and the third slash (/).
let dseUri = ("datashare:///com.samples.datasharetest.DataShare");
```
2. Create a **DataShareHelper** instance.
```ts
let dsHelper;
let abilityContext;
export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
abilityContext = this.context;
dataShare.createDataShareHelper(abilityContext, dseUri, (err,data)=>{
dsHelper = data;
});
}
}
```
3. Use the APIs provided by **DataShareHelper** to access the services provided by the provider, for example, adding, deleting, modifying, and querying data.
```ts
// Construct a piece of data.
var valuesBucket = {"name": "ZhangSan", "age": 21, "isStudent": false, "Binary": new Uint8Array([1,2,3])};
var updateBucket = {"name": "LiSi", "age": 18, "isStudent": true, "Binary": new Uint8Array([1,2,3])};
let da = new dataSharePredicates.DataSharePredicates();
var valArray =new Array("*");
let people = new Array(
{"name": "LiSi", "age": 41, "Binary": ar},
{"name": "WangWu", "age": 21, "Binary": arr},
{"name": "ZhaoLiu", "age": 61, "Binary": arr});
// Insert a piece of data.
dsHelper.insert(dseUri, valuesBucket, (err,data) => {
console.log("dsHelper insert result: " + data);
});
// Delete the specified data.
dsHelper.delete(dseUri, da, (err,data) => {
console.log("dsHelper delete result: " + data);
});
// Update data.
dsHelper.update(dseUri, da, updateBucket, (err,data) => {
console.log("dsHelper update result: " + data);
});
// Query data.
dsHelper.query(dseUri, da, valArray, (err,data) => {
console.log("dsHelper query result: " + data);
});
```
# DataShare Overview
## Introduction
The **DataShare** module allows an application to manage its own data and share data with other applications. Currently, data can be shared only between the applications on the same device.
**DataShare** is used in application scenarios, such as contacts, short message service (SMS), and media gallery. However, not all data, such as accounts and passwords, can be accessed by other applications. Some data, such as SMS messages, can only be queried by other applications. **DataShare** provides a secure data sharing mechanism for applications.
The data provider can directly use the **DataShare** framework to share data with other applications without complex encapsulation. The data consumer only needs to learn and use a set of interfaces because the data access mode does not vary with the data provisioning mode. This greatly reduces the learning time and development difficulty.
## Basic Concepts
Before you get started, familiarize yourself with the following concepts:
- Data provider
An application that provides data and implements related services. It is also called a producer or server.
- Data consumer
An application that accesses the data or services provided by a data provider. It is also called a client.
- Value bucket (**ValuesBucket**)
One or more data records stored in the form of key-value (KV) pairs. The keys are of the string type. The values can be of the number, string, Boolean, or Unit8Array type.
- Result set
A collection of query results. Flexible data access modes are provided for users to obtain data.
- Predicate
Conditions specified for updating, deleting, or querying data in the database.
## Working Principles
**Figure 1** DataShare mechanism
![](figures/en_DataShare.png)
- The **DataShareExtAbility** module, as the data provider, implements data sharing between applications.
- The **DataShareHelper** module, as the data consumer, provides interfaces for accessing data, including adding, deleting, modifying, and querying data.
- The data consumer communicates with the data provider using inter-process communication (IPC). The data provider can be implemented through a database or other data storage.
- The **ResultSet** module is implemented through shared memory. Share memory stores the result sets, and interfaces are provided to traverse result sets.
## Constraints
- **DataShare** is subject to the limitations on the database used by the data provider. For example, the supported data models, length of the keys and values, and maximum number of databases that can be accessed at a time by each application vary with the database in use.
- The payloads of **ValuesBucket**, predicates, and result sets are restricted by IPC.
......@@ -421,13 +421,13 @@ import stats from '@ohos.bundleState';
```javascript
import stats from '@ohos.bundleState'
//promise
// Promise mode
stats.unRegisterGroupCallBack().then(() => {
console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise succeeded.');
}).catch(err => {
console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise failed. because: ' + err.code);
});
//callback
// Asynchronous callback mode
stats.unRegisterGroupCallBack((err) => {
if (err) {
console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack callback failed, because: ' + err.code);
......
......@@ -14,6 +14,7 @@ You can `import` the native .so that contains the JS processing logic. For examp
* Add **static** to the **nm_register_func** function to prevent symbol conflicts with other .so files.
* The name of the module registration entry, that is, the function decorated by **\_\_attribute\_\_((constructor))**, must be unique.
### .so Naming Rules
Each module has a .so file. For example, if the module name is `hello`, name the .so file **libhello.so**. The `nm_modname` field in `napi_module` must be `hello`, which is the same as the module name. The sample code for importing the .so file is `import hello from 'libhello.so'`.
......@@ -25,6 +26,10 @@ The Ark engine prevents NAPIs from being called to operate JS objects in non-JS
* The NAPIs can be used only in JS threads.
* **env** is bound to a thread and cannot be used across threads. The JS object created by a NAPI can be used only in the thread, in which the object is created, that is, the JS object is bound to the **env** of the thread.
### Importing Header Files
Before using NAPI objects and methods, include **napi/native_api.h**. Otherwise, when only the third-party library header file is included, an error will be reporting, indicating that the interface cannot be found.
### napi_create_async_work
**napi_create_async_work** has two callbacks:
......@@ -635,3 +640,8 @@ export default {
}
}
```
## Samples
The following samples are provided for native API development:
- [`NativeAPI`: NativeAPI (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/Native/NativeAPI)
- [First Native C++ Application (eTS) (API9)](https://gitee.com/openharmony/codelabs/tree/master/NativeAPI/NativeTemplateDemo)
- [Native Component (eTS) (API9) ](https://gitee.com/openharmony/codelabs/tree/master/NativeAPI/XComponent)
......@@ -98,11 +98,11 @@ import commonEvent from '@ohos.commonEvent';
```js
// Publish a common event.
commonEvent.publish("event", (err) => {
if (err.code) {
console.error("[CommonEvent]PublishCallBack err=" + JSON.stringify(err))
} else {
console.info("[CommonEvent]Publish1")
}
if (err.code) {
console.error("[CommonEvent]PublishCallBack err=" + JSON.stringify(err))
} else {
console.info("[CommonEvent]Publish1")
}
})
```
......@@ -118,8 +118,8 @@ import commonEvent from '@ohos.commonEvent'
```js
// Attributes of a common event.
var options = {
code: 1, // Result code of the common event
data: "initial data";// Result data of the common event
code: 1, // Result code of the common event
data: "initial data",// Result data of the common event
}
```
......@@ -128,11 +128,11 @@ var options = {
```js
// Publish a common event.
commonEvent.publish("event", options, (err) => {
if (err.code) {
console.error("[CommonEvent]PublishCallBack err=" + JSON.stringify(err))
} else {
console.info("[CommonEvent]Publish2")
}
if (err.code) {
console.error("[CommonEvent]PublishCallBack err=" + JSON.stringify(err))
} else {
console.info("[CommonEvent]Publish2")
}
})
```
......
......@@ -89,7 +89,7 @@ Adds an app account name and additional information (information that can be con
### addAccount
addAccount(name: string, extraInfo: string): Promise&lt;void&gt;
addAccount(name: string, extraInfo?: string): Promise&lt;void&gt;
Adds an app account name and additional information (information that can be converted into the string type, such as token) to the **AppAccountManager** service. This API uses a promise to return the result.
......@@ -100,7 +100,7 @@ Adds an app account name and additional information (information that can be con
| Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ---------------------------------------- |
| name | string | Yes | Name of the app account to add. |
| extraInfo | string | Yes | Additional information to add. The additional information cannot contain sensitive information, such as the app account password.|
| extraInfo | string | No | Additional information to add. The additional information cannot contain sensitive information, such as the app account password.|
**Return value**
......@@ -1696,7 +1696,7 @@ Checks whether an app account has specific labels. This API uses an asynchronous
| name | string | Yes | Name of the target app account. |
| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
| labels | Array&lt;string&gt; | Yes | Labels to check. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the result. |
**Example**
......@@ -1710,7 +1710,7 @@ Checks whether an app account has specific labels. This API uses an asynchronous
### checkAccountLabels<sup>9+</sup>
checkAccountLabels(name: string, owner: string, labels: Array&lt;string&gt;): Promise&lt;void&gt;
checkAccountLabels(name: string, owner: string, labels: Array&lt;string&gt;): Promise&lt;boolean&gt;
Checks whether an app account has specific labels. This API uses a promise to return the result.
......@@ -1771,7 +1771,7 @@ Selects the accounts accessible to the requester based on the options. This API
### selectAccountsByOptions<sup>9+</sup>
selectAccountsByOptions(options: SelectAccountsOptions): Promise&lt;void&gt;
selectAccountsByOptions(options: SelectAccountsOptions): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;
Selects the accounts accessible to the requester based on the options. This API uses a promise to return the result.
......@@ -1836,7 +1836,7 @@ Verifies the user credential. This API uses an asynchronous callback to return t
### verifyCredential<sup>9+</sup>
verifyCredential(name: string, owner: string, options, callback: AuthenticatorCallback): void;
verifyCredential(name: string, owner: string, options: VerifyCredentialOptions, callback: AuthenticatorCallback): void;
Verifies the user credential. This API uses an asynchronous callback to return the result.
......@@ -1952,11 +1952,11 @@ Defines OAuth token information.
**System capability**: SystemCapability.Account.AppAccount
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | -------- |
| authType | string | Yes | Authentication type.|
| token | string | Yes | Value of the token. |
| account<sup>9+</sup> | AppAccountInfo | No | Account information of the token. |
| Name | Type | Mandatory | Description |
| -------------------- | -------------- | ----- | ---------------- |
| authType | string | Yes | Authentication type. |
| token | string | Yes | Value of the token. |
| account<sup>9+</sup> | AppAccountInfo | No | Account information of the token.|
## AuthenticatorInfo<sup>8+</sup>
......@@ -1978,7 +1978,7 @@ Represents the options for selecting accounts.
| Name | Type | Mandatory | Description |
| --------------- | --------------------------- | ----- | ------------------- |
| allowedAccounts | Array&lt;[AppAccountInfo](#appAccountinfo)&gt; | No | Allowed accounts. |
| allowedAccounts | Array&lt;[AppAccountInfo](#appaccountinfo)&gt; | No | Allowed accounts. |
| allowedOwners | Array&lt;string&gt; | No | Allowed account owners.|
| requiredLabels | Array&lt;string&gt; | No | Labels required for the authenticator. |
......@@ -2012,21 +2012,21 @@ Enumerates the constants.
**System capability**: SystemCapability.Account.AppAccount
| Name | Default Value | Description |
| ----------------------------- | ---------------------- | ------------- |
| ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | Operation of adding an account implicitly. |
| ACTION_AUTHENTICATE | "authenticate" | Authentication operation. |
| KEY_NAME | "name" | App account name. |
| KEY_OWNER | "owner" | Owner of an app account.|
| KEY_TOKEN | "token" | Token. |
| KEY_ACTION | "action" | Operation. |
| KEY_AUTH_TYPE | "authType" | Authentication type. |
| KEY_SESSION_ID | "sessionId" | Session ID. |
| KEY_CALLER_PID | "callerPid" | PID of the caller. |
| KEY_CALLER_UID | "callerUid" | UID of the caller. |
| KEY_CALLER_BUNDLE_NAME | "callerBundleName" | Bundle name of the caller. |
| KEY_REQUIRED_LABELS | "requiredLabels" | Required labels. |
| KEY_BOOLEAN_RESULT | "booleanResult" | Return value of the Boolean type. |
| Name | Default Value | Description |
| -------------------------------- | ---------------------- | ----------------------- |
| ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | Operation of adding an account implicitly. |
| ACTION_AUTHENTICATE | "authenticate" | Authentication operation. |
| KEY_NAME | "name" | App account name. |
| KEY_OWNER | "owner" | Owner of an app account.|
| KEY_TOKEN | "token" | Token. |
| KEY_ACTION | "action" | Operation. |
| KEY_AUTH_TYPE | "authType" | Authentication type. |
| KEY_SESSION_ID | "sessionId" | Session ID. |
| KEY_CALLER_PID | "callerPid" | PID of the caller. |
| KEY_CALLER_UID | "callerUid" | UID of the caller. |
| KEY_CALLER_BUNDLE_NAME | "callerBundleName" | Bundle name of the caller. |
| KEY_REQUIRED_LABELS<sup>9+</sup> | "requiredLabels" | Required labels. |
| KEY_BOOLEAN_RESULT<sup>9+</sup> | "booleanResult" | Return value of the Boolean type. |
## ResultCode<sup>8+</sup>
......@@ -2125,7 +2125,7 @@ Called to redirect a request.
### onRequestContinued<sup>9+</sup>
onRequestContinued: () =&gt; void
onRequestContinued?: () =&gt; void
Called to continue to process the request.
......
......@@ -2148,11 +2148,10 @@ Subscribes to audio capturer change events.
**System capability**: SystemCapability.Multimedia.Audio.Capturer
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------- | --------- | ------------------------------------------------------------------- ---- |
| -------- | ------- | --------- | ----------------------------------------------------------------------- |
| type | string | Yes | Event type. The event `'audioCapturerChange'` is triggered when the audio capturer changes. |
| callback | Callback<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | Yes | Callback used to return the result. |
| callback | Callback\<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | Yes | Callback used to return the result. |
**Example**
```
......
......@@ -18,9 +18,11 @@ The **ApplicationInfo** module provides application information. Unless otherwis
| systemApp | boolean | Yes | No | Whether the application is a system application. The default value is **false**. |
| enabled | boolean | Yes | No | Whether the application is enabled. The default value is **true**. |
| label | string | Yes | No | Application label. |
| labelId | string | Yes | No | Application label ID. |
| labelId<sup>(deprecated)</sup> | string | Yes | No | Application label ID.<br>\- **NOTE**: This attribute is deprecated from API version 9. Use **labelIndex** instead. |
| labelIndex<sup>9+</sup> | number | Yes | No | Index of the application label.|
| icon | string | Yes | No | Application icon. |
| iconId | string | Yes | No | Application icon ID. |
| iconId<sup>(deprecated)</sup> | string | Yes | No | Application icon ID.<br>\- **NOTE**: This attribute is deprecated from API version 9. Use **iconIndex** instead. |
| iconIndex<sup>9+</sup> | number | Yes | No | Index of the application icon.|
| process | string | Yes | No | Process in which the application runs. If this parameter is not set, the bundle name is used. |
| supportedModes | number | Yes | No | Running modes supported by the application. |
| moduleSourceDirs | Array\<string> | Yes | No | Relative paths for storing application resources. |
......
......@@ -136,6 +136,8 @@
| COMMON_EVENT_IVI_VOLTAGE_RECOVERY | common.event.IVI_VOLTAGE_RECOVERY | - |
| COMMON_EVENT_IVI_TEMPERATURE_RECOVERY | common.event.IVI_TEMPERATURE_RECOVERY | - |
| COMMON_EVENT_IVI_ACTIVE | common.event.IVI_ACTIVE | - |
|COMMON_EVENT_USB_STATE<sup>9+</sup> | usual.event.hardware.usb.action.USB_STATE | - |
|COMMON_EVENT_USB_PORT_CHANGED<sup>9+</sup> | usual.event.hardware.usb.action.USB_PORT_CHANGED | - |
| COMMON_EVENT_USB_DEVICE_ATTACHED | usual.event.hardware.usb.action.USB_DEVICE_ATTACHED | - |
| COMMON_EVENT_USB_DEVICE_DETACHED | usual.event.hardware.usb.action.USB_DEVICE_DETACHED | - |
| COMMON_EVENT_USB_ACCESSORY_ATTACHED | usual.event.hardware.usb.action.USB_ACCESSORY_ATTACHED | - |
......
# Data Share Result Set
The **DataShareResultSet** module provides methods for accessing the result set obtained from the database. You can access the values in the specified rows or the value of the specified data type.
The **DataShareResultSet** module provides APIs for accessing the result set obtained from the database. You can access the values in the specified rows or the value of the specified data type.
>**NOTE**
> **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.
> 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.
>
> The APIs provided by this module are system APIs.
## Modules to Import
......@@ -13,7 +15,7 @@ The **DataShareResultSet** module provides methods for accessing the result set
import DataShareResultSet from '@ohos.data.DataShareResultSet';
```
## How to Use
## Usage
You can call [query()](js-apis-data-dataShare.md#query) to obtain the **DataShareResultSet** object.
......@@ -44,7 +46,10 @@ dataShareHelper.query(uri, da, columns).then((data) => {
});
```
## Attributes
## DataShareResultSet
Provides methods for accessing the result sets generated by querying the database.
### Attributes
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
......@@ -55,7 +60,7 @@ dataShareHelper.query(uri, da, columns).then((data) => {
| rowCount | number | Yes | Number of rows in the result set. |
| isClosed | boolean | Yes | Whether the result set is closed.|
## goToFirstRow
### goToFirstRow
goToFirstRow(): boolean
......@@ -76,7 +81,7 @@ let isGoTOFirstRow = resultSet.goToFirstRow();
console.info('resultSet.goToFirstRow: ' + isGoTOFirstRow);
```
## goToLastRow
### goToLastRow
goToLastRow(): boolean
......@@ -97,7 +102,7 @@ let isGoToLastRow = resultSet.goToLastRow();
console.info('resultSet.goToLastRow: ' + isGoToLastRow);
```
## goToNextRow
### goToNextRow
goToNextRow(): boolean
......@@ -118,7 +123,7 @@ let isGoToNextRow = resultSet.goToNextRow();
console.info('resultSet.goToNextRow: ' + isGoToNextRow);
```
## goToPreviousRow
### goToPreviousRow
goToPreviousRow(): boolean
......@@ -139,7 +144,7 @@ let isGoToPreviousRow = resultSet.goToPreviousRow();
console.info('resultSet.goToPreviousRow: ' + isGoToPreviousRow);
```
## goTo
### goTo
goTo(offset:number): boolean
......@@ -167,7 +172,7 @@ let isGoTo = resultSet.goTo(goToNum);
console.info('resultSet.goTo: ' + isGoTo);
```
## goToRow
### goToRow
goToRow(position: number): boolean
......@@ -179,7 +184,7 @@ Moves to the specified row in the result set.
| **Name**| **Type**| **Mandatory**| Description |
| ---------- | -------- | -------- | ------------------------ |
| position | number | Yes | Destination position to move.|
| position | number | Yes | Destination position to move to.|
**Return value**
......@@ -195,11 +200,11 @@ let isGoToRow = resultSet.goToRow(goToRowNum);
console.info('resultSet.goToRow: ' + isGoToRow);
```
## getBlob
### getBlob
getBlob(columnIndex: number): Uint8Array
Obtains the value in the specified column in the current row as a byte array.
Obtains the value in the form of a byte array based on the specified column and the current row.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
......@@ -224,11 +229,11 @@ let getBlob = resultSet.getBlob(columnIndex);
console.info('resultSet.getBlob: ' + getBlob);
```
## getString
### getString
getString(columnIndex: number): *string*
Obtains the value in the specified column in the current row as a string.
Obtains the value in the form of a string based on the specified column and the current row.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
......@@ -253,11 +258,11 @@ let getString = resultSet.getString(columnIndex);
console.info('resultSet.getString: ' + getString);
```
## getLong
### getLong
getLong(columnIndex: number): number
Obtains the value in the specified column in the current row as a long integer.
Obtains the value in the form of a long integer based on the specified column and the current row.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
......@@ -282,11 +287,11 @@ let getLong = resultSet.getLong(columnIndex);
console.info('resultSet.getLong: ' + getLong);
```
## getDouble
### getDouble
getDouble(columnIndex: number): number
Obtains the value in the specified column in the current row as a double-precision floating-point number.
Obtains the value in the form of a double-precision floating-point number based on the specified column and the current row.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
......@@ -311,7 +316,7 @@ let getDouble = resultSet.getDouble(columnIndex);
console.info('resultSet.getDouble: ' + getDouble);
```
## close
### close
close(): void
......@@ -325,7 +330,7 @@ Closes this result set.
resultSet.close();
```
## getColumnIndex
### getColumnIndex
getColumnIndex(columnName: string): number
......@@ -353,7 +358,7 @@ let getColumnIndex = resultSet.getColumnIndex(ColumnName)
console.info('resultSet.getColumnIndex: ' + getColumnIndex);
```
## getColumnName
### getColumnName
getColumnName(columnIndex: number): *string*
......@@ -381,7 +386,7 @@ let getColumnName = resultSet.getColumnName(columnIndex)
console.info('resultSet.getColumnName: ' + getColumnName);
```
## getDataType
### getDataType
getDataType(columnIndex: number): DataType
......
# Distributed Data Object
The distributedDataObject module provides basic data object management, including creating, querying, deleting, modifying, and subscribing to data objects, and distributed data object collaboration for the same application among multiple devices.
The **distributedDataObject** module provides basic data object management, including creating, querying, deleting, modifying, and subscribing to data objects, and distributed data object collaboration for the same application among multiple devices.
> **NOTE**<br/>
>
......@@ -307,7 +307,7 @@ g_object.save("local").then((result)=>{
### revokeSave<sup>9+</sup>
revokeSave(callback: AsyncCallback&lt;SaveSuccessResponse&gt;): void
revokeSave(callback: AsyncCallback&lt;RevokeSaveSuccessResponse&gt;): void
Revokes the saving operation of a distributed data object. This API uses an asynchronous callback to return the result.
......@@ -334,7 +334,7 @@ g_object.revokeSave((result, data) =>{
### revokeSave<sup>9+</sup>
revokeSave(): Promise&lt;SaveSuccessResponse&gt;
revokeSave(): Promise&lt;RevokeSaveSuccessResponse&gt;
Revokes the saving operation of a distributed data object. This API uses a promise to return the result.
......
......@@ -174,6 +174,42 @@ Obtains all display objects. This API uses a promise to return the result.
});
```
## display.hasPrivateWindow<sup>9+</sup>
hasPrivateWindow(displayId: number): boolean
Checks whether there is a visible privacy window on a display. The privacy window can be set by calling **[setPrivacyMode](js-apis-window.md#setprivacymode7)**. The content in the privacy window cannot be captured or recorded.
This is a system API.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------------------------- | ---- |----------|
| id | number | Yes | ID of the display.|
**Return value**
| Type | Description |
| -------------------------------- |-----------------------------------------------------------------------|
|boolean | Whether there is a visible privacy window on the display.<br>The value **true** means that there is a visible privacy window on the display, and **false** means the opposite.<br>|
**Example**
```js
var ret = display.hasPrivateWindow(displayClass.id);
if (ret == undefined) {
console.log("HasPrivateWindow undefined.");
}
if (ret) {
console.log("HasPrivateWindow.");
} else if (!ret) {
console.log("Don't HasPrivateWindow.");
}
```
## display.on('add'|'remove'|'change')
on(type: 'add'|'remove'|'change', callback: Callback&lt;number&gt;): void
......
......@@ -19,8 +19,6 @@ getDistributedAccountAbility(): DistributedAccountAbility
Obtains a **DistributedAccountAbility** instance.
**System capability**: SystemCapability.Account.OsAccount
- Return value
| Type| Description|
| -------- | -------- |
......@@ -43,7 +41,7 @@ Obtains distributed account information. This API uses an asynchronous callback
**System capability**: SystemCapability.Account.OsAccount
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC
- Parameters
| Name| Type| Mandatory| Description|
......@@ -68,7 +66,7 @@ Obtains distributed account information. This API uses a promise to return the r
**System capability**: SystemCapability.Account.OsAccount
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC
- Return value
| Type| Description|
......
......@@ -16,22 +16,23 @@ import image from '@ohos.multimedia.image';
createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise\<PixelMap>
Creates a **PixelMap** object. This API uses a promise to return the result.
Creates a **PixelMap** object with the default BGRA_8888 format and pixel properties specified. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Image.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ |
| colors | ArrayBuffer | Yes | Color array in BGRA_8888 format. |
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------------ | ---- | ---------------------------------------------------------------- |
| colors | ArrayBuffer | Yes | Color array in BGRA_8888 format. |
| options | [InitializationOptions](#initializationoptions8) | Yes | Pixel properties, including the alpha type, size, scale mode, pixel format, and editable.|
**Return value**
| Type | Description |
| -------------------------------- | -------------- |
| Promise\<[PixelMap](#pixelmap7)> | Promise used to return the **PixelMap** object.|
| Type | Description |
| -------------------------------- | ----------------------------------------------------------------------- |
| Promise\<[PixelMap](#pixelmap7)> | Promise used to return the **PixelMap** object.<br>If the size of the created pixel map exceeds that of the original image, the pixel map size of the original image is returned.|
**Example**
......@@ -48,7 +49,7 @@ image.createPixelMap(color, opts)
createPixelMap(colors: ArrayBuffer, options: InitializationOptions, callback: AsyncCallback\<PixelMap>): void
Creates a **PixelMap** object. This API uses an asynchronous callback to return the result.
Creates a **PixelMap** object with the default BGRA_8888 format and pixel properties specified. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Image.Core
......@@ -91,7 +92,7 @@ Provides APIs to read or write image pixel map data and obtain image pixel map i
readPixelsToBuffer(dst: ArrayBuffer): Promise\<void>
Reads image pixel map data and writes the data to an **ArrayBuffer**. This API uses a promise to return the result.
Reads image pixel map data and writes the data to an **ArrayBuffer**. This API uses a promise to return the result. If the pixel map is created in the BGRA_8888 format, the pixel map data read is the same as the original data.
**System capability**: SystemCapability.Multimedia.Image.Core
......@@ -122,7 +123,7 @@ pixelmap.readPixelsToBuffer(readBuffer).then(() => {
readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\<void>): void
Reads image pixel map data and writes the data to an **ArrayBuffer**. This API uses an asynchronous callback to return the result.
Reads image pixel map data and writes the data to an **ArrayBuffer**. This API uses an asynchronous callback to return the result. If the pixel map is created in the BGRA_8888 format, the pixel map data read is the same as the original data.
**System capability**: SystemCapability.Multimedia.Image.Core
......@@ -1008,7 +1009,7 @@ const imageSourceApi = image.createImageSource(fd);
createImageSource(buf: ArrayBuffer): ImageSource
Creates an **ImageSource** instance based on the buffer.
Creates an **ImageSource** instance based on the buffers.
**System capability**: SystemCapability.Multimedia.Image.ImageSource
......@@ -1029,7 +1030,7 @@ const imageSourceApi = image.createImageSource(buf);
createImageSource(buf: ArrayBuffer, options: SourceOptions): ImageSource
Creates an **ImageSource** instance based on the buffer.
Creates an **ImageSource** instance based on the buffers.
**System capability**: SystemCapability.Multimedia.Image.ImageSource
......@@ -1057,7 +1058,7 @@ const imageSourceApi = image.createImageSource(data);
CreateIncrementalSource(buf: ArrayBuffer): ImageSource
Creates an **ImageSource** instance in incremental mode based on the buffer.
Creates an **ImageSource** instance in incremental mode based on the buffers.
**System capability**: SystemCapability.Multimedia.Image.ImageSource
......@@ -1084,7 +1085,7 @@ const imageSourceApi = image.CreateIncrementalSource(buf);
CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource
Creates an **ImageSource** instance in incremental mode based on the buffer.
Creates an **ImageSource** instance in incremental mode based on the buffers.
**System capability**: SystemCapability.Multimedia.Image.ImageSource
......@@ -2246,7 +2247,7 @@ Describes image properties.
## PropertyKey<sup>7+</sup>
Describes the exchangeable image file format (Exif) information of an image.
Describes the exchangeable image file format (EXIF) information of an image.
**System capability**: SystemCapability.Multimedia.Image.Core
......@@ -2322,7 +2323,7 @@ Enumerates the response codes returned upon build errors.
| ERR_IMAGE_CROP | 62980109 | An error occurs during image cropping. |
| ERR_IMAGE_SOURCE_DATA | 62980110 | The image source data is incorrect. |
| ERR_IMAGE_SOURCE_DATA_INCOMPLETE | 62980111 | The image source data is incomplete. |
| ERR_IMAGE_MISMATCHED_FORMAT | 62980112 | The image format does not match. |
| ERR_IMAGE_MISMATCHED_FORMAT | 62980112 | The image formats do not match. |
| ERR_IMAGE_UNKNOWN_FORMAT | 62980113 | Unknown image format. |
| ERR_IMAGE_SOURCE_UNRESOLVED | 62980114 | The image source is not parsed. |
| ERR_IMAGE_INVALID_PARAMETER | 62980115 | Invalid image parameter. |
......@@ -2338,4 +2339,4 @@ Enumerates the response codes returned upon build errors.
| ERR_IMAGE_READ_PIXELMAP_FAILED | 62980246 | Failed to read the pixel map. |
| ERR_IMAGE_WRITE_PIXELMAP_FAILED | 62980247 | Failed to write the pixel map. |
| ERR_IMAGE_PIXELMAP_NOT_ALLOW_MODIFY | 62980248 | Modification to the pixel map is not allowed. |
| ERR_IMAGE_CONFIG_FAILED | 62980259 | The software parameter setting is incorrect. |
| ERR_IMAGE_CONFIG_FAILED | 62980259 | The configuration is incorrect. |
# Input Method Framework
> **NOTE**
The **inputMethod** module provides an input method framework, which can be used to hide the keyboard, obtain the list of installed input methods, display the dialog box for input method selection, and more.
> **NOTE**
>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -8,14 +10,14 @@
## Modules to Import
```
import inputMethod from '@ohos.inputMethod';
import inputMethod from '@ohos.inputmethod';
```
## inputMethod<sup>8+</sup>
Provides the constants.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
**System capability**: SystemCapability.MiscServices.InputMethodFramework
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
......@@ -26,7 +28,7 @@ Provides the constants.
Describes the input method application attributes.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
**System capability**: SystemCapability.MiscServices.InputMethodFramework
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
......@@ -37,15 +39,15 @@ Describes the input method application attributes.
getInputMethodController(): InputMethodController
Obtains an [InputMethodController](#InputMethodController) instance.
Obtains an **[InputMethodController](#inputmethodcontroller)** instance.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Return value**
| Type| Description|
| -------- | -------- |
| [InputMethodController](#InputMethodController) | Returns the current **InputMethodController** instance.|
| Type | Description |
| ----------------------------------------- | ---------------------------- |
| [InputMethodController](#inputmethodcontroller) | Returns the current **InputMethodController** instance.|
**Example**
......@@ -57,25 +59,74 @@ Obtains an [InputMethodController](#InputMethodController) instance.
getInputMethodSetting(): InputMethodSetting
Obtains an [InputMethodSetting](#InputMethodSetting) instance.
Obtains an **[InputMethodSetting](#inputmethodsetting8)** instance.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Return value**
| Type | Description |
| ----------------------------------------- | ---------------------------- |
| [InputMethodSetting](#InputMethodSetting) | Returns the current **InputMethodSetting** instance.|
| [InputMethodSetting](#inputmethodsetting8) | Returns the current **InputMethodSetting** instance.|
**Example**
```js
var InputMethodSetting = inputMethod.getInputMethodSetting();
```
## inputMethod.switchInputMethod<sup>9+</sup>
switchInputMethod(target: InputmethodProperty, callback: AsyncCallback&lt;boolean&gt;): void;
Switches to another input method. This API uses an asynchronous callback to return the result. This API can be used only in the stage model.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
|target | [InputmethodProperty](#inputmethodproperty8) | Yes| Input method to switch to.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the execution result. |
**Example**
```js
inputMethod.switchInputMethod({packageName:"com.ohos.inputApp", methodId:"InputDemoService"}).then(res => {
prompt.showToast({message:"Input method switched." + this.imeList[this.flag].packageName, duration: 200});
});
```
## inputMethod.switchInputMethod<sup>9+</sup>
switchInputMethod(target: InputmethodProperty): Promise&lt;boolean&gt;
Switches to another input method. This API uses a promise to return the result. This API can be used only in the stage model.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
|target | [InputmethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.|
**Return value**
| Type | Description |
| ----------------------------------------- | ---------------------------- |
| Promise\<boolean> | Promise used to return the execution result. |
**Example**
```js
inputMethod.switchInputMethod({packageName:"com.ohos.inputApp", methodId:"InputDemoService"}).then(res => {
prompt.showToast({message:"Input method switched." + this.imeList[this.flag].packageName, duration: 200});
});
```
## InputMethodController
In the following API examples, you must first use [getInputMethodController](#getInputMethodController) to obtain an **InputMethodController** instance, and then call the APIs using the obtained instance.
In the following API examples, you must first use **[getInputMethodController](#inputmethodgetinputmethodcontroller)** to obtain an **InputMethodController** instance, and then call the APIs using the obtained instance.
### stopInput
......@@ -83,7 +134,7 @@ stopInput(callback: AsyncCallback&lt;boolean&gt;): void
Hides the keyboard. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
......@@ -105,13 +156,13 @@ stopInput(): Promise&lt;boolean&gt;
Hides the keyboard. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return whether the keyboard is successfully hidden.|
| Promise&lt;boolean&gt; | Promise used to return whether the keyboard is successfully hidden. |
**Example**
......@@ -123,7 +174,7 @@ Hides the keyboard. This API uses an asynchronous callback to return the result.
## InputMethodSetting<sup>8+</sup>
In the following API examples, you must first use [getInputMethodSetting](#getInputMethodSetting) to obtain an **InputMethodSetting** instance, and then call the APIs using the obtained instance.
In the following API examples, you must first use **[getInputMethodSetting](#inputmethodgetinputmethodcontroller)** to obtain an **InputMethodSetting** instance, and then call the APIs using the obtained instance.
### listInputMethod
......@@ -131,13 +182,12 @@ listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;)
Obtains the list of installed input methods. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------------------- | ---- | ---------------------- |
| callback | Array<[InputMethodProperty](#InputMethodProperty)> | Yes | Callback used to return the list of installed input methods.|
| callback | Array<[InputMethodProperty](#inputmethodproperty8)> | Yes | Callback used to return the list of installed input methods.|
**Example**
......@@ -156,13 +206,12 @@ listInputMethod(): Array&lt;InputMethodProperty&gt;
Obtains the list of installed input methods. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Return value**
| Type | Description |
| ----------------------------------------------------------- | ---------------------- |
| Promise<Array<[InputMethodProperty](#InputMethodProperty)>> | Promise used to return the list of installed input methods.|
| Promise<Array<[InputMethodProperty](#inputmethodproperty8)>> | Promise used to return the list of installed input methods. |
**Example**
......@@ -180,15 +229,16 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void
Displays a dialog box for selecting an input method. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
**System capability**: SystemCapability.MiscServices.InputMethodFramework
- Parameters
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.|
**Example**
```js
InputMethodSetting.displayOptionalInputMethod(()=>{
console.info('displayOptionalInputMethod is called');
......@@ -201,16 +251,16 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono
Displays a dialog box for selecting an input method. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
| Promise&lt;void&gt; | Promise used to return the execution result. |
**Example**
```js
InputMethodSetting.displayOptionalInputMethod();
```
\ No newline at end of file
```
......@@ -2278,7 +2278,7 @@ Describes options for fetching media files.
| Name | Type | Readable| Writable| Mandatory| Description |
| ----------------------- | ------------------- | ---- | ---- | ---- | ------------------------------------------------------------ |
| selections | string | Yes | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey8) are used as the column names of the conditions. Example:<br>selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR' +mediaLibrary.FileKey.MEDIA_TYPE + '= ?',|
| selections | string | Yes | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey8) are used as the column names of the conditions. Example:<br>selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR ' +mediaLibrary.FileKey.MEDIA_TYPE + '= ?', |
| selectionArgs | Array&lt;string&gt; | Yes | Yes | Yes | Value of the condition, which corresponds to the value of the condition column in **selections**.<br>Example:<br>selectionArgs: [mediaLibrary.MediaType.IMAGE.toString(), mediaLibrary.MediaType.VIDEO.toString()], |
| order | string | Yes | Yes | No | Sorting mode of the search results, which can be ascending or descending. The enumerated values in [FileKey](#filekey8) are used as the columns for sorting the search results. Example:<br>Ascending: order: mediaLibrary.FileKey.DATE_ADDED + " AESC"<br>Descending: order: mediaLibrary.FileKey.DATE_ADDED + " DESC"|
| uri<sup>8+</sup> | string | Yes | Yes | No | File URI. |
......
# Settings
This module provides APIs for setting data items.
The **Settings** module provides APIs for setting data items.
> **NOTE**
>
......
......@@ -19,34 +19,34 @@ Components support dynamic rotation, translation, and scaling effects. These eff
| animation-direction<sup>6+</sup> | string | normal | Mode of playing the animation. <br>- **normal**: Plays the animation in forward loop mode. <br>- **reverse**: Plays the animation in reverse loop mode. <br>- **alternate**: Plays the animation in alternating loop mode. When the animation is played for an odd number of times, the playback is in forward direction. When the animation is played for an even number of times, the playback is in backward direction. <br>- **alternate-reverse**: Plays the animation in reverse-alternating loop mode. When the animation is played for an odd number of times, the playback is in backward direction. When the animation is played for an even number of times, the playback is in forward direction. |
| animation-fill-mode | string | none | Start and end styles of the animation <br>- **none**: No style is applied to the target before or after the animation is executed. <br>- **forwards**: The target keeps the state at the end of the animation (defined in the last key frame) after the animation is executed. <br>- **backwards**<sup>6+</sup>: The animation uses the value defined in the first key frame during the **animation-delay**. When **animation-direction** is set to **normal** or **alternate**, the value in the **from** key frame is used. When **animation-direction** is set to **reverse** or **alternate-reverse**, the value in the **to** key frame is used.. <br>- **both**<sup>6+</sup>: The animation follows the **forwards** and **backwards** rules. |
| animation-play-state<sup>6+</sup> | string | running | Current state of the animation. <br>- **paused**: paused <br>- **running**: playing |
| transition<sup>6+</sup> | string | all 0 ease 0 | Transition effect when the component status is switched. The following four attributes can be set through the <br>- **transition** attribute: **transition-property**: name of the CSS property for setting the transition effect. Currently, the width, height, and background color are supported. <br>- **transition-duration**: duration required for completing the transition effect, in seconds. <br>- **transition-timing-function**: time curve of the transition effect. The curve provided by the style animation is supported. <br>- **transition-delay**: delay for starting the transition effect, in seconds. |
| transition<sup>6+</sup> | string | all 0 ease 0 | Transition effect when the component status is switched. The following four attributes can be set through the **transition** attribute.<br>- **transition-property**: name of the CSS property for setting the transition effect. Currently, the width, height, and background color are supported. <br>- **transition-duration**: duration required for completing the transition effect, in seconds. <br>- **transition-timing-function**: time curve of the transition effect. The curve provided by the style animation is supported. <br>- **transition-delay**: delay for starting the transition effect, in seconds. |
**Table 1** transform
| Name | Type | Description |
| ------------- | -------------------------------------- | ------------------------------------------------------------ |
| none<sup>6+</sup> | - | No conversion is performed. |
| matrix<sup>6+</sup> | \<number> | A matrix of six values, which represent scaleX, skewY, skewX, scaleY, translateX, translateY. |
| matrix3d<sup>6+</sup> | \<number> | A 4x4 matrix of 16 values. |
| translate | \<length> \| \<percent> | Moves an element along the x-axis and y-axis. |
| translate3d<sup>6+</sup> | \<length> \| \<percent> | Three input parameters, indicating the translation distance of the x-axis, y-axis, and z-axis, respectively. |
| none<sup>6+</sup> | - | Does not perform any transformation. |
| matrix<sup>6+</sup> | \<number> | Defines a matrix of six values, which represent scaleX, skewY, skewX, scaleY, translateX, translateY. |
| matrix3d<sup>6+</sup> | \<number> | Defines a 4x4 matrix of 16 values. |
| translate | \<length> \| \<percent> | Moves an element in 2D space. |
| translate3d<sup>6+</sup> | \<length> \| \<percent> | Moves an element in 3D space. There are three input parameters, indicating the translation distance of the x-axis, y-axis, and z-axis, respectively. |
| translateX | \<length> \| \<percent> | Moves an element along the x-axis. |
| translateY | \<length> \| \<percent> | Moves an element along the y-axis. |
| translateZ<sup>6+</sup> | \<length> \| \<percent> | Translation distance of the z-axis |
| scale | \<number> | Changes the size of an element. You need to set the target width and height on the x-axis and y-axis. |
| scale3d<sup>6+</sup> | \<number> | Three input parameters, indicating the scale ratio of the x-axis, y-axis, and z-axis, respectively. |
| scaleX | \<number> | Changes the element width. |
| scaleY | \<number> | Changes the element height. |
| scaleZ<sup>6+</sup> | \<number> | Scale ratio of the z-axis. |
| rotate | \<deg> \| \<rad> \| \<grad><sup>6+</sup> \| \<turn><sup>6+</sup> | Rotates an element. You can set the element to rotate around its x-axis or y-axis. |
| rotate3d<sup>6+</sup> | \<deg> \| \<rad> \| \<grad> \| \<turn> | Four input parameters: The first three parameters are the rotation vectors of the x-axis, y-axis, and z-axis, and the fourth parameter is the rotation angle. |
| translateZ<sup>6+</sup> | \<length> \| \<percent> | Moves an element along the z-axis. |
| scale | \<number> | Resizes an element in 2D space. You need to set the target width and height on the x-axis and y-axis. |
| scale3d<sup>6+</sup> | \<number> | Resizes an element in 3D space. There are three input parameters, indicating the scale ratio of the x-axis, y-axis, and z-axis, respectively. |
| scaleX | \<number> | Resizes an element along the x-axis. |
| scaleY | \<number> | Resizes an element along the y-axis. |
| scaleZ<sup>6+</sup> | \<number> | Resizes an element along the z-axis. |
| rotate | \<deg> \| \<rad> \| \<grad><sup>6+</sup> \| \<turn><sup>6+</sup> | Rotates an element in 2D space. You can set the element to rotate around its x-axis or y-axis. |
| rotate3d<sup>6+</sup> | \<deg> \| \<rad> \| \<grad> \| \<turn> | Rotates an element in 3D space. There are four input parameters: The first three parameters are the rotation vectors of the x-axis, y-axis, and z-axis, and the fourth parameter is the rotation angle. |
| rotateX | \<deg> \| \<rad> \| \<grad><sup>6+</sup> \| \<turn><sup>6+</sup> | Rotates an element around the x-axis. |
| rotateY | \<deg> \| \<rad> \| \<grad><sup>6+</sup> \| \<turn><sup>6+</sup> | Rotates an element around the y-axis. |
| rotateZ<sup>6+</sup> | \<deg> \| \<rad> \| \<grad> \| \<turn> | Rotation angle in the z-axis direction. |
| skew<sup>6+</sup> | \<deg> \| \<rad> \| \<grad> \| \<turn> | Two input parameters, indicating the 2D skew angle of the x-axis and y-axis, respectively. |
| skewX<sup>6+</sup> | \<deg> \| \<rad> \| \<grad> \| \<turn> | 2D skew angle of the x-axis. |
| skewY<sup>6+</sup> | \<deg> \| \<rad> \| \<grad> \| \<turn> | 2D skew angle of the y-axis. |
| perspective<sup>6+</sup> | \<number> | Distance from the lens to the element's surface in the 3D perspective scenario. |
| rotateZ<sup>6+</sup> | \<deg> \| \<rad> \| \<grad> \| \<turn> | Rotates an element around the z-axis. |
| skew<sup>6+</sup> | \<deg> \| \<rad> \| \<grad> \| \<turn> | Skews an element in 2D space. There are two input parameters, indicating the 2D skew angle of the x-axis and y-axis, respectively. |
| skewX<sup>6+</sup> | \<deg> \| \<rad> \| \<grad> \| \<turn> | Skews an element along the x-axis in 2D space. |
| skewY<sup>6+</sup> | \<deg> \| \<rad> \| \<grad> \| \<turn> | Skews an element along the y-axis in 2D space. |
| perspective<sup>6+</sup> | \<number> | Sets the distance from the lens to the element's surface in the 3D perspective scenario. |
**Table 2** @keyframes
......@@ -56,8 +56,8 @@ Components support dynamic rotation, translation, and scaling effects. These eff
| opacity | number | 1 | Opacity value applied to the component after the animation is played. The value ranges from **0** to **1**. The default value is **1**. |
| width | \<length> | - | Width value applied to the component after the animation is played. |
| height | \<length> | - | Height value applied to the component after the animation is played. |
| transform | string | - | Transformation type applied to a component. For details, see **transform**. |
| background-position<sup>6+</sup> | string \| \<percentage> \| \<length> string \| \<percentage> \| \<length> | 50% 50% | Set the background image for a window. The unit can be percentage or px. The first value indicates the horizontal position, and the second value indicates the vertical position. If only one value is specified, the other one is **50%**. The available values for the first string are **left**, **center**, and **right**. The available values for the second string are **top**, **center**, and **bottom**.<br>Example:<br>- background-position: 200px 30%<br>- background-position: 100px top<br>- background-position: center center |
| transform | string | - | Transformation type applied to the component. For details, see **transform**. |
| background-position<sup>6+</sup> | string \| \<percentage> \| \<length> string \| \<percentage> \| \<length> | 50% 50% | Position of the background image. The unit can be percentage or px. The first value indicates the horizontal position, and the second value indicates the vertical position. If only one value is specified, the other one is **50%**. The available values for the first string are **left**, **center**, and **right**. The available values for the second string are **top**, **center**, and **bottom**.<br>Example:<br>- background-position: 200px 30%<br>- background-position: 100px top<br>- background-position: center center |
If there is no default value for when an animation will start or end, use **from** and **to** to specify the start and end of the display. You can use a percentage value to specify an intermediate state of the animation.<sup>6+</sup> The following is an example:
......@@ -211,7 +211,8 @@ export default {
> **NOTE**
>
> The @keyframes rule with **from** and **to** defined cannot be dynamically bound to an element.
> The following figure shows the meanings of end and start in the steps function.
> The @keyframes rule with **from** and **to** defined cannot be dynamically bound to an element.
>
> ![img](figures/en-us_image_0000001127125220.png)
\ No newline at end of file
> The following figure shows the meanings of **end** and **start** in the **steps** function.
>
> ![en-us_image_0000001127125220](figures/en-us_image_0000001127125220.png)
\ No newline at end of file
......@@ -58,29 +58,44 @@ struct CheckboxExample {
build() {
Scroll() {
Column() {
CheckboxGroup({group : 'checkboxGroup'})
.selectedColor(0xed6f21)
.onChange((itemName:CheckboxGroupResult) => {
console.info("TextPicker::dialogResult is" + JSON.stringify(itemName))
})
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
.select(true)
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox1 change is' + value)
})
Checkbox({ name: 'checkbox2', group: 'checkboxGroup' })
.select(false)
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox2 change is' + value)
})
Checkbox({ name: 'checkbox3', group: 'checkboxGroup' })
.select(true)
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox3 change is' + value)
})
Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
CheckboxGroup({ group: 'checkboxGroup' })
.selectedColor(0xed6f21)
.onChange((itemName: CheckboxGroupResult) => {
console.info("TextPicker::dialogResult is" + JSON.stringify(itemName))
})
Text('select all').fontSize(20)
}
Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
.select(true)
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox1 change is' + value)
})
Text('Checkbox1').fontSize(20)
}
Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
Checkbox({ name: 'checkbox2', group: 'checkboxGroup' })
.select(false)
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox2 change is' + value)
})
Text('Checkbox2').fontSize(20)
}
Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
Checkbox({ name: 'checkbox3', group: 'checkboxGroup' })
.select(true)
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox3 change is' + value)
})
Text('Checkbox3').fontSize(20)
}
}
}
}
......
# DataPanel
> **NOTE**<br>
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
The **&lt;DataPanel&gt;** component displays proportions in a chart.
The **\<DataPanel>** component displays proportions in a chart.
> **NOTE**
>
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
## Required Permissions
......@@ -15,7 +14,7 @@ None
## Child Components
None
Not supported
## APIs
......@@ -23,24 +22,25 @@ None
DataPanel(value:{values: number[], max?: number, type?: DataPanelType})
- Parameters
| Name | Type | Mandatory | Default Value | Description |
| Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- |
| values | number[] | Yes | - | Value list. A maximum of nine values are supported. |
| max | number | No | 100 | - When set to a value greater than 0, this parameter indicates the maximum value in the **values** list.<br/>- When set to a value equal to or smaller than 0, this parameter indicates the sum of values in the **values** list. The values are displayed in proportion. |
| type<sup>8+</sup> | DataPanelType | No | DataPanelType.Circle | Type of the data panel. |
| values | number[] | Yes | - | Value list. A maximum of nine values are supported. |
| max | number | No | 100 | - When set to a value greater than 0, this parameter indicates the maximum value in the **values** list.<br/>- When set to a value equal to or smaller than 0, this parameter indicates the sum of values in the **values** list. The values are displayed in proportion. |
| type<sup>8+</sup> | DataPanelType | No | DataPanelType.Circle | Type of the data panel. |
- DataPanelType enums
| Name | Description |
| Name | Description |
| -------- | -------- |
| Line | Line data panel. |
| Line | Line data panel. |
| Circle | Circle data panel. |
## Example
```
```ts
// xxx.ets
@Entry
@Component
struct DataPanelExample {
......
# Stepper
The **\<Stepper>** component provides a step navigator.
> **NOTE**<br>
> **NOTE**
>
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
The **&lt;Stepper&gt;** component provides a step navigator.
## Required Permissions
......@@ -15,7 +16,7 @@ None
## Child Components
Only the child component **&lt;[StepperItem](ts-basic-components-stepperitem.md)&gt;** is supported.
Only the child component **\<[StepperItem](ts-basic-components-stepperitem.md)>** is supported.
## APIs
......@@ -24,9 +25,9 @@ Stepper(value?: { index?: number })
- Parameters
| Name | Type | Mandatory | Default Value | Description |
| Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- |
| index | number | No | 0 | Index of the **&lt;StepperItem&gt;** that is currently displayed. |
| index | number | No | 0 | Index of the **\<StepperItem>** that is currently displayed. |
## Attributes
......@@ -36,18 +37,18 @@ None
## Events
| Name | Description |
| Name | Description |
| -------- | -------- |
| onFinish(callback: () =&gt; void) | Invoked when the **nextLabel** of the last **&lt;StepperItem&gt;** in the **&lt;Stepper&gt;** is clicked. |
| onSkip(callback: () =&gt; void) | Invoked when the current **&lt;StepperItem&gt;** is **ItemState.Skip** and the **nextLabel** is clicked. |
| onChange(callback: (prevIndex?: number, index?: number) =&gt; void) | Invoked when the text button on the left or right is clicked to switch between steps.<br/>- **prevIndex**: index of the step page before the switching.<br/>- **index**: index of the step page after the switching, that is, index of the previous or next page. |
| onFinish(callback: () =&gt; void) | Invoked when the **nextLabel** of the last **\<StepperItem>** in the **\<Stepper>** is clicked. |
| onSkip(callback: () =&gt; void) | Invoked when the current **\<StepperItem>** is **ItemState.Skip** and the **nextLabel** is clicked. |
| onChange(callback: (prevIndex?: number, index?: number) =&gt; void) | Invoked when the text button on the left or right is clicked to switch between steps.<br/>- **prevIndex**: index of the step page before the switching.<br/>- **index**: index of the step page after the switching, that is, index of the previous or next page. |
## Example
```
```ts
// xxx.ets
@Entry
@Component
struct StepperExample {
......@@ -65,47 +66,50 @@ struct StepperExample {
.fontColor(Color.Blue)
.width(200)
.lineHeight(50)
.margin({top:250})
.margin({ top: 250 })
}
.nextLabel('')
.position({x: '35%', y: 0})
.position({ x: '35%', y: 0 })
StepperItem() {
Text('Page Two')
.fontSize(35)
.fontColor(Color.Blue)
.width(200)
.lineHeight(50)
.margin({top:250})
.onClick(()=>{
.margin({ top: 250 })
.onClick(() => {
this.firstState = this.firstState === ItemState.Skip ? ItemState.Normal : ItemState.Skip
})
}
.nextLabel('Next')
.prevLabel('Previous')
.status(this.firstState)
.position({x: '35%', y: 0})
.position({ x: '35%', y: 0 })
StepperItem() {
Text('Page Three')
.fontSize(35)
.fontColor(Color.Blue)
.width(200)
.lineHeight(50)
.margin({top:250})
.onClick(()=>{
.margin({ top: 250 })
.onClick(() => {
this.secondState = this.secondState === ItemState.Waiting ? ItemState.Normal : ItemState.Waiting
})
}
.position({x: '35%', y: 0})
.position({ x: '35%', y: 0 })
.status(this.secondState)
StepperItem() {
Text('Page four')
.fontSize(35)
.fontColor(Color.Blue)
.width(200)
.lineHeight(50)
.margin({top:250})
.margin({ top: 250 })
}
.position({x: '35%', y: 0})
.position({ x: '35%', y: 0 })
.nextLabel('Finish')
}
.onFinish(() => {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册