> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>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**<br>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.
...
@@ -48,9 +48,9 @@ Creates a **PasteData** object for plain text.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>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**<br>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.
@@ -258,26 +259,26 @@ Checks whether to allow the application to change the wallpaper for the current
...
@@ -258,26 +259,26 @@ Checks whether to allow the application to change the wallpaper for the current
| Name | Type | Mandatory | Description |
| 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**
**Example**
```js
```js
wallpaper.isChangePermitted((error,data)=>{
wallpaper.isChangePermitted((error,data)=>{
if(error){
if(error){
console.error(`failed to isChangePermitted because: `+JSON.stringify(error));
console.error(`failed to isChangePermitted because: `+JSON.stringify(error));
return;
return;
}
}
console.log(`success to isChangePermitted: `+JSON.stringify(data));
console.log(`success to isChangePermitted: `+JSON.stringify(data));
});
});
```
```
## wallpaper.isChangePermitted
## wallpaper.isChangePermitted
isChangePermitted(): Promise<boolean>
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.
@@ -285,24 +286,24 @@ Checks whether to allow the application to change the wallpaper for the current
...
@@ -285,24 +286,24 @@ Checks whether to allow the application to change the wallpaper for the current
| Type | Description |
| 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**
**Example**
```js
```js
wallpaper.isChangePermitted().then((data)=>{
wallpaper.isChangePermitted().then((data)=>{
console.log(`success to isChangePermitted: `+JSON.stringify(data));
console.log(`success to isChangePermitted: `+JSON.stringify(data));
}).catch((error)=>{
}).catch((error)=>{
console.error(`failed to isChangePermitted because: `+JSON.stringify(error));
console.error(`failed to isChangePermitted because: `+JSON.stringify(error));
@@ -310,26 +311,26 @@ Checks whether the user is allowed to set wallpapers.
...
@@ -310,26 +311,26 @@ Checks whether the user is allowed to set wallpapers.
| Name | Type | Mandatory | Description |
| 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**
**Example**
```js
```js
wallpaper.isOperationAllowed((error,data)=>{
wallpaper.isOperationAllowed((error,data)=>{
if(error){
if(error){
console.error(`failed to isOperationAllowed because: `+JSON.stringify(error));
console.error(`failed to isOperationAllowed because: `+JSON.stringify(error));
return;
return;
}
}
console.log(`success to isOperationAllowed: `+JSON.stringify(data));
console.log(`success to isOperationAllowed: `+JSON.stringify(data));
});
});
```
```
## wallpaper.isOperationAllowed
## wallpaper.isOperationAllowed
isOperationAllowed(): Promise<boolean>
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.
@@ -337,26 +338,26 @@ Checks whether the user is allowed to set wallpapers.
...
@@ -337,26 +338,26 @@ Checks whether the user is allowed to set wallpapers.
| Type | Description |
| 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**
**Example**
```js
```js
wallpaper.isOperationAllowed().then((data)=>{
wallpaper.isOperationAllowed().then((data)=>{
console.log(`success to isOperationAllowed: `+JSON.stringify(data));
console.log(`success to isOperationAllowed: `+JSON.stringify(data));
}).catch((error)=>{
}).catch((error)=>{
console.error(`failed to isOperationAllowed because: `+JSON.stringify(error));
console.error(`failed to isOperationAllowed because: `+JSON.stringify(error));
| 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. |
@@ -400,26 +401,26 @@ Removes a wallpaper of the specified type and restores the default one.
...
@@ -400,26 +401,26 @@ Removes a wallpaper of the specified type and restores the default one.
| Type | Description |
| 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. |
| 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. |
| 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,25 +436,25 @@ Sets a specified source as the wallpaper of a specified type.
...
@@ -435,25 +436,25 @@ Sets a specified source as the wallpaper of a specified 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) {
| Promise<void> | Promise used to return the result. If the operation is successful, the result is returned. Otherwise, error information is returned.|
@@ -596,16 +659,16 @@ Subscribes to the wallpaper color change event.
...
@@ -596,16 +659,16 @@ Subscribes to the wallpaper color change event.
| Name | Type | Mandatory | Description |
| 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. |
| 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.<br/>- colors<br/> Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).<br/>- wallpaperType<br/> Wallpaper type. |
| callback | function | Yes | Callback triggered when the wallpaper color changes. The wallpaper type and main colors are returned.<br>- colors<br> Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).<br>- wallpaperType<br> Wallpaper type. |
**Example**
**Example**
```js
```js
letlistener=(colors,wallpaperType)=>{
let listener = (colors, wallpaperType) => {
console.log(`wallpaper color changed.`);
console.log(`wallpaper color changed.`);
};
};
wallpaper.on('colorChange',listener);
wallpaper.on('colorChange', listener);
```
```
## wallpaper.off('colorChange')
## wallpaper.off('colorChange')
...
@@ -621,15 +684,15 @@ Unsubscribes from the wallpaper color change event.
...
@@ -621,15 +684,15 @@ Unsubscribes from the wallpaper color change event.
| Name | Type | Mandatory | Description |
| 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. |
| 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.<br/>- colors<br/> Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).<br/>- wallpaperType<br/> 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.<br>- colors<br> Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).<br>- wallpaperType<br> Wallpaper type. |
**Example**
**Example**
```js
```js
letlistener=(colors,wallpaperType)=>{
let listener = (colors, wallpaperType) => {
console.log(`wallpaper color changed.`);
console.log(`wallpaper color changed.`);
};
};
wallpaper.on('colorChange',listener);
wallpaper.on('colorChange', listener);
// Unsubscribe from the listener.
// Unsubscribe from the listener.
wallpaper.off('colorChange', listener);
wallpaper.off('colorChange', listener);
//Unsubscribe from all subscriptions of the colorChange type.
//Unsubscribe from all subscriptions of the colorChange type.