Fix MediaStore DATE_ADDED/DATE_MODIFIED
They are in seconds not milliseconds as per the documentation.
This commit is contained in:
1 parent
1a53d0d207
commit
843e1cc6a0
3 files changed
+5
-4
No files matched your search
@@ -97,7 +97,7 @@ suspend fun save(page: ReaderPage) {
|
||||
val values = ContentValues()
|
||||
val realPath: String
|
||||
values.put(MediaStore.MediaColumns.DISPLAY_NAME, filename)
|
||||
values.put(MediaStore.Images.Media.DATE_ADDED, Clock.System.now().toEpochMilliseconds())
|
||||
values.put(MediaStore.MediaColumns.DATE_ADDED, Clock.System.now().epochSeconds)
|
||||
values.put(MediaStore.MediaColumns.MIME_TYPE, mimeType)
|
||||
if (isAtLeastQ) {
|
||||
realPath = Environment.DIRECTORY_PICTURES + File.separator + AppConfig.APP_DIRNAME
|
||||
|
||||
@@ -127,7 +127,8 @@ class AndroidFileSystem(context: Context) : FileSystem() {
|
||||
}
|
||||
|
||||
val uri = path.toUri()
|
||||
val projection = if (uri.authority == MediaStore.AUTHORITY) {
|
||||
val isMediaUri = uri.authority == MediaStore.AUTHORITY
|
||||
val projection = if (isMediaUri) {
|
||||
arrayOf(MediaStore.MediaColumns.MIME_TYPE, MediaStore.MediaColumns.DATE_MODIFIED)
|
||||
} else {
|
||||
arrayOf(Document.COLUMN_MIME_TYPE, Document.COLUMN_LAST_MODIFIED)
|
||||
@@ -138,7 +139,7 @@ class AndroidFileSystem(context: Context) : FileSystem() {
|
||||
if (!c.moveToNext()) return null
|
||||
|
||||
val mimeType = c.getString(0)
|
||||
val lastModified = c.getLongOrNull(1)
|
||||
val lastModified = c.getLongOrNull(1)?.let { if (isMediaUri) it * 1000 else it }
|
||||
val isDirectory = mimeType == Document.MIME_TYPE_DIR
|
||||
|
||||
FileMetadata(
|
||||
|
||||
@@ -433,7 +433,7 @@ class ReaderActivity : EhActivity() {
|
||||
val resolver = contentResolver
|
||||
val values = ContentValues()
|
||||
values.put(MediaStore.MediaColumns.DISPLAY_NAME, filename)
|
||||
values.put(MediaStore.Images.Media.DATE_ADDED, Clock.System.now().toEpochMilliseconds())
|
||||
values.put(MediaStore.MediaColumns.DATE_ADDED, Clock.System.now().epochSeconds)
|
||||
values.put(MediaStore.MediaColumns.MIME_TYPE, mimeType)
|
||||
if (isAtLeastQ) {
|
||||
realPath = Environment.DIRECTORY_PICTURES + File.separator + AppConfig.APP_DIRNAME
|
||||
|
||||
Reference in new issue
Block a user