aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-12-28 22:15:08 -0500
committerAllan Wang <me@allanwang.ca>2018-12-28 22:15:08 -0500
commit7f545a19dcb52073bc22d2bb59e6cb4beecac4a6 (patch)
tree19f1458e408da149291ea7260b2196576ece0de9 /app
parent9c3d7c8b6cca17dc10fc310d41e547d1fe1725ea (diff)
downloadfrost-7f545a19dcb52073bc22d2bb59e6cb4beecac4a6.tar.gz
frost-7f545a19dcb52073bc22d2bb59e6cb4beecac4a6.tar.bz2
frost-7f545a19dcb52073bc22d2bb59e6cb4beecac4a6.zip
Switch default user agent to android, resolves #1245, #1229
Diffstat (limited to 'app')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt11
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt13
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt2
4 files changed, 17 insertions, 16 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt
index b6207a7b..1d6937f7 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt
@@ -28,13 +28,12 @@ fun profilePictureUrl(id: Long) = "https://graph.facebook.com/$id/picture?type=l
const val FB_LOGIN_URL = "${FB_URL_BASE}login"
const val FB_HOME_URL = "${FB_URL_BASE}home.php"
+// Default user agent
const val USER_AGENT_FULL =
- "Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG SM-G900T Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36"
-const val USER_AGENT_BASIC_OLD =
- "Mozilla/5.0 (Linux; Android 6.0) AppleWebKit/537.10+ (KHTML, like Gecko) Version/10.1.0.4633 Mobile Safari/537.10+"
-const val USER_AGENT_MESSENGER =
- "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
-const val USER_AGENT_BASIC = USER_AGENT_MESSENGER
+ "Mozilla/5.0 (Linux; Android 7.1; Mi A1 Build/N2G47H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.83 Mobile Safari/537.36"
+// Basic user agent; non mobile version
+const val USER_AGENT_BASIC =
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36"
/**
* Animation transition delay, just to ensure that the styles
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt
index b15ad5cf..0e9d94e6 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt
@@ -28,7 +28,9 @@ import com.pitchedapps.frost.contracts.FrostContentContainer
import com.pitchedapps.frost.contracts.FrostContentCore
import com.pitchedapps.frost.contracts.FrostContentParent
import com.pitchedapps.frost.facebook.FB_HOME_URL
+import com.pitchedapps.frost.facebook.FbItem
import com.pitchedapps.frost.facebook.USER_AGENT_BASIC
+import com.pitchedapps.frost.facebook.USER_AGENT_FULL
import com.pitchedapps.frost.fragments.WebFragment
import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.frostDownload
@@ -63,8 +65,9 @@ class FrostWebView @JvmOverloads constructor(
@SuppressLint("SetJavaScriptEnabled")
override fun bind(container: FrostContentContainer): View {
- if (parent.baseEnum != null || parent.baseUrl.shouldUseBasicAgent)
- userAgentString = USER_AGENT_BASIC // go through our own agent ref
+ userAgentString =
+ if (parent.baseEnum == FbItem.MESSAGES || parent.baseUrl.shouldUseBasicAgent) USER_AGENT_BASIC
+ else USER_AGENT_FULL
with(settings) {
javaScriptEnabled = true
allowFileAccess = true
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
index e2d294f7..490c02e5 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
@@ -84,7 +84,7 @@ fun FrostWebView.requestWebOverlay(url: String): Boolean {
context.launchWebOverlayBasic(url)
return true
}
- if (context is WebOverlayBasicActivity && !shouldUseBasic) {
+ if (userAgentString == USER_AGENT_BASIC && !shouldUseBasic) {
L.i { "Switch from basic agent" }
context.launchWebOverlay(url)
return true
@@ -105,10 +105,9 @@ val messageWhitelist: Set<String> =
.mapTo(mutableSetOf(), FbItem::url)
val String.shouldUseBasicAgent: Boolean
- get() {
- if (contains("story.php")) // do not use basic for comment section
- return false
- if (contains("/events/")) // do not use for events (namely the map)
- return false
- return true // use for everything else
+ get() = when {
+ contains("story.php") -> false // do not use basic for comment section
+ contains("/events/") -> false // do not use for events (namely the map)
+ contains("/messages") -> true // must use for messages
+ else -> false // default to normal user agent
}
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 cb212b0a..ab97c0a8 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
@@ -72,7 +72,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
if (url == null) return
- v { "loading $url" }
+ v { "loading $url ${web.settings.userAgentString}" }
refresh.offer(true)
}