Fix some crashes

This commit is contained in:
arkon 2022-01-02 11:25:35 -05:00
parent 2d03f3ce1e
commit 0b9d436753
5 changed files with 35 additions and 19 deletions

View File

@ -176,13 +176,15 @@ class DownloadService : Service() {
* Listens to downloader status. Enables or disables the wake lock depending on the status. * Listens to downloader status. Enables or disables the wake lock depending on the status.
*/ */
private fun listenDownloaderState() { private fun listenDownloaderState() {
subscriptions += downloadManager.runningRelay.subscribe { running -> subscriptions += downloadManager.runningRelay
if (running) { .doOnError { /* Swallow wakelock error */ }
wakeLock.acquireIfNeeded() .subscribe { running ->
} else { if (running) {
wakeLock.releaseIfNeeded() wakeLock.acquireIfNeeded()
} else {
wakeLock.releaseIfNeeded()
}
} }
}
} }
/** /**

View File

@ -2,6 +2,7 @@ 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
@ -10,6 +11,7 @@ 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
@ -37,13 +39,14 @@ class CloudflareInterceptor(private val context: Context) : Interceptor {
* Application class. * Application class.
*/ */
private val initWebView by lazy { private val initWebView by lazy {
try { // Crashes on some devices. We skip this in some cases since the only impact is slower
WebSettings.getDefaultUserAgent(context) // WebView init in those rare cases.
} catch (_: Exception) { // See https://bugs.chromium.org/p/chromium/issues/detail?id=1279562
// Crashes on some devices. We just ignore it since the only impact is slower if (Build.VERSION.SDK_INT == Build.VERSION_CODES.S && DeviceUtil.isSamsung) {
// WebView init in those rare cases. return@lazy
// See https://bugs.chromium.org/p/chromium/issues/detail?id=1279562
} }
WebSettings.getDefaultUserAgent(context)
} }
@Synchronized @Synchronized

View File

@ -159,14 +159,16 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
applyAppTheme(preferences) applyAppTheme(preferences)
// Setup shared element transitions // Setup shared element transitions
window.requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS) findViewById<View>(android.R.id.content)?.let { contentView ->
findViewById<View>(android.R.id.content).transitionName = SHARED_ELEMENT_NAME window.requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)
setEnterSharedElementCallback(MaterialContainerTransformSharedElementCallback()) contentView.transitionName = SHARED_ELEMENT_NAME
window.sharedElementEnterTransition = buildContainerTransform(true) setEnterSharedElementCallback(MaterialContainerTransformSharedElementCallback())
window.sharedElementReturnTransition = buildContainerTransform(false) window.sharedElementEnterTransition = buildContainerTransform(true)
window.sharedElementReturnTransition = buildContainerTransform(false)
// Postpone custom transition until manga ready // Postpone custom transition until manga ready
postponeEnterTransition() postponeEnterTransition()
}
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)

View File

@ -1,6 +1,7 @@
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 {
@ -25,6 +26,10 @@ 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 {

View File

@ -47,6 +47,10 @@ class ThemesPreference @JvmOverloads constructor(context: Context, attrs: Attrib
} }
override fun onItemClick(position: Int) { override fun onItemClick(position: Int) {
if (position !in 0..entries.size) {
return
}
callChangeListener(value) callChangeListener(value)
value = entries[position].name value = entries[position].name
} }