diff --git a/domain/src/main/java/com/moez/QKSMS/model/Conversation.kt b/domain/src/main/java/com/moez/QKSMS/model/Conversation.kt index d4339b414..08a9c9dcc 100644 --- a/domain/src/main/java/com/moez/QKSMS/model/Conversation.kt +++ b/domain/src/main/java/com/moez/QKSMS/model/Conversation.kt @@ -47,4 +47,8 @@ open class Conversation( return name.takeIf { it.isNotBlank() } ?: recipients.joinToString { recipient -> recipient.getDisplayName() } } + fun getNumberForSingleReceipt(): String { + return if(recipients.isNullOrEmpty() || recipients.size > 1 || recipients[0]!!.contact == null) "" else recipients[0]!!.address + } + } diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt index 3b42535b6..6a96fbb6a 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt @@ -186,11 +186,14 @@ class ComposeActivity : QkThemedActivity(), ComposeView { else -> state.conversationtitle } + toolbarNumber.text = state.conversationNumber + toolbarSubtitle.setVisible(state.query.isNotEmpty()) toolbarSubtitle.text = getString(R.string.compose_subtitle_results, state.searchSelectionPosition, state.searchResults) toolbarTitle.setVisible(!state.editingMode) + toolbarNumber.setVisible(!state.editingMode && state.conversationNumber.isNotEmpty() ) chips.setVisible(state.editingMode) composeBar.setVisible(!state.loading) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeState.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeState.kt index 1524b2018..6a6204754 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeState.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeState.kt @@ -32,6 +32,7 @@ data class ComposeState( val selectedChips: List = ArrayList(), val sendAsGroup: Boolean = true, val conversationtitle: String = "", + val conversationNumber: String = "", val loading: Boolean = false, val query: String = "", val searchSelectionId: Long = -1, diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt index ba601f2f7..fb05b0995 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt @@ -190,6 +190,11 @@ class ComposeViewModel @Inject constructor( .distinctUntilChanged() .subscribe { title -> newState { copy(conversationtitle = title) } } + disposables += conversation + .map { conversation -> conversation.getNumberForSingleReceipt() } + .distinctUntilChanged() + .subscribe { number -> newState { copy(conversationNumber = number) } } + disposables += prefs.sendAsGroup.asObservable() .distinctUntilChanged() .subscribe { enabled -> newState { copy(sendAsGroup = enabled) } } diff --git a/presentation/src/main/res/layout/compose_activity.xml b/presentation/src/main/res/layout/compose_activity.xml index 19900e0ad..cbaba39da 100644 --- a/presentation/src/main/res/layout/compose_activity.xml +++ b/presentation/src/main/res/layout/compose_activity.xml @@ -329,6 +329,13 @@ android:layout_height="wrap_content" tools:text="Moez Bhatti" /> + +