aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/assets/js/click_a.js32
-rw-r--r--app/src/main/assets/js/click_a.min.js29
-rw-r--r--app/src/main/assets/js/click_interceptor.js13
-rw-r--r--app/src/main/assets/js/click_interceptor.min.js17
-rw-r--r--app/src/main/assets/js/header_badges.min.js5
-rw-r--r--app/src/main/assets/js/menu.js73
-rw-r--r--app/src/main/assets/js/menu.min.js10
-rw-r--r--app/src/main/assets/js/search.js33
-rw-r--r--app/src/main/assets/js/search.min.js15
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt27
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbTab.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClientMenu.kt7
-rw-r--r--app/src/main/res/menu/menu_main.xml2
-rw-r--r--app/src/main/res/menu/menu_web.xml19
-rw-r--r--app/src/main/res/values/strings.xml2
-rw-r--r--app/src/main/res/xml/changelog.xml3
17 files changed, 177 insertions, 116 deletions
diff --git a/app/src/main/assets/js/click_a.js b/app/src/main/assets/js/click_a.js
index a960c4f2..aabcd7e3 100644
--- a/app/src/main/assets/js/click_a.js
+++ b/app/src/main/assets/js/click_a.js
@@ -1,18 +1,22 @@
// we will handle click events
-console.log('Registering frost_a click');
+if (!window.hasOwnProperty('frost_click_a')) {
+ console.log('Registering frost_click_a');
+ window.frost_click_a = true;
-var _frostAClick = function(e) {
- var element = e.target || e.srcElement;
- if (element.tagName !== 'A') element = element.parentNode;
- //Notifications is two layers under
- if (element.tagName !== 'A') element = element.parentNode;
- if (element.tagName === 'A' && element.getAttribute('href') !== '#') {
- var url = element.getAttribute('href');
- console.log('Click Intercept', url);
- Frost.loadUrl(url);
- e.stopPropagation();
- e.preventDefault();
+ var _frostAClick = function(e) {
+ var element = e.target || e.srcElement;
+ if (element.tagName !== 'A') element = element.parentNode;
+ //Notifications is two layers under
+ if (element.tagName !== 'A') element = element.parentNode;
+ if (element.tagName === 'A' && element.getAttribute('href') !== '#') {
+ var url = element.getAttribute('href');
+ if (url.includes('photoset_token')) return;
+ console.log('Click Intercept', url);
+ Frost.loadUrl(url);
+ e.stopPropagation();
+ e.preventDefault();
+ }
}
-}
-document.addEventListener('click', _frostAClick, true);
+ document.addEventListener('click', _frostAClick, true);
+}
diff --git a/app/src/main/assets/js/click_a.min.js b/app/src/main/assets/js/click_a.min.js
index d858d956..b09e7174 100644
--- a/app/src/main/assets/js/click_a.min.js
+++ b/app/src/main/assets/js/click_a.min.js
@@ -1,12 +1,17 @@
-console.log("Registering frost_a click")
-
-;var _frostAClick=function(t){
-var e=t.target||t.srcElement
-;if("A"!==e.tagName&&(e=e.parentNode),"A"!==e.tagName&&(e=e.parentNode),
-"A"===e.tagName&&"#"!==e.getAttribute("href")){
-var r=e.getAttribute("href")
-;console.log("Click Intercept",r),Frost.loadUrl(r),t.stopPropagation(),
-t.preventDefault()
-}
-}
-;document.addEventListener("click",_frostAClick,!0); \ No newline at end of file
+if(!window.hasOwnProperty("frost_click_a")){
+console.log("Registering frost_click_a");
+window.frost_click_a=true;
+var _frostAClick=function(e){
+var element=e.target||e.srcElement;
+if(element.tagName!=="A")element=element.parentNode;
+if(element.tagName!=="A")element=element.parentNode;
+if(element.tagName==="A"&&element.getAttribute("href")!=="#"){
+var url=element.getAttribute("href");
+if(url.includes("photoset_token"))return;
+console.log("Click Intercept",url);
+Frost.loadUrl(url);
+e.stopPropagation();
+e.preventDefault();
+}};
+document.addEventListener("click",_frostAClick,true);
+} \ No newline at end of file
diff --git a/app/src/main/assets/js/click_interceptor.js b/app/src/main/assets/js/click_interceptor.js
index ce55f669..debf85dc 100644
--- a/app/src/main/assets/js/click_interceptor.js
+++ b/app/src/main/assets/js/click_interceptor.js
@@ -1,6 +1,9 @@
// we will handle click events
-console.log('Registering click interceptor');
-document.addEventListener('click', function _menuClick(e) {
- var element = e.target || e.srcElement;
- console.log(element.tagName);
-}, true);
+if (!window.hasOwnProperty('frost_click_interceptor')) {
+ console.log('Registering frost_click_interceptor');
+ window.frost_click_interceptor = true;
+ document.addEventListener('click', function _menuClick(e) {
+ var element = e.target || e.srcElement;
+ console.log(element.tagName);
+ }, true);
+}
diff --git a/app/src/main/assets/js/click_interceptor.min.js b/app/src/main/assets/js/click_interceptor.min.js
index 3acb9265..45649781 100644
--- a/app/src/main/assets/js/click_interceptor.min.js
+++ b/app/src/main/assets/js/click_interceptor.min.js
@@ -1,9 +1,8 @@
-document.querySelector("body").addEventListener("click",function(e){
-e=e||window.event
-;var t=e.target||e.srcElement
-;if("A"!==t.tagName&&(t=t.parentNode),"A"===t.tagName){
-var n=t.href
-;console.log("Generic Click Intercept"),console.log(n)
-}
-return!1
-}); \ No newline at end of file
+if(!window.hasOwnProperty("frost_click_interceptor")){
+console.log("Registering frost_click_interceptor");
+window.frost_click_interceptor=true;
+document.addEventListener("click",function _menuClick(e){
+var element=e.target||e.srcElement;
+console.log(element.tagName);
+},true);
+} \ No newline at end of file
diff --git a/app/src/main/assets/js/header_badges.min.js b/app/src/main/assets/js/header_badges.min.js
index 9526474d..7d5b45ea 100644
--- a/app/src/main/assets/js/header_badges.min.js
+++ b/app/src/main/assets/js/header_badges.min.js
@@ -1,3 +1,2 @@
-var header=document.getElementById("mJewelNav")
-
-;null!==header&&Frost.handleHeader(header.outerHTML); \ No newline at end of file
+var header=document.getElementById("mJewelNav");
+if(header!==null)Frost.handleHeader(header.outerHTML); \ No newline at end of file
diff --git a/app/src/main/assets/js/menu.js b/app/src/main/assets/js/menu.js
index 458d9edf..f8cd03c9 100644
--- a/app/src/main/assets/js/menu.js
+++ b/app/src/main/assets/js/menu.js
@@ -1,36 +1,39 @@
//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();
+if (!window.hasOwnProperty('frost_menu')) {
+ console.log('Registering frost_menu');
+ window.frost_menu = true;
+ 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 4627b847..ce878b88 100644
--- a/app/src/main/assets/js/menu.min.js
+++ b/app/src/main/assets/js/menu.min.js
@@ -1,16 +1,14 @@
-console.log("Fetching menu")
-
+if(!window.hasOwnProperty("frost_menu")){
+console.log("Registering frost_menu"),window.frost_menu=!0
;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){
@@ -22,8 +20,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
index 5f0f0e0a..0a8954ef 100644
--- a/app/src/main/assets/js/search.js
+++ b/app/src/main/assets/js/search.js
@@ -1,16 +1,19 @@
//binds callbacks to an invisible webview to take in the search events
-console.log('Binding Search');
-var _f_page = document.querySelector('#page');
-// var _f_input = document.querySelector('#main-search-input')
-if (!_f_page) Frost.emit(1);
-// else {
- Frost.emit(0);
- var x = new MutationObserver(function(mutations) {
- Frost.handleHtml(page.innerHTML);
- Frost.emit(2);
- });
- x.observe(_f_page, {
- childList: true,
- subtree: true
- });
-// }
+if (!window.hasOwnProperty('frost_search')) {
+ console.log('Registering frost_search');
+ window.frost_search = true;
+ var _f_page = document.querySelector('#page');
+ // var _f_input = document.querySelector('#main-search-input')
+ if (!_f_page) Frost.emit(1);
+ else {
+ Frost.emit(0);
+ var x = new MutationObserver(function(mutations) {
+ Frost.handleHtml(page.innerHTML);
+ Frost.emit(2);
+ });
+ x.observe(_f_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
index c5e577d1..109bfb13 100644
--- a/app/src/main/assets/js/search.min.js
+++ b/app/src/main/assets/js/search.min.js
@@ -1,14 +1,15 @@
-console.log("Binding Search")
-
+if(!window.hasOwnProperty("frost_search")){
+console.log("Registering frost_search"),
+window.frost_search=!0
;var _f_page=document.querySelector("#page")
-
-;_f_page||Frost.emit(1),Frost.emit(0)
-
+;if(_f_page){
+Frost.emit(0)
;var x=new MutationObserver(function(e){
Frost.handleHtml(page.innerHTML),Frost.emit(2)
})
-
;x.observe(_f_page,{
childList:!0,
subtree:!0
-}); \ No newline at end of file
+})
+}else Frost.emit(1)
+} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
index 000a862e..9f203970 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
@@ -7,6 +7,8 @@ import android.support.design.widget.CoordinatorLayout
import android.support.design.widget.Snackbar
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.Toolbar
+import android.view.Menu
+import android.view.MenuItem
import android.webkit.ValueCallback
import android.webkit.WebChromeClient
import ca.allanwang.kau.permissions.kauOnRequestPermissionsResult
@@ -14,6 +16,7 @@ import ca.allanwang.kau.swipe.kauSwipeOnCreate
import ca.allanwang.kau.swipe.kauSwipeOnDestroy
import ca.allanwang.kau.swipe.kauSwipeOnPostCreate
import ca.allanwang.kau.utils.*
+import com.mikepenz.community_material_typeface_library.CommunityMaterial
import com.mikepenz.google_material_typeface_library.GoogleMaterial
import com.pitchedapps.frost.contracts.ActivityWebContract
import com.pitchedapps.frost.contracts.FileChooserContract
@@ -78,6 +81,7 @@ open class WebOverlayActivity : AppCompatActivity(),
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
val newUrl = intent.extras!!.getString(ARG_URL).formattedFbUrl
+ L.d("New intent")
if (url != newUrl) {
this.intent = intent
frostWeb.web.baseUrl = newUrl
@@ -126,4 +130,27 @@ open class WebOverlayActivity : AppCompatActivity(),
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
kauOnRequestPermissionsResult(permissions, grantResults)
}
+
+ override fun onCreateOptionsMenu(menu: Menu): Boolean {
+ menuInflater.inflate(R.menu.menu_web, menu)
+ toolbar.tint(Prefs.iconColor)
+ setMenuIcons(menu, Prefs.iconColor,
+ R.id.action_share to CommunityMaterial.Icon.cmd_share,
+ R.id.action_copy_link to GoogleMaterial.Icon.gmd_content_copy)
+ return true
+ }
+
+ override fun onOptionsItemSelected(item: MenuItem): Boolean {
+ when (item.itemId) {
+ R.id.action_copy_link -> copyToClipboard(frostWeb.web.url)
+ R.id.action_share -> {
+ val intent = Intent(Intent.ACTION_SEND)
+ intent.type = "text/plain"
+ intent.putExtra(Intent.EXTRA_TEXT, frostWeb.web.url)
+ startActivity(Intent.createChooser(intent, string(R.string.share)))
+ }
+ else -> return super.onOptionsItemSelected(item)
+ }
+ return true
+ }
} \ 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 f26581df..7e7a8f42 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbTab.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbTab.kt
@@ -12,8 +12,8 @@ import com.pitchedapps.frost.web.FrostWebViewCore
enum class FbTab(@StringRes val titleId: Int, val icon: IIcon, relativeUrl: String, val webClient: ((webCore: FrostWebViewCore) -> FrostWebViewClient)? = null) {
FEED(R.string.feed, CommunityMaterial.Icon.cmd_newspaper, ""),
- FEED_MOST_RECENT(R.string.most_recent, GoogleMaterial.Icon.gmd_history, "/?sk=h_chr"),
- FEED_TOP_STORIES(R.string.top_stories, GoogleMaterial.Icon.gmd_star, "/?sk=h_nor"),
+ FEED_MOST_RECENT(R.string.most_recent, GoogleMaterial.Icon.gmd_history, "?sk=h_chr"),
+ FEED_TOP_STORIES(R.string.top_stories, GoogleMaterial.Icon.gmd_star, "?sk=h_nor"),
PROFILE(R.string.profile, CommunityMaterial.Icon.cmd_account, "me"),
EVENTS(R.string.events, GoogleMaterial.Icon.gmd_event_note, "events/upcoming"),
FRIENDS(R.string.friends, GoogleMaterial.Icon.gmd_people, "friends/center/requests"),
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
index a3124dea..9fee3571 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
@@ -17,7 +17,6 @@ import android.widget.FrameLayout
import android.widget.TextView
import ca.allanwang.kau.utils.*
import com.afollestad.materialdialogs.MaterialDialog
-import com.bumptech.glide.GlideBuilder
import com.bumptech.glide.annotation.GlideModule
import com.bumptech.glide.module.AppGlideModule
import com.crashlytics.android.answers.Answers
@@ -65,6 +64,7 @@ val String.formattedFbUrl: String
fun Context.launchWebOverlay(url: String) {
val argUrl = url.formattedFbUrl
+ L.v("Launch received $url")
L.i("Launch web overlay: $argUrl")
startActivity(WebOverlayActivity::class.java, false, intentBuilder = {
putExtra(ARG_URL, argUrl)
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 5d44b580..0f08bcf3 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClientMenu.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClientMenu.kt
@@ -35,12 +35,7 @@ class FrostWebViewClientMenu(webCore: FrostWebViewCore) : FrostWebViewClient(web
override fun onPageFinished(view: WebView, url: String) {
super.onPageFinished(view, url)
if (url == webCore.baseUrl && content == null) {
- jsInject(JsAssets.MENU, callback = {
-// jsInject(JsAssets.CLICK_A) //menu injection must be after or we will have a loop from the click listener
- })
-// } else if (url == contentBaseUrl) {
-// L.i("Inject content")
-// jsInject(JsAssets.CLICK_A)
+ jsInject(JsAssets.MENU)
}
}
diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml
index d4cdddb9..3063ffec 100644
--- a/app/src/main/res/menu/menu_main.xml
+++ b/app/src/main/res/menu/menu_main.xml
@@ -5,7 +5,7 @@
<item
android:id="@+id/action_search"
- android:orderInCategory="200"
+ android:orderInCategory="100"
android:title="@string/kau_search"
app:showAsAction="always" />
<item
diff --git a/app/src/main/res/menu/menu_web.xml b/app/src/main/res/menu/menu_web.xml
new file mode 100644
index 00000000..833e7c27
--- /dev/null
+++ b/app/src/main/res/menu/menu_web.xml
@@ -0,0 +1,19 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ tools:context="com.pitchedapps.myapplication.MainActivity">
+
+
+ <item
+ android:id="@+id/action_copy_link"
+ android:orderInCategory="100"
+ android:title="@string/copy_link"
+ app:showAsAction="ifRoom" />
+
+ <item
+ android:id="@+id/action_share"
+ android:orderInCategory="200"
+ android:title="@string/kau_share"
+ app:showAsAction="always" />
+</menu>
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index a67861ef..73ee1316 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -40,6 +40,8 @@
<string name="theme_issue">Theme Issue</string>
<string name="feature_request">Feature Request</string>
<string name="subject">Subject</string>
+ <string name="share">Share</string>
+ <string name="copy_link">Copy Link</string>
<string name="no_longer_facebook">No longer under facebook; refreshing…</string>
diff --git a/app/src/main/res/xml/changelog.xml b/app/src/main/res/xml/changelog.xml
index ecd95c8d..82ec5257 100644
--- a/app/src/main/res/xml/changelog.xml
+++ b/app/src/main/res/xml/changelog.xml
@@ -10,6 +10,9 @@
<item text="Scale browser on keyboard pop up" />
<item text="Clean up web overlay" />
<item text="Allow customization of overlay swipe" />
+ <item text="Add sharing menu options in the overlay app" />
+ <item text="" />
+ <item text="" />
<item text="" />
<item text="" />
<item text="" />