aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2021-09-12 19:54:31 -0700
committerAllan Wang <me@allanwang.ca>2021-09-12 19:54:31 -0700
commit039d7a7c199c4d991dd143f3b096a0707100f6a3 (patch)
treeb5e9ef2b512105bd6e70d8f8d7d0b7ad22e39ba4 /app/src/main/kotlin
parent57f761d401dd23ec7699d21cfab174f4133f4cf3 (diff)
downloadfrost-039d7a7c199c4d991dd143f3b096a0707100f6a3.tar.gz
frost-039d7a7c199c4d991dd143f3b096a0707100f6a3.tar.bz2
frost-039d7a7c199c4d991dd143f3b096a0707100f6a3.zip
Fix multi account switching
Diffstat (limited to 'app/src/main/kotlin')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt21
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt2
5 files changed, 17 insertions, 12 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
index 19e54f68..3766aef7 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
@@ -500,7 +500,7 @@ abstract class BaseMainActivity :
)
positiveButton(R.string.kau_yes) {
this@BaseMainActivity.launch {
- fbCookie.logout(this@BaseMainActivity)
+ fbCookie.logout(this@BaseMainActivity, deleteCookie = true)
}
}
negativeButton(R.string.kau_no)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt
index bce3aa48..8bf3345e 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt
@@ -233,8 +233,8 @@ class SettingsActivity : KPrefActivity() {
@SuppressLint("MissingSuperCall")
override fun onCreate(savedInstanceState: Bundle?) {
- activityThemer.setFrostTheme(forceTransparent = true)
super.onCreate(savedInstanceState)
+ activityThemer.setFrostTheme(forceTransparent = true)
animate = prefs.animate
themeExterior(false)
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
index ea1b0946..1a714374 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
@@ -48,8 +48,11 @@ class FbCookie @Inject internal constructor(
) {
companion object {
- private const val FB_COOKIE_DOMAIN = HTTPS_FACEBOOK_COM
- private const val MESSENGER_COOKIE_DOMAIN = HTTPS_MESSENGER_COM
+ /**
+ * Domain information. Dot prefix still matters for Android browsers.
+ */
+ private const val FB_COOKIE_DOMAIN = ".$FACEBOOK_COM"
+ private const val MESSENGER_COOKIE_DOMAIN = ".$MESSENGER_COM"
}
/**
@@ -135,22 +138,24 @@ class FbCookie @Inject internal constructor(
* Helper function to remove the current cookies
* and launch the proper login page
*/
- suspend fun logout(context: Context) {
+ suspend fun logout(context: Context, deleteCookie: Boolean = true) {
val cookies = arrayListOf<CookieEntity>()
if (context is Activity)
cookies.addAll(context.cookies().filter { it.id != prefs.userId })
- logout(prefs.userId)
+ logout(prefs.userId, deleteCookie)
context.launchLogin(cookies, true)
}
/**
* Clear the cookies of the given id
*/
- suspend fun logout(id: Long) {
+ suspend fun logout(id: Long, deleteCookie: Boolean = true) {
L.d { "Logging out user" }
- cookieDao.deleteById(id)
- L.d { "Fb cookie deleted" }
- L._d { id }
+ if (deleteCookie) {
+ cookieDao.deleteById(id)
+ L.d { "Fb cookie deleted" }
+ L._d { id }
+ }
reset()
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
index ec8aec6c..4ba87209 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
@@ -133,7 +133,7 @@ private inline fun <reified T : WebOverlayActivityBase> Context.launchWebOverlay
if (argUrl.isFacebookUrl && argUrl.contains("/logout.php")) {
L.d { "Logout php found" }
ctxCoroutine.launch {
- fbCookie.logout(this@launchWebOverlayImpl)
+ fbCookie.logout(this@launchWebOverlayImpl, deleteCookie = false)
}
} else if (!(prefs.linksInDefaultApp && resolveActivityForUri(Uri.parse(argUrl)))) {
startActivity<T>(
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 0d7bbb79..9a853dae 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
@@ -121,7 +121,7 @@ class FrostJSI(val web: FrostWebView) {
fun loadLogin() {
L.d { "Sign up button found; load login" }
context.ctxCoroutine.launch {
- fbCookie.logout(context)
+ fbCookie.logout(context, deleteCookie = false)
}
}