try getting the mediastore last_modified field at extended details, if available
This commit is contained in:
parent
2ca309e60f
commit
05b5a4282e
1 changed files with 19 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
package com.simplemobiletools.gallery.pro.fragments
|
package com.simplemobiletools.gallery.pro.fragments
|
||||||
|
|
||||||
|
import android.provider.MediaStore
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
|
@ -56,7 +57,7 @@ abstract class ViewPagerFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (detailsFlag and EXT_LAST_MODIFIED != 0) {
|
if (detailsFlag and EXT_LAST_MODIFIED != 0) {
|
||||||
file.lastModified().formatDate().let { if (it.isNotEmpty()) details.appendln(it) }
|
getFileLastModified(file).let { if (it.isNotEmpty()) details.appendln(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (detailsFlag and EXT_DATE_TAKEN != 0) {
|
if (detailsFlag and EXT_DATE_TAKEN != 0) {
|
||||||
|
@ -75,6 +76,23 @@ abstract class ViewPagerFragment : Fragment() {
|
||||||
|
|
||||||
fun getPathToLoad(medium: Medium) = if (medium.path.startsWith(OTG_PATH)) medium.path.getOTGPublicPath(context!!) else medium.path
|
fun getPathToLoad(medium: Medium) = if (medium.path.startsWith(OTG_PATH)) medium.path.getOTGPublicPath(context!!) else medium.path
|
||||||
|
|
||||||
|
private fun getFileLastModified(file: File): String {
|
||||||
|
val projection = arrayOf(MediaStore.Images.Media.DATE_MODIFIED)
|
||||||
|
val uri = MediaStore.Files.getContentUri("external")
|
||||||
|
val selection = "${MediaStore.MediaColumns.DATA} = ?"
|
||||||
|
val selectionArgs = arrayOf(file.absolutePath)
|
||||||
|
val cursor = context!!.contentResolver.query(uri, projection, selection, selectionArgs, null)
|
||||||
|
cursor?.use {
|
||||||
|
return if (cursor.moveToFirst()) {
|
||||||
|
val dateModified = cursor.getLongValue(MediaStore.Images.Media.DATE_MODIFIED) * 1000L
|
||||||
|
dateModified.formatDate()
|
||||||
|
} else {
|
||||||
|
file.lastModified().formatDate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
protected fun handleEvent(event: MotionEvent) {
|
protected fun handleEvent(event: MotionEvent) {
|
||||||
when (event.actionMasked) {
|
when (event.actionMasked) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
|
|
Loading…
Reference in a new issue