aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-29 21:48:27 -0700
committerAllan Wang <me@allanwang.ca>2017-06-29 21:48:27 -0700
commit86f789f8ec0d150098904b85dd6feb7a19725b1c (patch)
tree3cfcbdc78a96572ab5ef723de023b922a221cd54 /app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt
parent601b0492110f17e5f9a1a446897e0b42d4a8cffe (diff)
downloadfrost-86f789f8ec0d150098904b85dd6feb7a19725b1c.tar.gz
frost-86f789f8ec0d150098904b85dd6feb7a19725b1c.tar.bz2
frost-86f789f8ec0d150098904b85dd6feb7a19725b1c.zip
Lots of small incremental fixes
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt55
1 files changed, 55 insertions, 0 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt
new file mode 100644
index 00000000..60b0d2e9
--- /dev/null
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt
@@ -0,0 +1,55 @@
+package com.pitchedapps.frost.settings
+
+import ca.allanwang.kau.kpref.KPrefAdapterBuilder
+import ca.allanwang.kau.utils.string
+import com.pitchedapps.frost.MainActivity
+import com.pitchedapps.frost.R
+import com.pitchedapps.frost.SettingsActivity
+import com.pitchedapps.frost.facebook.FeedSort
+import com.pitchedapps.frost.utils.Prefs
+import com.pitchedapps.frost.utils.materialDialogThemed
+
+/**
+ * Created by Allan Wang on 2017-06-29.
+ */
+fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = {
+
+ text(R.string.newsfeed_sort, { Prefs.feedSort }, { Prefs.feedSort = it }) {
+ descRes = R.string.newsfeed_sort_desc
+ onClick = {
+ _, _, item ->
+ materialDialogThemed {
+ title(R.string.newsfeed_sort)
+ items(FeedSort.values().map { string(it.textRes) })
+ itemsCallbackSingleChoice(item.pref, {
+ _, _, which, text ->
+ if (item.pref != which) {
+ item.pref = which
+ shouldRestartMain()
+ }
+ true
+ })
+ }
+ true
+ }
+ textGetter = { string(FeedSort(it).textRes) }
+ }
+
+ header(R.string.pro_features)
+
+ checkbox(R.string.suggested_friends, { Prefs.showSuggestedFriends }, {
+ Prefs.showSuggestedFriends = it
+ setResult(MainActivity.REQUEST_REFRESH)
+ }) {
+ descRes = R.string.suggested_friends_desc
+ dependsOnPro()
+ }
+
+ checkbox(R.string.facebook_ads, { Prefs.showFacebookAds }, {
+ Prefs.showFacebookAds = it
+ setResult(MainActivity.REQUEST_REFRESH)
+ }) {
+ descRes = R.string.facebook_ads_desc
+ dependsOnPro()
+ }
+} \ No newline at end of file