forked from upstream-mirrors/quik
Add support for Android 5.0
This commit is contained in:
@@ -49,12 +49,7 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
set(value) {
|
||||
if (field == value) return
|
||||
field = value
|
||||
|
||||
colors.theme(value).run {
|
||||
setBackgroundTint(theme)
|
||||
initial.setTextColor(textPrimary)
|
||||
icon.setTint(textPrimary)
|
||||
}
|
||||
applyTheme(value)
|
||||
}
|
||||
|
||||
private var lookupKey: String? = null
|
||||
@@ -106,16 +101,19 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
super.onFinishInflate()
|
||||
|
||||
if (!isInEditMode) {
|
||||
colors.theme(threadId).run {
|
||||
setBackgroundTint(theme)
|
||||
initial.setTextColor(textPrimary)
|
||||
icon.setTint(textPrimary)
|
||||
}
|
||||
|
||||
applyTheme(threadId)
|
||||
updateView()
|
||||
}
|
||||
}
|
||||
|
||||
fun applyTheme(threadId: Long) {
|
||||
colors.theme(threadId).run {
|
||||
setBackgroundTint(theme)
|
||||
initial.setTextColor(textPrimary)
|
||||
icon.setTint(textPrimary)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateView() {
|
||||
if (name?.isNotEmpty() == true) {
|
||||
initial.text = name?.substring(0, 1)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package common.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.support.constraint.ConstraintLayout
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
@@ -47,6 +48,11 @@ class GroupAvatarView @JvmOverloads constructor(context: Context, attrs: Attribu
|
||||
|
||||
avatars.forEach { avatar ->
|
||||
avatar.setBackgroundResource(R.drawable.rectangle)
|
||||
|
||||
// If we're on API 21 we need to reapply the tint after changing the background
|
||||
if (Build.VERSION.SDK_INT < 22) {
|
||||
avatar.applyTheme(0)
|
||||
}
|
||||
}
|
||||
|
||||
if (!isInEditMode) {
|
||||
|
||||
Reference in New Issue
Block a user