Audio caption improvements (#2220)

* Fix caption display in audio player

* Make video/audio description scrollable

* Constrain the maximum size of media label previews
This commit is contained in:
Levi Bard 2021-09-17 21:55:54 +02:00 committed by GitHub
parent 949fb6fbb6
commit 45598cf047
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View file

@ -21,6 +21,7 @@ import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.text.method.ScrollingMovementMethod
import android.view.KeyEvent import android.view.KeyEvent
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
@ -79,6 +80,7 @@ class ViewVideoFragment : ViewMediaFragment() {
) { ) {
binding.mediaDescription.text = description binding.mediaDescription.text = description
binding.mediaDescription.visible(showingDescription) binding.mediaDescription.visible(showingDescription)
binding.mediaDescription.movementMethod = ScrollingMovementMethod()
binding.videoView.transitionName = url binding.videoView.transitionName = url
binding.videoView.setVideoPath(url) binding.videoView.setVideoPath(url)
@ -125,7 +127,10 @@ class ViewVideoFragment : ViewMediaFragment() {
val videoWidth = mp.videoWidth.toFloat() val videoWidth = mp.videoWidth.toFloat()
val videoHeight = mp.videoHeight.toFloat() val videoHeight = mp.videoHeight.toFloat()
if (containerWidth / containerHeight > videoWidth / videoHeight) { if (isAudio) {
binding.videoView.layoutParams.height = 1
binding.videoView.layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT
} else if (containerWidth / containerHeight > videoWidth / videoHeight) {
binding.videoView.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT binding.videoView.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
binding.videoView.layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT binding.videoView.layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT
} else { } else {

View file

@ -20,6 +20,7 @@
android:textAlignment="center" android:textAlignment="center"
android:textColor="#eee" android:textColor="#eee"
android:textSize="?attr/status_text_medium" android:textSize="?attr/status_text_medium"
android:scrollbars="vertical"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:text="Some media description" /> tools:text="Some media description" />

View file

@ -141,6 +141,8 @@
android:importantForAccessibility="no" android:importantForAccessibility="no"
android:textSize="?attr/status_text_medium" android:textSize="?attr/status_text_medium"
android:visibility="gone" android:visibility="gone"
android:maxLines="10"
android:ellipsize="end"
app:drawableTint="?android:attr/textColorTertiary" app:drawableTint="?android:attr/textColorTertiary"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@ -155,6 +157,8 @@
android:importantForAccessibility="no" android:importantForAccessibility="no"
android:textSize="?attr/status_text_medium" android:textSize="?attr/status_text_medium"
android:visibility="gone" android:visibility="gone"
android:maxLines="10"
android:ellipsize="end"
app:drawableTint="?android:attr/textColorTertiary" app:drawableTint="?android:attr/textColorTertiary"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/status_media_label_0" /> app:layout_constraintTop_toBottomOf="@id/status_media_label_0" />
@ -169,6 +173,8 @@
android:importantForAccessibility="no" android:importantForAccessibility="no"
android:textSize="?attr/status_text_medium" android:textSize="?attr/status_text_medium"
android:visibility="gone" android:visibility="gone"
android:maxLines="10"
android:ellipsize="end"
app:drawableTint="?android:attr/textColorTertiary" app:drawableTint="?android:attr/textColorTertiary"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/status_media_label_1" /> app:layout_constraintTop_toBottomOf="@id/status_media_label_1" />
@ -183,6 +189,8 @@
android:importantForAccessibility="no" android:importantForAccessibility="no"
android:textSize="?attr/status_text_medium" android:textSize="?attr/status_text_medium"
android:visibility="gone" android:visibility="gone"
android:maxLines="10"
android:ellipsize="end"
app:drawableTint="?android:attr/textColorTertiary" app:drawableTint="?android:attr/textColorTertiary"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/status_media_label_2" /> app:layout_constraintTop_toBottomOf="@id/status_media_label_2" />