From dc4910e1e9b26eb71bb7a663cb2994b277be40ac Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Mon, 4 Mar 2019 15:55:47 -0500 Subject: Allow hiding stories (#1361) --- app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt | 3 ++- app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt | 7 +++++++ app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt | 2 ++ app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt | 1 + .../main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt | 1 + app/src/main/res/values/strings_pref_feed.xml | 2 ++ 6 files changed, 15 insertions(+), 1 deletion(-) 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 4fd46ae4..292b7ff5 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt @@ -37,7 +37,8 @@ enum class CssHider(vararg val items: String) : InjectorContract { SUGGESTED_GROUPS("article[data-ft*=\"ei\":]"), COMPOSER("#MComposer"), MESSENGER("._s15", "[data-testid=info_panel]", "js_i"), - NON_RECENT("article:not([data-store*=actor_name])") + NON_RECENT("article:not([data-store*=actor_name])"), + STORIES("#MStoriesTray") ; val injector: JsInjector by lazy { 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 ff0badf0..baf68634 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt @@ -76,6 +76,13 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = { descRes = R.string.suggested_groups_desc } + checkbox(R.string.show_stories, Prefs::showStories, { + Prefs.showStories = it + setFrostResult(REQUEST_REFRESH) + }) { + descRes = R.string.show_stories_desc + } + checkbox(R.string.facebook_ads, Prefs::showFacebookAds, { Prefs.showFacebookAds = it setFrostResult(REQUEST_REFRESH) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt index add9c6cd..9a63f527 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt @@ -126,6 +126,8 @@ object Prefs : KPref() { var showFacebookAds: Boolean by kpref("facebook_ads", false) + var showStories: Boolean by kpref("show_stories", true) + var animate: Boolean by kpref("fancy_animations", true) var notificationKeywords: Set by kpref("notification_keywords", mutableSetOf()) 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 d2b53ab5..6b186b1c 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt @@ -105,6 +105,7 @@ class DebugWebView @JvmOverloads constructor( CssAssets.ROUND_ICONS.maybe(Prefs.showRoundedIcons), // CssHider.CORE, 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, 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 2e8408ea..e162f9da 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -95,6 +95,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { // 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, diff --git a/app/src/main/res/values/strings_pref_feed.xml b/app/src/main/res/values/strings_pref_feed.xml index bacd6b32..d7a15bda 100644 --- a/app/src/main/res/values/strings_pref_feed.xml +++ b/app/src/main/res/values/strings_pref_feed.xml @@ -12,6 +12,8 @@ Show "People You May Know" in the feed Suggested Groups Show "Suggested Groups" in the feed + Show Stories + Show stories in the feed Facebook Ads Show native Facebook ads -- cgit v1.2.3