Added NavigationRailView for Landscape
This commit is contained in:
parent
7efbbc3f11
commit
d2a7588861
11 changed files with 100 additions and 34 deletions
|
@ -78,9 +78,9 @@ class MainActivity : AbsCastActivity() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
navController.graph = navGraph
|
navController.graph = navGraph
|
||||||
bottomNavigationView.setupWithNavController(navController)
|
navigationView.setupWithNavController(navController)
|
||||||
// Scroll Fragment to top
|
// Scroll Fragment to top
|
||||||
bottomNavigationView.setOnItemReselectedListener {
|
navigationView.setOnItemReselectedListener {
|
||||||
currentFragment(R.id.fragment_container).apply {
|
currentFragment(R.id.fragment_container).apply {
|
||||||
if (this is IScrollHelper) {
|
if (this is IScrollHelper) {
|
||||||
scrollToTop()
|
scrollToTop()
|
||||||
|
|
|
@ -66,6 +66,7 @@ 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.util.ViewUtil
|
import code.name.monkey.retromusic.util.ViewUtil
|
||||||
import code.name.monkey.retromusic.util.logD
|
import code.name.monkey.retromusic.util.logD
|
||||||
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior.*
|
import com.google.android.material.bottomsheet.BottomSheetBehavior.*
|
||||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
|
@ -127,7 +128,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
||||||
}
|
}
|
||||||
STATE_SETTLING, STATE_DRAGGING -> {
|
STATE_SETTLING, STATE_DRAGGING -> {
|
||||||
if (fromNotification) {
|
if (fromNotification) {
|
||||||
binding.bottomNavigationView.bringToFront()
|
binding.navigationView.bringToFront()
|
||||||
fromNotification = false
|
fromNotification = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,7 +163,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
||||||
updateColor()
|
updateColor()
|
||||||
if (!PreferenceUtil.materialYou) {
|
if (!PreferenceUtil.materialYou) {
|
||||||
binding.slidingPanel.backgroundTintList = ColorStateList.valueOf(darkAccentColor())
|
binding.slidingPanel.backgroundTintList = ColorStateList.valueOf(darkAccentColor())
|
||||||
bottomNavigationView.backgroundTintList = ColorStateList.valueOf(darkAccentColor())
|
navigationView.backgroundTintList = ColorStateList.valueOf(darkAccentColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
navigationBarColor = surfaceColor()
|
navigationBarColor = surfaceColor()
|
||||||
|
@ -230,7 +231,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
||||||
updateTabs()
|
updateTabs()
|
||||||
}
|
}
|
||||||
TAB_TEXT_MODE -> {
|
TAB_TEXT_MODE -> {
|
||||||
bottomNavigationView.labelVisibilityMode = PreferenceUtil.tabTitleMode
|
navigationView.labelVisibilityMode = PreferenceUtil.tabTitleMode
|
||||||
}
|
}
|
||||||
TOGGLE_FULL_SCREEN -> {
|
TOGGLE_FULL_SCREEN -> {
|
||||||
if (!PreferenceUtil.isFullScreenMode) exitFullscreen()
|
if (!PreferenceUtil.isFullScreenMode) exitFullscreen()
|
||||||
|
@ -258,8 +259,10 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
||||||
val alpha = 1 - progress
|
val alpha = 1 - progress
|
||||||
miniPlayerFragment?.view?.alpha = 1 - (progress / 0.2F)
|
miniPlayerFragment?.view?.alpha = 1 - (progress / 0.2F)
|
||||||
miniPlayerFragment?.view?.isGone = alpha == 0f
|
miniPlayerFragment?.view?.isGone = alpha == 0f
|
||||||
binding.bottomNavigationView.translationY = progress * 500
|
if (!isLandscape) {
|
||||||
binding.bottomNavigationView.alpha = alpha
|
binding.navigationView.translationY = progress * 500
|
||||||
|
binding.navigationView.alpha = alpha
|
||||||
|
}
|
||||||
binding.playerFragmentContainer.alpha = (progress - 0.2F) / 0.2F
|
binding.playerFragmentContainer.alpha = (progress - 0.2F) / 0.2F
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,10 +319,12 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
val bottomNavigationView get() = binding.bottomNavigationView
|
val navigationView get() = binding.navigationView
|
||||||
|
|
||||||
val slidingPanel get() = binding.slidingPanel
|
val slidingPanel get() = binding.slidingPanel
|
||||||
|
|
||||||
|
val isBottomNavVisible get() = navigationView.isVisible && navigationView is BottomNavigationView
|
||||||
|
|
||||||
override fun onServiceConnected() {
|
override fun onServiceConnected() {
|
||||||
super.onServiceConnected()
|
super.onServiceConnected()
|
||||||
hideBottomSheet(false)
|
hideBottomSheet(false)
|
||||||
|
@ -386,18 +391,18 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateTabs() {
|
fun updateTabs() {
|
||||||
binding.bottomNavigationView.menu.clear()
|
binding.navigationView.menu.clear()
|
||||||
val currentTabs: List<CategoryInfo> = PreferenceUtil.libraryCategory
|
val currentTabs: List<CategoryInfo> = PreferenceUtil.libraryCategory
|
||||||
for (tab in currentTabs) {
|
for (tab in currentTabs) {
|
||||||
if (tab.visible) {
|
if (tab.visible) {
|
||||||
val menu = tab.category
|
val menu = tab.category
|
||||||
binding.bottomNavigationView.menu.add(0, menu.id, 0, menu.stringRes)
|
binding.navigationView.menu.add(0, menu.id, 0, menu.stringRes)
|
||||||
.setIcon(menu.icon)
|
.setIcon(menu.icon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (binding.bottomNavigationView.menu.size() == 1) {
|
if (binding.navigationView.menu.size() == 1) {
|
||||||
isInOneTabMode = true
|
isInOneTabMode = true
|
||||||
binding.bottomNavigationView.isVisible = false
|
binding.navigationView.isVisible = false
|
||||||
} else {
|
} else {
|
||||||
isInOneTabMode = false
|
isInOneTabMode = false
|
||||||
}
|
}
|
||||||
|
@ -423,33 +428,33 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (visible xor bottomNavigationView.isVisible) {
|
if (visible xor navigationView.isVisible) {
|
||||||
val mAnimate = animate && bottomSheetBehavior.state == STATE_COLLAPSED
|
val mAnimate = animate && bottomSheetBehavior.state == STATE_COLLAPSED
|
||||||
if (mAnimate) {
|
if (mAnimate) {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
binding.bottomNavigationView.bringToFront()
|
binding.navigationView.bringToFront()
|
||||||
binding.bottomNavigationView.show()
|
binding.navigationView.show()
|
||||||
} else {
|
} else {
|
||||||
binding.bottomNavigationView.hide()
|
binding.navigationView.hide()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binding.bottomNavigationView.isVisible = false
|
binding.navigationView.isVisible = visible
|
||||||
if (visible && bottomSheetBehavior.state != STATE_EXPANDED) {
|
if (visible && bottomSheetBehavior.state != STATE_EXPANDED) {
|
||||||
binding.bottomNavigationView.bringToFront()
|
binding.navigationView.bringToFront()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hideBottomSheet(
|
hideBottomSheet(
|
||||||
hide = hideBottomSheet,
|
hide = hideBottomSheet,
|
||||||
animate = animate,
|
animate = animate,
|
||||||
isBottomNavVisible = visible
|
isBottomNavVisible = visible && navigationView is BottomNavigationView
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hideBottomSheet(
|
fun hideBottomSheet(
|
||||||
hide: Boolean,
|
hide: Boolean,
|
||||||
animate: Boolean = false,
|
animate: Boolean = false,
|
||||||
isBottomNavVisible: Boolean = bottomNavigationView.isVisible,
|
isBottomNavVisible: Boolean = navigationView.isVisible && navigationView is BottomNavigationView,
|
||||||
) {
|
) {
|
||||||
val heightOfBar = windowInsets.getBottomInsets() + dip(R.dimen.mini_player_height)
|
val heightOfBar = windowInsets.getBottomInsets() + dip(R.dimen.mini_player_height)
|
||||||
val heightOfBarWithTabs = heightOfBar + dip(R.dimen.bottom_nav_height)
|
val heightOfBarWithTabs = heightOfBar + dip(R.dimen.bottom_nav_height)
|
||||||
|
@ -463,7 +468,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
||||||
} else {
|
} else {
|
||||||
if (MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
if (MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||||
binding.slidingPanel.elevation = 0F
|
binding.slidingPanel.elevation = 0F
|
||||||
binding.bottomNavigationView.elevation = 5F
|
binding.navigationView.elevation = 5F
|
||||||
if (isBottomNavVisible) {
|
if (isBottomNavVisible) {
|
||||||
logD("List")
|
logD("List")
|
||||||
if (animate) {
|
if (animate) {
|
||||||
|
|
|
@ -38,6 +38,8 @@ import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.card.MaterialCardView
|
import com.google.android.material.card.MaterialCardView
|
||||||
|
import com.google.android.material.navigation.NavigationBarView
|
||||||
|
import com.google.android.material.navigationrail.NavigationRailView
|
||||||
import dev.chrisbanes.insetter.applyInsetter
|
import dev.chrisbanes.insetter.applyInsetter
|
||||||
|
|
||||||
const val ANIM_DURATION = 300L
|
const val ANIM_DURATION = 300L
|
||||||
|
@ -74,7 +76,8 @@ fun EditText.appHandleColor(): EditText {
|
||||||
* Instead, take a snapshot of the view, and animate this in, only changing the visibility (and
|
* Instead, take a snapshot of the view, and animate this in, only changing the visibility (and
|
||||||
* thus layout) when the animation completes.
|
* thus layout) when the animation completes.
|
||||||
*/
|
*/
|
||||||
fun BottomNavigationView.show() {
|
fun NavigationBarView.show() {
|
||||||
|
if (this is NavigationRailView) return
|
||||||
if (isVisible) return
|
if (isVisible) return
|
||||||
|
|
||||||
val parent = parent as ViewGroup
|
val parent = parent as ViewGroup
|
||||||
|
@ -118,7 +121,8 @@ fun BottomNavigationView.show() {
|
||||||
* Instead, take a snapshot, instantly hide the view (so content lays out to fill), then animate
|
* Instead, take a snapshot, instantly hide the view (so content lays out to fill), then animate
|
||||||
* out the snapshot.
|
* out the snapshot.
|
||||||
*/
|
*/
|
||||||
fun BottomNavigationView.hide() {
|
fun NavigationBarView.hide() {
|
||||||
|
if (this is NavigationRailView) return
|
||||||
if (isGone) return
|
if (isGone) return
|
||||||
|
|
||||||
if (!isLaidOut) {
|
if (!isLaidOut) {
|
||||||
|
|
|
@ -147,7 +147,7 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkForMargins() {
|
private fun checkForMargins() {
|
||||||
if (mainActivity.bottomNavigationView.isVisible) {
|
if (mainActivity.isBottomNavVisible) {
|
||||||
binding.recyclerView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
binding.recyclerView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
bottomMargin = dip(R.dimen.bottom_nav_height)
|
bottomMargin = dip(R.dimen.bottom_nav_height)
|
||||||
}
|
}
|
||||||
|
|
|
@ -407,7 +407,7 @@ class FoldersFragment : AbsMainActivityFragment(R.layout.fragment_folder),
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkForMargins() {
|
private fun checkForMargins() {
|
||||||
if (mainActivity.bottomNavigationView.isVisible) {
|
if (mainActivity.isBottomNavVisible) {
|
||||||
binding.recyclerView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
binding.recyclerView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
bottomMargin = dip(R.dimen.bottom_nav_height)
|
bottomMargin = dip(R.dimen.bottom_nav_height)
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ class HomeFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkForMargins() {
|
private fun checkForMargins() {
|
||||||
if (mainActivity.bottomNavigationView.isVisible) {
|
if (mainActivity.isBottomNavVisible) {
|
||||||
binding.recyclerView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
binding.recyclerView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
bottomMargin = dip(R.dimen.bottom_nav_height)
|
bottomMargin = dip(R.dimen.bottom_nav_height)
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ class LibraryFragment : AbsMainActivityFragment(R.layout.fragment_library) {
|
||||||
navGraph.setStartDestination(categoryInfo.category.id)
|
navGraph.setStartDestination(categoryInfo.category.id)
|
||||||
}
|
}
|
||||||
navController.graph = navGraph
|
navController.graph = navGraph
|
||||||
NavigationUI.setupWithNavController(mainActivity.bottomNavigationView, navController)
|
NavigationUI.setupWithNavController(mainActivity.navigationView, navController)
|
||||||
navController.addOnDestinationChangedListener { _, _, _ ->
|
navController.addOnDestinationChangedListener { _, _, _ ->
|
||||||
binding.appBarLayout.setExpanded(true, true)
|
binding.appBarLayout.setExpanded(true, true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search),
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkForMargins() {
|
private fun checkForMargins() {
|
||||||
if (mainActivity.bottomNavigationView.isVisible) {
|
if (mainActivity.isBottomNavVisible) {
|
||||||
binding.recyclerView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
binding.recyclerView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
bottomMargin = dip(R.dimen.bottom_nav_height)
|
bottomMargin = dip(R.dimen.bottom_nav_height)
|
||||||
}
|
}
|
||||||
|
|
58
app/src/main/res/layout-land/sliding_music_panel_layout.xml
Normal file
58
app/src/main/res/layout-land/sliding_music_panel_layout.xml
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/mainContent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<com.google.android.material.navigationrail.NavigationRailView
|
||||||
|
android:id="@+id/navigationView"
|
||||||
|
style="@style/Widget.Material3.NavigationRailView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:itemHorizontalTranslationEnabled="false"
|
||||||
|
app:menu="@menu/bottom_navigation_main"
|
||||||
|
tools:viewBindingType="com.google.android.material.navigation.NavigationBarView" />
|
||||||
|
|
||||||
|
<androidx.fragment.app.FragmentContainerView
|
||||||
|
android:id="@+id/fragment_container"
|
||||||
|
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/colorSurface"
|
||||||
|
app:defaultNavHost="true"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:layout="@layout/fragment_home" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/slidingPanel"
|
||||||
|
style="@style/BottomSheetStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:behavior_hideable="true"
|
||||||
|
app:behavior_peekHeight="@dimen/mini_player_height"
|
||||||
|
app:enableEdgeToEdge="true"
|
||||||
|
app:gestureInsetBottomIgnored="true"
|
||||||
|
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/playerFragmentContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/miniPlayerFragment"
|
||||||
|
android:name="code.name.monkey.retromusic.fragments.other.MiniPlayerFragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/mini_player_height"
|
||||||
|
tools:layout="@layout/fragment_mini_player" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -43,14 +43,13 @@
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<code.name.monkey.retromusic.views.BottomNavigationBarTinted
|
<code.name.monkey.retromusic.views.BottomNavigationBarTinted
|
||||||
android:id="@+id/bottomNavigationView"
|
android:id="@+id/navigationView"
|
||||||
style="@style/Widget.Material3.BottomNavigationView"
|
style="@style/Widget.Material3.BottomNavigationView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:minHeight="@dimen/bottom_nav_height"
|
android:minHeight="@dimen/bottom_nav_height"
|
||||||
app:itemHorizontalTranslationEnabled="false"
|
app:itemHorizontalTranslationEnabled="false"
|
||||||
app:itemPaddingBottom="8dp"
|
app:menu="@menu/bottom_navigation_main"
|
||||||
app:itemPaddingTop="8dp"
|
tools:viewBindingType="com.google.android.material.navigation.NavigationBarView"/>
|
||||||
app:menu="@menu/bottom_navigation_main" />
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -12,8 +12,8 @@
|
||||||
<dimen name="list_item_image_icon_padding">8dp</dimen>
|
<dimen name="list_item_image_icon_padding">8dp</dimen>
|
||||||
|
|
||||||
<dimen name="mini_player_height">56dp</dimen>
|
<dimen name="mini_player_height">56dp</dimen>
|
||||||
<dimen name="bottom_nav_height">72dp</dimen>
|
<dimen name="bottom_nav_height">80dp</dimen>
|
||||||
<dimen name="bottom_nav_mini_player_height">128dp</dimen>
|
<dimen name="bottom_nav_mini_player_height">136dp</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>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue