From 8c9dee220c95cd0da151d57d8dd43fbfb7b348b2 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Mon, 30 Dec 2019 17:17:48 -0800 Subject: Update nav colors to avoid over transparent backgrounds --- .../frost/activities/BaseMainActivity.kt | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'app/src/main/kotlin/com') 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) } -- cgit v1.2.3