From 4a0e552f738741a9d93314c9c8ab380660324226 Mon Sep 17 00:00:00 2001 From: Mehdi Date: Fri, 20 Aug 2021 20:18:29 +0430 Subject: [PATCH 1/2] Show confirmation dialog before deleting message. --- .../moez/QKSMS/feature/compose/ComposeActivity.kt | 11 +++++++++++ .../com/moez/QKSMS/feature/compose/ComposeView.kt | 2 ++ .../moez/QKSMS/feature/compose/ComposeViewModel.kt | 14 +++++++++++--- presentation/src/main/res/values/strings.xml | 4 ++++ 4 files changed, 28 insertions(+), 3 deletions(-) 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..0ceff0d3a 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 @@ -115,6 +115,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView { override val sendIntent by lazy { send.clicks() } override val viewQksmsPlusIntent: Subject = PublishSubject.create() override val backPressedIntent: Subject = PublishSubject.create() + override val confirmDeleteIntent: Subject> = 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) { + 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) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt index d8a78eec2..166ae49a2 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt @@ -55,6 +55,7 @@ interface ComposeView : QkView { val sendIntent: Observable val viewQksmsPlusIntent: Subject val backPressedIntent: Observable + val confirmDeleteIntent: Observable> fun clearSelection() fun showDetails(details: String) @@ -71,5 +72,6 @@ interface ComposeView : QkView { fun setDraft(draft: String) fun scrollToMessage(id: Long) fun showQksmsPlusSnackbar(@StringRes message: Int) + fun showDeleteDialog( messages: List) } \ No newline at end of file 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..960471915 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 @@ -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? { diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 2c7e1b838..31cbb0820 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -92,6 +92,10 @@ Are you sure you would like to delete this conversation? Are you sure you would like to delete %d conversations? + + Are you sure you would like to delete this message? + Are you sure you would like to delete %d messages? + Copy text From 881df4ad9ac18a68bef1d0363ed5ba1043392086 Mon Sep 17 00:00:00 2001 From: Mehdi Date: Sat, 21 Aug 2021 01:21:06 +0430 Subject: [PATCH 2/2] Fix misdisplaying mobile numbers in RTL mode. --- presentation/src/main/res/layout/blocked_list_item.xml | 3 ++- presentation/src/main/res/layout/blocked_number_list_item.xml | 3 ++- presentation/src/main/res/layout/chip_input_list_item.xml | 3 ++- presentation/src/main/res/layout/compose_activity.xml | 3 ++- presentation/src/main/res/layout/contact_chip.xml | 3 ++- presentation/src/main/res/layout/contact_chip_detailed.xml | 3 ++- presentation/src/main/res/layout/contact_number_list_item.xml | 3 ++- presentation/src/main/res/layout/contacts_activity.xml | 3 ++- .../src/main/res/layout/conversation_info_controller.xml | 3 ++- presentation/src/main/res/layout/conversation_list_item.xml | 3 ++- 10 files changed, 20 insertions(+), 10 deletions(-) diff --git a/presentation/src/main/res/layout/blocked_list_item.xml b/presentation/src/main/res/layout/blocked_list_item.xml index a70b945eb..b53a0cfc7 100644 --- a/presentation/src/main/res/layout/blocked_list_item.xml +++ b/presentation/src/main/res/layout/blocked_list_item.xml @@ -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" /> + tools:text="(123) 456-7890" + android:textDirection="ltr" /> \ No newline at end of file + app:textSize="primary" + android:textDirection="ltr" /> \ No newline at end of file diff --git a/presentation/src/main/res/layout/compose_activity.xml b/presentation/src/main/res/layout/compose_activity.xml index 19900e0ad..b6805b879 100644 --- a/presentation/src/main/res/layout/compose_activity.xml +++ b/presentation/src/main/res/layout/compose_activity.xml @@ -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" /> + tools:text="Moez Bhatti" + android:textDirection="ltr" /> diff --git a/presentation/src/main/res/layout/contact_chip_detailed.xml b/presentation/src/main/res/layout/contact_chip_detailed.xml index 786e160fd..fa4c08f34 100755 --- a/presentation/src/main/res/layout/contact_chip_detailed.xml +++ b/presentation/src/main/res/layout/contact_chip_detailed.xml @@ -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" /> + tools:text="(123) 456-7890" + android:textDirection="ltr" /> \ No newline at end of file diff --git a/presentation/src/main/res/layout/contacts_activity.xml b/presentation/src/main/res/layout/contacts_activity.xml index 3ded424f1..1c21ded70 100644 --- a/presentation/src/main/res/layout/contacts_activity.xml +++ b/presentation/src/main/res/layout/contacts_activity.xml @@ -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" /> + android:paddingBottom="8dp" + android:textDirection="ltr" /> diff --git a/presentation/src/main/res/layout/conversation_list_item.xml b/presentation/src/main/res/layout/conversation_list_item.xml index 70e1a2526..cc7f94819 100644 --- a/presentation/src/main/res/layout/conversation_list_item.xml +++ b/presentation/src/main/res/layout/conversation_list_item.xml @@ -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" />