Skip to content

Commit dcb6071

Browse files
authored
fix android file props (#21307)
1 parent 1365b64 commit dcb6071

1 file changed

Lines changed: 4 additions & 20 deletions

File tree

src/Android/Avalonia.Android/Platform/Storage/AndroidStorageItem.cs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -546,16 +546,15 @@ public override Task<StorageItemProperties> GetBasicPropertiesAsync()
546546
{
547547
var projection = new[]
548548
{
549-
MediaStore.IMediaColumns.Size, MediaStore.IMediaColumns.DateAdded,
550-
MediaStore.IMediaColumns.DateModified
549+
Document.ColumnSize, Document.ColumnLastModified
551550
};
552551
using var cursor = Activity.ContentResolver!.Query(Uri, projection, null, null, null);
553552

554553
if (cursor?.MoveToFirst() == true)
555554
{
556555
try
557556
{
558-
var columnIndex = cursor.GetColumnIndex(MediaStore.IMediaColumns.Size);
557+
var columnIndex = cursor.GetColumnIndex(Document.ColumnSize);
559558
if (columnIndex != -1)
560559
{
561560
size = (ulong)cursor.GetLong(columnIndex);
@@ -569,22 +568,7 @@ public override Task<StorageItemProperties> GetBasicPropertiesAsync()
569568

570569
try
571570
{
572-
var columnIndex = cursor.GetColumnIndex(MediaStore.IMediaColumns.DateAdded);
573-
if (columnIndex != -1)
574-
{
575-
var longValue = cursor.GetLong(columnIndex);
576-
itemDate = longValue > 0 ? DateTimeOffset.FromUnixTimeMilliseconds(longValue) : null;
577-
}
578-
}
579-
catch (Exception ex)
580-
{
581-
Logger.TryGet(LogEventLevel.Verbose, LogArea.AndroidPlatform)?
582-
.Log(this, "File DateAdded metadata reader failed: '{Exception}'", ex);
583-
}
584-
585-
try
586-
{
587-
var columnIndex = cursor.GetColumnIndex(MediaStore.IMediaColumns.DateModified);
571+
var columnIndex = cursor.GetColumnIndex(Document.ColumnLastModified);
588572
if (columnIndex != -1)
589573
{
590574
var longValue = cursor.GetLong(columnIndex);
@@ -594,7 +578,7 @@ public override Task<StorageItemProperties> GetBasicPropertiesAsync()
594578
catch (Exception ex)
595579
{
596580
Logger.TryGet(LogEventLevel.Verbose, LogArea.AndroidPlatform)?
597-
.Log(this, "File DateAdded metadata reader failed: '{Exception}'", ex);
581+
.Log(this, "File LastModified metadata reader failed: '{Exception}'", ex);
598582
}
599583
}
600584
}

0 commit comments

Comments
 (0)