From 9d08be9a5644200b2a6881ea1e04e8a702901ae8 Mon Sep 17 00:00:00 2001 From: moezbhatti Date: Thu, 31 Oct 2019 00:09:40 -0400 Subject: [PATCH] Updated group avatar style Closes #1492, closes #1093 --- .../QKSMS/common/widget/GroupAvatarView.kt | 34 ++++++------ .../src/main/res/layout/blocked_list_item.xml | 16 +++--- .../src/main/res/layout/contact_list_item.xml | 8 +-- .../res/layout/conversation_list_item.xml | 12 ++--- .../src/main/res/layout/group_avatar_view.xml | 52 ++++++++++++------- .../layout/scheduled_message_list_item.xml | 6 +-- .../src/main/res/layout/search_list_item.xml | 12 ++--- 7 files changed, 77 insertions(+), 63 deletions(-) diff --git a/presentation/src/main/java/com/moez/QKSMS/common/widget/GroupAvatarView.kt b/presentation/src/main/java/com/moez/QKSMS/common/widget/GroupAvatarView.kt index d3f2d9af..904ec460 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/widget/GroupAvatarView.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/widget/GroupAvatarView.kt @@ -19,11 +19,15 @@ package com.moez.QKSMS.common.widget import android.content.Context -import android.os.Build import android.util.AttributeSet import android.view.View import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.view.isVisible +import androidx.core.view.updateLayoutParams 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 kotlinx.android.synthetic.main.group_avatar_view.view.* @@ -37,36 +41,30 @@ class GroupAvatarView @JvmOverloads constructor( updateView() } - private val avatars by lazy { listOf(avatar1, avatar2, avatar3) } - init { View.inflate(context, R.layout.group_avatar_view, this) - setBackgroundResource(R.drawable.circle) - clipToOutline = true } override fun 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) { updateView() } } private fun updateView() { - avatars.forEachIndexed { index, avatar -> - avatar.visibility = if (contacts.size > index) View.VISIBLE else View.GONE - avatar.setContact(contacts.getOrNull(index)) + avatar1Frame.setBackgroundTint(when (contacts.size > 1) { + true -> context.resolveThemeColor(android.R.attr.windowBackground) + false -> context.getColorCompat(android.R.color.transparent) + }) + avatar1Frame.updateLayoutParams { + 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)) } -} \ No newline at end of file +} diff --git a/presentation/src/main/res/layout/blocked_list_item.xml b/presentation/src/main/res/layout/blocked_list_item.xml index 5c41be73..a70b945e 100644 --- a/presentation/src/main/res/layout/blocked_list_item.xml +++ b/presentation/src/main/res/layout/blocked_list_item.xml @@ -23,15 +23,15 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" - android:paddingTop="8dp" - android:paddingBottom="8dp" + android:paddingTop="4dp" + android:paddingBottom="4dp" app:layout_constraintVertical_chainStyle="packed"> @@ -69,12 +70,11 @@ android:id="@+id/blocker" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="16dp" android:layout_marginTop="2dp" android:textColor="?android:attr/textColorTertiary" android:textStyle="bold" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintStart_toEndOf="@id/avatars" + app:layout_constraintStart_toStartOf="@id/title" app:layout_constraintTop_toBottomOf="@id/title" app:textSize="secondary" tools:text="Call Control" /> diff --git a/presentation/src/main/res/layout/contact_list_item.xml b/presentation/src/main/res/layout/contact_list_item.xml index 3b669e33..9c10ef53 100644 --- a/presentation/src/main/res/layout/contact_list_item.xml +++ b/presentation/src/main/res/layout/contact_list_item.xml @@ -55,9 +55,9 @@ + android:paddingBottom="8dp"> - + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0" + app:layout_constraintWidth_percent=".75"> - - - + + + + + app:layout_constraintHorizontal_bias="0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="1" + app:layout_constraintWidth_percent=".75"> + + + + \ No newline at end of file diff --git a/presentation/src/main/res/layout/scheduled_message_list_item.xml b/presentation/src/main/res/layout/scheduled_message_list_item.xml index 46e6733a..6520ea74 100644 --- a/presentation/src/main/res/layout/scheduled_message_list_item.xml +++ b/presentation/src/main/res/layout/scheduled_message_list_item.xml @@ -25,12 +25,12 @@ android:background="?attr/selectableItemBackground" android:gravity="center_vertical" android:orientation="horizontal" - android:padding="16dp"> + android:padding="12dp">