File tree Expand file tree Collapse file tree 4 files changed +30
-0
lines changed
java/nl/gardensnakes/ukrainefield/helper Expand file tree Collapse file tree 4 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -14,10 +14,22 @@ class NewsFeedHelper {
1414 if (! PreferenceHelper .shouldShowUkrainianSources(context)){
1515 filteredMessages = removeMessagesWithCategory(filteredMessages, " ukraine" )
1616 }
17+ if (! PreferenceHelper .shouldShowTwitterSources(context)){
18+ filteredMessages = removeMessagesByType(filteredMessages, " twitter" )
19+ }
20+ if (! PreferenceHelper .shouldShowTelegramSources(context)){
21+ filteredMessages = removeMessagesByType(filteredMessages, " telegram" )
22+ }
1723 return filteredMessages
1824 }
25+
1926 private fun removeMessagesWithCategory (messages : List <FeedMessageResponse >, category : String ): List <FeedMessageResponse > {
2027 return messages.filter { message -> message.categories.indexOf(category) == - 1 }
2128 }
29+
30+ private fun removeMessagesByType (messages : List <FeedMessageResponse >, type : String ): List <FeedMessageResponse > {
31+ return messages.filter { message -> message.type != type }
32+ }
33+
2234 }
2335}
Original file line number Diff line number Diff line change @@ -17,5 +17,13 @@ class PreferenceHelper {
1717 val sharedPreferences = PreferenceManager .getDefaultSharedPreferences(context)
1818 return sharedPreferences.getBoolean(" ukraineNewsSources" , true )
1919 }
20+ fun shouldShowTwitterSources (context : Context ): Boolean {
21+ val sharedPreferences = PreferenceManager .getDefaultSharedPreferences(context)
22+ return sharedPreferences.getBoolean(" twitterSources" , true )
23+ }
24+ fun shouldShowTelegramSources (context : Context ): Boolean {
25+ val sharedPreferences = PreferenceManager .getDefaultSharedPreferences(context)
26+ return sharedPreferences.getBoolean(" telegramSources" , true )
27+ }
2028 }
2129}
Original file line number Diff line number Diff line change 3131 <string name =" show_russian_sources" >Show Russian news sources</string >
3232 <string name =" show_ukraine_sources" >Show Ukrainian news sources</string >
3333 <string name =" no_news_found" >No news found, try changing your filters on the Settings page</string >
34+ <string name =" show_telegram_sources" >Show Telegram sources</string >
35+ <string name =" show_twitter_sources" >Show Twitter sources</string >
3436</resources >
Original file line number Diff line number Diff line change 2626 app : key =" ukraineNewsSources"
2727 app : title =" @string/show_ukraine_sources"
2828 app : defaultValue =" true" />
29+ <SwitchPreferenceCompat
30+ app : key =" twitterSources"
31+ app : title =" @string/show_twitter_sources"
32+ app : defaultValue =" true" />
33+ <SwitchPreferenceCompat
34+ app : key =" telegramSources"
35+ app : title =" @string/show_telegram_sources"
36+ app : defaultValue =" true" />
2937 </PreferenceCategory >
3038
3139
You can’t perform that action at this time.
0 commit comments