Make the unread message count 4 digits instead of 2. (#827)

* Make the unread message count 4 digits instead of 2.

99+ unread messages can be reached within an hour in some busy open
groups. 4 digits allow for much more accurate reporting.

* Improve appearance of unread counter by using rounded rectangle.
This commit is contained in:
Ian Macdonald 2022-01-18 12:32:20 +01:00 committed by GitHub
parent bd5a324ad8
commit 46aebb168c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 11 deletions

View file

@ -756,9 +756,9 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
}
private fun updateUnreadCountIndicator() {
val formattedUnreadCount = if (unreadCount < 100) unreadCount.toString() else "99+"
val formattedUnreadCount = if (unreadCount < 10000) unreadCount.toString() else "9999+"
binding.unreadCountTextView.text = formattedUnreadCount
val textSize = if (unreadCount < 100) 12.0f else 9.0f
val textSize = if (unreadCount < 10000) 12.0f else 9.0f
binding.unreadCountTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize)
binding.unreadCountTextView.setTypeface(Typeface.DEFAULT, if (unreadCount < 100) Typeface.BOLD else Typeface.NORMAL)
binding.unreadCountIndicator.isVisible = (unreadCount != 0)

View file

@ -61,10 +61,10 @@ class ConversationView : LinearLayout {
val formattedUnreadCount = if (thread.isRead) {
null
} else {
if (unreadCount < 100) unreadCount.toString() else "99+"
if (unreadCount < 10000) unreadCount.toString() else "9999+"
}
binding.unreadCountTextView.text = formattedUnreadCount
val textSize = if (unreadCount < 100) 12.0f else 9.0f
val textSize = if (unreadCount < 10000) 12.0f else 9.0f
binding.unreadCountTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize)
binding.unreadCountTextView.setTypeface(Typeface.DEFAULT, if (unreadCount < 100) Typeface.BOLD else Typeface.NORMAL)
binding.unreadCountIndicator.isVisible = (unreadCount != 0 && !thread.isRead)
@ -120,4 +120,4 @@ class ConversationView : LinearLayout {
}
}
// endregion
}
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/white" />
<corners android:radius="16dp" />
</shape>

View file

@ -115,11 +115,14 @@
<RelativeLayout
android:id="@+id/unreadCountIndicator"
android:layout_width="20dp"
android:layout_width="wrap_content"
android:maxWidth="40dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:layout_height="20dp"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:background="@drawable/circle_tintable"
android:background="@drawable/rounded_rectangle"
android:backgroundTint="@color/conversation_unread_count_indicator_background">
<TextView
@ -165,4 +168,4 @@
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>

View file

@ -63,10 +63,13 @@
<RelativeLayout
android:id="@+id/unreadCountIndicator"
android:layout_width="20dp"
android:layout_width="wrap_content"
android:maxWidth="40dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:layout_height="20dp"
android:layout_marginStart="4dp"
android:background="@drawable/circle_tintable"
android:background="@drawable/rounded_rectangle"
android:backgroundTint="@color/conversation_unread_count_indicator_background">
<TextView
@ -148,4 +151,4 @@
</FrameLayout>
</LinearLayout>
</LinearLayout>