未验证 提交 96a01acb 编写于 作者: O openharmony_ci 提交者: Gitee

!13468 翻译完成:12528+12508+12552 回流格式问题修改

Merge pull request !13468 from wusongqing/TR12149
# Camera Management
# @ohos.multimedia.camera (Camera Management)
> **NOTE**
>
......@@ -22,7 +22,7 @@ Obtains a **CameraManager** instance. This API uses an asynchronous callback to
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------- | ---- | ---------------------------- |
| context | [Context](../../ability/context-userguide.md) | Yes | Application context. |
| context | [Context](js-apis-inner-app-context.md) | Yes | Application context. |
| callback | AsyncCallback<[CameraManager](#cameramanager)\> | Yes | Callback used to return the **CameraManager** instance.|
**Example**
......@@ -49,7 +49,7 @@ Obtains a **CameraManager** instance. This API uses a promise to return the resu
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | ------------ |
| context | [Context](../../ability/context-userguide.md) | Yes | Application context.|
| context | [Context](js-apis-inner-app-context.md) | Yes | Application context.|
**Return value**
......@@ -757,7 +757,7 @@ This is a system API.
| Name | Type | Mandatory| Description |
| -------- | --------------- | ---- | --------- |
| type | string | Yes | Event type. The value is fixed at **'cameraMute'**, indicating the camera mute status change event.|
| callback | AsyncCallback<boolean> | Yes | Callback used to return the camera mute status. |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the camera mute status. |
**Example**
......
......@@ -180,7 +180,8 @@ To create a better video watching and gaming experience, you can use the immersi
}
console.info('Succeeded in setting the system bar to be visible.');
});
// Use method 2 to implement the immersive effect.
// Use method 2 to implement the immersive effect.
let isLayoutFullScreen = true;
mainWindowClass.setWindowLayoutFullScreen(isLayoutFullScreen, (err) => {
if (err.code) {
......@@ -204,7 +205,7 @@ To create a better video watching and gaming experience, you can use the immersi
console.info('Succeeded in setting the system bar properties.');
});
```
3. Load content for the immersive window and show it.
Call **SetUIContent** and **showWindow** to load and display the content in the immersive window.
......
......@@ -55,12 +55,15 @@ In the stage model, the main window of an application is created and maintained
### How to Develop
1. Obtain the main window.
Call **getMainWindow** to obtain the main window of the application.
2. Set the properties of the main window.
You can set multiple properties of the main window, such as the background color, brightness, and whether the main window is touchable. The code snippet below uses the **touchable** property as an example.
3. Load content for the main window.
Call **loadContent** to load the page content to the main window.
```ts
......@@ -108,17 +111,21 @@ You can create an application subwindow, such as a dialog box, and set its prope
### How to Develop
1. Create a subwindow.
Call **createSubWindow** to create a subwindow.
2. Set the properties of the subwindow.
After the subwindow is created, you can set its properties, such as the size, position, background color, and brightness.
3. Load content for the subwindow and show it.
Call **setUIContent** and **showWindow** to load and display the content in the subwindow.
4. Destroy the subwindow.
When the subwindow is no longer needed, you can call **destroyWindow** to destroy it.
```ts
import Ability from '@ohos.application.Ability'
......@@ -201,6 +208,7 @@ To create a better video watching and gaming experience, you can use the immersi
### How to Develop
1. Obtain the main window.
Call **getMainWindow** to obtain the main window of the application.
2. Implement the immersive effect. You can use any of the following methods:
......@@ -208,8 +216,9 @@ To create a better video watching and gaming experience, you can use the immersi
- Method 2: Call **setWindowLayoutFullScreen** to enable the full-screen mode for the main window layout. Call **setWindowSystemBarProperties** to set the opacity, background color, text color, and highlighted icon of the navigation bar and status bar to ensure that their display effect is consistent with that of the main window.
3. Load content for the immersive window and show it.
Call **loadContent** to load the content to the immersive window.
```ts
import Ability from '@ohos.application.Ability'
......@@ -279,12 +288,13 @@ A floating window is created based on an existing task. It is always displayed i
### How to Develop
1. Apply for permissions.
To create a floating window (of the **WindowType.TYPE_FLOAT** type), you must configure the **ohos.permission.SYSTEM_FLOAT_WINDOW** permission in the **requestPermissions** field of the **module.json5** file. For more configuration information, see [module.json5 Configuration File](../quick-start/module-configuration-file.md).
> **NOTE**
>
> If the task for creating the floating window is reclaimed by the system, the floating window will no longer be displayed. If you want the floating window to be displayed in such a case, apply for a [continuous task](../task-management/background-task-overview.md).
```json
{
"module": {
......@@ -304,12 +314,15 @@ A floating window is created based on an existing task. It is always displayed i
```
2. Create a floating window.
Call **window.createWindow** to create a floating window.
3. Set properties for the floating window.
After the floating window is created, you can set its properties, such as the size, position, background color, and brightness.
4. Load content for the floating window and show it.
Call **setUIContent** and **showWindow** to load and display the content in the floating window.
5. Destroy the floating window.
......
......@@ -4,6 +4,12 @@
In the stage model, system applications are allowed to create and manage system windows, including the volume bar, wallpaper, notification panel, status bar, and navigation bar. For details about the supported system window types, see [WindowType in Window](../reference/apis/js-apis-window.md#windowtype7).
When a window is displayed, hidden, or switched, an animation is usually used to smooth the interaction process.
In OpenHarmony, the animation is the default behavior for application windows. You do not need to set or modify the code.
However, you can customize an animation to be played during the display or hiding of a system window.
> **NOTE**
>
> This document involves the use of system APIs. Use the full SDK for development. For details, see [Guide to Switching to Full SDK](../quick-start/full-sdk-switch-guide.md).
......@@ -13,22 +19,26 @@ In the stage model, system applications are allowed to create and manage system
For details, see [Window](../reference/apis/js-apis-window.md).
| Instance| API| Description|
| -------- | -------- | -------- |
| Window static method| createWindow(config: Configuration, callback: AsyncCallback\<Window>): void | Creates a subwindow or system window.<br>**config** specifies the parameters used for creating the window.|
| Window | resize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): void | Changes the window size.|
| Window | moveWindowTo(x: number, y: number, callback: AsyncCallback&lt;void&gt;): void | Moves this window.|
| Window | SetUIContent(path: string, callback: AsyncCallback&lt;void&gt;): void | Loads the page content to this window.|
| Window | showWindow(callback: AsyncCallback\<void>): void | Shows this window.|
| Window | on(type: 'touchOutside', callback: Callback&lt;void&gt;): void | Enables listening for click events outside this window.|
| Window | hide (callback: AsyncCallback\<void>): void | Hides this window. This is a system API.|
| Window | destroyWindow(callback: AsyncCallback&lt;void&gt;): void | Destroys this window.|
| Instance | API | Description |
| ----------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| Window static method | createWindow(config: Configuration, callback: AsyncCallback\<Window>): void | Creates a subwindow or system window.<br>**config** specifies the parameters used for creating the window. |
| Window | resize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): void | Changes the window size. |
| Window | moveWindowTo(x: number, y: number, callback: AsyncCallback&lt;void&gt;): void | Moves this window. |
| Window | SetUIContent(path: string, callback: AsyncCallback&lt;void&gt;): void | Loads the page content to this window. |
| Window | showWindow(callback: AsyncCallback\<void>): void | Shows this window. |
| Window | on(type: 'touchOutside', callback: Callback&lt;void&gt;): void | Enables listening for click events outside this window. |
| Window | hide (callback: AsyncCallback\<void>): void | Hides this window. This is a system API. |
| Window | destroyWindow(callback: AsyncCallback&lt;void&gt;): void | Destroys this window. |
| Window | getTransitionController(): TransitionController | Obtains the transition animation controller. This is a system API. |
| TransitionContext | completeTransition(isCompleted: boolean): void | Completes the transition. This API can be called only after [animateTo()](../reference/arkui-ts/ts-explicit-animation.md) is executed. This is a system API.|
| Window | showWithAnimation(callback: AsyncCallback\<void>): void | Shows this window and plays an animation during the process. This is a system API. |
| Window | hideWithAnimation(callback: AsyncCallback\<void>): void | Hides this window and plays an animation during the process. This is a system API. |
## How to Develop
## Developing a System Window
This section uses the volume bar as an example to describe how to develop a system window.
This section uses the volume bar as an example to describe the steps for system window development.
### How to Develop
1. Create a system window.
......@@ -112,3 +122,140 @@ export default class ServiceExtensionAbility1 extends ExtensionContext {
}
};
```
## Customizing an Animation to Be Played During the Display or Hiding of a System Window
You can determine whether to play an animation when a system window is showing or hiding.
### How to Develop
1. Obtain the transition animation controller.
Call **getTransitionController** to obtain the controller, which completes subsequent animation operations.
2. Configure the animation to be played.
Call [animateTo()](../reference/arkui-ts/ts-explicit-animation.md) to configure the animation attributes.
3. Complete the transition.
Use **completeTransition(true)** to set the completion status of the transition. If **false** is passed in, the transition is canceled.
4. Show or hide the system window and play the animation during the process.
Call **showWithAnimation** to show the window and play the animation. Call **hideWithAnimation** to hide the window and play the animation.
```ts
import ExtensionContext from '@ohos.app.ability.ServiceExtensionAbility';
import window from '@ohos.window';
export default class ServiceExtensionAbility1 extends ExtensionContext {
onCreate(want) {
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
// Create a volume bar window.
let windowClass = null;
let config = {name: "volume", windowType: window.WindowType.TYPE_VOLUME_OVERLAY, ctx: this.context};
window.createWindow(config, (err, data) => {
if (err.code) {
console.error('Failed to create the volume window. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in creating the volume window.')
windowClass = data;
// Customize an animation to be played during the display of the system window.
// 1. Obtain the transition animation controller.
let controller = windowClass.getTransitionController();
// 2. Configure the animation to be played.
controller.animationForShown = (context : window.TransitionContext) => {
let toWindow = context.toWindow
// Set the animation attributes.
animateTo({
duration: 1000, // Animation duration.
tempo: 0.5, // Playback speed.
curve: Curve.EaseInOut, // Animation curve.
delay: 0, // Animation delay.
iterations: 1, // Number of playback times.
playMode: PlayMode.Normal // Animation playback mode.
onFinish: ()=> {
// 3. Complete the transition.
context.completeTransition(true)
}
}, () => {
let obj : window.TranslateOptions = {
x : 100.0,
y : 0.0,
z : 0.0
}
toWindow.translate(obj);
console.info('toWindow translate end');
})
console.info('complete transition end');
}
windowClass.loadContent("pages/page_volume", (err) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content.');
// 4. Show the window and play the animation during the process.
windowClass.showWithAnimation((err) => {
if (err.code) {
console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in showing the window with animation.');
})
});
});
}
onDestroy() {
let windowClass = null;
try {
windowClass = window.findWindow('volume');
} catch (exception) {
console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception));
}
// Customize an animation to be played during the hiding of the system window.
// 1. Obtain the transition animation controller.
let controller = windowClass.getTransitionController();
// 2. Configure the animation to be played.
controller.animationForHidden = (context : window.TransitionContext) => {
let toWindow = context.toWindow
// Set the animation attributes.
animateTo({
duration: 1000, // Animation duration.
tempo: 0.5, // Playback speed.
curve: Curve.EaseInOut, // Animation curve.
delay: 0, // Animation delay.
iterations: 1, // Number of playback times.
playMode: PlayMode.Normal // Animation playback mode.
onFinish: ()=> {
// 3. Complete the transition.
context.completeTransition(true)
windowClass.destroyWindow((err) => {
if (err.code) {
console.error('Failed to destroy the window. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in destroying the window.');
});
}
}, () => {
toWindow.opacity(0.0);
console.info('toWindow opacity end');
})
console.info('complete transition end');
}
// 4. Hide the window and play the animation during the process.
windowClass.hideWithAnimation((err) => {
if (err.code) {
console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in hiding the window with animation.');
});
}
};
```
......@@ -56,7 +56,7 @@ The application window mode refers to the display mode of the main window when i
The window implementation and development vary according to the application development model, that is, FA model and stage model.
For details about the overall architecture and design ideas of the two models, see [FA Model Overview](../ability/fa-brief.md) and [Stage Model Overview](../ability/stage-brief.md).
For details about the overall architecture and design ideas of the two models, see [Interpretation of the Application Model](../application-models/application-model-description.md).
You are advised to use the stage model for window development.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册