mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 08:08:55 +01:00 
			
		
		
		
	Fix crashes below L
This commit is contained in:
		@@ -14,6 +14,13 @@ class AndroidCookieJar(context: Context) : CookieJar {
 | 
			
		||||
 | 
			
		||||
    private val syncManager by lazy { CookieSyncManager.createInstance(context) }
 | 
			
		||||
 | 
			
		||||
    init {
 | 
			
		||||
        // Init sync manager when using anything below L
 | 
			
		||||
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
 | 
			
		||||
            syncManager
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override fun saveFromResponse(url: HttpUrl, cookies: MutableList<Cookie>) {
 | 
			
		||||
        val urlString = url.toString()
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -101,11 +101,12 @@ class CloudflareInterceptor(private val context: Context) : Interceptor {
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                override fun onPageFinished(view: WebView, url: String) {
 | 
			
		||||
                    if (url == origRequestUrl) {
 | 
			
		||||
                    // Http error codes are only received since M
 | 
			
		||||
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
 | 
			
		||||
                        url == origRequestUrl && !challengeFound
 | 
			
		||||
                    ) {
 | 
			
		||||
                        // The first request didn't return the challenge, abort.
 | 
			
		||||
                        if (!challengeFound) {
 | 
			
		||||
                            latch.countDown()
 | 
			
		||||
                        }
 | 
			
		||||
                        latch.countDown()
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
@@ -125,11 +126,6 @@ class CloudflareInterceptor(private val context: Context) : Interceptor {
 | 
			
		||||
                            latch.countDown()
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    // Any error on the main frame that isn't the Cloudflare check should unlock
 | 
			
		||||
                    // OkHttp's thread.
 | 
			
		||||
                    if (errorCode != 503 && isMainFrame) {
 | 
			
		||||
                        latch.countDown()
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            webView?.loadUrl(origRequestUrl, headers)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user