diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/CatalogueNavigationView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/CatalogueNavigationView.kt index 5e34ba35c7..84a3fb0972 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/CatalogueNavigationView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/CatalogueNavigationView.kt @@ -23,7 +23,7 @@ class CatalogueNavigationView @JvmOverloads constructor(context: Context, attrs: init { recycler.adapter = adapter recycler.setHasFixedSize(true) - val view = inflate(R.layout.catalogue_drawer_content) + val view = inflate(R.layout.catalogue_filter_sheet) ((view as ViewGroup).getChildAt(1) as ViewGroup).addView(recycler) addView(view) // title.text = context.getString(R.string.source_search_options) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/CatalogueSearchSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/CatalogueSearchSheet.kt index d3d25b31be..b1446f6d4d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/CatalogueSearchSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/CatalogueSearchSheet.kt @@ -16,7 +16,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.view.setEdgeToEdge -import kotlinx.android.synthetic.main.catalogue_drawer_content.* +import kotlinx.android.synthetic.main.catalogue_filter_sheet.* import uy.kohesive.injekt.injectLazy class CatalogueSearchSheet(activity: Activity) : @@ -43,15 +43,11 @@ class CatalogueSearchSheet(activity: Activity) : var onResetClicked = {} init { - val view = activity.layoutInflater.inflate(R.layout.catalogue_drawer_content, null) + val view = activity.layoutInflater.inflate(R.layout.catalogue_filter_sheet, null) setContentView(view) toolbar_title.text = context.getString(R.string.search_filters) - dismiss_button.setOnClickListener { dismiss() } + search_btn.setOnClickListener { dismiss() } reset_btn.setOnClickListener { onResetClicked() } - /*view.search_layout.setOnApplyWindowInsetsListener { v, insets -> - view.updatePaddingRelative(bottom = insets.systemWindowInsetBottom) - insets - }*/ recycler.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(context) recycler.clipToPadding = false @@ -66,7 +62,6 @@ class CatalogueSearchSheet(activity: Activity) : if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && preferences.readerTheme() .getOrDefault() == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetLeft == 0 ) window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR - val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { override fun onSlide(bottomSheet: View, progress: Float) {} @@ -99,11 +94,6 @@ class CatalogueSearchSheet(activity: Activity) : }) } - override fun onStart() { - super.onStart() - sheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED - } - override fun dismiss() { super.dismiss() if (filterChanged) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersSortBottomSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersSortBottomSheet.kt index ab8602eb8a..d5b7d715f4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersSortBottomSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersSortBottomSheet.kt @@ -16,6 +16,7 @@ import eu.kanade.tachiyomi.util.view.setEdgeToEdge import eu.kanade.tachiyomi.util.view.visInvisIf import eu.kanade.tachiyomi.util.view.visibleIf import kotlinx.android.synthetic.main.chapter_sort_bottom_sheet.* +import kotlin.math.max class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetDialog (controller.activity!!, R.style.BottomSheetDialogTheme) { @@ -37,7 +38,12 @@ class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetD sheetBehavior.peekHeight = 415.dpToPx + height sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { - override fun onSlide(bottomSheet: View, progress: Float) { } + override fun onSlide(bottomSheet: View, progress: Float) { + if (progress.isNaN()) + pill.alpha = 0f + else + pill.alpha = (1 - max(0f, progress)) * 0.25f + } override fun onStateChanged(p0: View, state: Int) { if (state == BottomSheetBehavior.STATE_EXPANDED) { @@ -65,6 +71,7 @@ class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetD settings_scroll_view!!.height < bottom_sheet.height + settings_scroll_view.paddingTop + settings_scroll_view.paddingBottom close_button.visibleIf(isScrollable) + pill.visibleIf(!isScrollable) } setOnDismissListener { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt index 823eb47701..467760a918 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt @@ -8,7 +8,6 @@ import android.view.View import android.view.ViewGroup import android.widget.CompoundButton import android.widget.Spinner -import androidx.core.widget.NestedScrollView import com.f2prateek.rx.preferences.Preference import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog @@ -22,9 +21,11 @@ import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.setBottomEdge import eu.kanade.tachiyomi.util.view.setEdgeToEdge import eu.kanade.tachiyomi.util.view.visible +import eu.kanade.tachiyomi.util.view.visibleIf import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener import kotlinx.android.synthetic.main.reader_settings_sheet.* import uy.kohesive.injekt.injectLazy +import kotlin.math.max /** * Sheet to show reader and viewer preferences. @@ -39,18 +40,14 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : private var sheetBehavior: BottomSheetBehavior<*> - val scroll: NestedScrollView - init { // Use activity theme for this layout val view = activity.layoutInflater.inflate(R.layout.reader_settings_sheet, null) - scroll = NestedScrollView(activity) - scroll.addView(view) - setContentView(scroll) + setContentView(view) - sheetBehavior = BottomSheetBehavior.from(scroll.parent as ViewGroup) + sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup) setEdgeToEdge( - activity, scroll, if (context.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) + activity, view, if (context.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) 0 else -1 ) window?.navigationBarColor = Color.TRANSPARENT @@ -58,10 +55,15 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : .getOrDefault() == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetLeft == 0 ) window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom - sheetBehavior.peekHeight = 200.dpToPx + height + sheetBehavior.peekHeight = 500.dpToPx + height sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { - override fun onSlide(bottomSheet: View, progress: Float) {} + override fun onSlide(bottomSheet: View, progress: Float) { + if (progress.isNaN()) + pill.alpha = 0f + else + pill.alpha = (1 - max(0f, progress)) * 0.25f + } override fun onStateChanged(p0: View, state: Int) { if (state == BottomSheetBehavior.STATE_EXPANDED) { @@ -91,12 +93,13 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : close_button.setOnClickListener { dismiss() } - } - - override fun onStart() { - super.onStart() - sheetBehavior.skipCollapsed = true - sheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED + settings_scroll_view.viewTreeObserver.addOnGlobalLayoutListener { + val isScrollable = + settings_scroll_view.height < constraint_layout.height + + settings_scroll_view.paddingTop + settings_scroll_view.paddingBottom + close_button.visibleIf(isScrollable) + pill.visibleIf(!isScrollable) + } } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt index c81a7f845e..bbacdc5bb3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt @@ -341,9 +341,16 @@ fun Controller.scrollViewWith( activity?.appbar?.y = 0f val attrsArray = intArrayOf(android.R.attr.actionBarSize) val array = recycler.context.obtainStyledAttributes(attrsArray) - val appBarHeight = array.getDimensionPixelSize(0, 0) + var appBarHeight = if (activity!!.toolbar.height > 0) activity!!.toolbar.height + else array.getDimensionPixelSize(0, 0) array.recycle() swipeRefreshLayout?.setDistanceToTriggerSync(150.dpToPx) + activity!!.toolbar.post { + if (activity!!.toolbar.height > 0) { + appBarHeight = activity!!.toolbar.height + recycler.requestApplyInsets() + } + } recycler.doOnApplyWindowInsets { view, insets, _ -> val headerHeight = insets.systemWindowInsetTop + appBarHeight if (!customPadding) view.updatePaddingRelative( @@ -467,14 +474,9 @@ fun BottomSheetDialog.setEdgeToEdge( activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0) contentView.systemUiVisibility = contentView.systemUiVisibility .or(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) - /*contentView.updateLayoutParams { - leftMargin = activity.window.decorView.rootWindowInsets.systemWindowInsetLeft - rightMargin = activity.window.decorView.rootWindowInsets.systemWindowInsetRight - }*/ if (setTopMargin > 0) (contentView.parent as View).updateLayoutParams { height = activity.window.decorView.height - activity.window.decorView.rootWindowInsets.systemWindowInsetTop - setTopMargin - // activity.window.decorView.rootWindowInsets.systemWindowInsetTop // + setTopMargin } else if (setTopMargin == 0) contentView.updateLayoutParams { topMargin = activity.window.decorView.rootWindowInsets.systemWindowInsetTop diff --git a/app/src/main/res/layout/catalogue_drawer_content.xml b/app/src/main/res/layout/catalogue_filter_sheet.xml similarity index 86% rename from app/src/main/res/layout/catalogue_drawer_content.xml rename to app/src/main/res/layout/catalogue_filter_sheet.xml index 8936e405ef..347c147b9c 100644 --- a/app/src/main/res/layout/catalogue_drawer_content.xml +++ b/app/src/main/res/layout/catalogue_filter_sheet.xml @@ -34,6 +34,8 @@ android:layout_width="wrap_content" android:textColor="?attr/tabBarIconColor" android:layout_height="match_parent" + android:textSize="16sp" + android:letterSpacing="0.0" android:text="@string/reset" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -55,15 +57,15 @@ app:layout_constraintTop_toTopOf="parent" tools:text="Title Text" /> - diff --git a/app/src/main/res/layout/chapter_sort_bottom_sheet.xml b/app/src/main/res/layout/chapter_sort_bottom_sheet.xml index 4a07afab9c..716d3f8c0a 100644 --- a/app/src/main/res/layout/chapter_sort_bottom_sheet.xml +++ b/app/src/main/res/layout/chapter_sort_bottom_sheet.xml @@ -1,8 +1,9 @@ @@ -155,6 +155,17 @@ + + diff --git a/app/src/main/res/layout/filter_bottom_sheet.xml b/app/src/main/res/layout/filter_bottom_sheet.xml index 07805c0c54..1e816366f9 100644 --- a/app/src/main/res/layout/filter_bottom_sheet.xml +++ b/app/src/main/res/layout/filter_bottom_sheet.xml @@ -29,11 +29,11 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="2dp" - android:requiresFadingEdge="horizontal" - android:fadingEdgeLength="20dp" android:clipToPadding="false" + android:fadingEdgeLength="20dp" android:paddingTop="8dp" android:paddingBottom="6dp" + android:requiresFadingEdge="horizontal" android:scrollbars="none"> + android:paddingEnd="20dp"> + app:iconTint="?android:attr/textColorPrimary" /> + android:text="@string/start_with_filters_hidden" + android:visibility="gone" /> diff --git a/app/src/main/res/layout/reader_settings_sheet.xml b/app/src/main/res/layout/reader_settings_sheet.xml index 4100e6c55f..ff4c87e095 100644 --- a/app/src/main/res/layout/reader_settings_sheet.xml +++ b/app/src/main/res/layout/reader_settings_sheet.xml @@ -1,274 +1,297 @@ - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:layout_gravity="center|top" + android:layout_marginTop="5dp" + android:alpha="0.25" + android:contentDescription="@string/drag_handle" + android:src="@drawable/draggable_pill" + android:tint="?android:attr/textColorPrimary" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:clickable="true" + android:contentDescription="@string/close" + android:focusable="true" + android:src="@drawable/ic_close_white_24dp" + android:tint="@color/gray_button" /> + \ No newline at end of file