mirror of
				https://github.com/SimpleMobileTools/Simple-Gallery.git
				synced 2025-06-05 21:59:19 +02:00 
			
		
		
		
	pass the MediaStoreId with FileDirItems at deleting too
This commit is contained in:
		| @@ -1104,7 +1104,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View | ||||
|     } | ||||
|  | ||||
|     private fun askConfirmDelete() { | ||||
|         val fileDirItem = File(getCurrentPath()).toFileDirItem(this) | ||||
|         val fileDirItem = getCurrentMedium()?.toFileDirItem() ?: return | ||||
|         val size = fileDirItem.getProperSize(this, countHidden = true).formatSize() | ||||
|         val filename = "\"${getCurrentPath().getFilenameFromPath()}\"" | ||||
|         val filenameAndSize = "$filename ($size)" | ||||
| @@ -1123,12 +1123,13 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View | ||||
|     } | ||||
|  | ||||
|     private fun deleteConfirmed() { | ||||
|         val path = getCurrentMedia().getOrNull(mPos)?.path ?: return | ||||
|         val currentMedium = getCurrentMedium() | ||||
|         val path = currentMedium?.path ?: return | ||||
|         if (getIsPathDirectory(path) || !path.isMediaFile()) { | ||||
|             return | ||||
|         } | ||||
|  | ||||
|         val fileDirItem = FileDirItem(path, path.getFilenameFromPath()) | ||||
|         val fileDirItem = currentMedium.toFileDirItem() | ||||
|         if (config.useRecycleBin && !getCurrentMedium()!!.getIsInRecycleBin()) { | ||||
|             checkManageMediaOrHandleSAFDialogSdk30(fileDirItem.path) { | ||||
|                 if (!it) { | ||||
|   | ||||
| @@ -38,7 +38,6 @@ import kotlinx.android.synthetic.main.video_item_grid.view.media_item_holder | ||||
| import kotlinx.android.synthetic.main.video_item_grid.view.medium_check | ||||
| import kotlinx.android.synthetic.main.video_item_grid.view.medium_name | ||||
| import kotlinx.android.synthetic.main.video_item_grid.view.medium_thumbnail | ||||
| import java.io.File | ||||
|  | ||||
| class MediaAdapter( | ||||
|     activity: BaseSimpleActivity, var media: ArrayList<ThumbnailItem>, val listener: MediaOperationsListener?, val isAGetIntent: Boolean, | ||||
| @@ -462,16 +461,17 @@ class MediaAdapter( | ||||
|  | ||||
|     private fun askConfirmDelete() { | ||||
|         val itemsCnt = selectedKeys.size | ||||
|         val firstPath = getSelectedPaths().first() | ||||
|         val fileDirItem = File(firstPath).toFileDirItem(activity) | ||||
|         val selectedMedia = getSelectedItems() | ||||
|         val firstPath = selectedMedia.first().path | ||||
|         val fileDirItem = selectedMedia.first().toFileDirItem() | ||||
|         val size = fileDirItem.getProperSize(activity, countHidden = true).formatSize() | ||||
|         val itemsAndSize = if (itemsCnt == 1) { | ||||
|             fileDirItem.mediaStoreId = selectedMedia.first().mediaStoreId | ||||
|             "\"${firstPath.getFilenameFromPath()}\" ($size)" | ||||
|         } else { | ||||
|             val paths = getSelectedPaths() | ||||
|             val fileDirItems = ArrayList<FileDirItem>(paths.size) | ||||
|             paths.forEach { | ||||
|                 val curFileDirItem = File(it).toFileDirItem(activity) | ||||
|             val fileDirItems = ArrayList<FileDirItem>(selectedMedia.size) | ||||
|             selectedMedia.forEach { medium -> | ||||
|                 val curFileDirItem = medium.toFileDirItem() | ||||
|                 fileDirItems.add(curFileDirItem) | ||||
|             } | ||||
|             val fileSize = fileDirItems.sumByLong { it.getProperSize(activity, countHidden = true) }.formatSize() | ||||
| @@ -501,8 +501,8 @@ class MediaAdapter( | ||||
|                 return@handleSAFDialog | ||||
|             } | ||||
|  | ||||
|             val sdk30SafPath = selectedPaths.firstOrNull { activity.isAccessibleWithSAFSdk30(it) } ?: getFirstSelectedItemPath() ?: return@handleSAFDialog | ||||
|             activity.checkManageMediaOrHandleSAFDialogSdk30(sdk30SafPath) { | ||||
|             val sdk30SAFPath = selectedPaths.firstOrNull { activity.isAccessibleWithSAFSdk30(it) } ?: getFirstSelectedItemPath() ?: return@handleSAFDialog | ||||
|             activity.checkManageMediaOrHandleSAFDialogSdk30(sdk30SAFPath) { | ||||
|                 if (!it) { | ||||
|                     return@checkManageMediaOrHandleSAFDialogSdk30 | ||||
|                 } | ||||
| @@ -511,9 +511,9 @@ class MediaAdapter( | ||||
|                 val removeMedia = ArrayList<Medium>(selectedKeys.size) | ||||
|                 val positions = getSelectedItemPositions() | ||||
|  | ||||
|                 selectedItems.forEach { | ||||
|                     fileDirItems.add(FileDirItem(it.path, it.name)) | ||||
|                     removeMedia.add(it) | ||||
|                 selectedItems.forEach { medium -> | ||||
|                     fileDirItems.add(medium.toFileDirItem()) | ||||
|                     removeMedia.add(medium) | ||||
|                 } | ||||
|  | ||||
|                 media.removeAll(removeMedia) | ||||
|   | ||||
| @@ -8,6 +8,7 @@ import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED | ||||
| import com.simplemobiletools.commons.helpers.SORT_BY_NAME | ||||
| import com.simplemobiletools.commons.helpers.SORT_BY_PATH | ||||
| import com.simplemobiletools.commons.helpers.SORT_BY_SIZE | ||||
| import com.simplemobiletools.commons.models.FileDirItem | ||||
| import com.simplemobiletools.gallery.pro.helpers.* | ||||
| import java.io.File | ||||
| import java.io.Serializable | ||||
| @@ -107,4 +108,6 @@ data class Medium( | ||||
|     } | ||||
|  | ||||
|     fun getKey() = ObjectKey(getSignature()) | ||||
|  | ||||
|     fun toFileDirItem() = FileDirItem(path, name, false, 0, size, modified, mediaStoreId) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user