1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-09 20:42:34 +01:00

Test kau update

This commit is contained in:
Allan Wang 2017-06-25 14:30:49 -07:00
parent e502ea8cd7
commit f35939ce42
11 changed files with 148 additions and 67 deletions

View File

@ -14,7 +14,7 @@
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<profile default="true" name="Default" enabled="true">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>

View File

@ -53,7 +53,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@ -95,24 +95,12 @@ dependencies {
// compile "com.github.Raizlabs.DBFlow:dbflow-rx2:${DBFLOW}"
// compile "com.github.Raizlabs.DBFlow:dbflow-rx2-kotlinextensions:${DBFLOW}"
// compile "org.greenrobot:eventbus:${EVENTBUS}"
//Icons
compile "com.mikepenz:google-material-typeface:${IICON_GOOGLE}.original@aar"
compile "com.mikepenz:material-design-iconic-typeface:${IICON_MATERIAL}@aar"
compile "com.mikepenz:community-material-typeface:${IICON_COMMUNITY}@aar"
compile "io.reactivex.rxjava2:rxjava:${RX_JAVA}"
compile "io.reactivex.rxjava2:rxandroid:${RX_ANDROID}"
// compile "com.jakewharton.rxbinding2:rxbinding:${RX_BINDING}"
// compile "com.jakewharton.rxbinding2:rxbinding-appcompat-v7:${RX_BINDING}"
// compile "com.lapism:searchview:${SEARCH_VIEW}"
compile "org.jsoup:jsoup:${JSOUP}"
compile "org.jetbrains.anko:anko:${ANKO}"
compile "com.github.bumptech.glide:glide:${GLIDE}"
annotationProcessor "com.github.bumptech.glide:compiler:${GLIDE}"

View File

@ -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();

View File

@ -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()
}
}),document.querySelector("#bookmarks_jewel").querySelector("a").click();

View File

@ -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
});

10
app/src/main/assets/js/search.min.js vendored Normal file
View File

@ -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
});

View File

@ -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"

View File

@ -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)
}
}
}
}

View File

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.2-5'
ext.kotlin_version = '1.1.3'
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }

View File

@ -19,24 +19,15 @@ BUILD_TOOLS=26.0.0
VERSION_CODE=5
VERSION_NAME=0.5
KAU=9e31fdd4f1
KAU=2c97b479d3
MATERIAL_DRAWER=5.9.2
MATERIAL_DRAWER_KT=1.0.2
IICON_GOOGLE=3.0.1.0
IICON_MATERIAL=2.2.0.2
IICON_COMMUNITY=1.9.32.1
SEARCH_VIEW=4.0
RX_JAVA=2.1.0
RX_ANDROID=2.0.1
RX_BINDING=2.0.0
JSOUP=1.10.2
ANKO=0.10.1
GLIDE=4.0.0-RC0
RETROFIT=2.2.0
EVENTBUS=3.0.0
DBFLOW=4.0.2
ROBOELECTRIC=3.3.2
RX_PREFS=2.0.0-RC2
PAPER_PARCEL=2.0.1
SWIPE_BACK=3.1.2
CRASHLYTICS=2.6.8