aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-25 14:30:49 -0700
committerAllan Wang <me@allanwang.ca>2017-06-25 14:30:49 -0700
commitf35939ce42ca9244468434f93dbd705e02911623 (patch)
treef473434ce37f4844e288489452d1773c03511736 /app/src/main
parente502ea8cd77357c1e9a6680d912252524f2950f0 (diff)
downloadfrost-f35939ce42ca9244468434f93dbd705e02911623.tar.gz
frost-f35939ce42ca9244468434f93dbd705e02911623.tar.bz2
frost-f35939ce42ca9244468434f93dbd705e02911623.zip
Test kau update
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/assets/js/menu.js74
-rw-r--r--app/src/main/assets/js/menu.min.js8
-rw-r--r--app/src/main/assets/js/search.js10
-rw-r--r--app/src/main/assets/js/search.min.js10
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbTab.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt81
6 files changed, 144 insertions, 42 deletions
diff --git a/app/src/main/assets/js/menu.js b/app/src/main/assets/js/menu.js
index 4a39a93b..458d9edf 100644
--- a/app/src/main/assets/js/menu.js
+++ b/app/src/main/assets/js/menu.js
@@ -1,38 +1,36 @@
-if (document.querySelector('#mJewelNav') !== null) {
- console.log('Fetching menu');
- var viewport = document.querySelector('#viewport');
- var root = document.querySelector('#root');
- var y = new MutationObserver(function(mutations) {
- viewport.removeAttribute('style');
- root.removeAttribute('style');
- });
- y.observe(viewport, {
- attributes: true
- });
- y.observe(root, {
- attributes: true
- });
- var x = new MutationObserver(function(mutations) {
- var menu = document.querySelector('.mSideMenu');
- if (menu !== null) {
- x.disconnect();
- console.log('Found side menu');
- while (root.firstChild)
- root.removeChild(root.firstChild);
- while (menu.childNodes.length)
- root.appendChild(menu.childNodes[0]);
- Frost.emit(0);
- setTimeout(function() {
- y.disconnect();
- console.log('Unhook styler');
- Frost.handleHtml(document.documentElement.outerHTML);
- }, 500);
- }
- });
- x.observe(document.querySelector('#mJewelNav'), {
- childList: true,
- subtree: true
- });
- document.querySelector('#bookmarks_jewel').querySelector('a').click();
-}
-//otherwise we've already found the side nav and this is unnecessary
+//click menu and move contents to main view
+console.log('Fetching menu');
+var viewport = document.querySelector('#viewport');
+var root = document.querySelector('#root');
+var y = new MutationObserver(function(mutations) {
+ viewport.removeAttribute('style');
+ root.removeAttribute('style');
+});
+y.observe(viewport, {
+ attributes: true
+});
+y.observe(root, {
+ attributes: true
+});
+var x = new MutationObserver(function(mutations) {
+ var menu = document.querySelector('.mSideMenu');
+ if (menu !== null) {
+ x.disconnect();
+ console.log('Found side menu');
+ while (root.firstChild)
+ root.removeChild(root.firstChild);
+ while (menu.childNodes.length)
+ root.appendChild(menu.childNodes[0]);
+ Frost.emit(0);
+ setTimeout(function() {
+ y.disconnect();
+ console.log('Unhook styler');
+ Frost.handleHtml(document.documentElement.outerHTML);
+ }, 500);
+ }
+});
+x.observe(document.querySelector('#mJewelNav'), {
+ childList: true,
+ subtree: true
+});
+document.querySelector('#bookmarks_jewel').querySelector('a').click();
diff --git a/app/src/main/assets/js/menu.min.js b/app/src/main/assets/js/menu.min.js
index 0f218ea5..4627b847 100644
--- a/app/src/main/assets/js/menu.min.js
+++ b/app/src/main/assets/js/menu.min.js
@@ -1,14 +1,16 @@
-if(null!==document.querySelector("#mJewelNav")){
console.log("Fetching menu")
+
;var viewport=document.querySelector("#viewport"),root=document.querySelector("#root"),y=new MutationObserver(function(e){
viewport.removeAttribute("style"),
root.removeAttribute("style")
})
+
;y.observe(viewport,{
attributes:!0
}),y.observe(root,{
attributes:!0
})
+
;var x=new MutationObserver(function(e){
var o=document.querySelector(".mSideMenu")
;if(null!==o){
@@ -20,8 +22,8 @@ Frost.handleHtml(document.documentElement.outerHTML)
},500)
}
})
+
;x.observe(document.querySelector("#mJewelNav"),{
childList:!0,
subtree:!0
-}),document.querySelector("#bookmarks_jewel").querySelector("a").click()
-} \ No newline at end of file
+}),document.querySelector("#bookmarks_jewel").querySelector("a").click(); \ No newline at end of file
diff --git a/app/src/main/assets/js/search.js b/app/src/main/assets/js/search.js
new file mode 100644
index 00000000..3d10e6f5
--- /dev/null
+++ b/app/src/main/assets/js/search.js
@@ -0,0 +1,10 @@
+//binds callbacks to an invisible webview to take in the search events
+console.log('Binding Search');
+var page = document.querySelector('#page');
+var x = new MutationObserver(function(mutations) {
+ Frost.handleHtml(page.innerHTML);
+});
+x.observe(page, {
+ childList: true,
+ subtree: true
+});
diff --git a/app/src/main/assets/js/search.min.js b/app/src/main/assets/js/search.min.js
new file mode 100644
index 00000000..fe93d004
--- /dev/null
+++ b/app/src/main/assets/js/search.min.js
@@ -0,0 +1,10 @@
+console.log("Binding Search")
+
+;var page=document.querySelector("#page"),x=new MutationObserver(function(e){
+Frost.handleHtml(page.innerHTML)
+})
+
+;x.observe(page,{
+childList:!0,
+subtree:!0
+}); \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbTab.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbTab.kt
index c91792a2..f26581df 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbTab.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbTab.kt
@@ -29,7 +29,8 @@ enum class FbTab(@StringRes val titleId: Int, val icon: IIcon, relativeUrl: Stri
SETTINGS(R.string.settings, GoogleMaterial.Icon.gmd_settings, "settings"),
MENU(R.string.menu, GoogleMaterial.Icon.gmd_menu, "settings", { FrostWebViewClientMenu(it) }),
NOTES(R.string.notes, CommunityMaterial.Icon.cmd_note, "notes"),
- ON_THIS_DAY(R.string.on_this_day, GoogleMaterial.Icon.gmd_today, "onthisday")
+ ON_THIS_DAY(R.string.on_this_day, GoogleMaterial.Icon.gmd_today, "onthisday"),
+ SEARCH(R.string.search_menu_title, GoogleMaterial.Icon.gmd_search, "search")
;
val url = "$FB_URL_BASE$relativeUrl"
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt
new file mode 100644
index 00000000..0795efe2
--- /dev/null
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt
@@ -0,0 +1,81 @@
+package com.pitchedapps.frost.web
+
+import android.annotation.SuppressLint
+import android.content.Context
+import android.graphics.Color
+import android.support.v4.view.NestedScrollingChild
+import android.util.AttributeSet
+import android.view.View
+import android.webkit.WebView
+import ca.allanwang.kau.utils.*
+import com.pitchedapps.frost.facebook.FbTab
+import com.pitchedapps.frost.facebook.USER_AGENT_BASIC
+import com.pitchedapps.frost.utils.Prefs
+import io.reactivex.android.schedulers.AndroidSchedulers
+import io.reactivex.disposables.Disposable
+import io.reactivex.subjects.BehaviorSubject
+import io.reactivex.subjects.PublishSubject
+
+/**
+ * Created by Allan Wang on 2017-06-25.
+ *
+ * A bare bone search view meant solely to extract data from the web
+ * This should be hidden
+ */
+class FrostWebViewSearch (context: Context) : WebView(context) {
+ var baseUrl: String? = null
+ var baseEnum: FbTab? = null
+ internal var frostWebClient: FrostWebViewClient? = null
+
+ init {
+ gone()
+ setupWebview()
+ }
+
+ @SuppressLint("SetJavaScriptEnabled")
+ fun setupWebview(url: String, enum: FbTab? = null) {
+ baseUrl = url
+ baseEnum = enum
+ settings.javaScriptEnabled = true
+ settings.userAgentString = USER_AGENT_BASIC
+// settings.domStorageEnabled = true
+ setLayerType(View.LAYER_TYPE_HARDWARE, null)
+ frostWebClient = baseEnum?.webClient?.invoke(this) ?: FrostWebViewClient(this)
+ webViewClient = frostWebClient
+ webChromeClient = FrostChromeClient(this)
+ addJavascriptInterface(FrostJSI(context, this), "Frost")
+ setBackgroundColor(Color.TRANSPARENT)
+ }
+
+ fun loadUrl(url: String?, animate: Boolean) {
+ if (url == null) return
+ registerTransition(animate)
+ super.loadUrl(url)
+ }
+
+ fun reload(animate: Boolean) {
+ registerTransition(animate)
+ super.reload()
+ }
+
+ /**
+ * Hook onto the refresh observable for one cycle
+ * Animate toggles between the fancy ripple and the basic fade
+ * The cycle only starts on the first load since there may have been another process when this is registered
+ */
+ fun registerTransition(animate: Boolean) {
+ var dispose: Disposable? = null
+ var loading = false
+ dispose = refreshObservable.subscribeOn(AndroidSchedulers.mainThread()).subscribe {
+ if (it) {
+ loading = true
+ if (isVisible()) fadeOut(duration = 200L)
+ } else if (loading) {
+ dispose?.dispose()
+ if (animate && Prefs.animate) circularReveal(offset = 150L)
+ else fadeIn(duration = 100L)
+ }
+ }
+ }
+
+}