mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-11-10 04:52:38 +01:00
Feature/recents (#290)
* Create toggle for aggressive recents * Add toggle
This commit is contained in:
parent
33ca5b2762
commit
4394690250
@ -2,14 +2,15 @@ package com.pitchedapps.frost.enums
|
|||||||
|
|
||||||
import android.support.annotation.StringRes
|
import android.support.annotation.StringRes
|
||||||
import com.pitchedapps.frost.R
|
import com.pitchedapps.frost.R
|
||||||
|
import com.pitchedapps.frost.facebook.FbItem
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Allan Wang on 2017-06-23.
|
* Created by Allan Wang on 2017-06-23.
|
||||||
*/
|
*/
|
||||||
enum class FeedSort(@StringRes val textRes: Int) {
|
enum class FeedSort(@StringRes val textRes: Int, val item: FbItem) {
|
||||||
DEFAULT(R.string.kau_default),
|
DEFAULT(R.string.kau_default, FbItem.FEED),
|
||||||
MOST_RECENT(R.string.most_recent),
|
MOST_RECENT(R.string.most_recent, FbItem.FEED_MOST_RECENT),
|
||||||
TOP(R.string.top_stories);
|
TOP(R.string.top_stories, FbItem.FEED_TOP_STORIES);
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val values = values() //save one instance
|
val values = values() //save one instance
|
||||||
|
@ -31,15 +31,7 @@ class WebFragment : Fragment() {
|
|||||||
const val REQUEST_REFRESH = 99
|
const val REQUEST_REFRESH = 99
|
||||||
|
|
||||||
operator fun invoke(data: FbItem, position: Int) = WebFragment().apply {
|
operator fun invoke(data: FbItem, position: Int) = WebFragment().apply {
|
||||||
val d = when (data) {
|
val d = if (data == FbItem.FEED) FeedSort(Prefs.feedSort).item else 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
|
|
||||||
}
|
|
||||||
withArguments(
|
withArguments(
|
||||||
ARG_URL to d.url,
|
ARG_URL to d.url,
|
||||||
ARG_POSITION to position,
|
ARG_POSITION to position,
|
||||||
|
@ -34,6 +34,13 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = {
|
|||||||
textGetter = { string(FeedSort(it).textRes) }
|
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) {
|
plainText(R.string.autoplay_settings) {
|
||||||
descRes = R.string.autoplay_settings_desc
|
descRes = R.string.autoplay_settings_desc
|
||||||
onClick = { _, _, _ -> launchWebOverlay("https://touch.facebook.com/settings/videos"); true }
|
onClick = { _, _, _ -> launchWebOverlay("https://touch.facebook.com/settings/videos"); true }
|
||||||
|
@ -86,6 +86,8 @@ object Prefs : KPref() {
|
|||||||
|
|
||||||
var feedSort: Int by kpref("feed_sort", FeedSort.DEFAULT.ordinal)
|
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 showRoundedIcons: Boolean by kpref("rounded_icons", true)
|
||||||
|
|
||||||
var showSuggestedFriends: Boolean by kpref("suggested_friends_feed", true)
|
var showSuggestedFriends: Boolean by kpref("suggested_friends_feed", true)
|
||||||
|
@ -11,8 +11,8 @@ import com.pitchedapps.frost.activities.LoginActivity
|
|||||||
import com.pitchedapps.frost.activities.MainActivity
|
import com.pitchedapps.frost.activities.MainActivity
|
||||||
import com.pitchedapps.frost.activities.SelectorActivity
|
import com.pitchedapps.frost.activities.SelectorActivity
|
||||||
import com.pitchedapps.frost.activities.WebOverlayActivity
|
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.FB_URL_BASE
|
||||||
import com.pitchedapps.frost.facebook.FbCookie
|
|
||||||
import com.pitchedapps.frost.facebook.FbItem
|
import com.pitchedapps.frost.facebook.FbItem
|
||||||
import com.pitchedapps.frost.injectors.*
|
import com.pitchedapps.frost.injectors.*
|
||||||
import com.pitchedapps.frost.utils.*
|
import com.pitchedapps.frost.utils.*
|
||||||
@ -74,7 +74,8 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : BaseWebViewClient
|
|||||||
CssHider.CORE,
|
CssHider.CORE,
|
||||||
CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!Prefs.showSuggestedFriends && IS_FROST_PRO),
|
CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!Prefs.showSuggestedFriends && IS_FROST_PRO),
|
||||||
Prefs.themeInjector,
|
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?) {
|
override fun onPageFinished(view: WebView, url: String?) {
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
<string name="newsfeed_sort">Newsfeed Order</string>
|
<string name="newsfeed_sort">Newsfeed Order</string>
|
||||||
<string name="newsfeed_sort_desc">Defines the order in which the posts are shown</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">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="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>
|
<string name="pro_features">Pro Features</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user