home: fix appbar issues
Fix two annoying appbar issues: - Appbar will collapse if the navigation sequence is too fast - Tab ripple would paint over the indicator unless the ripple was unbounded [???]
This commit is contained in:
parent
5fe01777d0
commit
9162246b8b
3 changed files with 25 additions and 22 deletions
|
@ -101,8 +101,6 @@ dependencies {
|
||||||
// Material
|
// Material
|
||||||
implementation "com.google.android.material:material:1.4.0"
|
implementation "com.google.android.material:material:1.4.0"
|
||||||
|
|
||||||
implementation 'me.zhanghai.android.fastscroll:library:1.1.7'
|
|
||||||
|
|
||||||
// --- DEBUG ---
|
// --- DEBUG ---
|
||||||
|
|
||||||
// Lint
|
// Lint
|
||||||
|
|
|
@ -49,8 +49,6 @@ import org.oxycblt.auxio.util.logE
|
||||||
* It will require a new SortMode to be made simply for compat. Migrate the old SortMode
|
* It will require a new SortMode to be made simply for compat. Migrate the old SortMode
|
||||||
* eventually.
|
* eventually.
|
||||||
* TODO: Add lift-on-scroll eventually [when I can file a bug report or hack it into working]
|
* TODO: Add lift-on-scroll eventually [when I can file a bug report or hack it into working]
|
||||||
* FIXME: Find a way to store the collapsed state so it stays consistent
|
|
||||||
* TODO: Fix issue where TabLayout ripples will shove above the indicator
|
|
||||||
* @author OxygenCobalt
|
* @author OxygenCobalt
|
||||||
*/
|
*/
|
||||||
class HomeFragment : Fragment() {
|
class HomeFragment : Fragment() {
|
||||||
|
@ -69,9 +67,6 @@ class HomeFragment : Fragment() {
|
||||||
|
|
||||||
binding.lifecycleOwner = viewLifecycleOwner
|
binding.lifecycleOwner = viewLifecycleOwner
|
||||||
|
|
||||||
// For some insane reason certain navigation actions will collapse the app bar
|
|
||||||
binding.homeAppbar.setExpanded(true)
|
|
||||||
|
|
||||||
binding.homeToolbar.setOnMenuItemClickListener { item ->
|
binding.homeToolbar.setOnMenuItemClickListener { item ->
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.action_settings -> {
|
R.id.action_settings -> {
|
||||||
|
@ -128,6 +123,9 @@ class HomeFragment : Fragment() {
|
||||||
// --- VIEWMODEL SETUP ---
|
// --- VIEWMODEL SETUP ---
|
||||||
|
|
||||||
detailModel.navToItem.observe(viewLifecycleOwner) { item ->
|
detailModel.navToItem.observe(viewLifecycleOwner) { item ->
|
||||||
|
// Unless we wait for the AppBarLayout to be done setting up before we navigate,
|
||||||
|
// it might result in the collapsed state being lost for...reasons.
|
||||||
|
binding.homeAppbar.post {
|
||||||
when (item) {
|
when (item) {
|
||||||
is Song -> findNavController().navigate(
|
is Song -> findNavController().navigate(
|
||||||
HomeFragmentDirections.actionShowAlbum(item.album.id)
|
HomeFragmentDirections.actionShowAlbum(item.album.id)
|
||||||
|
@ -149,6 +147,7 @@ class HomeFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logD("Fragment Created.")
|
logD("Fragment Created.")
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
android:id="@+id/home_appbar"
|
android:id="@+id/home_appbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
android:background="?attr/colorSurface"
|
android:background="?attr/colorSurface"
|
||||||
android:elevation="@dimen/elevation_normal">
|
android:elevation="@dimen/elevation_normal">
|
||||||
|
|
||||||
|
@ -31,9 +33,13 @@
|
||||||
android:id="@+id/home_tabs"
|
android:id="@+id/home_tabs"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
app:tabUnboundedRipple="true"
|
||||||
|
app:tabRippleColor="?attr/colorControlHighlight"
|
||||||
app:tabTextAppearance="@style/TextAppearance.TabLayout.Label"
|
app:tabTextAppearance="@style/TextAppearance.TabLayout.Label"
|
||||||
app:tabMode="scrollable"
|
|
||||||
app:tabContentStart="@dimen/spacing_medium"
|
app:tabContentStart="@dimen/spacing_medium"
|
||||||
|
app:tabMode="scrollable"
|
||||||
app:tabTextColor="?android:attr/textColorPrimary"
|
app:tabTextColor="?android:attr/textColorPrimary"
|
||||||
app:tabIndicatorColor="?attr/colorAccent" />
|
app:tabIndicatorColor="?attr/colorAccent" />
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue