mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 08:01:50 +01:00
Fix some crashes
This commit is contained in:
parent
800583b5e2
commit
353485054e
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.network.interceptor
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
|
||||||
import android.webkit.WebSettings
|
import android.webkit.WebSettings
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
@ -11,7 +10,6 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||||
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
|
||||||
import eu.kanade.tachiyomi.util.system.WebViewClientCompat
|
import eu.kanade.tachiyomi.util.system.WebViewClientCompat
|
||||||
import eu.kanade.tachiyomi.util.system.WebViewUtil
|
import eu.kanade.tachiyomi.util.system.WebViewUtil
|
||||||
import eu.kanade.tachiyomi.util.system.isOutdated
|
import eu.kanade.tachiyomi.util.system.isOutdated
|
||||||
@ -39,13 +37,13 @@ class CloudflareInterceptor(private val context: Context) : Interceptor {
|
|||||||
* Application class.
|
* Application class.
|
||||||
*/
|
*/
|
||||||
private val initWebView by lazy {
|
private val initWebView by lazy {
|
||||||
// Avoid crashes on Samsung devices on Android 12
|
try {
|
||||||
// See https://bugs.chromium.org/p/chromium/issues/detail?id=1279562
|
WebSettings.getDefaultUserAgent(context)
|
||||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.S && DeviceUtil.isSamsung) {
|
} catch (_: Exception) {
|
||||||
return@lazy
|
// Crashes on some devices. We just ignore it since the only impact is slower
|
||||||
|
// WebView init in those rare cases.
|
||||||
|
// See https://bugs.chromium.org/p/chromium/issues/detail?id=1279562
|
||||||
}
|
}
|
||||||
|
|
||||||
WebSettings.getDefaultUserAgent(context)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
|
@ -8,6 +8,7 @@ import eu.davidea.flexibleadapter.items.IFlexible
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
|
||||||
data class DownloadHeaderItem(
|
data class DownloadHeaderItem(
|
||||||
|
val id: Long,
|
||||||
val name: String,
|
val name: String,
|
||||||
val size: Int
|
val size: Int
|
||||||
) : AbstractExpandableHeaderItem<DownloadHeaderHolder, DownloadItem>() {
|
) : AbstractExpandableHeaderItem<DownloadHeaderHolder, DownloadItem>() {
|
||||||
@ -41,7 +42,7 @@ data class DownloadHeaderItem(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
return name.hashCode()
|
return id.hashCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -33,7 +33,7 @@ class DownloadPresenter : BasePresenter<DownloadController>() {
|
|||||||
downloads
|
downloads
|
||||||
.groupBy { it.source }
|
.groupBy { it.source }
|
||||||
.map { entry ->
|
.map { entry ->
|
||||||
DownloadHeaderItem(entry.key.name, entry.value.size).apply {
|
DownloadHeaderItem(entry.key.id, entry.key.name, entry.value.size).apply {
|
||||||
addSubItems(0, entry.value.map { DownloadItem(it, this) })
|
addSubItems(0, entry.value.map { DownloadItem(it, this) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
|||||||
|
|
||||||
// Close BrowseSourceController and its MangaController child when incognito mode is disabled
|
// Close BrowseSourceController and its MangaController child when incognito mode is disabled
|
||||||
if (!it) {
|
if (!it) {
|
||||||
val fg = router.backstack.last().controller
|
val fg = router.backstack.lastOrNull()?.controller
|
||||||
if (fg is BrowseSourceController || fg is MangaController && fg.fromSource) {
|
if (fg is BrowseSourceController || fg is MangaController && fg.fromSource) {
|
||||||
router.popToRoot()
|
router.popToRoot()
|
||||||
}
|
}
|
||||||
|
@ -338,6 +338,9 @@ class MangaController :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateToolbarTitleAlpha(@FloatRange(from = 0.0, to = 1.0) alpha: Float? = null) {
|
private fun updateToolbarTitleAlpha(@FloatRange(from = 0.0, to = 1.0) alpha: Float? = null) {
|
||||||
|
// Controller may actually already be destroyed by the time this gets run
|
||||||
|
binding ?: return
|
||||||
|
|
||||||
val scrolledList = binding.fullRecycler ?: binding.infoRecycler!!
|
val scrolledList = binding.fullRecycler ?: binding.infoRecycler!!
|
||||||
(activity as? MainActivity)?.binding?.appbar?.titleTextAlpha = when {
|
(activity as? MainActivity)?.binding?.appbar?.titleTextAlpha = when {
|
||||||
// Specific alpha provided
|
// Specific alpha provided
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package eu.kanade.tachiyomi.util.system
|
package eu.kanade.tachiyomi.util.system
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.os.Build
|
|
||||||
import logcat.LogPriority
|
import logcat.LogPriority
|
||||||
|
|
||||||
object DeviceUtil {
|
object DeviceUtil {
|
||||||
@ -26,10 +25,6 @@ object DeviceUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val isSamsung by lazy {
|
|
||||||
Build.MANUFACTURER.equals("samsung", ignoreCase = true)
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("PrivateApi")
|
@SuppressLint("PrivateApi")
|
||||||
private fun getSystemProperty(key: String?): String? {
|
private fun getSystemProperty(key: String?): String? {
|
||||||
return try {
|
return try {
|
||||||
|
Loading…
Reference in New Issue
Block a user