Fix bad color for settings icon on Android < 24 (#1786)
This commit is contained in:
parent
9f3f981ab0
commit
249f268fb5
|
@ -9,6 +9,7 @@ Improvements 🙌:
|
|||
|
||||
Bugfix 🐛:
|
||||
- Display name not shown under Settings/General (#1926)
|
||||
- Fix bad color for settings icon on Android < 24 (#1786)
|
||||
|
||||
Translations 🗣:
|
||||
-
|
||||
|
|
|
@ -20,12 +20,15 @@ import android.animation.Animator
|
|||
import android.animation.ArgbEvaluator
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.graphics.Typeface
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.animation.doOnEnd
|
||||
import androidx.core.widget.ImageViewCompat
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceViewHolder
|
||||
import im.vector.app.R
|
||||
|
@ -76,6 +79,12 @@ open class VectorPreference : Preference {
|
|||
notifyChanged()
|
||||
}
|
||||
|
||||
var tintIcon = false
|
||||
set(value) {
|
||||
field = value
|
||||
notifyChanged()
|
||||
}
|
||||
|
||||
var currentHighlightAnimator: Animator? = null
|
||||
|
||||
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
||||
|
@ -93,6 +102,14 @@ open class VectorPreference : Preference {
|
|||
|
||||
summary?.setTypeface(null, mTypeface)
|
||||
|
||||
if (tintIcon) {
|
||||
// Tint icons (See #1786)
|
||||
val icon = holder.findViewById(android.R.id.icon) as? ImageView
|
||||
|
||||
icon?.let {
|
||||
val color = ThemeUtils.getColor(context, R.attr.riotx_header_panel_text_secondary)
|
||||
ImageViewCompat.setImageTintList(it, ColorStateList.valueOf(color))
|
||||
}
|
||||
}
|
||||
|
||||
// cancel existing animation (find a way to resume if happens during anim?)
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
|
||||
package im.vector.app.features.settings
|
||||
|
||||
import android.os.Build
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.preference.VectorPreference
|
||||
import javax.inject.Inject
|
||||
|
||||
class VectorSettingsRootFragment @Inject constructor() : VectorSettingsBaseFragment() {
|
||||
|
@ -25,6 +27,15 @@ class VectorSettingsRootFragment @Inject constructor() : VectorSettingsBaseFragm
|
|||
override val preferenceXmlRes = R.xml.vector_settings_root
|
||||
|
||||
override fun bindPref() {
|
||||
// Nothing to do
|
||||
// Tint icon on API < 24
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||
tintIcons()
|
||||
}
|
||||
}
|
||||
|
||||
private fun tintIcons() {
|
||||
for (i in 0 until preferenceScreen.preferenceCount) {
|
||||
(preferenceScreen.getPreference(i) as? VectorPreference)?.let { it.tintIcon = true }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue