mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
properly handle Date Taken value at file copy/move
This commit is contained in:
parent
7f73b9259e
commit
1030021ca1
5 changed files with 25 additions and 8 deletions
|
@ -62,7 +62,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:5.17.9'
|
||||
implementation 'com.simplemobiletools:commons:5.17.12'
|
||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
||||
implementation 'androidx.multidex:multidex:2.0.1'
|
||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||
|
|
|
@ -576,7 +576,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
|
||||
val fileDirItems = arrayListOf(FileDirItem(currPath, currPath.getFilenameFromPath()))
|
||||
tryCopyMoveFilesTo(fileDirItems, isCopyOperation) {
|
||||
fixDateTaken(arrayListOf(currPath), false)
|
||||
val newPath = "$it/${currPath.getFilenameFromPath()}"
|
||||
rescanPaths(arrayListOf(newPath)) {
|
||||
fixDateTaken(arrayListOf(newPath), false)
|
||||
}
|
||||
|
||||
config.tempFolderPath = ""
|
||||
if (!isCopyOperation) {
|
||||
refreshViewPager()
|
||||
|
|
|
@ -442,7 +442,12 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
|
||||
val fileDirItems = paths.map { FileDirItem(it, it.getFilenameFromPath()) } as ArrayList<FileDirItem>
|
||||
activity.tryCopyMoveFilesTo(fileDirItems, isCopyOperation) {
|
||||
activity.fixDateTaken(paths, false)
|
||||
val destinationPath = it
|
||||
val newPaths = fileDirItems.map { "$destinationPath/${it.name}" }.toMutableList() as java.util.ArrayList<String>
|
||||
activity.rescanPaths(newPaths) {
|
||||
activity.fixDateTaken(newPaths, false)
|
||||
}
|
||||
|
||||
config.tempFolderPath = ""
|
||||
listener?.refreshItems()
|
||||
finishActMode()
|
||||
|
|
|
@ -326,13 +326,18 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
|||
}
|
||||
|
||||
activity.tryCopyMoveFilesTo(fileDirItems, isCopyOperation) {
|
||||
val destinationPath = it
|
||||
config.tempFolderPath = ""
|
||||
activity.applicationContext.rescanFolderMedia(it)
|
||||
activity.applicationContext.rescanFolderMedia(destinationPath)
|
||||
activity.applicationContext.rescanFolderMedia(fileDirItems.first().getParentPath())
|
||||
activity.fixDateTaken(paths, false)
|
||||
|
||||
val newPaths = fileDirItems.map { "$destinationPath/${it.name}" }.toMutableList() as ArrayList<String>
|
||||
activity.rescanPaths(newPaths) {
|
||||
activity.fixDateTaken(newPaths, false)
|
||||
}
|
||||
if (!isCopyOperation) {
|
||||
listener?.refreshItems()
|
||||
activity.updateFavoritePaths(fileDirItems, it)
|
||||
activity.updateFavoritePaths(fileDirItems, destinationPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -292,7 +292,9 @@ fun BaseSimpleActivity.restoreRecycleBinPaths(paths: ArrayList<String>, mediumDa
|
|||
callback()
|
||||
}
|
||||
|
||||
fixDateTaken(newPaths, false)
|
||||
rescanPaths(newPaths) {
|
||||
fixDateTaken(newPaths, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -356,7 +358,8 @@ fun Activity.fixDateTaken(paths: ArrayList<String>, showToasts: Boolean, callbac
|
|||
var didUpdateFile = false
|
||||
val operations = ArrayList<ContentProviderOperation>()
|
||||
val mediumDao = galleryDB.MediumDao()
|
||||
rescanPaths(paths) {
|
||||
|
||||
ensureBackgroundThread {
|
||||
for (path in paths) {
|
||||
val dateTime = ExifInterface(path).getAttribute(ExifInterface.TAG_DATETIME_ORIGINAL)
|
||||
?: ExifInterface(path).getAttribute(ExifInterface.TAG_DATETIME) ?: continue
|
||||
|
|
Loading…
Reference in a new issue