diff --git a/en/application-dev/database/database-relational-guidelines.md b/en/application-dev/database/database-relational-guidelines.md index 3905580f4f44de8b541e9650916f281011839bf5..fe70b837c085a2309cdbc26a5365dfcce29d6b5c 100644 --- a/en/application-dev/database/database-relational-guidelines.md +++ b/en/application-dev/database/database-relational-guidelines.md @@ -204,7 +204,7 @@ You can obtain the distributed table name for a remote device based on the local const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"; const STORE_CONFIG = {name: "rdbstore.db",} data_rdb.getRdbStore(STORE_CONFIG, 1, function (err, rdbStore) { - rdbStore.executeSql(SQL_CREATE_TABLE) + rdbStore.executeSql(CREATE_TABLE_TEST) console.info('create table done.') }) ``` diff --git a/en/application-dev/media/opensles-playback.md b/en/application-dev/media/opensles-playback.md index b8568a6946d7c4f0d1647f23c9d52909e1cbd8df..f70dc251b831644cccdfdfb9fc6b1dc9ea738965 100644 --- a/en/application-dev/media/opensles-playback.md +++ b/en/application-dev/media/opensles-playback.md @@ -82,7 +82,7 @@ To use OpenSL ES to develop the audio playback function in OpenHarmony, perform ```c++ FILE *wavFile_ = nullptr; - static void BuqqerQueueCallback (SLOHBufferQueueItf bufferQueueItf, void *pContext, SLuint32 size) + static void BufferQueueCallback (SLOHBufferQueueItf bufferQueueItf, void *pContext, SLuint32 size) { FILE *wavFile = (FILE *)pContext; if (!feof(wavFile)) { @@ -98,7 +98,7 @@ To use OpenSL ES to develop the audio playback function in OpenHarmony, perform // Set wavFile_ to the descriptor of the file to be played. wavFile_ = fopen(path, "rb"); - (*bufferQueueItf)->RegisterCallback(bufferQueueItf, BuqqerQueueCallback, wavFile_); + (*bufferQueueItf)->RegisterCallback(bufferQueueItf, BufferQueueCallback, wavFile_); ``` diff --git a/en/application-dev/quick-start/start-with-ets-low-code.md b/en/application-dev/quick-start/start-with-ets-low-code.md index de3c11c9bcef2c6ef3ecd4e77db051de55844359..1dd03af96c2064b5b6b0baa89e7295decb4cf1fd 100644 --- a/en/application-dev/quick-start/start-with-ets-low-code.md +++ b/en/application-dev/quick-start/start-with-ets-low-code.md @@ -15,7 +15,7 @@ You can develop applications or services in the low-code approach using either o - Create a project that supports low-code development. This method is used as an example in this topic. -- In an existing project, create a .visual file for development. +- In an existing project, create a .visual file for development. For details, see [Creating a .visual File That Supports Low-Code Development](#building-the-second-page). ## Creating a Project That Supports Low-Code Development @@ -52,7 +52,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column Open the **index.visual** file, right-click the existing template components on the canvas, and choose **Delete** from the shortcut menu to delete them. Below is an illustration of the operations. -![en-us_image_0000001233208980](figures/en-us_image_0000001233208980.gif) + ![en-us_image_0000001233208980](figures/en-us_image_0000001233208980.gif) 2. Add a **Column** component and set its styles and attributes. @@ -70,7 +70,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column Drag the **Button** component from the **UI Control** area to the canvas and then to a position under the **Text** component. In the **Attributes & Styles** area on the right, click ![en-us_image_0000001277728577](figures/en-us_image_0000001277728577.png)**General** and set **Height** of the **Button** component to **40vp**. Click ![en-us_image_0000001277809337](figures/en-us_image_0000001277809337.png)**Feature** and set **Label** to **Next** and **FontSize** to **25fp**. Below is an illustration of the operations. -![en-us_image_0000001235732402](figures/en-us_image_0000001235732402.gif) + ![en-us_image_0000001235732402](figures/en-us_image_0000001235732402.gif) 5. On the toolbar in the upper right corner of the editing window, click **Previewer** to open the Previewer. @@ -85,7 +85,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column In the **Project** window, choose **entry** > **src** > **main** > **ets** > **MainAbility**, right-click the **pages** folder, choose **New** > **Visual**, name the page **second**, and click **Finish**. Below, you can see the structure of the **pages** folder. -![en-us_image_0000001233368868](figures/en-us_image_0000001233368868.png) + ![en-us_image_0000001233368868](figures/en-us_image_0000001233368868.png) 2. [Delete the existing template components from the canvas.](#delete_origin_content) diff --git a/en/application-dev/quick-start/start-with-js-low-code.md b/en/application-dev/quick-start/start-with-js-low-code.md index 865f2b69847412f626c47d8228d1a3dc344a3b7a..9d551aea76026a1d089d6853bce1aabdc1533192 100644 --- a/en/application-dev/quick-start/start-with-js-low-code.md +++ b/en/application-dev/quick-start/start-with-js-low-code.md @@ -13,7 +13,7 @@ You can develop applications or services in the low-code approach using either o - Create a project that supports low-code development. This method is used as an example in this topic. -- In an existing project, create a Visual file for development. +- In an existing project, create a Visual file for development. For details, see [Creating a .visual File That Supports Low-Code Development](#building-the-second-page). ## Creating a Project That Supports Low-Code Development @@ -53,15 +53,15 @@ Add **Div**, **Text**, and **Button** components to the first page. 1. Delete the existing template components from the canvas. -Open the index.visual file, right-click the existing template components on the canvas, and choose **Delete** from the shortcut menu to delete them. Below is an illustration of the operations. + Open the index.visual file, right-click the existing template components on the canvas, and choose **Delete** from the shortcut menu to delete them. Below is an illustration of the operations. -![en-us_image_0000001216600980](figures/en-us_image_0000001216600980.gif) + ![en-us_image_0000001216600980](figures/en-us_image_0000001216600980.gif) 2. Add a **Div** component and set its styles and attributes. Drag the **Div** component from the **UI Control** area to the canvas. In the **Attributes & Styles** area on the right, click ![en-us_image_0000001260226691](figures/en-us_image_0000001260226691.png)**General** and set **Height** to **100%** so that the component fills the entire screen. Click ![en-us_image_0000001215226858](figures/en-us_image_0000001215226858.png)**Flex**, set **FlexDirection** to **column** so that the main axis of the component is vertical, and set both **JustifyContent** and **AlignItems** to **center** so that the child components of the **Div** component are centered along the main axis and cross axis. Below is an illustration of the operations. -![en-us_image_0000001216448880](figures/en-us_image_0000001216448880.gif) + ![en-us_image_0000001216448880](figures/en-us_image_0000001216448880.gif) 3. Add a **Text** component. @@ -88,7 +88,7 @@ Open the index.visual file, right-click the existing template components on the In the **Project** window, choose **entry** > **src** > **main** > **js** > **MainAbility**, right-click the **pages** folder, choose **New** > **Visual**, name the page **second**, and click **Finish**. Below, you can see the structure of the **pages** folder. -![en-us_image_0000001223882030](figures/en-us_image_0000001223882030.png) + ![en-us_image_0000001223882030](figures/en-us_image_0000001223882030.png) 2. [Delete the existing template components from the canvas.](#delete_origin_content) diff --git a/en/application-dev/reference/apis/js-apis-pasteboard.md b/en/application-dev/reference/apis/js-apis-pasteboard.md index c5ca90fd33c1de4b2eb4f4fff33eee5e2d899a79..3dc7bd863f5aaa22245bb2c779b6c426e065f49e 100644 --- a/en/application-dev/reference/apis/js-apis-pasteboard.md +++ b/en/application-dev/reference/apis/js-apis-pasteboard.md @@ -1,7 +1,7 @@ # Pasteboard -> ![icon-note.gif](public_sys-resources/icon-note.gif) **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. +> **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. > @@ -48,9 +48,9 @@ Creates a **PasteData** object for plain text. **Example** -```js -var pasteData = pasteboard.createPlainTextData("content"); -``` + ```js + var pasteData = pasteboard.createPlainTextData("content"); + ``` ## pasteboard.createHtmlData7+ @@ -75,10 +75,10 @@ Creates a **PasteData** object for HTML text. **Example** -```js -var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; -var pasteData = pasteboard.createHtmlData(html); -``` + ```js + var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; + var pasteData = pasteboard.createHtmlData(html); + ``` ## pasteboard.createWantData7+ @@ -103,13 +103,13 @@ Creates a **PasteData** object for Want text. **Example** -```js -var object = { - bundleName: "com.example.aafwk.test", - abilityName: "com.example.aafwk.test.TwoAbility" -}; -var pasteData = pasteboard.createWantData(object); -``` + ```js + var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" + }; + var pasteData = pasteboard.createWantData(object); + ``` ## pasteboard.createUriData7+ @@ -134,9 +134,9 @@ Creates a **PasteData** object for URI text. **Example** -```js -var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); -``` + ```js + var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); + ``` ## pasteboard.createPlainTextRecord7+ @@ -161,9 +161,9 @@ Creates a **PasteDataRecord** object of the plain text type. **Example** -```js -var record = pasteboard.createPlainTextRecord("hello"); -``` + ```js + var record = pasteboard.createPlainTextRecord("hello"); + ``` ## pasteboard.createHtmlTextRecord7+ @@ -188,10 +188,10 @@ Creates a **PasteDataRecord** object of the HTML text type. **Example** -```js -var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; -var record = pasteboard.createHtmlTextRecord(html); -``` + ```js + var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; + var record = pasteboard.createHtmlTextRecord(html); + ``` ## pasteboard.createWantRecord7+ @@ -216,13 +216,13 @@ Creates a **PasteDataRecord** object of the Want text type. **Example** -```js -var object = { - bundleName: "com.example.aafwk.test", - abilityName: "com.example.aafwk.test.TwoAbility" -}; -var record = pasteboard.createWantRecord(object); -``` + ```js + var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" + }; + var record = pasteboard.createWantRecord(object); + ``` ## pasteboard.createUriRecord7+ @@ -247,9 +247,9 @@ Creates a **PasteDataRecord** object of the URI text type. **Example** -```js -var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); -``` + ```js + var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); + ``` ## PasteDataProperty7+ @@ -301,14 +301,14 @@ Forcibly converts the content in this **PasteData** object to the plain text. Th **Example** -```js -var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); -record.convertToText().then((data) => { - console.info('convertToText success data : ' + JSON.stringify(data)); -}).catch((error) => { - console.error('convertToText failed because ' + JSON.stringify(error)); -}); -``` + ```js + var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); + record.convertToText().then((data) => { + console.info('convertToText success data : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('convertToText failed because ' + JSON.stringify(error)); + }); + ``` ### convertToText7+ @@ -327,16 +327,16 @@ Forcibly converts the content in this **PasteData** object to the plain text. Th **Example** -```js -var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); -record.convertToText((err, data) => { - if (err) { - console.error('convertToText failed because ' + JSON.stringify(err)); - return; - } - console.info('convertToText success data : ' + JSON.stringify(data)); -}); -``` + ```js + var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); + record.convertToText((err, data) => { + if (err) { + console.error('convertToText failed because ' + JSON.stringify(err)); + return; + } + console.info('convertToText success data : ' + JSON.stringify(data)); + }); + ``` ## PasteData @@ -366,10 +366,10 @@ Obtains the plain text of the primary record. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var plainText = pasteData.getPrimaryText(); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var plainText = pasteData.getPrimaryText(); + ``` ### getPrimaryHtml7+ @@ -388,11 +388,11 @@ Obtains the HTML text of the primary record. **Example** -```js -var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; -var pasteData = pasteboard.createHtmlData(html); -var htmlText = pasteData.getPrimaryHtml(); -``` + ```js + var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; + var pasteData = pasteboard.createHtmlData(html); + var htmlText = pasteData.getPrimaryHtml(); + ``` ### getPrimaryWant7+ @@ -411,14 +411,14 @@ Obtains the **Want** object of the primary record. **Example** -```js -var object = { - bundleName: "com.example.aafwk.test", - abilityName: "com.example.aafwk.test.TwoAbility" -}; -var pasteData = pasteboard.createWantData(object); -var want = pasteData.getPrimaryWant(); -``` + ```js + var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" + }; + var pasteData = pasteboard.createWantData(object); + var want = pasteData.getPrimaryWant(); + ``` ### getPrimaryUri7+ @@ -437,10 +437,10 @@ Obtains the URI text of the primary record. **Example** -```js -var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); -var uri = pasteData.getPrimaryUri(); -``` + ```js + var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); + var uri = pasteData.getPrimaryUri(); + ``` ### addTextRecord7+ @@ -461,10 +461,10 @@ The pasteboard supports a maximum number of 128 data records. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -pasteData.addTextRecord("good"); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + pasteData.addTextRecord("good"); + ``` ### addHtmlRecord7+ @@ -485,11 +485,11 @@ The pasteboard supports a maximum number of 128 data records. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; -pasteData.addHtmlRecord(html); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; + pasteData.addHtmlRecord(html); + ``` ### addWantRecord7+ @@ -510,14 +510,14 @@ The pasteboard supports a maximum number of 128 data records. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var object = { - bundleName: "com.example.aafwk.test", - abilityName: "com.example.aafwk.test.TwoAbility" -}; -pasteData.addWantRecord(object); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" + }; + pasteData.addWantRecord(object); + ``` ### addUriRecord7+ @@ -538,10 +538,10 @@ The pasteboard supports a maximum number of 128 data records. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt"); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt"); + ``` ### addRecord7+ @@ -562,14 +562,14 @@ The pasteboard supports a maximum number of 128 data records. **Example** -```js -var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); -var textRecord = pasteboard.createPlainTextRecord("hello"); -var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; -var htmlRecord = pasteboard.createHtmlTextRecord(html); -pasteData.addRecord(textRecord); -pasteData.addRecord(htmlRecord); -``` + ```js + var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); + var textRecord = pasteboard.createPlainTextRecord("hello"); + var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; + var htmlRecord = pasteboard.createHtmlTextRecord(html); + pasteData.addRecord(textRecord); + pasteData.addRecord(htmlRecord); + ``` ### getMimeTypes7+ @@ -588,10 +588,10 @@ Obtains **mimeTypes** in [PasteDataProperty](#pastedataproperty7) from this past **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var types = pasteData.getMimeTypes(); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var types = pasteData.getMimeTypes(); + ``` ### getPrimaryMimeType7+ @@ -610,10 +610,10 @@ Obtains the data type of the primary record. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var type = pasteData.getPrimaryMimeType(); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var type = pasteData.getPrimaryMimeType(); + ``` ### getProperty7+ @@ -632,10 +632,10 @@ Obtains the property description object. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var property = pasteData.getProperty(); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var property = pasteData.getProperty(); + ``` ### getRecordAt7+ @@ -660,10 +660,10 @@ Obtains the record with the specified index. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var record = pasteData.getRecordAt(0); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var record = pasteData.getRecordAt(0); + ``` ### getRecordCount7+ @@ -682,10 +682,10 @@ Obtains the number of data records in this pasteboard. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var count = pasteData.getRecordCount(); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var count = pasteData.getRecordCount(); + ``` ### getTag7+ @@ -704,10 +704,10 @@ Obtains the user-defined tag content. If the tag content is not set, null is ret **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var tag = pasteData.getTag(); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var tag = pasteData.getTag(); + ``` ### hasMimeType7+ @@ -732,10 +732,10 @@ Checks whether the content of this pasteboard contains the specified data type. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); + ``` ### removeRecordAt7+ @@ -760,10 +760,10 @@ Removes the data record with a specified index from this pasteboard. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var isRemove = pasteData.removeRecordAt(0); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var isRemove = pasteData.removeRecordAt(0); + ``` ### replaceRecordAt7+ @@ -789,11 +789,11 @@ Replaces the data record with a specified index in this pasteboard. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); -var isReplace = pasteData.replaceRecordAt(0, record); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); + var isReplace = pasteData.replaceRecordAt(0, record); + ``` ## pasteboard.getSystemPasteboard @@ -812,9 +812,9 @@ Obtains the system pasteboard. **Example** -```js -var systemPasteboard = pasteboard.getSystemPasteboard(); -``` + ```js + var systemPasteboard = pasteboard.getSystemPasteboard(); + ``` ## SystemPasteboard @@ -843,17 +843,17 @@ Writes data to a pasteboard. This API uses an asynchronous callback to return th **Example** -```js -var pasteData = pasteboard.createPlainTextData("content"); -var systemPasteboard = pasteboard.getSystemPasteboard(); -systemPasteboard.setPasteData(pasteData, (error, data) => { - if (error) { - console.error('Failed to setPasteData. Cause: ' + error.message); - return; - } - console.info('setPasteData successfully.'); -}); -``` + ```js + var pasteData = pasteboard.createPlainTextData("content"); + var systemPasteboard = pasteboard.getSystemPasteboard(); + systemPasteboard.setPasteData(pasteData, (error, data) => { + if (error) { + console.error('Failed to setPasteData. Cause: ' + error.message); + return; + } + console.info('setPasteData successfully.'); + }); + ``` ### setPasteData @@ -878,15 +878,15 @@ Writes data to a pasteboard. This API uses a promise to return the result. **Example** -```js -var pasteData = pasteboard.createPlainTextData("content"); -var systemPasteboard = pasteboard.getSystemPasteboard(); -systemPasteboard.setPasteData(pasteData).then((data) => { - console.info('setPasteData success.'); -}).catch((error) => { - console.error('Failed to setPasteData. Cause: ' + error.message); -}); -``` + ```js + var pasteData = pasteboard.createPlainTextData("content"); + var systemPasteboard = pasteboard.getSystemPasteboard(); + systemPasteboard.setPasteData(pasteData).then((data) => { + console.info('setPasteData success.'); + }).catch((error) => { + console.error('Failed to setPasteData. Cause: ' + error.message); + }); + ``` ### getPasteData @@ -905,16 +905,16 @@ Reads the system pasteboard content. This API uses an asynchronous callback to r **Example** -```js -var systemPasteboard = pasteboard.getSystemPasteboard(); -systemPasteboard.getPasteData((error, pasteData) => { - if (error) { - console.error('Failed to getPasteData. Cause: ' + error.message); - return; - } - var text = pasteData.getPrimaryText(); -}); -``` + ```js + var systemPasteboard = pasteboard.getSystemPasteboard(); + systemPasteboard.getPasteData((error, pasteData) => { + if (error) { + console.error('Failed to getPasteData. Cause: ' + error.message); + return; + } + var text = pasteData.getPrimaryText(); + }); + ``` ### getPasteData @@ -933,14 +933,14 @@ Reads the system pasteboard content. This API uses a promise to return the resul **Example** -```js -var systemPasteboard = pasteboard.getSystemPasteboard(); -systemPasteboard.getPasteData().then((pasteData) => { - var text = pasteData.getPrimaryText(); -}).catch((error) => { - console.error('Failed to getPasteData. Cause: ' + error.message); -}) -``` + ```js + var systemPasteboard = pasteboard.getSystemPasteboard(); + systemPasteboard.getPasteData().then((pasteData) => { + var text = pasteData.getPrimaryText(); + }).catch((error) => { + console.error('Failed to getPasteData. Cause: ' + error.message); + }) + ``` ### on('update')7+ @@ -960,18 +960,18 @@ Subscribes to the content change event of the system pasteboard. If the pasteboa **Example** -```js -var systemPasteboard = pasteboard.getSystemPasteboard(); -var listener = ()=>{ - console.info('The system pasteboard has changed'); -}; -systemPasteboard.on('update', listener); -``` + ```js + var systemPasteboard = pasteboard.getSystemPasteboard(); + var listener = () => { + console.info('The system pasteboard has changed'); + }; + systemPasteboard.on('update', listener); + ``` ### off('update')7+ -off(type: 'update', callback? : () =>void ): void +off(type: 'update', callback?: () =>void ): void Unsubscribes from the system pasteboard content change event. @@ -986,9 +986,12 @@ Unsubscribes from the system pasteboard content change event. **Example** -```js -systemPasteboard.off('update', listener); -``` + ```js + let listener = () => { + console.info('The system pasteboard has changed'); + }; + systemPasteboard.off('update', listener); + ``` ### hasPasteData7+ @@ -1007,15 +1010,15 @@ Checks whether the system pasteboard contains content. This API uses an asynchro **Example** -```js -systemPasteboard.hasPasteData((err, data) => { - if (err) { - console.error('failed to hasPasteData because ' + JSON.stringify(err)); - return; - } - console.info('success hasPasteData : ' + JSON.stringify(data)); -}); -``` + ```js + systemPasteboard.hasPasteData((err, data) => { + if (err) { + console.error('failed to hasPasteData because ' + JSON.stringify(err)); + return; + } + console.info('success hasPasteData : ' + JSON.stringify(data)); + }); + ``` ### hasPasteData7+ @@ -1059,15 +1062,15 @@ Clears the system pasteboard content. This API uses an asynchronous callback to **Example** -```js -systemPasteboard.clear((err, data) => { - if (err) { - console.error('failed to clear because ' + JSON.stringify(err)); - return; - } - console.info('success clear'); -}); -``` + ```js + systemPasteboard.clear((err, data) => { + if (err) { + console.error('failed to clear because ' + JSON.stringify(err)); + return; + } + console.info('success clear'); + }); + ``` ### clear7+ @@ -1086,10 +1089,10 @@ Clears the system pasteboard content. This API uses a promise to return the resu **Example** -```js -systemPasteboard.clear().then((data) => { - console.info('success clear'); -}).catch((error) => { - console.error('failed to clear because ' + JSON.stringify(error)); -}); -``` \ No newline at end of file + ```js + systemPasteboard.clear().then((data) => { + console.info('success clear'); + }).catch((error) => { + console.error('failed to clear because ' + JSON.stringify(error)); + }); + ``` diff --git a/en/application-dev/reference/apis/js-apis-system-parameter.md b/en/application-dev/reference/apis/js-apis-system-parameter.md index c111c6c2cbfa5e809816b3246a28ac8114e35f76..73735820c91a554fc8ea5a5dc14e9ef241327736 100644 --- a/en/application-dev/reference/apis/js-apis-system-parameter.md +++ b/en/application-dev/reference/apis/js-apis-system-parameter.md @@ -1,6 +1,6 @@ # System Parameter -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **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. > - This is a system API and cannot be called by third-party applications. @@ -203,9 +203,9 @@ try { ``` -## parameter.set(key: string, def?: string) +## parameter.set -set(key: string, def?: string): Promise<string> +set(key: string, value: string): Promise<void> Sets a value for the attribute with the specified key. This API uses a promise to return the result. @@ -222,7 +222,7 @@ Sets a value for the attribute with the specified key. This API uses a promise t | Type| Description| | -------- | -------- | -| Promise<string> | Promise used to return the execution result.| +| Promise<void> | Promise used to return the execution result.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-system-time.md b/en/application-dev/reference/apis/js-apis-system-time.md index 74beca3c0aacbabd628f99f7987b96caf5988f61..b61e69a07cf8ddf5d1d72a7e49c888ca71e2002d 100644 --- a/en/application-dev/reference/apis/js-apis-system-time.md +++ b/en/application-dev/reference/apis/js-apis-system-time.md @@ -1,7 +1,7 @@ # Setting the System Time -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. -> +This module is used to set and obtain the current system date, time, and time zone. +> **NOTE**
The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -189,7 +189,7 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This **Example** ```js - systemTime.getCurrentTime().then((data) => { + systemTime.getRealActiveTime().then((data) => { console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); }).catch((error) => { console.error(`failed to systemTime.getRealActiveTime because ` + JSON.stringify(error)); diff --git a/en/application-dev/reference/apis/js-apis-wallpaper.md b/en/application-dev/reference/apis/js-apis-wallpaper.md index 726134af57d86fcb611dd5a03c898d3e656bd272..75dda908af3e32140bf7c94b92ff73117be0ad7e 100644 --- a/en/application-dev/reference/apis/js-apis-wallpaper.md +++ b/en/application-dev/reference/apis/js-apis-wallpaper.md @@ -1,8 +1,7 @@ # Wallpaper -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. -> +> **NOTE**
The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -29,18 +28,18 @@ Defines the wallpaper type. getColors(wallpaperType: WallpaperType, callback: AsyncCallback<Array<RgbaColor>>): void -Obtains the main color information of the wallpaper of a specified type. +Obtains the main color information of the wallpaper of the specified type. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | - | callback | AsyncCallback<Array<[RgbaColor](#rgbacolor)>> | Yes | Callback used to return the main color information of the wallpaper. | +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | +| callback | AsyncCallback<Array<[RgbaColor](#rgbacolor)>> | Yes | Callback used to return the main color information of the wallpaper. | + +**Example** -- Example - ```js wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { if (error) { @@ -56,7 +55,7 @@ Obtains the main color information of the wallpaper of a specified type. getColors(wallpaperType: WallpaperType): Promise<Array<RgbaColor>> -Obtains the main color information of the wallpaper of a specified type. +Obtains the main color information of the wallpaper of the specified type. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -74,20 +73,20 @@ Obtains the main color information of the wallpaper of a specified type. **Example** -```js -wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { - console.log(`success to getColors.`); -}).catch((error) => { - console.error(`failed to getColors because: ` + JSON.stringify(error)); -}); -``` + ```js + wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to getColors.`); + }).catch((error) => { + console.error(`failed to getColors because: ` + JSON.stringify(error)); + }); + ``` ## wallpaper.getId getId(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void -Obtains the ID of the wallpaper of the specified type. +Obtains the ID of the wallpaper of the specified type. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -100,25 +99,26 @@ Obtains the ID of the wallpaper of the specified type. **Example** -```js -wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { - if (error) { - console.error(`failed to getId because: ` + JSON.stringify(error)); - return; - } - console.log(`success to getId: ` + JSON.stringify(data)); -}); -``` + ```js + wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to getId because: ` + JSON.stringify(error)); + return; + } + console.log(`success to getId: ` + JSON.stringify(data)); + }); + ``` ## wallpaper.getId getId(wallpaperType: WallpaperType): Promise<number> -Obtains the ID of the wallpaper of the specified type. +Obtains the ID of the wallpaper of the specified type. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper + **Parameters** | Name | Type | Mandatory | Description | @@ -133,20 +133,20 @@ Obtains the ID of the wallpaper of the specified type. **Example** -```js -wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { - console.log(`success to getId: ` + JSON.stringify(data)); -}).catch((error) => { - console.error(`failed to getId because: ` + JSON.stringify(error)); -}); -``` + ```js + wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to getId: ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to getId because: ` + JSON.stringify(error)); + }); + ``` ## wallpaper.getMinHeight getMinHeight(callback: AsyncCallback<number>): void -Obtains the minimum height of the wallpaper. +Obtains the minimum height of this wallpaper. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -158,25 +158,26 @@ Obtains the minimum height of the wallpaper. **Example** -```js -wallpaper.getMinHeight((error, data) => { - if (error) { - console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); - return; - } - console.log(`success to getMinHeight: ` + JSON.stringify(data)); -}); -``` + ```js + wallpaper.getMinHeight((error, data) => { + if (error) { + console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); + return; + } + console.log(`success to getMinHeight: ` + JSON.stringify(data)); + }); + ``` ## wallpaper.getMinHeight getMinHeight(): Promise<number> -Obtains the minimum height of the wallpaper. +Obtains the minimum height of this wallpaper. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper + **Return value** | Type | Description | @@ -185,20 +186,20 @@ Obtains the minimum height of the wallpaper. **Example** -```js -wallpaper.getMinHeight().then((data) => { - console.log(`success to getMinHeight: ` + JSON.stringify(data)); -}).catch((error) => { - console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); -}); -``` + ```js + wallpaper.getMinHeight().then((data) => { + console.log(`success to getMinHeight: ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); + }); + ``` ## wallpaper.getMinWidth getMinWidth(callback: AsyncCallback<number>): void -Obtains the minimum width of the wallpaper. +Obtains the minimum width of this wallpaper. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -210,22 +211,22 @@ Obtains the minimum width of the wallpaper. **Example** -```js -wallpaper.getMinWidth((error, data) => { - if (error) { - console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); - return; - } - console.log(`success to getMinWidth: ` + JSON.stringify(data)); -}); -``` + ```js + wallpaper.getMinWidth((error, data) => { + if (error) { + console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); + return; + } + console.log(`success to getMinWidth: ` + JSON.stringify(data)); + }); + ``` ## wallpaper.getMinWidth getMinWidth(): Promise<number> -Obtains the minimum width of the wallpaper. +Obtains the minimum width of this wallpaper. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -237,20 +238,20 @@ Obtains the minimum width of the wallpaper. **Example** -```js -wallpaper.getMinWidth().then((data) => { - console.log(`success to getMinWidth: ` + JSON.stringify(data)); -}).catch((error) => { - console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); -}); -``` + ```js + wallpaper.getMinWidth().then((data) => { + console.log(`success to getMinWidth: ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); + }); + ``` ## wallpaper.isChangePermitted isChangePermitted(callback: AsyncCallback<boolean>): void -Checks whether to allow the application to change the wallpaper for the current user. +Checks whether to allow the application to change the wallpaper for the current user. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -258,26 +259,26 @@ Checks whether to allow the application to change the wallpaper for the current | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the queried result. Returns **true** if it is allowed; returns **false** otherwise. | +| callback | AsyncCallback<boolean> | Yes | Returns **true** if the application is allowed to change the wallpaper for the current user; returns **false** otherwise. | **Example** -```js -wallpaper.isChangePermitted((error, data) => { - if (error) { - console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); - return; - } - console.log(`success to isChangePermitted: ` + JSON.stringify(data)); -}); -``` + ```js + wallpaper.isChangePermitted((error, data) => { + if (error) { + console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); + return; + } + console.log(`success to isChangePermitted: ` + JSON.stringify(data)); + }); + ``` ## wallpaper.isChangePermitted isChangePermitted(): Promise<boolean> -Checks whether to allow the application to change the wallpaper for the current user. +Checks whether to allow the application to change the wallpaper for the current user. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -285,24 +286,24 @@ Checks whether to allow the application to change the wallpaper for the current | Type | Description | | -------- | -------- | -| Promise<boolean> | Promise used to return whether to allow the application to change the wallpaper for the current user. Returns **true** if it is allowed; returns **false** otherwise. | +| Promise<boolean> | Returns **true** if the application is allowed to change the wallpaper for the current user; returns **false** otherwise. | **Example** -```js -wallpaper.isChangePermitted().then((data) => { - console.log(`success to isChangePermitted: ` + JSON.stringify(data)); -}).catch((error) => { - console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); -}); -``` + ```js + wallpaper.isChangePermitted().then((data) => { + console.log(`success to isChangePermitted: ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); + }); + ``` ## wallpaper.isOperationAllowed isOperationAllowed(callback: AsyncCallback<boolean>): void -Checks whether the user is allowed to set wallpapers. +Checks whether the user is allowed to set wallpapers. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -310,26 +311,26 @@ Checks whether the user is allowed to set wallpapers. | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the user is allowed to set wallpapers. Returns **true** if it is allowed; returns **false** otherwise. | +| callback | AsyncCallback<boolean> | Yes | Returns **true** if the user is allowed to set wallpapers; returns **false** otherwise. | **Example** -```js -wallpaper.isOperationAllowed((error, data) => { - if (error) { - console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); - return; - } - console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); -}); -``` + ```js + wallpaper.isOperationAllowed((error, data) => { + if (error) { + console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); + return; + } + console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); + }); + ``` ## wallpaper.isOperationAllowed isOperationAllowed(): Promise<boolean> -Checks whether the user is allowed to set wallpapers. +Checks whether the user is allowed to set wallpapers. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -337,26 +338,26 @@ Checks whether the user is allowed to set wallpapers. | Type | Description | | -------- | -------- | -| Promise<boolean> | Promise used to return whether the user is allowed to set wallpapers. Returns **true** if it is allowed; returns **false** otherwise. | +| Promise<boolean> | Returns **true** if the user is allowed to set wallpapers; returns **false** otherwise. | **Example** -```js -wallpaper.isOperationAllowed().then((data) => { - console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); -}).catch((error) => { - console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); -}); -``` + ```js + wallpaper.isOperationAllowed().then((data) => { + console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); + }); + ``` ## wallpaper.reset reset(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void -Removes a wallpaper of the specified type and restores the default one. +Resets the wallpaper of the specified type to the default wallpaper. This API uses an asynchronous callback to return the result. -**Required permission**: ohos.permission.SET_WALLPAPER +**Required permissions**: ohos.permission.SET_WALLPAPER **System capability**: SystemCapability.MiscServices.Wallpaper @@ -365,28 +366,28 @@ Removes a wallpaper of the specified type and restores the default one. | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, the result of removal is returned. Otherwise, error information is returned. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, the result is returned. Otherwise, error information is returned. | **Example** -```js -wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { - if (error) { - console.error(`failed to reset because: ` + JSON.stringify(error)); - return; - } - console.log(`success to reset.`); -}); -``` + ```js + wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to reset because: ` + JSON.stringify(error)); + return; + } + console.log(`success to reset.`); + }); + ``` ## wallpaper.reset reset(wallpaperType: WallpaperType): Promise<void> -Removes a wallpaper of the specified type and restores the default one. +Resets the wallpaper of the specified type to the default wallpaper. This API uses a promise to return the result. -**Required permission**: ohos.permission.SET_WALLPAPER +**Required permissions**: ohos.permission.SET_WALLPAPER **System capability**: SystemCapability.MiscServices.Wallpaper @@ -400,26 +401,26 @@ Removes a wallpaper of the specified type and restores the default one. | Type | Description | | -------- | -------- | -| Promise<void> | Promise used to return the result. If the operation is successful, the result of removal is returned. Otherwise, error information is returned. | +| Promise<void> | Promise used to return the result. If the operation is successful, the result is returned. Otherwise, error information is returned. | **Example** -```js -wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { - console.log(`success to reset.`); -}).catch((error) => { - console.error(`failed to reset because: ` + JSON.stringify(error)); -}); -``` + ```js + wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to reset.`); + }).catch((error) => { + console.error(`failed to reset because: ` + JSON.stringify(error)); + }); + ``` ## wallpaper.setWallpaper setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void -Sets a specified source as the wallpaper of a specified type. +Sets a specified source as the wallpaper of a specified type. This API uses an asynchronous callback to return the result. -**Required permission**: ohos.permission.SET_WALLPAPER +**Required permissions**: ohos.permission.SET_WALLPAPER **System capability**: SystemCapability.MiscServices.Wallpaper @@ -427,7 +428,7 @@ Sets a specified source as the wallpaper of a specified type. | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| source | string \| [PixelMap](js-apis-image.md#pixelmap7) | Yes | URI path of the JPEG or PNG file, or bitmap of the PNG file. | +| source | string \| [PixelMap](js-apis-image.md#pixelmap7) | Yes | URI of a JPEG or PNG file, or bitmap of a PNG file. | | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | | callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, the setting result is returned. Otherwise, error information is returned. | @@ -435,45 +436,45 @@ Sets a specified source as the wallpaper of a specified type. ```js // The source type is string. -let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; -wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { - if (error) { - console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); - return; - } - console.log(`success to setWallpaper.`); -}); - + let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; + wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); + return; + } + console.log(`success to setWallpaper.`); + }); + // The source type is image.PixelMap. -import image from '@ohos.multimedia.image'; -let imageSource = image.createImageSource("file://" + wallpaperPath); -let opts = { - "desiredSize": { - "height": 3648, - "width": 2736 - } -}; -imageSource.createPixelMap(opts).then((pixelMap) => { - wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { - if (error) { - console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); - return; - } - console.log(`success to setWallpaper.`); - }); -}).catch((error) => { - console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); -}); -``` + import image from '@ohos.multimedia.image'; + let imageSource = image.createImageSource("file://" + wallpaperPath); + let opts = { + "desiredSize": { + "height": 3648, + "width": 2736 + } + }; + imageSource.createPixelMap(opts).then((pixelMap) => { + wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); + return; + } + console.log(`success to setWallpaper.`); + }); + }).catch((error) => { + console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); + }); + ``` ## wallpaper.setWallpaper setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void> -Sets a specified source as the wallpaper of a specified type. +Sets a specified source as the wallpaper of a specified type. This API uses a promise to return the result. -**Required permission**: ohos.permission.SET_WALLPAPER +**Required permissions**: ohos.permission.SET_WALLPAPER **System capability**: SystemCapability.MiscServices.Wallpaper @@ -494,38 +495,38 @@ Sets a specified source as the wallpaper of a specified type. ```js // The source type is string. -let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; -wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { - console.log(`success to setWallpaper.`); -}).catch((error) => { - console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); -}); - + let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; + wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to setWallpaper.`); + }).catch((error) => { + console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); + }); + // The source type is image.PixelMap. -import image from '@ohos.multimedia.image'; -let imageSource = image.createImageSource("file://" + wallpaperPath); -let opts = { - "desiredSize": { - "height": 3648, - "width": 2736 - } -}; -imageSource.createPixelMap(opts).then((pixelMap) => { - wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { - console.log(`success to setWallpaper.`); - }).catch((error) => { - console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); - }); -}).catch((error) => { - console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); -}); -``` + import image from '@ohos.multimedia.image'; + let imageSource = image.createImageSource("file://" + wallpaperPath); + let opts = { + "desiredSize": { + "height": 3648, + "width": 2736 + } + }; + imageSource.createPixelMap(opts).then((pixelMap) => { + wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to setWallpaper.`); + }).catch((error) => { + console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); + }); + }).catch((error) => { + console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); + }); + ``` ## wallpaper.getFile8+ getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void -Obtains the wallpaper of the specified type. +Obtains the wallpaper of the specified type. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.SET_WALLPAPER and ohos.permission.READ_USER_STORAGE @@ -540,23 +541,23 @@ Obtains the wallpaper of the specified type. **Example** -```js -wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { - if (error) { - console.error(`failed to getFile because: ` + JSON.stringify(error)); - return; - } - console.log(`success to getFile: ` + JSON.stringify(data)); -}); -``` + ```js + wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to getFile because: ` + JSON.stringify(error)); + return; + } + console.log(`success to getFile: ` + JSON.stringify(data)); + }); + ``` ## wallpaper.getFile8+ getFile(wallpaperType: WallpaperType): Promise<number> -Obtains the wallpaper of the specified type. +Obtains the wallpaper of the specified type. This API uses a promise to return the result. -**Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE +**Required permissions**: ohos.permission.SET_WALLPAPER and ohos.permission.READ_USER_STORAGE **System capability**: SystemCapability.MiscServices.Wallpaper @@ -574,13 +575,75 @@ Obtains the wallpaper of the specified type. **Example** -```js -wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { - console.log(`success to getFile: ` + JSON.stringify(data)); -}).catch((error) => { - console.error(`failed to getFile because: ` + JSON.stringify(error)); -}); -``` + ```js + wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to getFile: ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to getFile because: ` + JSON.stringify(error)); + }); + ``` + + +## wallpaper.getPixelMap + +getPixelMap(wallpaperType: WallpaperType, callback: AsyncCallback<image.PixelMap>): void; + +Obtains the pixel image for the wallpaper of the specified type. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE + +**System capability**: SystemCapability.MiscServices.Wallpaper + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| wallpaperType | [WallpaperType](#wallpapertype) | Yes| Wallpaper type.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, the result is returned. Otherwise, error information is returned.| + +**Example** + + ```js + wallpaper.getPixelMap(wallpaper.WallpaperType.WALLPAPER_SYSTEM, function (err, data) { + console.info('wallpaperXTS ===> testGetPixelMapCallbackSystem err : ' + JSON.stringify(err)); + console.info('wallpaperXTS ===> testGetPixelMapCallbackSystem data : ' + JSON.stringify(data)); + }); + ``` + + +## wallpaper.getPixelMap + +getPixelMap(wallpaperType: WallpaperType): Promise<image.PixelMap> + +Obtains the pixel image for the wallpaper of the specified type. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE + +**System capability**: SystemCapability.MiscServices.Wallpaper + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| wallpaperType | [WallpaperType](#wallpapertype) | Yes| Wallpaper type.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result. If the operation is successful, the result is returned. Otherwise, error information is returned.| + +**Example** + + ```js + wallpaper.getPixelMap(WALLPAPER_SYSTEM).then((data) => { + console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + data); + console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + JSON.stringify(data)); + }).catch((err) => { + console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem err : ' + err); + console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem err : ' + JSON.stringify(err)); + }); + ``` ## wallpaper.on('colorChange') @@ -596,16 +659,16 @@ Subscribes to the wallpaper color change event. | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | | type | string | Yes | Type of the event to subscribe to. The value **colorChange** indicates subscribing to the wallpaper color change event. | -| callback | function | Yes | Callback triggered when the wallpaper color changes. The wallpaper type and main colors are returned.
- colors
Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).
- wallpaperType
Wallpaper type. | +| callback | function | Yes | Callback triggered when the wallpaper color changes. The wallpaper type and main colors are returned.
- colors
Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).
- wallpaperType
Wallpaper type. | **Example** -```js -let listener = (colors, wallpaperType) => { - console.log(`wallpaper color changed.`); -}; -wallpaper.on('colorChange', listener); -``` + ```js + let listener = (colors, wallpaperType) => { + console.log(`wallpaper color changed.`); + }; + wallpaper.on('colorChange', listener); + ``` ## wallpaper.off('colorChange') @@ -621,15 +684,15 @@ Unsubscribes from the wallpaper color change event. | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | | type | string | Yes | Type of the event to unsubscribe from. The value **colorChange** indicates unsubscribing from the wallpaper color change event. | -| callback | function | No | Callback for the wallpaper color change event. If this parameter is not specified, all callbacks corresponding to the wallpaper color change event are invoked.
- colors
Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).
- wallpaperType
Wallpaper type. | +| callback | function | No | Callback for the wallpaper color change event. If this parameter is not specified, all callbacks corresponding to the wallpaper color change event are invoked.
- colors
Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).
- wallpaperType
Wallpaper type. | **Example** -```js -let listener = (colors, wallpaperType) => { - console.log(`wallpaper color changed.`); -}; -wallpaper.on('colorChange', listener); + ```js + let listener = (colors, wallpaperType) => { + console.log(`wallpaper color changed.`); + }; + wallpaper.on('colorChange', listener); // Unsubscribe from the listener. wallpaper.off('colorChange', listener); //Unsubscribe from all subscriptions of the colorChange type. diff --git a/en/application-dev/reference/arkui-js/js-components-media-video.md b/en/application-dev/reference/arkui-js/js-components-media-video.md index 1e2b132c923351e37d92eafeea3bf71ef34d3fb1..b957ee6d968a2a4b038c4d600d7ea6adef966b40 100644 --- a/en/application-dev/reference/arkui-js/js-components-media-video.md +++ b/en/application-dev/reference/arkui-js/js-components-media-video.md @@ -1,240 +1,134 @@ -# video +# video -The **** component provides a video player. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- Configure the following information in the **config.json** file: -> ``` -> "configChanges": ["orientation"] -> ``` +> **NOTE**
+> +> - This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. +> +> - Set **configChanges** under **abilities** in the **config.json** file to **orientation**. +> ``` +> "abilities": [ +> { +> "configChanges": ["orientation"], +> ... +> } +> ] +> ``` -## Required Permissions +The **\