Fix more playback display issues
Fix some other problems with the way playback is displayed.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user