aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-09-16 01:34:45 -0400
committerGitHub <noreply@github.com>2017-09-16 01:34:45 -0400
commit43946902504c1aa5c1217e3fe802697566db4c03 (patch)
treea10c09b74f42ef69b1c5a72f947040dd0b3d03a2
parent33ca5b2762e0dca515a54a715845ce816215de7a (diff)
downloadfrost-43946902504c1aa5c1217e3fe802697566db4c03.tar.gz
frost-43946902504c1aa5c1217e3fe802697566db4c03.tar.bz2
frost-43946902504c1aa5c1217e3fe802697566db4c03.zip
Feature/recents (#290)
* Create toggle for aggressive recents * Add toggle
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/enums/FeedSort.kt9
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragment.kt10
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt5
-rw-r--r--app/src/main/res/values/strings_pref_feed.xml2
6 files changed, 20 insertions, 15 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/enums/FeedSort.kt b/app/src/main/kotlin/com/pitchedapps/frost/enums/FeedSort.kt
index 65b3c101..d2de9988 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/enums/FeedSort.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/enums/FeedSort.kt
@@ -2,14 +2,15 @@ package com.pitchedapps.frost.enums
import android.support.annotation.StringRes
import com.pitchedapps.frost.R
+import com.pitchedapps.frost.facebook.FbItem
/**
* Created by Allan Wang on 2017-06-23.
*/
-enum class FeedSort(@StringRes val textRes: Int) {
- DEFAULT(R.string.kau_default),
- MOST_RECENT(R.string.most_recent),
- TOP(R.string.top_stories);
+enum class FeedSort(@StringRes val textRes: Int, val item: FbItem) {
+ DEFAULT(R.string.kau_default, FbItem.FEED),
+ MOST_RECENT(R.string.most_recent, FbItem.FEED_MOST_RECENT),
+ TOP(R.string.top_stories, FbItem.FEED_TOP_STORIES);
companion object {
val values = values() //save one instance
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragment.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragment.kt
index f0bf2efa..4286be86 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragment.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragment.kt
@@ -31,15 +31,7 @@ class WebFragment : Fragment() {
const val REQUEST_REFRESH = 99
operator fun invoke(data: FbItem, position: Int) = WebFragment().apply {
- val d = when (data) {
- //If is feed, check if sorting method is specified
- FbItem.FEED -> when (FeedSort(Prefs.feedSort)) {
- FeedSort.DEFAULT -> data
- FeedSort.MOST_RECENT -> FbItem.FEED_MOST_RECENT
- FeedSort.TOP -> FbItem.FEED_TOP_STORIES
- }
- else -> data
- }
+ val d = if (data == FbItem.FEED) FeedSort(Prefs.feedSort).item else data
withArguments(
ARG_URL to d.url,
ARG_POSITION to position,
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 cfc2bb6f..3676d39c 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt
@@ -34,6 +34,13 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = {
textGetter = { string(FeedSort(it).textRes) }
}
+ checkbox(R.string.aggressive_recents, { Prefs.aggressiveRecents }, {
+ Prefs.aggressiveRecents = it
+ setFrostResult(MainActivity.REQUEST_REFRESH)
+ }) {
+ descRes = R.string.aggressive_recents_desc
+ }
+
plainText(R.string.autoplay_settings) {
descRes = R.string.autoplay_settings_desc
onClick = { _, _, _ -> launchWebOverlay("https://touch.facebook.com/settings/videos"); true }
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 af605388..18ab874a 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
@@ -86,6 +86,8 @@ object Prefs : KPref() {
var feedSort: Int by kpref("feed_sort", FeedSort.DEFAULT.ordinal)
+ var aggressiveRecents: Boolean by kpref("aggressive_recents", true)
+
var showRoundedIcons: Boolean by kpref("rounded_icons", true)
var showSuggestedFriends: Boolean by kpref("suggested_friends_feed", true)
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 a961972f..253b4a9b 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
@@ -11,8 +11,8 @@ import com.pitchedapps.frost.activities.LoginActivity
import com.pitchedapps.frost.activities.MainActivity
import com.pitchedapps.frost.activities.SelectorActivity
import com.pitchedapps.frost.activities.WebOverlayActivity
+import com.pitchedapps.frost.enums.FeedSort
import com.pitchedapps.frost.facebook.FB_URL_BASE
-import com.pitchedapps.frost.facebook.FbCookie
import com.pitchedapps.frost.facebook.FbItem
import com.pitchedapps.frost.injectors.*
import com.pitchedapps.frost.utils.*
@@ -74,7 +74,8 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : BaseWebViewClient
CssHider.CORE,
CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!Prefs.showSuggestedFriends && IS_FROST_PRO),
Prefs.themeInjector,
- CssHider.NON_RECENT.maybe(webCore.url?.contains("?sk=h_chr") ?: false))
+ CssHider.NON_RECENT.maybe((webCore.url?.contains("?sk=h_chr") ?: false)
+ && Prefs.aggressiveRecents))
}
override fun onPageFinished(view: WebView, url: String?) {
diff --git a/app/src/main/res/values/strings_pref_feed.xml b/app/src/main/res/values/strings_pref_feed.xml
index 0bd0792b..42aefbbc 100644
--- a/app/src/main/res/values/strings_pref_feed.xml
+++ b/app/src/main/res/values/strings_pref_feed.xml
@@ -3,6 +3,8 @@
<string name="newsfeed_sort">Newsfeed Order</string>
<string name="newsfeed_sort_desc">Defines the order in which the posts are shown</string>
+ <string name="aggressive_recents">Aggressive Recents</string>
+ <string name="aggressive_recents_desc">Filter out additional old posts from Facebook\'s original most recents feed. Disable this if your feed is empty.</string>
<string name="autoplay_settings">Video Autoplay Settings</string>
<string name="autoplay_settings_desc">Enable/disable video autoplays on data or at all times.\nThese settings are independent of your settings for desktop.</string>
<string name="pro_features">Pro Features</string>