mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 01:35:09 +01:00
Fixes to swiping chapters
Fixes also to the bottom sheets
This commit is contained in:
parent
776c85a954
commit
fde6506842
@ -20,7 +20,7 @@ import kotlinx.android.synthetic.main.catalogue_drawer_content.*
|
|||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class CatalogueSearchSheet(activity: Activity) :
|
class CatalogueSearchSheet(activity: Activity) :
|
||||||
BottomSheetDialog(activity, R.style.BottomSheetDialogThemeCovered) {
|
BottomSheetDialog(activity, R.style.BottomSheetDialogTheme) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preferences helper.
|
* Preferences helper.
|
||||||
@ -61,11 +61,8 @@ class CatalogueSearchSheet(activity: Activity) :
|
|||||||
sheetBehavior.skipCollapsed = true
|
sheetBehavior.skipCollapsed = true
|
||||||
sheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
|
sheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||||
setEdgeToEdge(
|
setEdgeToEdge(
|
||||||
activity, recycler, view, 50.dpToPx
|
activity, view, 50.dpToPx
|
||||||
)
|
)
|
||||||
// window?.findViewById<View>(com.google.android.material.R.id.container)?.fitsSystemWindows =
|
|
||||||
// false
|
|
||||||
window?.navigationBarColor = activity.window.navigationBarColor
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && preferences.readerTheme()
|
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
|
.getOrDefault() == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetLeft == 0
|
||||||
) window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
) window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
||||||
|
@ -20,7 +20,7 @@ import kotlinx.android.synthetic.main.display_bottom_sheet.*
|
|||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class DisplayBottomSheet(private val controller: LibraryController) : BottomSheetDialog
|
class DisplayBottomSheet(private val controller: LibraryController) : BottomSheetDialog
|
||||||
(controller.activity!!, R.style.BottomSheetDialogThemeCovered) {
|
(controller.activity!!, R.style.BottomSheetDialogTheme) {
|
||||||
|
|
||||||
val activity = controller.activity!!
|
val activity = controller.activity!!
|
||||||
|
|
||||||
@ -37,10 +37,9 @@ class DisplayBottomSheet(private val controller: LibraryController) : BottomShee
|
|||||||
setContentView(view)
|
setContentView(view)
|
||||||
|
|
||||||
sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup)
|
sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup)
|
||||||
setEdgeToEdge(activity, bottom_sheet, view)
|
setEdgeToEdge(activity, view)
|
||||||
val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom
|
val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom
|
||||||
sheetBehavior.peekHeight = 220.dpToPx + height
|
sheetBehavior.peekHeight = 220.dpToPx + height
|
||||||
window?.navigationBarColor = activity.window.navigationBarColor
|
|
||||||
|
|
||||||
sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
||||||
override fun onSlide(bottomSheet: View, progress: Float) { }
|
override fun onSlide(bottomSheet: View, progress: Float) { }
|
||||||
|
@ -5,7 +5,6 @@ import android.animation.AnimatorSet
|
|||||||
import android.animation.ValueAnimator
|
import android.animation.ValueAnimator
|
||||||
import android.app.SearchManager
|
import android.app.SearchManager
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.Configuration
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
@ -17,6 +16,7 @@ import android.view.MenuItem
|
|||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.view.WindowInsets
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
import androidx.appcompat.content.res.AppCompatResources
|
||||||
@ -59,6 +59,7 @@ import eu.kanade.tachiyomi.ui.setting.SettingsController
|
|||||||
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
|
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.system.launchUI
|
import eu.kanade.tachiyomi.util.system.launchUI
|
||||||
|
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
||||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||||
import eu.kanade.tachiyomi.util.view.updatePadding
|
import eu.kanade.tachiyomi.util.view.updatePadding
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
@ -196,29 +197,9 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
|||||||
|
|
||||||
supportActionBar?.setDisplayShowCustomEnabled(true)
|
supportActionBar?.setDisplayShowCustomEnabled(true)
|
||||||
|
|
||||||
content.setOnApplyWindowInsetsListener { v, insets ->
|
setNavBarColor(content.rootWindowInsets)
|
||||||
window.navigationBarColor = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O_MR1) {
|
content.doOnApplyWindowInsets { v, insets, _ ->
|
||||||
// basically if in landscape on a phone
|
setNavBarColor(insets)
|
||||||
// For lollipop, draw opaque nav bar
|
|
||||||
if (v.rootWindowInsets.systemWindowInsetLeft > 0 || v.rootWindowInsets.systemWindowInsetRight > 0)
|
|
||||||
Color.BLACK
|
|
||||||
else Color.argb(179, 0, 0, 0)
|
|
||||||
}
|
|
||||||
// if the android q+ device has gesture nav, transparent nav bar
|
|
||||||
// this is here in case some crazy with a notch uses landscape
|
|
||||||
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && (v.rootWindowInsets.systemWindowInsetBottom != v.rootWindowInsets.tappableElementInsets.bottom)) {
|
|
||||||
getColor(android.R.color.transparent)
|
|
||||||
}
|
|
||||||
// if in landscape with 2/3 button mode, fully opaque nav bar
|
|
||||||
else if (v.rootWindowInsets.systemWindowInsetLeft > 0 || v.rootWindowInsets.systemWindowInsetRight > 0) {
|
|
||||||
getResourceColor(R.attr.colorPrimaryVariant)
|
|
||||||
}
|
|
||||||
// if in portrait with 2/3 button mode, translucent nav bar
|
|
||||||
else {
|
|
||||||
ColorUtils.setAlphaComponent(
|
|
||||||
getResourceColor(R.attr.colorPrimaryVariant), 179
|
|
||||||
)
|
|
||||||
}
|
|
||||||
val contextView = window?.decorView?.findViewById<View>(R.id.action_mode_bar)
|
val contextView = window?.decorView?.findViewById<View>(R.id.action_mode_bar)
|
||||||
contextView?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
contextView?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
leftMargin = insets.systemWindowInsetLeft
|
leftMargin = insets.systemWindowInsetLeft
|
||||||
@ -234,13 +215,10 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
|||||||
)
|
)
|
||||||
bottom_nav.updatePadding(bottom = insets.systemWindowInsetBottom)
|
bottom_nav.updatePadding(bottom = insets.systemWindowInsetBottom)
|
||||||
|
|
||||||
insets.replaceSystemWindowInsets(
|
/*insets.replaceSystemWindowInsets(
|
||||||
0, insets.systemWindowInsetTop, 0, insets.systemWindowInsetBottom
|
0, insets.systemWindowInsetTop, 0, insets.systemWindowInsetBottom
|
||||||
)
|
)*/
|
||||||
|
|
||||||
insets
|
|
||||||
}
|
}
|
||||||
val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
|
||||||
|
|
||||||
router = Conductor.attachRouter(this, container, savedInstanceState)
|
router = Conductor.attachRouter(this, container, savedInstanceState)
|
||||||
if (!router.hasRootController()) {
|
if (!router.hasRootController()) {
|
||||||
@ -305,6 +283,33 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
|||||||
setExtensionsBadge()
|
setExtensionsBadge()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setNavBarColor(insets: WindowInsets?) {
|
||||||
|
if (insets == null) return
|
||||||
|
window.navigationBarColor = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O_MR1) {
|
||||||
|
// basically if in landscape on a phone
|
||||||
|
// For lollipop, draw opaque nav bar
|
||||||
|
if (insets.systemWindowInsetLeft > 0 || insets.systemWindowInsetRight > 0)
|
||||||
|
Color.BLACK
|
||||||
|
else Color.argb(179, 0, 0, 0)
|
||||||
|
}
|
||||||
|
// if the android q+ device has gesture nav, transparent nav bar
|
||||||
|
// this is here in case some crazy with a notch uses landscape
|
||||||
|
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && (insets
|
||||||
|
.systemWindowInsetBottom != insets.tappableElementInsets.bottom)) {
|
||||||
|
getColor(android.R.color.transparent)
|
||||||
|
}
|
||||||
|
// if in landscape with 2/3 button mode, fully opaque nav bar
|
||||||
|
else if (insets.systemWindowInsetLeft > 0 || insets.systemWindowInsetRight > 0) {
|
||||||
|
getResourceColor(R.attr.colorPrimaryVariant)
|
||||||
|
}
|
||||||
|
// if in portrait with 2/3 button mode, translucent nav bar
|
||||||
|
else {
|
||||||
|
ColorUtils.setAlphaComponent(
|
||||||
|
getResourceColor(R.attr.colorPrimaryVariant), 179
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun updateRecentsIcon() {
|
fun updateRecentsIcon() {
|
||||||
bottom_nav.menu.findItem(R.id.nav_recents).icon = AppCompatResources.getDrawable(
|
bottom_nav.menu.findItem(R.id.nav_recents).icon = AppCompatResources.getDrawable(
|
||||||
this,
|
this,
|
||||||
|
@ -52,7 +52,7 @@ class MangaDetailsAdapter(
|
|||||||
fun performFilter() {
|
fun performFilter() {
|
||||||
val s = getFilter(String::class.java)
|
val s = getFilter(String::class.java)
|
||||||
if (s.isNullOrBlank()) {
|
if (s.isNullOrBlank()) {
|
||||||
updateDataSet(items)
|
updateDataSet(items, true)
|
||||||
} else {
|
} else {
|
||||||
updateDataSet(items.filter { it.name.contains(s, true) ||
|
updateDataSet(items.filter { it.name.contains(s, true) ||
|
||||||
it.scanlator?.contains(s, true) == true })
|
it.scanlator?.contains(s, true) == true })
|
||||||
|
@ -526,14 +526,11 @@ class MangaDetailsController : BaseController,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun markAsRead(chapters: List<ChapterItem>) {
|
private fun markAsRead(chapters: List<ChapterItem>) {
|
||||||
presenter.markChaptersRead(chapters, read = true)
|
presenter.markChaptersRead(chapters, true)
|
||||||
if (presenter.preferences.removeAfterMarkedAsRead()) {
|
|
||||||
presenter.deleteChapters(chapters)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun markAsUnread(chapters: List<ChapterItem>) {
|
private fun markAsUnread(chapters: List<ChapterItem>) {
|
||||||
presenter.markChaptersRead(chapters, read = false)
|
presenter.markChaptersRead(chapters, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun openChapter(chapter: Chapter) {
|
private fun openChapter(chapter: Chapter) {
|
||||||
|
@ -292,14 +292,15 @@ class MangaDetailsPresenter(
|
|||||||
* Deletes the given list of chapter.
|
* Deletes the given list of chapter.
|
||||||
* @param chapters the list of chapters to delete.
|
* @param chapters the list of chapters to delete.
|
||||||
*/
|
*/
|
||||||
fun deleteChapters(chapters: List<ChapterItem>) {
|
fun deleteChapters(chapters: List<ChapterItem>, update: Boolean = true) {
|
||||||
deleteChaptersInternal(chapters)
|
deleteChaptersInternal(chapters)
|
||||||
|
|
||||||
chapters.forEach { chapter ->
|
chapters.forEach { chapter ->
|
||||||
this.chapters.find { it.id == chapter.id }?.download?.status = Download.NOT_DOWNLOADED
|
this.chapters.find { it.id == chapter.id }?.download?.status = Download.NOT_DOWNLOADED
|
||||||
}
|
}
|
||||||
|
|
||||||
controller.updateChapters(this.chapters)
|
if (update)
|
||||||
|
controller.updateChapters(this.chapters)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -404,6 +405,7 @@ class MangaDetailsPresenter(
|
|||||||
it.bookmark = bookmarked
|
it.bookmark = bookmarked
|
||||||
}
|
}
|
||||||
db.updateChaptersProgress(selectedChapters).executeAsBlocking()
|
db.updateChaptersProgress(selectedChapters).executeAsBlocking()
|
||||||
|
getChapters()
|
||||||
withContext(Dispatchers.Main) { controller.updateChapters(chapters) }
|
withContext(Dispatchers.Main) { controller.updateChapters(chapters) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -423,6 +425,10 @@ class MangaDetailsPresenter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
db.updateChaptersProgress(selectedChapters).executeAsBlocking()
|
db.updateChaptersProgress(selectedChapters).executeAsBlocking()
|
||||||
|
if (read && preferences.removeAfterMarkedAsRead()) {
|
||||||
|
deleteChapters(selectedChapters, false)
|
||||||
|
}
|
||||||
|
getChapters()
|
||||||
withContext(Dispatchers.Main) { controller.updateChapters(chapters) }
|
withContext(Dispatchers.Main) { controller.updateChapters(chapters) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ class MangaHeaderHolder(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
text = resources.getString(R.string.start_reading)
|
text = resources.getString(R.string.all_chapters_read)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package eu.kanade.tachiyomi.ui.manga.chapter
|
package eu.kanade.tachiyomi.ui.manga.chapter
|
||||||
|
|
||||||
import android.animation.Animator
|
|
||||||
import android.text.format.DateUtils
|
import android.text.format.DateUtils
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
@ -147,23 +146,7 @@ class ChapterHolder(
|
|||||||
|
|
||||||
private fun resetFrontView() {
|
private fun resetFrontView() {
|
||||||
if (front_view.translationX == 0f) return
|
if (front_view.translationX == 0f) return
|
||||||
itemView.post {
|
itemView.post { adapter.notifyItemChanged(adapterPosition) }
|
||||||
adapter.recyclerView.itemAnimator?.changeDuration = 0
|
|
||||||
val anim = front_view.animate().translationX(0f).setDuration(250)
|
|
||||||
anim.setListener(object : Animator.AnimatorListener {
|
|
||||||
override fun onAnimationEnd(animation: Animator?) {
|
|
||||||
adapter.itemTouchHelper.startSwipe(this@ChapterHolder)
|
|
||||||
adapter.notifyItemChanged(adapterPosition)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAnimationCancel(animation: Animator?) {}
|
|
||||||
|
|
||||||
override fun onAnimationRepeat(animation: Animator?) {}
|
|
||||||
|
|
||||||
override fun onAnimationStart(animation: Animator?) {}
|
|
||||||
})
|
|
||||||
anim.start()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun notifyStatus(status: Int, locked: Boolean, progress: Int) = with(download_button) {
|
fun notifyStatus(status: Int, locked: Boolean, progress: Int) = with(download_button) {
|
||||||
|
@ -16,7 +16,7 @@ import eu.kanade.tachiyomi.util.view.visibleIf
|
|||||||
import kotlinx.android.synthetic.main.chapter_sort_bottom_sheet.*
|
import kotlinx.android.synthetic.main.chapter_sort_bottom_sheet.*
|
||||||
|
|
||||||
class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetDialog
|
class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetDialog
|
||||||
(controller.activity!!, R.style.BottomSheetDialogThemeCovered) {
|
(controller.activity!!, R.style.BottomSheetDialogTheme) {
|
||||||
|
|
||||||
val activity = controller.activity!!
|
val activity = controller.activity!!
|
||||||
|
|
||||||
@ -30,10 +30,9 @@ class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetD
|
|||||||
setContentView(view)
|
setContentView(view)
|
||||||
|
|
||||||
sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup)
|
sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup)
|
||||||
setEdgeToEdge(activity, bottom_sheet, view)
|
setEdgeToEdge(activity, view)
|
||||||
val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom
|
val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom
|
||||||
sheetBehavior.peekHeight = 380.dpToPx + height
|
sheetBehavior.peekHeight = 380.dpToPx + height
|
||||||
window?.navigationBarColor = activity.window.navigationBarColor
|
|
||||||
|
|
||||||
sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
||||||
override fun onSlide(bottomSheet: View, progress: Float) { }
|
override fun onSlide(bottomSheet: View, progress: Float) { }
|
||||||
|
@ -40,7 +40,7 @@ class TrackingBottomSheet(private val controller: MangaDetailsController) : Bott
|
|||||||
setContentView(view)
|
setContentView(view)
|
||||||
|
|
||||||
sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup)
|
sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup)
|
||||||
setEdgeToEdge(activity, display_bottom_sheet, view)
|
setEdgeToEdge(activity, view)
|
||||||
val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom
|
val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom
|
||||||
sheetBehavior.peekHeight = 380.dpToPx + height
|
sheetBehavior.peekHeight = 380.dpToPx + height
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ 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.WindowManager
|
|
||||||
import android.widget.CompoundButton
|
import android.widget.CompoundButton
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.RadioButton
|
import android.widget.RadioButton
|
||||||
@ -62,7 +61,7 @@ class MigrationBottomSheetDialog(
|
|||||||
params3.endToEnd = -1
|
params3.endToEnd = -1
|
||||||
extra_search_param.layoutParams = params3
|
extra_search_param.layoutParams = params3
|
||||||
}
|
}
|
||||||
setEdgeToEdge(activity, constraint_layout, view)
|
setEdgeToEdge(activity, view)
|
||||||
setBottomEdge(
|
setBottomEdge(
|
||||||
if (activity.resources.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) extra_search_param_text
|
if (activity.resources.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) extra_search_param_text
|
||||||
else skip_step, activity
|
else skip_step, activity
|
||||||
@ -77,7 +76,7 @@ class MigrationBottomSheetDialog(
|
|||||||
|
|
||||||
initPreferences()
|
initPreferences()
|
||||||
|
|
||||||
window?.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
|
// window?.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
|
||||||
|
|
||||||
fab.setOnClickListener {
|
fab.setOnClickListener {
|
||||||
preferences.skipPreMigration().set(skip_step.isChecked)
|
preferences.skipPreMigration().set(skip_step.isChecked)
|
||||||
|
@ -54,7 +54,7 @@ class ReaderColorFilterSheet(activity: ReaderActivity) : BottomSheetDialog
|
|||||||
val view = activity.layoutInflater.inflate(R.layout.reader_color_filter_sheet, null)
|
val view = activity.layoutInflater.inflate(R.layout.reader_color_filter_sheet, null)
|
||||||
setContentView(view)
|
setContentView(view)
|
||||||
|
|
||||||
setEdgeToEdge(activity, constraint_layout, view, 0)
|
setEdgeToEdge(activity, view, 0)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
|
||||||
preferences.readerTheme().getOrDefault() == 0 &&
|
preferences.readerTheme().getOrDefault() == 0 &&
|
||||||
activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 &&
|
activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 &&
|
||||||
|
@ -32,7 +32,7 @@ class ReaderPageSheet(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
setContentView(view)
|
setContentView(view)
|
||||||
setEdgeToEdge(activity, view, view)
|
setEdgeToEdge(activity, view)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
|
||||||
Injekt.get<PreferencesHelper>().readerTheme().getOrDefault() == 0 &&
|
Injekt.get<PreferencesHelper>().readerTheme().getOrDefault() == 0 &&
|
||||||
activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 &&
|
activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 &&
|
||||||
|
@ -49,10 +49,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) :
|
|||||||
|
|
||||||
sheetBehavior = BottomSheetBehavior.from(scroll.parent as ViewGroup)
|
sheetBehavior = BottomSheetBehavior.from(scroll.parent as ViewGroup)
|
||||||
setEdgeToEdge(
|
setEdgeToEdge(
|
||||||
activity,
|
activity, scroll, if (context.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE)
|
||||||
constraint_layout,
|
|
||||||
scroll,
|
|
||||||
if (context.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE)
|
|
||||||
0 else -1
|
0 else -1
|
||||||
)
|
)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && preferences.readerTheme()
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && preferences.readerTheme()
|
||||||
|
@ -8,7 +8,6 @@ import android.content.res.Configuration
|
|||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.Point
|
import android.graphics.Point
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
import android.graphics.drawable.GradientDrawable
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@ -21,8 +20,6 @@ import android.widget.ImageView
|
|||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.Px
|
import androidx.annotation.Px
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
import androidx.core.graphics.ColorUtils
|
|
||||||
import androidx.core.math.MathUtils.clamp
|
import androidx.core.math.MathUtils.clamp
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
@ -37,11 +34,11 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
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.getResourceColor
|
||||||
import kotlin.math.abs
|
|
||||||
import kotlin.math.min
|
|
||||||
import kotlinx.android.synthetic.main.main_activity.*
|
import kotlinx.android.synthetic.main.main_activity.*
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
import kotlin.math.abs
|
||||||
|
import kotlin.math.min
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns coordinates of view.
|
* Returns coordinates of view.
|
||||||
@ -396,42 +393,31 @@ inline fun View.updatePaddingRelative(
|
|||||||
|
|
||||||
fun BottomSheetDialog.setEdgeToEdge(
|
fun BottomSheetDialog.setEdgeToEdge(
|
||||||
activity: Activity,
|
activity: Activity,
|
||||||
layout: View,
|
|
||||||
contentView: View,
|
contentView: View,
|
||||||
setTopMargin: Int = -1
|
setTopMargin: Int = -1
|
||||||
) {
|
) {
|
||||||
window?.setBackgroundDrawable(null)
|
window?.setBackgroundDrawable(null)
|
||||||
val currentNightMode =
|
val currentNightMode =
|
||||||
activity.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
activity.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
||||||
if (currentNightMode == Configuration.UI_MODE_NIGHT_NO) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
window?.navigationBarColor = activity.window.navigationBarColor
|
||||||
if (activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetLeft == 0) window?.decorView?.systemUiVisibility =
|
val isLight = (activity.window?.decorView?.systemUiVisibility ?: 0) and View
|
||||||
View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR == View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||||
} else if (layout is ConstraintLayout) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && isLight)
|
||||||
val nView = View(context)
|
window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
||||||
val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom
|
|
||||||
val params = ConstraintLayout.LayoutParams(
|
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT, height
|
|
||||||
)
|
|
||||||
params.bottomToBottom = layout.id
|
|
||||||
params.startToStart = layout.id
|
|
||||||
params.endToEnd = layout.id
|
|
||||||
nView.layoutParams = params
|
|
||||||
nView.background = GradientDrawable(
|
|
||||||
GradientDrawable.Orientation.BOTTOM_TOP, intArrayOf(
|
|
||||||
ColorUtils.setAlphaComponent(Color.BLACK, 179), Color.TRANSPARENT
|
|
||||||
)
|
|
||||||
)
|
|
||||||
layout.addView(nView)
|
|
||||||
}
|
|
||||||
window?.findViewById<View>(com.google.android.material.R.id.container)?.fitsSystemWindows =
|
window?.findViewById<View>(com.google.android.material.R.id.container)?.fitsSystemWindows =
|
||||||
false
|
false
|
||||||
contentView.systemUiVisibility =
|
contentView.systemUiVisibility =
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN //
|
||||||
/*contentView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
// or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||||
if (setTopMargin > -1) topMargin =
|
|
||||||
activity.window.decorView.rootWindowInsets.systemWindowInsetTop + setTopMargin
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
if (activity.window.decorView.rootWindowInsets.systemWindowInsetLeft +
|
||||||
|
activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0)
|
||||||
|
contentView.systemUiVisibility = contentView.systemUiVisibility
|
||||||
|
.or(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
|
||||||
|
/*contentView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
|
leftMargin = activity.window.decorView.rootWindowInsets.systemWindowInsetLeft
|
||||||
|
rightMargin = activity.window.decorView.rootWindowInsets.systemWindowInsetRight
|
||||||
|
}*/
|
||||||
if (setTopMargin > 0) (contentView.parent as View).updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
if (setTopMargin > 0) (contentView.parent as View).updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
height =
|
height =
|
||||||
activity.window.decorView.height - activity.window.decorView.rootWindowInsets.systemWindowInsetTop - setTopMargin
|
activity.window.decorView.height - activity.window.decorView.rootWindowInsets.systemWindowInsetTop - setTopMargin
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
style="@style/Theme.MaterialComponents.BottomSheetDialog"
|
style="@style/Theme.MaterialComponents.BottomSheetDialog"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
|
||||||
|
@ -210,11 +210,6 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="BottomSheetDialogTheme" parent="@style/Theme.MaterialComponents.BottomSheetDialog">
|
<style name="BottomSheetDialogTheme" parent="@style/Theme.MaterialComponents.BottomSheetDialog">
|
||||||
<item name="android:colorBackground">@android:color/transparent</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="BottomSheetDialogThemeCovered"
|
|
||||||
parent="@style/Theme.MaterialComponents.BottomSheetDialog">
|
|
||||||
<item name="android:windowIsFloating">false</item>
|
<item name="android:windowIsFloating">false</item>
|
||||||
<item name="android:colorBackground">@android:color/transparent</item>
|
<item name="android:colorBackground">@android:color/transparent</item>
|
||||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user