Fixing animations

This commit is contained in:
Hemanth S 2020-12-04 02:27:44 +05:30
parent 0679774d41
commit b944ef5de6
21 changed files with 123 additions and 122 deletions

View file

@ -56,7 +56,6 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.CategoryInfo import code.name.monkey.retromusic.model.CategoryInfo
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.views.BottomNavigationBarTinted import code.name.monkey.retromusic.views.BottomNavigationBarTinted
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetBehavior.* import com.google.android.material.bottomsheet.BottomSheetBehavior.*
import kotlinx.android.synthetic.main.sliding_music_panel_layout.* import kotlinx.android.synthetic.main.sliding_music_panel_layout.*
import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.androidx.viewmodel.ext.android.viewModel
@ -133,7 +132,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
if (nowPlayingScreen != PreferenceUtil.nowPlayingScreen) { if (nowPlayingScreen != PreferenceUtil.nowPlayingScreen) {
postRecreate() postRecreate()
} }
if (bottomSheetBehavior.state == BottomSheetBehavior.STATE_EXPANDED) { if (bottomSheetBehavior.state == STATE_EXPANDED) {
setMiniPlayerAlphaProgress(1f) setMiniPlayerAlphaProgress(1f)
} }
} }
@ -326,14 +325,14 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
}) })
} }
fun setBottomBarVisibility(visible: Int) { fun setBottomBarVisibility(visible: Boolean) {
bottomNavigationView.visibility = visible bottomNavigationView.isVisible = visible
hideBottomBar(MusicPlayerRemote.playingQueue.isEmpty()) hideBottomBar(MusicPlayerRemote.playingQueue.isEmpty())
} }
private fun hideBottomBar(hide: Boolean) { private fun hideBottomBar(hide: Boolean) {
val heightOfBar = dip(R.dimen.mini_player_height) val heightOfBar = dip(R.dimen.mini_player_height)
val heightOfBarWithTabs = dip(R.dimen.mini_player_height_expanded) val heightOfBarWithTabs = heightOfBar * 2
val isVisible = bottomNavigationView.isVisible val isVisible = bottomNavigationView.isVisible
if (hide) { if (hide) {
bottomSheetBehavior.isHideable = true bottomSheetBehavior.isHideable = true
@ -347,10 +346,10 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
ViewCompat.setElevation(slidingPanel, 10f) ViewCompat.setElevation(slidingPanel, 10f)
ViewCompat.setElevation(bottomNavigationView, 10f) ViewCompat.setElevation(bottomNavigationView, 10f)
if (isVisible) { if (isVisible) {
bottomSheetBehavior.peekHeight = heightOfBarWithTabs println("List")
bottomNavigationView.translateYAnimate(0f) bottomSheetBehavior.peekHeight = heightOfBarWithTabs - 22
} else { } else {
bottomNavigationView.translateYAnimate(150f) println("Details")
bottomSheetBehavior.peekHeight = heightOfBar bottomSheetBehavior.peekHeight = heightOfBar
} }
} }

View file

@ -15,7 +15,6 @@
package code.name.monkey.retromusic.adapter.album package code.name.monkey.retromusic.adapter.album
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.content.res.Resources
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
@ -27,7 +26,6 @@ import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
import code.name.monkey.retromusic.glide.AlbumGlideRequest import code.name.monkey.retromusic.glide.AlbumGlideRequest
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.SortOrder import code.name.monkey.retromusic.helper.SortOrder
import code.name.monkey.retromusic.helper.menu.SongsMenuHelper import code.name.monkey.retromusic.helper.menu.SongsMenuHelper
import code.name.monkey.retromusic.interfaces.IAlbumClickListener import code.name.monkey.retromusic.interfaces.IAlbumClickListener
@ -41,14 +39,14 @@ import com.bumptech.glide.Glide
import me.zhanghai.android.fastscroll.PopupTextProvider import me.zhanghai.android.fastscroll.PopupTextProvider
open class AlbumAdapter( open class AlbumAdapter(
protected val activity: FragmentActivity, val activity: FragmentActivity,
var dataSet: List<Album>, var dataSet: List<Album>,
protected var itemLayoutRes: Int, var itemLayoutRes: Int,
ICabHolder: ICabHolder?, iCabHolder: ICabHolder?,
private val albumClickListener: IAlbumClickListener? val listener: IAlbumClickListener?
) : AbsMultiSelectAdapter<AlbumAdapter.ViewHolder, Album>( ) : AbsMultiSelectAdapter<AlbumAdapter.ViewHolder, Album>(
activity, activity,
ICabHolder, iCabHolder,
R.menu.menu_media_selection R.menu.menu_media_selection
), PopupTextProvider { ), PopupTextProvider {
@ -62,12 +60,7 @@ open class AlbumAdapter(
} }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = val view = LayoutInflater.from(activity).inflate(itemLayoutRes, parent, false)
try {
LayoutInflater.from(activity).inflate(itemLayoutRes, parent, false)
} catch (e: Resources.NotFoundException) {
LayoutInflater.from(activity).inflate(R.layout.item_grid, parent, false)
}
return createViewHolder(view, viewType) return createViewHolder(view, viewType)
} }
@ -99,7 +92,7 @@ open class AlbumAdapter(
holder.paletteColorContainer?.setBackgroundColor(color.backgroundColor) holder.paletteColorContainer?.setBackgroundColor(color.backgroundColor)
} }
holder.mask?.backgroundTintList = ColorStateList.valueOf(color.primaryTextColor) holder.mask?.backgroundTintList = ColorStateList.valueOf(color.primaryTextColor)
} holder.imageContainerCard?.setCardBackgroundColor(color.backgroundColor) }
protected open fun loadAlbumCover(album: Album, holder: ViewHolder) { protected open fun loadAlbumCover(album: Album, holder: ViewHolder) {
if (holder.image == null) { if (holder.image == null) {
@ -177,8 +170,11 @@ open class AlbumAdapter(
if (isInQuickSelectMode) { if (isInQuickSelectMode) {
toggleChecked(layoutPosition) toggleChecked(layoutPosition)
} else { } else {
ViewCompat.setTransitionName(itemView, "album") image?.let {
albumClickListener?.onAlbumClick(dataSet[layoutPosition].id, itemView) ViewCompat.setTransitionName(it, "album")
listener?.onAlbumClick(dataSet[layoutPosition].id, it)
}
} }
} }

View file

@ -155,8 +155,8 @@ class ArtistAdapter(
toggleChecked(layoutPosition) toggleChecked(layoutPosition)
} else { } else {
image?.let { image?.let {
ViewCompat.setTransitionName(itemView, "album") ViewCompat.setTransitionName(it, "artist")
IArtistClickListener.onArtist(dataSet[layoutPosition].id, itemView) IArtistClickListener.onArtist(dataSet[layoutPosition].id, it)
} }
} }
} }

