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
12 changed files with 52 additions and 17 deletions
@@ -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 {
@@ -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
}
}
@@ -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
}
}
@@ -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 {
@@ -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
@@ -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
@@ -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
@@ -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.
*/