diff options
author | Allan Wang <me@allanwang.ca> | 2017-07-13 13:50:00 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-13 13:50:00 -0700 |
commit | 91119de328bf5f4e8c945f8fb470453319b9f0ed (patch) | |
tree | 9ba1786f9cd8488a0cc0dfb247e1b387a4161cfb /app/src/main/kotlin/com/pitchedapps/frost/web | |
parent | de34d09f975079d5c044eae6da7ed92605009faf (diff) | |
download | frost-91119de328bf5f4e8c945f8fb470453319b9f0ed.tar.gz frost-91119de328bf5f4e8c945f8fb470453319b9f0ed.tar.bz2 frost-91119de328bf5f4e8c945f8fb470453319b9f0ed.zip |
Dev 1.2.2 - Add framework for messenger notifications (#47)
* Update KAU to v2.0
* Only inject theme for facebook and inject js after
* Clean up menu loading logic
* Add path null check
* Remove .idea files
* Add url formatter testers
* Update tests and check url nullability - Fixes
* Create instant messaging parser
* Shorted notification log and remove unnecessary null checks
* Make migration buildable
* Test message parser
* finalize messenger notifs for now
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt | 22 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClientMenu.kt | 45 |
2 files changed, 23 insertions, 44 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 16a4a092..0a254c50 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt @@ -45,15 +45,15 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : WebViewClient() { refreshObservable.onNext(false) return } - view.jsInject(JsActions.LOGIN_CHECK, + view.jsInject( CssAssets.ROUND_ICONS.maybe(Prefs.showRoundedIcons), CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!Prefs.showSuggestedFriends && Prefs.pro), - CssHider.ADS.maybe(!Prefs.showFacebookAds && Prefs.pro), - JsAssets.HEADER_BADGES.maybe(webCore.baseEnum != null)) + CssHider.ADS.maybe(!Prefs.showFacebookAds && Prefs.pro) + ) onPageFinishedActions(url) } - open internal fun onPageFinishedActions(url: String?) { + open internal fun onPageFinishedActions(url: String) { injectAndFinish() } @@ -61,9 +61,15 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : WebViewClient() { L.d("Page finished reveal") webCore.jsInject(CssHider.HEADER, Prefs.themeInjector, - JsAssets.CLICK_A.maybe(webCore.baseEnum != null), - JsAssets.CONTEXT_A, - callback = { refreshObservable.onNext(false) }) + callback = { + refreshObservable.onNext(false) + webCore.jsInject( + JsActions.LOGIN_CHECK, + JsAssets.CLICK_A.maybe(webCore.baseEnum != null), + JsAssets.CONTEXT_A, + JsAssets.HEADER_BADGES.maybe(webCore.baseEnum != null) + ) + }) } open fun handleHtml(html: String) { @@ -86,7 +92,7 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : WebViewClient() { override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean { L.i("Url Loading ${request.url}") - val path = request.url.path + val path = request.url.path ?: return super.shouldOverrideUrlLoading(view, request) if (path.startsWith("/composer/")) return launchRequest(request) return super.shouldOverrideUrlLoading(view, request) } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClientMenu.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClientMenu.kt index 0f08bcf3..10648e73 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClientMenu.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClientMenu.kt @@ -1,42 +1,26 @@ package com.pitchedapps.frost.web -import android.graphics.Bitmap import android.webkit.WebView import com.pitchedapps.frost.facebook.FB_URL_BASE import com.pitchedapps.frost.injectors.JsAssets import com.pitchedapps.frost.injectors.jsInject -import com.pitchedapps.frost.utils.L -import io.reactivex.subjects.Subject /** * Created by Allan Wang on 2017-05-31. */ class FrostWebViewClientMenu(webCore: FrostWebViewCore) : FrostWebViewClient(webCore) { - var content: String? = null - val progressObservable: Subject<Int> = webCore.progressObservable - private val contentBaseUrl = "${FB_URL_BASE}notifications" - - override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) { - super.onPageStarted(view, url, favicon) - if (content != null) { - when (url.removePrefix(FB_URL_BASE)) { - "settings", - "settings#", - "settings#!/settings?soft=bookmarks" -> { - L.d("Load from stored $url") - view.stopLoading() - view.loadDataWithBaseURL(contentBaseUrl, content, "text/html", "utf-8", "https://google.ca/test") - } - } - } + private val String.shouldInjectMenu + get() = when (removePrefix(FB_URL_BASE)) { + "settings", + "settings#", + "settings#!/settings?soft=bookmarks" -> true + else -> false } override fun onPageFinished(view: WebView, url: String) { super.onPageFinished(view, url) - if (url == webCore.baseUrl && content == null) { - jsInject(JsAssets.MENU) - } + if (url.shouldInjectMenu) jsInject(JsAssets.MENU) } override fun emit(flag: Int) { @@ -44,19 +28,8 @@ class FrostWebViewClientMenu(webCore: FrostWebViewCore) : FrostWebViewClient(web super.injectAndFinish() } - override fun onPageFinishedActions(url: String?) { - when (url?.removePrefix(FB_URL_BASE)) { - "settings", - "settings#", - "settings#!/settings?soft=bookmarks" -> { - //do nothing; we will further inject before revealing - } - else -> injectAndFinish() - } + override fun onPageFinishedActions(url: String) { + if (!url.shouldInjectMenu) injectAndFinish() } - override fun handleHtml(html: String) { - super.handleHtml(html) - content = html //we will not save this locally in case things change - } }
\ No newline at end of file |