diff --git a/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo01.ets b/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo01.ets deleted file mode 100644 index 76d1c1c03c2aa1f8272c09c9976d94ed9664628b..0000000000000000000000000000000000000000 --- a/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo01.ets +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { webview } from '@kit.ArkWeb'; -import { common } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { AlertDialog, ComponentContent, promptAction, window } from '@kit.ArkUI'; -import { Constants } from '../common/Constants'; -import { WebDownloadManager } from '../utils/WebDownloadManager'; -import { downloadControlBuilder } from '../view/DownloadControlView'; -import { customPopupMenuBuilder, getOffset } from '../view/CustomPopupMenu'; -const uiContext: UIContext | undefined = AppStorage.get('uiContext'); -let context = uiContext!.getHostContext() -@Entry -@Component -struct Index { - @State isShow: boolean = false; - @State pressPosY: number = 0; - @State pressPosX: number = 0; - @StorageProp(Constants.SYSTEM_LANGUAGE_KEY) language: string = ''; - private handler: FullScreenExitHandler | null = null; - private result: WebContextMenuResult | null = null; - private webController: webview.WebviewController = new webview.WebviewController(); - private isFullScreen: boolean = false; - private linkUrl: string = ''; - private webWidth: number = 0; - private webHeight: number = 0; - private windowClass: window.Window | null = null; - private context: common.UIAbilityContext = context as common.UIAbilityContext; - private manager: WebDownloadManager = WebDownloadManager.getInstance(); - private ctx: UIContext = this.getUIContext(); - private options: promptAction.BaseDialogOptions = { - alignment: DialogAlignment.Center, - isModal: true, - autoCancel: false, - onWillDismiss: () => { - WebDownloadManager.getInstance().pause(); - this.dialogControllerConfirm.open(); - } - }; - private contentNode: ComponentContent = new ComponentContent(this.ctx, wrapBuilder(downloadControlBuilder)); - private dialogControllerConfirm: CustomDialogController = new CustomDialogController({ - builder: AlertDialog({ - primaryTitle: $r('app.string.confirm_cancel'), - content: $r('app.string.confirm_task_cancel'), - primaryButton: { - value: $r('app.string.cancel_download'), - fontColor: Color.Red, - action: () => { - this.manager.cancel(); - this.closeDownloadDialog(); - } - }, - secondaryButton: { - value: $r('app.string.resume_download'), - action: () => { - this.manager.unpause(); - } - } - }) - }); - private openDownloadDialog = () => { - this.ctx.getPromptAction().openCustomDialog(this.contentNode, this.options); - }; - private closeDownloadDialog = () => { - this.ctx.getPromptAction().closeCustomDialog(this.contentNode); - }; - private changeIsShow = () => { - this.isShow = !this.isShow; - }; - - aboutToAppear(): void { - window.getLastWindow(this.context).then((windowClass) => this.windowClass = windowClass); - this.manager.registerController(Constants.INDEX_WEB_CONTROLLER, this.webController); - AppStorage.setOrCreate>('contentNode', this.contentNode); - hilog.info(0x000, Constants.TAG, 'language: ' + this.language); - } - - /** - * Changes the preferred orientation of the window. - * - * @param orientation - The preferred orientation to set. This should be a value from the `window.Orientation` enum. - * @returns void - This function does not return any value. - */ - changeOrientation(orientation: window.Orientation) { - this.windowClass?.setPreferredOrientation(orientation); - } - - onBackPress(): boolean | void { - if (this.isFullScreen && this.handler) { - this.handler.exitFullScreen(); - return true; - } - return false; - } - - build() { - Column() { - // [Start web] - // src/main/ets/pages/Index.ets - - Web({ - src: $rawfile(/zh/.test(this.language) ? 'index_cn.html' : 'index_en.html'), - controller: this.webController - }) - // [StartExclude web] - .zoomAccess(false) - .width('100%') - .height('100%') - // [EndExclude web] - .expandSafeArea([SafeAreaType.SYSTEM]) - // [End web] - .onAreaChange((oldArea, newArea) => { - this.webWidth = newArea.width as number; - this.webHeight = newArea.height as number; - }) - .onContextMenuShow((event) => { - if (!event) { - return false; - } - this.result = event.result; - this.pressPosX = this.getUIContext().px2vp(event.param.x()); - this.pressPosY = this.getUIContext().px2vp(event.param.y()); - this.linkUrl = event.param.getSourceUrl(); - this.isShow = true; - return true; - }) - .bindPopup(this.isShow, { - builder: customPopupMenuBuilder( - this.linkUrl, - this.context, - this.openDownloadDialog, - this.closeDownloadDialog, - this.changeIsShow, - ), - enableArrow: false, - placement: Placement.TopLeft, - offset: getOffset(this.webWidth, this.webHeight, - this.pressPosX, this.pressPosY), - onStateChange: (e) => { - if (!e.isVisible) { - this.isShow = false; - this.result?.closeContextMenu(); - } - } - }) - .onFullScreenEnter((event) => { - this.handler = event.handler; - this.changeOrientation(window.Orientation.LANDSCAPE); - this.isFullScreen = true; - }) - .onFullScreenExit(() => { - this.changeOrientation(window.Orientation.PORTRAIT); - this.isFullScreen = false; - }) - } - } -} \ No newline at end of file diff --git a/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo02.ets b/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo02.ets deleted file mode 100644 index 244c6ac9d92b2fd6a41a23b9863ea1278ee45150..0000000000000000000000000000000000000000 --- a/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo02.ets +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { window } from '@kit.ArkUI'; -import { common } from '@kit.AbilityKit'; - -// src/main/ets/pages/Index.ets -const uiContext: UIContext | undefined = AppStorage.get('uiContext'); -let context = uiContext!.getHostContext() -// [Start component_index] -@Entry -@Component -struct Index { - private windowClass: window.Window | null = null; - private context: common.UIAbilityContext = context as common.UIAbilityContext; - - aboutToAppear(): void { - window.getLastWindow(this.context).then((windowClass) => this.windowClass = windowClass); - } - - /** - * Changes the preferred orientation of the window. - * - * @param orientation - The preferred orientation to set. This should be a value from the `window.Orientation` enum. - * @returns void - This function does not return any value. - */ - changeOrientation(orientation: window.Orientation) { - this.windowClass?.setPreferredOrientation(orientation); - } - - build() { - } -} -// [End component_index] \ No newline at end of file diff --git a/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo03.ets b/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo03.ets deleted file mode 100644 index 35f09f466bb2e413ac39a576ebee30837d27a099..0000000000000000000000000000000000000000 --- a/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo03.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { window } from '@kit.ArkUI'; -import { Constants } from '../common/Constants'; -import { webview } from '@kit.ArkWeb'; - -// src/main/ets/pages/Index.ets - -// [Start isfull_screen] -@Entry -@Component -struct Index { - private isFullScreen: boolean = false; - private handler: FullScreenExitHandler | null = null; - // [StartExclude isfull_screen] - @StorageProp(Constants.SYSTEM_LANGUAGE_KEY) language: string = ''; - private webController: webview.WebviewController = new webview.WebviewController(); - private windowClass: window.Window | null = null; - - changeOrientation(orientation: window.Orientation) { - this.windowClass?.setPreferredOrientation(orientation); - } - // [EndExclude isfull_screen] - - build() { - Column() { - Web({ - src: $rawfile(/zh/.test(this.language) ? 'index_cn.html' : 'index_en.html'), - controller: this.webController - }) - .onFullScreenEnter((event) => { - this.handler = event.handler; - this.changeOrientation(window.Orientation.LANDSCAPE); - this.isFullScreen = true; - }) - } - } -} -// [End isfull_screen] \ No newline at end of file diff --git a/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo04.ets b/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo04.ets deleted file mode 100644 index cb1cd1273ef132142815737698dfa6972613e3d7..0000000000000000000000000000000000000000 --- a/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo04.ets +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { webview } from '@kit.ArkWeb'; -import { window } from '@kit.ArkUI'; -import { Constants } from '../common/Constants'; - -@Entry -@Component -struct Index { - @StorageProp(Constants.SYSTEM_LANGUAGE_KEY) language: string = ''; - private isFullScreen: boolean = false; - private windowClass: window.Window | null = null; - private handler: FullScreenExitHandler | null = null; - private webController: webview.WebviewController = new webview.WebviewController(); - - changeOrientation(orientation: window.Orientation) { - this.windowClass?.setPreferredOrientation(orientation); - } - - // [Start on_back_press] - // src/main/ets/pages/Index.ets - onBackPress(): boolean | void { - if (this.isFullScreen && this.handler) { - this.handler.exitFullScreen(); - return true; - } - return false; - } - // [End on_back_press] - - build() { - Column() { - // [Start rawfile] - // src/main/ets/pages/Index.ets - Web({ - src: $rawfile(/zh/.test(this.language) ? 'index_cn.html' : 'index_en.html'), - controller: this.webController - }) - .onFullScreenExit(() => { - this.changeOrientation(window.Orientation.PORTRAIT); - this.isFullScreen = false; - }) - // [End rawfile] - } - } -} \ No newline at end of file diff --git a/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo05.ets b/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo05.ets deleted file mode 100644 index 338fd5166c434a252ef763631819e87fa87613da..0000000000000000000000000000000000000000 --- a/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo05.ets +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { webview } from '@kit.ArkWeb'; -import { common } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { AlertDialog, ComponentContent, promptAction, window } from '@kit.ArkUI'; -import { Constants } from '../common/Constants'; -import { WebDownloadManager } from '../utils/WebDownloadManager'; -import { downloadControlBuilder } from '../view/DownloadControlView'; -import { customPopupMenuBuilder, getOffset } from '../view/CustomPopupMenu'; -// [Start uicontext_index] -// src/main/ets/pages/Index.ets -const uiContext: UIContext | undefined = AppStorage.get('uiContext'); -let context = uiContext!.getHostContext() -@Entry -@Component -struct Index { - @State isShow: boolean = false; - // [StartExclude uicontext_index] - @State pressPosY: number = 0; - @State pressPosX: number = 0; - @StorageProp(Constants.SYSTEM_LANGUAGE_KEY) language: string = ''; - private handler: FullScreenExitHandler | null = null; - private result: WebContextMenuResult | null = null; - private webController: webview.WebviewController = new webview.WebviewController(); - private isFullScreen: boolean = false; - private linkUrl: string = ''; - private webWidth: number = 0; - private webHeight: number = 0; - private windowClass: window.Window | null = null; - private context: common.UIAbilityContext = context as common.UIAbilityContext; - private manager: WebDownloadManager = WebDownloadManager.getInstance(); - private ctx: UIContext = this.getUIContext(); - private options: promptAction.BaseDialogOptions = { - alignment: DialogAlignment.Center, - isModal: true, - autoCancel: false, - onWillDismiss: () => { - WebDownloadManager.getInstance().pause(); - this.dialogControllerConfirm.open(); - } - }; - private contentNode: ComponentContent = new ComponentContent(this.ctx, wrapBuilder(downloadControlBuilder)); - private dialogControllerConfirm: CustomDialogController = new CustomDialogController({ - builder: AlertDialog({ - primaryTitle: $r('app.string.confirm_cancel'), - content: $r('app.string.confirm_task_cancel'), - primaryButton: { - value: $r('app.string.cancel_download'), - fontColor: Color.Red, - action: () => { - this.manager.cancel(); - this.closeDownloadDialog(); - } - }, - secondaryButton: { - value: $r('app.string.resume_download'), - action: () => { - this.manager.unpause(); - } - } - }) - }); - private openDownloadDialog = () => { - this.ctx.getPromptAction().openCustomDialog(this.contentNode, this.options); - }; - private closeDownloadDialog = () => { - this.ctx.getPromptAction().closeCustomDialog(this.contentNode); - }; - private changeIsShow = () => { - this.isShow = !this.isShow; - }; - - aboutToAppear(): void { - window.getLastWindow(this.context).then((windowClass) => this.windowClass = windowClass); - this.manager.registerController(Constants.INDEX_WEB_CONTROLLER, this.webController); - AppStorage.setOrCreate>('contentNode', this.contentNode); - hilog.info(0x000, Constants.TAG, 'language: ' + this.language); - } - - /** - * Changes the preferred orientation of the window. - * - * @param orientation - The preferred orientation to set. This should be a value from the `window.Orientation` enum. - * @returns void - This function does not return any value. - */ - changeOrientation(orientation: window.Orientation) { - this.windowClass?.setPreferredOrientation(orientation); - } - - onBackPress(): boolean | void { - if (this.isFullScreen && this.handler) { - this.handler.exitFullScreen(); - return true; - } - return false; - } - - // [EndExclude uicontext_index] - build() { - Column() { - Web({ - src: $rawfile(/zh/.test(this.language) ? 'index_cn.html' : 'index_en.html'), - controller: this.webController - }) - // [StartExclude uicontext_index] - .zoomAccess(false) - .width('100%') - .height('100%') - .onAreaChange((oldArea, newArea) => { - this.webWidth = newArea.width as number; - this.webHeight = newArea.height as number; - }) - .onContextMenuShow((event) => { - if (!event) { - return false; - } - this.result = event.result; - this.pressPosX = this.getUIContext().px2vp(event.param.x()); - this.pressPosY = this.getUIContext().px2vp(event.param.y()); - this.linkUrl = event.param.getSourceUrl(); - this.isShow = true; - return true; - }) - // [EndExclude uicontext_index] - .bindPopup(this.isShow, { - builder: customPopupMenuBuilder( - this.linkUrl, - this.context, - this.openDownloadDialog, - this.closeDownloadDialog, - this.changeIsShow, - ), - enableArrow: false, - placement: Placement.TopLeft, - offset: getOffset(this.webWidth, this.webHeight, - this.pressPosX, this.pressPosY), - onStateChange: (event) => { - if (!event.isVisible) { - this.isShow = false; - this.result?.closeContextMenu(); - } - } - }) - // [StartExclude uicontext_index] - .onFullScreenEnter((event) => { - this.handler = event.handler; - this.changeOrientation(window.Orientation.LANDSCAPE); - this.isFullScreen = true; - }) - .onFullScreenExit(() => { - this.changeOrientation(window.Orientation.PORTRAIT); - this.isFullScreen = false; - }) - // [EndExclude uicontext_index] - } - } -} -// [End uicontext_index] \ No newline at end of file diff --git a/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo06.ets b/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo06.ets deleted file mode 100644 index 1167b463dc921acb39792228ed7c63287de96542..0000000000000000000000000000000000000000 --- a/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo06.ets +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { webview } from '@kit.ArkWeb'; -import { common } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { AlertDialog, ComponentContent, promptAction, window } from '@kit.ArkUI'; -import { Constants } from '../common/Constants'; -import { WebDownloadManager } from '../utils/WebDownloadManager'; -import { downloadControlBuilder } from '../view/DownloadControlView'; -import { customPopupMenuBuilder, getOffset } from '../view/CustomPopupMenu'; -// src/main/ets/pages/Index.ets -const uiContext: UIContext | undefined = AppStorage.get('uiContext'); -let context = uiContext!.getHostContext() -// [Start uicontext_isshow] -// [Start get_host_context] -@Entry -@Component -struct Index { - @State isShow: boolean = false; - // [StartExclude uicontext_isshow] - // [StartExclude get_host_context] - @State pressPosY: number = 0; - @State pressPosX: number = 0; - @StorageProp(Constants.SYSTEM_LANGUAGE_KEY) language: string = ''; - private handler: FullScreenExitHandler | null = null; - private result: WebContextMenuResult | null = null; - private webController: webview.WebviewController = new webview.WebviewController(); - private isFullScreen: boolean = false; - private linkUrl: string = ''; - private webWidth: number = 0; - private webHeight: number = 0; - private windowClass: window.Window | null = null; - private context: common.UIAbilityContext = context as common.UIAbilityContext; - private manager: WebDownloadManager = WebDownloadManager.getInstance(); - private ctx: UIContext = this.getUIContext(); - private options: promptAction.BaseDialogOptions = { - alignment: DialogAlignment.Center, - isModal: true, - autoCancel: false, - onWillDismiss: () => { - WebDownloadManager.getInstance().pause(); - this.dialogControllerConfirm.open(); - } - }; - private contentNode: ComponentContent = new ComponentContent(this.ctx, wrapBuilder(downloadControlBuilder)); - private dialogControllerConfirm: CustomDialogController = new CustomDialogController({ - builder: AlertDialog({ - primaryTitle: $r('app.string.confirm_cancel'), - content: $r('app.string.confirm_task_cancel'), - primaryButton: { - value: $r('app.string.cancel_download'), - fontColor: Color.Red, - action: () => { - this.manager.cancel(); - this.closeDownloadDialog(); - } - }, - secondaryButton: { - value: $r('app.string.resume_download'), - action: () => { - this.manager.unpause(); - } - } - }) - }); - private openDownloadDialog = () => { - this.ctx.getPromptAction().openCustomDialog(this.contentNode, this.options); - }; - private closeDownloadDialog = () => { - this.ctx.getPromptAction().closeCustomDialog(this.contentNode); - }; - private changeIsShow = () => { - this.isShow = !this.isShow; - }; - - aboutToAppear(): void { - window.getLastWindow(this.context).then((windowClass) => this.windowClass = windowClass); - this.manager.registerController(Constants.INDEX_WEB_CONTROLLER, this.webController); - AppStorage.setOrCreate>('contentNode', this.contentNode); - hilog.info(0x000, Constants.TAG, 'language: ' + this.language); - } - - /** - * Changes the preferred orientation of the window. - * - * @param orientation - The preferred orientation to set. This should be a value from the `window.Orientation` enum. - * @returns void - This function does not return any value. - */ - changeOrientation(orientation: window.Orientation) { - this.windowClass?.setPreferredOrientation(orientation); - } - - onBackPress(): boolean | void { - if (this.isFullScreen && this.handler) { - this.handler.exitFullScreen(); - return true; - } - return false; - } - // [EndExclude uicontext_isshow] - // [EndExclude get_host_context] - build() { - Column() { - Web({ - src: $rawfile(/zh/.test(this.language) ? 'index_cn.html' : 'index_en.html'), - controller: this.webController - }) - // [StartExclude get_host_context] - // [StartExclude uicontext_isshow] - .zoomAccess(false) - .width('100%') - .height('100%') - .onAreaChange((oldArea, newArea) => { - this.webWidth = newArea.width as number; - this.webHeight = newArea.height as number; - }) - // [EndExclude uicontext_isshow] - // [EndExclude get_host_context] - .onContextMenuShow((event) => { - if (!event) { - return false; - } - // [StartExclude get_host_context] - // [StartExclude uicontext_isshow] - this.result = event.result; - this.pressPosX = this.getUIContext().px2vp(event.param.x()); - this.pressPosY = this.getUIContext().px2vp(event.param.y()); - // [EndExclude get_host_context] - // [EndExclude uicontext_isshow] - this.linkUrl = event.param.getSourceUrl(); - this.isShow = true; - return true; - }) - // [StartExclude get_host_context] - // [StartExclude uicontext_isshow] - .bindPopup(this.isShow, { - builder: customPopupMenuBuilder( - this.linkUrl, - this.context, - this.openDownloadDialog, - this.closeDownloadDialog, - this.changeIsShow, - ), - enableArrow: false, - placement: Placement.TopLeft, - offset: getOffset(this.webWidth, this.webHeight, - this.pressPosX, this.pressPosY), - onStateChange: (e) => { - if (!e.isVisible) { - this.isShow = false; - this.result?.closeContextMenu(); - } - } - }) - .onFullScreenEnter((event) => { - this.handler = event.handler; - this.changeOrientation(window.Orientation.LANDSCAPE); - this.isFullScreen = true; - }) - .onFullScreenExit(() => { - this.changeOrientation(window.Orientation.PORTRAIT); - this.isFullScreen = false; - }) - // [EndExclude uicontext_isshow] - // [EndExclude get_host_context] - } - } -} -// [End get_host_context] -// [End uicontext_isshow] \ No newline at end of file diff --git a/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo07.ets b/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo07.ets deleted file mode 100644 index 444132fb7d2e66ba212c9289288d727bbe34aec0..0000000000000000000000000000000000000000 --- a/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo07.ets +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { webview } from '@kit.ArkWeb'; -import { fileIo } from '@kit.CoreFileKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { Constants } from '../common/Constants'; - -interface ControllerManager { - registerController(name: string, controller: webview.WebviewController): void; - - getController(name: string): webview.WebviewController | undefined; -} - -abstract class AbstractWebDownloadManager { - abstract start(controllerName: string, path: string, url: string): void; - - abstract pause(): void; - - abstract resume(): void; - - abstract cancel(): void; -} - -@Observed -// [Start web_download_manager] -// src/main/ets/utils/WebDownloadManager.ets - -export class WebDownloadManager extends AbstractWebDownloadManager -implements ControllerManager { - // [StartExclude web_download_manager] - downloadSpeed: number = 0; - downloadProgress: number = 0; - taskStatus: webview.WebDownloadState = webview.WebDownloadState.IN_PROGRESS; - private static instance: WebDownloadManager; - private sourcePath: string = ''; - private failedData: Uint8Array = new Uint8Array(); - private controllers: Map = new Map(); - private currentTask: webview.WebDownloadItem = new webview.WebDownloadItem(); - // [EndExclude web_download_manager] - // Define the download delegate instance. - private delegate: webview.WebDownloadDelegate = new webview.WebDownloadDelegate(); - - // [StartExclude web_download_manager] - private constructor() { - super() - } - - public static getInstance() { - if (!WebDownloadManager.instance) { - WebDownloadManager.instance = new WebDownloadManager(); - } - return WebDownloadManager.instance; - } - - // [EndExclude web_download_manager] - public start(controllerName: string, path: string, url: string): Promise { - return new Promise((resolve, reject) => { - const controller = this.getController(controllerName); - // [StartExclude web_download_manager] - this.delegate.onBeforeDownload((webDownloadItem: webview.WebDownloadItem) => { - this.currentTask = webDownloadItem; - this.sourcePath = path + '/' + webDownloadItem.getSuggestedFileName(); - this.currentTask.start(this.sourcePath); - // Specify the download path before downloading. - this.taskStatus = webDownloadItem.getState(); - }) - this.delegate.onDownloadUpdated((webDownloadItem: webview.WebDownloadItem) => { - this.currentTask = webDownloadItem; - // maintain download progress. - this.downloadProgress = webDownloadItem.getPercentComplete(); - this.downloadSpeed = webDownloadItem.getCurrentSpeed(); - this.taskStatus = webDownloadItem.getState(); - }) - this.delegate.onDownloadFailed((webDownloadItem: webview.WebDownloadItem) => { - // Serialize the download data when the download fails to resume the download. - this.failedData = webDownloadItem.serialize(); - this.taskStatus = webDownloadItem.getState(); - reject(new Error('download failed')); - }) - this.delegate.onDownloadFinish((webDownloadItem: webview.WebDownloadItem) => { - this.taskStatus = webDownloadItem.getState(); - resolve(this.sourcePath); - }) - // [EndExclude web_download_manager] - // Associate the download delegate with the webview controller. - controller?.setDownloadDelegate(this.delegate); - // [StartExclude web_download_manager] - controller?.startDownload(url); - // [EndExclude web_download_manager] - }); - } - - // [StartExclude web_download_manager] - public pause() { - const state = this.currentTask.getState(); - if (state === webview.WebDownloadState.IN_PROGRESS) { - this.currentTask.pause(); - } - } - - public unpause() { - const state = this.currentTask.getState(); - if (state === webview.WebDownloadState.PAUSED) { - this.currentTask.resume(); - } - } - - // Provides an external interface for resuming downloads. - public resume() { - const state = this.currentTask.getState(); - if (state === webview.WebDownloadState.CANCELED) { - webview.WebDownloadManager.setDownloadDelegate(this.delegate); - webview.WebDownloadManager.resumeDownload(webview.WebDownloadItem.deserialize(this.failedData)); - } - } - - public cancel(): void { - try { - this.currentTask.cancel(); - this.taskStatus = this.currentTask.getState(); - this.deleteFile(); - } catch (e) { - hilog.error(0x000, Constants.TAG, `failed to cancel:${JSON.stringify(e)}`); - } - } - - public clearProgress() { - this.downloadSpeed = 0; - this.downloadProgress = 0; - } - - public deleteFile() { - if (fileIo.accessSync(this.sourcePath)) { - fileIo.unlink(this.sourcePath); - } - } - - public registerController(name: string, controller: webview.WebviewController): void { - this.controllers.set(name, controller); - } - - public getController(name: string): webview.WebviewController | undefined { - return this.controllers.get(name); - } - // [EndExclude web_download_manager] -} -// [End web_download_manager] \ No newline at end of file diff --git a/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo08.ets b/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo08.ets deleted file mode 100644 index 03b34be11db06b541fb4674e90e57723df94e977..0000000000000000000000000000000000000000 --- a/VideoProcessBaseWeb/entry/src/main/ets/sourcecode/Demo08.ets +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { webview } from '@kit.ArkWeb'; -import { fileIo } from '@kit.CoreFileKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { Constants } from '../common/Constants'; -import { promptAction } from '@kit.ArkUI'; -const uiContext: UIContext | undefined = AppStorage.get('uiContext'); -let context = uiContext!.getPromptAction() -interface ControllerManager { - registerController(name: string, controller: webview.WebviewController): void; - - getController(name: string): webview.WebviewController | undefined; -} - -abstract class AbstractWebDownloadManager { - abstract start(controllerName: string, path: string, url: string): void; - - abstract pause(): void; - - abstract resume(): void; - - abstract cancel(): void; -} - -@Observed -export class WebDownloadManager extends AbstractWebDownloadManager -implements ControllerManager { - downloadSpeed: number = 0; - downloadProgress: number = 0; - taskStatus: webview.WebDownloadState = webview.WebDownloadState.IN_PROGRESS; - private static instance: WebDownloadManager; - private sourcePath: string = ''; - private failedData: Uint8Array = new Uint8Array(); - private controllers: Map = new Map(); - private currentTask: webview.WebDownloadItem = new webview.WebDownloadItem(); - // Define the download delegate instance. - private delegate: webview.WebDownloadDelegate = new webview.WebDownloadDelegate(); - - private constructor() { - super() - } - - public static getInstance() { - if (!WebDownloadManager.instance) { - WebDownloadManager.instance = new WebDownloadManager(); - } - return WebDownloadManager.instance; - } - - public start(controllerName: string, path: string, url: string): Promise { - return new Promise((resolve, reject) => { - const controller = this.getController(controllerName); - // [Start delegate] - // src/main/ets/utils/WebDownloadManager.ets - - this.delegate.onBeforeDownload((webDownloadItem: webview.WebDownloadItem) => { - this.currentTask = webDownloadItem; - this.sourcePath = path + '/' + webDownloadItem.getSuggestedFileName(); - // Specify the download path before downloading. - this.currentTask.start(this.sourcePath); - this.taskStatus = webDownloadItem.getState(); - }) - // [End delegate] - - // [Start ondownloadupdated] - // src/main/ets/utils/WebDownloadManager.ets - - this.delegate.onDownloadUpdated((webDownloadItem: webview.WebDownloadItem) => { - this.currentTask = webDownloadItem; - // maintain download progress. - this.downloadProgress = webDownloadItem.getPercentComplete(); - this.downloadSpeed = webDownloadItem.getCurrentSpeed(); - this.taskStatus = webDownloadItem.getState(); - }) - // [End ondownloadupdated] - // [Start failed_data] - // src/main/ets/utils/WebDownloadManager.ets - - this.delegate.onDownloadFailed((webDownloadItem: webview.WebDownloadItem) => { - // Serialize the download data when the download fails to resume the download. - this.failedData = webDownloadItem.serialize(); - this.taskStatus = webDownloadItem.getState(); - reject(new Error('download failed')); - }) - // [End failed_data] - - // [Start delegate] - // src/main/ets/utils/WebDownloadManager.ets - - this.delegate.onDownloadFinish((webDownloadItem: webview.WebDownloadItem) => { - // After the download is complete, execute the custom logic. - context.showToast({ message: $r('app.string.download_success') }) - // [StartExclude delegate] - this.taskStatus = webDownloadItem.getState(); - resolve(this.sourcePath); - // [EndExclude delegate] - }) - // [End delegate] - // Associate the download delegate with the webview controller. - controller?.setDownloadDelegate(this.delegate); - // src/main/ets/utils/WebDownloadManager.ets - - controller?.startDownload(url); - }); - } - - public pause() { - const state = this.currentTask.getState(); - if (state === webview.WebDownloadState.IN_PROGRESS) { - this.currentTask.pause(); - } - } - - public unpause() { - const state = this.currentTask.getState(); - if (state === webview.WebDownloadState.PAUSED) { - this.currentTask.resume(); - } - } - - // [Start resume_public] - // src/main/ets/utils/WebDownloadManager.ets - - // Provides an external interface for resuming downloads. - public resume() { - const state = this.currentTask.getState(); - if (state === webview.WebDownloadState.CANCELED) { - webview.WebDownloadManager.setDownloadDelegate(this.delegate); - webview.WebDownloadManager.resumeDownload(webview.WebDownloadItem.deserialize(this.failedData)); - } - } - // [End resume_public] - - public cancel(): void { - try { - this.currentTask.cancel(); - this.taskStatus = this.currentTask.getState(); - this.deleteFile(); - } catch (e) { - hilog.error(0x000, Constants.TAG, `failed to cancel:${JSON.stringify(e)}`); - } - } - - public clearProgress() { - this.downloadSpeed = 0; - this.downloadProgress = 0; - } - - public deleteFile() { - if (fileIo.accessSync(this.sourcePath)) { - fileIo.unlink(this.sourcePath); - } - } - - public registerController(name: string, controller: webview.WebviewController): void { - this.controllers.set(name, controller); - } - - public getController(name: string): webview.WebviewController | undefined { - return this.controllers.get(name); - } -} \ No newline at end of file