Fix compact playback visibility issues

For some reason the new system I implemented for compact playback visibility suddenly stopped working! Revert to the old system.
This commit is contained in:
OxygenCobalt 2021-01-19 14:39:09 -07:00
parent 942e1fc740
commit 0bbcff35eb
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
12 changed files with 52 additions and 17 deletions

View file

@ -150,8 +150,9 @@ class MainFragment : Fragment() {
if (song == null) {
logD("Hiding CompactPlaybackFragment since no song is being played.")
binding.compactPlayback.visibility = if (isLandscape(resources))
View.INVISIBLE else View.GONE
if (!isLandscape(resources)) {
binding.compactPlayback.visibility = View.GONE
}
playbackModel.disableAnimation()
} else {

View file

@ -6,6 +6,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.core.view.children
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
@ -15,6 +16,7 @@ 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
/**
@ -57,6 +59,10 @@ class CompactPlaybackFragment : Fragment() {
}
}
if (playbackModel.song.value == null) {
setInvisible(true)
}
// --- VIEWMODEL SETUP ---
playbackModel.song.observe(viewLifecycleOwner) {
@ -65,6 +71,9 @@ class CompactPlaybackFragment : Fragment() {
binding.song = it
binding.playbackProgress.max = it.seconds.toInt()
setInvisible(false)
} else {
setInvisible(true)
}
}
@ -112,4 +121,20 @@ class CompactPlaybackFragment : Fragment() {
}
}
}
/**
* Set this fragment to be invisible, if needed. Only runs in landscape mode.
*/
private fun setInvisible(invisible: Boolean) {
// Does not run in landscape
if (!isLandscape(resources)) return
val visibility = if (invisible) View.INVISIBLE else View.VISIBLE
binding.playbackLayout.children.forEach {
it.visibility = visibility
}
binding.root.isEnabled = !invisible
}
}

View file

@ -66,6 +66,7 @@ class QueueFragment : Fragment() {
insets
}
} else {
// Dont even bother w/edge-to-edge if the navigation bar is on the side
binding.root.fitsSystemWindows = true
}
}

View file

@ -232,6 +232,9 @@ class PlaybackStateManager private constructor() {
resetLoopMode()
setShuffling(shuffled, keepSong = false)
logD(mQueue[0].name)
updatePlayback(mQueue[0])
}
@ -253,6 +256,7 @@ class PlaybackStateManager private constructor() {
/**
* Update the current position. Will not notify any listeners of a seek event, that's what [seekTo] is for.
* @param position The new position in millis.
* @see seekTo
*/
fun setPosition(position: Long) {
mSong?.let {

View file

@ -104,8 +104,8 @@ enum class SortMode(@DrawableRes val iconRes: Int) {
NUMERIC_UP -> {
val list = mutableListOf<Song>()
songs.groupBy { it.album }.toSortedMap(compareBy { it.year }).values.forEach {
list.addAll(it.sortedWith(compareBy { it.track }))
songs.groupBy { it.album }.toSortedMap(compareBy { it.year }).values.forEach { items ->
list.addAll(items.sortedWith(compareBy { it.track }))
}
list
@ -113,8 +113,8 @@ enum class SortMode(@DrawableRes val iconRes: Int) {
NUMERIC_DOWN -> {
val list = mutableListOf<Song>()
songs.groupBy { it.album }.toSortedMap(compareByDescending { it.year }).values.forEach {
list.addAll(it.sortedWith(compareBy { it.track }))
songs.groupBy { it.album }.toSortedMap(compareByDescending { it.year }).values.forEach { items ->
list.addAll(items.sortedWith(compareBy { it.track }))
}
list

View file

@ -76,6 +76,7 @@ class SongsFragment : Fragment() {
}
post {
// Disable fast scrolling if there is nothing to scroll
if (computeVerticalScrollRange() < height) {
binding.songFastScroll.visibility = View.GONE
binding.songFastScrollThumb.visibility = View.GONE

View file

@ -8,6 +8,7 @@ import androidx.appcompat.widget.PopupMenu
import androidx.lifecycle.ViewModelProvider
import org.oxycblt.auxio.R
import org.oxycblt.auxio.detail.DetailViewModel
import org.oxycblt.auxio.logD
import org.oxycblt.auxio.music.Album
import org.oxycblt.auxio.music.Artist
import org.oxycblt.auxio.music.BaseModel

View file

@ -160,7 +160,7 @@ fun Context.getSpans(): Int {
}
/**
* Check if we are in the "Irregular" landscape mode [e.g landscape, but nav bar is on the sides]
* Check if we are in the "Irregular" landscape mode (e.g landscape, but nav bar is on the sides)
* Used to disable most of edge-to-edge if that's the case, as I cant get it to work on this mode.
* @return True if we are in the irregular landscape mode, false if not.
*/

View file

@ -16,6 +16,7 @@
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/playback_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"

View file

@ -16,6 +16,7 @@
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/playback_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_play_albums"
android:id="@+id/action_play"
android:title="@string/label_play" />
<item
android:id="@+id/action_shuffle"

View file

@ -238,13 +238,13 @@
<item name="android:padding">@dimen/padding_play_pause</item>
</style>
<style name="Widget.Design.BottomNavigationView" parent="">
<item name="elevation">@dimen/design_bottom_navigation_elevation</item>
<item name="enforceTextAppearance">false</item>
<item name="enforceMaterialTheme">false</item>
<item name="itemBackground">?attr/selectableItemBackgroundBorderless</item>
<item name="itemHorizontalTranslationEnabled">true</item>
<item name="itemIconSize">@dimen/design_bottom_navigation_icon_size</item>
<item name="labelVisibilityMode">auto</item>
</style>
<style name="Widget.Design.BottomNavigationView" parent="">
<item name="elevation">@dimen/design_bottom_navigation_elevation</item>
<item name="enforceTextAppearance">false</item>
<item name="enforceMaterialTheme">false</item>
<item name="itemBackground">?attr/selectableItemBackgroundBorderless</item>
<item name="itemHorizontalTranslationEnabled">true</item>
<item name="itemIconSize">@dimen/design_bottom_navigation_icon_size</item>
<item name="labelVisibilityMode">auto</item>
</style>
</resources>