File tree Expand file tree Collapse file tree 4 files changed +9
-1
lines changed
app/src/main/java/org/lineageos/glimpse Expand file tree Collapse file tree 4 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ class LocalDataSource(
8585 val width = columnIndexCache.getInt(MediaStore .Files .FileColumns .WIDTH )
8686 val height = columnIndexCache.getInt(MediaStore .Files .FileColumns .HEIGHT )
8787 val orientation = columnIndexCache.getInt(MediaStore .Files .FileColumns .ORIENTATION )
88+ val size = columnIndexCache.getLong(MediaStore .Files .FileColumns .SIZE )
8889
8990 val typedMediaType = when (mediaType) {
9091 MediaStore .Files .FileColumns .MEDIA_TYPE_IMAGE -> MediaType .IMAGE
@@ -113,6 +114,7 @@ class LocalDataSource(
113114 width,
114115 height,
115116 orientation,
117+ size,
116118 )
117119 }
118120
@@ -317,6 +319,7 @@ class LocalDataSource(
317319 MediaStore .Files .FileColumns .WIDTH ,
318320 MediaStore .Files .FileColumns .HEIGHT ,
319321 MediaStore .Files .FileColumns .ORIENTATION ,
322+ MediaStore .Files .FileColumns .SIZE ,
320323 )
321324
322325 private val isImage =
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import java.util.Date
2424 * @param width The width of the item
2525 * @param height The height of the item
2626 * @param orientation The orientation of the item
27+ * @param sizeBytes The size of the item in bytes
2728 */
2829@Parcelize
2930data class Media (
@@ -40,6 +41,7 @@ data class Media(
4041 val width : Int ,
4142 val height : Int ,
4243 val orientation : Int ,
44+ val sizeBytes : Long ,
4345) : MediaItem<Media>, Parcelable {
4446 init {
4547 require(mediaType in allowedMediaTypes) {
@@ -61,6 +63,7 @@ data class Media(
6163 Media ::width,
6264 Media ::height,
6365 Media ::orientation,
66+ Media ::sizeBytes,
6467 ) == 0
6568
6669 companion object {
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import android.location.Geocoder
1313import android.net.Uri
1414import android.os.Build
1515import android.text.InputType
16+ import android.text.format.Formatter
1617import android.view.View
1718import android.view.ViewGroup
1819import android.widget.EditText
@@ -165,8 +166,8 @@ class MediaInfoBottomSheetDialog(
165166
166167 mediaInfoListItem.supportingText = listOf (
167168 media.mimeType,
168- " ${((media.width.toDouble() * media.height) / 1024000 ).round(1 )} MP" ,
169169 " ${media.width} x ${media.height} " ,
170+ Formatter .formatFileSize(context, media.sizeBytes),
170171 ).joinToString(SEPARATOR )
171172
172173 exifInterface.latLong?.let {
Original file line number Diff line number Diff line change @@ -302,6 +302,7 @@ class IntentsViewModel(application: Application) : GlimpseViewModel(application)
302302 width = 0 ,
303303 height = 0 ,
304304 orientation = 0 ,
305+ sizeBytes = 0 ,
305306 )
306307
307308 else -> {
You can’t perform that action at this time.
0 commit comments