forked from upstream-mirrors/quik
@@ -115,6 +115,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
override val sendIntent by lazy { send.clicks() }
|
||||
override val viewQksmsPlusIntent: Subject<Unit> = PublishSubject.create()
|
||||
override val backPressedIntent: Subject<Unit> = PublishSubject.create()
|
||||
override val confirmDeleteIntent: Subject<List<Long>> = PublishSubject.create()
|
||||
|
||||
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[ComposeViewModel::class.java] }
|
||||
|
||||
@@ -349,6 +350,16 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
}
|
||||
}
|
||||
|
||||
override fun showDeleteDialog(messages: List<Long>) {
|
||||
val count = messages.size
|
||||
android.app.AlertDialog.Builder(this)
|
||||
.setTitle(R.string.dialog_delete_title)
|
||||
.setMessage(resources.getQuantityString(R.plurals.dialog_delete_chat, count, count))
|
||||
.setPositiveButton(R.string.button_delete) { _, _ -> confirmDeleteIntent.onNext(messages) }
|
||||
.setNegativeButton(R.string.button_cancel, null)
|
||||
.show()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
menuInflater.inflate(R.menu.compose, menu)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
|
||||
@@ -55,6 +55,7 @@ interface ComposeView : QkView<ComposeState> {
|
||||
val sendIntent: Observable<Unit>
|
||||
val viewQksmsPlusIntent: Subject<Unit>
|
||||
val backPressedIntent: Observable<Unit>
|
||||
val confirmDeleteIntent: Observable<List<Long>>
|
||||
|
||||
fun clearSelection()
|
||||
fun showDetails(details: String)
|
||||
@@ -71,5 +72,6 @@ interface ComposeView : QkView<ComposeState> {
|
||||
fun setDraft(draft: String)
|
||||
fun scrollToMessage(id: Long)
|
||||
fun showQksmsPlusSnackbar(@StringRes message: Int)
|
||||
fun showDeleteDialog( messages: List<Long>)
|
||||
|
||||
}
|
||||
@@ -340,15 +340,15 @@ class ComposeViewModel @Inject constructor(
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { view.showDetails(it) }
|
||||
|
||||
// Delete the messages
|
||||
// Show the delete message dialog
|
||||
view.optionsItemIntent
|
||||
.filter { it == R.id.delete }
|
||||
.filter { permissionManager.isDefaultSms().also { if (!it) view.requestDefaultSms() } }
|
||||
.withLatestFrom(view.messagesSelectedIntent, conversation) { _, messages, conversation ->
|
||||
deleteMessages.execute(DeleteMessages.Params(messages, conversation.id))
|
||||
view.showDeleteDialog(messages)
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { view.clearSelection() }
|
||||
.subscribe()
|
||||
|
||||
// Forward the message
|
||||
view.optionsItemIntent
|
||||
@@ -728,6 +728,14 @@ class ComposeViewModel @Inject constructor(
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
// Delete the message
|
||||
view.confirmDeleteIntent
|
||||
.withLatestFrom(view.messagesSelectedIntent, conversation) { _, messages, conversation ->
|
||||
deleteMessages.execute(DeleteMessages.Params(messages, conversation.id))
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { view.clearSelection() }
|
||||
|
||||
}
|
||||
|
||||
private fun getVCard(contactData: Uri): String? {
|
||||
|
||||
@@ -51,7 +51,8 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
app:textSize="primary"
|
||||
tools:text="@tools:sample/full_names" />
|
||||
tools:text="@tools:sample/full_names"
|
||||
android:textDirection="ltr" />
|
||||
|
||||
<com.moez.QKSMS.common.widget.QkTextView
|
||||
android:id="@+id/date"
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="24dp"
|
||||
tools:text="(123) 456-7890" />
|
||||
tools:text="(123) 456-7890"
|
||||
android:textDirection="ltr" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/unblock"
|
||||
|
||||
@@ -27,4 +27,5 @@
|
||||
android:privateImeOptions="nm"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textColorHint="?android:attr/textColorTertiary"
|
||||
app:textSize="primary" />
|
||||
app:textSize="primary"
|
||||
android:textDirection="ltr" />
|
||||
@@ -327,7 +327,8 @@
|
||||
android:id="@+id/toolbarTitle"
|
||||
style="@style/ToolbarText"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="Moez Bhatti" />
|
||||
tools:text="Moez Bhatti"
|
||||
android:textDirection="ltr" />
|
||||
|
||||
<com.moez.QKSMS.common.widget.QkTextView
|
||||
android:id="@+id/toolbarSubtitle"
|
||||
|
||||
@@ -48,7 +48,8 @@
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textStyle="bold"
|
||||
app:textSize="secondary"
|
||||
tools:text="Moez Bhatti" />
|
||||
tools:text="Moez Bhatti"
|
||||
android:textDirection="ltr" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -72,7 +72,8 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/name"
|
||||
app:textSize="secondary"
|
||||
tools:text="(123) 456-7890"
|
||||
tools:textColor="@color/textTertiaryDark" />
|
||||
tools:textColor="@color/textTertiaryDark"
|
||||
android:textDirection="ltr" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/delete"
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="?android:attr/textColorTertiary"
|
||||
app:textSize="secondary"
|
||||
tools:text="(123) 456-7890" />
|
||||
tools:text="(123) 456-7890"
|
||||
android:textDirection="ltr" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -40,7 +40,8 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar"
|
||||
tools:listitem="@layout/contact_list_item" />
|
||||
tools:listitem="@layout/contact_list_item"
|
||||
android:textDirection="ltr" />
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
|
||||
@@ -24,4 +24,5 @@
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp" />
|
||||
android:paddingBottom="8dp"
|
||||
android:textDirection="ltr" />
|
||||
|
||||
@@ -56,7 +56,8 @@
|
||||
app:layout_constraintStart_toEndOf="@id/avatars"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
tools:text="@tools:sample/full_names" />
|
||||
tools:text="@tools:sample/full_names"
|
||||
android:textDirection="ltr" />
|
||||
|
||||
<com.moez.QKSMS.common.widget.QkTextView
|
||||
android:id="@+id/snippet"
|
||||
|
||||
@@ -92,6 +92,10 @@
|
||||
<item quantity="one">Are you sure you would like to delete this conversation?</item>
|
||||
<item quantity="other">Are you sure you would like to delete %d conversations?</item>
|
||||
</plurals>
|
||||
<plurals name="dialog_delete_chat">
|
||||
<item quantity="one">Are you sure you would like to delete this message?</item>
|
||||
<item quantity="other">Are you sure you would like to delete %d messages?</item>
|
||||
</plurals>
|
||||
|
||||
<string-array name="message_options">
|
||||
<item>Copy text</item>
|
||||
|
||||
Reference in New Issue
Block a user