Collasing bottom sheet's peak on small phones in landscape

This commit is contained in:
Jay 2020-02-08 06:43:41 -08:00
parent 033e4f205d
commit 596597c910
4 changed files with 21 additions and 25 deletions

View File

@ -425,23 +425,22 @@ class LibraryController(
} }
private fun onRefresh() { private fun onRefresh() {
activity?.invalidateOptionsMenu() if (!MainActivity.bottomNav) activity?.invalidateOptionsMenu()
presenter.requestFullUpdate() presenter.requestFullUpdate()
} }
/** /**
* Called when a filter is changed. * Called when a filter is changed.
*/ */
private fun onFilterChanged(item: ExtendedNavigationView.Item) { private fun onFilterChanged(item: ExtendedNavigationView.Item?) {
if (item is ExtendedNavigationView.Item.MultiStateGroup && if (item is ExtendedNavigationView.Item.MultiStateGroup && item.resTitle == R.string.categories) {
item.resTitle == R.string.action_hide_categories) { if (!MainActivity.bottomNav) activity?.invalidateOptionsMenu()
activity?.invalidateOptionsMenu()
presenter.requestFullUpdate() presenter.requestFullUpdate()
return return
} }
presenter.requestFilterUpdate() presenter.requestFilterUpdate()
destroyActionModeIfNeeded() destroyActionModeIfNeeded()
activity?.invalidateOptionsMenu() if (!MainActivity.bottomNav) activity?.invalidateOptionsMenu()
} }
private fun onDownloadBadgeChanged() { private fun onDownloadBadgeChanged() {
@ -452,7 +451,7 @@ class LibraryController(
* Called when the sorting mode is changed. * Called when the sorting mode is changed.
*/ */
private fun onSortChanged() { private fun onSortChanged() {
activity?.invalidateOptionsMenu() if (!MainActivity.bottomNav) activity?.invalidateOptionsMenu()
presenter.requestSortUpdate() presenter.requestSortUpdate()
} }
@ -503,7 +502,13 @@ class LibraryController(
!MainActivity.bottomNav !MainActivity.bottomNav
preferences.librarySortingMode().getOrDefault() == LibrarySort.DRAG_AND_DROP && preferences.librarySortingMode().getOrDefault() == LibrarySort.DRAG_AND_DROP &&
!preferences.hideCategories().getOrDefault() !preferences.hideCategories().getOrDefault()
menu.findItem(R.id.action_filter).isVisible = !MainActivity.bottomNav
val config = resources?.configuration
val phoneLandscape = (config?.orientation == Configuration.ORIENTATION_LANDSCAPE &&
(config.screenLayout.and(Configuration.SCREENLAYOUT_SIZE_MASK)) <
Configuration.SCREENLAYOUT_SIZE_LARGE)
menu.findItem(R.id.action_library_filter).isVisible = !MainActivity.bottomNav || phoneLandscape
reorderMenuItem = reorganizeItem reorderMenuItem = reorganizeItem
enableReorderItems() enableReorderItems()
@ -519,7 +524,7 @@ class LibraryController(
} }
// Mutate the filter icon because it needs to be tinted and the resource is shared. // Mutate the filter icon because it needs to be tinted and the resource is shared.
menu.findItem(R.id.action_filter).icon.mutate() menu.findItem(R.id.action_library_filter).icon.mutate()
searchViewSubscription?.unsubscribe() searchViewSubscription?.unsubscribe()
searchViewSubscription = searchView.queryTextChanges() searchViewSubscription = searchView.queryTextChanges()
@ -549,7 +554,7 @@ class LibraryController(
override fun onPrepareOptionsMenu(menu: Menu) { override fun onPrepareOptionsMenu(menu: Menu) {
val navView = navView ?: return val navView = navView ?: return
val filterItem = menu.findItem(R.id.action_filter) val filterItem = menu.findItem(R.id.action_library_filter)
// Tint icon if there's a filter active // Tint icon if there's a filter active
val filterColor = if (navView.hasActiveFilters()) Color.rgb(255, 238, 7) val filterColor = if (navView.hasActiveFilters()) Color.rgb(255, 238, 7)
@ -560,8 +565,10 @@ class LibraryController(
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.action_search -> expandActionViewFromInteraction = true R.id.action_search -> expandActionViewFromInteraction = true
R.id.action_filter -> { R.id.action_library_filter -> {
navView?.let { activity?.drawer?.openDrawer(GravityCompat.END) } if (MainActivity.bottomNav) bottom_sheet.sheetBehavior?.state =
BottomSheetBehavior.STATE_EXPANDED
else navView?.let { activity?.drawer?.openDrawer(GravityCompat.END) }
} }
R.id.action_edit_categories -> { R.id.action_edit_categories -> {
router.pushController(CategoryController().withFadeTransaction()) router.pushController(CategoryController().withFadeTransaction())

View File

@ -3,10 +3,9 @@ package eu.kanade.tachiyomi.widget
import android.animation.ObjectAnimator import android.animation.ObjectAnimator
import android.animation.StateListAnimator import android.animation.StateListAnimator
import android.content.Context import android.content.Context
import android.os.Build import android.util.AttributeSet
import com.google.android.material.R import com.google.android.material.R
import com.google.android.material.appbar.AppBarLayout import com.google.android.material.appbar.AppBarLayout
import android.util.AttributeSet
class ElevationAppBarLayout @JvmOverloads constructor( class ElevationAppBarLayout @JvmOverloads constructor(
context: Context, context: Context,

View File

@ -16,15 +16,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<androidx.core.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -182,7 +173,6 @@
</LinearLayout> </LinearLayout>
</HorizontalScrollView> </HorizontalScrollView>
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/topbar" android:id="@+id/topbar"

View File

@ -12,7 +12,7 @@
app:showAsAction="collapseActionView|ifRoom"/> app:showAsAction="collapseActionView|ifRoom"/>
<item <item
android:id="@+id/action_filter" android:id="@+id/action_library_filter"
android:icon="@drawable/ic_filter_list_white_24dp" android:icon="@drawable/ic_filter_list_white_24dp"
android:title="@string/action_filter" android:title="@string/action_filter"
app:showAsAction="ifRoom"/> app:showAsAction="ifRoom"/>