This repository was archived by the owner on May 23, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
app/src/main/java/com/keylesspalace/tusky/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33package com.keylesspalace.tusky.util
44
55import android.content.Context
6+ import android.content.res.Resources
67import com.keylesspalace.tusky.R
78import com.keylesspalace.tusky.entity.Attachment
89import kotlin.math.roundToInt
@@ -27,10 +28,16 @@ private fun formatDuration(durationInSeconds: Double): String {
2728}
2829
2930fun List<Attachment>.aspectRatios (): List <Double > {
31+ val displayMetrics = Resources .getSystem().displayMetrics
32+ val deviceIsHigher = displayMetrics.heightPixels > displayMetrics.widthPixels
33+
34+ val minAspect = if (deviceIsHigher) 0.5 else 1.2
35+ val maxAspect = if (deviceIsHigher) 2.0 else 3.0
36+
3037 return map { attachment ->
31- // clamp ratio between 2:1 & 1:2 , defaulting to 16:9
38+ // clamp ratio between min & max , defaulting to 16:9 if there is no metadata
3239 val size = (attachment.meta?.small ? : attachment.meta?.original) ? : return @map 1.7778
3340 val aspect = if (size.aspect > 0 ) size.aspect else size.width.toDouble() / size.height
34- aspect.coerceIn(0.5 , 2.0 )
41+ aspect.coerceIn(minAspect, maxAspect )
3542 }
3643}
You can’t perform that action at this time.
0 commit comments