playback: fix flickering with album/artist info

Forgot to move these TextViews into the hacky FrameLayout to make their
new marquee states work correctly.

Resolves #376.
This commit is contained in:
Alexander Capehart 2023-03-17 15:47:31 -06:00
parent 5e0059fdba
commit f57b5dfc81
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
6 changed files with 35 additions and 41 deletions

View file

@ -270,7 +270,8 @@ class MainFragment :
when (action) {
is MainNavigationAction.Expand -> tryExpandSheets()
is MainNavigationAction.Collapse -> tryCollapseSheets()
is MainNavigationAction.Directions -> findNavController().navigateSafe(action.directions)
is MainNavigationAction.Directions ->
findNavController().navigateSafe(action.directions)
}
navModel.mainNavigationAction.consume()

View file

@ -64,7 +64,8 @@ class RootPreferenceFragment : BasePreferenceFragment(R.xml.preferences_root) {
// do one.
when (preference.key) {
getString(R.string.set_key_ui) -> {
findNavController().navigateSafe(RootPreferenceFragmentDirections.goToUiPreferences())
findNavController()
.navigateSafe(RootPreferenceFragmentDirections.goToUiPreferences())
}
getString(R.string.set_key_personalize) -> {
findNavController()

View file

@ -39,7 +39,8 @@ class MusicPreferenceFragment : BasePreferenceFragment(R.xml.preferences_music)
override fun onOpenDialogPreference(preference: WrappedDialogPreference) {
if (preference.key == getString(R.string.set_key_separators)) {
findNavController().navigateSafe(MusicPreferenceFragmentDirections.goToSeparatorsDialog())
findNavController()
.navigateSafe(MusicPreferenceFragmentDirections.goToSeparatorsDialog())
}
}

View file

@ -32,7 +32,8 @@ import org.oxycblt.auxio.util.navigateSafe
class PersonalizePreferenceFragment : BasePreferenceFragment(R.xml.preferences_personalize) {
override fun onOpenDialogPreference(preference: WrappedDialogPreference) {
if (preference.key == getString(R.string.set_key_home_tabs)) {
findNavController().navigateSafe(PersonalizePreferenceFragmentDirections.goToTabDialog())
findNavController()
.navigateSafe(PersonalizePreferenceFragmentDirections.goToTabDialog())
}
}
}

View file

@ -29,7 +29,6 @@ import androidx.appcompat.widget.AppCompatButton
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.graphics.Insets
import androidx.core.graphics.drawable.DrawableCompat
import androidx.navigation.NavAction
import androidx.navigation.NavController
import androidx.navigation.NavDirections
import androidx.recyclerview.widget.RecyclerView
@ -119,9 +118,11 @@ fun AppCompatButton.fixDoubleRipple() {
/**
* Crash-safe wrapped around [NavController.navigate] that will not crash if multiple destinations
* are selected at once.
*
* @param directions The [NavDirections] to navigate with.
*/
fun NavController.navigateSafe(directions: NavDirections) = try {
fun NavController.navigateSafe(directions: NavDirections) =
try {
navigate(directions)
} catch (e: IllegalStateException) {
// Nothing to do.

View file

@ -28,15 +28,16 @@
tools:staticIcon="@drawable/ic_song_24" />
<!-- TextView is wrapped in a container so that marquee doesn't break -->
<!-- Playback information is wrapped in a container so that marquee doesn't break -->
<FrameLayout
android:id="@+id/playback_song_container"
<LinearLayout
android:id="@+id/playback_info_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_medium"
android:layout_marginEnd="@dimen/spacing_medium"
app:layout_constraintBottom_toTopOf="@+id/playback_artist"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@+id/playback_seek_bar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/playback_cover"
@ -47,43 +48,31 @@
android:id="@+id/playback_song"
style="@style/Widget.Auxio.TextView.Primary"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
tools:text="Song Name" />
</FrameLayout>
<TextView
android:id="@+id/playback_artist"
style="@style/Widget.Auxio.TextView.Secondary.Marquee"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_medium"
app:layout_constraintBottom_toTopOf="@+id/playback_album"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/playback_cover"
app:layout_constraintTop_toBottomOf="@+id/playback_song_container"
tools:text="Artist Name" />
<TextView
android:id="@+id/playback_album"
style="@style/Widget.Auxio.TextView.Secondary.Marquee"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_medium"
app:layout_constraintBottom_toBottomOf="@+id/playback_cover"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/playback_cover"
app:layout_constraintTop_toBottomOf="@+id/playback_artist"
tools:text="Album Name" />
</LinearLayout>
<org.oxycblt.auxio.playback.ui.StyledSeekBar
android:id="@+id/playback_seek_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/playback_controls_container"
app:layout_constraintEnd_toEndOf="@+id/playback_song_container"
app:layout_constraintEnd_toEndOf="@+id/playback_info_container"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" />