Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #439, Add option to show phone number on top of the conversation #1737

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions domain/src/main/java/com/moez/QKSMS/model/Conversation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ data class ComposeState(
val selectedChips: List<Recipient> = ArrayList(),
val sendAsGroup: Boolean = true,
val conversationtitle: String = "",
val conversationNumber: String = "",
val loading: Boolean = false,
val query: String = "",
val searchSelectionId: Long = -1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) } }
Expand Down
7 changes: 7 additions & 0 deletions presentation/src/main/res/layout/compose_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,13 @@
android:layout_height="wrap_content"
tools:text="Moez Bhatti" />

<com.moez.QKSMS.common.widget.QkTextView
android:id="@+id/toolbarNumber"
style="@style/ToolbarText"
android:layout_height="wrap_content"
app:textSize="secondary"
tools:text="+12345678" />

<com.moez.QKSMS.common.widget.QkTextView
android:id="@+id/toolbarSubtitle"
style="@style/ToolbarText"
Expand Down