kopia lustrzana https://github.com/ryukoposting/Signal-Android
Center story viewport on tall devices.
rodzic
77beeda62a
commit
84f0548966
|
@ -10,8 +10,11 @@ import android.view.View
|
|||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.media.AudioManagerCompat
|
||||
import androidx.window.layout.WindowMetricsCalculator
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.MemoryCategory
|
||||
import org.signal.core.util.dp
|
||||
import org.signal.core.util.sp
|
||||
import org.thoughtcrime.securesms.PassphraseRequiredActivity
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.components.voice.VoiceNoteMediaController
|
||||
|
@ -52,11 +55,22 @@ class StoryViewerActivity : PassphraseRequiredActivity(), VoiceNoteMediaControll
|
|||
supportPostponeEnterTransition()
|
||||
|
||||
val root = findViewById<View>(android.R.id.content)
|
||||
val metrics = WindowMetricsCalculator.getOrCreate().computeCurrentWindowMetrics(this)
|
||||
val statusBarHeight = ViewUtil.getStatusBarHeight(root)
|
||||
val contentHeight = metrics.bounds.width() * (16 / 9f) + 48.sp
|
||||
val spaceAndNavbar = metrics.bounds.height() - statusBarHeight - contentHeight
|
||||
val (padTop, padBottom) = if (spaceAndNavbar > 72.dp) {
|
||||
val pad = (metrics.bounds.height() - contentHeight) / 2f
|
||||
pad to pad
|
||||
} else {
|
||||
statusBarHeight to ViewUtil.getNavigationBarHeight(root)
|
||||
}
|
||||
|
||||
root.setPadding(
|
||||
0,
|
||||
ViewUtil.getStatusBarHeight(root),
|
||||
padTop.toInt(),
|
||||
0,
|
||||
ViewUtil.getNavigationBarHeight(root)
|
||||
padBottom.toInt()
|
||||
)
|
||||
|
||||
super.onCreate(savedInstanceState, ready)
|
||||
|
|
|
@ -12,4 +12,16 @@ val Float.dp: Float get() = DimensionUnit.DP.toPixels(this)
|
|||
* Converts the given Int DP value into Pixels
|
||||
*/
|
||||
@get:Px
|
||||
val Int.dp: Int get() = this.toFloat().dp.toInt()
|
||||
val Int.dp: Int get() = this.toFloat().dp.toInt()
|
||||
|
||||
/**
|
||||
* Converts the given Float SP value into Pixels.
|
||||
*/
|
||||
@get:Px
|
||||
val Float.sp: Float get() = DimensionUnit.SP.toPixels(this)
|
||||
|
||||
/**
|
||||
* Converts the given Int SP value into Pixels
|
||||
*/
|
||||
@get:Px
|
||||
val Int.sp: Int get() = this.toFloat().sp.toInt()
|
Ładowanie…
Reference in New Issue