diff --git a/en/application-dev/reference/apis/js-apis-window.md b/en/application-dev/reference/apis/js-apis-window.md index 13edbc7a924ff1e0b5ad8ef7f3f6f2720eb49de2..517852cee622e2d7554a12ce7c3251562472dc8b 100644 --- a/en/application-dev/reference/apis/js-apis-window.md +++ b/en/application-dev/reference/apis/js-apis-window.md @@ -895,7 +895,7 @@ Unsubscribes from the gesture navigation status change event. | Name | Type | Mandatory| Description | | -------- | ----------------------- | -- | ------------------------------------------------------------ | | type | string | Yes| Event type. The value is fixed at **'gestureNavigationEnabledChange'**, indicating the gesture navigation status change event.| -| callback | Callback<boolean> | No| Callback function that has been used for registering the listener. If a value is passed in, the corresponding subscription is canceled. If no value is passed in, all subscriptions to the specified event are canceled.| +| callback | Callback<boolean> | No| Callback function that has been used for the subscription. If a value is passed in, the corresponding subscription is canceled. If no value is passed in, all subscriptions to the specified event are canceled.| **Error codes** @@ -916,6 +916,78 @@ try { } ``` +## window.on('waterMarkFlagChange')10+ + +on(type: 'waterMarkFlagChange', callback: Callback<boolean>): void + +Subscribes to the watermark status change event. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | ----------------------------------------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **'waterMarkFlagChange'**, indicating the watermark status change event. | +| callback | Callback<boolean> | Yes | Callback used to return the watermark status. The value **true** means that the watermark feature is enabled, and **false** means the opposite.| + +**Error codes** + +For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 1300003 | This window manager service works abnormally. | + +**Example** + +```js +try { + window.on('waterMarkFlagChange', (data) => { + console.info('Succeeded in enabling the listener for watermark flag changes. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to enable the listener for watermark flag changes. Cause: ' + JSON.stringify(exception)); +} +``` + +## window.off('waterMarkFlagChange')10+ + +off(type: 'waterMarkFlagChange', callback?: Callback<boolean>): void + +Unsubscribes from the watermark status change event. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | -- | ------------------------------------------------------------ | +| type | string | Yes| Event type. The value is fixed at **'waterMarkFlagChange'**, indicating the watermark status change event.| +| callback | Callback<boolean> | No| Callback function that has been used for the subscription. If a value is passed in, the corresponding subscription is canceled. If no value is passed in, all subscriptions to the specified event are canceled.| + +**Error codes** + +For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 1300003 | This window manager service works abnormally. | + +**Example** + +```js +try { + window.off('waterMarkFlagChange'); +} catch (exception) { + console.error('Failed to disable the listener for watermark flag changes. Cause: ' + JSON.stringify(exception)); +} +``` + ## window.setGestureNavigationEnabled10+ setGestureNavigationEnabled(enable: boolean, callback: AsyncCallback<void>): void @@ -1002,6 +1074,122 @@ try { } ``` +## window.setWaterMarkImage10+ +setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean, callback: AsyncCallback<void>): void + +Sets the watermark image display status. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------- | +| pixelMap | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes| Watermark image.| +| enable | boolean | Yes | Whether to display the watermark image. The value **true** means to display the watermark image, and **false** means the opposite.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| + +**Error codes** + +For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md). + +| ID| Error Message| +| ------- | --------------------------------------------- | +| 1300003 | This window manager service works abnormally. | + +**Example** + +```js +import image from '@ohos.multimedia.image'; + +let enable = true; +let color = new ArrayBuffer(0); +let initializationOptions = { + size: { + height: 100, + width: 100 + } +}; +image.createPixelMap(color, initializationOptions).then((pixelMap) => { + console.info('Succeeded in creating pixelmap.'); + try { + window.setWaterMarkImage(pixelMap, enable, (err) => { + if (err.code) { + console.error('Failed to show watermark image. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in showing watermark image.'); + }); + } catch (exception) { + console.error('Failed to show watermark image. Cause: ' + JSON.stringify(exception)); + } +}).catch((err) => { + console.error('Failed to create PixelMap. Cause: ' + JSON.stringify(err)); +}); +``` + +## window.setWaterMarkImage10+ +setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean): Promise<void> + +Sets the watermark image display status. This API uses a promise to return the result. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name| Type | Mandatory | Description | +| ------ | --------------------------- | ---- | -------------------- | +| pixelMap | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes| Watermark image.| +| enable | boolean | Yes | Whether to display the watermark image. The value **true** means to display the watermark image, and **false** means the opposite.| + +**Return value** + +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| + +**Error codes** + +For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 1300003 | This window manager service works abnormally. | + +**Example** + +```js +import image from '@ohos.multimedia.image'; + +let enable = true; +let color = new ArrayBuffer(0); +let initializationOptions = { + size: { + height: 100, + width: 100 + } +}; +image.createPixelMap(color, initializationOptions).then((pixelMap) => { + console.info('Succeeded in creating pixelmap.'); + try { + let promise = window.setWaterMarkImage(pixelMap, enable); + promise.then(() => { + console.info('Succeeded in showing watermark image.'); + }).catch((err) => { + console.error('Failed to show watermark image. Cause: ' + JSON.stringify(err)); + }); + } catch (exception) { + console.error('Failed to show watermark image. Cause: ' + JSON.stringify(exception)); + } +}).catch((err) => { + console.error('Failed to create PixelMap. Cause: ' + JSON.stringify(err)); +}); +``` + ## window.create(deprecated) create(id: string, type: WindowType, callback: AsyncCallback<Window>): void @@ -2470,28 +2658,28 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc import UIAbility from '@ohos.app.ability.UIAbility'; export default class EntryAbility extends UIAbility { - onWindowStageCreate(windowStage) { - // Load content for the main window. - windowStage.loadContent("pages/page2", (err) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in loading the content.'); - }); - // Obtain the main window. - let windowClass = null; - windowStage.getMainWindow((err, data) => { - if (err.code) { - console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); - // Obtain a UIContext instance. - globalThis.uiContext = windowClass.getUIContext(); - }) - } + onWindowStageCreate(windowStage) { + // Load content for the main window. + windowStage.loadContent("pages/page2", (err) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content.'); + // Obtain the main window. + let windowClass = null; + windowStage.getMainWindow((err, data) => { + if (err.code) { + console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); + // Obtain a UIContext instance. + globalThis.uiContext = windowClass.getUIContext(); + }) + }); + } }; ``` @@ -5476,7 +5664,7 @@ In non-full-screen mode, the status bar and navigation bar are displayed, and th > **NOTE** > -> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowSystemBarEnable()](#setwindowsystembarenable9) instead. +> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowSystemBarEnable()](#setwindowsystembarenable9) and [setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9) to implement the full-screen mode. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -5507,11 +5695,12 @@ setFullScreen(isFullScreen: boolean): Promise<void> Sets whether the window is in full-screen mode. This API uses a promise to return the result. In full-screen mode, the window is displayed in full screen, and the status bar and navigation bar are not displayed. + In non-full-screen mode, the status bar and navigation bar are displayed, and the window size does not overlap the positions of the status bar and navigation bar. > **NOTE** > -> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowSystemBarEnable()](#setwindowsystembarenable9-1) instead. +> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowSystemBarEnable()](#setwindowsystembarenable9-1) and [setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9-1) to implement the full-screen mode. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -6538,7 +6727,9 @@ promise.then(()=> { setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void -Sets whether this window is in privacy mode. This API uses an asynchronous callback to return the result. When in privacy mode, the window content cannot be captured or recorded. +Sets whether this window is in privacy mode. This API uses an asynchronous callback to return the result. + +A window in privacy mode cannot be captured or recorded. > **NOTE** > @@ -6570,7 +6761,9 @@ windowClass.setPrivacyMode(isPrivacyMode, (err) => { setPrivacyMode(isPrivacyMode: boolean): Promise<void> -Sets whether this window is in privacy mode. This API uses a promise to return the result. When in privacy mode, the window content cannot be captured or recorded. +Sets whether this window is in privacy mode. This API uses a promise to return the result. + +A window in privacy mode cannot be captured or recorded. > **NOTE** >