|
|
@@ -77,6 +77,7 @@ import { TextNodeController } from './PipLyricTextBuilder';
|
|
|
import { IndexerView } from './IndexerView';
|
|
|
import { KeyCode } from '@kit.InputKit';
|
|
|
import { KnockController } from '../controller/KnockController';
|
|
|
+import { DeleteComptent } from '../view/DeleteComptent'
|
|
|
// import { FFmpeg, FFProgressMessageParser } from '@sj/ffmpeg';
|
|
|
const TAG = 'LocalMusic';
|
|
|
|
|
|
@@ -1682,220 +1683,6 @@ export struct LocalMusic {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private deleteDialogComponentId: number = 0
|
|
|
- @State isDeleteYuan:boolean = true
|
|
|
- @State isDeletePicture:boolean = true
|
|
|
- @State isDeleteLrc:boolean = true
|
|
|
- @Builder
|
|
|
- customDeleteDialogComponent(item: VideoItem, index: string, filePath: string) {
|
|
|
- Column() {
|
|
|
- Text('温馨提醒').fontSize(20).margin({ top: 10, bottom: 10 })
|
|
|
- Text('是否删除该文件?').fontSize(16).margin({ top: 10, bottom: 10 })
|
|
|
- Column(){
|
|
|
- // 删除源文件选项
|
|
|
- Button({ type: ButtonType.Capsule, stateEffect: true }) {
|
|
|
- Row() {
|
|
|
- SymbolGlyph($r('sys.symbol.doc_text'))
|
|
|
- .fontSize(20)
|
|
|
- .fontColor([this.themeColor])
|
|
|
- .alignSelf(ItemAlign.Center)
|
|
|
- .margin({ left: 15 })
|
|
|
- Text("删除源文件")
|
|
|
- .fontSize(16)
|
|
|
- .layoutWeight(1)
|
|
|
- .margin({ left: 10 })
|
|
|
- Toggle({ type: ToggleType.Checkbox, isOn: this.isDeleteYuan })
|
|
|
- .onChange((isOn: boolean) => {
|
|
|
- this.isDeleteYuan = isOn;
|
|
|
- PreferencesUtil.put('isDeleteYuan', this.isDeleteYuan)
|
|
|
- })
|
|
|
- .margin({ right: 28 })
|
|
|
- .selectedColor(this.themeColor)
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- .backgroundColor(Color.Transparent)
|
|
|
- .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
|
|
|
- .onClick(() => {
|
|
|
- this.isDeleteYuan = !this.isDeleteYuan
|
|
|
- })
|
|
|
- .width('100%')
|
|
|
- .padding(10)
|
|
|
- .margin({ left: 18 })
|
|
|
-
|
|
|
- // 删除封面选项
|
|
|
- Button({ type: ButtonType.Capsule, stateEffect: true }) {
|
|
|
- Row() {
|
|
|
- SymbolGlyph($r('sys.symbol.picture'))
|
|
|
- .fontSize(20)
|
|
|
- .fontColor([this.themeColor])
|
|
|
- .alignSelf(ItemAlign.Center)
|
|
|
- .margin({ left: 15 })
|
|
|
- Text("删除封面文件")
|
|
|
- .fontSize(16)
|
|
|
- .layoutWeight(1)
|
|
|
- .margin({ left: 10 })
|
|
|
- Toggle({ type: ToggleType.Checkbox, isOn: this.isDeletePicture })
|
|
|
- .onChange((isOn: boolean) => {
|
|
|
- this.isDeletePicture = isOn;
|
|
|
- PreferencesUtil.put('isDeletePicture', this.isDeletePicture)
|
|
|
- })
|
|
|
- .margin({ right: 28 })
|
|
|
- .selectedColor(this.themeColor)
|
|
|
- }
|
|
|
- }
|
|
|
- .backgroundColor(Color.Transparent)
|
|
|
- .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
|
|
|
- .onClick(() => {
|
|
|
- this.isDeletePicture = !this.isDeletePicture
|
|
|
- })
|
|
|
- .width('100%')
|
|
|
- .padding(10)
|
|
|
- .margin({ left: 18 })
|
|
|
-
|
|
|
-
|
|
|
- // 删除歌词选项
|
|
|
- Button({ type: ButtonType.Capsule, stateEffect: true }) {
|
|
|
- Row() {
|
|
|
- SymbolGlyph($r('sys.symbol.input_mode'))
|
|
|
- .fontSize(20)
|
|
|
- .fontColor([this.themeColor])
|
|
|
- .alignSelf(ItemAlign.Center)
|
|
|
- .margin({ left: 15 })
|
|
|
-
|
|
|
- Text("删除歌词文件")
|
|
|
- .fontSize(16)
|
|
|
- .layoutWeight(1)
|
|
|
- .margin({ left: 10 })
|
|
|
- Toggle({ type: ToggleType.Checkbox, isOn: this.isDeleteLrc })
|
|
|
- .onChange((isOn: boolean) => {
|
|
|
- this.isDeleteLrc = isOn;
|
|
|
- PreferencesUtil.put('isDeleteLrc', this.isDeleteLrc)
|
|
|
- })
|
|
|
- .margin({ right: 28 })
|
|
|
- .selectedColor(this.themeColor)
|
|
|
- }
|
|
|
- }
|
|
|
- .backgroundColor(Color.Transparent)
|
|
|
- .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
|
|
|
- .onClick(() => {
|
|
|
- this.isDeleteLrc = !this.isDeleteLrc
|
|
|
- })
|
|
|
- .width('100%')
|
|
|
- .padding(10)
|
|
|
- .margin({ left: 18 ,bottom:10})
|
|
|
-
|
|
|
- }
|
|
|
- .visibility(item.type === CommonConstants.TYPE_IS_DIR?Visibility.None:Visibility.Visible)
|
|
|
- Flex({ justifyContent: FlexAlign.SpaceAround }) {
|
|
|
- Button($r('app.string.cancel'))
|
|
|
- .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.8 })
|
|
|
- .padding(15)
|
|
|
- .width(120)
|
|
|
- .onClick(() => {
|
|
|
- this.getUIContext().getPromptAction().closeCustomDialog(this.deleteDialogComponentId)
|
|
|
- }).backgroundColor(0xffffff).fontColor(Color.Black)
|
|
|
- Button($r('app.string.sure'))
|
|
|
- .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.8 })
|
|
|
- .padding(15)
|
|
|
- .width(120)
|
|
|
- .onClick(() => {
|
|
|
- this.doDelete(item, index + '', filePath)
|
|
|
- this.getUIContext().getPromptAction().closeCustomDialog(this.deleteDialogComponentId)
|
|
|
-
|
|
|
- }).backgroundColor(0xffffff).fontColor(Color.Red)
|
|
|
- }.margin({ bottom: 10 })
|
|
|
- }
|
|
|
- }
|
|
|
- showWarnIsDeleteFile(item: VideoItem, index: string, filePath: string){
|
|
|
- this.getUIContext().getPromptAction().openCustomDialog({
|
|
|
- builder: () => {
|
|
|
- this.customDeleteDialogComponent(item,index,filePath)
|
|
|
- },
|
|
|
- isModal:true,
|
|
|
- showInSubWindow:false,
|
|
|
- maskColor: Color.Transparent,
|
|
|
- dialogTransition: // 设置弹窗内容显示的过渡效果
|
|
|
- TransitionEffect.translate({ x: 0, y: 290, z: 0 })
|
|
|
- .animation({ duration: 600, curve: Curve.Smooth }),
|
|
|
-
|
|
|
- maskTransition: // 设置蒙层显示的过渡效果
|
|
|
- TransitionEffect.opacity(0)
|
|
|
- .animation({ duration: 600, curve: Curve.Smooth })
|
|
|
- }).then((dialogId: number) => {
|
|
|
- this.deleteDialogComponentId = dialogId
|
|
|
- })
|
|
|
- .catch((error: BusinessError) => {
|
|
|
- console.error(`openCustomDialog error code is ${error.code}, message is ${error.message}`)
|
|
|
- })
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- showWarnIsDeleteFile2(item: VideoItem, index: string, filePath: string) {
|
|
|
- //操作确认类弹出框
|
|
|
- DialogHelper.showAlertDialog({
|
|
|
- maskColor: Color.Transparent,
|
|
|
- content: "确定要删除这个文件吗?",
|
|
|
- backgroundColor: Color.Grey,
|
|
|
- transition: AnimationHelper.transitionInUp(555),
|
|
|
- onAction: (action) => {
|
|
|
- if (action == DialogAction.ONE) {
|
|
|
- // ToastUtil.showToast(`您点击了取消按钮`);
|
|
|
- } else if (action == DialogAction.TWO) {
|
|
|
- // ToastUtil.showToast(`您点击了确认按钮`);
|
|
|
- this.doDelete(item, index + '', filePath)
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- //删除单个索引index的视频
|
|
|
- async doDelete(item: VideoItem, index: string, filePath: string) {
|
|
|
- if (ArrayUtil.isNotEmpty(this.videoLocalList)) {
|
|
|
-
|
|
|
- Logger.info(TAG, 'delete filePath = ' + filePath);
|
|
|
- if (item.type === CommonConstants.TYPE_IS_DIR) {
|
|
|
- //旧文件删除
|
|
|
- this.table.deleteDataForParentPath(item.filePath, () => {
|
|
|
- FileUtil.rmdir(filePath).then(() => {
|
|
|
- this.videoLocalList.splice(Number(index), 1)
|
|
|
- this.deleteCache(this.currentPath)
|
|
|
- this.getSortedFiles(this.currentPath, true)
|
|
|
- }).catch((error: BusinessError) => {
|
|
|
- console.error(error.message);
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- } else {
|
|
|
- this.table.deleteData(item,async () => {
|
|
|
- if(this.isDeleteYuan){
|
|
|
- await FileUtil.unlink(filePath)
|
|
|
-
|
|
|
- }
|
|
|
- if (this.isDeletePicture && item.pixelMapPath &&
|
|
|
- item.pixelMapPath !== $r('app.media.music_red').toString() &&
|
|
|
- FileUtil.accessSync(item.pixelMapPath)) {
|
|
|
- await FileUtil.unlink(item.pixelMapPath);
|
|
|
- Logger.info(TAG, `onecold 封面文件已删除: ${item.pixelMapPath}`);
|
|
|
- }
|
|
|
- if(this.isDeleteLrc) {
|
|
|
- const lyricPath = item.filePath?.replace(/\.[^/.]+$/, ".lrc");
|
|
|
- if (lyricPath && FileUtil.accessSync(lyricPath)) {
|
|
|
- await FileUtil.unlink(lyricPath);
|
|
|
- Logger.info(TAG, `onecold 歌词文件已删除: ${lyricPath}`);
|
|
|
- }
|
|
|
- }
|
|
|
- this.videoLocalList.splice(Number(index), 1)
|
|
|
- this.deleteCache(this.currentPath)
|
|
|
- this.getSortedFiles(this.currentPath, true)
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
//重命名的对话框
|
|
|
showReNameDialog(item: VideoItem, index: string, filePath: string) {
|
|
|
@@ -2424,67 +2211,57 @@ export struct LocalMusic {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- showWarnIsDelete() {
|
|
|
- //操作确认类弹出框
|
|
|
- DialogHelper.showAlertDialog({
|
|
|
- content: "确定要删除这些文件吗?",
|
|
|
- transition: AnimationHelper.transitionInUp(666),
|
|
|
- maskColor: Color.Transparent,
|
|
|
- backgroundColor: Color.Grey,
|
|
|
- onAction: (action) => {
|
|
|
- if (action == DialogAction.ONE) {
|
|
|
- // ToastUtil.showToast(`您点击了取消按钮`);
|
|
|
- } else if (action == DialogAction.TWO) {
|
|
|
- // ToastUtil.showToast(`您点击了确认按钮`);
|
|
|
- this.deleteMultipleFiles()
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
+ private deleteComponentId: number = 0
|
|
|
//多选删除文件
|
|
|
- deleteMultipleFiles() {
|
|
|
- if (ArrayUtil.isNotEmpty(this.selectedFiles)) {
|
|
|
- this.selectedFiles.forEach((item) => {
|
|
|
- Logger.info(TAG, 'delete filePath = ' + item.filePath);
|
|
|
- if (item.type === CommonConstants.TYPE_IS_DIR) {
|
|
|
- this.table.deleteDataForParentPath(item.filePath, () => {
|
|
|
- FileUtil.rmdir(item.filePath).then(() => {
|
|
|
- this.videoLocalList = this.videoLocalList.filter(v => v !== item);
|
|
|
-
|
|
|
- this.selectedFiles = [];
|
|
|
- this.isMultiSelect = false
|
|
|
- this.isAllSelected = false
|
|
|
- this.cache.delete(this.currentPath);
|
|
|
- this.getSortedFiles(this.currentPath, true);
|
|
|
- }).catch((error: Error) => {
|
|
|
- console.error(error.message);
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
+ showWarnIsDelete(){
|
|
|
+ this.getUIContext().getPromptAction().openCustomDialog({
|
|
|
+ builder: () => {
|
|
|
+ this.deleteComptentBuilder()
|
|
|
+ },
|
|
|
+ isModal:true,
|
|
|
+ showInSubWindow:false,
|
|
|
+ maskColor: Color.Transparent,
|
|
|
+ dialogTransition: // 设置弹窗内容显示的过渡效果
|
|
|
+ TransitionEffect.translate({ x: 0, y: 290, z: 0 })
|
|
|
+ .animation({ duration: 600, curve: Curve.Smooth }),
|
|
|
|
|
|
- } else {
|
|
|
- this.table.deleteData(item, () => {
|
|
|
- FileUtil.unlink(item.filePath).catch((error: Error) => {
|
|
|
- console.error(error.message);
|
|
|
- }).finally(() => {
|
|
|
- this.videoLocalList = this.videoLocalList.filter(v => v !== item);
|
|
|
- this.selectedFiles = [];
|
|
|
- this.isMultiSelect = false
|
|
|
- this.isAllSelected = false
|
|
|
- this.cache.delete(this.currentPath);
|
|
|
- this.getSortedFiles(this.currentPath, true);
|
|
|
- });
|
|
|
- });
|
|
|
+ maskTransition: // 设置蒙层显示的过渡效果
|
|
|
+ TransitionEffect.opacity(0)
|
|
|
+ .animation({ duration: 600, curve: Curve.Smooth })
|
|
|
+ }).then((dialogId: number) => {
|
|
|
+ this.deleteComponentId = dialogId
|
|
|
+ })
|
|
|
+ .catch((error: BusinessError) => {
|
|
|
+ console.error(`openCustomDialog error code is ${error.code}, message is ${error.message}`)
|
|
|
+ })
|
|
|
|
|
|
+ }
|
|
|
|
|
|
+ @Builder
|
|
|
+ deleteComptentBuilder(){
|
|
|
+ DeleteComptent({
|
|
|
+ selectedFiles:this.selectedFiles,
|
|
|
+ onCancel:()=>{
|
|
|
+ this.isMultiSelect = false
|
|
|
+ this.getUIContext().getPromptAction().closeCustomDialog(this.deleteComponentId)
|
|
|
+ },
|
|
|
+ onDeleteResult:(result: boolean,item: VideoItem)=>{
|
|
|
+ this.isMultiSelect = false
|
|
|
+ this.getUIContext().getPromptAction().closeCustomDialog(this.deleteComponentId)
|
|
|
+ if(result){//如果删除成功,更新数据
|
|
|
+ this.videoLocalList = this.videoLocalList.filter(v => v !== item);
|
|
|
+ this.selectedFiles = [];
|
|
|
+ this.isAllSelected = false
|
|
|
+ this.cache.delete(this.currentPath);
|
|
|
+ this.getSortedFiles(this.currentPath, true);
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
//多选移动文件
|
|
|
showCutDialogForMultipleFiles(isCurrent: boolean, viewId: string) {
|
|
|
Logger.info('onecold showCutDialogForMultipleFiles')
|
|
|
@@ -3086,7 +2863,7 @@ export struct LocalMusic {
|
|
|
.textOverflow({ overflow: TextOverflow.MARQUEE })//超长滚动
|
|
|
.fontWeight(FontWeight.Bold)
|
|
|
.fontColor($r('app.color.text_color'))
|
|
|
- .margin({ left: this.currentLyricAlignMode === 0 ? 13 : 0 })
|
|
|
+ .margin({ left: this.currentLyricAlignMode === 0 ? 8 : 0 })
|
|
|
if (this.modeType == 3 && ArrayUtil.isNotEmpty(this.videoLocalList)) {
|
|
|
Text(`艺术家:${this.videoLocalList[0].artist}`)
|
|
|
.fontSize(14)
|
|
|
@@ -3094,7 +2871,7 @@ export struct LocalMusic {
|
|
|
.maxLines(1)
|
|
|
.fontWeight(FontWeight.Bold)
|
|
|
.fontColor($r('app.color.text_color'))
|
|
|
- .margin({ left: this.currentLyricAlignMode === 0 ? 13 : 0 })
|
|
|
+ .margin({ left: this.currentLyricAlignMode === 0 ? 8 : 0 })
|
|
|
if(this.videoLocalList[0].genre){
|
|
|
Text(`风格:${this.videoLocalList[0].genre}`)
|
|
|
.fontSize(14)
|
|
|
@@ -3105,7 +2882,7 @@ export struct LocalMusic {
|
|
|
?Visibility.None:Visibility.Visible)
|
|
|
.fontWeight(FontWeight.Bold)
|
|
|
.fontColor($r('app.color.text_color'))
|
|
|
- .margin({ left: this.currentLyricAlignMode === 0 ? 18 : 0 })
|
|
|
+ .margin({ left: this.currentLyricAlignMode === 0 ? 8 : 0 })
|
|
|
}
|
|
|
if(this.videoLocalList[0].year){
|
|
|
Text(`发行时间:${this.videoLocalList[0].year}`)
|
|
|
@@ -3117,7 +2894,7 @@ export struct LocalMusic {
|
|
|
?Visibility.None:Visibility.Visible)
|
|
|
.fontWeight(FontWeight.Bold)
|
|
|
.fontColor($r('app.color.text_color'))
|
|
|
- .margin({ left: this.currentLyricAlignMode === 0 ? 18 : 0 })
|
|
|
+ .margin({ left: this.currentLyricAlignMode === 0 ? 8 : 0 })
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -3129,7 +2906,7 @@ export struct LocalMusic {
|
|
|
.fontWeight(FontWeight.Bold)
|
|
|
.padding({ top: 8 })
|
|
|
.fontColor($r('app.color.text_color'))
|
|
|
- .margin({ left: this.currentLyricAlignMode === 0 ? 18 : 0 })
|
|
|
+ .margin({ left: this.currentLyricAlignMode === 0 ? 8 : 0 })
|
|
|
Blank()
|
|
|
|
|
|
}
|
|
|
@@ -4111,7 +3888,8 @@ export struct LocalMusic {
|
|
|
(item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
|
|
|
item.name === LocalMusic.STR_HISTORY_MUSIC ? Visibility.None : Visibility.Visible) : Visibility.Visible)
|
|
|
.onClick(() => {
|
|
|
- this.showWarnIsDeleteFile(item, index + '', filePath)
|
|
|
+ this.selectedFiles.push(item)
|
|
|
+ this.showWarnIsDelete()
|
|
|
this.longItemFilePath = ''
|
|
|
})
|
|
|
|
|
|
@@ -11856,7 +11634,9 @@ export struct LocalMusic {
|
|
|
item.name === LocalMusic.STR_HISTORY_MUSIC ? Visibility.None : Visibility.Visible) : Visibility.Visible)
|
|
|
.margin(5)
|
|
|
.onClick(() => {
|
|
|
- this.showWarnIsDeleteFile(item, index + '', filePath)
|
|
|
+ this.selectedFiles.push(item)
|
|
|
+ this.showWarnIsDelete()
|
|
|
+ // this.showWarnIsDeleteFile(item, index + '', filePath)
|
|
|
})
|
|
|
|
|
|
Button() {
|