mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 19:55:11 +01:00
move windowInset check for bottom into extension
This commit is contained in:
parent
f0cf0f4106
commit
e5d3890ead
@ -4,8 +4,6 @@ import android.app.Dialog
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.WhichButton
|
|
||||||
import com.afollestad.materialdialogs.actions.setActionButtonEnabled
|
|
||||||
import com.afollestad.materialdialogs.customview.customView
|
import com.afollestad.materialdialogs.customview.customView
|
||||||
import com.jakewharton.rxbinding.widget.itemClicks
|
import com.jakewharton.rxbinding.widget.itemClicks
|
||||||
import com.jakewharton.rxbinding.widget.textChanges
|
import com.jakewharton.rxbinding.widget.textChanges
|
||||||
|
@ -183,7 +183,6 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
|
|||||||
false -> reader_layout.systemUiVisibility.rem(systemUiFlag)
|
false -> reader_layout.systemUiVisibility.rem(systemUiFlag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (presenter.needsInit()) {
|
if (presenter.needsInit()) {
|
||||||
val manga = intent.extras!!.getLong("manga", -1)
|
val manga = intent.extras!!.getLong("manga", -1)
|
||||||
val chapter = intent.extras!!.getLong("chapter", -1)
|
val chapter = intent.extras!!.getLong("chapter", -1)
|
||||||
|
@ -7,7 +7,6 @@ import android.view.View
|
|||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import com.mikepenz.fastadapter.FastAdapter
|
import com.mikepenz.fastadapter.FastAdapter
|
||||||
import com.mikepenz.fastadapter.items.AbstractItem
|
import com.mikepenz.fastadapter.items.AbstractItem
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.ui.reader
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Build
|
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
@ -16,6 +15,7 @@ import com.mikepenz.fastadapter.adapters.ItemAdapter
|
|||||||
import com.mikepenz.fastadapter.listeners.ClickEventHook
|
import com.mikepenz.fastadapter.listeners.ClickEventHook
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
|
import eu.kanade.tachiyomi.util.system.getBottomInsets
|
||||||
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.doOnApplyWindowInsets
|
||||||
@ -39,24 +39,28 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
|
|||||||
fun setup(activity: ReaderActivity) {
|
fun setup(activity: ReaderActivity) {
|
||||||
presenter = activity.presenter
|
presenter = activity.presenter
|
||||||
val fullPrimary = activity.getResourceColor(R.attr.colorSecondary)
|
val fullPrimary = activity.getResourceColor(R.attr.colorSecondary)
|
||||||
val primary = ColorUtils.setAlphaComponent( fullPrimary, 200)
|
val primary = ColorUtils.setAlphaComponent(fullPrimary, 200)
|
||||||
|
|
||||||
sheetBehavior = BottomSheetBehavior.from(this)
|
sheetBehavior = BottomSheetBehavior.from(this)
|
||||||
chapters_button.setOnClickListener {
|
chapters_button.setOnClickListener {
|
||||||
if (sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) sheetBehavior?.state =
|
if (sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) {
|
||||||
BottomSheetBehavior.STATE_COLLAPSED
|
sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||||
else sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
} else {
|
||||||
|
sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val peek = sheetBehavior?.peekHeight ?: 30.dpToPx
|
val peek = sheetBehavior?.peekHeight ?: 30.dpToPx
|
||||||
post {
|
post {
|
||||||
chapter_recycler.alpha =
|
chapter_recycler.alpha = when (sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) {
|
||||||
if (sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) 1f else 0f
|
true -> 1f
|
||||||
|
false -> 0f
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
chapters_bottom_sheet.doOnApplyWindowInsets { _, insets, _ ->
|
chapters_bottom_sheet.doOnApplyWindowInsets { _, insets, _ ->
|
||||||
sheetBehavior?.peekHeight =
|
sheetBehavior?.peekHeight = peek + insets.getBottomInsets()
|
||||||
peek + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) insets.mandatorySystemGestureInsets.bottom
|
|
||||||
else insets.systemWindowInsetBottom
|
|
||||||
chapters_bottom_sheet.updateLayoutParams<MarginLayoutParams> {
|
chapters_bottom_sheet.updateLayoutParams<MarginLayoutParams> {
|
||||||
height = 280.dpToPx + insets.systemWindowInsetBottom
|
height = 280.dpToPx + insets.systemWindowInsetBottom
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package eu.kanade.tachiyomi.util.system
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.os.Build
|
||||||
|
import android.view.WindowInsets
|
||||||
|
|
||||||
|
@SuppressLint("NewApi")
|
||||||
|
fun WindowInsets.getBottomInsets(): Int {
|
||||||
|
return when (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
true -> mandatorySystemGestureInsets.bottom
|
||||||
|
false -> systemWindowInsetBottom
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user