diff --git a/mobile/android/app/src/main/kotlin/app/alextran/immich/sync/Messages.g.kt b/mobile/android/app/src/main/kotlin/app/alextran/immich/sync/Messages.g.kt index 18a788903..6ae4c99bd 100644 --- a/mobile/android/app/src/main/kotlin/app/alextran/immich/sync/Messages.g.kt +++ b/mobile/android/app/src/main/kotlin/app/alextran/immich/sync/Messages.g.kt @@ -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 { @@ -106,6 +110,8 @@ data class PlatformAsset ( type, createdAt, updatedAt, + width, + height, durationInSeconds, ) } diff --git a/mobile/android/app/src/main/kotlin/app/alextran/immich/sync/MessagesImplBase.kt b/mobile/android/app/src/main/kotlin/app/alextran/immich/sync/MessagesImplBase.kt index 70fc045d5..7f8ad531b 100644 --- a/mobile/android/app/src/main/kotlin/app/alextran/immich/sync/MessagesImplBase.kt +++ b/mobile/android/app/src/main/kotlin/app/alextran/immich/sync/MessagesImplBase.kt @@ -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)) } } diff --git a/mobile/drift_schemas/main/drift_schema_v1.json b/mobile/drift_schemas/main/drift_schema_v1.json index ee8e41aea..0d147b9b2 100644 Binary files a/mobile/drift_schemas/main/drift_schema_v1.json and b/mobile/drift_schemas/main/drift_schema_v1.json differ diff --git a/mobile/ios/Runner/Sync/Messages.g.swift b/mobile/ios/Runner/Sync/Messages.g.swift index eb765337c..89eb092a1 100644 --- a/mobile/ios/Runner/Sync/Messages.g.swift +++ b/mobile/ios/Runner/Sync/Messages.g.swift @@ -135,6 +135,8 @@ struct PlatformAsset: Hashable { var type: Int64 var createdAt: Int64? = nil var updatedAt: Int64? = nil + var width: Int64? = nil + var height: Int64? = nil var durationInSeconds: Int64 @@ -145,7 +147,9 @@ struct PlatformAsset: Hashable { let type = pigeonVar_list[2] as! Int64 let createdAt: Int64? = nilOrValue(pigeonVar_list[3]) let updatedAt: Int64? = nilOrValue(pigeonVar_list[4]) - let durationInSeconds = pigeonVar_list[5] as! Int64 + let width: Int64? = nilOrValue(pigeonVar_list[5]) + let height: Int64? = nilOrValue(pigeonVar_list[6]) + let durationInSeconds = pigeonVar_list[7] as! Int64 return PlatformAsset( id: id, @@ -153,6 +157,8 @@ struct PlatformAsset: Hashable { type: type, createdAt: createdAt, updatedAt: updatedAt, + width: width, + height: height, durationInSeconds: durationInSeconds ) } @@ -163,6 +169,8 @@ struct PlatformAsset: Hashable { type, createdAt, updatedAt, + width, + height, durationInSeconds, ] } diff --git a/mobile/ios/Runner/Sync/MessagesImpl.swift b/mobile/ios/Runner/Sync/MessagesImpl.swift index 06c958b88..700162996 100644 --- a/mobile/ios/Runner/Sync/MessagesImpl.swift +++ b/mobile/ios/Runner/Sync/MessagesImpl.swift @@ -25,7 +25,9 @@ extension PHAsset { type: Int64(mediaType.rawValue), createdAt: creationDate.map { Int64($0.timeIntervalSince1970) }, updatedAt: modificationDate.map { Int64($0.timeIntervalSince1970) }, - durationInSeconds: Int64(duration) + width: Int64(pixelWidth), + height: Int64(pixelHeight), + durationInSeconds: Int64(duration), ) } } @@ -156,8 +158,6 @@ class NativeSyncApiImpl: NativeSyncApi { id: asset.localIdentifier, name: "", type: 0, - createdAt: nil, - updatedAt: nil, durationInSeconds: 0 ) if (updatedAssets.contains(AssetWrapper(with: predicate))) { diff --git a/mobile/lib/domain/services/local_sync.service.dart b/mobile/lib/domain/services/local_sync.service.dart index e39999f22..037179c96 100644 --- a/mobile/lib/domain/services/local_sync.service.dart +++ b/mobile/lib/domain/services/local_sync.service.dart @@ -373,6 +373,8 @@ extension on Iterable { updatedAt: e.updatedAt == null ? DateTime.now() : DateTime.fromMillisecondsSinceEpoch(e.updatedAt! * 1000), + width: e.width, + height: e.height, durationInSeconds: e.durationInSeconds, ), ).toList(); diff --git a/mobile/lib/infrastructure/entities/local_asset.entity.drift.dart b/mobile/lib/infrastructure/entities/local_asset.entity.drift.dart index 68bc1b3c5..a3c79b2e2 100644 Binary files a/mobile/lib/infrastructure/entities/local_asset.entity.drift.dart and b/mobile/lib/infrastructure/entities/local_asset.entity.drift.dart differ diff --git a/mobile/lib/infrastructure/entities/remote_asset.entity.drift.dart b/mobile/lib/infrastructure/entities/remote_asset.entity.drift.dart index e3fe52170..c244b5a09 100644 Binary files a/mobile/lib/infrastructure/entities/remote_asset.entity.drift.dart and b/mobile/lib/infrastructure/entities/remote_asset.entity.drift.dart differ diff --git a/mobile/lib/infrastructure/repositories/local_album.repository.dart b/mobile/lib/infrastructure/repositories/local_album.repository.dart index 5100b7a19..075b6e180 100644 --- a/mobile/lib/infrastructure/repositories/local_album.repository.dart +++ b/mobile/lib/infrastructure/repositories/local_album.repository.dart @@ -272,7 +272,9 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository type: asset.type, createdAt: Value(asset.createdAt), updatedAt: Value(asset.updatedAt), - durationInSeconds: Value.absentIfNull(asset.durationInSeconds), + width: Value(asset.width), + height: Value(asset.height), + durationInSeconds: Value(asset.durationInSeconds), id: asset.id, checksum: const Value(null), ); diff --git a/mobile/lib/infrastructure/utils/asset.mixin.dart b/mobile/lib/infrastructure/utils/asset.mixin.dart index 864955082..4e14a2919 100644 --- a/mobile/lib/infrastructure/utils/asset.mixin.dart +++ b/mobile/lib/infrastructure/utils/asset.mixin.dart @@ -6,5 +6,7 @@ mixin AssetEntityMixin on Table { IntColumn get type => intEnum()(); DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)(); DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)(); + IntColumn get width => integer().nullable()(); + IntColumn get height => integer().nullable()(); IntColumn get durationInSeconds => integer().nullable()(); } diff --git a/mobile/lib/platform/native_sync_api.g.dart b/mobile/lib/platform/native_sync_api.g.dart index ffcef6796..dd6e545f8 100644 Binary files a/mobile/lib/platform/native_sync_api.g.dart and b/mobile/lib/platform/native_sync_api.g.dart differ diff --git a/mobile/pigeon/native_sync_api.dart b/mobile/pigeon/native_sync_api.dart index 9bcb816a6..33e242940 100644 --- a/mobile/pigeon/native_sync_api.dart +++ b/mobile/pigeon/native_sync_api.dart @@ -20,6 +20,8 @@ class PlatformAsset { // Seconds since epoch final int? createdAt; final int? updatedAt; + final int? width; + final int? height; final int durationInSeconds; const PlatformAsset({ @@ -28,6 +30,8 @@ class PlatformAsset { required this.type, this.createdAt, this.updatedAt, + this.width, + this.height, this.durationInSeconds = 0, }); }