mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-17 15:19:15 +01:00
Fix some crashes
This commit is contained in:
parent
2d03f3ce1e
commit
0b9d436753
@ -176,7 +176,9 @@ 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
|
||||||
|
.doOnError { /* Swallow wakelock error */ }
|
||||||
|
.subscribe { running ->
|
||||||
if (running) {
|
if (running) {
|
||||||
wakeLock.acquireIfNeeded()
|
wakeLock.acquireIfNeeded()
|
||||||
} else {
|
} else {
|
||||||
|
@ -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)
|
|
||||||
} catch (_: Exception) {
|
|
||||||
// Crashes on some devices. We just ignore it since the only impact is slower
|
|
||||||
// WebView init in those rare cases.
|
// WebView init in those rare cases.
|
||||||
// See https://bugs.chromium.org/p/chromium/issues/detail?id=1279562
|
// 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
|
@Synchronized
|
||||||
|
@ -159,14 +159,16 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
|||||||
applyAppTheme(preferences)
|
applyAppTheme(preferences)
|
||||||
|
|
||||||
// Setup shared element transitions
|
// Setup shared element transitions
|
||||||
|
findViewById<View>(android.R.id.content)?.let { contentView ->
|
||||||
window.requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)
|
window.requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)
|
||||||
findViewById<View>(android.R.id.content).transitionName = SHARED_ELEMENT_NAME
|
contentView.transitionName = SHARED_ELEMENT_NAME
|
||||||
setEnterSharedElementCallback(MaterialContainerTransformSharedElementCallback())
|
setEnterSharedElementCallback(MaterialContainerTransformSharedElementCallback())
|
||||||
window.sharedElementEnterTransition = buildContainerTransform(true)
|
window.sharedElementEnterTransition = buildContainerTransform(true)
|
||||||
window.sharedElementReturnTransition = buildContainerTransform(false)
|
window.sharedElementReturnTransition = buildContainerTransform(false)
|
||||||
|
|
||||||
// Postpone custom transition until manga ready
|
// Postpone custom transition until manga ready
|
||||||
postponeEnterTransition()
|
postponeEnterTransition()
|
||||||
|
}
|
||||||
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
@ -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 {
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user