aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt35
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt1
2 files changed, 23 insertions, 13 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt
index 37383182..aa6a0130 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt
@@ -20,6 +20,7 @@ import android.content.Intent
import android.graphics.Color
import android.os.Build
import android.os.Bundle
+import android.webkit.CookieManager
import android.widget.ImageView
import android.widget.TextView
import ca.allanwang.kau.internal.KauBaseActivity
@@ -31,6 +32,7 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial
import com.pitchedapps.frost.activities.LoginActivity
import com.pitchedapps.frost.activities.MainActivity
import com.pitchedapps.frost.activities.SelectorActivity
+import com.pitchedapps.frost.dbflow.CookieModel
import com.pitchedapps.frost.dbflow.loadFbCookiesSync
import com.pitchedapps.frost.facebook.FbCookie
import com.pitchedapps.frost.utils.EXTRA_COOKIES
@@ -56,6 +58,14 @@ class StartActivity : KauBaseActivity() {
showInvalidSdkView()
return
}
+
+ try {
+ // TODO add better descriptions
+ CookieManager.getInstance()
+ } catch (e: Exception) {
+ showInvalidWebView()
+ }
+
launch {
try {
FbCookie.switchBackUser()
@@ -64,18 +74,17 @@ class StartActivity : KauBaseActivity() {
})
L.i { "Cookies loaded at time ${System.currentTimeMillis()}" }
L._d { "Cookies: ${cookies.joinToString("\t")}" }
- loadAssets()
- if (cookies.isNotEmpty()) {
- if (Prefs.userId != -1L)
- startActivity<MainActivity>(intentBuilder = {
- putParcelableArrayListExtra(EXTRA_COOKIES, cookies)
- flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or
- Intent.FLAG_ACTIVITY_SINGLE_TOP
- })
- else
- launchNewTask<SelectorActivity>(cookies)
- } else
- launchNewTask<LoginActivity>()
+ loadAssets()
+ when {
+ cookies.isEmpty() -> launchNewTask<LoginActivity>()
+ // Has cookies but no selected account
+ Prefs.userId == -1L -> launchNewTask<SelectorActivity>(cookies)
+ else -> startActivity<MainActivity>(intentBuilder = {
+ putParcelableArrayListExtra(EXTRA_COOKIES, cookies)
+ flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or
+ Intent.FLAG_ACTIVITY_SINGLE_TOP
+ })
+ }
} catch (e: Exception) {
showInvalidWebView()
}
@@ -87,7 +96,7 @@ class StartActivity : KauBaseActivity() {
private fun showInvalidSdkView() {
val text = try {
- String.format(getString(R.string.error_sdk), Build.VERSION.SDK_INT)
+ String.format(string(R.string.error_sdk), Build.VERSION.SDK_INT)
} catch (e: IllegalFormatException) {
string(R.string.error_sdk)
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt
index 77cb4de1..0caeda1a 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt
@@ -63,6 +63,7 @@ enum class CssAssets(val folder: String = THEME_FOLDER) : InjectorContract {
.replace("\$T\$", Prefs.textColor.toRgbaString())
.replace("\$TT\$", Prefs.textColor.colorToBackground(0.05f).toRgbaString())
.replace("\$A\$", Prefs.accentColor.toRgbaString())
+ .replace("\$AT\$", Prefs.iconColor.toRgbaString())
.replace("\$B\$", Prefs.bgColor.toRgbaString())
.replace("\$BT\$", bt)
.replace("\$BBT\$", bb.withAlpha(51).toRgbaString())