From 8523dba27b3768c4df73a1ac1cdaae23df486db2 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Mon, 26 Apr 2021 03:15:59 -0400 Subject: [PATCH] Creating a base class for the edge2edge bottomsheets --- .../tachiyomi/ui/base/MaterialMenuSheet.kt | 14 ++--- .../addtolibrary/SetCategoriesSheet.kt | 19 ++----- .../manga/chapter/ChaptersSortBottomSheet.kt | 18 ++---- .../ui/manga/track/TrackingBottomSheet.kt | 29 +++++----- .../design/MigrationBottomSheetDialog.kt | 11 ++-- .../settings/TabbedReaderSettingsSheet.kt | 5 -- .../ui/source/browse/SourceFilterSheet.kt | 14 ++--- .../tachiyomi/util/view/ViewExtensions.kt | 38 ------------- .../widget/EdgeToEdgeBottomSheetDialog.kt | 56 +++++++++++++++++++ .../tachiyomi/widget/TabbedBottomSheet.kt | 16 +----- .../main/res/layout/tracking_bottom_sheet.xml | 4 +- 11 files changed, 99 insertions(+), 125 deletions(-) create mode 100644 app/src/main/java/eu/kanade/tachiyomi/widget/EdgeToEdgeBottomSheetDialog.kt diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/MaterialMenuSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/MaterialMenuSheet.kt index 3803bd8bf8..f1c935ec29 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/MaterialMenuSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/MaterialMenuSheet.kt @@ -5,6 +5,7 @@ import android.animation.ValueAnimator import android.annotation.SuppressLint import android.app.Activity import android.os.Build +import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.annotation.DrawableRes @@ -12,17 +13,15 @@ import androidx.annotation.StringRes import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.view.isVisible import com.google.android.material.bottomsheet.BottomSheetBehavior -import com.google.android.material.bottomsheet.BottomSheetDialog import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.BottomMenuSheetBinding import eu.kanade.tachiyomi.util.system.dpToPx -import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.hasSideNavBar import eu.kanade.tachiyomi.util.system.isInNightMode import eu.kanade.tachiyomi.util.view.expand import eu.kanade.tachiyomi.util.view.setBottomEdge -import eu.kanade.tachiyomi.util.view.setEdgeToEdge import eu.kanade.tachiyomi.util.view.updateLayoutParams +import eu.kanade.tachiyomi.widget.EdgeToEdgeBottomSheetDialog import eu.kanade.tachiyomi.widget.MenuSheetItemView @SuppressLint("InflateParams") @@ -34,16 +33,11 @@ open class MaterialMenuSheet( maxHeight: Int? = null, showDivider: Boolean = false, onMenuItemClicked: (MaterialMenuSheet, Int) -> Boolean -) : - BottomSheetDialog - (activity, R.style.BottomSheetDialogTheme) { +) : EdgeToEdgeBottomSheetDialog(activity) { - private val primaryColor = activity.getResourceColor(android.R.attr.textColorPrimary) - private val binding = BottomMenuSheetBinding.inflate(activity.layoutInflater) + override fun createBinding(inflater: LayoutInflater) = BottomMenuSheetBinding.inflate(inflater) init { - setContentView(binding.root) - setEdgeToEdge(activity, binding.root) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !context.isInNightMode() && !activity.window.decorView.rootWindowInsets.hasSideNavBar()) { window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/addtolibrary/SetCategoriesSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/addtolibrary/SetCategoriesSheet.kt index 62680a06b8..28acb5fd91 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/addtolibrary/SetCategoriesSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/addtolibrary/SetCategoriesSheet.kt @@ -2,13 +2,12 @@ package eu.kanade.tachiyomi.ui.category.addtolibrary import android.app.Activity import android.os.Bundle +import android.view.LayoutInflater import android.view.View -import android.view.ViewGroup import androidx.constraintlayout.widget.ConstraintLayout import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.google.android.material.bottomsheet.BottomSheetBehavior -import com.google.android.material.bottomsheet.BottomSheetDialog import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.ISelectionListener import com.mikepenz.fastadapter.adapters.ItemAdapter @@ -23,9 +22,9 @@ import eu.kanade.tachiyomi.databinding.SetCategoriesSheetBinding import eu.kanade.tachiyomi.ui.category.ManageCategoryDialog 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 eu.kanade.tachiyomi.util.view.updatePaddingRelative +import eu.kanade.tachiyomi.widget.EdgeToEdgeBottomSheetDialog import uy.kohesive.injekt.injectLazy import java.util.ArrayList import java.util.Date @@ -39,27 +38,19 @@ class SetCategoriesSheet( var preselected: Array, private val addingToLibrary: Boolean, val onMangaAdded: (() -> Unit) = { } -) : BottomSheetDialog -(activity, R.style.BottomSheetDialogTheme) { +) : EdgeToEdgeBottomSheetDialog(activity) { constructor(activity: Activity, manga: Manga, categories: MutableList, preselected: Array, addingToLibrary: Boolean, onMangaAdded: () -> Unit) : this(activity, listOf(manga), categories, preselected, addingToLibrary, onMangaAdded) - private var sheetBehavior: BottomSheetBehavior<*> - private val fastAdapter: FastAdapter private val itemAdapter = ItemAdapter() private val selectExtension: SelectExtension private val db: DatabaseHelper by injectLazy() - private val binding = SetCategoriesSheetBinding.inflate(activity.layoutInflater) + override fun createBinding(inflater: LayoutInflater) = + SetCategoriesSheetBinding.inflate(inflater) init { - // Use activity theme for this layout - setContentView(binding.root) - - sheetBehavior = BottomSheetBehavior.from(binding.root.parent as ViewGroup) - setEdgeToEdge(activity, binding.root) - binding.toolbarTitle.text = context.getString( if (addingToLibrary) { R.string.add_x_to 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 27a87ccb7d..74b877852c 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 @@ -1,37 +1,29 @@ package eu.kanade.tachiyomi.ui.manga.chapter import android.os.Bundle +import android.view.LayoutInflater import android.view.View -import android.view.ViewGroup import androidx.core.view.isInvisible import androidx.core.view.isVisible import com.google.android.material.bottomsheet.BottomSheetBehavior -import com.google.android.material.bottomsheet.BottomSheetDialog import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.databinding.ChapterSortBottomSheetBinding import eu.kanade.tachiyomi.ui.manga.MangaDetailsController import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.view.setBottomEdge -import eu.kanade.tachiyomi.util.view.setEdgeToEdge +import eu.kanade.tachiyomi.widget.EdgeToEdgeBottomSheetDialog import kotlin.math.max -class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetDialog -(controller.activity!!, R.style.BottomSheetDialogTheme) { +class ChaptersSortBottomSheet(controller: MangaDetailsController) : + EdgeToEdgeBottomSheetDialog(controller.activity!!) { val activity = controller.activity!! - private var sheetBehavior: BottomSheetBehavior<*> - private val presenter = controller.presenter - private val binding = ChapterSortBottomSheetBinding.inflate(activity.layoutInflater) + override fun createBinding(inflater: LayoutInflater) = ChapterSortBottomSheetBinding.inflate(inflater) init { - // Use activity theme for this layout - setContentView(binding.root) - - sheetBehavior = BottomSheetBehavior.from(binding.root.parent as ViewGroup) - setEdgeToEdge(activity, binding.root) val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom sheetBehavior.peekHeight = 415.dpToPx + height diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackingBottomSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackingBottomSheet.kt index 430d5e26f4..8c7f509046 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackingBottomSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackingBottomSheet.kt @@ -2,12 +2,12 @@ package eu.kanade.tachiyomi.ui.manga.track import android.content.Intent import android.os.Bundle +import android.view.LayoutInflater import android.view.View -import android.view.ViewGroup +import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.net.toUri import androidx.recyclerview.widget.LinearLayoutManager import com.google.android.material.bottomsheet.BottomSheetBehavior -import com.google.android.material.bottomsheet.BottomSheetDialog import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.model.TrackSearch @@ -16,12 +16,13 @@ import eu.kanade.tachiyomi.ui.manga.MangaDetailsController import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener -import eu.kanade.tachiyomi.util.view.setEdgeToEdge +import eu.kanade.tachiyomi.util.view.checkHeightThen +import eu.kanade.tachiyomi.util.view.updateLayoutParams +import eu.kanade.tachiyomi.widget.EdgeToEdgeBottomSheetDialog import timber.log.Timber class TrackingBottomSheet(private val controller: MangaDetailsController) : - BottomSheetDialog - (controller.activity!!, R.style.BottomSheetDialogTheme), + EdgeToEdgeBottomSheetDialog(controller.activity!!), TrackAdapter.OnClickListener, SetTrackStatusDialog.Listener, SetTrackChaptersDialog.Listener, @@ -31,20 +32,14 @@ class TrackingBottomSheet(private val controller: MangaDetailsController) : val activity = controller.activity!! - private var sheetBehavior: BottomSheetBehavior<*> - val presenter = controller.presenter private var adapter: TrackAdapter? = null - private val binding = TrackingBottomSheetBinding.inflate(activity.layoutInflater) + override fun createBinding(inflater: LayoutInflater) = + TrackingBottomSheetBinding.inflate(inflater) init { - // Use activity theme for this layout - setContentView(binding.root) - - sheetBehavior = BottomSheetBehavior.from(binding.root.parent as ViewGroup) - setEdgeToEdge(activity, binding.root, 0) val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom sheetBehavior.peekHeight = 500.dpToPx + height @@ -59,6 +54,14 @@ class TrackingBottomSheet(private val controller: MangaDetailsController) : } } ) + binding.displayBottomSheet.checkHeightThen { + val fullHeight = activity.window.decorView.height + val insets = activity.window.decorView.rootWindowInsets + binding.trackRecycler.updateLayoutParams { + matchConstraintMaxHeight = + fullHeight - (insets?.systemWindowInsetTop ?: 0) - 30.dpToPx + } + } } override fun onStart() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/MigrationBottomSheetDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/MigrationBottomSheetDialog.kt index 23ee5f896e..dd3a148c96 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/MigrationBottomSheetDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/MigrationBottomSheetDialog.kt @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.migration.manga.design import android.app.Activity import android.content.res.Configuration import android.os.Bundle +import android.view.LayoutInflater import android.widget.CompoundButton import android.widget.LinearLayout import android.widget.RadioButton @@ -12,7 +13,6 @@ import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.view.isVisible import com.bluelinelabs.conductor.Controller import com.f2prateek.rx.preferences.Preference -import com.google.android.material.bottomsheet.BottomSheetDialog import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.getOrDefault @@ -22,23 +22,21 @@ import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.toInt import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.view.setBottomEdge -import eu.kanade.tachiyomi.util.view.setEdgeToEdge +import eu.kanade.tachiyomi.widget.EdgeToEdgeBottomSheetDialog import uy.kohesive.injekt.injectLazy class MigrationBottomSheetDialog( activity: Activity, private val listener: StartMigrationListener -) : BottomSheetDialog(activity, R.style.BottomSheetDialogTheme) { +) : EdgeToEdgeBottomSheetDialog(activity) { /** * Preferences helper. */ private val preferences by injectLazy() - private val binding = MigrationBottomSheetBinding.inflate(activity.layoutInflater) + override fun createBinding(inflater: LayoutInflater) = MigrationBottomSheetBinding.inflate(inflater) init { - // Use activity theme for this layout - setContentView(binding.root) if (activity.resources.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) { binding.sourceGroup.orientation = LinearLayout.HORIZONTAL val params = binding.skipStep.layoutParams as ConstraintLayout.LayoutParams @@ -61,7 +59,6 @@ class MigrationBottomSheetDialog( params3.endToEnd = -1 binding.extraSearchParam.layoutParams = params3 } - setEdgeToEdge(activity, binding.root) setBottomEdge( if (activity.resources.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) binding.extraSearchParamText else binding.skipStep, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/TabbedReaderSettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/TabbedReaderSettingsSheet.kt index 50613fd3f7..ecd5a0b80c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/TabbedReaderSettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/TabbedReaderSettingsSheet.kt @@ -1,12 +1,10 @@ package eu.kanade.tachiyomi.ui.reader.settings import android.view.View -import android.view.ViewGroup import android.view.WindowManager import androidx.core.content.ContextCompat import androidx.core.view.isInvisible import androidx.core.view.isVisible -import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.tabs.TabLayout import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.ReaderColorFilterBinding @@ -57,7 +55,6 @@ class TabbedReaderSettingsSheet( R.string.filter ) - var sheetBehavior: BottomSheetBehavior<*> init { generalView.activity = readerActivity pagedView.activity = readerActivity @@ -66,8 +63,6 @@ class TabbedReaderSettingsSheet( filterView.window = window generalView.sheet = this - sheetBehavior = BottomSheetBehavior.from(binding.root.parent as ViewGroup) - ReaderColorFilterBinding.bind(filterView).swipeDown.setOnClickListener { if (sheetBehavior.isCollapsed()) { sheetBehavior.expand() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/SourceFilterSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/SourceFilterSheet.kt index 711777c0ac..e3f7b4f42a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/SourceFilterSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/SourceFilterSheet.kt @@ -2,27 +2,24 @@ package eu.kanade.tachiyomi.ui.source.browse import android.app.Activity import android.os.Bundle +import android.view.LayoutInflater import android.view.View -import android.view.ViewGroup import android.view.ViewTreeObserver.OnGlobalLayoutListener import androidx.constraintlayout.widget.ConstraintLayout import androidx.recyclerview.widget.RecyclerView import com.google.android.material.bottomsheet.BottomSheetBehavior -import com.google.android.material.bottomsheet.BottomSheetDialog import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.items.IFlexible import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.SourceFilterSheetBinding import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.view.collapse -import eu.kanade.tachiyomi.util.view.setEdgeToEdge import eu.kanade.tachiyomi.util.view.updateLayoutParams import eu.kanade.tachiyomi.util.view.updatePaddingRelative +import eu.kanade.tachiyomi.widget.EdgeToEdgeBottomSheetDialog class SourceFilterSheet(val activity: Activity) : - BottomSheetDialog(activity, R.style.BottomSheetDialogTheme) { - - private val sheetBehavior: BottomSheetBehavior<*> + EdgeToEdgeBottomSheetDialog(activity) { private var filterChanged = true @@ -33,16 +30,13 @@ class SourceFilterSheet(val activity: Activity) : var onResetClicked = {} - private val binding = SourceFilterSheetBinding.inflate(activity.layoutInflater) + override fun createBinding(inflater: LayoutInflater) = SourceFilterSheetBinding.inflate(inflater) init { - setContentView(binding.root) binding.searchBtn.setOnClickListener { dismiss() } binding.resetBtn.setOnClickListener { onResetClicked() } - sheetBehavior = BottomSheetBehavior.from(binding.root.parent as ViewGroup) sheetBehavior.peekHeight = 450.dpToPx sheetBehavior.collapse() - setEdgeToEdge(activity, binding.root) binding.titleLayout.viewTreeObserver.addOnGlobalLayoutListener(object : OnGlobalLayoutListener { override fun onGlobalLayout() { 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 dfa2c6821c..9d1a94f026 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 @@ -34,7 +34,6 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.google.android.material.bottomnavigation.BottomNavigationItemView import com.google.android.material.bottomnavigation.BottomNavigationMenuView import com.google.android.material.bottomnavigation.BottomNavigationView -import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.button.MaterialButton import com.google.android.material.snackbar.Snackbar import eu.kanade.tachiyomi.R @@ -232,43 +231,6 @@ inline fun View.updatePaddingRelative( setPaddingRelative(start, top, end, bottom) } -fun BottomSheetDialog.setEdgeToEdge( - activity: Activity, - contentView: View, - setTopMargin: Int = -1 -) { - window?.setBackgroundDrawable(null) - window?.navigationBarColor = activity.window.navigationBarColor - val isLight = (activity.window?.decorView?.systemUiVisibility ?: 0) and View - .SYSTEM_UI_FLAG_LIGHT_STATUS_BAR == View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && isLight) { - window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR - } - window?.findViewById(com.google.android.material.R.id.container)?.fitsSystemWindows = - false - window?.findViewById(com.google.android.material.R.id.coordinator)?.fitsSystemWindows = - false - contentView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View - .SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - - val insets = activity.window.decorView.rootWindowInsets - (contentView.parent as View).background = null - contentView.post { - (contentView.parent as View).background = null - } - contentView.updateLayoutParams { - leftMargin = insets.systemWindowInsetLeft - rightMargin = insets.systemWindowInsetRight - } - if (setTopMargin > 0) (contentView.parent as View).updateLayoutParams { - height = activity.window.decorView.height - insets.systemWindowInsetTop - setTopMargin - } - else if (setTopMargin == 0) contentView.updateLayoutParams { - topMargin = insets.systemWindowInsetTop - } - contentView.requestLayout() -} - fun setBottomEdge(view: View, activity: Activity) { val marginB = view.marginBottom view.updateLayoutParams { diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/EdgeToEdgeBottomSheetDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/EdgeToEdgeBottomSheetDialog.kt new file mode 100644 index 0000000000..0e812bc27b --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/EdgeToEdgeBottomSheetDialog.kt @@ -0,0 +1,56 @@ +package eu.kanade.tachiyomi.widget + +import android.app.Activity +import android.os.Build +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.viewbinding.ViewBinding +import com.google.android.material.bottomsheet.BottomSheetBehavior +import com.google.android.material.bottomsheet.BottomSheetDialog +import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.util.view.updateLayoutParams + +@Suppress("LeakingThis") +abstract class EdgeToEdgeBottomSheetDialog(activity: Activity) : + BottomSheetDialog(activity, R.style.BottomSheetDialogTheme) { + protected val binding: VB + + protected val sheetBehavior: BottomSheetBehavior<*> + + init { + binding = createBinding(activity.layoutInflater) + setContentView(binding.root) + + sheetBehavior = BottomSheetBehavior.from(binding.root.parent as ViewGroup) + + val contentView = binding.root + + window?.setBackgroundDrawable(null) + window?.navigationBarColor = activity.window.navigationBarColor + val isLight = (activity.window?.decorView?.systemUiVisibility ?: 0) and View + .SYSTEM_UI_FLAG_LIGHT_STATUS_BAR == View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && isLight) { + window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR + } + window?.findViewById(com.google.android.material.R.id.container)?.fitsSystemWindows = + false + window?.findViewById(com.google.android.material.R.id.coordinator)?.fitsSystemWindows = + false + contentView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View + .SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + + val insets = activity.window.decorView.rootWindowInsets + (contentView.parent as View).background = null + contentView.post { + (contentView.parent as View).background = null + } + contentView.updateLayoutParams { + leftMargin = insets.systemWindowInsetLeft + rightMargin = insets.systemWindowInsetRight + } + contentView.requestLayout() + } + + abstract fun createBinding(inflater: LayoutInflater): VB +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/TabbedBottomSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/TabbedBottomSheet.kt index b58d782e54..bdff3f8ccb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/TabbedBottomSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/TabbedBottomSheet.kt @@ -3,34 +3,24 @@ package eu.kanade.tachiyomi.widget import android.app.Activity import android.content.Context import android.util.AttributeSet +import android.view.LayoutInflater import android.view.View import android.view.ViewGroup 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.databinding.TabbedBottomSheetBinding import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.view.expand -import eu.kanade.tachiyomi.util.view.setEdgeToEdge import kotlin.math.max abstract class TabbedBottomSheetDialog(private val activity: Activity) : - BottomSheetDialog - (activity, R.style.BottomSheetDialogTheme) { + EdgeToEdgeBottomSheetDialog(activity) { - private var sheetBehavior: BottomSheetBehavior<*> - protected val binding = TabbedBottomSheetBinding.inflate(activity.layoutInflater) + override fun createBinding(inflater: LayoutInflater) = TabbedBottomSheetBinding.inflate(inflater) open var offset = -1 init { - // Use activity theme for this layout - setContentView(binding.root) - sheetBehavior = BottomSheetBehavior.from(binding.root.parent as ViewGroup) - setEdgeToEdge(activity, binding.root) - val height = activity.window.decorView.rootWindowInsets.systemWindowInsetTop binding.pager.maxHeight = activity.window.decorView.height - height - 125.dpToPx diff --git a/app/src/main/res/layout/tracking_bottom_sheet.xml b/app/src/main/res/layout/tracking_bottom_sheet.xml index 5c79f350f1..419ffd5bd7 100644 --- a/app/src/main/res/layout/tracking_bottom_sheet.xml +++ b/app/src/main/res/layout/tracking_bottom_sheet.xml @@ -1,5 +1,5 @@ - - \ No newline at end of file + \ No newline at end of file