diff --git a/MediaService/BuildProfile.ets b/MediaService/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a501e5ddee8ea6d28961648fc7dd314a5304bd4 --- /dev/null +++ b/MediaService/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/audiointeractionlibrary/.gitignore b/audiointeractionlibrary/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/audiointeractionlibrary/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/audiointeractionlibrary/BuildProfile.ets b/audiointeractionlibrary/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a501e5ddee8ea6d28961648fc7dd314a5304bd4 --- /dev/null +++ b/audiointeractionlibrary/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/audiointeractionlibrary/Index.ets b/audiointeractionlibrary/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..5b556574661da407fddda61e9885c731f251c6d1 --- /dev/null +++ b/audiointeractionlibrary/Index.ets @@ -0,0 +1,2 @@ +export { AudioInteractionPage } from './src/main/ets/pages/AudioInteractionPage'; +export { WindowUtil } from './src/main/ets/common/utils/WindowUtil'; \ No newline at end of file diff --git a/audiointeractionlibrary/build-profile.json5 b/audiointeractionlibrary/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..cda3307123ec7c43181580a86ef7e82a18319a34 --- /dev/null +++ b/audiointeractionlibrary/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + } + ] +} diff --git a/audiointeractionlibrary/consumer-rules.txt b/audiointeractionlibrary/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/audiointeractionlibrary/hvigorfile.ts b/audiointeractionlibrary/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..42187071482d292588ad40babeda74f7b8d97a23 --- /dev/null +++ b/audiointeractionlibrary/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/audiointeractionlibrary/obfuscation-rules.txt b/audiointeractionlibrary/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/audiointeractionlibrary/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/entry/oh-package.json5 b/audiointeractionlibrary/oh-package.json5 similarity index 66% rename from entry/oh-package.json5 rename to audiointeractionlibrary/oh-package.json5 index c4e22fa532151ab0e1e5ee8ad06369c4d551444b..6002408e5e61535b8863491b964ee0d206d7cb4e 100644 --- a/entry/oh-package.json5 +++ b/audiointeractionlibrary/oh-package.json5 @@ -1,12 +1,11 @@ { - "name": "entry", + "name": "audiointeractionlibrary", "version": "1.0.0", "description": "Please describe the basic information.", - "main": "", + "main": "Index.ets", "author": "", - "license": "", + "license": "Apache-2.0", "dependencies": { '@ohos/MediaService': "file:../MediaService" } } - diff --git a/entry/src/main/ets/common/constants/BreakpointConstants.ets b/audiointeractionlibrary/src/main/ets/common/constants/BreakpointConstants.ets similarity index 100% rename from entry/src/main/ets/common/constants/BreakpointConstants.ets rename to audiointeractionlibrary/src/main/ets/common/constants/BreakpointConstants.ets diff --git a/entry/src/main/ets/common/constants/ContentConstants.ets b/audiointeractionlibrary/src/main/ets/common/constants/ContentConstants.ets similarity index 100% rename from entry/src/main/ets/common/constants/ContentConstants.ets rename to audiointeractionlibrary/src/main/ets/common/constants/ContentConstants.ets diff --git a/entry/src/main/ets/common/constants/PlayerConstants.ets b/audiointeractionlibrary/src/main/ets/common/constants/PlayerConstants.ets similarity index 100% rename from entry/src/main/ets/common/constants/PlayerConstants.ets rename to audiointeractionlibrary/src/main/ets/common/constants/PlayerConstants.ets diff --git a/entry/src/main/ets/common/constants/RouterConstants.ets b/audiointeractionlibrary/src/main/ets/common/constants/RouterConstants.ets similarity index 100% rename from entry/src/main/ets/common/constants/RouterConstants.ets rename to audiointeractionlibrary/src/main/ets/common/constants/RouterConstants.ets diff --git a/entry/src/main/ets/common/constants/StyleConstants.ets b/audiointeractionlibrary/src/main/ets/common/constants/StyleConstants.ets similarity index 100% rename from entry/src/main/ets/common/constants/StyleConstants.ets rename to audiointeractionlibrary/src/main/ets/common/constants/StyleConstants.ets diff --git a/audiointeractionlibrary/src/main/ets/common/utils/BreakpointSystem.ets b/audiointeractionlibrary/src/main/ets/common/utils/BreakpointSystem.ets new file mode 100644 index 0000000000000000000000000000000000000000..8b801793696b105f927b310f663b7cee1d0632e2 --- /dev/null +++ b/audiointeractionlibrary/src/main/ets/common/utils/BreakpointSystem.ets @@ -0,0 +1,136 @@ +/* + * 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 { mediaquery } from '@kit.ArkUI'; +import { BreakpointConstants } from '../constants/BreakpointConstants'; + +/* + * 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 type { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = '[BreakpointSystem]'; + +export enum BreakpointTypeEnum { + XS = 'xs', + SM = 'sm', + MD = 'md', + LG = 'lg', + XL = 'xl', +} + +export interface BreakpointTypes { + xs?: T; + sm: T; + md: T; + lg: T; + xl?: T; +} + +export class BreakpointType { + private xs: T; + private sm: T; + private md: T; + private lg: T; + private xl: T; + + public constructor(param: BreakpointTypes) { + this.xs = param.xs || param.sm; + this.sm = param.sm; + this.md = param.md; + this.lg = param.lg; + this.xl = param.xl || param.lg; + } + + public getValue(currentBreakpoint: string): T { + if (currentBreakpoint === BreakpointTypeEnum.XS) { + return this.xs; + } + if (currentBreakpoint === BreakpointTypeEnum.SM) { + return this.sm; + } + if (currentBreakpoint === BreakpointTypeEnum.MD) { + return this.md; + } + if (currentBreakpoint === BreakpointTypeEnum.XL) { + return this.xl; + } + return this.lg; + } +} + +export class BreakpointSystem { + private static instance: BreakpointSystem; + private currentBreakpoint: BreakpointTypeEnum = BreakpointTypeEnum.MD; + + private constructor() { + } + + public static getInstance(): BreakpointSystem { + if (!BreakpointSystem.instance) { + BreakpointSystem.instance = new BreakpointSystem(); + } + return BreakpointSystem.instance; + } + + public updateCurrentBreakpoint(breakpoint: BreakpointTypeEnum): void { + if (this.currentBreakpoint !== breakpoint) { + this.currentBreakpoint = breakpoint; + AppStorage.setOrCreate('currentBreakpoint', this.currentBreakpoint); + } + } + + public onWindowSizeChange(window: window.Window): void { + this.updateWidthBp(window); + } + + public updateWidthBp(window: window.Window): void { + try { + const mainWindow: window.WindowProperties = window.getWindowProperties(); + const windowWidth: number = mainWindow.windowRect.width; + const windowWidthVp = px2vp(windowWidth); + let widthBp: BreakpointTypeEnum = BreakpointTypeEnum.MD; + if (windowWidthVp < 320) { + widthBp = BreakpointTypeEnum.XS; + } else if (windowWidthVp >= 320 && windowWidthVp < 600) { + widthBp = BreakpointTypeEnum.SM; + } else if (windowWidthVp >= 600 && windowWidthVp < 840) { + widthBp = BreakpointTypeEnum.MD; + } else if (windowWidthVp >= 840 && windowWidthVp < 1440) { + widthBp = BreakpointTypeEnum.LG; + } else { + widthBp = BreakpointTypeEnum.XL; + } + this.updateCurrentBreakpoint(widthBp); + } catch (error) { + const err: BusinessError = error as BusinessError; + hilog.error(0x0000, TAG, `UpdateBreakpoint fail, error code: ${err.code}, message: ${err.message}`); + } + } +} diff --git a/entry/src/main/ets/common/utils/ColorConversion.ets b/audiointeractionlibrary/src/main/ets/common/utils/ColorConversion.ets similarity index 100% rename from entry/src/main/ets/common/utils/ColorConversion.ets rename to audiointeractionlibrary/src/main/ets/common/utils/ColorConversion.ets diff --git a/entry/src/main/ets/common/utils/ResourceConversion.ets b/audiointeractionlibrary/src/main/ets/common/utils/ResourceConversion.ets similarity index 100% rename from entry/src/main/ets/common/utils/ResourceConversion.ets rename to audiointeractionlibrary/src/main/ets/common/utils/ResourceConversion.ets diff --git a/audiointeractionlibrary/src/main/ets/common/utils/WindowUtil.ets b/audiointeractionlibrary/src/main/ets/common/utils/WindowUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..f87376f789204fbaeaa0b4ad4db4ce5aafa9550d --- /dev/null +++ b/audiointeractionlibrary/src/main/ets/common/utils/WindowUtil.ets @@ -0,0 +1,70 @@ +/* + * 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 type { BusinessError } from '@kit.BasicServicesKit'; +import { BreakpointSystem } from './BreakpointSystem'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = '[WindowUtil]'; + +export class WindowUtil { + public static requestFullScreen(windowStage: window.WindowStage): void { + windowStage.getMainWindow((err: BusinessError, data: window.Window) => { + if (err.code) { + return; + } + const windowClass: window.Window = data; + // Realize the immersive effect. + try { + const promise: Promise = windowClass.setWindowLayoutFullScreen(true); + promise.then(() => { + hilog.info(0x0000, TAG, 'Succeeded in setting the window layout to full-screen mode.'); + }).catch((err: BusinessError) => { + hilog.info(0x0000, TAG, + `Failed to set the window layout to full-screen mode. Cause: ${err.code}, ${err.message}`); + }); + } catch { + hilog.error(0x0000, TAG, 'Failed to set the window layout to full-screen mode. '); + } + }); + } + + public static registerBreakPoint(windowStage: window.WindowStage) { + windowStage.getMainWindow((err: BusinessError, data: window.Window) => { + if (err.code) { + hilog.error(0x0000, TAG, `Failed to get main window: ${err.message}`); + return; + } + BreakpointSystem.getInstance().updateWidthBp(data); + data.on('windowSizeChange', () => BreakpointSystem.getInstance().onWindowSizeChange(data)); + data.on('avoidAreaChange', (avoidAreaOption) => { + if (avoidAreaOption.type === window.AvoidAreaType.TYPE_SYSTEM || + avoidAreaOption.type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) { + WindowUtil.setAvoidArea(avoidAreaOption.type, avoidAreaOption.area); + } + }); + }) + } + + // Get status bar height and indicator height. + public static setAvoidArea(type: window.AvoidAreaType, area: window.AvoidArea) { + if (type === window.AvoidAreaType.TYPE_SYSTEM) { + AppStorage.setOrCreate('topHeight', px2vp(area.topRect.height)); + } else { + AppStorage.setOrCreate('bottomHeight', px2vp(area.bottomRect.height)); + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/components/ControlAreaComponent.ets b/audiointeractionlibrary/src/main/ets/components/ControlAreaComponent.ets similarity index 100% rename from entry/src/main/ets/components/ControlAreaComponent.ets rename to audiointeractionlibrary/src/main/ets/components/ControlAreaComponent.ets diff --git a/entry/src/main/ets/components/LyricsComponent.ets b/audiointeractionlibrary/src/main/ets/components/LyricsComponent.ets similarity index 100% rename from entry/src/main/ets/components/LyricsComponent.ets rename to audiointeractionlibrary/src/main/ets/components/LyricsComponent.ets diff --git a/entry/src/main/ets/components/MusicInfoComponent.ets b/audiointeractionlibrary/src/main/ets/components/MusicInfoComponent.ets similarity index 100% rename from entry/src/main/ets/components/MusicInfoComponent.ets rename to audiointeractionlibrary/src/main/ets/components/MusicInfoComponent.ets diff --git a/entry/src/main/ets/components/PlayerInfoComponent.ets b/audiointeractionlibrary/src/main/ets/components/PlayerInfoComponent.ets similarity index 100% rename from entry/src/main/ets/components/PlayerInfoComponent.ets rename to audiointeractionlibrary/src/main/ets/components/PlayerInfoComponent.ets diff --git a/entry/src/main/ets/components/TopAreaComponent.ets b/audiointeractionlibrary/src/main/ets/components/TopAreaComponent.ets similarity index 100% rename from entry/src/main/ets/components/TopAreaComponent.ets rename to audiointeractionlibrary/src/main/ets/components/TopAreaComponent.ets diff --git a/entry/src/main/ets/datasource/SongDataSource.ets b/audiointeractionlibrary/src/main/ets/datasource/SongDataSource.ets similarity index 100% rename from entry/src/main/ets/datasource/SongDataSource.ets rename to audiointeractionlibrary/src/main/ets/datasource/SongDataSource.ets diff --git a/entry/src/main/ets/datasource/SongListData.ets b/audiointeractionlibrary/src/main/ets/datasource/SongListData.ets similarity index 100% rename from entry/src/main/ets/datasource/SongListData.ets rename to audiointeractionlibrary/src/main/ets/datasource/SongListData.ets diff --git a/entry/src/main/ets/lyric/LrcEntry.ets b/audiointeractionlibrary/src/main/ets/lyric/LrcEntry.ets similarity index 100% rename from entry/src/main/ets/lyric/LrcEntry.ets rename to audiointeractionlibrary/src/main/ets/lyric/LrcEntry.ets diff --git a/entry/src/main/ets/lyric/LrcUtils.ets b/audiointeractionlibrary/src/main/ets/lyric/LrcUtils.ets similarity index 100% rename from entry/src/main/ets/lyric/LrcUtils.ets rename to audiointeractionlibrary/src/main/ets/lyric/LrcUtils.ets diff --git a/entry/src/main/ets/lyric/LrcView.ets b/audiointeractionlibrary/src/main/ets/lyric/LrcView.ets similarity index 100% rename from entry/src/main/ets/lyric/LrcView.ets rename to audiointeractionlibrary/src/main/ets/lyric/LrcView.ets diff --git a/entry/src/main/ets/lyric/LyricConst.ets b/audiointeractionlibrary/src/main/ets/lyric/LyricConst.ets similarity index 100% rename from entry/src/main/ets/lyric/LyricConst.ets rename to audiointeractionlibrary/src/main/ets/lyric/LyricConst.ets diff --git a/entry/src/main/ets/pages/Root.ets b/audiointeractionlibrary/src/main/ets/pages/AudioInteractionPage.ets similarity index 85% rename from entry/src/main/ets/pages/Root.ets rename to audiointeractionlibrary/src/main/ets/pages/AudioInteractionPage.ets index 5c23b25bd20752e36524a27216613df218fd5604..9fd86eeb6b89941076573a4a05f7a0c00224978d 100644 --- a/entry/src/main/ets/pages/Root.ets +++ b/audiointeractionlibrary/src/main/ets/pages/AudioInteractionPage.ets @@ -12,13 +12,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { RouterConstants } from "../common/constants/RouterConstants"; +import { StyleConstants } from "../common/constants/StyleConstants"; -import { RouterConstants } from '../common/constants/RouterConstants'; -import { StyleConstants } from '../common/constants/StyleConstants'; -@Entry @Component -struct Index { +export struct AudioInteractionPage { @Provide(RouterConstants.NAV_PATH_STACK_CONSTANTS) pageStack: NavPathStack = new NavPathStack() build() { diff --git a/entry/src/main/ets/pages/PlayerPage.ets b/audiointeractionlibrary/src/main/ets/pages/PlayerPage.ets similarity index 74% rename from entry/src/main/ets/pages/PlayerPage.ets rename to audiointeractionlibrary/src/main/ets/pages/PlayerPage.ets index 6051c891c75e48e859347ad1f6661c0500537c64..6bece06bf3444381694940937a28e809636cd242 100644 --- a/entry/src/main/ets/pages/PlayerPage.ets +++ b/audiointeractionlibrary/src/main/ets/pages/PlayerPage.ets @@ -12,11 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { AudioRendererController } from "@ohos/MediaService"; +import { BreakpointSystem } from "../common/utils/BreakpointSystem"; +import { PlayerInfoComponent } from "../components/PlayerInfoComponent"; +import { songList } from "../datasource/SongListData"; -import { AudioRendererController } from '@ohos/MediaService'; -import { songList } from '../datasource/SongListData'; -import { BreakpointSystem } from '../common/utils/BreakpointSystem'; -import { PlayerInfoComponent } from '../components/PlayerInfoComponent'; @Builder export function PlayerPageBuilder() { @@ -26,16 +26,14 @@ export function PlayerPageBuilder() { @Component struct PlayerPage { @State isShowPlay: boolean = false; - private breakpointSystem: BreakpointSystem = new BreakpointSystem(); aboutToAppear(): void { AppStorage.setOrCreate('songList', songList); AudioRendererController.getInstance(); - this.breakpointSystem.register(); + } aboutToDisappear(): void { - this.breakpointSystem.unregister(); AudioRendererController.getInstance().release(); } diff --git a/audiointeractionlibrary/src/main/module.json5 b/audiointeractionlibrary/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..edc25d0ddbd6ff3c8d18cfc2c318c8e36783596a --- /dev/null +++ b/audiointeractionlibrary/src/main/module.json5 @@ -0,0 +1,12 @@ +{ + "module": { + "name": "audiointeractionlibrary", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ], + "routerMap": "$profile:route_map" + } +} diff --git a/entry/src/main/resources/base/element/color.json b/audiointeractionlibrary/src/main/resources/base/element/color.json similarity index 100% rename from entry/src/main/resources/base/element/color.json rename to audiointeractionlibrary/src/main/resources/base/element/color.json diff --git a/entry/src/main/resources/base/element/float.json b/audiointeractionlibrary/src/main/resources/base/element/float.json similarity index 100% rename from entry/src/main/resources/base/element/float.json rename to audiointeractionlibrary/src/main/resources/base/element/float.json diff --git a/entry/src/main/resources/base/element/string.json b/audiointeractionlibrary/src/main/resources/base/element/string.json similarity index 100% rename from entry/src/main/resources/base/element/string.json rename to audiointeractionlibrary/src/main/resources/base/element/string.json diff --git a/entry/src/main/resources/base/media/heart.svg b/audiointeractionlibrary/src/main/resources/base/media/heart.svg similarity index 99% rename from entry/src/main/resources/base/media/heart.svg rename to audiointeractionlibrary/src/main/resources/base/media/heart.svg index de43b237457f81c6bbcd3fd149b2869e58a2accc..0cb86bd405578277715ece7075ed4f40280b7c9a 100644 --- a/entry/src/main/resources/base/media/heart.svg +++ b/audiointeractionlibrary/src/main/resources/base/media/heart.svg @@ -1,2 +1,2 @@ - + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/heart_fill.svg b/audiointeractionlibrary/src/main/resources/base/media/heart_fill.svg similarity index 99% rename from entry/src/main/resources/base/media/heart_fill.svg rename to audiointeractionlibrary/src/main/resources/base/media/heart_fill.svg index 7ea737d56713c52fd3b8c73837e46afd4cffe428..93f227853978782ade78a8ef38d951f94cdf9ffc 100644 --- a/entry/src/main/resources/base/media/heart_fill.svg +++ b/audiointeractionlibrary/src/main/resources/base/media/heart_fill.svg @@ -1,2 +1,2 @@ - + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_avatar1.png b/audiointeractionlibrary/src/main/resources/base/media/ic_avatar1.png similarity index 100% rename from entry/src/main/resources/base/media/ic_avatar1.png rename to audiointeractionlibrary/src/main/resources/base/media/ic_avatar1.png diff --git a/entry/src/main/resources/base/media/ic_avatar10.png b/audiointeractionlibrary/src/main/resources/base/media/ic_avatar10.png similarity index 100% rename from entry/src/main/resources/base/media/ic_avatar10.png rename to audiointeractionlibrary/src/main/resources/base/media/ic_avatar10.png diff --git a/entry/src/main/resources/base/media/ic_avatar11.png b/audiointeractionlibrary/src/main/resources/base/media/ic_avatar11.png similarity index 100% rename from entry/src/main/resources/base/media/ic_avatar11.png rename to audiointeractionlibrary/src/main/resources/base/media/ic_avatar11.png diff --git a/entry/src/main/resources/base/media/ic_avatar12.png b/audiointeractionlibrary/src/main/resources/base/media/ic_avatar12.png similarity index 100% rename from entry/src/main/resources/base/media/ic_avatar12.png rename to audiointeractionlibrary/src/main/resources/base/media/ic_avatar12.png diff --git a/entry/src/main/resources/base/media/ic_avatar13.png b/audiointeractionlibrary/src/main/resources/base/media/ic_avatar13.png similarity index 100% rename from entry/src/main/resources/base/media/ic_avatar13.png rename to audiointeractionlibrary/src/main/resources/base/media/ic_avatar13.png diff --git a/entry/src/main/resources/base/media/ic_avatar14.png b/audiointeractionlibrary/src/main/resources/base/media/ic_avatar14.png similarity index 100% rename from entry/src/main/resources/base/media/ic_avatar14.png rename to audiointeractionlibrary/src/main/resources/base/media/ic_avatar14.png diff --git a/entry/src/main/resources/base/media/ic_avatar15.png b/audiointeractionlibrary/src/main/resources/base/media/ic_avatar15.png similarity index 100% rename from entry/src/main/resources/base/media/ic_avatar15.png rename to audiointeractionlibrary/src/main/resources/base/media/ic_avatar15.png diff --git a/entry/src/main/resources/base/media/ic_avatar16.png b/audiointeractionlibrary/src/main/resources/base/media/ic_avatar16.png similarity index 100% rename from entry/src/main/resources/base/media/ic_avatar16.png rename to audiointeractionlibrary/src/main/resources/base/media/ic_avatar16.png diff --git a/entry/src/main/resources/base/media/ic_avatar17.png b/audiointeractionlibrary/src/main/resources/base/media/ic_avatar17.png similarity index 100% rename from entry/src/main/resources/base/media/ic_avatar17.png rename to audiointeractionlibrary/src/main/resources/base/media/ic_avatar17.png diff --git a/entry/src/main/resources/base/media/ic_avatar2.png b/audiointeractionlibrary/src/main/resources/base/media/ic_avatar2.png similarity index 100% rename from entry/src/main/resources/base/media/ic_avatar2.png rename to audiointeractionlibrary/src/main/resources/base/media/ic_avatar2.png diff --git a/entry/src/main/resources/base/media/ic_avatar4.png b/audiointeractionlibrary/src/main/resources/base/media/ic_avatar4.png similarity index 100% rename from entry/src/main/resources/base/media/ic_avatar4.png rename to audiointeractionlibrary/src/main/resources/base/media/ic_avatar4.png diff --git a/entry/src/main/resources/base/media/ic_avatar5.png b/audiointeractionlibrary/src/main/resources/base/media/ic_avatar5.png similarity index 100% rename from entry/src/main/resources/base/media/ic_avatar5.png rename to audiointeractionlibrary/src/main/resources/base/media/ic_avatar5.png diff --git a/entry/src/main/resources/base/media/ic_avatar6.png b/audiointeractionlibrary/src/main/resources/base/media/ic_avatar6.png similarity index 100% rename from entry/src/main/resources/base/media/ic_avatar6.png rename to audiointeractionlibrary/src/main/resources/base/media/ic_avatar6.png diff --git a/entry/src/main/resources/base/media/ic_avatar8.png b/audiointeractionlibrary/src/main/resources/base/media/ic_avatar8.png similarity index 100% rename from entry/src/main/resources/base/media/ic_avatar8.png rename to audiointeractionlibrary/src/main/resources/base/media/ic_avatar8.png diff --git a/entry/src/main/resources/base/media/ic_avatar9.png b/audiointeractionlibrary/src/main/resources/base/media/ic_avatar9.png similarity index 100% rename from entry/src/main/resources/base/media/ic_avatar9.png rename to audiointeractionlibrary/src/main/resources/base/media/ic_avatar9.png diff --git a/entry/src/main/resources/base/media/ic_dream.png b/audiointeractionlibrary/src/main/resources/base/media/ic_dream.png similarity index 100% rename from entry/src/main/resources/base/media/ic_dream.png rename to audiointeractionlibrary/src/main/resources/base/media/ic_dream.png diff --git a/entry/src/main/resources/base/media/ic_music_icon.png b/audiointeractionlibrary/src/main/resources/base/media/ic_music_icon.png similarity index 100% rename from entry/src/main/resources/base/media/ic_music_icon.png rename to audiointeractionlibrary/src/main/resources/base/media/ic_music_icon.png diff --git a/entry/src/main/resources/base/media/ic_music_list.svg b/audiointeractionlibrary/src/main/resources/base/media/ic_music_list.svg similarity index 100% rename from entry/src/main/resources/base/media/ic_music_list.svg rename to audiointeractionlibrary/src/main/resources/base/media/ic_music_list.svg diff --git a/entry/src/main/resources/base/media/ic_public_forward.svg b/audiointeractionlibrary/src/main/resources/base/media/ic_public_forward.svg similarity index 100% rename from entry/src/main/resources/base/media/ic_public_forward.svg rename to audiointeractionlibrary/src/main/resources/base/media/ic_public_forward.svg diff --git a/entry/src/main/resources/base/media/ic_public_next.svg b/audiointeractionlibrary/src/main/resources/base/media/ic_public_next.svg similarity index 100% rename from entry/src/main/resources/base/media/ic_public_next.svg rename to audiointeractionlibrary/src/main/resources/base/media/ic_public_next.svg diff --git a/entry/src/main/resources/base/media/ic_public_pause.svg b/audiointeractionlibrary/src/main/resources/base/media/ic_public_pause.svg similarity index 100% rename from entry/src/main/resources/base/media/ic_public_pause.svg rename to audiointeractionlibrary/src/main/resources/base/media/ic_public_pause.svg diff --git a/entry/src/main/resources/base/media/ic_public_play.svg b/audiointeractionlibrary/src/main/resources/base/media/ic_public_play.svg similarity index 100% rename from entry/src/main/resources/base/media/ic_public_play.svg rename to audiointeractionlibrary/src/main/resources/base/media/ic_public_play.svg diff --git a/entry/src/main/resources/base/media/ic_ring.svg b/audiointeractionlibrary/src/main/resources/base/media/ic_ring.svg similarity index 100% rename from entry/src/main/resources/base/media/ic_ring.svg rename to audiointeractionlibrary/src/main/resources/base/media/ic_ring.svg diff --git a/entry/src/main/resources/base/media/ic_sq.svg b/audiointeractionlibrary/src/main/resources/base/media/ic_sq.svg similarity index 100% rename from entry/src/main/resources/base/media/ic_sq.svg rename to audiointeractionlibrary/src/main/resources/base/media/ic_sq.svg diff --git a/entry/src/main/resources/base/media/ic_vip.svg b/audiointeractionlibrary/src/main/resources/base/media/ic_vip.svg similarity index 100% rename from entry/src/main/resources/base/media/ic_vip.svg rename to audiointeractionlibrary/src/main/resources/base/media/ic_vip.svg diff --git a/entry/src/main/resources/base/media/icon.png b/audiointeractionlibrary/src/main/resources/base/media/icon.png similarity index 100% rename from entry/src/main/resources/base/media/icon.png rename to audiointeractionlibrary/src/main/resources/base/media/icon.png diff --git a/entry/src/main/resources/base/media/order_play.svg b/audiointeractionlibrary/src/main/resources/base/media/order_play.svg similarity index 99% rename from entry/src/main/resources/base/media/order_play.svg rename to audiointeractionlibrary/src/main/resources/base/media/order_play.svg index bf5d96d661b034d380e8233d5e90993f27a414b0..b1affe03fdd6be1a6b70972cf7555fe44fb271bf 100644 --- a/entry/src/main/resources/base/media/order_play.svg +++ b/audiointeractionlibrary/src/main/resources/base/media/order_play.svg @@ -1,2 +1,2 @@ - + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/repeat_1.svg b/audiointeractionlibrary/src/main/resources/base/media/repeat_1.svg similarity index 99% rename from entry/src/main/resources/base/media/repeat_1.svg rename to audiointeractionlibrary/src/main/resources/base/media/repeat_1.svg index d529fd978e5dad7217b4e4516315e3d2dec6ec83..3157659304229a4766a0f9eb2e59587c07d19153 100644 --- a/entry/src/main/resources/base/media/repeat_1.svg +++ b/audiointeractionlibrary/src/main/resources/base/media/repeat_1.svg @@ -1,2 +1,2 @@ - + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/shuffle.svg b/audiointeractionlibrary/src/main/resources/base/media/shuffle.svg similarity index 99% rename from entry/src/main/resources/base/media/shuffle.svg rename to audiointeractionlibrary/src/main/resources/base/media/shuffle.svg index c3a7d6053a5b4094a459bf548bedb0b68f7bb459..58e60bc86e15a77c7d8f8bc64cab3546337b7274 100644 --- a/entry/src/main/resources/base/media/shuffle.svg +++ b/audiointeractionlibrary/src/main/resources/base/media/shuffle.svg @@ -1,2 +1,2 @@ - + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/silence.svg b/audiointeractionlibrary/src/main/resources/base/media/silence.svg similarity index 100% rename from entry/src/main/resources/base/media/silence.svg rename to audiointeractionlibrary/src/main/resources/base/media/silence.svg diff --git a/entry/src/main/resources/base/profile/route_map.json b/audiointeractionlibrary/src/main/resources/base/profile/route_map.json similarity index 100% rename from entry/src/main/resources/base/profile/route_map.json rename to audiointeractionlibrary/src/main/resources/base/profile/route_map.json diff --git a/entry/src/main/resources/en_US/element/string.json b/audiointeractionlibrary/src/main/resources/en_US/element/string.json similarity index 100% rename from entry/src/main/resources/en_US/element/string.json rename to audiointeractionlibrary/src/main/resources/en_US/element/string.json diff --git a/entry/src/main/resources/rawfile/Delacey - Dream It Possible.flac b/audiointeractionlibrary/src/main/resources/rawfile/Delacey - Dream It Possible.flac similarity index 100% rename from entry/src/main/resources/rawfile/Delacey - Dream It Possible.flac rename to audiointeractionlibrary/src/main/resources/rawfile/Delacey - Dream It Possible.flac diff --git a/entry/src/main/resources/rawfile/Delacey - Dream It Possible.pcm b/audiointeractionlibrary/src/main/resources/rawfile/Delacey - Dream It Possible.pcm similarity index 100% rename from entry/src/main/resources/rawfile/Delacey - Dream It Possible.pcm rename to audiointeractionlibrary/src/main/resources/rawfile/Delacey - Dream It Possible.pcm diff --git a/entry/src/main/resources/rawfile/boisterous.pcm b/audiointeractionlibrary/src/main/resources/rawfile/boisterous.pcm similarity index 100% rename from entry/src/main/resources/rawfile/boisterous.pcm rename to audiointeractionlibrary/src/main/resources/rawfile/boisterous.pcm diff --git a/entry/src/main/resources/rawfile/boisterous.wav b/audiointeractionlibrary/src/main/resources/rawfile/boisterous.wav similarity index 100% rename from entry/src/main/resources/rawfile/boisterous.wav rename to audiointeractionlibrary/src/main/resources/rawfile/boisterous.wav diff --git a/entry/src/main/resources/rawfile/lrcfiles/DreamItPossible.lrc b/audiointeractionlibrary/src/main/resources/rawfile/lrcfiles/DreamItPossible.lrc similarity index 100% rename from entry/src/main/resources/rawfile/lrcfiles/DreamItPossible.lrc rename to audiointeractionlibrary/src/main/resources/rawfile/lrcfiles/DreamItPossible.lrc diff --git a/entry/src/main/resources/rawfile/power.pcm b/audiointeractionlibrary/src/main/resources/rawfile/power.pcm similarity index 100% rename from entry/src/main/resources/rawfile/power.pcm rename to audiointeractionlibrary/src/main/resources/rawfile/power.pcm diff --git a/entry/src/main/resources/rawfile/power.wav b/audiointeractionlibrary/src/main/resources/rawfile/power.wav similarity index 100% rename from entry/src/main/resources/rawfile/power.wav rename to audiointeractionlibrary/src/main/resources/rawfile/power.wav diff --git a/entry/src/main/resources/rawfile/world.pcm b/audiointeractionlibrary/src/main/resources/rawfile/world.pcm similarity index 100% rename from entry/src/main/resources/rawfile/world.pcm rename to audiointeractionlibrary/src/main/resources/rawfile/world.pcm diff --git a/entry/src/main/resources/rawfile/world.wav b/audiointeractionlibrary/src/main/resources/rawfile/world.wav similarity index 100% rename from entry/src/main/resources/rawfile/world.wav rename to audiointeractionlibrary/src/main/resources/rawfile/world.wav diff --git a/entry/src/main/resources/zh_CN/element/string.json b/audiointeractionlibrary/src/main/resources/zh_CN/element/string.json similarity index 100% rename from entry/src/main/resources/zh_CN/element/string.json rename to audiointeractionlibrary/src/main/resources/zh_CN/element/string.json diff --git a/entry/build-profile.json5 b/audiointeractionsample/build-profile.json5 similarity index 90% rename from entry/build-profile.json5 rename to audiointeractionsample/build-profile.json5 index b695582d3680556f4cce2ec518f65720a9413ca3..808380f3b726e2036a3d6cf5fb9b0fd9513a8215 100644 --- a/entry/build-profile.json5 +++ b/audiointeractionsample/build-profile.json5 @@ -20,9 +20,6 @@ "targets": [ { "name": "default" - }, - { - "name": "ohosTest", } ] } \ No newline at end of file diff --git a/entry/hvigorfile.ts b/audiointeractionsample/hvigorfile.ts similarity index 100% rename from entry/hvigorfile.ts rename to audiointeractionsample/hvigorfile.ts diff --git a/entry/obfuscation-rules.txt b/audiointeractionsample/obfuscation-rules.txt similarity index 100% rename from entry/obfuscation-rules.txt rename to audiointeractionsample/obfuscation-rules.txt diff --git a/audiointeractionsample/oh-package.json5 b/audiointeractionsample/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..bbc15c747d29b67222865d3a6f5cdd657165cb00 --- /dev/null +++ b/audiointeractionsample/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "audiointeractionsample", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "audiointeractionlibrary": "file:../audiointeractionlibrary" + } +} \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/audiointeractionsample/src/main/ets/entryability/EntryAbility.ets similarity index 57% rename from entry/src/main/ets/entryability/EntryAbility.ets rename to audiointeractionsample/src/main/ets/entryability/EntryAbility.ets index 7a7d487edb720094d21f93987793c0188fcdd7fe..00810872fe32eda63989e98007f35ef8e55c6007 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/audiointeractionsample/src/main/ets/entryability/EntryAbility.ets @@ -17,7 +17,8 @@ import { Configuration, ConfigurationConstant, UIAbility } from '@kit.AbilityKit import { display, window } from '@kit.ArkUI'; import { BusinessError } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { BreakpointConstants } from '../common/constants/BreakpointConstants'; +import { WindowUtil } from 'audiointeractionlibrary'; +import { BreakpointConstants } from 'audiointeractionlibrary/src/main/ets/common/constants/BreakpointConstants'; const TAG: string = '[EntryAbility]'; @@ -49,29 +50,9 @@ export default class EntryAbility extends UIAbility { onWindowStageCreate(windowStage: window.WindowStage) { // Main window is created, set main page for this ability hilog.info(0x0000, TAG, '%{public}s', 'Ability onWindowStageCreate'); - windowStage.getMainWindow().then((data: window.Window) => { - try { - this.windowObj = data; - AppStorage.setOrCreate('window', data); - data.setWindowLayoutFullScreen(true); - let topArea = this.windowObj.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM) - let topHeight = px2vp(topArea.topRect.height) - AppStorage.setOrCreate('topHeight', topHeight) - let bottomArea = this.windowObj.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) - let bottomHeight = px2vp(bottomArea.bottomRect.height) - AppStorage.setOrCreate('bottomHeight', bottomHeight) - this.updateBreakpoint(this.windowObj.getWindowProperties().windowRect.width); - this.windowObj.on('windowSizeChange', (windowSize: window.Size) => { - this.updateBreakpoint(windowSize.width); - }); - } catch (err) { - hilog.error(0x0000, 'testTag', `Set window properties err. Cause: ${err.code}`); - } - }).catch((error: BusinessError) => { - hilog.error(0x0000, TAG, '%{public}s', - `Failed to get main window. code: ${error.code}, message: ${error.message}`); - }); - windowStage.loadContent('pages/Root', (err: BusinessError) => { + WindowUtil.requestFullScreen(windowStage) + WindowUtil.registerBreakPoint(windowStage) + windowStage.loadContent('pages/Index', (err: BusinessError) => { if (err.code) { hilog.error(0x0000, TAG, '%{public}s', `Failed to load the content. code: ${err.code}, message: ${err.message}`); @@ -81,23 +62,6 @@ export default class EntryAbility extends UIAbility { }); } - private updateBreakpoint(windowWidth: number): void { - try { - let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; - let curBp: string = ''; - if (windowWidthVp < BreakpointConstants.BREAKPOINT_VALUE_NUMBER[1]) { - curBp = BreakpointConstants.BREAKPOINT_SM; - } else if (windowWidthVp < BreakpointConstants.BREAKPOINT_VALUE_NUMBER[2]) { - curBp = BreakpointConstants.BREAKPOINT_MD; - } else { - curBp = BreakpointConstants.BREAKPOINT_LG; - } - AppStorage.setOrCreate('currentBreakpoint', curBp); - } catch (err) { - hilog.error(0X0000, TAG, '%{public}s', `updateBreakpoint catch err. code: ${err.code}, message: ${err.message}`); - } - } - onWindowStageDestroy() { // Main window is destroyed, release UI related resources hilog.info(0x0000, TAG, '%{public}s', 'Ability onWindowStageDestroy'); diff --git a/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/audiointeractionsample/src/main/ets/entrybackupability/EntryBackupAbility.ets similarity index 100% rename from entry/src/main/ets/entrybackupability/EntryBackupAbility.ets rename to audiointeractionsample/src/main/ets/entrybackupability/EntryBackupAbility.ets diff --git a/audiointeractionsample/src/main/ets/pages/Index.ets b/audiointeractionsample/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..64807e24728d08be2c2f4665691db5e581e0807b --- /dev/null +++ b/audiointeractionsample/src/main/ets/pages/Index.ets @@ -0,0 +1,25 @@ +/* + * 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 { AudioInteractionPage } from 'audiointeractionlibrary' + +@Entry +@Component +struct Index { + build() { + Stack() { + AudioInteractionPage() + } + } +}; \ No newline at end of file diff --git a/entry/src/main/module.json5 b/audiointeractionsample/src/main/module.json5 similarity index 92% rename from entry/src/main/module.json5 rename to audiointeractionsample/src/main/module.json5 index c9d2fdec6485b9c5ef4f89ac5b26e1db1c54c8c7..31e4e220e85d6f106a8f0f301edc1c382fda6efe 100644 --- a/entry/src/main/module.json5 +++ b/audiointeractionsample/src/main/module.json5 @@ -1,6 +1,6 @@ { "module": { - "name": "entry", + "name": "audiointeractionsample", "type": "entry", "description": "$string:module_desc", "mainElement": "EntryAbility", @@ -9,7 +9,6 @@ "tablet", "2in1" ], - "routerMap": "$profile:route_map", "deliveryWithInstall": true, "installationFree": false, "pages": "$profile:main_pages", @@ -27,14 +26,14 @@ ], "abilities": [ { - "name": "EntryAbility", + "name": "AudioInteractionsampleAbility", "srcEntry": "./ets/entryability/EntryAbility.ets", "description": "$string:EntryAbility_desc", "icon": "$media:ic_music_icon", "label": "$string:EntryAbility_label", "startWindowIcon": "$media:icon", "startWindowBackground": "$color:start_window_background", - "exported": false, + "exported": true, "backgroundModes": [ "audioPlayback" ], diff --git a/entry/src/main/resources/base/profile/backup_config.json b/audiointeractionsample/src/main/resources/base/profile/backup_config.json similarity index 100% rename from entry/src/main/resources/base/profile/backup_config.json rename to audiointeractionsample/src/main/resources/base/profile/backup_config.json diff --git a/entry/src/main/resources/base/profile/main_pages.json b/audiointeractionsample/src/main/resources/base/profile/main_pages.json similarity index 51% rename from entry/src/main/resources/base/profile/main_pages.json rename to audiointeractionsample/src/main/resources/base/profile/main_pages.json index 9d440852ab022325c67b1417dc68c87fa485188a..1898d94f58d6128ab712be2c68acc7c98e9ab9ce 100644 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/audiointeractionsample/src/main/resources/base/profile/main_pages.json @@ -1,5 +1,5 @@ { "src": [ - "pages/Root" + "pages/Index" ] } diff --git a/build-profile.json5 b/build-profile.json5 index a29246055f930e9c5b9b7dc43ff64b2182742de2..450240f4dc5d38beb46d3cb56ec03c05262c6fd5 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -25,8 +25,8 @@ }, "modules": [ { - "name": "entry", - "srcPath": "./entry", + "name": "audiointeractionsample", + "srcPath": "./audiointeractionsample", "targets": [ { "name": "default", @@ -39,6 +39,10 @@ { "name": "MediaService", "srcPath": "./MediaService", + }, + { + "name": "audiointeractionlibrary", + "srcPath": "./audiointeractionlibrary", } ] } \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/BreakpointSystem.ets b/entry/src/main/ets/common/utils/BreakpointSystem.ets deleted file mode 100644 index 2bf40fff2c823aa8e0ab1c9c434d51ccb9cecc67..0000000000000000000000000000000000000000 --- a/entry/src/main/ets/common/utils/BreakpointSystem.ets +++ /dev/null @@ -1,86 +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 { mediaquery } from '@kit.ArkUI'; -import { BreakpointConstants } from '../constants/BreakpointConstants'; - -declare interface BreakPointTypeOption { - sm?: T, - md?: T, - lg?: T -} - -export class BreakpointType { - private options: BreakPointTypeOption; - - constructor(option: BreakPointTypeOption) { - this.options = option; - } - - getValue(currentPoint: string): T { - if (currentPoint === 'sm') { - return this.options.sm as T; - } else if (currentPoint === 'md') { - return this.options.md as T; - } else { - return this.options.lg as T; - } - } -} - -export class BreakpointSystem { - private currentBreakpoint: string = BreakpointConstants.BREAKPOINT_SM; - private smListener: mediaquery.MediaQueryListener = mediaquery.matchMediaSync(BreakpointConstants.RANGE_SM); - private mdListener: mediaquery.MediaQueryListener = mediaquery.matchMediaSync(BreakpointConstants.RANGE_MD); - private lgListener: mediaquery.MediaQueryListener = mediaquery.matchMediaSync(BreakpointConstants.RANGE_LG); - - private updateCurrentBreakpoint(breakpoint: string): void { - if (this.currentBreakpoint !== breakpoint) { - this.currentBreakpoint = breakpoint; - AppStorage.setOrCreate(BreakpointConstants.CURRENT_BREAKPOINT, this.currentBreakpoint); - } - } - - private isBreakpointSM = (mediaQueryResult: mediaquery.MediaQueryResult): void => { - if (mediaQueryResult.matches) { - this.updateCurrentBreakpoint(BreakpointConstants.BREAKPOINT_SM); - } - } - private isBreakpointMD = (mediaQueryResult: mediaquery.MediaQueryResult): void => { - if (mediaQueryResult.matches) { - this.updateCurrentBreakpoint(BreakpointConstants.BREAKPOINT_MD); - } - } - private isBreakpointLG = (mediaQueryResult: mediaquery.MediaQueryResult): void => { - if (mediaQueryResult.matches) { - this.updateCurrentBreakpoint(BreakpointConstants.BREAKPOINT_LG); - } - } - - public register(): void { - this.smListener = mediaquery.matchMediaSync(BreakpointConstants.RANGE_SM); - this.smListener.on('change', this.isBreakpointSM); - this.mdListener = mediaquery.matchMediaSync(BreakpointConstants.RANGE_MD); - this.mdListener.on('change', this.isBreakpointMD); - this.lgListener = mediaquery.matchMediaSync(BreakpointConstants.RANGE_LG); - this.lgListener.on('change', this.isBreakpointLG); - } - - public unregister(): void { - this.smListener.off('change', this.isBreakpointSM); - this.mdListener.off('change', this.isBreakpointMD); - this.lgListener.off('change', this.isBreakpointLG); - } -} \ No newline at end of file