Add action bar subtitle

This commit is contained in:
Niels Andriesse 2021-06-24 11:38:06 +10:00
parent 62cee715a7
commit e4292a3db5
2 changed files with 74 additions and 11 deletions

View File

@ -43,6 +43,8 @@ import org.thoughtcrime.securesms.database.DraftDatabase.Drafts
import org.thoughtcrime.securesms.database.model.MessageRecord import org.thoughtcrime.securesms.database.model.MessageRecord
import org.thoughtcrime.securesms.loki.utilities.toPx import org.thoughtcrime.securesms.loki.utilities.toPx
import org.thoughtcrime.securesms.mms.GlideApp import org.thoughtcrime.securesms.mms.GlideApp
import org.thoughtcrime.securesms.util.DateUtils
import java.util.*
import kotlin.math.* import kotlin.math.*
class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDelegate, class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDelegate,
@ -109,6 +111,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
scrollToBottomButton.setOnClickListener { conversationRecyclerView.smoothScrollToPosition(0) } scrollToBottomButton.setOnClickListener { conversationRecyclerView.smoothScrollToPosition(0) }
updateUnreadCount() updateUnreadCount()
setUpTypingObserver() setUpTypingObserver()
updateSubtitle()
} }
private fun setUpRecyclerView() { private fun setUpRecyclerView() {
@ -352,6 +355,24 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
unreadCountTextView.setTypeface(Typeface.DEFAULT, if (unreadCount < 100) Typeface.BOLD else Typeface.NORMAL) unreadCountTextView.setTypeface(Typeface.DEFAULT, if (unreadCount < 100) Typeface.BOLD else Typeface.NORMAL)
unreadCountIndicator.isVisible = (unreadCount != 0) unreadCountIndicator.isVisible = (unreadCount != 0)
} }
private fun updateSubtitle() {
muteIconImageView.isVisible = thread.isMuted
conversationSubtitleView.isVisible = true
if (thread.isMuted) {
conversationSubtitleView.text = getString(R.string.ConversationActivity_muted_until_date, DateUtils.getFormattedDateTime(thread.mutedUntil, "EEE, MMM d, yyyy HH:mm", Locale.getDefault()))
} else if (thread.isGroupRecipient) {
val openGroup = DatabaseFactory.getLokiThreadDatabase(this).getOpenGroupChat(threadID)
if (openGroup != null) {
val userCount = DatabaseFactory.getLokiAPIDatabase(this).getUserCount(openGroup.room, openGroup.server) ?: 0
conversationSubtitleView.text = getString(R.string.ConversationActivity_member_count, userCount)
} else {
conversationSubtitleView.isVisible = false
}
} else {
conversationSubtitleView.isVisible = false
}
}
// endregion // endregion
// region Interaction // region Interaction

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal" android:orientation="horizontal"
android:gravity="center_vertical"> android:gravity="center_vertical">
@ -11,11 +12,18 @@
android:layout_width="@dimen/small_profile_picture_size" android:layout_width="@dimen/small_profile_picture_size"
android:layout_height="@dimen/small_profile_picture_size" /> android:layout_height="@dimen/small_profile_picture_size" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-2dp"
android:orientation="vertical">
<TextView <TextView
android:id="@+id/conversationTitleView" android:id="@+id/conversationTitleView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:layout_marginBottom="-4dp"
android:text="Elon" android:text="Elon"
android:textColor="@color/text" android:textColor="@color/text"
android:textStyle="bold" android:textStyle="bold"
@ -23,4 +31,38 @@
android:maxLines="1" android:maxLines="1"
android:ellipsize="end" /> android:ellipsize="end" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:id="@+id/muteIconImageView"
android:layout_width="14dp"
android:layout_height="14dp"
android:layout_marginEnd="4dp"
android:layout_gravity="center"
android:src="@drawable/ic_outline_notifications_off_24"
app:tint="@color/text"
android:alpha="0.6"
android:visibility="gone"
tools:visibility="visible"/>
<TextView
android:id="@+id/conversationSubtitleView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Muted"
android:textColor="@color/text"
android:alpha="0.6"
android:textSize="@dimen/very_small_font_size"
android:maxLines="1"
android:ellipsize="end" />
</LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>