From 56df1bf145dc13633fa8916c8d8f3bec12de3336 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Tue, 11 Apr 2017 21:01:25 +0800 Subject: [PATCH] fixed follow button color under Android 5.0 --- .../org/mariotaku/twidere/fragment/UserFragment.kt | 9 ++++++--- .../org/mariotaku/twidere/view/IconActionButton.kt | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserFragment.kt index 4da38cb02..5a53ae703 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserFragment.kt @@ -29,6 +29,7 @@ import android.content.DialogInterface import android.content.Intent import android.graphics.Color import android.graphics.Outline +import android.graphics.PorterDuff import android.graphics.Rect import android.graphics.drawable.ColorDrawable import android.graphics.drawable.Drawable @@ -1579,9 +1580,11 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener, } private fun setFollowEditButton(@DrawableRes icon: Int, @ColorRes color: Int, @StringRes label: Int) { - followContainer.follow.setImageResource(icon) - ViewCompat.setBackgroundTintList(followContainer.follow, ContextCompat.getColorStateList(context, color)) - followContainer.follow.contentDescription = getString(label) + val followButton = followContainer.follow + followButton.setImageResource(icon) + ViewCompat.setBackgroundTintMode(followButton, PorterDuff.Mode.SRC_ATOP) + ViewCompat.setBackgroundTintList(followButton, ContextCompat.getColorStateList(context, color)) + followButton.contentDescription = getString(label) } private class ActionBarDrawable(shadow: Drawable) : LayerDrawable(arrayOf(shadow, ActionBarColorDrawable.create(true))) { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/view/IconActionButton.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/view/IconActionButton.kt index d13e80ee1..89cb09b14 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/view/IconActionButton.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/view/IconActionButton.kt @@ -94,6 +94,11 @@ class IconActionButton( updateColorFilter() } + override fun setSupportBackgroundTintList(tint: ColorStateList?) { + super.setSupportBackgroundTintList(tint) + updateColorFilter() + } + override fun isPostApplyTheme(): Boolean { return false }