1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-09-19 23:21:34 +02:00

Add option to hide suggested posts

This commit is contained in:
Allan Wang 2022-09-15 16:32:47 -07:00
parent b01ad915c6
commit ff2f1b8412
No known key found for this signature in database
GPG Key ID: C93E3F9C679D7A56
6 changed files with 55 additions and 16 deletions

View File

@ -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])"),

View File

@ -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)

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -14,6 +14,8 @@
<string name="suggested_friends_desc">Show \"People You May Know\" in the feed</string>
<string name="suggested_groups">Suggested Groups</string>
<string name="suggested_groups_desc">Show \"Suggested Groups\" in the feed</string>
<string name="suggested_posts">Suggested Posts</string>
<string name="suggested_posts_desc">Show \"Suggested for you\" in the feed</string>
<string name="show_stories">Show Stories</string>
<string name="show_stories_desc">Show stories in the feed</string>
<string name="show_post_actions">Show Post Actions</string>