aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt15
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt3
2 files changed, 9 insertions, 9 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
index e5a50543..610b2796 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
@@ -116,7 +116,7 @@ class LoginActivity : BaseActivity() {
val imageDeferred = async { loadProfile(cookie.id) }
val nameDeferred = async { loadUsername(cookie) }
- val name: String = nameDeferred.await()
+ val name: String? = nameDeferred.await()
val foundImage: Boolean = imageDeferred.await()
L._d { "Logged in and received data" }
@@ -127,7 +127,7 @@ class LoginActivity : BaseActivity() {
L._i { cookie }
}
- textview.text = String.format(getString(R.string.welcome), name)
+ textview.text = String.format(getString(R.string.welcome), name ?: "")
textview.fadeIn()
frostEvent("Login", "success" to true)
@@ -172,22 +172,23 @@ class LoginActivity : BaseActivity() {
}
}
- private suspend fun loadUsername(cookie: CookieEntity): String = withContext(Dispatchers.IO) {
- val result: String = try {
+ private suspend fun loadUsername(cookie: CookieEntity): String? = withContext(Dispatchers.IO) {
+ val result: String? = try {
withTimeout(5000) {
frostJsoup(cookie.cookie, FbItem.PROFILE.url).title()
}
} catch (e: Exception) {
if (e !is UnknownHostException)
e.logFrostEvent("Fetch username failed")
- ""
+ null
}
- if (cookie.name?.isNotBlank() == false && result != cookie.name) {
+ if (result != null) {
cookieDao.save(cookie.copy(name = result))
+ return@withContext result
}
- cookie.name ?: ""
+ return@withContext cookie.name
}
override fun backConsumer(): Boolean {
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 4c7572fb..4b891800 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
@@ -89,8 +89,7 @@ class LoginWebView @JvmOverloads constructor(
val cookie = CookieManager.getInstance().getCookie(url) ?: return null
L.d { "Checking cookie for login" }
val id = FB_USER_MATCHER.find(cookie)[1]?.toLong() ?: return null
- // TODO set name to null?
- return CookieEntity(id, "", cookie)
+ return CookieEntity(id, null, cookie)
}
override fun onPageCommitVisible(view: WebView, url: String?) {