Fix more playback display issues

Fix some other problems with the way playback is displayed.
This commit is contained in:
OxygenCobalt 2021-01-18 14:03:32 -07:00
parent 6687dbc2f6
commit 554a0f28b2
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
19 changed files with 27 additions and 93 deletions

View file

@ -12,7 +12,7 @@ class AuxioApp : Application(), ImageLoaderFactory {
super.onCreate()
// Init SettingsManager here so that there aren't any race conditions
// [e.g Service gets SettingsManager before activity can init SettingsManager]
// [e.g PlaybackService gets SettingsManager before activity can init SettingsManager]
SettingsManager.init(applicationContext)
}

View file

@ -75,26 +75,21 @@ class MainFragment : Fragment() {
if (isTablet(resources) && !isLandscape(resources)) {
labelVisibilityMode = LabelVisibilityMode.LABEL_VISIBILITY_LABELED
}
}
binding.navBar.itemIconTintList = navTints
binding.navBar.itemTextColor = navTints
navController?.let { controller ->
binding.navBar.setOnNavigationItemSelectedListener {
navigateWithItem(controller, it)
navController?.let { controller ->
binding.navBar.setOnNavigationItemSelectedListener {
navigateWithItem(controller, it)
}
}
}
// --- VIEWMODEL SETUP ---
// Change CompactPlaybackFragment's visibility here so that an animation occurs.
if (!isLandscape(resources)) {
handleCompactPlaybackVisibility(binding, playbackModel.song.value)
handleCompactPlaybackVisibility(binding, playbackModel.song.value)
playbackModel.song.observe(viewLifecycleOwner) {
handleCompactPlaybackVisibility(binding, it)
}
playbackModel.song.observe(viewLifecycleOwner) {
handleCompactPlaybackVisibility(binding, it)
}
detailModel.navToItem.observe(viewLifecycleOwner) {
@ -148,7 +143,9 @@ class MainFragment : Fragment() {
if (song == null) {
logD("Hiding CompactPlaybackFragment since no song is being played.")
binding.compactPlayback.visibility = View.GONE
binding.compactPlayback.visibility = if (isLandscape(resources))
View.INVISIBLE else View.GONE
playbackModel.disableAnimation()
} else {
binding.compactPlayback.visibility = View.VISIBLE

View file

@ -15,7 +15,6 @@ import org.oxycblt.auxio.databinding.FragmentCompactPlaybackBinding
import org.oxycblt.auxio.detail.DetailViewModel
import org.oxycblt.auxio.logD
import org.oxycblt.auxio.music.MusicStore
import org.oxycblt.auxio.ui.isLandscape
import org.oxycblt.auxio.ui.memberBinding
/**
@ -37,8 +36,6 @@ class CompactPlaybackFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
val isLandscape = isLandscape(resources)
// --- UI SETUP ---
binding.lifecycleOwner = viewLifecycleOwner
@ -46,9 +43,6 @@ class CompactPlaybackFragment : Fragment() {
// Put a placeholder song in the binding & hide the playback fragment initially.
binding.song = MusicStore.getInstance().songs[0]
binding.playbackModel = playbackModel
if (playbackModel.song.value == null && isLandscape) {
hideAll(binding)
}
binding.root.apply {
setOnClickListener {
@ -71,14 +65,6 @@ class CompactPlaybackFragment : Fragment() {
binding.song = it
binding.playbackProgress.max = it.seconds.toInt()
if (isLandscape) {
showAll(binding)
}
} else if (isLandscape) {
// CompactPlaybackFragment isn't fully hidden in landscape mode, only
// its UI elements are hidden.
hideAll(binding)
}
}
@ -126,36 +112,4 @@ class CompactPlaybackFragment : Fragment() {
}
}
}
/**
* Hide all UI elements, and disable the fragment from being clickable.
* Only called in landscape mode.
*/
private fun hideAll(binding: FragmentCompactPlaybackBinding) {
binding.apply {
root.isEnabled = false
playbackCover.visibility = View.INVISIBLE
playbackSong.visibility = View.INVISIBLE
playbackInfo.visibility = View.INVISIBLE
playbackControls.visibility = View.INVISIBLE
playbackProgress.visibility = View.INVISIBLE
}
}
/**
* Unhide all UI elements, and make the fragment clickable.
* Only called in landscape mode.
*/
private fun showAll(binding: FragmentCompactPlaybackBinding) {
binding.apply {
root.isEnabled = true
playbackCover.visibility = View.VISIBLE
playbackSong.visibility = View.VISIBLE
playbackInfo.visibility = View.VISIBLE
playbackControls.visibility = View.VISIBLE
playbackProgress.visibility = View.VISIBLE
}
}
}

View file

@ -44,8 +44,8 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_mid_small"
android:layout_marginEnd="@dimen/margin_mid_small"
android:fontFamily="@font/inter_semibold"
android:ellipsize="end"
android:fontFamily="@font/inter_semibold"
android:singleLine="true"
android:text="@{song.name}"
android:textAppearance="@style/TextAppearance.SmallHeader"

View file

@ -172,7 +172,6 @@
android:id="@+id/playback_skip_next"
style="@style/Widget.Button.Unbounded"
android:layout_marginEnd="@dimen/margin_large"
android:padding="0dp"
android:background="@drawable/ui_unbounded_ripple"
android:contentDescription="@string/description_skip_next"
android:onClick="@{() -> playbackModel.skipNext()}"
@ -190,7 +189,6 @@
android:contentDescription="@string/description_skip_prev"
android:onClick="@{() -> playbackModel.skipPrev()}"
android:src="@drawable/ic_skip_prev"
android:padding="0dp"
app:layout_constraintBottom_toBottomOf="@+id/playback_play_pause"
app:layout_constraintEnd_toStartOf="@+id/playback_play_pause"
app:layout_constraintStart_toEndOf="@+id/playback_loop"

View file

@ -29,9 +29,9 @@
android:layout_height="@dimen/size_cover_mid_huge"
android:layout_marginStart="@dimen/margin_medium"
android:layout_marginTop="@dimen/margin_medium"
android:outlineProvider="bounds"
android:elevation="@dimen/elevation_normal"
android:contentDescription="@{@string/description_album_cover(album.name)}"
android:elevation="@dimen/elevation_normal"
android:outlineProvider="bounds"
app:coverArt="@{album}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"

View file

@ -29,8 +29,8 @@
android:layout_height="@dimen/size_cover_mid_huge"
android:layout_margin="@dimen/margin_medium"
android:contentDescription="@{@string/description_artist_image(artist.name)}"
android:outlineProvider="bounds"
android:elevation="@dimen/elevation_normal"
android:outlineProvider="bounds"
app:artistImage="@{artist}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"

View file

@ -29,8 +29,8 @@
android:layout_height="@dimen/size_cover_mid_huge"
android:layout_margin="@dimen/margin_medium"
android:contentDescription="@{@string/description_genre_image(genre.name)}"
android:outlineProvider="bounds"
android:elevation="@dimen/elevation_normal"
android:outlineProvider="bounds"
app:genreImage="@{genre}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"

View file

@ -173,14 +173,10 @@
<ImageButton
android:id="@+id/playback_skip_next"
style="@style/Widget.Button.Unbounded"
android:layout_width="@dimen/size_play_pause_compact"
android:layout_height="@dimen/size_play_pause_compact"
android:layout_marginEnd="@dimen/margin_large"
android:background="@drawable/ui_unbounded_ripple"
android:contentDescription="@string/description_skip_next"
android:onClick="@{() -> playbackModel.skipNext()}"
android:src="@drawable/ic_skip_next"
android:padding="0dp"
app:layout_constraintBottom_toBottomOf="@+id/playback_play_pause"
app:layout_constraintEnd_toStartOf="@+id/playback_shuffle"
app:layout_constraintStart_toEndOf="@+id/playback_play_pause"
@ -189,10 +185,7 @@
<ImageButton
android:id="@+id/playback_skip_prev"
style="@style/Widget.Button.Unbounded"
android:layout_width="@dimen/size_play_pause_compact"
android:layout_height="@dimen/size_play_pause_compact"
android:layout_marginStart="@dimen/margin_large"
android:background="@drawable/ui_unbounded_ripple"
android:contentDescription="@string/description_skip_prev"
android:onClick="@{() -> playbackModel.skipPrev()}"
android:src="@drawable/ic_skip_prev"
@ -204,13 +197,9 @@
<ImageButton
android:id="@+id/playback_shuffle"
style="@style/Widget.Button.Unbounded"
android:layout_width="@dimen/size_play_pause_compact"
android:layout_height="@dimen/size_play_pause_compact"
android:background="@drawable/ui_unbounded_ripple"
android:contentDescription="@{playbackModel.isShuffling() ? @string/description_shuffle_off : @string/description_shuffle_on"
android:onClick="@{() -> playbackModel.invertShuffleStatus()}"
android:src="@drawable/ic_shuffle"
android:padding="0dp"
app:layout_constraintBottom_toBottomOf="@+id/playback_skip_next"
app:layout_constraintEnd_toEndOf="@+id/playback_song_container_duration"
app:layout_constraintStart_toEndOf="@+id/playback_skip_next"
@ -219,9 +208,6 @@
<ImageButton
android:id="@+id/playback_loop"
style="@style/Widget.Button.Unbounded"
android:layout_width="@dimen/size_play_pause_compact"
android:layout_height="@dimen/size_play_pause_compact"
android:background="@drawable/ui_unbounded_ripple"
android:contentDescription="@string/description_change_loop"
android:onClick="@{() -> playbackModel.incrementLoopStatus()}"
android:src="@drawable/ic_loop"

View file

@ -29,9 +29,9 @@
android:layout_height="@dimen/size_cover_mid_huge"
android:layout_marginStart="@dimen/margin_medium"
android:layout_marginTop="@dimen/margin_medium"
android:outlineProvider="bounds"
android:elevation="@dimen/elevation_normal"
android:contentDescription="@{@string/description_album_cover(album.name)}"
android:elevation="@dimen/elevation_normal"
android:outlineProvider="bounds"
app:coverArt="@{album}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"

View file

@ -29,8 +29,8 @@
android:layout_height="@dimen/size_cover_mid_huge"
android:layout_margin="@dimen/margin_medium"
android:contentDescription="@{@string/description_artist_image(artist.name)}"
android:outlineProvider="bounds"
android:elevation="@dimen/elevation_normal"
android:outlineProvider="bounds"
app:artistImage="@{artist}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"

View file

@ -29,8 +29,8 @@
android:layout_height="@dimen/size_cover_mid_huge"
android:layout_margin="@dimen/margin_medium"
android:contentDescription="@{@string/description_genre_image(genre.name)}"
android:outlineProvider="bounds"
android:elevation="@dimen/elevation_normal"
android:outlineProvider="bounds"
app:genreImage="@{genre}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"

View file

@ -175,7 +175,6 @@
android:layout_marginStart="@dimen/margin_large"
android:contentDescription="@string/description_skip_prev"
android:onClick="@{() -> playbackModel.skipPrev()}"
android:padding="0dp"
android:src="@drawable/ic_skip_prev"
app:layout_constraintBottom_toBottomOf="@+id/playback_play_pause"
app:layout_constraintEnd_toStartOf="@+id/playback_play_pause"
@ -188,7 +187,6 @@
android:contentDescription="@{playbackModel.isShuffling() ? @string/description_shuffle_off : @string/description_shuffle_on"
android:onClick="@{() -> playbackModel.invertShuffleStatus()}"
android:src="@drawable/ic_shuffle"
android:padding="0dp"
app:layout_constraintBottom_toBottomOf="@+id/playback_skip_next"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/playback_skip_next"

View file

@ -29,8 +29,8 @@
android:layout_height="@dimen/size_cover_huge"
android:layout_marginTop="@dimen/margin_medium"
android:contentDescription="@{@string/description_album_cover(album.name)}"
android:outlineProvider="bounds"
android:elevation="@dimen/elevation_normal"
android:outlineProvider="bounds"
app:coverArt="@{album}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View file

@ -29,8 +29,8 @@
android:layout_height="@dimen/size_cover_huge"
android:layout_marginTop="@dimen/margin_medium"
android:contentDescription="@{@string/description_artist_image(artist.name)}"
android:outlineProvider="bounds"
android:elevation="@dimen/elevation_normal"
android:outlineProvider="bounds"
app:artistImage="@{artist}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View file

@ -30,8 +30,8 @@
android:layout_height="@dimen/size_cover_huge"
android:layout_marginTop="@dimen/margin_medium"
android:contentDescription="@{@string/description_genre_image(genre.name)}"
android:outlineProvider="bounds"
android:elevation="@dimen/elevation_normal"
android:outlineProvider="bounds"
app:genreImage="@{genre}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View file

@ -13,7 +13,8 @@
android:title="@string/label_sort"
app:showAsAction="always">
<menu>
<group android:id="@+id/group_sorting"
<group
android:id="@+id/group_sorting"
android:checkableBehavior="single">
<item
android:id="@+id/option_sort_none"

View file

@ -42,7 +42,7 @@
<string name="label_queue_add">Add to queue</string>
<string name="label_queue_added">Added to queue</string>
<string name="label_next_user_queue">Next in Queue</string>
<string name="label_about">About</string>
<string name="label_version">Version</string>
<string name="label_code">View on Github</string>

View file

@ -235,6 +235,6 @@
<item name="android:layout_marginTop">@dimen/margin_medium</item>
<item name="android:layout_marginEnd">@dimen/margin_large</item>
<item name="android:scaleType">fitCenter</item>
<item name="android:padding">@dimen/padding_medium</item>
<item name="android:padding">18dp</item>
</style>
</resources>