aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt11
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt58
-rw-r--r--app/src/main/res/xml/frost_changelog.xml7
-rw-r--r--app/src/web/ts/context_a.ts8
-rw-r--r--app/src/web/ts/scroll_stop.ts25
-rw-r--r--app/src/web/typings/frost.d.ts4
7 files changed, 90 insertions, 25 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt
index b629fb91..55eb198e 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt
@@ -35,7 +35,7 @@ import kotlinx.coroutines.withContext
*/
enum class JsAssets(private val singleLoad: Boolean = true) : InjectorContract {
MENU, CLICK_A, CONTEXT_A, MEDIA, HEADER_BADGES, TEXTAREA_LISTENER, NOTIF_MSG,
- DOCUMENT_WATCHER, HORIZONTAL_SCROLLING, AUTO_RESIZE_TEXTAREA(singleLoad = false)
+ DOCUMENT_WATCHER, HORIZONTAL_SCROLLING, AUTO_RESIZE_TEXTAREA(singleLoad = false), SCROLL_STOP,
;
@VisibleForTesting
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
index e17ef99e..40a048af 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
@@ -161,4 +161,15 @@ class FrostJSI(val web: FrostWebView) {
activity?.contentBinding?.viewpager?.enableSwipe = enable
(context as? WebOverlayActivityBase)?.swipeBack?.disallowIntercept = !enable
}
+
+ private var isScrolling = false
+
+ @JavascriptInterface
+ fun setScrolling(scrolling: Boolean) {
+ L.v { "Scrolling $scrolling" }
+ this.isScrolling = scrolling
+ }
+
+ @JavascriptInterface
+ fun isScrolling(): Boolean = isScrolling
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
index dd1d45cb..324af69b 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
@@ -99,6 +99,37 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
protected inline fun v(crossinline message: () -> Any?) = L.v { "web client: ${message()}" }
+ /**
+ * Main injections for facebook content
+ */
+ private fun WebView.facebookJsInject() {
+ jsInject(
+// CssHider.CORE,
+ CssHider.HEADER,
+ CssHider.COMPOSER.maybe(!prefs.showComposer),
+ CssHider.STORIES.maybe(!prefs.showStories),
+ CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!prefs.showSuggestedFriends),
+ CssHider.SUGGESTED_GROUPS.maybe(!prefs.showSuggestedGroups),
+ prefs.themeInjector,
+ CssHider.NON_RECENT.maybe(
+ (web.url?.contains("?sk=h_chr") ?: false) &&
+ prefs.aggressiveRecents
+ ),
+ CssHider.ADS.maybe(!prefs.showFacebookAds),
+ CssHider.POST_ACTIONS.maybe(!prefs.showPostActions),
+ CssHider.POST_REACTIONS.maybe(!prefs.showPostReactions),
+ CssSmallAssets.FullSizeImage.maybe(prefs.fullSizeImage),
+ JsAssets.DOCUMENT_WATCHER,
+ JsAssets.HORIZONTAL_SCROLLING,
+ JsAssets.AUTO_RESIZE_TEXTAREA.maybe(prefs.autoExpandTextBox),
+ JsAssets.CLICK_A,
+ JsAssets.CONTEXT_A,
+ JsAssets.MEDIA,
+ JsAssets.SCROLL_STOP,
+ prefs = prefs
+ )
+ }
+
override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
if (url == null) return
@@ -120,30 +151,8 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
super.onPageCommitVisible(view, url)
injectBackgroundColor()
if (url.isFacebookUrl) {
- view.jsInject(
-// CssHider.CORE,
- CssHider.HEADER,
- CssHider.COMPOSER.maybe(!prefs.showComposer),
- CssHider.STORIES.maybe(!prefs.showStories),
- CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!prefs.showSuggestedFriends),
- CssHider.SUGGESTED_GROUPS.maybe(!prefs.showSuggestedGroups),
- prefs.themeInjector,
- CssHider.NON_RECENT.maybe(
- (web.url?.contains("?sk=h_chr") ?: false) &&
- prefs.aggressiveRecents
- ),
- CssHider.ADS.maybe(!prefs.showFacebookAds),
- CssHider.POST_ACTIONS.maybe(!prefs.showPostActions),
- CssHider.POST_REACTIONS.maybe(!prefs.showPostReactions),
- CssSmallAssets.FullSizeImage.maybe(prefs.fullSizeImage),
- JsAssets.DOCUMENT_WATCHER,
- JsAssets.HORIZONTAL_SCROLLING,
- JsAssets.AUTO_RESIZE_TEXTAREA,
- JsAssets.CLICK_A,
- JsAssets.CONTEXT_A,
- JsAssets.MEDIA,
- prefs = prefs
- )
+ v { "Page commit visible" }
+ view.facebookJsInject()
} else {
refresh.offer(false)
}
@@ -176,6 +185,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
JsAssets.HEADER_BADGES.maybe(isMain),
prefs = prefs
)
+ web.facebookJsInject()
}
open fun handleHtml(html: String?) {
diff --git a/app/src/main/res/xml/frost_changelog.xml b/app/src/main/res/xml/frost_changelog.xml
index 654f4a72..6a526ccb 100644
--- a/app/src/main/res/xml/frost_changelog.xml
+++ b/app/src/main/res/xml/frost_changelog.xml
@@ -6,6 +6,13 @@
<item text="" />
-->
+ <version title="v2.4.7" />
+ <item text="Fix theme not always sticking on refresh" />
+ <item text="Disable long press menu from appearing immediately after scrolling" />
+ <item text="" />
+ <item text="" />
+ <item text="" />
+
<version title="v2.4.6" />
<item text="Add option to hide likes and action bar in newsfeed" />
<item text="Fix textbox scroll position when typing multiple lines" />
diff --git a/app/src/web/ts/context_a.ts b/app/src/web/ts/context_a.ts
index 9faa1e94..ad81279e 100644
--- a/app/src/web/ts/context_a.ts
+++ b/app/src/web/ts/context_a.ts
@@ -110,6 +110,14 @@
Frost.longClick(true);
longClick = true;
+ /**
+ * Don't handle context events while scrolling
+ */
+ if (Frost.isScrolling()) {
+ console.log("Skip from scrolling");
+ return;
+ }
+
/*
* Commonality; check for valid target
*/
diff --git a/app/src/web/ts/scroll_stop.ts b/app/src/web/ts/scroll_stop.ts
new file mode 100644
index 00000000..1ec6d30b
--- /dev/null
+++ b/app/src/web/ts/scroll_stop.ts
@@ -0,0 +1,25 @@
+// Listen when scrolling events stop
+(function () {
+ let scrollTimeout: number | undefined = undefined;
+ let scrolling: boolean = false;
+
+ window.addEventListener('scroll', function (event) {
+
+ if (!scrolling) {
+ Frost.setScrolling(true);
+ scrolling = true;
+ }
+
+ window.clearTimeout(scrollTimeout);
+
+ scrollTimeout = setTimeout(function () {
+ if (scrolling) {
+ Frost.setScrolling(false);
+ scrolling = false;
+ }
+ }, 600);
+ // For our specific use case, we want to release other features pretty far after scrolling stops
+ // For general scrolling use cases, the delta can be much smaller
+ // My assumption for context menus is that the long press is 500ms
+ }, false);
+}).call(undefined); \ No newline at end of file
diff --git a/app/src/web/typings/frost.d.ts b/app/src/web/typings/frost.d.ts
index ae7c97ab..9f77ce9e 100644
--- a/app/src/web/typings/frost.d.ts
+++ b/app/src/web/typings/frost.d.ts
@@ -24,6 +24,10 @@ declare interface FrostJSI {
handleHeader(html: string | null)
allowHorizontalScrolling(enable: boolean)
+
+ setScrolling(scrolling: boolean)
+
+ isScrolling(): boolean
}
declare var Frost: FrostJSI;