Add option to not crop image previews (#2832)
* Don't crop image previews with aspects between 2:1 & 1:2 Fixes #1995 * Custom media preview layout for handling various aspect ratios
This commit is contained in:
parent
6b95790457
commit
cc790ccf69
10 changed files with 402 additions and 298 deletions
|
|
@ -1,4 +1,5 @@
|
|||
@file:JvmName("AttachmentHelper")
|
||||
|
||||
package com.keylesspalace.tusky.util
|
||||
|
||||
import android.content.Context
|
||||
|
|
@ -24,3 +25,12 @@ private fun formatDuration(durationInSeconds: Double): String {
|
|||
val hours = durationInSeconds.toInt() / 3600
|
||||
return "%d:%02d:%02d".format(hours, minutes, seconds)
|
||||
}
|
||||
|
||||
fun List<Attachment>.aspectRatios(): List<Double> {
|
||||
return map { attachment ->
|
||||
// clamp ratio between 2:1 & 1:2, defaulting to 16:9
|
||||
val size = (attachment.meta?.small ?: attachment.meta?.original) ?: return@map 1.7778
|
||||
val aspect = if (size.aspect > 0) size.aspect else size.width.toDouble() / size.height
|
||||
aspect.coerceIn(0.5, 2.0)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue