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 20dd4127d..cc2c95794 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt @@ -36,6 +36,8 @@ enum class CssHider(private vararg val items: String) : InjectorContract { ADS("article[data-xt*=sponsor]", "article[data-store*=sponsor]"), PEOPLE_YOU_MAY_KNOW("article._d2r"), SUGGESTED_GROUPS("article[data-ft*=\"ei\":]"), + // Is it really this simple? + SUGGESTED_POSTS("article[data-ft*=recommendation]"), COMPOSER("#MComposer"), MESSENGER("._s15", "[data-testid=info_panel]", "js_i"), NON_RECENT("article:not([data-store*=actor_name])"), 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 5d2c8195a..6c4540415 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 @@ -37,6 +37,8 @@ interface FeedPrefs : PrefsBase { var showSuggestedGroups: Boolean + var showSuggestedPosts: Boolean + var showFacebookAds: Boolean var showStories: Boolean @@ -58,24 +60,44 @@ class FeedPrefsImpl @Inject internal constructor(factory: KPrefFactory, oldPrefs override var feedSort: Int by kpref("feed_sort", oldPrefs.feedSort /* FeedSort.DEFAULT.ordinal */) override var aggressiveRecents: Boolean by - kpref("aggressive_recents", oldPrefs.aggressiveRecents /* false */) + kpref( + "aggressive_recents", + oldPrefs.aggressiveRecents, /* false */ + ) override var showComposer: Boolean by - kpref("status_composer_feed", oldPrefs.showComposer /* true */) + kpref( + "status_composer_feed", + oldPrefs.showComposer, /* true */ + ) override var showSuggestedFriends: Boolean by - kpref("suggested_friends_feed", oldPrefs.showSuggestedFriends /* true */) + kpref( + "suggested_friends_feed", + oldPrefs.showSuggestedFriends, /* true */ + ) override var showSuggestedGroups: Boolean by - kpref("suggested_groups_feed", oldPrefs.showSuggestedGroups /* true */) + kpref( + "suggested_groups_feed", + oldPrefs.showSuggestedGroups, /* true */ + ) + + override var showSuggestedPosts: Boolean by kpref("suggested_posts_feed", true) override var showFacebookAds: Boolean by - kpref("facebook_ads", oldPrefs.showFacebookAds /* false */) + kpref( + "facebook_ads", + oldPrefs.showFacebookAds, /* false */ + ) override var showStories: Boolean by kpref("show_stories", oldPrefs.showStories /* true */) override var mainActivityLayoutType: Int by - kpref("main_activity_layout_type", oldPrefs.mainActivityLayoutType /* 0 */) + kpref( + "main_activity_layout_type", + oldPrefs.mainActivityLayoutType, /* 0 */ + ) override val mainActivityLayout: MainActivityLayout get() = MainActivityLayout(mainActivityLayoutType) 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 cf8dfcdce..1af1ff66d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt @@ -34,7 +34,7 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = { title(R.string.newsfeed_sort) listItemsSingleChoice( items = FeedSort.values().map { string(it.textRes) }, - initialSelection = item.pref + initialSelection = item.pref, ) { _, index, _ -> if (item.pref != index) { item.pref = index @@ -52,7 +52,7 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = { { prefs.aggressiveRecents = it shouldRefreshMain() - } + }, ) { descRes = R.string.aggressive_recents_desc } @@ -63,7 +63,7 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = { { prefs.showComposer = it shouldRefreshMain() - } + }, ) { descRes = R.string.composer_desc } @@ -74,7 +74,7 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = { { prefs.showCreateFab = it setFrostResult(REQUEST_FAB) - } + }, ) { descRes = R.string.create_fab_desc } @@ -85,7 +85,7 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = { { prefs.showSuggestedFriends = it shouldRefreshMain() - } + }, ) { descRes = R.string.suggested_friends_desc } @@ -96,18 +96,29 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = { { prefs.showSuggestedGroups = it shouldRefreshMain() - } + }, ) { descRes = R.string.suggested_groups_desc } + checkbox( + R.string.suggested_posts, + prefs::showSuggestedPosts, + { + prefs.showSuggestedPosts = it + shouldRefreshMain() + }, + ) { + descRes = R.string.suggested_posts_desc + } + checkbox( R.string.show_stories, prefs::showStories, { prefs.showStories = it shouldRefreshMain() - } + }, ) { descRes = R.string.show_stories_desc } @@ -118,7 +129,7 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = { { prefs.showPostActions = it shouldRefreshMain() - } + }, ) { descRes = R.string.show_post_actions_desc } @@ -129,7 +140,7 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = { { prefs.showPostReactions = it shouldRefreshMain() - } + }, ) { descRes = R.string.show_post_reactions_desc } @@ -140,7 +151,7 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = { { prefs.fullSizeImage = it shouldRefreshMain() - } + }, ) { descRes = R.string.full_size_image_desc } 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 adb6ac2df..ad8222dc5 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt @@ -113,6 +113,7 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 CssHider.STORIES.maybe(!prefs.showStories), CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!prefs.showSuggestedFriends), CssHider.SUGGESTED_GROUPS.maybe(!prefs.showSuggestedGroups), + CssHider.SUGGESTED_POSTS.maybe(!prefs.showSuggestedPosts), themeProvider.injector(ThemeCategory.FACEBOOK), CssHider.NON_RECENT.maybe( (url?.contains("?sk=h_chr") ?: false) && prefs.aggressiveRecents 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 332bae128..407bbe11f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -113,6 +113,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { CssHider.STORIES.maybe(!prefs.showStories), CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!prefs.showSuggestedFriends), CssHider.SUGGESTED_GROUPS.maybe(!prefs.showSuggestedGroups), + CssHider.SUGGESTED_POSTS.maybe(!prefs.showSuggestedPosts), themeProvider.injector(ThemeCategory.FACEBOOK), CssHider.NON_RECENT.maybe( (web.url?.contains("?sk=h_chr") ?: false) && prefs.aggressiveRecents diff --git a/app/src/main/res/values/strings_pref_feed.xml b/app/src/main/res/values/strings_pref_feed.xml index 58d832cc8..1b40f60b2 100644 --- a/app/src/main/res/values/strings_pref_feed.xml +++ b/app/src/main/res/values/strings_pref_feed.xml @@ -14,6 +14,8 @@ Show \"People You May Know\" in the feed Suggested Groups Show \"Suggested Groups\" in the feed + Suggested Posts + Show \"Suggested for you\" in the feed Show Stories Show stories in the feed Show Post Actions