未验证 提交 4a45fdb5 编写于 作者: O openharmony_ci 提交者: Gitee

!21849 翻译完成 21550+21149+20673+20609:剪贴板资料优化+【screenlock】示例规范整改

Merge pull request !21849 from ester.zhou/TR-21550
...@@ -50,7 +50,7 @@ Creates a **PasteData** object of a custom type. ...@@ -50,7 +50,7 @@ Creates a **PasteData** object of a custom type.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| mimeType | string | Yes| MIME type of custom data.| | mimeType | string | Yes| MIME type of custom data. The value can a predefined MIME type listed in [Constants](#constants), including HTML, WANT, plain text, URI, and pixel map, or a custom MIME type.|
| value | [ValueType](#valuetype9) | Yes| Content of custom data.| | value | [ValueType](#valuetype9) | Yes| Content of custom data.|
**Return value** **Return value**
...@@ -59,13 +59,21 @@ Creates a **PasteData** object of a custom type. ...@@ -59,13 +59,21 @@ Creates a **PasteData** object of a custom type.
| -------- | -------- | | -------- | -------- |
| [PasteData](#pastedata) | **PasteData** object.| | [PasteData](#pastedata) | **PasteData** object.|
**Example** **Example 1**
```js ```js
let dataXml = new ArrayBuffer(256); let dataXml = new ArrayBuffer(256);
let pasteData = pasteboard.createData('app/xml', dataXml); let pasteData = pasteboard.createData('app/xml', dataXml);
```
**Example 2**
```js
let dataText = 'hello';
let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, dataText);
``` ```
## pasteboard.createRecord<sup>9+</sup> ## pasteboard.createRecord<sup>9+</sup>
createRecord(mimeType: string, value: ValueType):PasteDataRecord; createRecord(mimeType: string, value: ValueType):PasteDataRecord;
...@@ -78,7 +86,7 @@ Creates a **PasteDataRecord** object of the custom type. ...@@ -78,7 +86,7 @@ Creates a **PasteDataRecord** object of the custom type.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| mimeType | string | Yes| MIME type of custom data.| | mimeType | string | Yes| MIME type of custom data. The value can a predefined MIME type listed in [Constants](#constants), including HTML, WANT, plain text, URI, and pixel map, or a custom MIME type. |
| value | [ValueType](#valuetype9) | Yes| Content of custom data.| | value | [ValueType](#valuetype9) | Yes| Content of custom data.|
**Return value** **Return value**
...@@ -87,13 +95,20 @@ Creates a **PasteDataRecord** object of the custom type. ...@@ -87,13 +95,20 @@ Creates a **PasteDataRecord** object of the custom type.
| -------- | -------- | | -------- | -------- |
| [PasteDataRecord](#pastedatarecord7) | New **PasteDataRecord** object of the custom type.| | [PasteDataRecord](#pastedatarecord7) | New **PasteDataRecord** object of the custom type.|
**Example** **Example 1**
```js ```js
let dataXml = new ArrayBuffer(256); let dataXml = new ArrayBuffer(256);
let pasteDataRecord = pasteboard.createRecord('app/xml', dataXml); let pasteDataRecord = pasteboard.createRecord('app/xml', dataXml);
``` ```
**Example 2**
```js
let dataUri = 'dataability:///com.example.myapplication1/user.txt';
let record = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_URI, dataUri);
```
## pasteboard.getSystemPasteboard ## pasteboard.getSystemPasteboard
getSystemPasteboard(): SystemPasteboard getSystemPasteboard(): SystemPasteboard
...@@ -751,27 +766,53 @@ Sets a [PasteDataProperty](#pastedataproperty7) object. ...@@ -751,27 +766,53 @@ Sets a [PasteDataProperty](#pastedataproperty7) object.
let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_HTML, 'application/xml'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_HTML, 'application/xml');
let prop = pasteData.getProperty(); let prop = pasteData.getProperty();
prop.shareOption = pasteboard.ShareOption.INAPP; prop.shareOption = pasteboard.ShareOption.INAPP;
prop.additions['TestOne'] = 123; prop.additions['TestOne'] = {'Test' : 123};
prop.additions['TestTwo'] = {'Test' : 'additions'}; prop.additions['TestTwo'] = {'Test' : 'additions'};
prop.tag = 'TestTag'; prop.tag = 'TestTag';
pasteData.setProperty(prop); pasteData.setProperty(prop);
``` ```
The **localOnly** and **shareOption** attributes of [PasteDataProperty](#pastedataproperty7) are mutually exclusive. The **shareOption** attribute prevails, and its value affect the value of **localOnly**. The **localOnly** and **shareOption** attributes of [PasteDataProperty](#pastedataproperty7) are mutually exclusive. The **shareOption** attribute prevails, and its value affect the value of **localOnly**.
```js ```js
prop.shareOption = pasteboard.ShareOption.INAPP; (async function() {
prop.localOnly = false; let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'hello');
pasteData.setProperty(prop); let prop = pasteData.getProperty();
pasteData.localOnly //true prop.shareOption = pasteboard.ShareOption.INAPP;
prop.localOnly = false;
pasteData.setProperty(prop);
let systemPasteboard = pasteboard.getSystemPasteboard();
await systemPasteboard.setData(pasteData).then(async () => {
console.info('Succeeded in setting PasteData.');
await systemPasteboard.getData().then(pasteData => {
let prop = pasteData.getProperty();
prop.localOnly //true
});
});
prop.shareOption = pasteboard.ShareOption.LOCALDEVICE; prop.shareOption = pasteboard.ShareOption.LOCALDEVICE;
prop.localOnly = false; prop.localOnly = false;
pasteData.setProperty(prop); pasteData.setProperty(prop);
pasteData.localOnly //true
prop.shareOption = pasteboard.ShareOption.CROSSDEVICE; await systemPasteboard.setData(pasteData).then(async () => {
prop.localOnly = true; console.info('Succeeded in setting PasteData.');
pasteData.setProperty(prop); await systemPasteboard.getData().then(pasteData => {
pasteData.localOnly //false let prop = pasteData.getProperty();
prop.localOnly; //true
});
});
prop.shareOption = pasteboard.ShareOption.CROSSDEVICE;
prop.localOnly = true;
pasteData.setProperty(prop);
await systemPasteboard.setData(pasteData).then(async () => {
console.info('Succeeded in setting PasteData.');
await systemPasteboard.getData().then(pasteData => {
let prop = pasteData.getProperty();
prop.localOnly; //false
});
});
})()
``` ```
...@@ -1301,7 +1342,7 @@ For details about the error codes, see [Pasteboard Error Codes](../errorcodes/er ...@@ -1301,7 +1342,7 @@ For details about the error codes, see [Pasteboard Error Codes](../errorcodes/er
**Example** **Example**
```js ```js
let pasteData = pasteboard.createPlainTextData('content'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'content');
let systemPasteboard = pasteboard.getSystemPasteboard(); let systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setData(pasteData, (err, data) => { systemPasteboard.setData(pasteData, (err, data) => {
if (err) { if (err) {
...@@ -1344,7 +1385,7 @@ For details about the error codes, see [Pasteboard Error Codes](../errorcodes/er ...@@ -1344,7 +1385,7 @@ For details about the error codes, see [Pasteboard Error Codes](../errorcodes/er
**Example** **Example**
```js ```js
let pasteData = pasteboard.createPlainTextData('content'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'content');
let systemPasteboard = pasteboard.getSystemPasteboard(); let systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setData(pasteData).then((data) => { systemPasteboard.setData(pasteData).then((data) => {
console.info('Succeeded in setting PasteData.'); console.info('Succeeded in setting PasteData.');
......
...@@ -9,7 +9,7 @@ The **screenlock** module is a system module in OpenHarmony. It provides APIs fo ...@@ -9,7 +9,7 @@ The **screenlock** module is a system module in OpenHarmony. It provides APIs fo
## Modules to Import ## Modules to Import
```js ```js
import screenlock from '@ohos.screenLock'; import screenLock from '@ohos.screenLock';
``` ```
## EventType<sup>9+</sup> ## EventType<sup>9+</sup>
...@@ -50,7 +50,7 @@ Defines the structure of the system event callback. ...@@ -50,7 +50,7 @@ Defines the structure of the system event callback.
| eventType | [EventType](#eventtype9) | Yes | System event type.| | eventType | [EventType](#eventtype9) | Yes | System event type.|
| params | string | Yes | System event parameters.| | params | string | Yes | System event parameters.|
## screenlock.isLocked<sup>9+</sup> ## screenLock.isLocked<sup>9+</sup>
isLocked(): boolean isLocked(): boolean
...@@ -69,10 +69,10 @@ Checks whether the screen is locked. ...@@ -69,10 +69,10 @@ Checks whether the screen is locked.
**Example** **Example**
```js ```js
let isLocked = screenlock.isLocked(); let isLocked = screenLock.isLocked();
``` ```
## screenlock.unlock<sup>9+</sup> ## screenLock.unlock<sup>9+</sup>
unlock(callback: AsyncCallback&lt;boolean&gt;): void unlock(callback: AsyncCallback&lt;boolean&gt;): void
...@@ -98,17 +98,17 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e ...@@ -98,17 +98,17 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e
**Example** **Example**
```js ```js
screenlock.unlock((err, data) => { screenLock.unlock((err, data) => {
if (err) { if (err) {
console.error(`Failed to unlock the screen, because: ${err.message}`); console.error(`Failed to unlock the screen. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
console.info(`unlock the screen successfully. result: ${data}`); console.info(`Succeeded in unlocking the screen. Result: ${data}`);
}); });
``` ```
## screenlock.unlock<sup>9+</sup> ## screenLock.unlock<sup>9+</sup>
unlock(): Promise&lt;boolean&gt; unlock(): Promise&lt;boolean&gt;
...@@ -134,15 +134,15 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e ...@@ -134,15 +134,15 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e
**Example** **Example**
```js ```js
screenlock.unlock().then((data) => { screenLock.unlock().then((data) => {
console.info(`unlock the screen successfully. result: ${data}`); console.info(`Succeeded in unlocking the screen. Result: ${data}`);
}).catch((err) => { }).catch((err) => {
console.error(`Failed to unlock the screen, because: ${err.message}`); console.error(`Failed to unlock the screen, Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
## screenlock.lock<sup>9+</sup> ## screenLock.lock<sup>9+</sup>
lock(callback: AsyncCallback&lt;boolean&gt;): void lock(callback: AsyncCallback&lt;boolean&gt;): void
...@@ -170,17 +170,17 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e ...@@ -170,17 +170,17 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e
**Example** **Example**
```js ```js
screenlock.lock((err, data) => { screenLock.lock((err, data) => {
if (err) { if (err) {
console.error(`Failed to lock the screen, because: ${err.message}`); console.error(`Failed to lock the screen. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
console.info(`lock the screen successfully. result: ${data}`); console.info(`Succeeded in locking the screen. result: ${data}`);
}); });
``` ```
## screenlock.lock<sup>9+</sup> ## screenLock.lock<sup>9+</sup>
lock(): Promise&lt;boolean&gt; lock(): Promise&lt;boolean&gt;
...@@ -208,15 +208,15 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e ...@@ -208,15 +208,15 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e
**Example** **Example**
```js ```js
screenlock.lock().then((data) => { screenLock.lock().then((data) => {
console.info(`lock the screen successfully. result: ${data}`); console.info(`Succeeded in locking the screen. Result: ${data}`);
}).catch((err) => { }).catch((err) => {
console.error(`Failed to lock the screen, because: ${err.message}`); console.error(`Failed to lock the screen. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
## screenlock.onSystemEvent<sup>9+</sup> ## screenLock.onSystemEvent<sup>9+</sup>
onSystemEvent(callback: Callback&lt;SystemEvent&gt;): boolean onSystemEvent(callback: Callback&lt;SystemEvent&gt;): boolean
...@@ -250,17 +250,17 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e ...@@ -250,17 +250,17 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e
**Example** **Example**
```js ```js
try { try {
let isSuccess = screenlock.onSystemEvent((event) => { let isSuccess = screenLock.onSystemEvent((event) => {
console.log(`Register the system event which related to screenlock successfully. eventType: ${event.eventType}`) console.log(`Succeeded in registering the system event related to screenlock. eventType: ${event.eventType}`)
}); });
} catch (err) { } catch (err) {
console.error(`Failed to register the system event which related to screenlock, because: ${err.message}`) console.error(`Failed to register the system event related to screenlock. Code: ${err.code}, message: ${err.message}`)
} }
``` ```
## screenlock.sendScreenLockEvent<sup>9+</sup> ## screenLock.sendScreenLockEvent<sup>9+</sup>
sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback&lt;boolean&gt;): void sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback&lt;boolean&gt;): void
...@@ -290,17 +290,17 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e ...@@ -290,17 +290,17 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e
**Example** **Example**
```js ```js
screenlock.sendScreenLockEvent('unlockScreenResult', 0, (err, result) => { screenLock.sendScreenLockEvent('unlockScreenResult', 0, (err, result) => {
if (err) { if (err) {
console.error(`Failed to send screenlock event, because: ${err.message}`); console.error(`Failed to send the screenlock event. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
console.info(`Send screenlock event successfully. result: ${result}`); console.info(`Succeeded in sending the screenlock event. result: ${result}`);
}); });
``` ```
## screenlock.sendScreenLockEvent<sup>9+</sup> ## screenLock.sendScreenLockEvent<sup>9+</sup>
sendScreenLockEvent(event: String, parameter: number): Promise&lt;boolean&gt; sendScreenLockEvent(event: String, parameter: number): Promise&lt;boolean&gt;
...@@ -335,15 +335,15 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e ...@@ -335,15 +335,15 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e
**Example** **Example**
```js ```js
screenlock.sendScreenLockEvent('unlockScreenResult', 0).then((result) => { screenLock.sendScreenLockEvent('unlockScreenResult', 0).then((result) => {
console.info(`Send screenlock event successfully. result: ${result}`); console.info(`Succeeded in sending the screenlock event. Result: ${result}`);
}).catch((err) => { }).catch((err) => {
console.error(`Failed to send screenlock event, because: ${err.message}`); console.error(`Failed to send the screenlock event. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
## screenlock.isScreenLocked<sup>(deprecated)</sup> ## screenLock.isScreenLocked<sup>(deprecated)</sup>
isScreenLocked(callback: AsyncCallback&lt;boolean&gt;): void isScreenLocked(callback: AsyncCallback&lt;boolean&gt;): void
...@@ -363,17 +363,17 @@ Checks whether the screen is locked. This API uses an asynchronous callback to r ...@@ -363,17 +363,17 @@ Checks whether the screen is locked. This API uses an asynchronous callback to r
**Example** **Example**
```js ```js
screenlock.isScreenLocked((err, data)=>{ screenLock.isScreenLocked((err, data)=>{
if (err) { if (err) {
console.error(`Failed to obtain whether the screen is locked, because: ${err.message}`); console.error(`Failed to obtain whether the screen is locked. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
console.info(`Obtain whether the screen is locked successfully. result: ${data}`); console.info(`Succeeded in obtaining whether the screen is locked. Result: ${data}`);
}); });
``` ```
## screenlock.isScreenLocked<sup>(deprecated)</sup> ## screenLock.isScreenLocked<sup>(deprecated)</sup>
isScreenLocked(): Promise&lt;boolean&gt; isScreenLocked(): Promise&lt;boolean&gt;
...@@ -393,15 +393,15 @@ Checks whether the screen is locked. This API uses a promise to return the resul ...@@ -393,15 +393,15 @@ Checks whether the screen is locked. This API uses a promise to return the resul
**Example** **Example**
```js ```js
screenlock.isScreenLocked().then((data) => { screenLock.isScreenLocked().then((data) => {
console.info(`Obtain whether the screen is locked successfully. result: ${data}`); console.info(`Succeeded in obtaining whether the screen is locked. Result: ${data}`);
}).catch((err) => { }).catch((err) => {
console.error(`Failed to obtain whether the screen is locked, because: ${err.message}`); console.error(`Failed to obtain whether the screen is locked. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
## screenlock.isSecureMode<sup>(deprecated)</sup> ## screenLock.isSecureMode<sup>(deprecated)</sup>
isSecureMode(callback: AsyncCallback&lt;boolean&gt;): void isSecureMode(callback: AsyncCallback&lt;boolean&gt;): void
...@@ -421,17 +421,17 @@ Checks whether the device is in secure mode. When the device is in secure mode, ...@@ -421,17 +421,17 @@ Checks whether the device is in secure mode. When the device is in secure mode,
**Example** **Example**
```js ```js
screenlock.isSecureMode((err, data)=>{ screenLock.isSecureMode((err, data)=>{
if (err) { if (err) {
console.error(`Failed to obtain whether the device is in secure mode, because: ${err.message}`); console.error(`Failed to obtain whether the device is in secure mode. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
console.info(`Obtain whether the device is in secure mode successfully. result: ${data}`); console.info(`Succeeded in obtaining whether the device is in secure mode. Result: ${data}`);
}); });
``` ```
## screenlock.isSecureMode<sup>(deprecated)</sup> ## screenLock.isSecureMode<sup>(deprecated)</sup>
isSecureMode(): Promise&lt;boolean&gt; isSecureMode(): Promise&lt;boolean&gt;
...@@ -451,14 +451,15 @@ Checks whether the device is in secure mode. When the device is in secure mode, ...@@ -451,14 +451,15 @@ Checks whether the device is in secure mode. When the device is in secure mode,
**Example** **Example**
```js ```js
screenlock.isSecureMode().then((data) => { screenLock.isSecureMode().then((data) => {
console.info(`Obtain whether the device is in secure mode successfully. result: ${data}`); console.info(`Succeeded in obtaining whether the device is in secure mode. Result: ${data}`);
}).catch((err) => { }).catch((err) => {
console.error(`Failed to obtain whether the device is in secure mode, because: ${err.message}`); console.error(`Failed to obtain whether the device is in secure mode. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
## screenlock.unlockScreen<sup>(deprecated)</sup>
## screenLock.unlockScreen<sup>(deprecated)</sup>
unlockScreen(callback: AsyncCallback&lt;void&gt;): void unlockScreen(callback: AsyncCallback&lt;void&gt;): void
...@@ -478,17 +479,17 @@ Unlocks the screen. This API uses an asynchronous callback to return the result. ...@@ -478,17 +479,17 @@ Unlocks the screen. This API uses an asynchronous callback to return the result.
**Example** **Example**
```js ```js
screenlock.unlockScreen((err) => { screenLock.unlockScreen((err) => {
if (err) { if (err) {
console.error(`Failed to unlock the screen, because: ${err.message}`); console.error(`Failed to unlock the screen. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
console.info('unlock the screen successfully.'); console.info(`Succeeded in unlocking the screen.`);
}); });
``` ```
## screenlock.unlockScreen<sup>(deprecated)</sup> ## screenLock.unlockScreen<sup>(deprecated)</sup>
unlockScreen(): Promise&lt;void&gt; unlockScreen(): Promise&lt;void&gt;
...@@ -508,10 +509,10 @@ Unlocks the screen. This API uses a promise to return the result. ...@@ -508,10 +509,10 @@ Unlocks the screen. This API uses a promise to return the result.
**Example** **Example**
```js ```js
screenlock.unlockScreen().then(() => { screenLock.unlockScreen().then(() => {
console.info('unlock the screen successfully.'); console.info('Succeeded in unlocking the screen.');
}).catch((err) => { }).catch((err) => {
console.error(`Failed to unlock the screen, because: ${err.message}`); console.error(`Failed to unlock the screen. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
# Theme Framework Subsystem – Screen Lock Management Service Changelog
## cl.screenlock.1 Instance Name Change
Changed the name of the instance for importing the **@ohos.screenLock** module from **screenlock** to **screenLock**.
**Change Impact**
None.
**Key API/Component Changes**
Before change:
```js
screenlock.isLocked();
screenlock.unlock();
screenlock.lock();
screenlock.onSystemEvent(event=>{});
screenlock.sendScreenLockEvent('unlockScreenResult', 0);
screenlock.isScreenLocked()
screenlock.isSecureMode();
screenlock.unlockScreen();
```
After change:
```js
screenLock.isLocked();
screenLock.unlock();
screenLock.lock();
screenLock.onSystemEvent(event=>{});
screenLock.sendScreenLockEvent('unlockScreenResult', 0);
screenLock.isScreenLocked()
screenLock.isSecureMode();
screenLock.unlockScreen();
```
**Adaptation Guide**
Use **screenLock** in the **import** statement.
Before change:
```js
import screenlock from '@ohos.screenLock';
```
After change:
```js
import screenLock from '@ohos.screenLock';
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册