diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt index 1e0430ee..b017e4d3 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt @@ -132,7 +132,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() { val navbarHeight = RetroUtil.getNavigationBarHeight() updatePadding(bottom = navbarHeight) binding.bottomNavigationView.updateLayoutParams { - height = dip(R.dimen.mini_player_height) + navbarHeight + height = dip(R.dimen.bottom_nav_height) + navbarHeight } } } @@ -188,7 +188,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() { } open fun onPanelExpanded() { - if (nowPlayingScreen == Blur ) { + if (nowPlayingScreen == Blur) { super.setLightStatusbar(false) } else { super.setLightStatusbarAuto(surfaceColor()) @@ -289,14 +289,12 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() { fun hideBottomBar(hide: Boolean) { val heightOfBar = RetroUtil.getNavigationBarHeight() + if (MusicPlayerRemote.isCasting) dip(R.dimen.cast_mini_player_height) else dip(R.dimen.mini_player_height) - val heightOfBarWithTabs = RetroUtil.getNavigationBarHeight() + - if (MusicPlayerRemote.isCasting) dip(R.dimen.mini_cast_player_height_expanded) else dip( - R.dimen.mini_player_height_expanded - ) + val heightOfBarWithTabs = heightOfBar + dip(R.dimen.bottom_nav_height) val isVisible = binding.bottomNavigationView.isVisible if (hide) { bottomSheetBehavior.isHideable = true bottomSheetBehavior.peekHeight = 0 + libraryViewModel.setFabMargin(if (isVisible) dip(R.dimen.bottom_nav_height) else 0) ViewCompat.setElevation(binding.slidingPanel, 0f) ViewCompat.setElevation(binding.bottomNavigationView, 10f) collapsePanel() @@ -310,9 +308,11 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() { if (bottomSheetBehavior.state != STATE_EXPANDED) getBottomNavigationView().translateYAnimate(0F) bottomSheetBehavior.peekHeightAnimate(heightOfBarWithTabs) + libraryViewModel.setFabMargin(heightOfBarWithTabs - RetroUtil.getNavigationBarHeight()) } else { println("Details") bottomSheetBehavior.peekHeight = heightOfBar + libraryViewModel.setFabMargin(heightOfBar - RetroUtil.getNavigationBarHeight()) } } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt index c474823f..1db181b1 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt @@ -23,6 +23,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.interfaces.IMusicServiceEventListener import code.name.monkey.retromusic.model.* import code.name.monkey.retromusic.repository.RealRepository +import code.name.monkey.retromusic.util.DensityUtil import code.name.monkey.retromusic.util.PreferenceUtil import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.launch @@ -40,6 +41,7 @@ class LibraryViewModel( private val legacyPlaylists = MutableLiveData>() private val genres = MutableLiveData>() private val searchResults = MutableLiveData>() + private val fabMargin = MutableLiveData(0) val paletteColor: LiveData = _paletteColor init { @@ -85,6 +87,10 @@ class LibraryViewModel( return home } + fun getFabMargin(): LiveData { + return fabMargin + } + private fun fetchSongs() { viewModelScope.launch(IO) { songs.postValue(repository.allSongs()) @@ -328,6 +334,14 @@ class LibraryViewModel( } } } + + fun setFabMargin(bottomMargin: Int) { + fabMargin.postValue( + // Normal Margin + DensityUtil.dip2px(App.getContext(), 16F) + + bottomMargin + ) + } } enum class ReloadType { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsRecyclerViewFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsRecyclerViewFragment.kt index a9fa457c..32e8e4b4 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsRecyclerViewFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsRecyclerViewFragment.kt @@ -22,6 +22,7 @@ import androidx.appcompat.widget.Toolbar import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.core.view.doOnPreDraw import androidx.core.view.isVisible +import androidx.core.view.updateLayoutParams import androidx.core.view.updatePadding import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.RecyclerView @@ -85,6 +86,11 @@ abstract class AbsRecyclerViewFragment, LM : Recycle } else { binding.shuffleButton.isVisible = false } + libraryViewModel.getFabMargin().observe(viewLifecycleOwner, { + binding.shuffleButton.updateLayoutParams { + bottomMargin = it + } + }) } open fun onShuffleClicked() { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/queue/PlayingQueueFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/queue/PlayingQueueFragment.kt index b6a266b9..670fee51 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/queue/PlayingQueueFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/queue/PlayingQueueFragment.kt @@ -52,7 +52,7 @@ class PlayingQueueFragment : AbsRecyclerViewFragment { + bottomMargin = it + } + }) } private fun setupChips() { diff --git a/app/src/main/res/layout/fragment_main_recycler.xml b/app/src/main/res/layout/fragment_main_recycler.xml index ac07f625..2c2174b6 100644 --- a/app/src/main/res/layout/fragment_main_recycler.xml +++ b/app/src/main/res/layout/fragment_main_recycler.xml @@ -85,6 +85,5 @@ android:layout_height="wrap_content" android:layout_gravity="bottom|right" app:srcCompat="@drawable/ic_shuffle" - android:layout_marginBottom="116dp" android:layout_marginHorizontal="16dp"/> \ No newline at end of file diff --git a/app/src/main/res/layout/sliding_music_panel_layout.xml b/app/src/main/res/layout/sliding_music_panel_layout.xml index 0db8165f..b384d988 100644 --- a/app/src/main/res/layout/sliding_music_panel_layout.xml +++ b/app/src/main/res/layout/sliding_music_panel_layout.xml @@ -56,7 +56,7 @@ 10dp 20dp 64dp + 56dp