aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
blob: b5770739ca2bbde84b4ecb2defc299033b581504 (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
package com.pitchedapps.frost

import android.os.Bundle
import ca.allanwang.kau.kpref.KPrefActivity
import ca.allanwang.kau.kpref.KPrefAdapterBuilder
import ca.allanwang.kau.utils.darken
import ca.allanwang.kau.utils.navigationBarColor
import ca.allanwang.kau.views.RippleCanvas
import com.mikepenz.google_material_typeface_library.GoogleMaterial
import com.pitchedapps.frost.utils.Prefs

/**
 * Created by Allan Wang on 2017-06-06.
 */
class SettingsActivity : KPrefActivity() {
    override fun onCreateKPrefs(savedInstanceState: android.os.Bundle?): KPrefAdapterBuilder.() -> Unit = {
        textColor = { Prefs.textColor }
        accentColor = { Prefs.textColor }
        header(R.string.settings)
        colorPicker(title = R.string.text_color,
                getter = { Prefs.textColor }, setter = { Prefs.textColor = it; reload() },
                configs = {
                    allowCustom = true
                })
        colorPicker(iicon = GoogleMaterial.Icon.gmd_colorize,
                title = R.string.background_color,
                getter = { Prefs.bgColor }, setter = { Prefs.bgColor = it; bgCanvas.ripple(it, duration = 500L) },
                configs = {
                    allowCustomAlpha = false
                    allowCustom = true
                })
        colorPicker(title = R.string.header_color,
                getter = { Prefs.headerColor }, setter = {
            Prefs.headerColor = it
            val darkerColor = it.darken()
            this@SettingsActivity.navigationBarColor = darkerColor
            toolbarCanvas.ripple(darkerColor, RippleCanvas.MIDDLE, RippleCanvas.END, duration = 500L)
        },
                configs = {
                    allowCustom = false
                })
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        bgCanvas.set(Prefs.bgColor)
        val darkAccent = Prefs.headerColor.darken()
        toolbarCanvas.set(darkAccent)
        this.navigationBarColor = darkAccent
    }
}