diff options
author | Allan Wang <me@allanwang.ca> | 2017-06-03 13:22:06 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-06-03 13:22:06 -0700 |
commit | 35185958b077880465696d686bd797895cd3ebd4 (patch) | |
tree | 431967b2b00d00c71b06fa7a7814e05524961ead /app/src/main/kotlin/com/pitchedapps/frost/web | |
parent | 5796566137995c8d244720f87ba85bce0e0d2f00 (diff) | |
download | frost-35185958b077880465696d686bd797895cd3ebd4.tar.gz frost-35185958b077880465696d686bd797895cd3ebd4.tar.bz2 frost-35185958b077880465696d686bd797895cd3ebd4.zip |
setup login activity
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt | 11 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt | 4 |
2 files changed, 12 insertions, 3 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt index 4dcf0d9e..03bb5a60 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt @@ -3,10 +3,12 @@ package com.pitchedapps.frost.web import android.graphics.Bitmap import android.view.KeyEvent import android.webkit.* +import com.pitchedapps.frost.LoginActivity import com.pitchedapps.frost.facebook.FACEBOOK_COM import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.injectors.CssAssets import com.pitchedapps.frost.utils.L +import com.pitchedapps.frost.utils.Prefs import com.pitchedapps.frost.views.circularReveal import com.pitchedapps.frost.views.fadeOut @@ -28,14 +30,19 @@ class FrostWebViewClient(val position: () -> Int) : WebViewClient() { super.onPageStarted(view, url, favicon) L.i("FWV Loading $url") if (!url.contains(FACEBOOK_COM)) return - if (url.contains("logout.php")) FbCookie.logout(position.invoke()) + if (url.contains("logout.php")) { + FbCookie.logout(Prefs.userId) + LoginActivity.newInstance(view.context) + } else if (url.contains("login.php")) { + FbCookie.reset() + LoginActivity.newInstance(view.context) + } view.fadeOut(duration = 200L) } override fun onPageFinished(view: WebView, url: String) { super.onPageFinished(view, url) if (!url.contains(FACEBOOK_COM)) return - FbCookie.checkUserId(url, CookieManager.getInstance().getCookie(url), position.invoke()) CssAssets.HEADER.inject(view, { view.circularReveal(offset = 150L) }) 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 6e0cf201..aa40f1f1 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt @@ -39,6 +39,7 @@ class LoginWebView @JvmOverloads constructor( lateinit var progressObservable: Subject<Int> init { + FbCookie.reset() cookieObservable.filter { (_, cookie) -> cookie?.contains(userMatcher) ?: false } .subscribe { (url, cookie) -> @@ -46,9 +47,10 @@ class LoginWebView @JvmOverloads constructor( val id = userMatcher.find(cookie!!)?.groups?.get(1)?.value if (id != null) { try { - FbCookie.save(id.toLong(), -1) + FbCookie.save(id.toLong()) //TODO proceed to next view cookieObservable.onComplete() + loginObservable.onSuccess(CookieModel(id.toLong(), "", cookie)) } catch (e: NumberFormatException) { //todo send report that id has changed } |