Setting colorSurface for background

This commit is contained in:
Maxime Naturel 2022-03-03 10:06:48 +01:00
parent d36409d475
commit e4c9acde77

View file

@ -18,10 +18,13 @@ package im.vector.app.features.location.option
import android.content.Context
import android.util.AttributeSet
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import im.vector.app.R
import im.vector.app.databinding.ViewLocationSharingOptionPickerBinding
/**
@ -51,6 +54,10 @@ class LocationSharingOptionPickerView @JvmOverloads constructor(
this
)
init {
applyBackground()
}
fun setOptions(vararg options: LocationSharingOption) {
val optionsNumber = options.toSet().size
val isPinnedVisible = options.contains(LocationSharingOption.PINNED)
@ -63,4 +70,17 @@ class LocationSharingOptionPickerView @JvmOverloads constructor(
divider2.isVisible = isUserCurrentVisible && isUserLiveVisible
optionUserLive.isVisible = isUserLiveVisible
}
private fun applyBackground() {
val outValue = TypedValue()
context.theme.resolveAttribute(
R.attr.colorSurface,
outValue,
true
)
binding.root.background = ContextCompat.getDrawable(
context,
outValue.resourceId
)
}
}