From 84bf883a47b956865d31b1b618d5495fcd7d4876 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 19 Aug 2017 09:47:05 -0700 Subject: v1.4.7 (#195) * Add try catch (#179) * Add checks before injections (#180) * Enhancement/url redirect manager (#182) * Initial blacklist * Move js checks to java * Optimize imports and clean up request interceptor * Misc (#190) * Update play store description * Finalize description * Update kotlin and bg2 for custom themes * Update to Android Studio 3.0 beta 2 * Update test dependencies and add logging to image activity * Rename throwable to errorRef * Update searchview and media picker through kau * Update themes (#183) * Theme content now found view * Update verified bg and bg2 for transparent themes * Fix check in star text * Various fixes * Create base svg sass images * Feature/theme accent (#192) * Add lots of theming components * Optimize and add * Update accents * Misc 2 (#191) * Add further checks for iab and remove generic error dialog * Theme all snackbars * Add dynamic media action tile * Enhancement/media-camera-picker (#194) * Update kau * Update changelog --- .../pitchedapps/frost/web/FrostWebViewClients.kt | 24 ++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt index 5f679c65..b1466ee8 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -11,7 +11,6 @@ import com.pitchedapps.frost.activities.LoginActivity import com.pitchedapps.frost.activities.MainActivity import com.pitchedapps.frost.activities.SelectorActivity import com.pitchedapps.frost.activities.WebOverlayActivity -import com.pitchedapps.frost.facebook.FACEBOOK_COM import com.pitchedapps.frost.facebook.FB_URL_BASE import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.facebook.FbItem @@ -34,7 +33,7 @@ import org.jetbrains.anko.withAlpha open class BaseWebViewClient : WebViewClient() { override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest): WebResourceResponse? - = shouldFrostInterceptRequest(view, request) + = view.shouldFrostInterceptRequest(request) } @@ -51,7 +50,7 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : BaseWebViewClient if (url == null) return L.i("FWV Loading", url) refreshObservable.onNext(true) - if (!url.contains(FACEBOOK_COM)) return + if (!url.isFacebookUrl) return if (url.contains("logout.php")) FbCookie.logout(Prefs.userId, { launchLogin(view.context) }) else if (url.contains("login.php")) FbCookie.reset({ launchLogin(view.context) }) } @@ -71,18 +70,19 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : BaseWebViewClient override fun onPageCommitVisible(view: WebView, url: String?) { super.onPageCommitVisible(view, url) injectBackgroundColor() - view.jsInject( - CssAssets.ROUND_ICONS.maybe(Prefs.showRoundedIcons), - CssHider.HEADER, - CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!Prefs.showSuggestedFriends && IS_FROST_PRO), - Prefs.themeInjector, - CssHider.NON_RECENT.maybe(webCore.url?.contains("?sk=h_chr") ?: false)) + if (url.isFacebookUrl) + view.jsInject( + CssAssets.ROUND_ICONS.maybe(Prefs.showRoundedIcons), + CssHider.HEADER, + CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!Prefs.showSuggestedFriends && IS_FROST_PRO), + Prefs.themeInjector, + CssHider.NON_RECENT.maybe(webCore.url?.contains("?sk=h_chr") ?: false)) } override fun onPageFinished(view: WebView, url: String?) { url ?: return L.i("Page finished", url) - if (!url.contains(FACEBOOK_COM)) { + if (!url.isFacebookUrl) { refreshObservable.onNext(false) return } @@ -124,9 +124,7 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : BaseWebViewClient */ private fun launchRequest(request: WebResourceRequest): Boolean { L.d("Launching Url", request.url?.toString() ?: "null") - if (webCore.context is WebOverlayActivity) return false - webCore.context.launchWebOverlay(request.url.toString()) - return true + return webCore.context !is WebOverlayActivity && webCore.context.requestWebOverlay(request.url.toString()) } private fun launchImage(url: String, text: String? = null): Boolean { -- cgit v1.2.3