Adjust badge positioning.
This commit is contained in:
parent
5bcb7cece4
commit
19a95f479e
8 changed files with 45 additions and 25 deletions
|
@ -25,12 +25,20 @@ class BadgeImageView @JvmOverloads constructor(
|
|||
context.obtainStyledAttributes(attrs, R.styleable.BadgeImageView).use {
|
||||
badgeSize = it.getInt(R.styleable.BadgeImageView_badge_size, 0)
|
||||
}
|
||||
|
||||
isClickable = false
|
||||
}
|
||||
|
||||
override fun setOnClickListener(l: OnClickListener?) {
|
||||
val wasClickable = isClickable
|
||||
super.setOnClickListener(l)
|
||||
this.isClickable = wasClickable
|
||||
}
|
||||
|
||||
fun setBadgeFromRecipient(recipient: Recipient?) {
|
||||
getGlideRequests()?.let {
|
||||
setBadgeFromRecipient(recipient, it)
|
||||
} ?: setImageDrawable(null)
|
||||
} ?: clearDrawable()
|
||||
}
|
||||
|
||||
fun setBadgeFromRecipient(recipient: Recipient?, glideRequests: GlideRequests) {
|
||||
|
@ -44,7 +52,7 @@ class BadgeImageView @JvmOverloads constructor(
|
|||
fun setBadge(badge: Badge?) {
|
||||
getGlideRequests()?.let {
|
||||
setBadge(badge, it)
|
||||
} ?: setImageDrawable(null)
|
||||
} ?: clearDrawable()
|
||||
}
|
||||
|
||||
fun setBadge(badge: Badge?, glideRequests: GlideRequests) {
|
||||
|
@ -54,13 +62,20 @@ class BadgeImageView @JvmOverloads constructor(
|
|||
.downsample(DownsampleStrategy.NONE)
|
||||
.transform(BadgeSpriteTransformation(BadgeSpriteTransformation.Size.fromInteger(badgeSize), badge.imageDensity, ThemeUtil.isDarkTheme(context)))
|
||||
.into(this)
|
||||
|
||||
isClickable = true
|
||||
} else {
|
||||
glideRequests
|
||||
.clear(this)
|
||||
setImageDrawable(null)
|
||||
clearDrawable()
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearDrawable() {
|
||||
setImageDrawable(null)
|
||||
isClickable = false
|
||||
}
|
||||
|
||||
private fun getGlideRequests(): GlideRequests? {
|
||||
return try {
|
||||
GlideApp.with(this)
|
||||
|
|
|
@ -152,7 +152,11 @@ public final class RecipientBottomSheetDialogFragment extends BottomSheetDialogF
|
|||
}
|
||||
});
|
||||
avatar.setAvatar(recipient);
|
||||
|
||||
if (!recipient.isSelf()) {
|
||||
badgeImageView.setBadgeFromRecipient(recipient);
|
||||
}
|
||||
|
||||
if (recipient.isSelf()) {
|
||||
avatar.setOnClickListener(v -> {
|
||||
dismiss();
|
||||
|
|
|
@ -39,15 +39,14 @@
|
|||
android:id="@+id/check_box"
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="22dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:alpha="0"
|
||||
android:background="@drawable/contact_selection_checkbox"
|
||||
android:button="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
app:layout_constraintStart_toStartOf="@id/contact_photo_image"
|
||||
app:layout_constraintTop_toTopOf="@id/contact_photo_image" />
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<org.thoughtcrime.securesms.components.FromTextView
|
||||
android:id="@+id/name"
|
||||
|
@ -104,13 +103,15 @@
|
|||
android:id="@+id/sms_tag"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:text="@string/ContactSelectionListItem__sms"
|
||||
android:textAppearance="@style/TextAppearance.Signal.Body2"
|
||||
android:textColor="@color/signal_text_secondary"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/check_box"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_goneMarginEnd="0dp"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</org.thoughtcrime.securesms.contacts.ContactSelectionListItem>
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
|
||||
<org.thoughtcrime.securesms.badges.BadgeImageView
|
||||
android:id="@+id/message_request_badge"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginStart="47dp"
|
||||
android:layout_marginTop="48dp"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginStart="44dp"
|
||||
android:layout_marginTop="52dp"
|
||||
android:contentDescription="@string/ImageView__badge"
|
||||
app:badge_size="large"
|
||||
app:layout_constraintStart_toStartOf="@id/message_request_avatar"
|
||||
|
|
|
@ -178,8 +178,8 @@
|
|||
android:id="@+id/conversation_list_item_badge"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="26dp"
|
||||
android:layout_marginTop="26dp"
|
||||
android:layout_marginStart="28dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:contentDescription="@string/ImageView__badge"
|
||||
app:badge_size="medium"
|
||||
app:layout_constraintStart_toStartOf="@id/conversation_list_item_avatar"
|
||||
|
|
|
@ -23,10 +23,10 @@
|
|||
|
||||
<org.thoughtcrime.securesms.badges.BadgeImageView
|
||||
android:id="@+id/bio_preference_badge"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginStart="47dp"
|
||||
android:layout_marginTop="48dp"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginStart="44dp"
|
||||
android:layout_marginTop="52dp"
|
||||
android:contentDescription="@string/ImageView__badge"
|
||||
app:badge_size="large"
|
||||
app:layout_constraintStart_toStartOf="@id/bio_preference_avatar"
|
||||
|
|
|
@ -35,8 +35,8 @@
|
|||
android:layout_height="16dp"
|
||||
android:layout_alignStart="@id/contact_photo_image"
|
||||
android:layout_alignTop="@id/contact_photo_image"
|
||||
android:layout_marginStart="22dp"
|
||||
android:layout_marginTop="22dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="23dp"
|
||||
android:contentDescription="@string/ImageView__badge"
|
||||
app:badge_size="small" />
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -23,10 +23,10 @@
|
|||
|
||||
<org.thoughtcrime.securesms.badges.BadgeImageView
|
||||
android:id="@+id/rbs_badge"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginStart="47dp"
|
||||
android:layout_marginTop="48dp"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginStart="44dp"
|
||||
android:layout_marginTop="52dp"
|
||||
android:contentDescription="@string/ImageView__badge"
|
||||
app:badge_size="large"
|
||||
app:layout_constraintStart_toStartOf="@id/rbs_recipient_avatar"
|
||||
|
|
Loading…
Add table
Reference in a new issue