aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-09-28 22:48:50 -0700
committerAllan Wang <me@allanwang.ca>2019-09-28 22:48:50 -0700
commit8fb903398a3692e42d4ea8ddcf047937841f5901 (patch)
tree7d71b36131dd9a4a3895755f181f563f25377e6e /app/src
parent96908453abbd7e40e13af4359d1bce4524b979a6 (diff)
downloadfrost-8fb903398a3692e42d4ea8ddcf047937841f5901.tar.gz
frost-8fb903398a3692e42d4ea8ddcf047937841f5901.tar.bz2
frost-8fb903398a3692e42d4ea8ddcf047937841f5901.zip
Convert desktop urls to mobile ones
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt7
3 files changed, 12 insertions, 2 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 c01bce55..733349b7 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt
@@ -22,8 +22,9 @@ package com.pitchedapps.frost.facebook
const val FACEBOOK_COM = "facebook.com"
const val FBCDN_NET = "fbcdn.net"
-const val HTTPS_FACEBOOK_COM = "https://$FACEBOOK_COM/"
-const val FB_URL_BASE = "https://m.$FACEBOOK_COM/"
+const val WWW_FACEBOOK_COM = "www.$FACEBOOK_COM"
+const val FACEBOOK_BASE_COM = "m.$FACEBOOK_COM"
+const val FB_URL_BASE = "https://$FACEBOOK_BASE_COM/"
fun profilePictureUrl(id: Long) = "https://graph.facebook.com/$id/picture?type=large"
const val FB_LOGIN_URL = "${FB_URL_BASE}login"
const val FB_HOME_URL = "${FB_URL_BASE}home.php"
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt
index 2095f8fd..006fc3ca 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt
@@ -78,6 +78,8 @@ class FbUrlFormatter(url: String) {
cleanedUrl = cleanedUrl.substring(0, qm)
}
discardableQueries.forEach { queries.remove(it) }
+ // Convert desktop urls to mobile ones
+ cleanedUrl = cleanedUrl.replace(WWW_FACEBOOK_COM, FACEBOOK_BASE_COM)
if (cleanedUrl.startsWith("/")) cleanedUrl = FB_URL_BASE + cleanedUrl.substring(1)
cleanedUrl = cleanedUrl.replaceFirst(
".facebook.com//",
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 9e45d4fe..add643c5 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
@@ -23,8 +23,10 @@ import android.webkit.WebResourceResponse
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.FbCookie
import com.pitchedapps.frost.facebook.FbItem
+import com.pitchedapps.frost.facebook.WWW_FACEBOOK_COM
import com.pitchedapps.frost.facebook.formattedFbUrl
import com.pitchedapps.frost.injectors.CssHider
import com.pitchedapps.frost.injectors.JsActions
@@ -188,6 +190,11 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
if (Prefs.linksInDefaultApp && view.context.resolveActivityForUri(request.url)) {
return true
}
+ // Convert desktop urls to mobile ones
+ if (url.contains("https://www.facebook.com")) {
+ view.loadUrl(url.replace(WWW_FACEBOOK_COM, FACEBOOK_BASE_COM))
+ return true
+ }
return super.shouldOverrideUrlLoading(view, request)
}
}