diff --git a/common/constantsCommon/build-profile.json5 b/common/constantsCommon/build-profile.json5 index 79961f96a6fe0507354b7952a378c3be2ae4bfab..cda3307123ec7c43181580a86ef7e82a18319a34 100644 --- a/common/constantsCommon/build-profile.json5 +++ b/common/constantsCommon/build-profile.json5 @@ -2,6 +2,24 @@ "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/common/mediaCommon/build-profile.json5 b/common/mediaCommon/build-profile.json5 index 79961f96a6fe0507354b7952a378c3be2ae4bfab..cda3307123ec7c43181580a86ef7e82a18319a34 100644 --- a/common/mediaCommon/build-profile.json5 +++ b/common/mediaCommon/build-profile.json5 @@ -2,6 +2,24 @@ "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/common/mediaCommon/src/main/ets/utils/MediaTools.ets b/common/mediaCommon/src/main/ets/utils/MediaTools.ets index e0682e36ef16b1197dc0ab3d9546286142b0b91e..4b775d40ca73e5cfc834dc5b823a148f55b352fe 100644 --- a/common/mediaCommon/src/main/ets/utils/MediaTools.ets +++ b/common/mediaCommon/src/main/ets/utils/MediaTools.ets @@ -24,8 +24,13 @@ export class MediaTools { static async getPixelMapFromResource(context: common.UIAbilityContext, name: resourceManager.Resource): Promise { - let resourceMgr = context.resourceManager; - let fileData: Uint8Array = await resourceMgr.getMediaContent(name); + let fileData: Uint8Array = new Uint8Array([]); + try { + let resourceMgr = context.resourceManager; + fileData = await resourceMgr.getMediaContent(name.id); + } catch (e) { + Logger.error(TAG, `getPixelMapFromResource error: ${JSON.stringify(e)}`); + } return await image.createImageSource(fileData.buffer as ArrayBuffer).createPixelMap(); } diff --git a/common/mediaCommon/src/main/ets/utils/PreferencesUtil.ets b/common/mediaCommon/src/main/ets/utils/PreferencesUtil.ets index 77d67c0058d0d773042e2244940aead1d38189d1..be28ae47cb93fa43ed2802280949953d34618c94 100644 --- a/common/mediaCommon/src/main/ets/utils/PreferencesUtil.ets +++ b/common/mediaCommon/src/main/ets/utils/PreferencesUtil.ets @@ -86,7 +86,7 @@ export class PreferencesUtil { removePreferencesFromCache(context: Context): void { preferences.removePreferencesFromCache(context, MY_STORE).catch((err: BusinessError) => { - console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message); + Logger.error('Failed to remove preferences. code =' + err.code + ', message =' + err.message); }) } diff --git a/features/musicList/src/main/ets/components/AlbumComponent.ets b/features/musicList/src/main/ets/components/AlbumComponent.ets index cd31cd89ef31a8084b011191bb42e7c6ab74ecec..ca2427f72f6efe9101831b933af8bfcb2c8c8ef0 100644 --- a/features/musicList/src/main/ets/components/AlbumComponent.ets +++ b/features/musicList/src/main/ets/components/AlbumComponent.ets @@ -140,19 +140,19 @@ export struct AlbumComponent { GridCol({ span: { sm: GridConstants.SPAN_FOUR, md: GridConstants.SPAN_TWELVE, lg: GridConstants.SPAN_TWELVE } }) { - this.CoverImage(); + this.CoverImage() } GridCol({ span: { sm: GridConstants.SPAN_EIGHT, md: GridConstants.SPAN_TWELVE, lg: GridConstants.SPAN_TWELVE } }) { - this.CoverIntroduction(); + this.CoverIntroduction() } GridCol({ span: { sm: GridConstants.SPAN_TWELVE, md: GridConstants.SPAN_TWELVE, lg: GridConstants.SPAN_TWELVE } }) { - this.CoverOptions(); + this.CoverOptions() } .padding({ top: this.currentBreakpoint === BreakpointConstants.BREAKPOINT_SM ? $r('app.float.option_margin') : 0, diff --git a/features/musicList/src/main/ets/components/ControlAreaComponent.ets b/features/musicList/src/main/ets/components/ControlAreaComponent.ets index 51d096acb8513ff41cc0ec303065a174084e3b54..6c96ad716120b87e88a7c8b74bc529ec1a4002b7 100644 --- a/features/musicList/src/main/ets/components/ControlAreaComponent.ets +++ b/features/musicList/src/main/ets/components/ControlAreaComponent.ets @@ -165,5 +165,5 @@ export struct ControlAreaComponent { function controlImageBuilder() { .aspectRatio(1) .opacity(0.86) - .objectFit(ImageFit.Contain); + .objectFit(ImageFit.Contain) } diff --git a/features/musicList/src/main/ets/components/MusicControlComponent.ets b/features/musicList/src/main/ets/components/MusicControlComponent.ets index aebeafe0c40daf1339d18bd30e5ff5378a5b2ec9..b61f611dcb4f078623dd543cc0b19b84611eff74 100644 --- a/features/musicList/src/main/ets/components/MusicControlComponent.ets +++ b/features/musicList/src/main/ets/components/MusicControlComponent.ets @@ -37,6 +37,7 @@ export struct MusicControlComponent { @StorageLink('imageColor') imageColor: string = 'rgba(0, 0, 2, 1.00)'; @StorageLink('topArea') topArea: number = 0; @StorageLink('bottomArea') bottomArea: number = 0; + @StorageLink('currentHeightBreakpoint') currentHeightBreakpoint: number = 0; @State imageLabel: PixelMap | Resource = this.songList[this.selectIndex].label; @State isShowControl: boolean = true; @State isShowControlLg: boolean = false; @@ -97,7 +98,8 @@ export struct MusicControlComponent { .objectFit(ImageFit.Cover) .opacity(0.5) Row() { - if (this.isFoldFull) { + if ((this.currentBreakpoint === BreakpointConstants.BREAKPOINT_MD && + this.currentHeightBreakpoint === HeightBreakpoint.HEIGHT_MD)) { Column() { TopAreaComponent({ isShowPlay: this.isShowPlay }) .margin({ @@ -253,7 +255,7 @@ export struct MusicControlComponent { if (!this.context) { return; } - this.context.resourceManager.getMediaContent(this.songList[this.selectIndex].label) + this.context.resourceManager.getMediaContent(this.songList[this.selectIndex].label.id) .then((value: Uint8Array) => { let buffer = value.buffer as ArrayBuffer; image.createImageSource(buffer).createPixelMap().then((pixelMap) => { diff --git a/features/musicList/src/main/ets/components/MusicInfoComponent.ets b/features/musicList/src/main/ets/components/MusicInfoComponent.ets index 6f19935dff57c85d1f14b76a46679e421f5a082f..8c6bb7ad82f1c073fb336f3eaff9fe7b60bf7531 100644 --- a/features/musicList/src/main/ets/components/MusicInfoComponent.ets +++ b/features/musicList/src/main/ets/components/MusicInfoComponent.ets @@ -47,9 +47,13 @@ export struct MusicInfoComponent { offset: { md: BreakpointConstants.OFFSET_MD } }) { Column() { - this.CoverInfo(); - this.MusicInfo(); - Blank() + Column() { + this.CoverInfo() + this.MusicInfo() + } + .layoutWeight(1) + .justifyContent(FlexAlign.Start) + ControlAreaComponent() } .height(StyleConstants.FULL_HEIGHT) @@ -63,7 +67,6 @@ export struct MusicInfoComponent { CoverInfo() { Row() { Image(this.songList[this.selectIndex].label) - .width(StyleConstants.FULL_WIDTH) .aspectRatio(1) .borderRadius($r('app.float.cover_radius_label')) .shadow({ @@ -74,6 +77,11 @@ export struct MusicInfoComponent { }) .margin($r('app.float.lyric_margin_right_sm')) } + .aspectRatio(1) + .layoutWeight(1) + .constraintSize({ + maxWidth: '100%' + }) } @Builder diff --git a/features/musicList/src/main/ets/components/Player.ets b/features/musicList/src/main/ets/components/Player.ets index aaad3ffb501f1cd4f093efba3055c84eb8beacc7..ae60e99ebd70ea4ee528e64054faf520bd972ba7 100644 --- a/features/musicList/src/main/ets/components/Player.ets +++ b/features/musicList/src/main/ets/components/Player.ets @@ -197,15 +197,21 @@ export struct Player { .transition(TransitionEffect.translate({ y: 1000 }).animation({ curve: curves.springMotion(0.6, 0.8) })) .onAppear(() => { window.getLastWindow(this.context).then((windowStage: window.Window) => { - let area = windowStage.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); - this.topArea = this.getUIContext().px2vp(area.topRect.height); - let bottomArea = windowStage.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR); - this.bottomArea = this.getUIContext().px2vp(bottomArea.bottomRect.height); - Logger.info('bottomArea ' + this.bottomArea) - let sysBarProps: window.SystemBarProperties = { - statusBarContentColor: '#FFFFFF' - }; - windowStage.setWindowSystemBarProperties(sysBarProps); + try { + let area = windowStage.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); + this.topArea = this.getUIContext().px2vp(area.topRect.height); + let bottomArea = windowStage.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR); + this.bottomArea = this.getUIContext().px2vp(bottomArea.bottomRect.height); + Logger.info('bottomArea ' + this.bottomArea) + let sysBarProps: window.SystemBarProperties = { + statusBarContentColor: '#FFFFFF' + }; + windowStage.setWindowSystemBarProperties(sysBarProps).catch((error: BusinessError) => { + Logger.error(`setWindowSystemBarProperties error ${error.code} + ${error.message}`); + }); + } catch (e) { + Logger.error(`getWindowAvoidArea error ${JSON.stringify(e)}`); + } }).catch((error: BusinessError) => { Logger.error(`${error.code} + ${error.message}`); }); @@ -217,7 +223,9 @@ export struct Player { let sysBarProps: window.SystemBarProperties = { statusBarContentColor: '#000000' }; - windowStage.setWindowSystemBarProperties(sysBarProps); + windowStage.setWindowSystemBarProperties(sysBarProps).catch((error: BusinessError) => { + Logger.error(`setWindowSystemBarProperties error ${error.code} + ${error.message}`); + }); }).catch((error: BusinessError) => { Logger.error(`${error.code} + ${error.message}`); }); diff --git a/products/phone/src/main/ets/entryability/EntryAbility.ets b/products/phone/src/main/ets/entryability/EntryAbility.ets index 670dea9caf5867edf48fcf00b49d193ed9211e16..c58491549b7c0c40eec6d8617daca64a2240b4eb 100644 --- a/products/phone/src/main/ets/entryability/EntryAbility.ets +++ b/products/phone/src/main/ets/entryability/EntryAbility.ets @@ -34,44 +34,54 @@ export default class EntryAbility extends UIAbility { // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - windowStage.getMainWindow().then((data: window.Window) => { - this.windowObj = data; - this.updateBreakpoint(this.windowObj.getWindowProperties().windowRect.width); - this.windowObj.on('windowSizeChange', (windowSize: window.Size) => { - this.updateBreakpoint(windowSize.width); - }); - data.setWindowLayoutFullScreen(true).then(() => { - hilog.info(0x0000, 'EntryAbility', 'Succeeded in setting the window layout to full-screen mode.'); - }).catch((err: BusinessError) => { - hilog.info(0x0000, 'EntryAbility', - `Failed to set the window layout to full-screen mode. Cause: code=${err.code}, message=${err.message}`); - }); - - let type = window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR; - let avoidArea = data.getWindowAvoidArea(type); - let bottomRectHeight = avoidArea.bottomRect.height; - AppStorage.setOrCreate('bottomRectHeight', bottomRectHeight); - - type = window.AvoidAreaType.TYPE_SYSTEM; - avoidArea = data.getWindowAvoidArea(type); - let topRectHeight = avoidArea.topRect.height; - AppStorage.setOrCreate('topRectHeight', topRectHeight); - }).catch((error: BusinessError) => { - hilog.error(0x0000, 'testTag', 'Failed to getMainWindow. Cause: ', - JSON.stringify(error.code) + JSON.stringify(error.message)); - }) - windowStage.loadContent('pages/Index', (err) => { - AppStorage.setOrCreate('uiContext', windowStage.getMainWindowSync().getUIContext()); + try { + AppStorage.setOrCreate('uiContext', windowStage.getMainWindowSync().getUIContext()); + } catch (error) { + hilog.error(0x0000, 'testTag', `getMainWindowSync error ${JSON.stringify(error)}`); + } if (err.code) { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; } hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + windowStage.getMainWindow().then((data: window.Window) => { + try { + this.windowObj = data; + let uiContext = data.getUIContext(); + + this.updateBreakpoint(this.windowObj.getWindowProperties().windowRect.width, uiContext); + this.windowObj.on('windowSizeChange', (windowSize: window.Size) => { + this.updateBreakpoint(windowSize.width, uiContext); + }); + data.setWindowLayoutFullScreen(true).then(() => { + hilog.info(0x0000, 'EntryAbility', 'Succeeded in setting the window layout to full-screen mode.'); + }).catch((err: BusinessError) => { + hilog.info(0x0000, 'EntryAbility', + `Failed to set the window layout to full-screen mode. Cause: code=${err.code}, message=${err.message}`); + }); + + let type = window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR; + let avoidArea = data.getWindowAvoidArea(type); + let bottomRectHeight = avoidArea.bottomRect.height; + AppStorage.setOrCreate('bottomRectHeight', bottomRectHeight); + + type = window.AvoidAreaType.TYPE_SYSTEM; + avoidArea = data.getWindowAvoidArea(type); + let topRectHeight = avoidArea.topRect.height; + AppStorage.setOrCreate('topRectHeight', topRectHeight); + } catch (err) { + let error = err as BusinessError; + hilog.error(0x0000, 'GesturesShare', `getWindowProperties error ${error.code} ${error.message}`); + } + }).catch((error: BusinessError) => { + hilog.error(0x0000, 'testTag', 'Failed to getMainWindow. Cause: ', + JSON.stringify(error.code) + JSON.stringify(error.message)); + }) }); } - private updateBreakpoint(windowWidth: number): void{ + private updateBreakpoint(windowWidth: number, uiContext: UIContext): void{ try { let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; let curBp: string = ''; @@ -83,6 +93,9 @@ export default class EntryAbility extends UIAbility { curBp = BreakpointConstants.BREAKPOINT_LG; } AppStorage.setOrCreate('currentBreakpoint', curBp); + + let currentHeightBreakpoint = uiContext.getWindowHeightBreakpoint(); + AppStorage.setOrCreate('currentHeightBreakpoint', currentHeightBreakpoint); } catch (error) { hilog.error(0x0000, 'testTag', 'Failed to updateBreakpoint. Cause: %{public}s', JSON.stringify(error) ?? ''); } diff --git a/products/watch/oh-package.json5 b/products/watch/oh-package.json5 index 1edae348bc0ae542154e24101e6e2a0b3a988678..9d969e77d604fccfbc464e27dcad849ec0c176e9 100644 --- a/products/watch/oh-package.json5 +++ b/products/watch/oh-package.json5 @@ -6,12 +6,11 @@ "author": "", "license": "", "dependencies": { - "musicList": "file:../../features/musicList", - "@ohos/constantsCommon": "file:../../common/constantsCommon", - "@ohos/live": "file:../../features/live", - "@ohos/musicComment": "file:../../features/musicComment", - "@ohos/musicList": "file:../../features/musicList", - "@ohos/mediaCommon": "file:../../common/mediaCommon", + "musiclist": "file:../../features/musicList", + "constantscommon": "file:../../common/constantsCommon", + "live": "file:../../features/live", + "musiccomment": "file:../../features/musicComment", + "mediacommon": "file:../../common/mediaCommon", } } diff --git a/products/watch/src/main/ets/pages/Index.ets b/products/watch/src/main/ets/pages/Index.ets index 295e77c4650b6ef5eab327866e90e9daff2a3636..51f43c01a012a7c5d1aa7ad0984bcc6777e33d90 100644 --- a/products/watch/src/main/ets/pages/Index.ets +++ b/products/watch/src/main/ets/pages/Index.ets @@ -22,8 +22,8 @@ import { } from '@kit.ArkUI'; import { Home } from '../view/Home'; import { PlayList } from '../view/PlayList'; -import { MediaService } from '@ohos/mediaCommon'; -import { songList } from 'musicList'; +import { MediaService } from 'mediacommon'; +import { songList } from 'musiclist'; import { StyleConstants } from '../constants/StyleConstants'; @Entry diff --git a/products/watch/src/main/ets/view/SongList.ets b/products/watch/src/main/ets/view/SongList.ets index 46d52a0c099f3e941d9502875564072c1c7ba178..df5eb5852da6c43ffb7062bf5ae507d183990172 100644 --- a/products/watch/src/main/ets/view/SongList.ets +++ b/products/watch/src/main/ets/view/SongList.ets @@ -20,7 +20,7 @@ import { ArcListAttribute, // The properties of ArcList depend on ArcListAttribute and ArcListItemAttribute objects for import. ArcListItemAttribute } from '@kit.ArkUI'; -import { MediaService, SongItem } from '@ohos/mediaCommon'; +import { MediaService, SongItem } from 'mediacommon'; import { StyleConstants } from '../constants/StyleConstants'; @Builder diff --git a/products/watch/src/main/ets/view/SongPage.ets b/products/watch/src/main/ets/view/SongPage.ets index cec3f63136797f521d80449bbe84e58e1578188c..7392472660ec4c03b563ed96037d2f14758baba7 100644 --- a/products/watch/src/main/ets/view/SongPage.ets +++ b/products/watch/src/main/ets/view/SongPage.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { MediaService, SongItem } from '@ohos/mediaCommon'; +import { MediaService, SongItem } from 'mediacommon'; import { StyleConstants } from '../constants/StyleConstants'; import { VolumeSlider } from './VolumeSliderComponent'; diff --git a/products/watch/src/main/ets/view/VolumeSliderComponent.ets b/products/watch/src/main/ets/view/VolumeSliderComponent.ets index 1ceb26e8e992d068203d52121122d8335c9d9d61..a4ec0f03476f53f1bab0f666304089961f28c7cb 100644 --- a/products/watch/src/main/ets/view/VolumeSliderComponent.ets +++ b/products/watch/src/main/ets/view/VolumeSliderComponent.ets @@ -26,7 +26,7 @@ import { ArcSliderValueOptionsConstructorOptions } from '@kit.ArkUI'; import { BusinessError } from '@kit.BasicServicesKit'; -import { MediaService } from '@ohos/mediaCommon'; +import { MediaService } from 'mediacommon'; import { hilog } from '@kit.PerformanceAnalysisKit'; @Preview