properly set the Last Modified field at FileDirItems, when needed

This commit is contained in:
tibbi 2019-06-14 15:03:29 +02:00
parent 7dc802bad5
commit 020f12e97c
7 changed files with 8 additions and 9 deletions

View file

@ -7,7 +7,7 @@ buildscript {
propMinSdkVersion = 21
propTargetSdkVersion = propCompileSdkVersion
propVersionCode = 1
propVersionName = '5.13.12'
propVersionName = '5.13.13'
kotlin_version = '1.3.31'
}

View file

@ -188,7 +188,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal
}
val oldFile = File(source.path, child)
val oldFileDirItem = oldFile.toFileDirItem(activity.applicationContext)
val oldFileDirItem = oldFile.toFileDirItem()
val newFileDirItem = FileDirItem(newPath, newPath.getFilenameFromPath(), oldFile.isDirectory)
copy(oldFileDirItem, newFileDirItem)
}

View file

@ -43,7 +43,7 @@ class PropertiesDialog() {
val view = mInflater.inflate(R.layout.dialog_properties, null)
mPropertyView = view.properties_holder
val fileDirItem = FileDirItem(path, path.getFilenameFromPath(), File(path).isDirectory)
val fileDirItem = FileDirItem(path, path.getFilenameFromPath(), File(path).isDirectory, 0, 0, File(path).lastModified())
addProperty(R.string.name, fileDirItem.name)
addProperty(R.string.path, fileDirItem.getParentPath())
addProperty(R.string.size, "", R.id.properties_size)
@ -138,7 +138,7 @@ class PropertiesDialog() {
val fileDirItems = ArrayList<FileDirItem>(paths.size)
paths.forEach {
val fileDirItem = FileDirItem(it, it.getFilenameFromPath(), File(it).isDirectory)
val fileDirItem = FileDirItem(it, it.getFilenameFromPath(), File(it).isDirectory, 0, 0, File(it).lastModified())
fileDirItems.add(fileDirItem)
}

View file

@ -423,7 +423,7 @@ fun BaseSimpleActivity.deleteFolderBg(fileDirItem: FileDirItem, deleteMediaOnly:
val files = filesArr.toMutableList().filter { !deleteMediaOnly || it.isMediaFile() }
for (file in files) {
deleteFileBg(file.toFileDirItem(applicationContext), false) { }
deleteFileBg(file.toFileDirItem(), false) { }
}
if (folder.listFiles()?.isEmpty() == true) {

View file

@ -379,7 +379,7 @@ fun Context.getOTGItems(path: String, shouldShowHidden: Boolean, getProperFileSi
0
}
val fileDirItem = FileDirItem(decodedPath, name!!, isDirectory, childrenCount, fileSize)
val fileDirItem = FileDirItem(decodedPath, name!!, isDirectory, childrenCount, fileSize, file.lastModified())
items.add(fileDirItem)
}

View file

@ -1,6 +1,5 @@
package com.simplemobiletools.commons.extensions
import android.content.Context
import com.simplemobiletools.commons.helpers.audioExtensions
import com.simplemobiletools.commons.helpers.photoExtensions
import com.simplemobiletools.commons.helpers.rawExtensions
@ -77,4 +76,4 @@ private fun getDirectoryFileCount(dir: File, countHiddenItems: Boolean): Int {
fun File.getDirectChildrenCount(countHiddenItems: Boolean) = listFiles()?.filter { if (countHiddenItems) true else !it.isHidden }?.size ?: 0
fun File.toFileDirItem(context: Context) = FileDirItem(absolutePath, name, File(absolutePath).isDirectory, 0, length())
fun File.toFileDirItem() = FileDirItem(absolutePath, name, File(absolutePath).isDirectory, 0, length(), lastModified())

View file

@ -102,7 +102,7 @@ class Breadcrumbs(context: Context, attrs: AttributeSet) : LinearLayout(context,
}
currPath = "${currPath.trimEnd('/')}/"
val item = FileDirItem(currPath, dir, true, 0, 0)
val item = FileDirItem(currPath, dir, true, 0, 0, 0)
addBreadcrumb(item, i > 0)
}
}