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

View file

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

View file

@ -155,8 +155,8 @@ class ArtistAdapter(
toggleChecked(layoutPosition)
} else {
image?.let {
ViewCompat.setTransitionName(itemView, "album")
IArtistClickListener.onArtist(dataSet[layoutPosition].id, itemView)
ViewCompat.setTransitionName(it, "artist")
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?) {
super.onActivityCreated(savedInstanceState)
mainActivity.setBottomBarVisibility(View.GONE)
mainActivity.setBottomBarVisibility(false)
mainActivity.setSupportActionBar(toolbar)
progressIndicator.hide()
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.SingleColorTarget
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.model.Album
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.google.android.material.transition.MaterialArcMotion
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_details.*
import kotlinx.coroutines.Dispatchers
@ -101,11 +105,12 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setHasOptionsMenu(true)
mainActivity.setBottomBarVisibility(View.GONE)
mainActivity.setBottomBarVisibility(false)
mainActivity.addMusicServiceEventListener(detailsViewModel)
mainActivity.setSupportActionBar(toolbar)
toolbar.title = " "
ViewCompat.setTransitionName(container, "album")
ViewCompat.setTransitionName(albumCoverContainer, "album")
postponeEnterTransition()
detailsViewModel.getAlbum().observe(viewLifecycleOwner, Observer {
startPostponedEnterTransition()
@ -115,6 +120,12 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
setupRecyclerView()
artistImage.setOnClickListener { artistView ->
ViewCompat.setTransitionName(artistView, "artist")
exitTransition = MaterialElevationScale(false).apply {
duration = 300L
}
reenterTransition = MaterialElevationScale(true).apply {
duration = 300L
}
findActivityNavController(R.id.fragment_container)
.navigate(
R.id.artistDetailsFragment,
@ -123,8 +134,9 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
FragmentNavigatorExtras(artistView to "artist")
)
}
playAction.setOnClickListener { MusicPlayerRemote.openQueue(album.songs, 0, true) }
playAction.setOnClickListener {
MusicPlayerRemote.openQueue(album.songs, 0, true)
}
shuffleAction.setOnClickListener {
MusicPlayerRemote.openAndShuffleQueue(
album.songs,
@ -139,9 +151,6 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
aboutAlbumText.maxLines = 4
}
}
image.apply {
transitionName = getString(R.string.transition_album_art)
}
}
override fun onDestroy() {
@ -253,7 +262,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
}
private fun loadArtistImage(artist: Artist) {
detailsViewModel.getMoreAlbums(artist).observe(viewLifecycleOwner, Observer {
detailsViewModel.getMoreAlbums(artist).observe(viewLifecycleOwner, {
moreAlbums(it)
})
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) {
exitTransition = MaterialElevationScale(false).apply {
duration = 300L
}
reenterTransition = MaterialElevationScale(false).apply {
duration = 300L
}
findNavController().navigate(
R.id.albumDetailsFragment,
bundleOf(EXTRA_ALBUM_ID to albumId),
@ -354,13 +369,10 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
)
return true
}
/*Sort*/
R.id.action_sort_order_title -> sortOrder = SortOrder.AlbumSongSortOrder.SONG_A_Z
R.id.action_sort_order_title_desc -> sortOrder = SortOrder.AlbumSongSortOrder.SONG_Z_A
R.id.action_sort_order_track_list -> sortOrder =
SortOrder.AlbumSongSortOrder.SONG_TRACK_LIST
R.id.action_sort_order_artist_song_duration ->
sortOrder = SortOrder.AlbumSongSortOrder.SONG_DURATION
R.id.action_sort_order_title -> sortOrder = SONG_A_Z
R.id.action_sort_order_title_desc -> sortOrder = SONG_Z_A
R.id.action_sort_order_track_list -> sortOrder = SONG_TRACK_LIST
R.id.action_sort_order_artist_song_duration -> sortOrder = SONG_DURATION
}
if (sortOrder != null) {
item.isChecked = true
@ -371,36 +383,34 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
private fun setUpSortOrderMenu(sortOrder: SubMenu) {
when (savedSortOrder) {
SortOrder.AlbumSongSortOrder.SONG_A_Z -> sortOrder.findItem(R.id.action_sort_order_title)
.isChecked = true
SortOrder.AlbumSongSortOrder.SONG_Z_A -> sortOrder.findItem(R.id.action_sort_order_title_desc)
.isChecked = true
SortOrder.AlbumSongSortOrder.SONG_TRACK_LIST -> sortOrder.findItem(R.id.action_sort_order_track_list)
.isChecked = true
SortOrder.AlbumSongSortOrder.SONG_DURATION -> sortOrder.findItem(R.id.action_sort_order_artist_song_duration)
.isChecked = true
SONG_A_Z -> sortOrder.findItem(R.id.action_sort_order_title).isChecked = true
SONG_Z_A -> sortOrder.findItem(R.id.action_sort_order_title_desc).isChecked = true
SONG_TRACK_LIST ->
sortOrder.findItem(R.id.action_sort_order_track_list).isChecked = true
SONG_DURATION ->
sortOrder.findItem(R.id.action_sort_order_artist_song_duration).isChecked = true
}
}
private fun setSaveSortOrder(sortOrder: String) {
PreferenceUtil.albumDetailSongSortOrder = 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(
o2.trackNumber
)
}
SortOrder.AlbumSongSortOrder.SONG_A_Z -> album.songs.sortedWith { o1, o2 ->
SONG_A_Z -> album.songs.sortedWith { o1, o2 ->
o1.title.compareTo(
o2.title
)
}
SortOrder.AlbumSongSortOrder.SONG_Z_A -> album.songs.sortedWith { o1, o2 ->
SONG_Z_A -> album.songs.sortedWith { o1, o2 ->
o2.title.compareTo(
o1.title
)
}
SortOrder.AlbumSongSortOrder.SONG_DURATION -> album.songs.sortedWith { o1, o2 ->
SONG_DURATION -> album.songs.sortedWith { o1, o2 ->
o1.duration.compareTo(
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.fragments.ReloadType
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.interfaces.IAlbumClickListener
import code.name.monkey.retromusic.interfaces.ICabHolder
@ -118,7 +117,7 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
exitTransition = MaterialElevationScale(false).apply {
duration = 300L
}
reenterTransition = MaterialElevationScale(true).apply {
reenterTransition = MaterialElevationScale(false).apply {
duration = 300L
}
findNavController().navigate(
@ -154,28 +153,28 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
0,
R.string.sort_order_a_z
).isChecked =
currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_A_Z)
currentSortOrder.equals(AlbumSortOrder.ALBUM_A_Z)
sortOrderMenu.add(
0,
R.id.action_album_sort_order_desc,
1,
R.string.sort_order_z_a
).isChecked =
currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_Z_A)
currentSortOrder.equals(AlbumSortOrder.ALBUM_Z_A)
sortOrderMenu.add(
0,
R.id.action_album_sort_order_artist,
2,
R.string.sort_order_artist
).isChecked =
currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_ARTIST)
currentSortOrder.equals(AlbumSortOrder.ALBUM_ARTIST)
sortOrderMenu.add(
0,
R.id.action_album_sort_order_year,
3,
R.string.sort_order_year
).isChecked =
currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_YEAR)
currentSortOrder.equals(AlbumSortOrder.ALBUM_YEAR)
sortOrderMenu.setGroupCheckable(0, true, true)
}
@ -306,16 +305,6 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
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")

View file

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

View file

@ -167,13 +167,13 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
when (itemLayoutRes()) {
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_card_color ->
subMenu.findItem(R.id.action_layout_colored_card).isChecked = true
R.layout.item_grid_circle ->
subMenu.findItem(R.id.action_layout_circular).isChecked = true
R.layout.item_card_color -> subMenu.findItem(R.id.action_layout_colored_card).isChecked =
true
R.layout.item_grid_circle -> subMenu.findItem(R.id.action_layout_circular).isChecked =
true
R.layout.image -> subMenu.findItem(R.id.action_layout_image).isChecked = true
R.layout.item_image_gradient ->
subMenu.findItem(R.id.action_layout_gradient_image).isChecked = true
R.layout.item_image_gradient -> subMenu.findItem(R.id.action_layout_gradient_image).isChecked =
true
}
}
@ -285,19 +285,8 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
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()
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -17,6 +17,7 @@ package code.name.monkey.retromusic.fragments.search
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.speech.RecognizerIntent
import android.text.Editable
@ -30,12 +31,11 @@ import androidx.recyclerview.widget.RecyclerView
import androidx.transition.TransitionManager
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.SearchAdapter
import code.name.monkey.retromusic.extensions.accentColor
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.extensions.*
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
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 java.util.*
import kotlin.collections.ArrayList
@ -49,18 +49,30 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
private lateinit var searchAdapter: SearchAdapter
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?) {
super.onViewCreated(view, savedInstanceState)
mainActivity.setBottomBarVisibility(View.GONE)
mainActivity.setBottomBarVisibility(false)
mainActivity.setSupportActionBar(toolbar)
libraryViewModel.clearSearchResult()
setupRecyclerView()
voiceSearch.setOnClickListener { startMicSearch() }
clearText.setOnClickListener { searchView.clearText() }
searchView.apply {
addTextChangedListener(this@SearchFragment)
focusAndShowKeyboard()
}
voiceSearch.setOnClickListener { startMicSearch() }
clearText.setOnClickListener { searchView.clearText() }
keyboardPopup.apply {
accentColor()
setOnClickListener {

View file

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

View file

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

View file

@ -10,12 +10,11 @@
<com.google.android.material.card.MaterialCardView
android:id="@+id/imageContainer"
android:layout_width="156dp"
android:layout_height="0dp"
android:layout_height="156dp"
android:layout_margin="8dp"
android:orientation="vertical"
app:cardCornerRadius="8dp"
app:cardPreventCornerOverlap="true"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="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_start_directory">Aller au dossier de départ</string>
<string name="action_grant">Accorder</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">Taille de l\'affichage</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_next">Suivant</string>
<string name="action_play">Lecture</string>
@ -235,7 +235,6 @@
<string name="grid_size_6">6</string>
<string name="grid_size_7">7</string>
<string name="grid_size_8">8</string>
<string name="grid_style_label">Les Grilles &amp; Le Style</string>
<string name="hinge">Charnière</string>
@ -615,7 +614,6 @@
<string name="welcome">Bienvenue,</string>
<string name="what_do_you_want_to_share">Que souhaitez-vous partager ?</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="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_image_size">96dp</dimen>
@ -34,7 +34,7 @@
<dimen name="now_playing_top_margin">12dp</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_height">48dp</dimen>
<dimen name="item_song_height">52dp</dimen>

View file

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