diff options
author | Allan Wang <me@allanwang.ca> | 2019-12-30 17:17:48 -0800 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2019-12-30 17:17:48 -0800 |
commit | 8c9dee220c95cd0da151d57d8dd43fbfb7b348b2 (patch) | |
tree | 3650cabd98d331dc97aba1d3575d52035acf6f51 /app | |
parent | 115b1791ada343435544c0f794830c6327f561de (diff) | |
download | frost-8c9dee220c95cd0da151d57d8dd43fbfb7b348b2.tar.gz frost-8c9dee220c95cd0da151d57d8dd43fbfb7b348b2.tar.bz2 frost-8c9dee220c95cd0da151d57d8dd43fbfb7b348b2.zip |
Update nav colors to avoid over transparent backgrounds
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt index eb35ee77..dbe54471 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt @@ -37,6 +37,7 @@ import android.widget.ImageView import android.widget.TextView import androidx.appcompat.app.ActionBarDrawerToggle import androidx.appcompat.widget.Toolbar +import androidx.core.graphics.alpha import androidx.core.view.updateLayoutParams import androidx.drawerlayout.widget.DrawerLayout import androidx.fragment.app.Fragment @@ -46,7 +47,7 @@ import ca.allanwang.kau.searchview.SearchView import ca.allanwang.kau.searchview.SearchViewHolder import ca.allanwang.kau.searchview.bindSearchView import ca.allanwang.kau.ui.ProgressAnimator -import ca.allanwang.kau.utils.adjustAlpha +import ca.allanwang.kau.utils.blendWith import ca.allanwang.kau.utils.colorToForeground import ca.allanwang.kau.utils.dimenPixelSize import ca.allanwang.kau.utils.drawable @@ -63,6 +64,7 @@ import ca.allanwang.kau.utils.tint import ca.allanwang.kau.utils.toDrawable import ca.allanwang.kau.utils.toast import ca.allanwang.kau.utils.visible +import ca.allanwang.kau.utils.withAlpha import ca.allanwang.kau.utils.withMinAlpha import com.afollestad.materialdialogs.checkbox.checkBoxPrompt import com.bumptech.glide.Glide @@ -263,12 +265,12 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } } - private fun createNavDrawable(): RippleDrawable { + private fun createNavDrawable(foreground: Int, background: Int): RippleDrawable { val drawable = drawable(R.drawable.nav_item_background) as RippleDrawable drawable.setColor( ColorStateList( arrayOf(intArrayOf()), - intArrayOf(Prefs.accentColor.adjustAlpha(0.16f)) + intArrayOf(background.blendWith(foreground.withAlpha(background.alpha), 0.2f)) ) ) return drawable @@ -316,7 +318,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } val navBg = Prefs.bgColor.withMinAlpha(200) setBackgroundColor(navBg) - itemBackground = createNavDrawable() + itemBackground = createNavDrawable(Prefs.accentColor, navBg) itemTextColor = foregroundColor itemIconTintList = foregroundColor @@ -380,6 +382,9 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, private var pendingUpdate: Boolean = false private val binding = ViewNavHeaderBinding.inflate(layoutInflater) val root: View get() = binding.root + private val optionsBackground = Prefs.bgColor.withMinAlpha(200).colorToForeground( + 0.1f + ) init { setPrimary(Prefs.userId) @@ -395,11 +400,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, }) } with(binding) { - optionsContainer.setBackgroundColor( - Prefs.bgColor.withMinAlpha(200).colorToForeground( - 0.1f - ) - ) + optionsContainer.setBackgroundColor(optionsBackground) var showOptions = false val animator: ProgressAnimator = ProgressAnimator.ofFloat { } background.setOnClickListener { @@ -454,7 +455,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, null ) setTextColor(textColor) - background = createNavDrawable() + background = createNavDrawable(Prefs.accentColor, optionsBackground) } with(optionsLogout) { @@ -564,7 +565,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, }) tv.text = cookie.name tv.setTextColor(textColor) - tv.background = createNavDrawable() + tv.background = createNavDrawable(Prefs.accentColor, optionsBackground) tv.setOnClickListener { switchAccount(cookie.id) } |