Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master'

chendeben před 1 rokem
rodič
revize
a80933ab4e

+ 1 - 1
entry/src/main/ets/pages/SettingPage.ets

@@ -222,7 +222,7 @@ export struct SettingPage {
     this.isCoverTop = PreferencesUtil.getBooleanSync(SettingPage.IS_COVER_TOP, false)
     this.isShowTitleBar = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_TITLTBAR, true)
     this.isShowAllBar = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_ALLBAR, true)
-    this.isShowPlayPageBack = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_PLAYPAGE_BACK, false)
+    this.isShowPlayPageBack = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_PLAYPAGE_BACK, true)
     this.isShowSingleLineLyric = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_SLLYRIC, false)
     this.isCoverTopBig = PreferencesUtil.getBooleanSync(SettingPage.IS_COVER_TOP_BIG, false)
     this.longPressSpeed = PreferencesUtil.getNumberSync(SettingPage.LONG_PRESS_SPEED, 3)

+ 73 - 3
entry/src/main/ets/view/LocalMusic.ets

@@ -17,12 +17,12 @@ import {
   StrUtil,
   ToastUtil
 } from '@pura/harmony-utils';
+import { unifiedDataChannel, uniformDataStruct, uniformTypeDescriptor } from '@kit.ArkData';
 import { CommonConstants } from '../common/constants/CommonConstants';
 import Logger from '../common/util/Logger';
 import { photoAccessHelper } from '@kit.MediaLibraryKit';
 import { Utility } from '../common/util/Utility';
 import { BusinessError, emitter } from '@kit.BasicServicesKit';
-import { uniformTypeDescriptor } from '@kit.ArkData';
 import { BubbleBean } from '../viewmodel/BubbleBean';
 import { PopupPosition, XPopup } from '@chinalike/popup';
 import { common, ConfigurationConstant } from '@kit.AbilityKit';
@@ -596,7 +596,7 @@ export struct LocalMusic {
     this.twoFingerType = PreferencesUtil.getNumberSync(SettingPage.TWO_FINGER_TYPE, 3)
     this.isCoverTop = PreferencesUtil.getBooleanSync(SettingPage.IS_COVER_TOP, false)
     this.isCircleBtn = PreferencesUtil.getBooleanSync(SettingPage.IS_CIRCLE_BTN, true)
-    this.isShowPlayPageBack = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_PLAYPAGE_BACK, false)
+    this.isShowPlayPageBack = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_PLAYPAGE_BACK, true)
     this.isCoverTopBig = PreferencesUtil.getBooleanSync(SettingPage.IS_COVER_TOP_BIG, false)
     this.isShowSingleLineLyric = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_SLLYRIC, false)
     this.longPressSpeed = PreferencesUtil.getNumberSync(SettingPage.LONG_PRESS_SPEED, 3)
@@ -3415,9 +3415,44 @@ export struct LocalMusic {
 
       return { offsetRemain: offset };
     })
+    //允许拖拽音乐和视频到List或Grid上自动导入视频
+    .allowDrop([uniformTypeDescriptor.UniformDataType.AUDIO,uniformTypeDescriptor.UniformDataType.VIDEO])
+    .onDrop((event?: DragEvent) => {
+      try {
+        let dragData: UnifiedData = (event as DragEvent).getData() as UnifiedData;
+        if (dragData !== undefined) {
+          let records: unifiedDataChannel.UnifiedRecord[] = dragData.getRecords();
+          if (records.length > 0) {
+            for (let i = 0; i < records.length; i++) {
+              let types = records[i].getTypes();
+              if (types.includes(uniformTypeDescriptor.UniformDataType.FILE_URI)) {
+                const fileUriUds =
+                  records[i].getEntry(uniformTypeDescriptor.UniformDataType.FILE_URI) as uniformDataStruct.FileUri;
+                let typeDescriptor = uniformTypeDescriptor.getTypeDescriptor(fileUriUds.fileType);
+                if (typeDescriptor.belongsTo(uniformTypeDescriptor.UniformDataType.AUDIO)
+                 ||typeDescriptor.belongsTo(uniformTypeDescriptor.UniformDataType.VIDEO)) {
+                  this.targetFile = fileUriUds.oriUri;
+                  this.saveVideoDatas([this.targetFile])
+                  hilog.info(0x0000, 'Heanup', '当前targetFile:' + this.targetFile);
+                }
+              }
+            }
+          } else {
+            hilog.info(0x0000, TAG, `%{public}s`, `dragData arr is null`);
+          }
+        } else {
+          hilog.info(0x0000, TAG, `%{public}s`, `dragData is undefined`);
+        }
+
+      } catch (error) {
+        const err = error as BusinessError;
+        hilog.error(0x0000, TAG, `startDataLoading errorCode: ${err.code}, errorMessage: ${err.message}`);
+      }
+    })
 
-  }
 
+  }
+  @State targetFile: string = '';
   setGridTwoFingers() {
     this.pinchValue = this.scaleValue;
     Logger.info('this.pinchValue = ' + this.pinchValue);
@@ -3990,6 +4025,41 @@ export struct LocalMusic {
       return { offsetRemain: offset };
     })
 
+     //拖拽pc或者pad的用鼠标拖拽音乐和视频到List或Grid上自动导入视频
+    .allowDrop([uniformTypeDescriptor.UniformDataType.AUDIO,uniformTypeDescriptor.UniformDataType.VIDEO])
+    .onDrop((event?: DragEvent) => {
+      try {
+        let dragData: UnifiedData = (event as DragEvent).getData() as UnifiedData;
+        if (dragData !== undefined) {
+          let records: unifiedDataChannel.UnifiedRecord[] = dragData.getRecords();
+          if (records.length > 0) {
+            for (let i = 0; i < records.length; i++) {
+              let types = records[i].getTypes();
+              if (types.includes(uniformTypeDescriptor.UniformDataType.FILE_URI)) {
+                const fileUriUds =
+                  records[i].getEntry(uniformTypeDescriptor.UniformDataType.FILE_URI) as uniformDataStruct.FileUri;
+                let typeDescriptor = uniformTypeDescriptor.getTypeDescriptor(fileUriUds.fileType);
+                if (typeDescriptor.belongsTo(uniformTypeDescriptor.UniformDataType.AUDIO)
+                  ||typeDescriptor.belongsTo(uniformTypeDescriptor.UniformDataType.VIDEO)) {
+                  this.targetFile = fileUriUds.oriUri;
+                  this.saveVideoDatas([this.targetFile])
+                  hilog.info(0x0000, 'Heanup', '当前targetFile:' + this.targetFile);
+                }
+              }
+            }
+          } else {
+            hilog.info(0x0000, TAG, `%{public}s`, `dragData arr is null`);
+          }
+        } else {
+          hilog.info(0x0000, TAG, `%{public}s`, `dragData is undefined`);
+        }
+
+      } catch (error) {
+        const err = error as BusinessError;
+        hilog.error(0x0000, TAG, `startDataLoading errorCode: ${err.code}, errorMessage: ${err.message}`);
+      }
+    })
+
   }
 
   setBarHeightNormal() {