More fixes to swpiing list + toggle for hiding filters by default

This commit is contained in:
Jay 2020-03-11 18:31:23 -07:00
parent 495407f3ea
commit 0631b57795
6 changed files with 78 additions and 90 deletions

View File

@ -52,6 +52,7 @@ import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationProcedureConfig
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForRootController
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
import eu.kanade.tachiyomi.util.view.snack
@ -194,11 +195,7 @@ open class LibraryController(
when (it) {
SortFilterBottomSheet.ACTION_REFRESH -> onRefresh()
SortFilterBottomSheet.ACTION_FILTER -> onFilterChanged()
SortFilterBottomSheet.ACTION_SORT -> onSortChanged()
SortFilterBottomSheet.ACTION_DISPLAY -> reattachAdapter()
SortFilterBottomSheet.ACTION_DOWNLOAD_BADGE -> presenter.requestDownloadBadgesUpdate()
SortFilterBottomSheet.ACTION_UNREAD_BADGE -> presenter.requestUnreadBadgesUpdate()
SortFilterBottomSheet.ACTION_CAT_SORT -> onCatSortChanged()
SortFilterBottomSheet.ACTION_HIDE_FILTER_TIP -> activity?.toast(R.string.hide_filters_tip)
}
}

View File

@ -186,6 +186,15 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
}
return
}
if (event.actionMasked == MotionEvent.ACTION_UP) {
recycler_layout.post {
if (!flinging) {
resetScrollingValues()
resetRecyclerY(true)
}
}
return
}
if (startPosX != null && startPosY != null &&
(sheetRect.contains(startPosX!!.toInt(), startPosY!!.toInt()) ||
!recyclerRect.contains(startPosX!!.toInt(), startPosY!!.toInt()))) {
@ -239,14 +248,6 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
}
}
}
else if (event.actionMasked == MotionEvent.ACTION_UP) {
recycler_layout.post {
if (!flinging) {
resetScrollingValues()
resetRecyclerY(true)
}
}
}
}
private fun resetScrollingValues() {

View File

@ -115,9 +115,6 @@ class SortFilterBottomSheet @JvmOverloads constructor(context: Context, attrs: A
else
shadow.alpha = 1f
pager?.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
// snackbarLayout.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
if (!phoneLandscape)
preferences.hideFiltersAtStart().set(false)
}
if (state == BottomSheetBehavior.STATE_EXPANDED) {
top_bar.alpha = 0f
@ -129,8 +126,6 @@ class SortFilterBottomSheet @JvmOverloads constructor(context: Context, attrs: A
shadow.alpha = 0f
pager?.updatePaddingRelative(bottom = 0)
// snackbarLayout.updatePaddingRelative(bottom = 0)
if (!phoneLandscape)
preferences.hideFiltersAtStart().set(true)
}
//top_bar.isClickable = state == BottomSheetBehavior.STATE_COLLAPSED
//top_bar.isFocusable = state == BottomSheetBehavior.STATE_COLLAPSED
@ -147,6 +142,12 @@ class SortFilterBottomSheet @JvmOverloads constructor(context: Context, attrs: A
if (phoneLandscape && shadow2.visibility != View.GONE) {
shadow2.gone()
}
hide_filters.isChecked = preferences.hideFiltersAtStart().getOrDefault()
hide_filters.setOnCheckedChangeListener { _, isChecked ->
preferences.hideFiltersAtStart().set(isChecked)
if (isChecked)
onGroupClicked(ACTION_HIDE_FILTER_TIP)
}
createTags()
clearButton.setOnClickListener { clearFilters() }
}
@ -305,11 +306,7 @@ class SortFilterBottomSheet @JvmOverloads constructor(context: Context, attrs: A
companion object {
const val ACTION_REFRESH = 0
const val ACTION_SORT = 1
const val ACTION_FILTER = 2
const val ACTION_DISPLAY = 3
const val ACTION_DOWNLOAD_BADGE = 4
const val ACTION_UNREAD_BADGE = 5
const val ACTION_CAT_SORT = 6
const val ACTION_FILTER = 1
const val ACTION_HIDE_FILTER_TIP = 2
}
}

View File

@ -1,14 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<eu.kanade.tachiyomi.ui.library.filter.SortFilterBottomSheet 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/bottom_sheet"
style="@style/BottomSheetDialogTheme"
android:layout_width="match_parent"
app:behavior_peekHeight="60dp"
android:layout_height="wrap_content"
android:background="@drawable/bg_bottom_sheet_dialog_fragment"
android:orientation="vertical"
app:behavior_peekHeight="60dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<androidx.constraintlayout.widget.ConstraintLayout
@ -19,11 +18,11 @@
android:id="@+id/sheet_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:orientation="vertical">
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<HorizontalScrollView
android:id="@+id/filter_scroll"
@ -33,8 +32,8 @@
android:clipToPadding="false"
android:paddingStart="20dp"
android:paddingTop="8dp"
android:paddingBottom="6dp"
android:paddingEnd="20dp"
android:paddingBottom="6dp"
android:scrollbars="none">
<LinearLayout
@ -66,6 +65,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="23dp"
android:orientation="horizontal">
<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/hide_categories"
android:layout_width="wrap_content"
@ -73,22 +73,13 @@
android:layout_marginEnd="20dp"
android:text="@string/action_hide_categories" />
<TextView
android:layout_marginStart="12dp"
android:id="@+id/reorder_filters"
<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/hide_filters"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:clickable="true"
android:background="@drawable/square_ripple"
android:focusable="true"
android:gravity="start|center"
android:padding="10dp"
android:text="Reorder Filters"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"
android:textColor="?android:attr/textColorPrimary"
android:textSize="15sp"
android:textStyle="normal" />
android:layout_marginEnd="20dp"
android:text="@string/action_start_filters_hidden" />
</LinearLayout>
</LinearLayout>
@ -106,11 +97,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:src="@drawable/draggable_pill"
android:alpha="0.25"
android:contentDescription="@string/drag_handle"
app:layout_constraintStart_toStartOf="parent"
android:src="@drawable/draggable_pill"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -54,6 +54,7 @@
<string name="action_filter_tracked">Tracked</string>
<string name="action_filter_not_tracked">Not tracked</string>
<string name="action_hide_categories">Hide categories</string>
<string name="action_start_filters_hidden">Hide filters on startup</string>
<string name="hiding_categories">Hiding categories</string>
<string name="manga_only">Manga only</string>
<string name="manhwa_only">Manhwa only</string>
@ -468,7 +469,8 @@
<string name="hide_unread">Hide unread badges</string>
<string name="show_unread">Show unread badges</string>
<string name="show_unread_count">Show unread count</string>
<string name="hide_filters_tip">You can show filters by again tapping the Library tab when
hidden</string>
<!-- Catalogue fragment -->
<string name="source_search_options">Search filters</string>