From 76b26e3d7aad8f6f48cdfb3e196be5143c3c0887 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Mon, 4 Jul 2022 22:13:56 -0500 Subject: Added new “marketplace items” filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt | 4 ++++ app/src/main/kotlin/com/pitchedapps/frost/prefs/OldPrefs.kt | 2 ++ .../kotlin/com/pitchedapps/frost/prefs/sections/FeedPrefs.kt | 7 +++++++ app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt | 10 ++++++++++ app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt | 1 + .../kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt | 1 + app/src/main/res/values-es-rES/strings_pref_feed.xml | 2 ++ app/src/main/res/values/strings_pref_feed.xml | 2 ++ 8 files changed, 29 insertions(+) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt index cc7174d1..b8879a76 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt @@ -37,6 +37,10 @@ enum class CssHider(private vararg val items: String) : InjectorContract { "article[data-store*=adid]", "article[data-ft*=adid]" ), + MARKETPLACE_ITEMS( + "article[data-store*=CommerceAttachment]", + "article[data-ft*=CommerceAttachment]" + ), PEOPLE_YOU_MAY_KNOW("article._d2r"), SUGGESTED_GROUPS("article[data-ft*=\"ei\":]"), SUGGESTED_POSTS( diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/OldPrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/OldPrefs.kt index 14ef3c98..6e62134a 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/OldPrefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/OldPrefs.kt @@ -81,6 +81,8 @@ class OldPrefs @Inject internal constructor(factory: KPrefFactory) : var showFacebookAds: Boolean by kpref("facebook_ads", false) + var showMarketplaceItems: Boolean by kpref("marketplace_items", true) + var showStories: Boolean by kpref("show_stories", true) var animate: Boolean by kpref("fancy_animations", true) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/FeedPrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/FeedPrefs.kt index f60470f0..660dffda 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/FeedPrefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/FeedPrefs.kt @@ -41,6 +41,8 @@ interface FeedPrefs : PrefsBase { var showFacebookAds: Boolean + var showMarketplaceItems: Boolean + var showStories: Boolean var mainActivityLayoutType: Int @@ -94,6 +96,11 @@ class FeedPrefsImpl @Inject internal constructor( oldPrefs.showFacebookAds /* false */ ) + override var showMarketplaceItems: Boolean by kpref( + "marketplace_items", + oldPrefs.showMarketplaceItems /* true */ + ) + override var showStories: Boolean by kpref("show_stories", oldPrefs.showStories /* true */) override var mainActivityLayoutType: Int by kpref( diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt index 5b1007d5..851fa6f8 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt @@ -109,6 +109,16 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = { descRes = R.string.suggested_posts_desc } + checkbox( + R.string.marketplace_items, prefs::showMarketplaceItems, + { + prefs.showMarketplaceItems = it + shouldRefreshMain() + } + ) { + descRes = R.string.marketplace_items_desc + } + checkbox( R.string.show_stories, prefs::showStories, { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt index 10a2cf6f..11460ce4 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt @@ -116,6 +116,7 @@ class DebugWebView @JvmOverloads constructor( if (url.isFacebookUrl) view.jsInject( // CssHider.CORE, + CssHider.MARKETPLACE_ITEMS.maybe(!prefs.showMarketplaceItems), CssHider.COMPOSER.maybe(!prefs.showComposer), CssHider.STORIES.maybe(!prefs.showStories), CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!prefs.showSuggestedFriends), 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 95601236..a2ea000f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -129,6 +129,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { prefs.aggressiveRecents ), CssHider.ADS.maybe(!prefs.showFacebookAds), + CssHider.MARKETPLACE_ITEMS.maybe(!prefs.showMarketplaceItems), CssHider.POST_ACTIONS.maybe(!prefs.showPostActions), CssHider.POST_REACTIONS.maybe(!prefs.showPostReactions), CssAsset.FullSizeImage.maybe(prefs.fullSizeImage), diff --git a/app/src/main/res/values-es-rES/strings_pref_feed.xml b/app/src/main/res/values-es-rES/strings_pref_feed.xml index 487869c4..a81366f0 100644 --- a/app/src/main/res/values-es-rES/strings_pref_feed.xml +++ b/app/src/main/res/values-es-rES/strings_pref_feed.xml @@ -19,4 +19,6 @@ Mostrar historias en el feed Anuncios de Facebook Mostrar anuncios nativos de Facebook + Artículos de Marketplace + Mostrar artículos en venta en Marketplace diff --git a/app/src/main/res/values/strings_pref_feed.xml b/app/src/main/res/values/strings_pref_feed.xml index bdaca2ac..00688e61 100644 --- a/app/src/main/res/values/strings_pref_feed.xml +++ b/app/src/main/res/values/strings_pref_feed.xml @@ -24,6 +24,8 @@ Show reaction counts to post Facebook Ads Show native Facebook ads + Marketplace Items + Show articles on sale in Marketplace Full Size Images Force news feed images to be full width -- cgit v1.2.3