Glimpse: Add width and height to media
Change-Id: Id953c37950ef647e9f5d56d364eed91328c0d613
This commit is contained in:
parent
5b74dfead9
commit
3d41b82fc7
|
@ -60,6 +60,8 @@ class AlbumsFlow(private val context: Context) : QueryFlow<Album>() {
|
||||||
val dateAddedIndex = it.getColumnIndex(MediaStore.Files.FileColumns.DATE_ADDED)
|
val dateAddedIndex = it.getColumnIndex(MediaStore.Files.FileColumns.DATE_ADDED)
|
||||||
val dateModifiedIndex =
|
val dateModifiedIndex =
|
||||||
it.getColumnIndex(MediaStore.Files.FileColumns.DATE_MODIFIED)
|
it.getColumnIndex(MediaStore.Files.FileColumns.DATE_MODIFIED)
|
||||||
|
val widthIndex = it.getColumnIndex(MediaStore.Files.FileColumns.WIDTH)
|
||||||
|
val heightIndex = it.getColumnIndex(MediaStore.Files.FileColumns.HEIGHT)
|
||||||
val orientationIndex =
|
val orientationIndex =
|
||||||
it.getColumnIndex(MediaStore.Files.FileColumns.ORIENTATION)
|
it.getColumnIndex(MediaStore.Files.FileColumns.ORIENTATION)
|
||||||
val bucketDisplayNameIndex =
|
val bucketDisplayNameIndex =
|
||||||
|
@ -94,6 +96,8 @@ class AlbumsFlow(private val context: Context) : QueryFlow<Album>() {
|
||||||
val mimeType = it.getString(mimeTypeIndex)
|
val mimeType = it.getString(mimeTypeIndex)
|
||||||
val dateAdded = it.getLong(dateAddedIndex)
|
val dateAdded = it.getLong(dateAddedIndex)
|
||||||
val dateModified = it.getLong(dateModifiedIndex)
|
val dateModified = it.getLong(dateModifiedIndex)
|
||||||
|
val width = it.getInt(widthIndex)
|
||||||
|
val height = it.getInt(heightIndex)
|
||||||
val orientation = it.getInt(orientationIndex)
|
val orientation = it.getInt(orientationIndex)
|
||||||
val bucketDisplayName = it.getString(bucketDisplayNameIndex)
|
val bucketDisplayName = it.getString(bucketDisplayNameIndex)
|
||||||
|
|
||||||
|
@ -120,6 +124,8 @@ class AlbumsFlow(private val context: Context) : QueryFlow<Album>() {
|
||||||
mimeType,
|
mimeType,
|
||||||
dateAdded,
|
dateAdded,
|
||||||
dateModified,
|
dateModified,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
orientation,
|
orientation,
|
||||||
)
|
)
|
||||||
).apply { size += 1 }
|
).apply { size += 1 }
|
||||||
|
|
|
@ -77,6 +77,8 @@ class MediaFlow(private val context: Context, private val bucketId: Int?) : Quer
|
||||||
val mimeTypeIndex = it.getColumnIndex(MediaStore.Files.FileColumns.MIME_TYPE)
|
val mimeTypeIndex = it.getColumnIndex(MediaStore.Files.FileColumns.MIME_TYPE)
|
||||||
val dateAddedIndex = it.getColumnIndex(MediaStore.Files.FileColumns.DATE_ADDED)
|
val dateAddedIndex = it.getColumnIndex(MediaStore.Files.FileColumns.DATE_ADDED)
|
||||||
val dateModifiedIndex = it.getColumnIndex(MediaStore.Files.FileColumns.DATE_MODIFIED)
|
val dateModifiedIndex = it.getColumnIndex(MediaStore.Files.FileColumns.DATE_MODIFIED)
|
||||||
|
val widthIndex = it.getColumnIndex(MediaStore.Files.FileColumns.WIDTH)
|
||||||
|
val heightIndex = it.getColumnIndex(MediaStore.Files.FileColumns.HEIGHT)
|
||||||
val orientationIndex = it.getColumnIndex(MediaStore.Files.FileColumns.ORIENTATION)
|
val orientationIndex = it.getColumnIndex(MediaStore.Files.FileColumns.ORIENTATION)
|
||||||
|
|
||||||
val id = it.getLong(idIndex)
|
val id = it.getLong(idIndex)
|
||||||
|
@ -88,6 +90,8 @@ class MediaFlow(private val context: Context, private val bucketId: Int?) : Quer
|
||||||
val mimeType = it.getString(mimeTypeIndex)
|
val mimeType = it.getString(mimeTypeIndex)
|
||||||
val dateAdded = it.getLong(dateAddedIndex)
|
val dateAdded = it.getLong(dateAddedIndex)
|
||||||
val dateModified = it.getLong(dateModifiedIndex)
|
val dateModified = it.getLong(dateModifiedIndex)
|
||||||
|
val width = it.getInt(widthIndex)
|
||||||
|
val height = it.getInt(heightIndex)
|
||||||
val orientation = it.getInt(orientationIndex)
|
val orientation = it.getInt(orientationIndex)
|
||||||
|
|
||||||
Media.fromMediaStore(
|
Media.fromMediaStore(
|
||||||
|
@ -100,6 +104,8 @@ class MediaFlow(private val context: Context, private val bucketId: Int?) : Quer
|
||||||
mimeType,
|
mimeType,
|
||||||
dateAdded,
|
dateAdded,
|
||||||
dateModified,
|
dateModified,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
orientation,
|
orientation,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ data class Media(
|
||||||
val mimeType: String,
|
val mimeType: String,
|
||||||
val dateAdded: Date,
|
val dateAdded: Date,
|
||||||
val dateModified: Date,
|
val dateModified: Date,
|
||||||
|
val width: Int,
|
||||||
|
val height: Int,
|
||||||
val orientation: Int,
|
val orientation: Int,
|
||||||
) : Comparable<Media>, Parcelable {
|
) : Comparable<Media>, Parcelable {
|
||||||
val externalContentUri = ContentUris.withAppendedId(mediaType.externalContentUri, id)
|
val externalContentUri = ContentUris.withAppendedId(mediaType.externalContentUri, id)
|
||||||
|
@ -40,6 +42,8 @@ data class Media(
|
||||||
Date(parcel.readLong()),
|
Date(parcel.readLong()),
|
||||||
Date(parcel.readLong()),
|
Date(parcel.readLong()),
|
||||||
parcel.readInt(),
|
parcel.readInt(),
|
||||||
|
parcel.readInt(),
|
||||||
|
parcel.readInt(),
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
|
@ -59,6 +63,8 @@ data class Media(
|
||||||
{ it.mimeType },
|
{ it.mimeType },
|
||||||
{ it.dateAdded },
|
{ it.dateAdded },
|
||||||
{ it.dateModified },
|
{ it.dateModified },
|
||||||
|
{ it.width },
|
||||||
|
{ it.height },
|
||||||
{ it.orientation },
|
{ it.orientation },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -74,6 +80,8 @@ data class Media(
|
||||||
dest.writeString(mimeType)
|
dest.writeString(mimeType)
|
||||||
dest.writeLong(dateAdded.time)
|
dest.writeLong(dateAdded.time)
|
||||||
dest.writeLong(dateModified.time)
|
dest.writeLong(dateModified.time)
|
||||||
|
dest.writeInt(width)
|
||||||
|
dest.writeInt(height)
|
||||||
dest.writeInt(orientation)
|
dest.writeInt(orientation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +100,8 @@ data class Media(
|
||||||
mimeType: String,
|
mimeType: String,
|
||||||
dateAdded: Long,
|
dateAdded: Long,
|
||||||
dateModified: Long,
|
dateModified: Long,
|
||||||
|
width: Int,
|
||||||
|
height: Int,
|
||||||
orientation: Int,
|
orientation: Int,
|
||||||
) = Media(
|
) = Media(
|
||||||
id,
|
id,
|
||||||
|
@ -103,6 +113,8 @@ data class Media(
|
||||||
mimeType,
|
mimeType,
|
||||||
Date(dateAdded * 1000),
|
Date(dateAdded * 1000),
|
||||||
Date(dateModified * 1000),
|
Date(dateModified * 1000),
|
||||||
|
width,
|
||||||
|
height,
|
||||||
orientation,
|
orientation,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ object MediaQuery {
|
||||||
MediaStore.Files.FileColumns.MIME_TYPE,
|
MediaStore.Files.FileColumns.MIME_TYPE,
|
||||||
MediaStore.Files.FileColumns.DATE_ADDED,
|
MediaStore.Files.FileColumns.DATE_ADDED,
|
||||||
MediaStore.Files.FileColumns.DATE_MODIFIED,
|
MediaStore.Files.FileColumns.DATE_MODIFIED,
|
||||||
|
MediaStore.Files.FileColumns.WIDTH,
|
||||||
|
MediaStore.Files.FileColumns.HEIGHT,
|
||||||
MediaStore.Files.FileColumns.ORIENTATION,
|
MediaStore.Files.FileColumns.ORIENTATION,
|
||||||
)
|
)
|
||||||
val AlbumsProjection = arrayOf(
|
val AlbumsProjection = arrayOf(
|
||||||
|
|
Loading…
Reference in New Issue