aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-07-07 03:26:55 -0400
committerGitHub <noreply@github.com>2017-07-07 03:26:55 -0400
commit6adfc496374eb88919f70a240eb15a726d2c18e0 (patch)
tree7cba34515bde7d840d37c50c397e948407776cc9 /app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt
parentbb70ed737d98abbd6164b66ac5bd667553b312bd (diff)
downloadfrost-6adfc496374eb88919f70a240eb15a726d2c18e0.tar.gz
frost-6adfc496374eb88919f70a240eb15a726d2c18e0.tar.bz2
frost-6adfc496374eb88919f70a240eb15a726d2c18e0.zip
Dev 1.1.6 (#33) - Fix play store listing, add sharing options, update css & jsv1.1.6
* Remove play store listing updates * Fix up listing * Combine url getters for overlay activity * Begin building context menu programmatically * Update css and js
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt25
1 files changed, 24 insertions, 1 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt
index 7f74990e..64bdf888 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt
@@ -1,6 +1,8 @@
package com.pitchedapps.frost.web
+import android.annotation.SuppressLint
import android.content.Context
+import android.graphics.Color
import android.os.Build
import android.support.v4.widget.SwipeRefreshLayout
import android.util.AttributeSet
@@ -25,7 +27,8 @@ class FrostWebView @JvmOverloads constructor(
val refresh: SwipeRefreshLayout by bindView(R.id.swipe_refresh)
val web: FrostWebViewCore by bindView(R.id.frost_webview_core)
- val progress: ProgressBar by bindView(R.id.progressBar)
+ val progress: ProgressBar by bindView(R.id.progress_bar)
+ val contextMenu: FrostWebContextMenu by bindView(R.id.context_menu)
init {
inflate(getContext(), R.layout.swipe_webview, this)
@@ -50,6 +53,26 @@ class FrostWebView @JvmOverloads constructor(
})
}
+ @SuppressLint("SetJavaScriptEnabled")
+ fun setupWebview(url: String, enum: FbTab? = null) {
+ with (web) {
+ baseUrl = url
+ baseEnum = enum
+ with(settings) {
+ javaScriptEnabled = true
+ userAgentString = com.pitchedapps.frost.facebook.USER_AGENT_BASIC
+ allowFileAccess = true
+ defaultFontSize
+ }
+ setLayerType(View.LAYER_TYPE_HARDWARE, null)
+ frostWebClient = baseEnum?.webClient?.invoke(this) ?: FrostWebViewClient(this)
+ webViewClient = frostWebClient
+ webChromeClient = FrostChromeClient(this)
+ addJavascriptInterface(FrostJSI(context, this, contextMenu), "Frost")
+ setBackgroundColor(Color.TRANSPARENT)
+ }
+ }
+
//Some urls have postJavascript injections so make sure we load the base url
override fun onRefresh() {
when (web.baseUrl) {