mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 19:25:10 +01:00
Fixed reader crashing for lower android versions
Gotta love not using Compat
This commit is contained in:
parent
05c0c63f4c
commit
d651b896ba
@ -5,6 +5,7 @@ import android.content.ClipData
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.res.ColorStateList
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
@ -25,6 +26,7 @@ import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.GestureDetectorCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
@ -57,6 +59,7 @@ import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
||||
import eu.kanade.tachiyomi.util.system.GLUtil
|
||||
import eu.kanade.tachiyomi.util.system.ThemeUtil
|
||||
import eu.kanade.tachiyomi.util.system.contextCompatColor
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.system.getPrefTheme
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
@ -212,6 +215,11 @@ class ReaderActivity :
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
systemUiFlag = systemUiFlag.or(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR)
|
||||
}
|
||||
binding.appBar.setBackgroundColor(contextCompatColor(R.color.secondary_alpha))
|
||||
ViewCompat.setBackgroundTintList(
|
||||
binding.readerNav.root,
|
||||
ColorStateList.valueOf(contextCompatColor(R.color.secondary_alpha))
|
||||
)
|
||||
binding.readerLayout.systemUiVisibility = when (lightStatusBar) {
|
||||
true -> binding.readerLayout.systemUiVisibility.or(systemUiFlag)
|
||||
false -> binding.readerLayout.systemUiVisibility.rem(systemUiFlag)
|
||||
@ -595,7 +603,6 @@ class ReaderActivity :
|
||||
setMenuVisibility(menuVisible)
|
||||
binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.isHideable = !menuVisible
|
||||
if (!menuVisible) binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.hide()
|
||||
// val peek = binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.peekHeight ?: 30.dpToPx
|
||||
binding.readerLayout.doOnApplyWindowInsets { v, insets, _ ->
|
||||
sheetManageNavColor = when {
|
||||
insets.isBottomTappable() -> {
|
||||
@ -628,6 +635,11 @@ class ReaderActivity :
|
||||
leftMargin = 12.dpToPx + insets.systemWindowInsetLeft
|
||||
rightMargin = 12.dpToPx + insets.systemWindowInsetRight
|
||||
}
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
val peek = 50.dpToPx
|
||||
binding.chaptersSheet.root.sheetBehavior?.peekHeight =
|
||||
peek + insets.systemWindowInsetBottom
|
||||
}
|
||||
binding.chaptersSheet.chapterRecycler.updatePaddingRelative(bottom = insets.systemWindowInsetBottom)
|
||||
binding.viewerContainer.requestLayout()
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ import eu.kanade.tachiyomi.databinding.ReaderChaptersSheetBinding
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderPresenter
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.TabbedReaderSettingsSheet
|
||||
import eu.kanade.tachiyomi.util.system.contextCompatColor
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.launchUI
|
||||
import eu.kanade.tachiyomi.util.view.collapse
|
||||
import eu.kanade.tachiyomi.util.view.expand
|
||||
@ -53,7 +53,8 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
|
||||
|
||||
fun setup(activity: ReaderActivity) {
|
||||
presenter = activity.presenter
|
||||
val fullPrimary = activity.getResourceColor(R.attr.colorSecondary)
|
||||
val fullPrimary = activity.contextCompatColor(R.color.secondary_alpha)
|
||||
|
||||
val primary = ColorUtils.setAlphaComponent(fullPrimary, 200)
|
||||
|
||||
sheetBehavior = BottomSheetBehavior.from(this)
|
||||
|
@ -2,5 +2,5 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="50dp" />
|
||||
<solid android:color="@color/secondary_alpha" />
|
||||
<solid android:color="?colorSecondary" />
|
||||
</shape>
|
@ -51,8 +51,7 @@
|
||||
<FrameLayout
|
||||
android:id="@+id/app_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/secondary_alpha">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
|
@ -6,7 +6,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="300dp"
|
||||
android:background="@drawable/bottom_sheet_rounded_background"
|
||||
android:backgroundTint="@color/secondary_alpha"
|
||||
android:orientation="vertical"
|
||||
app:behavior_peekHeight="60dp"
|
||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||
|
Loading…
Reference in New Issue
Block a user