diff --git a/app/src/main/java/org/koitharu/kotatsu/browser/BrowserClient.kt b/app/src/main/java/org/koitharu/kotatsu/browser/BrowserClient.kt index 5e801a93f..0beaa7566 100644 --- a/app/src/main/java/org/koitharu/kotatsu/browser/BrowserClient.kt +++ b/app/src/main/java/org/koitharu/kotatsu/browser/BrowserClient.kt @@ -2,10 +2,9 @@ package org.koitharu.kotatsu.browser import android.graphics.Bitmap import android.webkit.WebView -import org.koin.core.component.KoinComponent -import org.koitharu.kotatsu.core.network.WebViewClientCompat +import android.webkit.WebViewClient -class BrowserClient(private val callback: BrowserCallback) : WebViewClientCompat(), KoinComponent { +class BrowserClient(private val callback: BrowserCallback) : WebViewClient() { override fun onPageFinished(webView: WebView, url: String) { super.onPageFinished(webView, url) diff --git a/app/src/main/java/org/koitharu/kotatsu/browser/ProgressChromeClient.kt b/app/src/main/java/org/koitharu/kotatsu/browser/ProgressChromeClient.kt index 1b29d7339..27e7f9b38 100644 --- a/app/src/main/java/org/koitharu/kotatsu/browser/ProgressChromeClient.kt +++ b/app/src/main/java/org/koitharu/kotatsu/browser/ProgressChromeClient.kt @@ -2,13 +2,14 @@ package org.koitharu.kotatsu.browser import android.webkit.WebChromeClient import android.webkit.WebView +import android.widget.ProgressBar import androidx.core.view.isVisible -import com.google.android.material.progressindicator.BaseProgressIndicator +import org.koitharu.kotatsu.utils.ext.setProgressCompat private const val PROGRESS_MAX = 100 class ProgressChromeClient( - private val progressIndicator: BaseProgressIndicator<*>, + private val progressIndicator: ProgressBar, ) : WebChromeClient() { init { @@ -24,7 +25,7 @@ class ProgressChromeClient( progressIndicator.isIndeterminate = false progressIndicator.setProgressCompat(newProgress.coerceAtMost(PROGRESS_MAX), true) } else { - progressIndicator.setIndeterminate(true) + progressIndicator.isIndeterminate = true } } } \ No newline at end of file diff --git a/app/src/main/java/org/koitharu/kotatsu/browser/cloudflare/CloudFlareClient.kt b/app/src/main/java/org/koitharu/kotatsu/browser/cloudflare/CloudFlareClient.kt index 56eef7520..264134e52 100644 --- a/app/src/main/java/org/koitharu/kotatsu/browser/cloudflare/CloudFlareClient.kt +++ b/app/src/main/java/org/koitharu/kotatsu/browser/cloudflare/CloudFlareClient.kt @@ -2,19 +2,19 @@ package org.koitharu.kotatsu.browser.cloudflare import android.graphics.Bitmap import android.webkit.WebView +import android.webkit.WebViewClient import okhttp3.HttpUrl.Companion.toHttpUrl import org.koitharu.kotatsu.core.network.AndroidCookieJar -import org.koitharu.kotatsu.core.network.WebViewClientCompat private const val CF_CLEARANCE = "cf_clearance" class CloudFlareClient( private val cookieJar: AndroidCookieJar, private val callback: CloudFlareCallback, - private val targetUrl: String -) : WebViewClientCompat() { + private val targetUrl: String, +) : WebViewClient() { - private val oldClearance = getCookieValue(CF_CLEARANCE) + private val oldClearance = getClearance() override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) { super.onPageStarted(view, url, favicon) @@ -32,14 +32,14 @@ class CloudFlareClient( } private fun checkClearance() { - val clearance = getCookieValue(CF_CLEARANCE) + val clearance = getClearance() if (clearance != null && clearance != oldClearance) { callback.onCheckPassed() } } - private fun getCookieValue(name: String): String? { + private fun getClearance(): String? { return cookieJar.loadForRequest(targetUrl.toHttpUrl()) - .find { it.name == name }?.value + .find { it.name == CF_CLEARANCE }?.value } } \ No newline at end of file diff --git a/app/src/main/java/org/koitharu/kotatsu/core/network/WebViewClientCompat.kt b/app/src/main/java/org/koitharu/kotatsu/core/network/WebViewClientCompat.kt deleted file mode 100644 index 8764a338d..000000000 --- a/app/src/main/java/org/koitharu/kotatsu/core/network/WebViewClientCompat.kt +++ /dev/null @@ -1,86 +0,0 @@ -package org.koitharu.kotatsu.core.network - -import android.annotation.TargetApi -import android.os.Build -import android.webkit.* - -@Suppress("OverridingDeprecatedMember") -abstract class WebViewClientCompat : WebViewClient() { - - open fun shouldOverrideUrlCompat(view: WebView, url: String): Boolean { - return false - } - - open fun shouldInterceptRequestCompat(view: WebView, url: String): WebResourceResponse? { - return null - } - - open fun onReceivedErrorCompat( - view: WebView, - errorCode: Int, - description: String?, - failingUrl: String, - isMainFrame: Boolean - ) { - } - - @TargetApi(Build.VERSION_CODES.N) - final override fun shouldOverrideUrlLoading( - view: WebView, - request: WebResourceRequest - ): Boolean = shouldOverrideUrlCompat(view, request.url.toString()) - - final override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean { - return shouldOverrideUrlCompat(view, url) - } - - final override fun shouldInterceptRequest( - view: WebView, - request: WebResourceRequest - ): WebResourceResponse? = shouldInterceptRequestCompat(view, request.url.toString()) - - final override fun shouldInterceptRequest( - view: WebView, - url: String - ): WebResourceResponse? = shouldInterceptRequestCompat(view, url) - - @TargetApi(Build.VERSION_CODES.M) - final override fun onReceivedError( - view: WebView, - request: WebResourceRequest, - error: WebResourceError - ) { - onReceivedErrorCompat( - view, - error.errorCode, - error.description?.toString(), - request.url.toString(), - request.isForMainFrame - ) - } - - final override fun onReceivedError( - view: WebView, - errorCode: Int, - description: String?, - failingUrl: String - ) { - onReceivedErrorCompat(view, errorCode, description, failingUrl, failingUrl == view.url) - } - - @TargetApi(Build.VERSION_CODES.M) - final override fun onReceivedHttpError( - view: WebView, - request: WebResourceRequest, - error: WebResourceResponse - ) { - onReceivedErrorCompat( - view, - error.statusCode, - error.reasonPhrase, - request.url - .toString(), - request.isForMainFrame - ) - } -}