From 1769dbcef9786b847ffeaebdf6ecced45da9222c Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 26 Dec 2017 03:37:32 -0500 Subject: Enhancement/fb requests (#575) * Update lambdas to references * Simplify regex and parsers * Fix some parsing and add more tests * Improve message parser and tests * Simplify parser * Shorten interfaces * Push rem * Create notification parser * Clean up notification service * Clean up notification service * Add safe cookie fallback * Fix cookie reference * Make parsers only hold cookie string * Clean up cookie references * Fix up login and event theme * Update changelog Remove workspace backup --- app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt') 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 f8b487a2..9251e607 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt @@ -2,6 +2,7 @@ package com.pitchedapps.frost.web import android.annotation.SuppressLint import android.content.Context +import android.graphics.Bitmap import android.graphics.Color import android.util.AttributeSet import android.view.View @@ -12,6 +13,7 @@ import com.pitchedapps.frost.dbflow.CookieModel 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.get import com.pitchedapps.frost.injectors.CssHider import com.pitchedapps.frost.injectors.jsInject import com.pitchedapps.frost.utils.L @@ -31,7 +33,7 @@ class LoginWebView @JvmOverloads constructor( private lateinit var progressCallback: (Int) -> Unit init { - FbCookie.reset { setupWebview() } + FbCookie.reset(this::setupWebview) } @SuppressLint("SetJavaScriptEnabled") @@ -62,13 +64,14 @@ class LoginWebView @JvmOverloads constructor( if (!url.isFacebookUrl) return@doAsync val cookie = CookieManager.getInstance().getCookie(url) ?: return@doAsync L.d("Checking cookie for login", cookie) - val id = FB_USER_MATCHER.find(cookie)?.groupValues?.get(1)?.toLong() ?: return@doAsync + val id = FB_USER_MATCHER.find(cookie)[1]?.toLong() ?: return@doAsync uiThread { onFound(id, cookie) } } } override fun onPageCommitVisible(view: WebView, url: String?) { super.onPageCommitVisible(view, url) + L.d("Login page commit visible") view.setBackgroundColor(Color.TRANSPARENT) if (url.isFacebookUrl) view.jsInject(CssHider.HEADER, -- cgit v1.2.3