Ver código fonte

适配电脑安全区域

onecold 9 meses atrás
pai
commit
3edac4dece
2 arquivos alterados com 61 adições e 33 exclusões
  1. 2 2
      AppScope/app.json5
  2. 59 31
      entry/src/main/ets/view/LocalMusic.ets

+ 2 - 2
AppScope/app.json5

@@ -2,8 +2,8 @@
   "app": {
     "bundleName": "com.xgplayer.ttmusic.hm",
     "vendor": "example",
-    "versionCode": 20251101,
-    "versionName": "1.6.7",
+    "versionCode": 20251105,
+    "versionName": "1.6.8",
     "icon": "$media:app_icon",
     "label": "$string:app_name",
     "multiAppMode": {

+ 59 - 31
entry/src/main/ets/view/LocalMusic.ets

@@ -358,8 +358,8 @@ export struct LocalMusic {
   @State isOneKeyTags:boolean = false
   @State isFixMessy:boolean = false
   @StorageProp('isLandscape') @Watch('onIsLandscapeChange')  isLandscape: boolean = false;
-  @StorageProp('topRectHeight') topRectHeight: number = px2vp(AppUtil.getStatusBarHeight());
-  @StorageProp('bottomRectHeight') bottomRectHeight: number = 0;
+  @StorageProp('topSafeHeight') topSafeHeight: number = 0;
+  @StorageProp('bottomSafeHeight') bottomSafeHeight: number = 0;
   @StorageProp('windowWidth') windowWidth: number = 0;
   @StorageProp('windowHeight') windowHeight: number = 0;
   @StorageProp('isHiCarStatus') isHiCarStatus: boolean = false;
@@ -678,7 +678,6 @@ export struct LocalMusic {
     }
     this.initSetting()
     this.UNKONWN = Utility.resourceToString(this.context, $r('app.string.unknown'));
-    this.topRectHeight = px2vp(AppUtil.getStatusBarHeight());
     Utility.getAppName(getContext(this)).then((appName: string) => {
       this.appName = appName
     })
@@ -2385,7 +2384,8 @@ export struct LocalMusic {
       .opacity(this.barBottomOpacity)
       .width('90%')
       .borderRadius(20)
-      .margin({ bottom:this.bottomRectHeight })
+      .margin({ bottom:DeviceUtil.getDeviceType() === resourceManager.DeviceType.DEVICE_TYPE_2IN1
+        ? 30 :this.bottomSafeHeight })
       .backgroundBlurStyle(BlurStyle.BACKGROUND_ULTRA_THICK)
       .backgroundImage( this.cover)
       .visibility(this.isMultiSelect ? Visibility.None : Visibility.Visible)
@@ -2406,6 +2406,44 @@ export struct LocalMusic {
       Column() {
 
         Stack() {
+          //libraryname加上去后onKeyEvent监听不了,因为目前的解决方案是上面的XComponent,去掉libraryname
+          XComponent({ id: 'for_onKeyEvent',type: XComponentType.SURFACE,
+            controller: this.xcomponentController })
+            .onLoad(async (event?: object) => {
+
+            })
+            .focusable(true)
+            .height(0)
+            .focusOnTouch(true)
+            .defaultFocus(true) // 自动获取键盘焦点
+            .onKeyEvent((event?: KeyEvent) => {
+              console.info('onecold点击 onKeyEvent')
+              // If the button type is pressed, the subsequent code will not be executed; the specific button logic will be executed upon release.
+              if (!event || event.type !== KeyType.Down) {
+                return;
+              }
+              console.info('onecold点击 onKeyEvent event.keyCode: ' + event.keyCode)
+              //空格键 Space key controls pause/play
+              if (event.keyCode === KeyCode.KEYCODE_SPACE|| event.keyCode === KeyCode.KEYCODE_MEDIA_PLAY_PAUSE) {
+                this.playOrPause()
+              }
+              if (event.keyCode === KeyCode.KEYCODE_DPAD_UP) {
+                this.playPrevious()
+              }
+              if (event.keyCode === KeyCode.KEYCODE_DPAD_DOWN) {
+                this.playNext()
+              }
+
+              // Right-click to fast forward
+              if (event.keyCode === KeyCode.KEYCODE_DPAD_RIGHT) {
+                this.fastForward()
+              }
+              // Left-click to rewind
+              if (event.keyCode === KeyCode.KEYCODE_DPAD_LEFT) {
+                this.backForward()
+              }
+            })
+
           Column() {
 
             XComponent({
@@ -2420,25 +2458,7 @@ export struct LocalMusic {
                   this.initDelayPlay(event);
                 }
               })
-              .onKeyEvent((event?: KeyEvent) => {
-                // If the button type is pressed, the subsequent code will not be executed; the specific button logic will be executed upon release.
-                if (!event || event.type !== KeyType.Down) {
-                  return;
-                }
-                //空格键 Space key controls pause/play
-                if (event.keyCode === KeyCode.KEYCODE_SPACE) {
-                  console.info('onecold playOrPause 1999')
-                  this.playOrPause()
-                }
-                // Right-click to fast forward
-                if (event.keyCode === KeyCode.KEYCODE_DPAD_RIGHT) {
-                  this.sessionFastForwardCallback(15);
-                }
-                // Left-click to rewind
-                if (event.keyCode === KeyCode.KEYCODE_DPAD_LEFT) {
-                  this.sessionRewindCallback(15);
-                }
-              })
+
               .onDestroy(() => {
               })
               .width('100%')// .width(this.videoWidth)
@@ -2826,7 +2846,7 @@ export struct LocalMusic {
         }
       }
     }
-    .padding({ top: this.topRectHeight+10, left: 10, right: 10 })
+    .padding({ top: this.topSafeHeight+10, left: 10, right: 10 })
     .width('100%')
   }
 
@@ -4219,7 +4239,7 @@ export struct LocalMusic {
   getWaterView(){
     Scroll(this.scroller) {
       Column() {
-        Blank().height(this.topRectHeight + 55)
+        Blank().height(this.topSafeHeight + 55)
 
         WaterFlow({
           scroller:this.waterScroller,
@@ -4668,7 +4688,7 @@ export struct LocalMusic {
     Grid(this.scroller, this.layoutOptionsForHeader) {
       GridItem() {
         Column(){
-          Blank().height(this.topRectHeight + 45)
+          Blank().height(this.topSafeHeight + 45)
         }
 
       }
@@ -4704,7 +4724,7 @@ export struct LocalMusic {
     .editMode(true)
     .transition(TransitionEffect.move(TransitionEdge.BOTTOM)
       .animation({ duration: 500, curve: Curve.Ease }))
-    .padding({bottom:this.bottomBarHeight+this.bottomRectHeight+10})
+    .padding({bottom:this.bottomBarHeight+this.bottomSafeHeight+10})
     .reuseId('grid_item')
     .layoutWeight(1)
     .scrollBar(BarState.Off)
@@ -5122,6 +5142,10 @@ export struct LocalMusic {
                 transition: TransitionEffect.translate({ x: 500 }).animation({ curve: curves.springMotion(0.6, 0.8) })
               })
               .onClick(() => {
+                if (!Utility.isNoble()) {
+                  this.showVipDialog()
+                  return
+                }
                 this.isExtractAcc = !this.isExtractAcc
               })
             MenuItem({
@@ -5132,6 +5156,10 @@ export struct LocalMusic {
                 transition: TransitionEffect.translate({ x: 500 }).animation({ curve: curves.springMotion(0.6, 0.8) })
               })
               .onClick(() => {
+                if (!Utility.isNoble()) {
+                  this.showVipDialog()
+                  return
+                }
                 this.isConverter = !this.isConverter
               })
 
@@ -5506,11 +5534,11 @@ export struct LocalMusic {
     // })
     // .margin({
     //       bottom:this.isShowCoverHeader() ? this.bottomBarHeight+30
-    //         :  this.bottomBarHeight+this.topRectHeight+this.topBarHeight+this.offHeight
+    //         :  this.bottomBarHeight+this.topSafeHeight+this.topBarHeight+this.offHeight
     //     })
-    .contentStartOffset(this.topRectHeight + 55)
+    .contentStartOffset(this.topSafeHeight + 55)
     .scrollBar(BarState.Off)
-    .contentEndOffset(this.bottomBarHeight+this.bottomRectHeight)
+    .contentEndOffset(this.bottomBarHeight+this.bottomSafeHeight)
     .cachedCount(6)
     .reuseId('list_item')
     .borderRadius(20)
@@ -9169,7 +9197,7 @@ export struct LocalMusic {
             .width(24)
             .clickEffect({level:ClickEffectLevel.MIDDLE})
             .bindSheet($$this.isShowMoreView, this.PlayMoreSheet(), {
-              height: this.isCoverOpacity() ? '95%' : '93%',
+              height:  '95%',
               preferType: this.currentBreakpoint!==BreakpointTypeEnum.SM?SheetType.CENTER:SheetType.BOTTOM,
               dragBar: true,
               showClose: true,