aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-08-07 23:07:40 -0700
committerAllan Wang <me@allanwang.ca>2019-08-07 23:07:40 -0700
commit6ab5ee6c839993b5340304dc86d4f43820b734fe (patch)
tree168f678030fa48c99248a41b04bdba65eb309b88 /app
parente64c30732b5156144f18db41fcf5a713b1d11deb (diff)
downloadfrost-6ab5ee6c839993b5340304dc86d4f43820b734fe.tar.gz
frost-6ab5ee6c839993b5340304dc86d4f43820b734fe.tar.bz2
frost-6ab5ee6c839993b5340304dc86d4f43820b734fe.zip
Add user agent toggle
Diffstat (limited to 'app')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt11
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt4
-rw-r--r--app/src/main/res/values/strings_pref_behaviour.xml5
-rw-r--r--app/src/main/res/values/strings_pref_experimental.xml9
-rw-r--r--app/src/main/res/xml/frost_changelog.xml2
8 files changed, 31 insertions, 15 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 f6316470..a83af46c 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt
@@ -16,6 +16,8 @@
*/
package com.pitchedapps.frost.facebook
+import com.pitchedapps.frost.utils.Prefs
+
/**
* Created by Allan Wang on 2017-06-01.
*/
@@ -32,8 +34,8 @@ const val FB_HOME_URL = "${FB_URL_BASE}home.php"
const val USER_AGENT_MOBILE =
"Mozilla/5.0 (Linux; Android 8.0.0; ONEPLUS A3000) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.90 Mobile Safari/537.36"
// Desktop agent, for pages like messages
-const val USER_AGENT_DESKTOP =
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.90 Safari/537.36"
+val USER_AGENT_DESKTOP =
+ if (Prefs.singleUserAgent) USER_AGENT_MOBILE else "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.90 Safari/537.36"
/**
* Animation transition delay, just to ensure that the styles
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
index 1ab53a56..ba5b839b 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
@@ -83,13 +83,6 @@ fun SettingsActivity.getBehaviourPrefs(): KPrefAdapterBuilder.() -> Unit = {
descRes = R.string.exit_confirmation_desc
}
- checkbox(R.string.web_only, Prefs::webOnly, {
- Prefs.webOnly = it
- shouldRestartMain()
- }) {
- descRes = R.string.web_only_desc
- }
-
checkbox(R.string.analytics, Prefs::analytics, { Prefs.analytics = it }) {
descRes = R.string.analytics_desc
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt
index 7aac7526..3c43bc47 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt
@@ -52,6 +52,17 @@ fun SettingsActivity.getExperimentalPrefs(): KPrefAdapterBuilder.() -> Unit = {
descRes = R.string.verbose_logging_desc
}
+ checkbox(R.string.web_only, Prefs::webOnly, {
+ Prefs.webOnly = it
+ shouldRestartMain()
+ }) {
+ descRes = R.string.web_only_desc
+ }
+
+ checkbox(R.string.single_user_agent, Prefs::singleUserAgent, { Prefs.singleUserAgent }) {
+ descRes = R.string.single_user_agent_desc
+ }
+
plainText(R.string.restart_frost) {
descRes = R.string.restart_frost_desc
onClick = {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
index f17645d0..3f844653 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
@@ -193,6 +193,8 @@ object Prefs : KPref() {
var webOnly: Boolean by kpref("web_only", false)
+ var singleUserAgent: Boolean by kpref("single_user_agent", false)
+
inline val mainActivityLayout: MainActivityLayout
get() = MainActivityLayout(mainActivityLayoutType)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
index 09796b15..14f49bd1 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
@@ -33,6 +33,7 @@ import com.pitchedapps.frost.db.CookieEntity
import com.pitchedapps.frost.facebook.FB_LOGIN_URL
import com.pitchedapps.frost.facebook.FB_USER_MATCHER
import com.pitchedapps.frost.facebook.FbCookie
+import com.pitchedapps.frost.facebook.USER_AGENT_MOBILE
import com.pitchedapps.frost.facebook.get
import com.pitchedapps.frost.injectors.CssHider
import com.pitchedapps.frost.injectors.jsInject
@@ -57,6 +58,9 @@ class LoginWebView @JvmOverloads constructor(
@SuppressLint("SetJavaScriptEnabled")
private fun setupWebview() {
settings.javaScriptEnabled = true
+ if (Prefs.singleUserAgent) {
+ settings.userAgentString = USER_AGENT_MOBILE
+ }
setLayerType(View.LAYER_TYPE_HARDWARE, null)
webViewClient = LoginClient()
webChromeClient = LoginChromeClient()
diff --git a/app/src/main/res/values/strings_pref_behaviour.xml b/app/src/main/res/values/strings_pref_behaviour.xml
index d7043aa7..32188698 100644
--- a/app/src/main/res/values/strings_pref_behaviour.xml
+++ b/app/src/main/res/values/strings_pref_behaviour.xml
@@ -19,11 +19,6 @@
<string name="force_message_bottom_desc">When loading a message thread, trigger a scroll to the bottom of the page rather than loading the page as is.</string>
<string name="enable_pip">Enable PIP</string>
<string name="enable_pip_desc">Enable picture in picture videos</string>
- <!-- Disable translation as this is still experimental -->
- <string name="web_only" translatable="false">Web Only</string>
- <string name="web_only_desc" translatable="false">Having troubles? Enable to use web exclusive features. All parsing and background services will be disabled.</string>
- <string name="leave_web_only_title" translatable="false">Leave web only mode</string>
- <string name="leave_web_only_desc" translatable="false">Currently in web only mode. Would you like to disable it to continue?</string>
<string name="autoplay_settings">Autoplay Settings</string>
<string name="autoplay_settings_desc">Open Facebook\'s auto play settings. Note that it must be disabled for PIP to work.</string>
<string name="exit_confirmation">Exit Confirmation</string>
diff --git a/app/src/main/res/values/strings_pref_experimental.xml b/app/src/main/res/values/strings_pref_experimental.xml
index 95d54ff2..161902bb 100644
--- a/app/src/main/res/values/strings_pref_experimental.xml
+++ b/app/src/main/res/values/strings_pref_experimental.xml
@@ -8,4 +8,13 @@
<string name="verbose_logging_desc">Enable verbose logging to help with crash reports. Logging will only be sent once an error is encountered, so repeat the issue to notify the dev. This will automatically be disabled if the app restarts.</string>
<string name="restart_frost">Restart Frost</string>
<string name="restart_frost_desc">Launch a cold restart for the application.</string>
+
+ <!-- Disable translation as this is still experimental -->
+ <string name="web_only" translatable="false">Web Only</string>
+ <string name="web_only_desc" translatable="false">Having troubles? Enable to use web exclusive features. All parsing and background services will be disabled.</string>
+ <string name="leave_web_only_title" translatable="false">Leave web only mode</string>
+ <string name="leave_web_only_desc" translatable="false">Currently in web only mode. Would you like to disable it to continue?</string>
+
+ <string name="single_user_agent" translatable="false">Single user agent</string>
+ <string name="single_user_agent_desc" translatable="false">Use one user agent across entire app</string>
</resources> \ 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 3c576a9e..349d4d83 100644
--- a/app/src/main/res/xml/frost_changelog.xml
+++ b/app/src/main/res/xml/frost_changelog.xml
@@ -13,7 +13,7 @@
<item text="Disable bugsnag completely when opting out of analytics" />
<item text="Filter urls before sending to other apps" />
<item text="Allow hiding main fab (see settings > newsfeed)" />
- <item text="Add option to disable non web based behaviour (settings > behaviour)" />
+ <item text="Add many options under settings > experimental to help with recent" />
<item text="" />
<version title="v2.3.1" />