Switch from ViewPager to BottomNavigationView

Use BottomNavigationView as the main navigator of Auxio instead of a ViewPager + BottomNavigationView, primarily to fix some memory leaks and give Auxio a better UI design overall.
This commit is contained in:
OxygenCobalt
2020-11-16 21:09:55 -07:00
parent 212ffbf2c7
commit c3a61e6071
14 changed files with 206 additions and 106 deletions
@@ -15,6 +15,8 @@
type="org.oxycblt.auxio.playback.PlaybackViewModel" />
</data>
<!-- TODO: Fix elevation not showing -->
<androidx.constraintlayout.widget.ConstraintLayout
android:animateLayoutChanges="true"
android:background="@drawable/ui_ripple"
+23 -20
View File
@@ -4,43 +4,46 @@
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainFragment">
<LinearLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:orientation="vertical">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/main_view_pager"
<androidx.fragment.app.FragmentContainerView
android:id="@+id/explore_nav_host"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
android:elevation="@dimen/elevation_normal"
app:layout_constraintBottom_toTopOf="@+id/compact_playback"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/nav_explore"
tools:layout="@layout/fragment_library" />
<androidx.fragment.app.FragmentContainerView
android:id="@+id/compact_playback"
android:name="org.oxycblt.auxio.playback.CompactPlaybackFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:name="org.oxycblt.auxio.playback.CompactPlaybackFragment"
android:elevation="@dimen/elevation_normal" />
app:layout_constraintBottom_toTopOf="@+id/nav_bar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:layout="@layout/fragment_compact_playback" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/main_tabs"
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/height_tab_menu"
android:layout_gravity="bottom"
android:background="?android:attr/windowBackground"
android:layout_height="wrap_content"
android:background="@color/background"
android:elevation="@dimen/elevation_normal"
app:itemRippleColor="@color/selection_color"
app:layout_constraintBottom_toBottomOf="parent"
app:tabGravity="fill"
app:tabIconTint="?attr/colorPrimary"
app:tabIconTintMode="src_in"
app:tabIndicator="@drawable/ui_indicator"
app:tabIndicatorColor="?attr/colorPrimary"
app:tabMode="fixed"
app:tabRippleColor="@color/selection_color"
tools:background="@color/control_color" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/menu_nav" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
@@ -46,7 +46,7 @@
android:layout_margin="@dimen/margin_mid_large"
android:contentDescription="@{@string/description_album_cover(song.name)}"
android:outlineProvider="bounds"
android:elevation="4dp"
android:elevation="2dp"
app:coverArt="@{song}"
app:layout_constraintBottom_toTopOf="@+id/playback_song"
app:layout_constraintDimensionRatio="1:1"
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/library_fragment"
android:title="@string/title_library_fragment"
android:icon="@drawable/ic_library" />
<item
android:id="@+id/songs_fragment"
android:title="@string/label_songs"
android:icon="@drawable/ic_song" />
</menu>
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation 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/nav_explore"
app:startDestination="@id/library_fragment">
<fragment
android:id="@+id/library_fragment"
android:name="org.oxycblt.auxio.library.LibraryFragment"
android:label="fragment_library"
tools:layout="@layout/fragment_library">
<action
android:id="@+id/action_show_genre"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim"
app:destination="@id/genre_detail_fragment" />
<action
android:id="@+id/action_show_artist"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim"
app:destination="@id/artist_detail_fragment" />
<action
android:id="@+id/action_show_album"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim"
app:destination="@id/album_detail_fragment" />
</fragment>
<fragment
android:id="@+id/artist_detail_fragment"
android:name="org.oxycblt.auxio.detail.ArtistDetailFragment"
android:label="ArtistDetailFragment"
tools:layout="@layout/fragment_artist_detail">
<argument
android:name="artistId"
app:argType="long" />
<action
android:id="@+id/action_show_album"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim"
app:destination="@id/album_detail_fragment"
app:launchSingleTop="true" />
</fragment>
<fragment
android:id="@+id/album_detail_fragment"
android:name="org.oxycblt.auxio.detail.AlbumDetailFragment"
android:label="AlbumDetailFragment"
tools:layout="@layout/fragment_album_detail">
<argument
android:name="albumId"
app:argType="long" />
<argument
android:name="enableParentNav"
app:argType="boolean" />
<action
android:id="@+id/action_show_parent_artist"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim"
app:destination="@id/artist_detail_fragment" />
</fragment>
<fragment
android:id="@+id/genre_detail_fragment"
android:name="org.oxycblt.auxio.detail.GenreDetailFragment"
android:label="GenreDetailFragment"
tools:layout="@layout/fragment_genre_detail">
<action
android:id="@+id/action_show_artist"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim"
app:destination="@id/artist_detail_fragment" />
<argument
android:name="genreId"
app:argType="long" />
</fragment>
<fragment
android:id="@+id/songs_fragment"
android:name="org.oxycblt.auxio.songs.SongsFragment"
android:label="fragment_songs"
tools:layout="@layout/fragment_songs" />
</navigation>