feat(mobile): sync local asset width & height from platform (#18994)

* add width and height to sqlite entities

* sync width & height from platform

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
shenlong
2025-06-09 08:20:54 +05:30
committed by GitHub
parent e376366b7b
commit 75c24f0023
12 changed files with 267 additions and 12 deletions
@@ -85,6 +85,8 @@ data class PlatformAsset (
val type: Long,
val createdAt: Long? = null,
val updatedAt: Long? = null,
val width: Long? = null,
val height: Long? = null,
val durationInSeconds: Long
)
{
@@ -95,8 +97,10 @@ data class PlatformAsset (
val type = pigeonVar_list[2] as Long
val createdAt = pigeonVar_list[3] as Long?
val updatedAt = pigeonVar_list[4] as Long?
val durationInSeconds = pigeonVar_list[5] as Long
return PlatformAsset(id, name, type, createdAt, updatedAt, durationInSeconds)
val width = pigeonVar_list[5] as Long?
val height = pigeonVar_list[6] as Long?
val durationInSeconds = pigeonVar_list[7] as Long
return PlatformAsset(id, name, type, createdAt, updatedAt, width, height, durationInSeconds)
}
}
fun toList(): List<Any?> {
@@ -106,6 +110,8 @@ data class PlatformAsset (
type,
createdAt,
updatedAt,
width,
height,
durationInSeconds,
)
}
@@ -37,6 +37,8 @@ open class NativeSyncApiImplBase(context: Context) {
MediaStore.MediaColumns.DATE_MODIFIED,
MediaStore.Files.FileColumns.MEDIA_TYPE,
MediaStore.MediaColumns.BUCKET_ID,
MediaStore.MediaColumns.WIDTH,
MediaStore.MediaColumns.HEIGHT,
MediaStore.MediaColumns.DURATION
)
@@ -68,6 +70,8 @@ open class NativeSyncApiImplBase(context: Context) {
val dateModifiedColumn = c.getColumnIndexOrThrow(MediaStore.MediaColumns.DATE_MODIFIED)
val mediaTypeColumn = c.getColumnIndexOrThrow(MediaStore.Files.FileColumns.MEDIA_TYPE)
val bucketIdColumn = c.getColumnIndexOrThrow(MediaStore.MediaColumns.BUCKET_ID)
val widthColumn = c.getColumnIndexOrThrow(MediaStore.MediaColumns.WIDTH)
val heightColumn = c.getColumnIndexOrThrow(MediaStore.MediaColumns.HEIGHT)
val durationColumn = c.getColumnIndexOrThrow(MediaStore.MediaColumns.DURATION)
while (c.moveToNext()) {
@@ -86,12 +90,23 @@ open class NativeSyncApiImplBase(context: Context) {
?: c.getLong(dateAddedColumn)
// Date modified is seconds since epoch
val modifiedAt = c.getLong(dateModifiedColumn)
val width = c.getInt(widthColumn).toLong()
val height = c.getInt(heightColumn).toLong()
// Duration is milliseconds
val duration = if (mediaType == MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE) 0
else c.getLong(durationColumn) / 1000
val bucketId = c.getString(bucketIdColumn)
val asset = PlatformAsset(id, name, mediaType.toLong(), createdAt, modifiedAt, duration)
val asset = PlatformAsset(
id,
name,
mediaType.toLong(),
createdAt,
modifiedAt,
width,
height,
duration
)
yield(AssetResult.ValidAsset(asset, bucketId))
}
}