mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-21 10:17:56 +00:00
Fix story display size logic.
This commit is contained in:
committed by
Cody Henthorne
parent
e552b5160f
commit
d61e33fdf3
@@ -1,7 +1,5 @@
|
||||
package org.thoughtcrime.securesms.stories.viewer.page
|
||||
|
||||
import android.content.res.Resources
|
||||
|
||||
/**
|
||||
* Given the size of our display, we render the story overlay / crop in one of 3 ways.
|
||||
*/
|
||||
@@ -24,13 +22,13 @@ enum class StoryDisplay {
|
||||
private const val LARGE_AR = 9 / 18f
|
||||
private const val SMALL_AR = 9 / 16f
|
||||
|
||||
fun getStoryDisplay(resources: Resources): StoryDisplay {
|
||||
val aspectRatio = resources.displayMetrics.widthPixels.toFloat() / resources.displayMetrics.heightPixels
|
||||
fun getStoryDisplay(screenWidth: Float, screenHeight: Float): StoryDisplay {
|
||||
val aspectRatio = screenWidth / screenHeight
|
||||
|
||||
return when {
|
||||
aspectRatio >= LANDSCAPE -> MEDIUM
|
||||
aspectRatio >= LARGE_AR -> LARGE
|
||||
aspectRatio <= SMALL_AR -> SMALL
|
||||
aspectRatio <= LARGE_AR -> LARGE
|
||||
aspectRatio >= SMALL_AR -> SMALL
|
||||
else -> MEDIUM
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ class StoryViewerPageFragment :
|
||||
val constraintSet = ConstraintSet()
|
||||
constraintSet.clone(requireView() as ConstraintLayout)
|
||||
|
||||
when (StoryDisplay.getStoryDisplay(resources)) {
|
||||
when (StoryDisplay.getStoryDisplay(resources.displayMetrics.widthPixels.toFloat(), resources.displayMetrics.heightPixels.toFloat())) {
|
||||
StoryDisplay.LARGE -> {
|
||||
constraintSet.connect(viewsAndReplies.id, ConstraintSet.TOP, cardWrapper.id, ConstraintSet.BOTTOM)
|
||||
constraintSet.connect(viewsAndReplies.id, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM)
|
||||
|
||||
Reference in New Issue
Block a user