From a4a66bc8aa78a6f8209492733821e47a39a23bbf Mon Sep 17 00:00:00 2001 From: Gloria Date: Thu, 19 Jan 2023 16:13:29 +0800 Subject: [PATCH] Update docs against 12543 Signed-off-by: wusongqing --- en/application-dev/faqs/faqs-ability.md | 2 -- en/application-dev/faqs/faqs-graphics.md | 10 +++++----- en/application-dev/faqs/faqs-media.md | 14 +++++++++----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/en/application-dev/faqs/faqs-ability.md b/en/application-dev/faqs/faqs-ability.md index bff181efb9..aab3ecc19a 100644 --- a/en/application-dev/faqs/faqs-ability.md +++ b/en/application-dev/faqs/faqs-ability.md @@ -212,5 +212,3 @@ The following conditions must be met: 1. Before the redirection to the previous page, a confirm dialog box will be displayed. Note that **router.disableAlertBeforeBackPage** is used to disable the display of a confirm dialog box before returning to the previous page (default), and **router.enableAlertBeforeBackPage** is used to enable the display. 2. The system return key is used. - - \ No newline at end of file diff --git a/en/application-dev/faqs/faqs-graphics.md b/en/application-dev/faqs/faqs-graphics.md index 7752d9d746..7eeba06447 100644 --- a/en/application-dev/faqs/faqs-graphics.md +++ b/en/application-dev/faqs/faqs-graphics.md @@ -18,10 +18,10 @@ Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9 1. Use the **onWindowStageCreate** to obtain a **windowClass** object. - ``` + ```ts onWindowStageCreate(windowStage) { // When the main window is created, set the main page for this ability. - console.log("[Demo] MainAbility onWindowStageCreate") + console.log("[Demo] EntryAbility onWindowStageCreate") windowStage.getMainWindow((err, data) => { if (err.code) { console.error('Failed to obtain the main window.') @@ -35,7 +35,7 @@ Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9 2. Enable the full-screen mode for the window and hide the status bar. - ``` + ```ts globalThis.windowClass.setFullScreen(isFullScreen, (err, data) => { if (err.code) { console.error('Failed to enable the full-screen mode. Cause:' + JSON.stringify(err)); @@ -54,7 +54,7 @@ Use **window.getProperties()** to obtain the window properties. The **windowRect Example: -``` +```ts let promise = windowClass.getProperties(); promise.then((data)=> { console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data.windowRect)); @@ -70,7 +70,7 @@ Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 Refer to the following code: -``` +```ts window.getTopWindow(globalThis.mainContext).then(win => { var systemBarProperties = { statusBarColor: '#19B6FF', // Set the background color of the status bar. diff --git a/en/application-dev/faqs/faqs-media.md b/en/application-dev/faqs/faqs-media.md index 9f465834a0..0e88cf4e94 100644 --- a/en/application-dev/faqs/faqs-media.md +++ b/en/application-dev/faqs/faqs-media.md @@ -42,7 +42,7 @@ cameraInput = await this.cameraManager.createCameraInput(cameraId) Applicable to: OpenHarmony SDK 3.2.5.6, stage model of API version 9 1. Create an **ImageSource** instance based on the input URI. - + ``` let path = this.context.getApplicationContext().fileDirs + "test.jpg"; const imageSourceApi = image.createImageSource(path); @@ -52,7 +52,7 @@ Applicable to: OpenHarmony SDK 3.2.5.6, stage model of API version 9 - Set **desiredSize** to specify the target size after scaling. If the values are all set to **0**, scaling will not be performed. - Set **desiredRegion** to specify the target rectangular area after cropping. If the values are all set to **0**, cropping will not be performed. - Set **rotateDegrees** to specify the rotation angle. The image will be rotated clockwise at the center. - + ``` const decodingOptions = { desiredSize: { @@ -85,7 +85,7 @@ Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 1. Configure the permissions **ohos.permission.READ_MEDIA** and **ohos.permission.WRITE_MEDIA** in the **module.json5** file. Example: - + ``` { "module" : { @@ -104,10 +104,14 @@ Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 ``` 2. Call **requestPermissionsFromUser** to request the permissions from end users in the form of a dialog box. This operation is required because the grant mode of both permissions is **user_grant**. - + ``` + import abilityAccessCtrl from '@ohos.abilityAccessCtrl.d.ts'; + let permissions: Array = ['ohos.permission.READ_MEDIA','ohos.permission.WRITE_MEDIA'] - context.requestPermissionsFromUser(permissions).then((data) => { + let atManager = abilityAccessCtrl.createAtManager(); + // context is the ability-level context of the initiator UIAbility. + atManager.requestPermissionsFromUser(context, permissions).then((data) => { console.log("Succeed to request permission from user with data: " + JSON.stringify(data)) }).catch((error) => { console.log("Failed to request permission from user with error: " + JSON.stringify(error)) -- GitLab