diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps')
5 files changed, 18 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?) { |