diff options
Diffstat (limited to 'app/src/main/kotlin/com')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt | 7 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt | 17 |
2 files changed, 22 insertions, 2 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt index 187ab9eb..0988e331 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt @@ -89,7 +89,9 @@ class FrostJSI(val web: FrostWebView) { @JavascriptInterface fun longClick(start: Boolean) { activity?.viewPager?.enableSwipe = !start - web.parent.swipeEnabled = !start + if (web.frostWebClient.urlSupportsRefresh) { + web.parent.swipeEnabled = !start + } } /** @@ -97,6 +99,9 @@ class FrostJSI(val web: FrostWebView) { */ @JavascriptInterface fun disableSwipeRefresh(disable: Boolean) { + if (!web.frostWebClient.urlSupportsRefresh) { + return + } web.parent.swipeEnabled = !disable if (disable) { // locked onto an input field; ensure content is visible diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt index f6279611..ab7ee087 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -24,6 +24,7 @@ import android.webkit.WebView import android.webkit.WebViewClient import ca.allanwang.kau.utils.withAlpha import com.pitchedapps.frost.facebook.FACEBOOK_BASE_COM +import com.pitchedapps.frost.facebook.FB_URL_BASE import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.facebook.WWW_FACEBOOK_COM @@ -69,10 +70,24 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { private val refresh: SendChannel<Boolean> = web.parent.refreshChannel private val isMain = web.parent.baseEnum != null + /** + * True if current url supports refresh. See [doUpdateVisitedHistory] for updates + */ + internal var urlSupportsRefresh: Boolean = true override fun doUpdateVisitedHistory(view: WebView, url: String?, isReload: Boolean) { - v { "History $url" } super.doUpdateVisitedHistory(view, url, isReload) + urlSupportsRefresh = urlSupportsRefresh(url) + web.parent.swipeEnabled = urlSupportsRefresh + v { "History $url; refresh $urlSupportsRefresh" } + } + + private fun urlSupportsRefresh(url: String?): Boolean { + if (url == null) return false + if (!url.isFacebookUrl) return true + if (url == "$FB_URL_BASE?soft=composer") return false + if (url.contains("sharer.php") || url.contains("sharer-dialog.php")) return false + return true } protected inline fun v(crossinline message: () -> Any?) = L.v { "web client: ${message()}" } |