From b10a745c7f0f46f4f014e1ba7fa71172d7442b83 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 8 Jul 2017 03:03:55 -0400 Subject: Dev-1.1.7 (#39) - feature overload + context menu * Address some crashlytics issues * Add text scaling * Kau fixes and cleanup * WIP formatter * Create in house url formatter * Update context menu * Update themes * Test proguard without R * Implement sharing and clean up context menu * Disable viewpager swipe on long press * Test keeping lib strings * Update changelog and proguard --- .../kotlin/com/pitchedapps/frost/web/FrostJSI.kt | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt') 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 68163333..3340e7d2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt @@ -2,8 +2,10 @@ package com.pitchedapps.frost.web import android.content.Context import android.webkit.JavascriptInterface +import ca.allanwang.kau.logging.KL import com.pitchedapps.frost.MainActivity import com.pitchedapps.frost.dbflow.CookieModel +import com.pitchedapps.frost.facebook.formattedFbUrl import com.pitchedapps.frost.utils.* import io.reactivex.subjects.Subject @@ -11,7 +13,7 @@ import io.reactivex.subjects.Subject /** * Created by Allan Wang on 2017-06-01. */ -class FrostJSI(val context: Context, val webView: FrostWebViewCore, val contextMenu: FrostWebContextMenu) { +class FrostJSI(val context: Context, val webView: FrostWebViewCore) { val headerObservable: Subject? = (context as? MainActivity)?.headerBadgeObservable @@ -33,8 +35,17 @@ class FrostJSI(val context: Context, val webView: FrostWebViewCore, val contextM } @JavascriptInterface - fun contextMenu(url: String) { - contextMenu.post { contextMenu.show(url) } + fun contextMenu(url: String, text: String) { + webView.post { webView.context.showWebContextMenu(WebContext(url.formattedFbUrl, text)) } + } + + /** + * Get notified when a stationary long click starts or ends + * This will be used to toggle the main activities viewpager swipe + */ + @JavascriptInterface + fun longClick(start: Boolean) { + (webView.context as? MainActivity)?.viewPager?.enableSwipe = !start } @JavascriptInterface @@ -44,12 +55,12 @@ class FrostJSI(val context: Context, val webView: FrostWebViewCore, val contextM @JavascriptInterface fun emit(flag: Int) { - webView.post { webView.frostWebClient!!.emit(flag) } + webView.post { webView.frostWebClient.emit(flag) } } @JavascriptInterface fun handleHtml(html: String) { - webView.post { webView.frostWebClient!!.handleHtml(html) } + webView.post { webView.frostWebClient.handleHtml(html) } } @JavascriptInterface -- cgit v1.2.3