aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt
blob: 78898eeb1c6d7fa6e6cf8d3d01d6d88c77228b12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package com.pitchedapps.frost.settings

import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder
import ca.allanwang.kau.utils.string
import com.pitchedapps.frost.R
import com.pitchedapps.frost.activities.SettingsActivity
import com.pitchedapps.frost.enums.FeedSort
import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.REQUEST_REFRESH
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 = {
            materialDialogThemed {
                title(R.string.newsfeed_sort)
                items(FeedSort.values().map { string(it.textRes) })
                itemsCallbackSingleChoice(item.pref, { _, _, which, _ ->
                    if (item.pref != which) {
                        item.pref = which
                        shouldRestartMain()
                    }
                    true
                })
            }
        }
        textGetter = { string(FeedSort(it).textRes) }
    }

    checkbox(R.string.aggressive_recents, Prefs::aggressiveRecents, {
        Prefs.aggressiveRecents = it
        setFrostResult(REQUEST_REFRESH)
    }) {
        descRes = R.string.aggressive_recents_desc
    }

    checkbox(R.string.composer, Prefs::showComposer, {
        Prefs.showComposer = it
        setFrostResult(REQUEST_REFRESH)
    }) {
        descRes = R.string.composer_desc
    }

    header(R.string.pro_features)

    checkbox(R.string.suggested_friends, Prefs::showSuggestedFriends, {
        Prefs.showSuggestedFriends = it
        setFrostResult(REQUEST_REFRESH)
    }) {
        descRes = R.string.suggested_friends_desc
        dependsOnPro()
    }

    checkbox(R.string.suggested_groups, Prefs::showSuggestedGroups, {
        Prefs.showSuggestedGroups = it
        setFrostResult(REQUEST_REFRESH)
    }) {
        descRes = R.string.suggested_groups_desc
        dependsOnPro()
    }

    checkbox(R.string.facebook_ads, Prefs::showFacebookAds, {
        Prefs.showFacebookAds = it
        setFrostResult(REQUEST_REFRESH)
    }) {
        descRes = R.string.facebook_ads_desc
        dependsOnPro()
    }
}