From d94bc858c8a0c273d87d705eb06d35cfd9cf9e08 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 25 Jul 2017 15:18:12 -0700 Subject: Update image downloads , IAB, and many issue reports (#95) * Remove iab proguard line * Remove dup vending aidl * Fix double calling issue * Change pro logging * Remove async call * Allow for multiple result flags from settings * Rename restore to get * Remove remaining async * Add null checks across web clients * Do not delete temp file on save * Implement image logic * Update file chooser * Update travis * Add intent checker * Update dependencies * Update dependencies * Add debugging option * Switch context for login glide * Scan newly added files * Update theme * Allow image downloading in messages * Finalize beta release * Build to beta * Update strings --- .../kotlin/com/pitchedapps/frost/web/FrostJSI.kt | 3 ++- .../pitchedapps/frost/web/FrostWebViewClients.kt | 27 ++++++++++++++++++---- .../com/pitchedapps/frost/web/LoginWebView.kt | 7 ++---- 3 files changed, 26 insertions(+), 11 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt index 13f1ac90..912a957e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt @@ -41,7 +41,8 @@ class FrostJSI(val webView: FrostWebViewCore) { @JavascriptInterface fun contextMenu(url: String, text: String?) { - webView.post { context.showWebContextMenu(WebContext(url.formattedFbUrl, text)) } + //url will be formatted through webcontext + webView.post { context.showWebContextMenu(WebContext(url, text)) } } /** 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 89eef258..7d5282d8 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -1,6 +1,8 @@ package com.pitchedapps.frost.web +import android.content.ActivityNotFoundException import android.content.Context +import android.content.Intent import android.graphics.Bitmap import android.webkit.WebResourceRequest import android.webkit.WebResourceResponse @@ -9,6 +11,7 @@ import android.webkit.WebViewClient 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 @@ -40,8 +43,9 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : BaseWebViewClient val refreshObservable: Subject = webCore.refreshObservable - override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) { + override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) { super.onPageStarted(view, url, favicon) + if (url == null) return L.i("FWV Loading $url") // L.v("Cookies ${CookieManager.getInstance().getCookie(url)}") refreshObservable.onNext(true) @@ -57,8 +61,9 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : BaseWebViewClient c.launchNewTask(LoginActivity::class.java) } - override fun onPageFinished(view: WebView, url: String) { + override fun onPageFinished(view: WebView, url: String?) { super.onPageFinished(view, url) + if (url == null) return L.i("Page finished $url") if (!url.contains(FACEBOOK_COM)) { refreshObservable.onNext(false) @@ -103,9 +108,11 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : BaseWebViewClient /** * Helper to format the request and launch it * returns true to override the url + * returns false if we are already in an overlaying activity */ private fun launchRequest(request: WebResourceRequest): Boolean { L.d("Launching Url", request.url.toString()) + if (webCore.context is WebOverlayActivity) return false webCore.context.launchWebOverlay(request.url.toString()) return true } @@ -124,6 +131,13 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : BaseWebViewClient if (path.startsWith("/composer/")) return launchRequest(request) if (request.url.toString().contains("scontent-sea1-1.xx.fbcdn.net") && (path.endsWith(".jpg") || path.endsWith(".png"))) return launchImage(request) + if (!request.url.toString().contains(FACEBOOK_COM)) { + val intent = Intent(Intent.ACTION_VIEW, request.url) + if (intent.resolveActivity(view.context.packageManager) != null) { + view.context.startActivity(Intent(Intent.ACTION_VIEW, request.url)) + return true + } + } return super.shouldOverrideUrlLoading(view, request) } @@ -142,8 +156,9 @@ class FrostWebViewClientMenu(webCore: FrostWebViewCore) : FrostWebViewClient(web else -> false } - override fun onPageFinished(view: WebView, url: String) { + override fun onPageFinished(view: WebView, url: String?) { super.onPageFinished(view, url) + if (url == null) return if (url.shouldInjectMenu) jsInject(JsAssets.MENU) } @@ -163,13 +178,15 @@ class FrostWebViewClientMenu(webCore: FrostWebViewCore) : FrostWebViewClient(web */ class HeadlessWebViewClient(val tag: String, val postInjection: InjectorContract) : BaseWebViewClient() { - override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) { + override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) { super.onPageStarted(view, url, favicon) + if (url == null) return L.d("Headless Page $tag Started", url) } - override fun onPageFinished(view: WebView, url: String) { + override fun onPageFinished(view: WebView, url: String?) { super.onPageFinished(view, url) + if (url == null) return L.d("Headless Page $tag Finished", url) postInjection.inject(view) } 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 b23d898e..b178f66c 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt @@ -24,10 +24,7 @@ import io.reactivex.subjects.Subject /** * Created by Allan Wang on 2017-05-29. - * */ - - class LoginWebView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 ) : WebView(context, attrs, defStyleAttr) { @@ -71,9 +68,9 @@ class LoginWebView @JvmOverloads constructor( inner class LoginClient : BaseWebViewClient() { - override fun onPageFinished(view: WebView, url: String) { + override fun onPageFinished(view: WebView, url: String?) { super.onPageFinished(view, url) - if (!url.contains(FACEBOOK_COM)) { + if (url == null || !url.contains(FACEBOOK_COM)) { view.frostSnackbar(R.string.no_longer_facebook) loadLogin() return -- cgit v1.2.3