mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 17:05:07 +01:00
Creating a base class for the edge2edge bottomsheets
This commit is contained in:
parent
5ca4e8ade0
commit
8523dba27b
@ -5,6 +5,7 @@ import android.animation.ValueAnimator
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
@ -12,17 +13,15 @@ import androidx.annotation.StringRes
|
|||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.databinding.BottomMenuSheetBinding
|
import eu.kanade.tachiyomi.databinding.BottomMenuSheetBinding
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
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.hasSideNavBar
|
||||||
import eu.kanade.tachiyomi.util.system.isInNightMode
|
import eu.kanade.tachiyomi.util.system.isInNightMode
|
||||||
import eu.kanade.tachiyomi.util.view.expand
|
import eu.kanade.tachiyomi.util.view.expand
|
||||||
import eu.kanade.tachiyomi.util.view.setBottomEdge
|
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.util.view.updateLayoutParams
|
||||||
|
import eu.kanade.tachiyomi.widget.EdgeToEdgeBottomSheetDialog
|
||||||
import eu.kanade.tachiyomi.widget.MenuSheetItemView
|
import eu.kanade.tachiyomi.widget.MenuSheetItemView
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
@ -34,16 +33,11 @@ open class MaterialMenuSheet(
|
|||||||
maxHeight: Int? = null,
|
maxHeight: Int? = null,
|
||||||
showDivider: Boolean = false,
|
showDivider: Boolean = false,
|
||||||
onMenuItemClicked: (MaterialMenuSheet, Int) -> Boolean
|
onMenuItemClicked: (MaterialMenuSheet, Int) -> Boolean
|
||||||
) :
|
) : EdgeToEdgeBottomSheetDialog<BottomMenuSheetBinding>(activity) {
|
||||||
BottomSheetDialog
|
|
||||||
(activity, R.style.BottomSheetDialogTheme) {
|
|
||||||
|
|
||||||
private val primaryColor = activity.getResourceColor(android.R.attr.textColorPrimary)
|
override fun createBinding(inflater: LayoutInflater) = BottomMenuSheetBinding.inflate(inflater)
|
||||||
private val binding = BottomMenuSheetBinding.inflate(activity.layoutInflater)
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setContentView(binding.root)
|
|
||||||
setEdgeToEdge(activity, binding.root)
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !context.isInNightMode() && !activity.window.decorView.rootWindowInsets.hasSideNavBar()) {
|
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
|
window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,12 @@ package eu.kanade.tachiyomi.ui.category.addtolibrary
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
|
||||||
import com.mikepenz.fastadapter.FastAdapter
|
import com.mikepenz.fastadapter.FastAdapter
|
||||||
import com.mikepenz.fastadapter.ISelectionListener
|
import com.mikepenz.fastadapter.ISelectionListener
|
||||||
import com.mikepenz.fastadapter.adapters.ItemAdapter
|
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.ui.category.ManageCategoryDialog
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.view.expand
|
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.updateLayoutParams
|
||||||
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
||||||
|
import eu.kanade.tachiyomi.widget.EdgeToEdgeBottomSheetDialog
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
@ -39,27 +38,19 @@ class SetCategoriesSheet(
|
|||||||
var preselected: Array<Int>,
|
var preselected: Array<Int>,
|
||||||
private val addingToLibrary: Boolean,
|
private val addingToLibrary: Boolean,
|
||||||
val onMangaAdded: (() -> Unit) = { }
|
val onMangaAdded: (() -> Unit) = { }
|
||||||
) : BottomSheetDialog
|
) : EdgeToEdgeBottomSheetDialog<SetCategoriesSheetBinding>(activity) {
|
||||||
(activity, R.style.BottomSheetDialogTheme) {
|
|
||||||
|
|
||||||
constructor(activity: Activity, manga: Manga, categories: MutableList<Category>, preselected: Array<Int>, addingToLibrary: Boolean, onMangaAdded: () -> Unit) :
|
constructor(activity: Activity, manga: Manga, categories: MutableList<Category>, preselected: Array<Int>, addingToLibrary: Boolean, onMangaAdded: () -> Unit) :
|
||||||
this(activity, listOf(manga), categories, preselected, addingToLibrary, onMangaAdded)
|
this(activity, listOf(manga), categories, preselected, addingToLibrary, onMangaAdded)
|
||||||
|
|
||||||
private var sheetBehavior: BottomSheetBehavior<*>
|
|
||||||
|
|
||||||
private val fastAdapter: FastAdapter<AddCategoryItem>
|
private val fastAdapter: FastAdapter<AddCategoryItem>
|
||||||
private val itemAdapter = ItemAdapter<AddCategoryItem>()
|
private val itemAdapter = ItemAdapter<AddCategoryItem>()
|
||||||
private val selectExtension: SelectExtension<AddCategoryItem>
|
private val selectExtension: SelectExtension<AddCategoryItem>
|
||||||
private val db: DatabaseHelper by injectLazy()
|
private val db: DatabaseHelper by injectLazy()
|
||||||
|
|
||||||
private val binding = SetCategoriesSheetBinding.inflate(activity.layoutInflater)
|
override fun createBinding(inflater: LayoutInflater) =
|
||||||
|
SetCategoriesSheetBinding.inflate(inflater)
|
||||||
init {
|
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(
|
binding.toolbarTitle.text = context.getString(
|
||||||
if (addingToLibrary) {
|
if (addingToLibrary) {
|
||||||
R.string.add_x_to
|
R.string.add_x_to
|
||||||
|
@ -1,37 +1,29 @@
|
|||||||
package eu.kanade.tachiyomi.ui.manga.chapter
|
package eu.kanade.tachiyomi.ui.manga.chapter
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.core.view.isInvisible
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.databinding.ChapterSortBottomSheetBinding
|
import eu.kanade.tachiyomi.databinding.ChapterSortBottomSheetBinding
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
|
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.view.setBottomEdge
|
import eu.kanade.tachiyomi.util.view.setBottomEdge
|
||||||
import eu.kanade.tachiyomi.util.view.setEdgeToEdge
|
import eu.kanade.tachiyomi.widget.EdgeToEdgeBottomSheetDialog
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
|
|
||||||
class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetDialog
|
class ChaptersSortBottomSheet(controller: MangaDetailsController) :
|
||||||
(controller.activity!!, R.style.BottomSheetDialogTheme) {
|
EdgeToEdgeBottomSheetDialog<ChapterSortBottomSheetBinding>(controller.activity!!) {
|
||||||
|
|
||||||
val activity = controller.activity!!
|
val activity = controller.activity!!
|
||||||
|
|
||||||
private var sheetBehavior: BottomSheetBehavior<*>
|
|
||||||
|
|
||||||
private val presenter = controller.presenter
|
private val presenter = controller.presenter
|
||||||
|
|
||||||
private val binding = ChapterSortBottomSheetBinding.inflate(activity.layoutInflater)
|
override fun createBinding(inflater: LayoutInflater) = ChapterSortBottomSheetBinding.inflate(inflater)
|
||||||
init {
|
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
|
val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom
|
||||||
sheetBehavior.peekHeight = 415.dpToPx + height
|
sheetBehavior.peekHeight = 415.dpToPx + height
|
||||||
|
|
||||||
|
@ -2,12 +2,12 @@ package eu.kanade.tachiyomi.ui.manga.track
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.track.TrackService
|
import eu.kanade.tachiyomi.data.track.TrackService
|
||||||
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
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.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
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
|
import timber.log.Timber
|
||||||
|
|
||||||
class TrackingBottomSheet(private val controller: MangaDetailsController) :
|
class TrackingBottomSheet(private val controller: MangaDetailsController) :
|
||||||
BottomSheetDialog
|
EdgeToEdgeBottomSheetDialog<TrackingBottomSheetBinding>(controller.activity!!),
|
||||||
(controller.activity!!, R.style.BottomSheetDialogTheme),
|
|
||||||
TrackAdapter.OnClickListener,
|
TrackAdapter.OnClickListener,
|
||||||
SetTrackStatusDialog.Listener,
|
SetTrackStatusDialog.Listener,
|
||||||
SetTrackChaptersDialog.Listener,
|
SetTrackChaptersDialog.Listener,
|
||||||
@ -31,20 +32,14 @@ class TrackingBottomSheet(private val controller: MangaDetailsController) :
|
|||||||
|
|
||||||
val activity = controller.activity!!
|
val activity = controller.activity!!
|
||||||
|
|
||||||
private var sheetBehavior: BottomSheetBehavior<*>
|
|
||||||
|
|
||||||
val presenter = controller.presenter
|
val presenter = controller.presenter
|
||||||
|
|
||||||
private var adapter: TrackAdapter? = null
|
private var adapter: TrackAdapter? = null
|
||||||
|
|
||||||
private val binding = TrackingBottomSheetBinding.inflate(activity.layoutInflater)
|
override fun createBinding(inflater: LayoutInflater) =
|
||||||
|
TrackingBottomSheetBinding.inflate(inflater)
|
||||||
|
|
||||||
init {
|
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
|
val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom
|
||||||
sheetBehavior.peekHeight = 500.dpToPx + height
|
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<ConstraintLayout.LayoutParams> {
|
||||||
|
matchConstraintMaxHeight =
|
||||||
|
fullHeight - (insets?.systemWindowInsetTop ?: 0) - 30.dpToPx
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.migration.manga.design
|
|||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.widget.CompoundButton
|
import android.widget.CompoundButton
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.RadioButton
|
import android.widget.RadioButton
|
||||||
@ -12,7 +13,6 @@ import androidx.constraintlayout.widget.ConstraintLayout
|
|||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.bluelinelabs.conductor.Controller
|
import com.bluelinelabs.conductor.Controller
|
||||||
import com.f2prateek.rx.preferences.Preference
|
import com.f2prateek.rx.preferences.Preference
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
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.toInt
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import eu.kanade.tachiyomi.util.view.setBottomEdge
|
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
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class MigrationBottomSheetDialog(
|
class MigrationBottomSheetDialog(
|
||||||
activity: Activity,
|
activity: Activity,
|
||||||
private val listener: StartMigrationListener
|
private val listener: StartMigrationListener
|
||||||
) : BottomSheetDialog(activity, R.style.BottomSheetDialogTheme) {
|
) : EdgeToEdgeBottomSheetDialog<MigrationBottomSheetBinding>(activity) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preferences helper.
|
* Preferences helper.
|
||||||
*/
|
*/
|
||||||
private val preferences by injectLazy<PreferencesHelper>()
|
private val preferences by injectLazy<PreferencesHelper>()
|
||||||
|
|
||||||
private val binding = MigrationBottomSheetBinding.inflate(activity.layoutInflater)
|
override fun createBinding(inflater: LayoutInflater) = MigrationBottomSheetBinding.inflate(inflater)
|
||||||
init {
|
init {
|
||||||
// Use activity theme for this layout
|
|
||||||
setContentView(binding.root)
|
|
||||||
if (activity.resources.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
if (activity.resources.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
binding.sourceGroup.orientation = LinearLayout.HORIZONTAL
|
binding.sourceGroup.orientation = LinearLayout.HORIZONTAL
|
||||||
val params = binding.skipStep.layoutParams as ConstraintLayout.LayoutParams
|
val params = binding.skipStep.layoutParams as ConstraintLayout.LayoutParams
|
||||||
@ -61,7 +59,6 @@ class MigrationBottomSheetDialog(
|
|||||||
params3.endToEnd = -1
|
params3.endToEnd = -1
|
||||||
binding.extraSearchParam.layoutParams = params3
|
binding.extraSearchParam.layoutParams = params3
|
||||||
}
|
}
|
||||||
setEdgeToEdge(activity, binding.root)
|
|
||||||
setBottomEdge(
|
setBottomEdge(
|
||||||
if (activity.resources.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) binding.extraSearchParamText
|
if (activity.resources.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) binding.extraSearchParamText
|
||||||
else binding.skipStep,
|
else binding.skipStep,
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package eu.kanade.tachiyomi.ui.reader.settings
|
package eu.kanade.tachiyomi.ui.reader.settings
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.isInvisible
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
|
||||||
import com.google.android.material.tabs.TabLayout
|
import com.google.android.material.tabs.TabLayout
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.databinding.ReaderColorFilterBinding
|
import eu.kanade.tachiyomi.databinding.ReaderColorFilterBinding
|
||||||
@ -57,7 +55,6 @@ class TabbedReaderSettingsSheet(
|
|||||||
R.string.filter
|
R.string.filter
|
||||||
)
|
)
|
||||||
|
|
||||||
var sheetBehavior: BottomSheetBehavior<*>
|
|
||||||
init {
|
init {
|
||||||
generalView.activity = readerActivity
|
generalView.activity = readerActivity
|
||||||
pagedView.activity = readerActivity
|
pagedView.activity = readerActivity
|
||||||
@ -66,8 +63,6 @@ class TabbedReaderSettingsSheet(
|
|||||||
filterView.window = window
|
filterView.window = window
|
||||||
generalView.sheet = this
|
generalView.sheet = this
|
||||||
|
|
||||||
sheetBehavior = BottomSheetBehavior.from(binding.root.parent as ViewGroup)
|
|
||||||
|
|
||||||
ReaderColorFilterBinding.bind(filterView).swipeDown.setOnClickListener {
|
ReaderColorFilterBinding.bind(filterView).swipeDown.setOnClickListener {
|
||||||
if (sheetBehavior.isCollapsed()) {
|
if (sheetBehavior.isCollapsed()) {
|
||||||
sheetBehavior.expand()
|
sheetBehavior.expand()
|
||||||
|
@ -2,27 +2,24 @@ package eu.kanade.tachiyomi.ui.source.browse
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener
|
import android.view.ViewTreeObserver.OnGlobalLayoutListener
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.databinding.SourceFilterSheetBinding
|
import eu.kanade.tachiyomi.databinding.SourceFilterSheetBinding
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.view.collapse
|
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.updateLayoutParams
|
||||||
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
||||||
|
import eu.kanade.tachiyomi.widget.EdgeToEdgeBottomSheetDialog
|
||||||
|
|
||||||
class SourceFilterSheet(val activity: Activity) :
|
class SourceFilterSheet(val activity: Activity) :
|
||||||
BottomSheetDialog(activity, R.style.BottomSheetDialogTheme) {
|
EdgeToEdgeBottomSheetDialog<SourceFilterSheetBinding>(activity) {
|
||||||
|
|
||||||
private val sheetBehavior: BottomSheetBehavior<*>
|
|
||||||
|
|
||||||
private var filterChanged = true
|
private var filterChanged = true
|
||||||
|
|
||||||
@ -33,16 +30,13 @@ class SourceFilterSheet(val activity: Activity) :
|
|||||||
|
|
||||||
var onResetClicked = {}
|
var onResetClicked = {}
|
||||||
|
|
||||||
private val binding = SourceFilterSheetBinding.inflate(activity.layoutInflater)
|
override fun createBinding(inflater: LayoutInflater) = SourceFilterSheetBinding.inflate(inflater)
|
||||||
init {
|
init {
|
||||||
setContentView(binding.root)
|
|
||||||
binding.searchBtn.setOnClickListener { dismiss() }
|
binding.searchBtn.setOnClickListener { dismiss() }
|
||||||
binding.resetBtn.setOnClickListener { onResetClicked() }
|
binding.resetBtn.setOnClickListener { onResetClicked() }
|
||||||
|
|
||||||
sheetBehavior = BottomSheetBehavior.from(binding.root.parent as ViewGroup)
|
|
||||||
sheetBehavior.peekHeight = 450.dpToPx
|
sheetBehavior.peekHeight = 450.dpToPx
|
||||||
sheetBehavior.collapse()
|
sheetBehavior.collapse()
|
||||||
setEdgeToEdge(activity, binding.root)
|
|
||||||
|
|
||||||
binding.titleLayout.viewTreeObserver.addOnGlobalLayoutListener(object : OnGlobalLayoutListener {
|
binding.titleLayout.viewTreeObserver.addOnGlobalLayoutListener(object : OnGlobalLayoutListener {
|
||||||
override fun onGlobalLayout() {
|
override fun onGlobalLayout() {
|
||||||
|
@ -34,7 +34,6 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
|||||||
import com.google.android.material.bottomnavigation.BottomNavigationItemView
|
import com.google.android.material.bottomnavigation.BottomNavigationItemView
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationMenuView
|
import com.google.android.material.bottomnavigation.BottomNavigationMenuView
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
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.button.MaterialButton
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
@ -232,43 +231,6 @@ inline fun View.updatePaddingRelative(
|
|||||||
setPaddingRelative(start, top, end, bottom)
|
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<View>(com.google.android.material.R.id.container)?.fitsSystemWindows =
|
|
||||||
false
|
|
||||||
window?.findViewById<View>(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<ViewGroup.MarginLayoutParams> {
|
|
||||||
leftMargin = insets.systemWindowInsetLeft
|
|
||||||
rightMargin = insets.systemWindowInsetRight
|
|
||||||
}
|
|
||||||
if (setTopMargin > 0) (contentView.parent as View).updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
|
||||||
height = activity.window.decorView.height - insets.systemWindowInsetTop - setTopMargin
|
|
||||||
}
|
|
||||||
else if (setTopMargin == 0) contentView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
|
||||||
topMargin = insets.systemWindowInsetTop
|
|
||||||
}
|
|
||||||
contentView.requestLayout()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setBottomEdge(view: View, activity: Activity) {
|
fun setBottomEdge(view: View, activity: Activity) {
|
||||||
val marginB = view.marginBottom
|
val marginB = view.marginBottom
|
||||||
view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
|
@ -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<VB : ViewBinding>(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<View>(com.google.android.material.R.id.container)?.fitsSystemWindows =
|
||||||
|
false
|
||||||
|
window?.findViewById<View>(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<ViewGroup.MarginLayoutParams> {
|
||||||
|
leftMargin = insets.systemWindowInsetLeft
|
||||||
|
rightMargin = insets.systemWindowInsetRight
|
||||||
|
}
|
||||||
|
contentView.requestLayout()
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract fun createBinding(inflater: LayoutInflater): VB
|
||||||
|
}
|
@ -3,34 +3,24 @@ package eu.kanade.tachiyomi.widget
|
|||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.widget.NestedScrollView
|
import androidx.core.widget.NestedScrollView
|
||||||
import androidx.viewpager.widget.ViewPager
|
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 com.google.android.material.tabs.TabLayout
|
||||||
import eu.kanade.tachiyomi.R
|
|
||||||
import eu.kanade.tachiyomi.databinding.TabbedBottomSheetBinding
|
import eu.kanade.tachiyomi.databinding.TabbedBottomSheetBinding
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.view.expand
|
import eu.kanade.tachiyomi.util.view.expand
|
||||||
import eu.kanade.tachiyomi.util.view.setEdgeToEdge
|
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
|
|
||||||
abstract class TabbedBottomSheetDialog(private val activity: Activity) :
|
abstract class TabbedBottomSheetDialog(private val activity: Activity) :
|
||||||
BottomSheetDialog
|
EdgeToEdgeBottomSheetDialog<TabbedBottomSheetBinding>(activity) {
|
||||||
(activity, R.style.BottomSheetDialogTheme) {
|
|
||||||
|
|
||||||
private var sheetBehavior: BottomSheetBehavior<*>
|
override fun createBinding(inflater: LayoutInflater) = TabbedBottomSheetBinding.inflate(inflater)
|
||||||
protected val binding = TabbedBottomSheetBinding.inflate(activity.layoutInflater)
|
|
||||||
|
|
||||||
open var offset = -1
|
open var offset = -1
|
||||||
init {
|
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
|
val height = activity.window.decorView.rootWindowInsets.systemWindowInsetTop
|
||||||
binding.pager.maxHeight = activity.window.decorView.height - height - 125.dpToPx
|
binding.pager.maxHeight = activity.window.decorView.height - height - 125.dpToPx
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/display_bottom_sheet"
|
android:id="@+id/display_bottom_sheet"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -13,4 +13,4 @@
|
|||||||
android:paddingTop="5dp"
|
android:paddingTop="5dp"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
tools:listitem="@layout/track_item" />
|
tools:listitem="@layout/track_item" />
|
||||||
</FrameLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue
Block a user