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.
*/
private fun listenDownloaderState() {
subscriptions += downloadManager.runningRelay.subscribe { running ->
if (running) {
wakeLock.acquireIfNeeded()
} else {
wakeLock.releaseIfNeeded()
subscriptions += downloadManager.runningRelay
.doOnError { /* Swallow wakelock error */ }
.subscribe { running ->
if (running) {
wakeLock.acquireIfNeeded()
} else {
wakeLock.releaseIfNeeded()
}
}
}
}
/**

View file

@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.network.interceptor
import android.annotation.SuppressLint
import android.content.Context
import android.os.Build
import android.webkit.WebSettings
import android.webkit.WebView
import android.widget.Toast
@ -10,6 +11,7 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.source.online.HttpSource
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.WebViewUtil
import eu.kanade.tachiyomi.util.system.isOutdated
@ -37,13 +39,14 @@ class CloudflareInterceptor(private val context: Context) : Interceptor {
* Application class.
*/
private val initWebView by lazy {
try {
WebSettings.getDefaultUserAgent(context)
} catch (_: Exception) {
// 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
// Crashes on some devices. We skip this in some cases since the only impact is slower
// WebView init in those rare cases.
// See https://bugs.chromium.org/p/chromium/issues/detail?id=1279562
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.S && DeviceUtil.isSamsung) {
return@lazy
}
WebSettings.getDefaultUserAgent(context)
}
@Synchronized

View file

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

View file

@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.util.system
import android.annotation.SuppressLint
import android.os.Build
import logcat.LogPriority
object DeviceUtil {
@ -25,6 +26,10 @@ object DeviceUtil {
}
}
val isSamsung by lazy {
Build.MANUFACTURER.equals("samsung", ignoreCase = true)
}
@SuppressLint("PrivateApi")
private fun getSystemProperty(key: String?): String? {
return try {

View file

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