diff options
author | Allan Wang <me@allanwang.ca> | 2017-06-22 19:50:44 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-06-22 19:50:44 -0700 |
commit | da5967f87b8a0e9863fb6b82fc5807bae9e62a00 (patch) | |
tree | 8575d63efacb79ae10a50c471bf3c8055ea1dbf9 /app/src/main/kotlin/com/pitchedapps/frost/utils | |
parent | 42d441c0e2b436c7b95fe8dc02ef36608395dbff (diff) | |
download | frost-da5967f87b8a0e9863fb6b82fc5807bae9e62a00.tar.gz frost-da5967f87b8a0e9863fb6b82fc5807bae9e62a00.tar.bz2 frost-da5967f87b8a0e9863fb6b82fc5807bae9e62a00.zip |
Fix up colors and add overlay tip
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils')
3 files changed, 34 insertions, 11 deletions
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 9128c42b..a75a4f8d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt @@ -4,6 +4,7 @@ import android.graphics.Color import ca.allanwang.kau.kpref.KPref import ca.allanwang.kau.kpref.StringSet import ca.allanwang.kau.kpref.kpref +import ca.allanwang.kau.utils.isColorVisibleOn import ca.allanwang.kau.utils.lazyResettable import com.pitchedapps.frost.injectors.InjectorContract @@ -56,6 +57,9 @@ object Prefs : KPref() { val iconColor: Int get() = t.iconColor + val accentColor: Int + get() = if (headerColor.isColorVisibleOn(bgColor, 100)) headerColor else textColor + val themeInjector: InjectorContract get() = t.injector @@ -71,4 +75,7 @@ object Prefs : KPref() { var animate: Boolean by kpref("fancy_animations", true) var notificationKeywords: StringSet by kpref("notification_keywords", mutableSetOf<String>()) + + //check if this is the first time launching the web overlay; show snackbar if true + var firstWebOverlay:Boolean by kpref("first_web_overlay", true) } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt index 43bb6ec6..cf1cbc67 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt @@ -14,23 +14,23 @@ enum class Theme(val textRes: Int, val injector: InjectorContract, private val headerColorGetter: () -> Int, private val iconColorGetter: () -> Int) { DEFAULT(R.string.kau_default, JsActions.EMPTY, { Color.BLACK }, { 0xfffafafa.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }), LIGHT(R.string.kau_light, CssAssets.MATERIAL_LIGHT, { Color.BLACK }, { 0xfffafafa.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }), - DARK(R.string.kau_dark, CssAssets.MATERIAL_DARK, { Color.WHITE }, { 0xff303030.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }), + DARK(R.string.kau_dark, CssAssets.MATERIAL_DARK, { Color.WHITE }, { 0xff303030.toInt() }, { 0xff2e4b86.toInt() }, { Color.WHITE }), AMOLED(R.string.kau_amoled, CssAssets.MATERIAL_AMOLED, { Color.WHITE }, { Color.BLACK }, { Color.BLACK }, { Color.WHITE }), GLASS(R.string.kau_glass, CssAssets.MATERIAL_GLASS, { Color.WHITE }, { 0x80000000.toInt() }, { 0xb3000000.toInt() }, { Color.WHITE }), CUSTOM(R.string.kau_custom, JsActions.EMPTY, { Prefs.customTextColor }, { Prefs.customBackgroundColor }, { Prefs.customHeaderColor }, { Prefs.customIconColor }) ; val textColor: Int - get() = textColorGetter.invoke() + get() = textColorGetter() val bgColor: Int - get() = backgroundColorGetter.invoke() + get() = backgroundColorGetter() val headerColor: Int - get() = headerColorGetter.invoke() + get() = headerColorGetter() val iconColor: Int - get() = iconColorGetter.invoke() + get() = iconColorGetter() companion object { val values = values() //save one instance diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt index a8a71845..70205bc6 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -7,10 +7,13 @@ import android.content.ComponentName import android.content.Context import android.graphics.Color import android.graphics.drawable.ColorDrawable +import android.support.annotation.StringRes +import android.support.design.internal.SnackbarContentLayout +import android.support.design.widget.Snackbar import android.support.v4.app.NotificationCompat -import android.support.v7.widget.SimpleItemAnimator import android.support.v7.widget.Toolbar import android.view.View +import android.widget.FrameLayout import android.widget.TextView import ca.allanwang.kau.utils.* import com.afollestad.materialdialogs.MaterialDialog @@ -102,15 +105,14 @@ fun Activity.setFrostTheme(forceTransparent: Boolean = false) { fun Activity.setFrostColors(toolbar: Toolbar? = null, themeWindow: Boolean = true, texts: Array<TextView> = arrayOf(), headers: Array<View> = arrayOf(), backgrounds: Array<View> = arrayOf()) { - val darkAccent = Prefs.headerColor.darken() - statusBarColor = darkAccent.darken().withAlpha(255) - navigationBarColor = darkAccent + statusBarColor = Prefs.headerColor.darken(0.1f).withAlpha(255) + navigationBarColor = Prefs.headerColor if (themeWindow) window.setBackgroundDrawable(ColorDrawable(Prefs.bgColor)) - toolbar?.setBackgroundColor(darkAccent) + toolbar?.setBackgroundColor(Prefs.headerColor) toolbar?.setTitleTextColor(Prefs.iconColor) toolbar?.overflowIcon?.setTint(Prefs.iconColor) texts.forEach { it.setTextColor(Prefs.textColor) } - headers.forEach { it.setBackgroundColor(darkAccent) } + headers.forEach { it.setBackgroundColor(Prefs.headerColor) } backgrounds.forEach { it.setBackgroundColor(Prefs.bgColor) } } @@ -147,4 +149,18 @@ fun frostAnswersCustom(name: String, action: CustomEvent.() -> Unit = {}) { frostAnswers { logCustom(CustomEvent("Frost $name").apply { action() }) } +} + +fun View.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) { + Snackbar.make(this, text, Snackbar.LENGTH_LONG).apply { + builder() + //hacky workaround, but it has proper checks and shouldn't crash + ((view as? FrameLayout)?.getChildAt(0) as? SnackbarContentLayout)?.apply { + messageView.setTextColor(Prefs.textColor) + actionView.setTextColor(Prefs.accentColor) + //only set if previous text colors are set + view.setBackgroundColor(Prefs.bgColor.colorToForeground(0.1f)) + } + show() + } }
\ No newline at end of file |