forked from upstream-mirrors/quik
@@ -19,11 +19,15 @@
|
|||||||
package com.moez.QKSMS.common.widget
|
package com.moez.QKSMS.common.widget
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
import androidx.core.view.isVisible
|
||||||
|
import androidx.core.view.updateLayoutParams
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
|
import com.moez.QKSMS.common.util.extensions.getColorCompat
|
||||||
|
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
||||||
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.model.Recipient
|
import com.moez.QKSMS.model.Recipient
|
||||||
import kotlinx.android.synthetic.main.group_avatar_view.view.*
|
import kotlinx.android.synthetic.main.group_avatar_view.view.*
|
||||||
|
|
||||||
@@ -37,36 +41,30 @@ class GroupAvatarView @JvmOverloads constructor(
|
|||||||
updateView()
|
updateView()
|
||||||
}
|
}
|
||||||
|
|
||||||
private val avatars by lazy { listOf(avatar1, avatar2, avatar3) }
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
View.inflate(context, R.layout.group_avatar_view, this)
|
View.inflate(context, R.layout.group_avatar_view, this)
|
||||||
setBackgroundResource(R.drawable.circle)
|
|
||||||
clipToOutline = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFinishInflate() {
|
override fun onFinishInflate() {
|
||||||
super.onFinishInflate()
|
super.onFinishInflate()
|
||||||
|
|
||||||
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) {
|
if (!isInEditMode) {
|
||||||
updateView()
|
updateView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateView() {
|
private fun updateView() {
|
||||||
avatars.forEachIndexed { index, avatar ->
|
avatar1Frame.setBackgroundTint(when (contacts.size > 1) {
|
||||||
avatar.visibility = if (contacts.size > index) View.VISIBLE else View.GONE
|
true -> context.resolveThemeColor(android.R.attr.windowBackground)
|
||||||
avatar.setContact(contacts.getOrNull(index))
|
false -> context.getColorCompat(android.R.color.transparent)
|
||||||
|
})
|
||||||
|
avatar1Frame.updateLayoutParams<LayoutParams> {
|
||||||
|
matchConstraintPercentWidth = if (contacts.size > 1) 0.75f else 1.0f
|
||||||
}
|
}
|
||||||
|
avatar2.isVisible = contacts.size > 1
|
||||||
|
|
||||||
|
avatar1.setContact(contacts.getOrNull(0))
|
||||||
|
avatar2.setContact(contacts.getOrNull(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -23,15 +23,15 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="4dp"
|
||||||
android:paddingBottom="8dp"
|
android:paddingBottom="4dp"
|
||||||
app:layout_constraintVertical_chainStyle="packed">
|
app:layout_constraintVertical_chainStyle="packed">
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.GroupAvatarView
|
<com.moez.QKSMS.common.widget.GroupAvatarView
|
||||||
android:id="@+id/avatars"
|
android:id="@+id/avatars"
|
||||||
android:layout_width="48dp"
|
android:layout_width="56dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="56dp"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="12dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@id/title"
|
app:layout_constraintEnd_toStartOf="@id/title"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
@@ -42,13 +42,14 @@
|
|||||||
style="@style/TextPrimary"
|
style="@style/TextPrimary"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="12dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
app:layout_constraintBottom_toTopOf="@id/blocker"
|
app:layout_constraintBottom_toTopOf="@id/blocker"
|
||||||
app:layout_constraintEnd_toStartOf="@id/date"
|
app:layout_constraintEnd_toStartOf="@id/date"
|
||||||
app:layout_constraintHorizontal_bias="0"
|
app:layout_constraintHorizontal_bias="0"
|
||||||
app:layout_constraintStart_toEndOf="@id/avatars"
|
app:layout_constraintStart_toEndOf="@id/avatars"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_chainStyle="packed"
|
||||||
app:textSize="primary"
|
app:textSize="primary"
|
||||||
tools:text="@tools:sample/full_names" />
|
tools:text="@tools:sample/full_names" />
|
||||||
|
|
||||||
@@ -69,12 +70,11 @@
|
|||||||
android:id="@+id/blocker"
|
android:id="@+id/blocker"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_marginTop="2dp"
|
android:layout_marginTop="2dp"
|
||||||
android:textColor="?android:attr/textColorTertiary"
|
android:textColor="?android:attr/textColorTertiary"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@id/avatars"
|
app:layout_constraintStart_toStartOf="@id/title"
|
||||||
app:layout_constraintTop_toBottomOf="@id/title"
|
app:layout_constraintTop_toBottomOf="@id/title"
|
||||||
app:textSize="secondary"
|
app:textSize="secondary"
|
||||||
tools:text="Call Control" />
|
tools:text="Call Control" />
|
||||||
|
|||||||
@@ -55,9 +55,9 @@
|
|||||||
|
|
||||||
<com.moez.QKSMS.common.widget.GroupAvatarView
|
<com.moez.QKSMS.common.widget.GroupAvatarView
|
||||||
android:id="@+id/avatar"
|
android:id="@+id/avatar"
|
||||||
android:layout_width="40dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="48dp"
|
||||||
android:layout_marginStart="72dp"
|
android:layout_marginStart="68dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
style="@style/TextPrimary"
|
style="@style/TextPrimary"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="12dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:layout_constraintBottom_toTopOf="@id/subtitle"
|
app:layout_constraintBottom_toTopOf="@id/subtitle"
|
||||||
|
|||||||
@@ -25,15 +25,15 @@
|
|||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="12dp"
|
||||||
android:paddingTop="12dp"
|
android:paddingTop="8dp"
|
||||||
android:paddingEnd="16dp"
|
android:paddingEnd="16dp"
|
||||||
android:paddingBottom="12dp">
|
android:paddingBottom="8dp">
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.GroupAvatarView
|
<com.moez.QKSMS.common.widget.GroupAvatarView
|
||||||
android:id="@+id/avatars"
|
android:id="@+id/avatars"
|
||||||
android:layout_width="48dp"
|
android:layout_width="56dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="56dp"
|
||||||
android:layout_gravity="top"
|
android:layout_gravity="top"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
style="@style/TextPrimary"
|
style="@style/TextPrimary"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="12dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:lines="1"
|
android:lines="1"
|
||||||
|
|||||||
@@ -22,34 +22,50 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal"
|
|
||||||
tools:parentTag="com.moez.QKSMS.common.widget.GroupAvatarView">
|
tools:parentTag="com.moez.QKSMS.common.widget.GroupAvatarView">
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.AvatarView
|
<FrameLayout
|
||||||
android:id="@+id/avatar1"
|
android:id="@+id/avatar2Frame"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
android:padding="4dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/avatar2"
|
app:layout_constraintDimensionRatio="1:1"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="1"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0"
|
||||||
|
app:layout_constraintWidth_percent=".75">
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.AvatarView
|
<com.moez.QKSMS.common.widget.AvatarView
|
||||||
android:id="@+id/avatar2"
|
android:id="@+id/avatar2"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="match_parent" />
|
||||||
app:layout_constraintBottom_toTopOf="@+id/avatar3"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
</FrameLayout>
|
||||||
app:layout_constraintStart_toEndOf="@+id/avatar1"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
<FrameLayout
|
||||||
|
android:id="@+id/avatar1Frame"
|
||||||
<com.moez.QKSMS.common.widget.AvatarView
|
|
||||||
android:id="@+id/avatar3"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
android:background="@drawable/circle"
|
||||||
|
android:backgroundTint="?android:attr/windowBackground"
|
||||||
|
android:padding="4dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintDimensionRatio="1:1"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="@+id/avatar2"
|
app:layout_constraintHorizontal_bias="0"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/avatar2" />
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="1"
|
||||||
|
app:layout_constraintWidth_percent=".75">
|
||||||
|
|
||||||
|
<com.moez.QKSMS.common.widget.AvatarView
|
||||||
|
android:id="@+id/avatar1"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
</merge>
|
</merge>
|
||||||
@@ -25,12 +25,12 @@
|
|||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:padding="16dp">
|
android:padding="12dp">
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.GroupAvatarView
|
<com.moez.QKSMS.common.widget.GroupAvatarView
|
||||||
android:id="@+id/avatars"
|
android:id="@+id/avatars"
|
||||||
android:layout_width="48dp"
|
android:layout_width="56dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="56dp"
|
||||||
android:layout_gravity="top"
|
android:layout_gravity="top"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
|||||||
@@ -58,12 +58,12 @@
|
|||||||
|
|
||||||
<com.moez.QKSMS.common.widget.GroupAvatarView
|
<com.moez.QKSMS.common.widget.GroupAvatarView
|
||||||
android:id="@+id/avatars"
|
android:id="@+id/avatars"
|
||||||
android:layout_width="48dp"
|
android:layout_width="56dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="56dp"
|
||||||
android:layout_gravity="top"
|
android:layout_gravity="top"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="12dp"
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginBottom="12dp"
|
android:layout_marginBottom="8dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/resultsTitle"
|
app:layout_constraintTop_toBottomOf="@id/resultsTitle"
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
style="@style/TextPrimary"
|
style="@style/TextPrimary"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="12dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
app:layout_constraintBottom_toTopOf="@id/snippet"
|
app:layout_constraintBottom_toTopOf="@id/snippet"
|
||||||
app:layout_constraintEnd_toStartOf="@id/date"
|
app:layout_constraintEnd_toStartOf="@id/date"
|
||||||
|
|||||||
Reference in New Issue
Block a user