aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin
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
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')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt17
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()}" }