aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-09-29 03:36:45 -0700
committerGitHub <noreply@github.com>2019-09-29 03:36:45 -0700
commitc17a6a3df40d2985bec9e8b58802cf7f65281b4e (patch)
tree5f063a0be2962ea96f4bd49088623841da46cd53 /app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
parent8932e9f5eb9995729f674ebe02464a6f20f4d1ec (diff)
parenta75176f963e1fed7e99389b84170da058072128f (diff)
downloadfrost-c17a6a3df40d2985bec9e8b58802cf7f65281b4e.tar.gz
frost-c17a6a3df40d2985bec9e8b58802cf7f65281b4e.tar.bz2
frost-c17a6a3df40d2985bec9e8b58802cf7f65281b4e.zip
Merge pull request #1565 from AllanWang/disable-swipe-on-pages
Disable swipe to refresh for composer and sharer urls
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt17
1 files changed, 16 insertions, 1 deletions
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()}" }