mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-09-19 23:21:34 +02:00
Delete custom menu item logic
This commit is contained in:
parent
239781bea3
commit
f0519246ed
@ -45,13 +45,7 @@ enum class FbItem(
|
||||
FRIENDS(R.string.friends, GoogleMaterial.Icon.gmd_person_add, "friends/center/requests"),
|
||||
GROUPS(R.string.groups, GoogleMaterial.Icon.gmd_group, "groups"),
|
||||
MARKETPLACE(R.string.marketplace, GoogleMaterial.Icon.gmd_store, "marketplace"),
|
||||
|
||||
/*
|
||||
* Unlike other urls, menus cannot be linked directly as it is a soft reference. Instead, we can
|
||||
* pick any url with the blue bar and manually click to enter the menu.
|
||||
* We pick home.php as some back interactions default to home regardless of the base url.
|
||||
*/
|
||||
MENU(R.string.menu, GoogleMaterial.Icon.gmd_menu, "home.php"),
|
||||
MENU(R.string.menu, GoogleMaterial.Icon.gmd_menu, "bookmarks"),
|
||||
MESSAGES(R.string.messages, MaterialDesignIconic.Icon.gmi_comments, "messages"),
|
||||
MESSENGER(
|
||||
R.string.messenger,
|
||||
|
@ -25,7 +25,6 @@ import com.pitchedapps.frost.injectors.JsActions
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.views.FrostWebView
|
||||
import com.pitchedapps.frost.web.FrostWebViewClient
|
||||
import com.pitchedapps.frost.web.FrostWebViewClientMenu
|
||||
import com.pitchedapps.frost.web.FrostWebViewClientMessenger
|
||||
|
||||
/**
|
||||
@ -41,7 +40,6 @@ class WebFragment : BaseFragment() {
|
||||
fun client(web: FrostWebView) =
|
||||
when (baseEnum) {
|
||||
FbItem.MESSENGER -> FrostWebViewClientMessenger(web)
|
||||
FbItem.MENU -> FrostWebViewClientMenu(web)
|
||||
else -> FrostWebViewClient(web)
|
||||
}
|
||||
|
||||
|
@ -23,13 +23,6 @@ import com.pitchedapps.frost.prefs.Prefs
|
||||
enum class CssAsset(private val content: String) : InjectorContract {
|
||||
FullSizeImage(
|
||||
"div._4prr[style*=\"max-width\"][style*=\"max-height\"]{max-width:none !important;max-height:none !important}"
|
||||
),
|
||||
|
||||
/*
|
||||
* Remove top margin and hide some contents from the top bar and home page (as it's our base url)
|
||||
*/
|
||||
Menu(
|
||||
"#bookmarks_flyout{margin-top:0 !important}#m_news_feed_stream,#MComposer{display:none !important}"
|
||||
);
|
||||
|
||||
val injector: JsInjector by lazy {
|
||||
|
@ -30,11 +30,10 @@ import kotlinx.coroutines.withContext
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-05-31. Mapping of the available assets The enum name must match the
|
||||
* css file name
|
||||
* js file name
|
||||
*/
|
||||
enum class JsAssets(private val singleLoad: Boolean = true) : InjectorContract {
|
||||
MENU,
|
||||
MENU_QUICK(singleLoad = false),
|
||||
CLICK_A,
|
||||
CONTEXT_A,
|
||||
MEDIA,
|
||||
|
@ -46,7 +46,6 @@ import com.pitchedapps.frost.web.FrostWebClientEntryPoint
|
||||
import com.pitchedapps.frost.web.FrostWebComponentBuilder
|
||||
import com.pitchedapps.frost.web.FrostWebEntryPoint
|
||||
import com.pitchedapps.frost.web.FrostWebViewClient
|
||||
import com.pitchedapps.frost.web.FrostWebViewClientMenu
|
||||
import com.pitchedapps.frost.web.FrostWebViewClientMessenger
|
||||
import com.pitchedapps.frost.web.NestedWebView
|
||||
import dagger.hilt.EntryPoints
|
||||
@ -107,7 +106,6 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
frostWebClient =
|
||||
when (parent.baseEnum) {
|
||||
FbItem.MESSENGER -> FrostWebViewClientMessenger(this)
|
||||
FbItem.MENU -> FrostWebViewClientMenu(this)
|
||||
else -> clientEntryPoint.webClient()
|
||||
}
|
||||
webViewClient = frostWebClient
|
||||
|
@ -32,8 +32,8 @@ import com.pitchedapps.frost.utils.isIndependent
|
||||
import com.pitchedapps.frost.utils.launchImageActivity
|
||||
import com.pitchedapps.frost.utils.showWebContextMenu
|
||||
import com.pitchedapps.frost.views.FrostWebView
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
/** Created by Allan Wang on 2017-06-01. */
|
||||
@FrostWebScoped
|
||||
@ -87,7 +87,7 @@ internal constructor(
|
||||
activity.showWebContextMenu(
|
||||
WebContext(url.takeIf { it.isIndependent }, text),
|
||||
fbCookie,
|
||||
prefs
|
||||
prefs,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -136,10 +136,8 @@ internal constructor(
|
||||
|
||||
@JavascriptInterface
|
||||
fun isReady() {
|
||||
if (web.frostWebClient !is FrostWebViewClientMenu) {
|
||||
L.v { "JSI is ready" }
|
||||
refreshEmit(false)
|
||||
}
|
||||
L.v { "JSI is ready" }
|
||||
refreshEmit(false)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@ -168,5 +166,6 @@ internal constructor(
|
||||
this.isScrolling = scrolling
|
||||
}
|
||||
|
||||
@JavascriptInterface fun isScrolling(): Boolean = isScrolling
|
||||
@JavascriptInterface
|
||||
fun isScrolling(): Boolean = isScrolling
|
||||
}
|
||||
|
@ -271,49 +271,6 @@ private const val EMIT_ID = 0b10
|
||||
private const val EMIT_COMPLETE = EMIT_THEME or EMIT_ID
|
||||
private const val EMIT_FINISH = 0
|
||||
|
||||
/** Client variant for the menu view */
|
||||
class FrostWebViewClientMenu(web: FrostWebView) : FrostWebViewClient(web) {
|
||||
|
||||
override fun onPageFinished(view: WebView, url: String?) {
|
||||
super.onPageFinished(view, url)
|
||||
if (url == null) {
|
||||
return
|
||||
}
|
||||
jsInject(JsAssets.MENU, prefs = prefs)
|
||||
}
|
||||
|
||||
/*
|
||||
* We do not inject headers as they include the menu flyout.
|
||||
* Instead, we remove the flyout margins within the js script so that it covers the header.
|
||||
*/
|
||||
override val facebookJsInjectors: List<InjectorContract> =
|
||||
super.facebookJsInjectors - CssHider.HEADER + CssAsset.Menu
|
||||
|
||||
override fun emit(flag: Int) {
|
||||
super.emit(flag)
|
||||
when (flag) {
|
||||
EMIT_FINISH -> {
|
||||
super.injectAndFinish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Facebook doesn't properly load back to the menu even in standard browsers.
|
||||
* Instead, if we detect the base soft url, we will manually click the menu item
|
||||
*/
|
||||
override fun doUpdateVisitedHistory(view: WebView, url: String?, isReload: Boolean) {
|
||||
super.doUpdateVisitedHistory(view, url, isReload)
|
||||
if (url?.startsWith(FbItem.MENU.url) == true) {
|
||||
jsInject(JsAssets.MENU_QUICK, prefs = prefs)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPageFinishedActions(url: String) {
|
||||
// Skip
|
||||
}
|
||||
}
|
||||
|
||||
class FrostWebViewClientMessenger(web: FrostWebView) : FrostWebViewClient(web) {
|
||||
|
||||
override fun onPageFinished(view: WebView, url: String?) {
|
||||
|
@ -1,32 +0,0 @@
|
||||
// Click menu after delay and notify
|
||||
(function () {
|
||||
const viewport = document.querySelector("#viewport");
|
||||
const root = document.querySelector("#root");
|
||||
const bookmarkJewel = document.querySelector("#bookmarks_jewel");
|
||||
if (!viewport || !root || !bookmarkJewel) {
|
||||
console.log('Menu.js: main elements not found');
|
||||
Frost.emit(0);
|
||||
return
|
||||
}
|
||||
const menuA = bookmarkJewel.querySelector("a");
|
||||
if (!menuA) {
|
||||
console.log('Menu.js: menu links not found');
|
||||
Frost.emit(0);
|
||||
return
|
||||
}
|
||||
const jewel = document.querySelector('#mJewelNav');
|
||||
if (!jewel) {
|
||||
console.log('Menu.js: jewel is null');
|
||||
return
|
||||
}
|
||||
|
||||
// Js handling is a bit slow so we need to wait
|
||||
setTimeout(() => {
|
||||
menuA.click();
|
||||
console.log("Menu setup clicked");
|
||||
// Reaction is also slow so we need to wait
|
||||
setTimeout(() => {
|
||||
Frost.emit(0);
|
||||
}, 100);
|
||||
}, 500);
|
||||
}).call(undefined);
|
@ -1,24 +0,0 @@
|
||||
// Copy of menu.ts without timeouts or notifications
|
||||
(function () {
|
||||
const viewport = document.querySelector("#viewport");
|
||||
const root = document.querySelector("#root");
|
||||
const bookmarkJewel = document.querySelector("#bookmarks_jewel");
|
||||
if (!viewport || !root || !bookmarkJewel) {
|
||||
console.log('Menu.js: main elements not found');
|
||||
Frost.emit(0);
|
||||
return
|
||||
}
|
||||
const menuA = bookmarkJewel.querySelector("a");
|
||||
if (!menuA) {
|
||||
console.log('Menu.js: menu links not found');
|
||||
Frost.emit(0);
|
||||
return
|
||||
}
|
||||
const jewel = document.querySelector('#mJewelNav');
|
||||
if (!jewel) {
|
||||
console.log('Menu.js: jewel is null');
|
||||
return
|
||||
}
|
||||
|
||||
menuA.click();
|
||||
}).call(undefined);
|
Loading…
Reference in New Issue
Block a user