View file

@ -45,7 +45,7 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
mainActivity.setBottomBarVisibility(View.GONE) mainActivity.setBottomBarVisibility(false)
mainActivity.setSupportActionBar(toolbar) mainActivity.setSupportActionBar(toolbar)
progressIndicator.hide() progressIndicator.hide()
when (args.type) { when (args.type) {

View file

@ -49,7 +49,10 @@ import code.name.monkey.retromusic.glide.ArtistGlideRequest
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
import code.name.monkey.retromusic.glide.SingleColorTarget import code.name.monkey.retromusic.glide.SingleColorTarget
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.SortOrder import code.name.monkey.retromusic.helper.SortOrder.AlbumSongSortOrder.Companion.SONG_A_Z
import code.name.monkey.retromusic.helper.SortOrder.AlbumSongSortOrder.Companion.SONG_DURATION
import code.name.monkey.retromusic.helper.SortOrder.AlbumSongSortOrder.Companion.SONG_TRACK_LIST
import code.name.monkey.retromusic.helper.SortOrder.AlbumSongSortOrder.Companion.SONG_Z_A
import code.name.monkey.retromusic.interfaces.IAlbumClickListener import code.name.monkey.retromusic.interfaces.IAlbumClickListener
import code.name.monkey.retromusic.model.Album import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Artist import code.name.monkey.retromusic.model.Artist
@ -63,6 +66,7 @@ import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.google.android.material.transition.MaterialArcMotion import com.google.android.material.transition.MaterialArcMotion
import com.google.android.material.transition.MaterialContainerTransform import com.google.android.material.transition.MaterialContainerTransform
import com.google.android.material.transition.MaterialElevationScale
import kotlinx.android.synthetic.main.fragment_album_content.* import kotlinx.android.synthetic.main.fragment_album_content.*
import kotlinx.android.synthetic.main.fragment_album_details.* import kotlinx.android.synthetic.main.fragment_album_details.*
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -101,11 +105,12 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
setHasOptionsMenu(true) setHasOptionsMenu(true)
mainActivity.setBottomBarVisibility(View.GONE) mainActivity.setBottomBarVisibility(false)
mainActivity.addMusicServiceEventListener(detailsViewModel) mainActivity.addMusicServiceEventListener(detailsViewModel)
mainActivity.setSupportActionBar(toolbar) mainActivity.setSupportActionBar(toolbar)
toolbar.title = " " toolbar.title = " "
ViewCompat.setTransitionName(container, "album") ViewCompat.setTransitionName(albumCoverContainer, "album")
postponeEnterTransition() postponeEnterTransition()
detailsViewModel.getAlbum().observe(viewLifecycleOwner, Observer { detailsViewModel.getAlbum().observe(viewLifecycleOwner, Observer {
startPostponedEnterTransition() startPostponedEnterTransition()
@ -115,6 +120,12 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
setupRecyclerView() setupRecyclerView()
artistImage.setOnClickListener { artistView -> artistImage.setOnClickListener { artistView ->
ViewCompat.setTransitionName(artistView, "artist") ViewCompat.setTransitionName(artistView, "artist")
exitTransition = MaterialElevationScale(false).apply {
duration = 300L
}
reenterTransition = MaterialElevationScale(true).apply {
duration = 300L
}
findActivityNavController(R.id.fragment_container) findActivityNavController(R.id.fragment_container)
.navigate( .navigate(
R.id.artistDetailsFragment, R.id.artistDetailsFragment,
@ -123,8 +134,9 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
FragmentNavigatorExtras(artistView to "artist") FragmentNavigatorExtras(artistView to "artist")
) )
} }
playAction.setOnClickListener { MusicPlayerRemote.openQueue(album.songs, 0, true) } playAction.setOnClickListener {
MusicPlayerRemote.openQueue(album.songs, 0, true)
}
shuffleAction.setOnClickListener { shuffleAction.setOnClickListener {
MusicPlayerRemote.openAndShuffleQueue( MusicPlayerRemote.openAndShuffleQueue(
album.songs, album.songs,
@ -139,9 +151,6 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
aboutAlbumText.maxLines = 4 aboutAlbumText.maxLines = 4
} }
} }
image.apply {
transitionName = getString(R.string.transition_album_art)
}
} }
override fun onDestroy() { override fun onDestroy() {
@ -253,7 +262,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
} }
private fun loadArtistImage(artist: Artist) { private fun loadArtistImage(artist: Artist) {
detailsViewModel.getMoreAlbums(artist).observe(viewLifecycleOwner, Observer { detailsViewModel.getMoreAlbums(artist).observe(viewLifecycleOwner, {
moreAlbums(it) moreAlbums(it)
}) })
ArtistGlideRequest.Builder.from(Glide.with(requireContext()), artist) ArtistGlideRequest.Builder.from(Glide.with(requireContext()), artist)
@ -286,6 +295,12 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
} }
override fun onAlbumClick(albumId: Long, view: View) { override fun onAlbumClick(albumId: Long, view: View) {
exitTransition = MaterialElevationScale(false).apply {
duration = 300L
}
reenterTransition = MaterialElevationScale(false).apply {
duration = 300L
}
findNavController().navigate( findNavController().navigate(
R.id.albumDetailsFragment, R.id.albumDetailsFragment,
bundleOf(EXTRA_ALBUM_ID to albumId), bundleOf(EXTRA_ALBUM_ID to albumId),
@ -354,13 +369,10 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
) )
return true return true
} }
/*Sort*/ R.id.action_sort_order_title -> sortOrder = SONG_A_Z
R.id.action_sort_order_title -> sortOrder = SortOrder.AlbumSongSortOrder.SONG_A_Z R.id.action_sort_order_title_desc -> sortOrder = SONG_Z_A
R.id.action_sort_order_title_desc -> sortOrder = SortOrder.AlbumSongSortOrder.SONG_Z_A R.id.action_sort_order_track_list -> sortOrder = SONG_TRACK_LIST
R.id.action_sort_order_track_list -> sortOrder = R.id.action_sort_order_artist_song_duration -> sortOrder = SONG_DURATION
SortOrder.AlbumSongSortOrder.SONG_TRACK_LIST
R.id.action_sort_order_artist_song_duration ->
sortOrder = SortOrder.AlbumSongSortOrder.SONG_DURATION
} }
if (sortOrder != null) { if (sortOrder != null) {
item.isChecked = true item.isChecked = true
@ -371,36 +383,34 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
private fun setUpSortOrderMenu(sortOrder: SubMenu) { private fun setUpSortOrderMenu(sortOrder: SubMenu) {
when (savedSortOrder) { when (savedSortOrder) {
SortOrder.AlbumSongSortOrder.SONG_A_Z -> sortOrder.findItem(R.id.action_sort_order_title) SONG_A_Z -> sortOrder.findItem(R.id.action_sort_order_title).isChecked = true
.isChecked = true SONG_Z_A -> sortOrder.findItem(R.id.action_sort_order_title_desc).isChecked = true
SortOrder.AlbumSongSortOrder.SONG_Z_A -> sortOrder.findItem(R.id.action_sort_order_title_desc) SONG_TRACK_LIST ->
.isChecked = true sortOrder.findItem(R.id.action_sort_order_track_list).isChecked = true
SortOrder.AlbumSongSortOrder.SONG_TRACK_LIST -> sortOrder.findItem(R.id.action_sort_order_track_list) SONG_DURATION ->
.isChecked = true sortOrder.findItem(R.id.action_sort_order_artist_song_duration).isChecked = true
SortOrder.AlbumSongSortOrder.SONG_DURATION -> sortOrder.findItem(R.id.action_sort_order_artist_song_duration)
.isChecked = true
} }
} }
private fun setSaveSortOrder(sortOrder: String) { private fun setSaveSortOrder(sortOrder: String) {
PreferenceUtil.albumDetailSongSortOrder = sortOrder PreferenceUtil.albumDetailSongSortOrder = sortOrder
val songs = when (sortOrder) { val songs = when (sortOrder) {
SortOrder.AlbumSongSortOrder.SONG_TRACK_LIST -> album.songs.sortedWith { o1, o2 -> SONG_TRACK_LIST -> album.songs.sortedWith { o1, o2 ->
o1.trackNumber.compareTo( o1.trackNumber.compareTo(
o2.trackNumber o2.trackNumber
) )
} }
SortOrder.AlbumSongSortOrder.SONG_A_Z -> album.songs.sortedWith { o1, o2 -> SONG_A_Z -> album.songs.sortedWith { o1, o2 ->
o1.title.compareTo( o1.title.compareTo(
o2.title o2.title
) )
} }
SortOrder.AlbumSongSortOrder.SONG_Z_A -> album.songs.sortedWith { o1, o2 -> SONG_Z_A -> album.songs.sortedWith { o1, o2 ->
o2.title.compareTo( o2.title.compareTo(
o1.title o1.title
) )
} }
SortOrder.AlbumSongSortOrder.SONG_DURATION -> album.songs.sortedWith { o1, o2 -> SONG_DURATION -> album.songs.sortedWith { o1, o2 ->
o1.duration.compareTo( o1.duration.compareTo(
o2.duration o2.duration
) )

View file

@ -26,7 +26,6 @@ import code.name.monkey.retromusic.adapter.album.AlbumAdapter
import code.name.monkey.retromusic.extensions.surfaceColor 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.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.interfaces.ICabHolder
@ -118,7 +117,7 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
exitTransition = MaterialElevationScale(false).apply { exitTransition = MaterialElevationScale(false).apply {
duration = 300L duration = 300L
} }
reenterTransition = MaterialElevationScale(true).apply { reenterTransition = MaterialElevationScale(false).apply {
duration = 300L duration = 300L
} }
findNavController().navigate( findNavController().navigate(
@ -154,28 +153,28 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
0, 0,
R.string.sort_order_a_z R.string.sort_order_a_z
).isChecked = ).isChecked =
currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_A_Z) currentSortOrder.equals(AlbumSortOrder.ALBUM_A_Z)
sortOrderMenu.add( sortOrderMenu.add(
0, 0,
R.id.action_album_sort_order_desc, R.id.action_album_sort_order_desc,
1, 1,
R.string.sort_order_z_a R.string.sort_order_z_a
).isChecked = ).isChecked =
currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_Z_A) currentSortOrder.equals(AlbumSortOrder.ALBUM_Z_A)
sortOrderMenu.add( sortOrderMenu.add(
0, 0,
R.id.action_album_sort_order_artist, R.id.action_album_sort_order_artist,
2, 2,
R.string.sort_order_artist R.string.sort_order_artist
).isChecked = ).isChecked =
currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_ARTIST) currentSortOrder.equals(AlbumSortOrder.ALBUM_ARTIST)
sortOrderMenu.add( sortOrderMenu.add(
0, 0,
R.id.action_album_sort_order_year, R.id.action_album_sort_order_year,
3, 3,
R.string.sort_order_year R.string.sort_order_year
).isChecked = ).isChecked =
currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_YEAR) currentSortOrder.equals(AlbumSortOrder.ALBUM_YEAR)
sortOrderMenu.setGroupCheckable(0, true, true) sortOrderMenu.setGroupCheckable(0, true, true)
} }
@ -306,16 +305,6 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
private var cab: MaterialCab? = null 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 { override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
cab?.let { cab?.let {
println("Cab") println("Cab")

View file

@ -55,6 +55,7 @@ import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.RetroUtil
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.google.android.material.transition.MaterialContainerTransform import com.google.android.material.transition.MaterialContainerTransform
import com.google.android.material.transition.MaterialElevationScale
import kotlinx.android.synthetic.main.fragment_artist_content.* import kotlinx.android.synthetic.main.fragment_artist_content.*
import kotlinx.android.synthetic.main.fragment_artist_details.* import kotlinx.android.synthetic.main.fragment_artist_details.*
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -92,13 +93,13 @@ class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_d
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
setHasOptionsMenu(true) setHasOptionsMenu(true)
mainActivity.setBottomBarVisibility(View.GONE) mainActivity.setBottomBarVisibility(false)
mainActivity.addMusicServiceEventListener(detailsViewModel) mainActivity.addMusicServiceEventListener(detailsViewModel)
mainActivity.setSupportActionBar(toolbar) mainActivity.setSupportActionBar(toolbar)
toolbar.title = null toolbar.title = null
ViewCompat.setTransitionName(container, "artist") ViewCompat.setTransitionName(artistCoverContainer, "artist")
postponeEnterTransition() postponeEnterTransition()
detailsViewModel.getArtist().observe(viewLifecycleOwner, Observer { detailsViewModel.getArtist().observe(viewLifecycleOwner, {
startPostponedEnterTransition() startPostponedEnterTransition()
showArtist(it) showArtist(it)
}) })
@ -147,14 +148,12 @@ class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_d
MusicUtil.getArtistInfoString(requireContext(), artist), MusicUtil.getArtistInfoString(requireContext(), artist),
MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(artist.songs)) MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(artist.songs))
) )
val songText = val songText = resources.getQuantityString(
resources.getQuantityString(
R.plurals.albumSongs, R.plurals.albumSongs,
artist.songCount, artist.songCount,
artist.songCount artist.songCount
) )
val albumText = val albumText = resources.getQuantityString(
resources.getQuantityString(
R.plurals.albums, R.plurals.albums,
artist.songCount, artist.songCount,
artist.songCount artist.songCount
@ -225,6 +224,12 @@ class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_d
} }
override fun onAlbumClick(albumId: Long, view: View) { override fun onAlbumClick(albumId: Long, view: View) {
exitTransition = MaterialElevationScale(false).apply {
duration = 300L
}
reenterTransition = MaterialElevationScale(false).apply {
duration = 300L
}
findNavController().navigate( findNavController().navigate(
R.id.albumDetailsFragment, R.id.albumDetailsFragment,
bundleOf(EXTRA_ALBUM_ID to albumId), bundleOf(EXTRA_ALBUM_ID to albumId),

View file

@ -167,13 +167,13 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
when (itemLayoutRes()) { when (itemLayoutRes()) {
R.layout.item_card -> subMenu.findItem(R.id.action_layout_card).isChecked = true R.layout.item_card -> subMenu.findItem(R.id.action_layout_card).isChecked = true
R.layout.item_grid -> subMenu.findItem(R.id.action_layout_normal).isChecked = true R.layout.item_grid -> subMenu.findItem(R.id.action_layout_normal).isChecked = true
R.layout.item_card_color -> R.layout.item_card_color -> subMenu.findItem(R.id.action_layout_colored_card).isChecked =
subMenu.findItem(R.id.action_layout_colored_card).isChecked = true true
R.layout.item_grid_circle -> R.layout.item_grid_circle -> subMenu.findItem(R.id.action_layout_circular).isChecked =
subMenu.findItem(R.id.action_layout_circular).isChecked = true true
R.layout.image -> subMenu.findItem(R.id.action_layout_image).isChecked = true R.layout.image -> subMenu.findItem(R.id.action_layout_image).isChecked = true
R.layout.item_image_gradient -> R.layout.item_image_gradient -> subMenu.findItem(R.id.action_layout_gradient_image).isChecked =
subMenu.findItem(R.id.action_layout_gradient_image).isChecked = true true
} }
} }
@ -285,19 +285,8 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
private var cab: MaterialCab? = null 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 { override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
cab?.let { cab?.let {
println("Cab")
if (it.isActive) { if (it.isActive) {
it.finish() it.finish()
} }

View file

@ -56,7 +56,7 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
postponeEnterTransition() postponeEnterTransition()
view.doOnPreDraw { startPostponedEnterTransition() } view.doOnPreDraw { startPostponedEnterTransition() }
mainActivity.setBottomBarVisibility(View.VISIBLE) mainActivity.setBottomBarVisibility(true)
mainActivity.setSupportActionBar(toolbar) mainActivity.setSupportActionBar(toolbar)
mainActivity.supportActionBar?.title = null mainActivity.supportActionBar?.title = null
initLayoutManager() initLayoutManager()

View file

@ -166,7 +166,7 @@ public class FoldersFragment extends AbsMainActivityFragment
@Override @Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
getMainActivity().addMusicServiceEventListener(getLibraryViewModel()); getMainActivity().addMusicServiceEventListener(getLibraryViewModel());
getMainActivity().setBottomBarVisibility(View.VISIBLE); getMainActivity().setBottomBarVisibility(true);
getMainActivity().setSupportActionBar(toolbar); getMainActivity().setSupportActionBar(toolbar);
getMainActivity().getSupportActionBar().setTitle(null); getMainActivity().getSupportActionBar().setTitle(null);
setStatusBarColorAuto(view); setStatusBarColorAuto(view);

View file

@ -62,7 +62,7 @@ class GenreDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playlist_
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
setHasOptionsMenu(true) setHasOptionsMenu(true)
mainActivity.setBottomBarVisibility(View.GONE) mainActivity.setBottomBarVisibility(false)
mainActivity.addMusicServiceEventListener(detailsViewModel) mainActivity.addMusicServiceEventListener(detailsViewModel)
mainActivity.setSupportActionBar(toolbar) mainActivity.setSupportActionBar(toolbar)
ViewCompat.setTransitionName(container, "genre") ViewCompat.setTransitionName(container, "genre")

View file

@ -48,7 +48,7 @@ class HomeFragment :
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
mainActivity.setBottomBarVisibility(View.VISIBLE) mainActivity.setBottomBarVisibility(true)
mainActivity.setSupportActionBar(toolbar) mainActivity.setSupportActionBar(toolbar)
mainActivity.supportActionBar?.title = null mainActivity.supportActionBar?.title = null
setStatusBarColorAuto(view) setStatusBarColorAuto(view)

View file

@ -41,7 +41,7 @@ class LibraryFragment : AbsMainActivityFragment(R.layout.fragment_library) {
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
setHasOptionsMenu(true) setHasOptionsMenu(true)
mainActivity.setBottomBarVisibility(View.VISIBLE) mainActivity.setBottomBarVisibility(true)
mainActivity.setSupportActionBar(toolbar) mainActivity.setSupportActionBar(toolbar)
mainActivity.supportActionBar?.title = null mainActivity.supportActionBar?.title = null
toolbar.setNavigationOnClickListener { toolbar.setNavigationOnClickListener {

View file

@ -50,7 +50,7 @@ class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playli
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
setHasOptionsMenu(true) setHasOptionsMenu(true)
mainActivity.setBottomBarVisibility(View.GONE) mainActivity.setBottomBarVisibility(false)
mainActivity.addMusicServiceEventListener(viewModel) mainActivity.addMusicServiceEventListener(viewModel)
mainActivity.setSupportActionBar(toolbar) mainActivity.setSupportActionBar(toolbar)
ViewCompat.setTransitionName(container, "playlist") ViewCompat.setTransitionName(container, "playlist")

View file

@ -17,6 +17,7 @@ package code.name.monkey.retromusic.fragments.search
import android.content.ActivityNotFoundException import android.content.ActivityNotFoundException
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.speech.RecognizerIntent import android.speech.RecognizerIntent
import android.text.Editable import android.text.Editable
@ -30,12 +31,11 @@ import androidx.recyclerview.widget.RecyclerView
import androidx.transition.TransitionManager import androidx.transition.TransitionManager
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.SearchAdapter import code.name.monkey.retromusic.adapter.SearchAdapter
import code.name.monkey.retromusic.extensions.accentColor import code.name.monkey.retromusic.extensions.*
import code.name.monkey.retromusic.extensions.dipToPix
import code.name.monkey.retromusic.extensions.focusAndShowKeyboard
import code.name.monkey.retromusic.extensions.showToast
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
import com.google.android.material.textfield.TextInputEditText import com.google.android.material.textfield.TextInputEditText
import com.google.android.material.transition.MaterialArcMotion
import com.google.android.material.transition.MaterialContainerTransform
import kotlinx.android.synthetic.main.fragment_search.* import kotlinx.android.synthetic.main.fragment_search.*
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
@ -49,18 +49,30 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
private lateinit var searchAdapter: SearchAdapter private lateinit var searchAdapter: SearchAdapter
private var query: String? = null private var query: String? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
sharedElementEnterTransition = MaterialContainerTransform().apply {
drawingViewId = R.id.fragment_container
duration = 300L
scrimColor = Color.TRANSPARENT
setAllContainerColors(requireContext().resolveColor(R.attr.colorSurface))
setPathMotion(MaterialArcMotion())
}
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
mainActivity.setBottomBarVisibility(View.GONE) mainActivity.setBottomBarVisibility(false)
mainActivity.setSupportActionBar(toolbar) mainActivity.setSupportActionBar(toolbar)
libraryViewModel.clearSearchResult() libraryViewModel.clearSearchResult()
setupRecyclerView() setupRecyclerView()
voiceSearch.setOnClickListener { startMicSearch() }
clearText.setOnClickListener { searchView.clearText() }
searchView.apply { searchView.apply {
addTextChangedListener(this@SearchFragment) addTextChangedListener(this@SearchFragment)
focusAndShowKeyboard() focusAndShowKeyboard()
} }
voiceSearch.setOnClickListener { startMicSearch() }
clearText.setOnClickListener { searchView.clearText() }
keyboardPopup.apply { keyboardPopup.apply {
accentColor() accentColor()
setOnClickListener { setOnClickListener {

View file

@ -31,9 +31,12 @@ class RetroShapeableImageView @JvmOverloads constructor(
init { init {
val typedArray = val typedArray =
context.obtainStyledAttributes(attrs, R.styleable.RetroShapeableImageView, defStyle, -1) context.obtainStyledAttributes(attrs, R.styleable.RetroShapeableImageView, defStyle, -1)
val cornerSize = val cornerSize = typedArray.getDimension(R.styleable.RetroShapeableImageView_retroCornerSize, 0f)
typedArray.getDimension(R.styleable.RetroShapeableImageView_retroCornerSize, 0f) val circleShape = typedArray.getBoolean(R.styleable.RetroShapeableImageView_circleShape, false)
updateCornerSize(cornerSize) addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ ->
val radius = width / 2f
shapeAppearanceModel = ShapeAppearanceModel().withCornerSize(radius)
}
typedArray.recycle() typedArray.recycle()
} }

View file

@ -9,7 +9,7 @@
android:padding="4dp" android:padding="4dp"
tools:ignore="MissingPrefix"> tools:ignore="MissingPrefix">
<code.name.monkey.retromusic.views.CircularImageView <code.name.monkey.retromusic.views.RetroShapeableImageView
android:id="@+id/image" android:id="@+id/image"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"

View file

@ -10,12 +10,11 @@
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:id="@+id/imageContainer" android:id="@+id/imageContainer"
android:layout_width="156dp" android:layout_width="156dp"
android:layout_height="0dp" android:layout_height="156dp"
android:layout_margin="8dp" android:layout_margin="8dp"
android:orientation="vertical" android:orientation="vertical"
app:cardCornerRadius="8dp" app:cardCornerRadius="8dp"
app:cardPreventCornerOverlap="true" app:cardPreventCornerOverlap="true"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">

View file

@ -20,8 +20,8 @@
<string name="action_go_to_genre">Aller au genre</string> <string name="action_go_to_genre">Aller au genre</string>
<string name="action_go_to_start_directory">Aller au dossier de départ</string> <string name="action_go_to_start_directory">Aller au dossier de départ</string>
<string name="action_grant">Accorder</string> <string name="action_grant">Accorder</string>
<string name="action_grid_size">Taille de l'affichage</string> <string name="action_grid_size">Taille de l\'affichage</string>
<string name="action_grid_size_land">Taille de l'affichage (paysage)</string> <string name="action_grid_size_land">Taille de l\'affichage (paysage)</string>
<string name="action_new_playlist">Nouvelle liste de lecture…</string> <string name="action_new_playlist">Nouvelle liste de lecture…</string>
<string name="action_next">Suivant</string> <string name="action_next">Suivant</string>
<string name="action_play">Lecture</string> <string name="action_play">Lecture</string>
@ -235,7 +235,6 @@
<string name="grid_size_6">6</string> <string name="grid_size_6">6</string>
<string name="grid_size_7">7</string> <string name="grid_size_7">7</string>
<string name="grid_size_8">8</string> <string name="grid_size_8">8</string>
<string name="grid_style_label">Les Grilles &amp; Le Style</string> <string name="grid_style_label">Les Grilles &amp; Le Style</string>
<string name="hinge">Charnière</string> <string name="hinge">Charnière</string>
@ -615,7 +614,6 @@
<string name="welcome">Bienvenue,</string> <string name="welcome">Bienvenue,</string>
<string name="what_do_you_want_to_share">Que souhaitez-vous partager ?</string> <string name="what_do_you_want_to_share">Que souhaitez-vous partager ?</string>
<string name="whats_new">Quoi de neuf</string> <string name="whats_new">Quoi de neuf</string>

View file

@ -12,7 +12,7 @@
<dimen name="list_item_image_icon_padding">8dp</dimen> <dimen name="list_item_image_icon_padding">8dp</dimen>
<dimen name="mini_player_height">48dp</dimen> <dimen name="mini_player_height">56dp</dimen>
<dimen name="app_widget_classic_height">96dp</dimen> <dimen name="app_widget_classic_height">96dp</dimen>
<dimen name="app_widget_classic_image_size">96dp</dimen> <dimen name="app_widget_classic_image_size">96dp</dimen>
@ -34,7 +34,7 @@
<dimen name="now_playing_top_margin">12dp</dimen> <dimen name="now_playing_top_margin">12dp</dimen>
<dimen name="icon_notification_dimen">32dp</dimen> <dimen name="icon_notification_dimen">32dp</dimen>
<dimen name="mini_player_height_expanded">104dp</dimen> <dimen name="mini_player_height_expanded">112dp</dimen>
<dimen name="toolbar_margin_horizontal">8dp</dimen> <dimen name="toolbar_margin_horizontal">8dp</dimen>
<dimen name="toolbar_height">48dp</dimen> <dimen name="toolbar_height">48dp</dimen>
<dimen name="item_song_height">52dp</dimen> <dimen name="item_song_height">52dp</dimen>

View file

@ -15,5 +15,6 @@
<resources> <resources>
<declare-styleable name="RetroShapeableImageView"> <declare-styleable name="RetroShapeableImageView">
<attr name="retroCornerSize" format="dimension" /> <attr name="retroCornerSize" format="dimension" />
<attr name="circleShape" format="boolean" />
</declare-styleable> </declare-styleable>
</resources> </resources>