aboutsummaryrefslogtreecommitdiff
path: root/app
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
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')
-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
-rw-r--r--app/src/main/play/en-US/whatsnew3
-rw-r--r--app/src/main/res/xml/frost_changelog.xml1
4 files changed, 25 insertions, 3 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()}" }
diff --git a/app/src/main/play/en-US/whatsnew b/app/src/main/play/en-US/whatsnew
index 6f1d0b36..f286cb6f 100644
--- a/app/src/main/play/en-US/whatsnew
+++ b/app/src/main/play/en-US/whatsnew
@@ -5,4 +5,5 @@ v2.4.1
* Fix nav and status bar icon colors for custom themes (Android O+)
* Fix biometric prompt, and prompt on activity resume
* Fix notification title
-* Add option to open overlay links in browser \ No newline at end of file
+* Add option to open overlay links in browser
+* Disable swipe to refresh for composer and sharer pages \ No newline at end of file
diff --git a/app/src/main/res/xml/frost_changelog.xml b/app/src/main/res/xml/frost_changelog.xml
index 4cf51cb0..e8856b03 100644
--- a/app/src/main/res/xml/frost_changelog.xml
+++ b/app/src/main/res/xml/frost_changelog.xml
@@ -13,6 +13,7 @@
<item text="Fix biometric prompt, and prompt on activity resume" />
<item text="Fix notification title" />
<item text="Add option to open overlay links in browser" />
+ <item text="Disable swipe to refresh for composer and sharer pages" />
<item text="" />
<version title="v2.4.0" />