mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 15:01:52 +01:00
Refactoring Tabbed Sheets
This commit is contained in:
parent
fe2543b9d5
commit
a2c7705d07
@ -3,10 +3,11 @@ package eu.kanade.tachiyomi.ui.library.display
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import eu.kanade.tachiyomi.util.bindToPreference
|
||||
import eu.kanade.tachiyomi.widget.BaseLibraryDisplayView
|
||||
import kotlinx.android.synthetic.main.library_badges_layout.view.*
|
||||
|
||||
class LibraryBadgesView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
LibraryPreferenceView(context, attrs) {
|
||||
BaseLibraryDisplayView(context, attrs) {
|
||||
|
||||
override fun initGeneralPreferences() {
|
||||
unread_badge_group.bindToPreference(preferences.unreadBadgeType()) {
|
||||
|
@ -3,10 +3,11 @@ package eu.kanade.tachiyomi.ui.library.display
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import eu.kanade.tachiyomi.util.bindToPreference
|
||||
import eu.kanade.tachiyomi.widget.BaseLibraryDisplayView
|
||||
import kotlinx.android.synthetic.main.library_category_layout.view.*
|
||||
|
||||
class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
LibraryPreferenceView(context, attrs) {
|
||||
BaseLibraryDisplayView(context, attrs) {
|
||||
|
||||
override fun initGeneralPreferences() {
|
||||
show_all.bindToPreference(preferences.showAllCategories()) {
|
||||
|
@ -3,10 +3,11 @@ package eu.kanade.tachiyomi.ui.library.display
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import eu.kanade.tachiyomi.util.bindToPreference
|
||||
import eu.kanade.tachiyomi.widget.BaseLibraryDisplayView
|
||||
import kotlinx.android.synthetic.main.library_display_layout.view.*
|
||||
|
||||
class LibraryDisplayView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
LibraryPreferenceView(context, attrs) {
|
||||
BaseLibraryDisplayView(context, attrs) {
|
||||
|
||||
override fun initGeneralPreferences() {
|
||||
display_group.bindToPreference(preferences.libraryLayout()) {
|
||||
|
@ -1,28 +0,0 @@
|
||||
package eu.kanade.tachiyomi.ui.library.display
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.AttributeSet
|
||||
import android.widget.CompoundButton
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.RadioButton
|
||||
import android.widget.RadioGroup
|
||||
import com.f2prateek.rx.preferences.Preference
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.ui.library.LibraryController
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
abstract class LibraryPreferenceView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
LinearLayout(context, attrs) {
|
||||
|
||||
internal val preferences by injectLazy<PreferencesHelper>()
|
||||
lateinit var controller: LibraryController
|
||||
|
||||
abstract fun initGeneralPreferences()
|
||||
|
||||
override fun onFinishInflate() {
|
||||
super.onFinishInflate()
|
||||
initGeneralPreferences()
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package eu.kanade.tachiyomi.ui.reader.settings
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.LinearLayout
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.library.LibraryController
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
abstract class BaseReaderSettingsView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
FrameLayout(context, attrs) {
|
||||
|
||||
internal val preferences by injectLazy<PreferencesHelper>()
|
||||
lateinit var activity: ReaderActivity
|
||||
|
||||
abstract fun initGeneralPreferences()
|
||||
|
||||
override fun onFinishInflate() {
|
||||
super.onFinishInflate()
|
||||
initGeneralPreferences()
|
||||
}
|
||||
}
|
@ -6,11 +6,11 @@ import android.widget.SeekBar
|
||||
import androidx.annotation.ColorInt
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
||||
import eu.kanade.tachiyomi.widget.BaseReaderSettingsView
|
||||
import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener
|
||||
import eu.kanade.tachiyomi.widget.SimpleSeekBarListener
|
||||
import kotlinx.android.synthetic.main.reader_color_filter.*
|
||||
import kotlinx.android.synthetic.main.reader_color_filter.view.*
|
||||
import kotlinx.android.synthetic.main.reader_color_filter.view.settings_scroll_view
|
||||
import kotlinx.android.synthetic.main.reader_general_layout.view.*
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
@ -21,7 +21,6 @@ class ReaderFilterView @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||
|
||||
override fun initGeneralPreferences() {
|
||||
activity = context as ReaderActivity
|
||||
settings_scroll_view.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
||||
preferences.colorFilter().asFlow()
|
||||
.onEach { setColorFilter(it) }
|
||||
.launchIn(activity.scope)
|
||||
|
@ -5,6 +5,7 @@ import android.util.AttributeSet
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.util.bindToPreference
|
||||
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
||||
import eu.kanade.tachiyomi.widget.BaseReaderSettingsView
|
||||
import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener
|
||||
import kotlinx.android.synthetic.main.reader_general_layout.view.*
|
||||
|
||||
@ -13,7 +14,6 @@ class ReaderGeneralView @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
|
||||
lateinit var sheet: TabbedReaderSettingsSheet
|
||||
override fun initGeneralPreferences() {
|
||||
settings_scroll_view.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
||||
viewer_series.onItemSelectedListener = { position ->
|
||||
activity.presenter.setMangaViewer(position)
|
||||
|
||||
|
@ -4,15 +4,10 @@ import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.util.bindToIntPreference
|
||||
import eu.kanade.tachiyomi.util.bindToPreference
|
||||
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
||||
import eu.kanade.tachiyomi.util.view.visibleIf
|
||||
import eu.kanade.tachiyomi.widget.BaseReaderSettingsView
|
||||
import kotlinx.android.synthetic.main.reader_paged_layout.view.*
|
||||
import kotlinx.android.synthetic.main.reader_paged_layout.view.crop_borders_webtoon
|
||||
import kotlinx.android.synthetic.main.reader_paged_layout.view.settings_scroll_view
|
||||
import kotlinx.android.synthetic.main.reader_paged_layout.view.webtoon_enable_zoom_out
|
||||
import kotlinx.android.synthetic.main.reader_paged_layout.view.webtoon_side_padding
|
||||
|
||||
class ReaderPagedView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
BaseReaderSettingsView(context, attrs) {
|
||||
@ -23,7 +18,6 @@ class ReaderPagedView @JvmOverloads constructor(context: Context, attrs: Attribu
|
||||
crop_borders.bindToPreference(preferences.cropBorders())
|
||||
page_transitions.bindToPreference(preferences.pageTransitions())
|
||||
|
||||
settings_scroll_view.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
||||
val mangaViewer = (context as ReaderActivity).presenter.getMangaViewer()
|
||||
val isWebtoonView = mangaViewer == ReaderActivity.WEBTOON || mangaViewer == ReaderActivity.VERTICAL_PLUS
|
||||
val hasMargins = mangaViewer == ReaderActivity.VERTICAL_PLUS
|
||||
|
@ -1,6 +1,7 @@
|
||||
package eu.kanade.tachiyomi.ui.reader.settings
|
||||
|
||||
import android.view.View
|
||||
import androidx.core.widget.NestedScrollView
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.library.display.LibraryBadgesView
|
||||
@ -66,22 +67,13 @@ class TabbedReaderSettingsSheet(val readerActivity: ReaderActivity): TabbedBotto
|
||||
tabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
|
||||
override fun onTabSelected(tab: TabLayout.Tab?) {
|
||||
window?.setDimAmount(if (tab?.position == 2) 0f else ogDim)
|
||||
val view = getTabViews()[tab?.position ?: 0]
|
||||
view.settings_scroll_view?.isNestedScrollingEnabled = true
|
||||
view.settings_scroll_view?.requestLayout()
|
||||
readerActivity.appbar.visInvisIf(tab?.position != 2)
|
||||
}
|
||||
|
||||
override fun onTabUnselected(tab: TabLayout.Tab?) {
|
||||
val view = getTabViews()[tab?.position ?: 0]
|
||||
view.settings_scroll_view?.isNestedScrollingEnabled = false
|
||||
view.settings_scroll_view?.requestLayout()
|
||||
}
|
||||
|
||||
override fun onTabReselected(tab: TabLayout.Tab?) {
|
||||
val view = getTabViews()[tab?.position ?: 0]
|
||||
view.settings_scroll_view?.isNestedScrollingEnabled = true
|
||||
view.settings_scroll_view?.requestLayout()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package eu.kanade.tachiyomi.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.core.widget.NestedScrollView
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.library.LibraryController
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
abstract class BaseTabbedScrollView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
NestedScrollView(context, attrs) {
|
||||
|
||||
init {
|
||||
clipToPadding = false
|
||||
}
|
||||
internal val preferences by injectLazy<PreferencesHelper>()
|
||||
|
||||
abstract fun initGeneralPreferences()
|
||||
|
||||
override fun onFinishInflate() {
|
||||
super.onFinishInflate()
|
||||
setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
||||
initGeneralPreferences()
|
||||
}
|
||||
}
|
||||
|
||||
abstract class BaseLibraryDisplayView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
BaseTabbedScrollView(context, attrs) {
|
||||
lateinit var controller: LibraryController
|
||||
}
|
||||
|
||||
abstract class BaseReaderSettingsView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
BaseTabbedScrollView(context, attrs) {
|
||||
lateinit var activity: ReaderActivity
|
||||
}
|
@ -3,20 +3,17 @@ package eu.kanade.tachiyomi.widget
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.core.widget.NestedScrollView
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.view.expand
|
||||
import eu.kanade.tachiyomi.util.view.setEdgeToEdge
|
||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||
import kotlinx.android.synthetic.main.library_list_controller.*
|
||||
import kotlinx.android.synthetic.main.tabbed_bottom_sheet.*
|
||||
|
||||
|
||||
@ -48,7 +45,25 @@ abstract class TabbedBottomSheetDialog(private val activity: Activity) :
|
||||
super.onStart()
|
||||
sheetBehavior.skipCollapsed = true
|
||||
sheetBehavior.expand()
|
||||
val height = activity.window.decorView.rootWindowInsets.systemWindowInsetTop
|
||||
tabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
|
||||
override fun onTabSelected(tab: TabLayout.Tab?) {
|
||||
val view = getTabViews()[tab?.position ?: 0] as? NestedScrollView
|
||||
view?.isNestedScrollingEnabled = true
|
||||
view?.requestLayout()
|
||||
}
|
||||
|
||||
override fun onTabUnselected(tab: TabLayout.Tab?) {
|
||||
val view = getTabViews()[tab?.position ?: 0] as? NestedScrollView
|
||||
view?.isNestedScrollingEnabled = false
|
||||
view?.requestLayout()
|
||||
}
|
||||
|
||||
override fun onTabReselected(tab: TabLayout.Tab?) {
|
||||
val view = getTabViews()[tab?.position ?: 0] as? NestedScrollView
|
||||
view?.isNestedScrollingEnabled = true
|
||||
view?.requestLayout()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
abstract fun getTabViews(): List<View>
|
||||
|
@ -4,6 +4,12 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linear_layout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/unread_badge_group"
|
||||
android:layout_width="match_parent"
|
||||
@ -46,4 +52,5 @@
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:text="@string/download_badge" />
|
||||
</LinearLayout>
|
||||
</eu.kanade.tachiyomi.ui.library.display.LibraryBadgesView>
|
@ -4,6 +4,12 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linear_layout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.checkbox.MaterialCheckBox
|
||||
android:id="@+id/category_show"
|
||||
android:layout_width="match_parent"
|
||||
@ -35,4 +41,5 @@
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:text="@string/hide_hopper_on_scroll" />
|
||||
</LinearLayout>
|
||||
</eu.kanade.tachiyomi.ui.library.display.LibraryCategoryView>
|
@ -4,6 +4,12 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linear_layout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/display_group"
|
||||
android:layout_width="match_parent"
|
||||
@ -83,5 +89,5 @@
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:text="@string/uniform_covers" />
|
||||
|
||||
</LinearLayout>
|
||||
</eu.kanade.tachiyomi.ui.library.display.LibraryDisplayView>
|
@ -6,13 +6,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bottom_sheet_rounded_background"
|
||||
android:forceDarkAllowed="false">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/settings_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layout_height="wrap_content">
|
||||
android:clipToPadding="false">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraint_layout"
|
||||
@ -241,5 +235,4 @@
|
||||
app:layout_constraintGuide_percent="0.5" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</eu.kanade.tachiyomi.ui.reader.settings.ReaderFilterView>
|
@ -5,15 +5,10 @@
|
||||
android:id="@+id/filter_bottom_sheet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:background="@drawable/bottom_sheet_rounded_background"
|
||||
android:forceDarkAllowed="false">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/settings_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/constraint_layout"
|
||||
style="@style/BottomSheetDialogTheme"
|
||||
@ -82,5 +77,4 @@
|
||||
android:text="@string/always_show_chapter_transition"
|
||||
android:textColor="?android:attr/textColorPrimary" />
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</eu.kanade.tachiyomi.ui.reader.settings.ReaderGeneralView>
|
@ -6,13 +6,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bottom_sheet_rounded_background"
|
||||
android:forceDarkAllowed="false">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/settings_scroll_view"
|
||||
android:clipToPadding="false"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:clipToPadding="false">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -100,5 +94,4 @@
|
||||
app:constraint_referenced_ids="crop_borders_webtoon,webtoon_side_padding,webtoon_enable_zoom_out" />
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</eu.kanade.tachiyomi.ui.reader.settings.ReaderPagedView>
|
Loading…
Reference in New Issue
Block a user