Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ abstract class EditorWebView : ExternalSiteWebView() {
}

lifecycleScope.launch {
WebViewUtil().setProxyKKPlus(webView)
delay(PROXY_SETUP_DELAY)
val wvUtil = WebViewUtil()

if (wvUtil.hasProxyConfig()) {
wvUtil.setProxyKKPlus(webView)
delay(PROXY_SETUP_DELAY)
}

if (loadedUrl != webView.url) {
webView.loadUrl(loadedUrl)
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/com/owncloud/android/utils/WebViewUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import java.io.PrintWriter
import java.io.StringWriter

class WebViewUtil {
val proxyHost = OwnCloudClientManagerFactory.getProxyHost() ?: ""
val proxyPort = OwnCloudClientManagerFactory.getProxyPort()

/**
* From https://stackoverflow.com/a/18453384
Expand All @@ -30,9 +32,6 @@ class WebViewUtil {
@SuppressLint("PrivateApi", "DiscouragedPrivateApi")
@Suppress("TooGenericExceptionCaught", "NestedBlockDepth")
fun setProxyKKPlus(webView: WebView) {
val proxyHost = OwnCloudClientManagerFactory.getProxyHost()
val proxyPort = OwnCloudClientManagerFactory.getProxyPort()

if (TextUtils.isEmpty(proxyHost) || proxyPort <= 0) {
return
}
Expand Down Expand Up @@ -79,6 +78,8 @@ class WebViewUtil {
}
}

fun hasProxyConfig(): Boolean = OwnCloudClientManagerFactory.getProxyHost().isNotEmpty()

companion object {
private const val PROXY_TAG = "PROXY"
private const val WEB_VIEW_TAG = "WEB_VIEW"
Expand Down
Loading