diff options
author | Allan Wang <me@allanwang.ca> | 2017-06-15 16:19:56 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-06-15 16:19:56 -0700 |
commit | 15d8a70a6c7596bb9f59a4383df7dccbba3a7012 (patch) | |
tree | 4d56aa5e2a78a434bc4c73ea10dfdeb7d8ac8b6f /app/src/main/kotlin/com/pitchedapps/frost/utils | |
parent | 9e0044f8789a47a41933d341b968fe0a6bc22b6d (diff) | |
download | frost-15d8a70a6c7596bb9f59a4383df7dccbba3a7012.tar.gz frost-15d8a70a6c7596bb9f59a4383df7dccbba3a7012.tar.bz2 frost-15d8a70a6c7596bb9f59a4383df7dccbba3a7012.zip |
Tint more things
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/ContextUtils.kt | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/ContextUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/ContextUtils.kt index 2053a6bf..c2bcc2ab 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/ContextUtils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/ContextUtils.kt @@ -3,9 +3,11 @@ package com.pitchedapps.frost.utils import android.app.Activity import android.content.Context import android.content.Intent +import android.graphics.Color import android.support.v4.app.ActivityOptionsCompat import android.support.v4.content.ContextCompat import ca.allanwang.kau.utils.adjustAlpha +import ca.allanwang.kau.utils.isColorDark import ca.allanwang.kau.utils.lighten import ca.allanwang.kau.utils.startActivity import com.afollestad.materialdialogs.MaterialDialog @@ -43,7 +45,8 @@ fun WebOverlayActivity.url(): String { return intent.extras?.getString(ARG_URL) ?: FbTab.FEED.url } -fun Activity.materialDialog(action: MaterialDialog.Builder.() -> Unit) { + +fun Activity.materialDialogThemed(action: MaterialDialog.Builder.() -> Unit): MaterialDialog { val builder = MaterialDialog.Builder(this) val dimmerTextColor = Prefs.textColor.adjustAlpha(0.8f) builder.titleColor(Prefs.textColor) @@ -54,4 +57,13 @@ fun Activity.materialDialog(action: MaterialDialog.Builder.() -> Unit) { .negativeColor(Prefs.textColor) .neutralColor(Prefs.textColor) builder.action() + return builder.show() +} + +fun Activity.setFrostTheme() { + val isTransparent = Color.alpha(Prefs.bgColor) != 255 + if (Prefs.bgColor.isColorDark()) + setTheme(if (isTransparent) R.style.FrostTheme_Transparent else R.style.FrostTheme) + else + setTheme(if (isTransparent) R.style.FrostTheme_Light_Transparent else R.style.FrostTheme_Light) }
\ No newline at end of file |