mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-15 18:48:52 +01:00
Merge pull request #215 from gavine99/no_reply_for_non_numbers_94
disable reply ability to non-replyable messages/conversations
This commit is contained in:
@@ -40,6 +40,8 @@ import android.view.View
|
||||
import android.view.View.OnTouchListener
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
@@ -296,6 +298,26 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
|
||||
send.isEnabled = state.canSend
|
||||
send.imageAlpha = if (state.canSend) 255 else 128
|
||||
|
||||
// if not in editing mode, and there are no non-me participants that can be sent to,
|
||||
// hide controls that allow constructing a reply and inform user no valid recipients
|
||||
if (!state.editingMode && (state.validRecipientNumbers == 0)) {
|
||||
composeBar.visibility = View.GONE
|
||||
noValidRecipients.visibility = View.VISIBLE
|
||||
|
||||
// change constraint of messageList to constrain bottom to top of noValidRecipients
|
||||
val constraintLayout = findViewById<ConstraintLayout>(R.id.contentView)
|
||||
val constraintSet = ConstraintSet()
|
||||
constraintSet.clone(constraintLayout)
|
||||
constraintSet.connect(
|
||||
R.id.messageList,
|
||||
ConstraintSet.BOTTOM,
|
||||
R.id.noValidRecipients,
|
||||
ConstraintSet.TOP,
|
||||
0
|
||||
)
|
||||
constraintSet.applyTo(constraintLayout)
|
||||
}
|
||||
}
|
||||
|
||||
override fun clearSelection() = messageAdapter.clearSelection()
|
||||
|
||||
@@ -44,5 +44,6 @@ data class ComposeState(
|
||||
val attaching: Boolean = false,
|
||||
val remaining: String = "",
|
||||
val subscription: SubscriptionInfoCompat? = null,
|
||||
val canSend: Boolean = false
|
||||
val canSend: Boolean = false,
|
||||
val validRecipientNumbers: Int = 1,
|
||||
)
|
||||
@@ -207,6 +207,23 @@ class ComposeViewModel @Inject constructor(
|
||||
.filter { messages -> messages.isValid }
|
||||
.subscribe(searchResults::onNext)
|
||||
|
||||
// on conversation change/init, work out how many non-me participants of the conversation
|
||||
// have a valid address (subscriber number) for replying/sending to
|
||||
disposables += conversation
|
||||
.distinctUntilChanged { conversation -> conversation.id }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.map { conversation ->
|
||||
var possibleNumbers = 0
|
||||
conversation.recipients.forEach { recipient ->
|
||||
if (phoneNumberUtils.isPossibleNumber(recipient.address))
|
||||
++possibleNumbers
|
||||
}
|
||||
possibleNumbers
|
||||
}
|
||||
.subscribe { validRecipientNumbers ->
|
||||
newState { copy(validRecipientNumbers = validRecipientNumbers) }
|
||||
}
|
||||
|
||||
disposables += Observables.combineLatest(searchSelection, searchResults) { selected, messages ->
|
||||
if (selected == -1L) {
|
||||
messages.lastOrNull()?.let { message -> searchSelection.onNext(message.id) }
|
||||
|
||||
@@ -353,12 +353,14 @@
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
<View
|
||||
android:id="@+id/titleBarShadow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"
|
||||
android:background="@drawable/ab_shadow"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/divider"
|
||||
@@ -533,4 +535,18 @@
|
||||
tools:backgroundTint="@color/tools_theme"
|
||||
tools:tint="@color/textPrimaryDark" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noValidRecipients"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:gravity="center"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingBottom="12dp"
|
||||
android:text="@string/compose_no_valid_recipients"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -119,6 +119,7 @@
|
||||
<string name="compose_scheduled_plus">You must unlock QUIK+ to use scheduled messaging</string>
|
||||
<string name="compose_scheduled_toast">Added to scheduled messages</string>
|
||||
<string name="compose_hint">Write a message…</string>
|
||||
<string name="compose_no_valid_recipients">Can\'t send to other participants</string>
|
||||
<string name="compose_menu_copy">Copy text</string>
|
||||
<string name="compose_menu_forward">Forward</string>
|
||||
<string name="compose_menu_delete">Delete</string>
|
||||
|
||||
Reference in New Issue
Block a user