Skip to content

Commit 6fcd70c

Browse files
committed
Glimpse: Add file size to media info
Replaces the megapixels entry, and now follows design spec. Change-Id: I1db5084b883f668ad50b3d3bd038cb36e95ccce3
1 parent fa8b084 commit 6fcd70c

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

app/src/main/java/org/lineageos/glimpse/datasources/LocalDataSource.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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 =

app/src/main/java/org/lineageos/glimpse/models/Media.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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
2930
data 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 {

app/src/main/java/org/lineageos/glimpse/ui/dialogs/MediaInfoBottomSheetDialog.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import android.location.Geocoder
1313
import android.net.Uri
1414
import android.os.Build
1515
import android.text.InputType
16+
import android.text.format.Formatter
1617
import android.view.View
1718
import android.view.ViewGroup
1819
import 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 {

app/src/main/java/org/lineageos/glimpse/viewmodels/IntentsViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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 -> {

0 commit comments

Comments
 (0)