未验证 提交 50ab4bb5 编写于 作者: O openharmony_ci 提交者: Gitee

!23887 翻译完成:22404 增加window安全水印说明文档

Merge pull request !23887 from wusongqing/TR22404
...@@ -895,7 +895,7 @@ Unsubscribes from the gesture navigation status change event. ...@@ -895,7 +895,7 @@ Unsubscribes from the gesture navigation status change event.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------- | -- | ------------------------------------------------------------ | | -------- | ----------------------- | -- | ------------------------------------------------------------ |
| type | string | Yes| Event type. The value is fixed at **'gestureNavigationEnabledChange'**, indicating the gesture navigation status change event.| | 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** **Error codes**
...@@ -916,6 +916,78 @@ try { ...@@ -916,6 +916,78 @@ try {
} }
``` ```
## window.on('waterMarkFlagChange')<sup>10+</sup>
on(type: 'waterMarkFlagChange', callback: Callback&lt;boolean&gt;): 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&lt;boolean&gt; | 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')<sup>10+</sup>
off(type: 'waterMarkFlagChange', callback?: Callback&lt;boolean&gt;): 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&lt;boolean&gt; | 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.setGestureNavigationEnabled<sup>10+</sup> ## window.setGestureNavigationEnabled<sup>10+</sup>
setGestureNavigationEnabled(enable: boolean, callback: AsyncCallback&lt;void&gt;): void setGestureNavigationEnabled(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
...@@ -1002,6 +1074,122 @@ try { ...@@ -1002,6 +1074,122 @@ try {
} }
``` ```
## window.setWaterMarkImage<sup>10+</sup>
setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean, callback: AsyncCallback&lt;void&gt;): 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&lt;void&gt; | 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.setWaterMarkImage<sup>10+</sup>
setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean): Promise&lt;void&gt;
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&lt;void&gt; | 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<sup>(deprecated)</sup> ## window.create<sup>(deprecated)</sup>
create(id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void create(id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void
...@@ -2470,28 +2658,28 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -2470,28 +2658,28 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
export default class EntryAbility extends UIAbility { export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
// Load content for the main window. // Load content for the main window.
windowStage.loadContent("pages/page2", (err) => { windowStage.loadContent("pages/page2", (err) => {
if (err.code) { if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in loading the content.'); console.info('Succeeded in loading the content.');
}); // Obtain the main window.
// Obtain the main window. let windowClass = null;
let windowClass = null; windowStage.getMainWindow((err, data) => {
windowStage.getMainWindow((err, data) => { if (err.code) {
if (err.code) { console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); return;
return; }
} windowClass = data;
windowClass = data; console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); // Obtain a UIContext instance.
// Obtain a UIContext instance. globalThis.uiContext = windowClass.getUIContext();
globalThis.uiContext = windowClass.getUIContext(); })
}) });
} }
}; };
``` ```
...@@ -5476,7 +5664,7 @@ In non-full-screen mode, the status bar and navigation bar are displayed, and th ...@@ -5476,7 +5664,7 @@ In non-full-screen mode, the status bar and navigation bar are displayed, and th
> **NOTE** > **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 **System capability**: SystemCapability.WindowManager.WindowManager.Core
...@@ -5507,11 +5695,12 @@ setFullScreen(isFullScreen: boolean): Promise&lt;void&gt; ...@@ -5507,11 +5695,12 @@ setFullScreen(isFullScreen: boolean): Promise&lt;void&gt;
Sets whether the window is in full-screen mode. This API uses a promise to return the result. 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 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. 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** > **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 **System capability**: SystemCapability.WindowManager.WindowManager.Core
...@@ -6538,7 +6727,9 @@ promise.then(()=> { ...@@ -6538,7 +6727,9 @@ promise.then(()=> {
setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback&lt;void&gt;): void setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback&lt;void&gt;): 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** > **NOTE**
> >
...@@ -6570,7 +6761,9 @@ windowClass.setPrivacyMode(isPrivacyMode, (err) => { ...@@ -6570,7 +6761,9 @@ windowClass.setPrivacyMode(isPrivacyMode, (err) => {
setPrivacyMode(isPrivacyMode: boolean): Promise&lt;void&gt; setPrivacyMode(isPrivacyMode: boolean): Promise&lt;void&gt;
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** > **NOTE**
> >
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册