Code refactor, fix animations on Album and Artist details

This commit is contained in:
Hemanth S 2020-10-03 00:40:26 +05:30
parent 31a0ddd731
commit c23c56649e
8 changed files with 205 additions and 114 deletions

View file

@ -148,7 +148,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
miniPlayerFragment?.view?.alpha = alpha miniPlayerFragment?.view?.alpha = alpha
miniPlayerFragment?.view?.visibility = if (alpha == 0f) View.GONE else View.VISIBLE miniPlayerFragment?.view?.visibility = if (alpha == 0f) View.GONE else View.VISIBLE
bottomNavigationView.translationY = progress * 500 bottomNavigationView.translationY = progress * 500
bottomNavigationView.alpha = alpha //bottomNavigationView.alpha = alpha
} }
open fun onPanelCollapsed() { open fun onPanelCollapsed() {
@ -207,8 +207,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
override fun onQueueChanged() { override fun onQueueChanged() {
super.onQueueChanged() super.onQueueChanged()
val isEmpty = MusicPlayerRemote.playingQueue.isEmpty() if (MusicPlayerRemote.playingQueue.isEmpty()) {
if (isEmpty) {
libraryViewModel.setPanelState(HIDE) libraryViewModel.setPanelState(HIDE)
} else { } else {
if (bottomNavigationView.isVisible) { if (bottomNavigationView.isVisible) {
@ -229,6 +228,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
collapsePanel() collapsePanel()
return true return true
} }
return false return false
} }
@ -323,17 +323,20 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
val isQueueEmpty = MusicPlayerRemote.playingQueue.isEmpty() val isQueueEmpty = MusicPlayerRemote.playingQueue.isEmpty()
when (state) { when (state) {
EXPAND -> { EXPAND -> {
println("EXPAND")
expandPanel() expandPanel()
} }
HIDE -> { HIDE -> {
ViewCompat.setElevation(slidingPanel, 0f) println("HIDE")
ViewCompat.setElevation(bottomNavigationView, 10f) bottomNavigationView.translateXAnimate(0f)
bottomSheetBehavior.isHideable = true bottomSheetBehavior.isHideable = true
bottomSheetBehavior.peekHeightAnimate(0) bottomSheetBehavior.peekHeightAnimate(0)
bottomNavigationView.translateXAnimate(0f)
bottomSheetBehavior.state = STATE_COLLAPSED bottomSheetBehavior.state = STATE_COLLAPSED
ViewCompat.setElevation(slidingPanel, 0f)
ViewCompat.setElevation(bottomNavigationView, 10f)
} }
COLLAPSED_WITH -> { COLLAPSED_WITH -> {
println("COLLAPSED_WITH")
val heightOfBar = bottomNavigationView.height val heightOfBar = bottomNavigationView.height
val height = if (isQueueEmpty) 0 else (heightOfBar * 2) - 24 val height = if (isQueueEmpty) 0 else (heightOfBar * 2) - 24
ViewCompat.setElevation(bottomNavigationView, 20f) ViewCompat.setElevation(bottomNavigationView, 20f)
@ -343,6 +346,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
bottomNavigationView.translateXAnimate(0f) bottomNavigationView.translateXAnimate(0f)
} }
COLLAPSED_WITHOUT -> { COLLAPSED_WITHOUT -> {
println("COLLAPSED_WITHOUT")
val heightOfBar = bottomNavigationView.height val heightOfBar = bottomNavigationView.height
val height = if (isQueueEmpty) 0 else heightOfBar - 24 val height = if (isQueueEmpty) 0 else heightOfBar - 24
ViewCompat.setElevation(bottomNavigationView, 10f) ViewCompat.setElevation(bottomNavigationView, 10f)
@ -352,6 +356,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
bottomNavigationView.translateXAnimate(150f) bottomNavigationView.translateXAnimate(150f)
} }
else -> { else -> {
println("else")
bottomSheetBehavior.isHideable = true bottomSheetBehavior.isHideable = true
bottomSheetBehavior.peekHeight = 0 bottomSheetBehavior.peekHeight = 0
collapsePanel() collapsePanel()

View file

@ -10,7 +10,6 @@ import androidx.core.text.HtmlCompat
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.navigation.findNavController
import androidx.navigation.fragment.FragmentNavigatorExtras import androidx.navigation.fragment.FragmentNavigatorExtras
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs import androidx.navigation.fragment.navArgs
@ -31,6 +30,7 @@ import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
import code.name.monkey.retromusic.extensions.applyColor import code.name.monkey.retromusic.extensions.applyColor
import code.name.monkey.retromusic.extensions.applyOutlineColor import code.name.monkey.retromusic.extensions.applyOutlineColor
import code.name.monkey.retromusic.extensions.findActivityNavController
import code.name.monkey.retromusic.extensions.show import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
import code.name.monkey.retromusic.glide.AlbumGlideRequest import code.name.monkey.retromusic.glide.AlbumGlideRequest
@ -106,11 +106,14 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
}) })
setupRecyclerView() setupRecyclerView()
artistImage.setOnClickListener { artistImage.setOnClickListener { artistView ->
requireActivity().findNavController(R.id.fragment_container) ViewCompat.setTransitionName(artistView, "artist")
findActivityNavController(R.id.fragment_container)
.navigate( .navigate(
R.id.artistDetailsFragment, R.id.artistDetailsFragment,
bundleOf(EXTRA_ARTIST_ID to album.artistId) bundleOf(EXTRA_ARTIST_ID to album.artistId),
null,
FragmentNavigatorExtras(artistView to "artist")
) )
} }
playAction.setOnClickListener { MusicPlayerRemote.openQueue(album.songs, 0, true) } playAction.setOnClickListener { MusicPlayerRemote.openQueue(album.songs, 0, true) }

View file

@ -10,17 +10,21 @@ import androidx.recyclerview.widget.GridLayoutManager
import code.name.monkey.retromusic.EXTRA_ALBUM_ID import code.name.monkey.retromusic.EXTRA_ALBUM_ID
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.album.AlbumAdapter import code.name.monkey.retromusic.adapter.album.AlbumAdapter
import code.name.monkey.retromusic.extensions.surfaceColor
import code.name.monkey.retromusic.fragments.ReloadType import code.name.monkey.retromusic.fragments.ReloadType
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment
import code.name.monkey.retromusic.helper.SortOrder import code.name.monkey.retromusic.helper.SortOrder
import code.name.monkey.retromusic.helper.SortOrder.AlbumSortOrder import code.name.monkey.retromusic.helper.SortOrder.AlbumSortOrder
import code.name.monkey.retromusic.interfaces.IAlbumClickListener import code.name.monkey.retromusic.interfaces.IAlbumClickListener
import code.name.monkey.retromusic.interfaces.ICabHolder
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroColorUtil
import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.RetroUtil
import com.afollestad.materialcab.MaterialCab
class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(), class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(),
IAlbumClickListener { IAlbumClickListener, ICabHolder {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
@ -45,7 +49,7 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
requireActivity(), requireActivity(),
dataSet, dataSet,
itemLayoutRes(), itemLayoutRes(),
null, this,
this this
) )
} }
@ -225,15 +229,14 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
private fun handleSortOrderMenuItem( private fun handleSortOrderMenuItem(
item: MenuItem item: MenuItem
): Boolean { ): Boolean {
var sortOrder: String? = null val sortOrder: String = when (item.itemId) {
R.id.action_album_sort_order_asc -> AlbumSortOrder.ALBUM_A_Z
when (item.itemId) { R.id.action_album_sort_order_desc -> AlbumSortOrder.ALBUM_Z_A
R.id.action_album_sort_order_asc -> sortOrder = AlbumSortOrder.ALBUM_A_Z R.id.action_album_sort_order_artist -> AlbumSortOrder.ALBUM_ARTIST
R.id.action_album_sort_order_desc -> sortOrder = AlbumSortOrder.ALBUM_Z_A R.id.action_album_sort_order_year -> AlbumSortOrder.ALBUM_YEAR
R.id.action_album_sort_order_artist -> sortOrder = AlbumSortOrder.ALBUM_ARTIST else -> PreferenceUtil.albumSortOrder
R.id.action_album_sort_order_year -> sortOrder = AlbumSortOrder.ALBUM_YEAR
} }
if (sortOrder != null) { if (sortOrder != PreferenceUtil.albumSortOrder) {
item.isChecked = true item.isChecked = true
setAndSaveSortOrder(sortOrder) setAndSaveSortOrder(sortOrder)
return true return true
@ -244,16 +247,16 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
private fun handleLayoutResType( private fun handleLayoutResType(
item: MenuItem item: MenuItem
): Boolean { ): Boolean {
var layoutRes = -1 val layoutRes = when (item.itemId) {
when (item.itemId) { R.id.action_layout_normal -> R.layout.item_grid
R.id.action_layout_normal -> layoutRes = R.layout.item_grid R.id.action_layout_card -> R.layout.item_card
R.id.action_layout_card -> layoutRes = R.layout.item_card R.id.action_layout_colored_card -> R.layout.item_card_color
R.id.action_layout_colored_card -> layoutRes = R.layout.item_card_color R.id.action_layout_circular -> R.layout.item_grid_circle
R.id.action_layout_circular -> layoutRes = R.layout.item_grid_circle R.id.action_layout_image -> R.layout.image
R.id.action_layout_image -> layoutRes = R.layout.image R.id.action_layout_gradient_image -> R.layout.item_image_gradient
R.id.action_layout_gradient_image -> layoutRes = R.layout.item_image_gradient else -> PreferenceUtil.albumGridStyle
} }
if (layoutRes != -1) { if (layoutRes != PreferenceUtil.albumGridStyle) {
item.isChecked = true item.isChecked = true
setAndSaveLayoutRes(layoutRes) setAndSaveLayoutRes(layoutRes)
return true return true
@ -264,16 +267,16 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
private fun handleGridSizeMenuItem( private fun handleGridSizeMenuItem(
item: MenuItem item: MenuItem
): Boolean { ): Boolean {
var gridSize = 0 val gridSize = when (item.itemId) {
when (item.itemId) { R.id.action_grid_size_1 -> 1
R.id.action_grid_size_1 -> gridSize = 1 R.id.action_grid_size_2 -> 2
R.id.action_grid_size_2 -> gridSize = 2 R.id.action_grid_size_3 -> 3
R.id.action_grid_size_3 -> gridSize = 3 R.id.action_grid_size_4 -> 4
R.id.action_grid_size_4 -> gridSize = 4 R.id.action_grid_size_5 -> 5
R.id.action_grid_size_5 -> gridSize = 5 R.id.action_grid_size_6 -> 6
R.id.action_grid_size_6 -> gridSize = 6 R.id.action_grid_size_7 -> 7
R.id.action_grid_size_7 -> gridSize = 7 R.id.action_grid_size_8 -> 8
R.id.action_grid_size_8 -> gridSize = 8 else -> 0
} }
if (gridSize > 0) { if (gridSize > 0) {
item.isChecked = true item.isChecked = true
@ -283,4 +286,30 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
return false return false
} }
private var cab: MaterialCab? = null
fun handleBackPress(): Boolean {
cab?.let {
if (it.isActive) {
it.finish()
return true
}
}
return false
}
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
cab?.let {
println("Cab")
if (it.isActive) {
it.finish()
}
}
cab = MaterialCab(mainActivity, R.id.cab_stub)
.setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close)
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
.start(callback)
return cab as MaterialCab
}
} }

View file

@ -10,16 +10,20 @@ import androidx.recyclerview.widget.GridLayoutManager
import code.name.monkey.retromusic.EXTRA_ARTIST_ID import code.name.monkey.retromusic.EXTRA_ARTIST_ID
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.artist.ArtistAdapter import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
import code.name.monkey.retromusic.extensions.surfaceColor
import code.name.monkey.retromusic.fragments.ReloadType import code.name.monkey.retromusic.fragments.ReloadType
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment
import code.name.monkey.retromusic.helper.SortOrder.ArtistSortOrder import code.name.monkey.retromusic.helper.SortOrder.ArtistSortOrder
import code.name.monkey.retromusic.interfaces.IArtistClickListener import code.name.monkey.retromusic.interfaces.IArtistClickListener
import code.name.monkey.retromusic.interfaces.ICabHolder
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroColorUtil
import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.RetroUtil
import com.afollestad.materialcab.MaterialCab
class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager>(), class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager>(),
IArtistClickListener { IArtistClickListener, ICabHolder {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
libraryViewModel.getArtists().observe(viewLifecycleOwner, Observer { libraryViewModel.getArtists().observe(viewLifecycleOwner, Observer {
@ -47,7 +51,7 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
requireActivity(), requireActivity(),
dataSet, dataSet,
itemLayoutRes(), itemLayoutRes(),
null, this,
this this
) )
} }
@ -205,13 +209,12 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
private fun handleSortOrderMenuItem( private fun handleSortOrderMenuItem(
item: MenuItem item: MenuItem
): Boolean { ): Boolean {
var sortOrder: String? = null val sortOrder: String = when (item.itemId) {
R.id.action_artist_sort_order_asc -> ArtistSortOrder.ARTIST_A_Z
when (item.itemId) { R.id.action_artist_sort_order_desc -> ArtistSortOrder.ARTIST_Z_A
R.id.action_artist_sort_order_asc -> sortOrder = ArtistSortOrder.ARTIST_A_Z else -> PreferenceUtil.artistSortOrder
R.id.action_artist_sort_order_desc -> sortOrder = ArtistSortOrder.ARTIST_Z_A
} }
if (sortOrder != null) { if (sortOrder != PreferenceUtil.artistSortOrder) {
item.isChecked = true item.isChecked = true
setAndSaveSortOrder(sortOrder) setAndSaveSortOrder(sortOrder)
return true return true
@ -222,16 +225,16 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
private fun handleLayoutResType( private fun handleLayoutResType(
item: MenuItem item: MenuItem
): Boolean { ): Boolean {
var layoutRes = -1 val layoutRes = when (item.itemId) {
when (item.itemId) { R.id.action_layout_normal -> R.layout.item_grid
R.id.action_layout_normal -> layoutRes = R.layout.item_grid R.id.action_layout_card -> R.layout.item_card
R.id.action_layout_card -> layoutRes = R.layout.item_card R.id.action_layout_colored_card -> R.layout.item_card_color
R.id.action_layout_colored_card -> layoutRes = R.layout.item_card_color R.id.action_layout_circular -> R.layout.item_grid_circle
R.id.action_layout_circular -> layoutRes = R.layout.item_grid_circle R.id.action_layout_image -> R.layout.image
R.id.action_layout_image -> layoutRes = R.layout.image R.id.action_layout_gradient_image -> R.layout.item_image_gradient
R.id.action_layout_gradient_image -> layoutRes = R.layout.item_image_gradient else -> PreferenceUtil.artistGridStyle
} }
if (layoutRes != -1) { if (layoutRes != PreferenceUtil.artistGridStyle) {
item.isChecked = true item.isChecked = true
setAndSaveLayoutRes(layoutRes) setAndSaveLayoutRes(layoutRes)
return true return true
@ -242,16 +245,16 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
private fun handleGridSizeMenuItem( private fun handleGridSizeMenuItem(
item: MenuItem item: MenuItem
): Boolean { ): Boolean {
var gridSize = 0 val gridSize = when (item.itemId) {
when (item.itemId) { R.id.action_grid_size_1 -> 1
R.id.action_grid_size_1 -> gridSize = 1 R.id.action_grid_size_2 -> 2
R.id.action_grid_size_2 -> gridSize = 2 R.id.action_grid_size_3 -> 3
R.id.action_grid_size_3 -> gridSize = 3 R.id.action_grid_size_4 -> 4
R.id.action_grid_size_4 -> gridSize = 4 R.id.action_grid_size_5 -> 5
R.id.action_grid_size_5 -> gridSize = 5 R.id.action_grid_size_6 -> 6
R.id.action_grid_size_6 -> gridSize = 6 R.id.action_grid_size_7 -> 7
R.id.action_grid_size_7 -> gridSize = 7 R.id.action_grid_size_8 -> 8
R.id.action_grid_size_8 -> gridSize = 8 else -> 0
} }
if (gridSize > 0) { if (gridSize > 0) {
item.isChecked = true item.isChecked = true
@ -260,4 +263,30 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
} }
return false return false
} }
private var cab: MaterialCab? = null
fun handleBackPress(): Boolean {
cab?.let {
if (it.isActive) {
it.finish()
return true
}
}
return false
}
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
cab?.let {
println("Cab")
if (it.isActive) {
it.finish()
}
}
cab = MaterialCab(mainActivity, R.id.cab_stub)
.setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close)
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
.start(callback)
return cab as MaterialCab
}
} }

View file

@ -7,14 +7,19 @@ import androidx.lifecycle.Observer
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.song.SongAdapter import code.name.monkey.retromusic.adapter.song.SongAdapter
import code.name.monkey.retromusic.extensions.surfaceColor
import code.name.monkey.retromusic.fragments.ReloadType import code.name.monkey.retromusic.fragments.ReloadType
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment
import code.name.monkey.retromusic.helper.SortOrder.SongSortOrder import code.name.monkey.retromusic.helper.SortOrder.SongSortOrder
import code.name.monkey.retromusic.interfaces.ICabHolder
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroColorUtil
import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.RetroUtil
import com.afollestad.materialcab.MaterialCab
class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager>() { class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager>(),
ICabHolder {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
libraryViewModel.getSongs().observe(viewLifecycleOwner, Observer { libraryViewModel.getSongs().observe(viewLifecycleOwner, Observer {
@ -38,7 +43,7 @@ class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLay
requireActivity(), requireActivity(),
dataSet, dataSet,
itemLayoutRes(), itemLayoutRes(),
null this
) )
} }
@ -227,20 +232,18 @@ class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLay
private fun handleSortOrderMenuItem( private fun handleSortOrderMenuItem(
item: MenuItem item: MenuItem
): Boolean { ): Boolean {
var sortOrder: String? = null val sortOrder: String = when (item.itemId) {
R.id.action_song_sort_order_asc -> SongSortOrder.SONG_A_Z
when (item.itemId) { R.id.action_song_sort_order_desc -> SongSortOrder.SONG_Z_A
R.id.action_song_sort_order_asc -> sortOrder = SongSortOrder.SONG_A_Z R.id.action_song_sort_order_artist -> SongSortOrder.SONG_ARTIST
R.id.action_song_sort_order_desc -> sortOrder = SongSortOrder.SONG_Z_A R.id.action_song_sort_order_album -> SongSortOrder.SONG_ALBUM
R.id.action_song_sort_order_artist -> sortOrder = SongSortOrder.SONG_ARTIST R.id.action_song_sort_order_year -> SongSortOrder.SONG_YEAR
R.id.action_song_sort_order_album -> sortOrder = SongSortOrder.SONG_ALBUM R.id.action_song_sort_order_date -> SongSortOrder.SONG_DATE
R.id.action_song_sort_order_year -> sortOrder = SongSortOrder.SONG_YEAR R.id.action_song_sort_order_composer -> SongSortOrder.COMPOSER
R.id.action_song_sort_order_date -> sortOrder = SongSortOrder.SONG_DATE R.id.action_song_sort_order_date_modified -> SongSortOrder.SONG_DATE_MODIFIED
R.id.action_song_sort_order_composer -> sortOrder = SongSortOrder.COMPOSER else -> PreferenceUtil.songSortOrder
R.id.action_song_sort_order_date_modified -> sortOrder =
SongSortOrder.SONG_DATE_MODIFIED
} }
if (sortOrder != null) { if (sortOrder != PreferenceUtil.songSortOrder) {
item.isChecked = true item.isChecked = true
setAndSaveSortOrder(sortOrder) setAndSaveSortOrder(sortOrder)
return true return true
@ -251,16 +254,16 @@ class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLay
private fun handleLayoutResType( private fun handleLayoutResType(
item: MenuItem item: MenuItem
): Boolean { ): Boolean {
var layoutRes = -1 val layoutRes = when (item.itemId) {
when (item.itemId) { R.id.action_layout_normal -> R.layout.item_grid
R.id.action_layout_normal -> layoutRes = R.layout.item_grid R.id.action_layout_card -> R.layout.item_card
R.id.action_layout_card -> layoutRes = R.layout.item_card R.id.action_layout_colored_card -> R.layout.item_card_color
R.id.action_layout_colored_card -> layoutRes = R.layout.item_card_color R.id.action_layout_circular -> R.layout.item_grid_circle
R.id.action_layout_circular -> layoutRes = R.layout.item_grid_circle R.id.action_layout_image -> R.layout.image
R.id.action_layout_image -> layoutRes = R.layout.image R.id.action_layout_gradient_image -> R.layout.item_image_gradient
R.id.action_layout_gradient_image -> layoutRes = R.layout.item_image_gradient else -> PreferenceUtil.songGridStyle
} }
if (layoutRes != -1) { if (layoutRes != PreferenceUtil.songGridStyle) {
item.isChecked = true item.isChecked = true
setAndSaveLayoutRes(layoutRes) setAndSaveLayoutRes(layoutRes)
return true return true
@ -271,16 +274,16 @@ class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLay
private fun handleGridSizeMenuItem( private fun handleGridSizeMenuItem(
item: MenuItem item: MenuItem
): Boolean { ): Boolean {
var gridSize = 0 val gridSize = when (item.itemId) {
when (item.itemId) { R.id.action_grid_size_1 -> 1
R.id.action_grid_size_1 -> gridSize = 1 R.id.action_grid_size_2 -> 2
R.id.action_grid_size_2 -> gridSize = 2 R.id.action_grid_size_3 -> 3
R.id.action_grid_size_3 -> gridSize = 3 R.id.action_grid_size_4 -> 4
R.id.action_grid_size_4 -> gridSize = 4 R.id.action_grid_size_5 -> 5
R.id.action_grid_size_5 -> gridSize = 5 R.id.action_grid_size_6 -> 6
R.id.action_grid_size_6 -> gridSize = 6 R.id.action_grid_size_7 -> 7
R.id.action_grid_size_7 -> gridSize = 7 R.id.action_grid_size_8 -> 8
R.id.action_grid_size_8 -> gridSize = 8 else -> 0
} }
if (gridSize > 0) { if (gridSize > 0) {
item.isChecked = true item.isChecked = true
@ -299,4 +302,31 @@ class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLay
return SongsFragment() return SongsFragment()
} }
} }
private var cab: MaterialCab? = null
fun handleBackPress(): Boolean {
cab?.let {
if (it.isActive) {
it.finish()
return true
}
}
return false
}
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
cab?.let {
println("Cab")
if (it.isActive) {
it.finish()
}
}
cab = MaterialCab(mainActivity, R.id.cab_stub)
.setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close)
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
.start(callback)
return cab as MaterialCab
}
} }

View file

@ -426,7 +426,7 @@ object PreferenceUtil {
val tabTitleMode: Int val tabTitleMode: Int
get() { get() {
return when (sharedPreferences.getStringOrDefault( return when (sharedPreferences.getStringOrDefault(
TAB_TEXT_MODE, "1" TAB_TEXT_MODE, "0"
).toInt()) { ).toInt()) {
1 -> LabelVisibilityMode.LABEL_VISIBILITY_LABELED 1 -> LabelVisibilityMode.LABEL_VISIBILITY_LABELED
0 -> LabelVisibilityMode.LABEL_VISIBILITY_AUTO 0 -> LabelVisibilityMode.LABEL_VISIBILITY_AUTO

View file

@ -2,6 +2,7 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/colorSurface" android:background="?attr/colorSurface"
@ -9,7 +10,6 @@
android:transitionName="@string/transition_album_art" android:transitionName="@string/transition_album_art"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute">
<FrameLayout <FrameLayout
android:id="@+id/toolbarContainer" android:id="@+id/toolbarContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -29,7 +29,6 @@
android:layout_height="48dp" /> android:layout_height="48dp" />
</FrameLayout> </FrameLayout>
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:id="@+id/albumCoverContainer" android:id="@+id/albumCoverContainer"
android:layout_width="0dp" android:layout_width="0dp"
@ -38,9 +37,8 @@
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
app:cardCornerRadius="24dp" app:cardCornerRadius="24dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toStartOf="@+id/container" app:layout_constraintEnd_toStartOf="@+id/content"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbarContainer"> app:layout_constraintTop_toBottomOf="@id/toolbarContainer">
@ -53,9 +51,8 @@
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:id="@+id/container" android:id="@+id/content"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:descendantFocusability="beforeDescendants" android:descendantFocusability="beforeDescendants"

View file

@ -2,13 +2,13 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/colorSurface" android:background="?attr/colorSurface"
android:orientation="vertical" android:orientation="vertical"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute">
<FrameLayout <FrameLayout
android:id="@+id/toolbarContainer" android:id="@+id/toolbarContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -38,9 +38,8 @@
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:transitionName="@string/transition_artist_image" android:transitionName="@string/transition_artist_image"
app:cardCornerRadius="24dp" app:cardCornerRadius="24dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toStartOf="@+id/container" app:layout_constraintEnd_toStartOf="@+id/content"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbarContainer"> app:layout_constraintTop_toBottomOf="@id/toolbarContainer">
@ -53,9 +52,8 @@
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:id="@+id/container" android:id="@+id/content"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"