From 7eef4f7fbf271ba05450551141929cb8142147ff Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 28 Jan 2021 09:10:15 -0500 Subject: [PATCH] Apply bottom sheet dialog with restriction consistently --- .../browse/source/browse/SourceFilterSheet.kt | 4 ++-- .../ui/library/LibrarySettingsSheet.kt | 2 +- .../ui/manga/chapter/ChaptersSettingsSheet.kt | 2 +- .../ui/reader/ReaderColorFilterSheet.kt | 4 ++-- .../tachiyomi/ui/reader/ReaderPageSheet.kt | 14 ++------------ .../tachiyomi/ui/reader/ReaderSettingsSheet.kt | 4 ++-- .../widget/sheet/BaseBottomSheetDialog.kt | 18 ++++++++++++++++++ .../{ => sheet}/TabbedBottomSheetDialog.kt | 6 +++--- 8 files changed, 31 insertions(+), 23 deletions(-) create mode 100644 app/src/main/java/eu/kanade/tachiyomi/widget/sheet/BaseBottomSheetDialog.kt rename app/src/main/java/eu/kanade/tachiyomi/widget/{ => sheet}/TabbedBottomSheetDialog.kt (88%) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceFilterSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceFilterSheet.kt index a1e272334..923e5c964 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceFilterSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceFilterSheet.kt @@ -5,17 +5,17 @@ import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater import android.view.ViewGroup -import com.google.android.material.bottomsheet.BottomSheetDialog import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.items.IFlexible import eu.kanade.tachiyomi.databinding.SourceFilterSheetBinding import eu.kanade.tachiyomi.widget.SimpleNavigationView +import eu.kanade.tachiyomi.widget.sheet.BaseBottomSheetDialog class SourceFilterSheet( activity: Activity, onFilterClicked: () -> Unit, onResetClicked: () -> Unit -) : BottomSheetDialog(activity) { +) : BaseBottomSheetDialog(activity) { private var filterNavView: FilterNavigationView diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt index 9a37d73a8..f64f00abe 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt @@ -11,7 +11,7 @@ import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.widget.ExtendedNavigationView import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.State -import eu.kanade.tachiyomi.widget.TabbedBottomSheetDialog +import eu.kanade.tachiyomi.widget.sheet.TabbedBottomSheetDialog import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersSettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersSettingsSheet.kt index b1bdce8d1..6c4245019 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersSettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersSettingsSheet.kt @@ -11,7 +11,7 @@ import eu.kanade.tachiyomi.ui.manga.MangaPresenter import eu.kanade.tachiyomi.util.view.popupMenu import eu.kanade.tachiyomi.widget.ExtendedNavigationView import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.State -import eu.kanade.tachiyomi.widget.TabbedBottomSheetDialog +import eu.kanade.tachiyomi.widget.sheet.TabbedBottomSheetDialog class ChaptersSettingsSheet( private val router: Router, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt index abae0789e..139407bbb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt @@ -9,11 +9,11 @@ import androidx.core.graphics.green import androidx.core.graphics.red import androidx.lifecycle.lifecycleScope import com.google.android.material.bottomsheet.BottomSheetBehavior -import com.google.android.material.bottomsheet.BottomSheetDialog import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.databinding.ReaderColorFilterSheetBinding import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener import eu.kanade.tachiyomi.widget.SimpleSeekBarListener +import eu.kanade.tachiyomi.widget.sheet.BaseBottomSheetDialog import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.sample @@ -22,7 +22,7 @@ import uy.kohesive.injekt.injectLazy /** * Color filter sheet to toggle custom filter and brightness overlay. */ -class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheetDialog(activity) { +class ReaderColorFilterSheet(private val activity: ReaderActivity) : BaseBottomSheetDialog(activity) { private val preferences: PreferencesHelper by injectLazy() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPageSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPageSheet.kt index eaac6e8d3..7edcabfef 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPageSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPageSheet.kt @@ -1,13 +1,11 @@ package eu.kanade.tachiyomi.ui.reader -import android.os.Bundle -import android.view.ViewGroup import com.afollestad.materialdialogs.MaterialDialog -import com.google.android.material.bottomsheet.BottomSheetDialog import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.ReaderPageSheetBinding import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.ui.reader.model.ReaderPage +import eu.kanade.tachiyomi.widget.sheet.BaseBottomSheetDialog /** * Sheet to show when a page is long clicked. @@ -15,7 +13,7 @@ import eu.kanade.tachiyomi.ui.reader.model.ReaderPage class ReaderPageSheet( private val activity: ReaderActivity, private val page: ReaderPage -) : BottomSheetDialog(activity) { +) : BaseBottomSheetDialog(activity) { private val binding = ReaderPageSheetBinding.inflate(activity.layoutInflater, null, false) @@ -27,14 +25,6 @@ class ReaderPageSheet( binding.saveLayout.setOnClickListener { save() } } - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - val width = context.resources.getDimensionPixelSize(R.dimen.bottom_sheet_width) - if (width > 0) { - window?.setLayout(width, ViewGroup.LayoutParams.MATCH_PARENT) - } - } - /** * Sets the image of this page as the cover of the manga. */ 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 48b323010..07b3b3bac 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 @@ -6,7 +6,6 @@ import android.widget.Spinner import androidx.annotation.ArrayRes import androidx.core.view.isVisible import androidx.core.widget.NestedScrollView -import com.google.android.material.bottomsheet.BottomSheetDialog import com.tfcporciuncula.flow.Preference import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper @@ -14,12 +13,13 @@ import eu.kanade.tachiyomi.databinding.ReaderSettingsSheetBinding import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerViewer import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener +import eu.kanade.tachiyomi.widget.sheet.BaseBottomSheetDialog import uy.kohesive.injekt.injectLazy /** * Sheet to show reader and viewer preferences. */ -class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDialog(activity) { +class ReaderSettingsSheet(private val activity: ReaderActivity) : BaseBottomSheetDialog(activity) { private val preferences: PreferencesHelper by injectLazy() diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/sheet/BaseBottomSheetDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/sheet/BaseBottomSheetDialog.kt new file mode 100644 index 000000000..1fb501d0e --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/sheet/BaseBottomSheetDialog.kt @@ -0,0 +1,18 @@ +package eu.kanade.tachiyomi.widget.sheet + +import android.content.Context +import android.os.Bundle +import android.view.ViewGroup +import com.google.android.material.bottomsheet.BottomSheetDialog +import eu.kanade.tachiyomi.R + +open class BaseBottomSheetDialog(context: Context) : BottomSheetDialog(context) { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val width = context.resources.getDimensionPixelSize(R.dimen.bottom_sheet_width) + if (width > 0) { + window?.setLayout(width, ViewGroup.LayoutParams.MATCH_PARENT) + } + } +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/TabbedBottomSheetDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/sheet/TabbedBottomSheetDialog.kt similarity index 88% rename from app/src/main/java/eu/kanade/tachiyomi/widget/TabbedBottomSheetDialog.kt rename to app/src/main/java/eu/kanade/tachiyomi/widget/sheet/TabbedBottomSheetDialog.kt index 8b840ac29..3d00688a9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/TabbedBottomSheetDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/sheet/TabbedBottomSheetDialog.kt @@ -1,12 +1,12 @@ -package eu.kanade.tachiyomi.widget +package eu.kanade.tachiyomi.widget.sheet import android.view.View import android.view.ViewGroup import com.bluelinelabs.conductor.Router -import com.google.android.material.bottomsheet.BottomSheetDialog import eu.kanade.tachiyomi.databinding.CommonTabbedSheetBinding +import eu.kanade.tachiyomi.widget.ViewPagerAdapter -abstract class TabbedBottomSheetDialog(private val router: Router) : BottomSheetDialog(router.activity!!) { +abstract class TabbedBottomSheetDialog(private val router: Router) : BaseBottomSheetDialog(router.activity!!) { val binding: CommonTabbedSheetBinding = CommonTabbedSheetBinding.inflate(router.activity!!.layoutInflater)