From 83e14173ac74f1a0c348ee02a5c4f87ba1ed09ba Mon Sep 17 00:00:00 2001 From: Narinder Rana Date: Wed, 30 Mar 2022 16:01:57 +0530 Subject: [PATCH 1/3] restricted to add empty text field --- .../numbers/BlockedNumbersController.kt | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersController.kt b/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersController.kt index 7b1cbb93c..fd2f57924 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersController.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersController.kt @@ -20,6 +20,8 @@ package com.moez.QKSMS.feature.blocking.numbers import android.view.LayoutInflater import android.view.View +import android.widget.Button +import android.widget.Toast import androidx.appcompat.app.AlertDialog import androidx.core.content.ContextCompat import com.jakewharton.rxbinding2.view.clicks @@ -38,11 +40,14 @@ import kotlinx.android.synthetic.main.blocked_numbers_controller.* import javax.inject.Inject class BlockedNumbersController : QkController(), - BlockedNumbersView { + BlockedNumbersView { - @Inject override lateinit var presenter: BlockedNumbersPresenter - @Inject lateinit var colors: Colors - @Inject lateinit var phoneNumberUtils: PhoneNumberUtils + @Inject + override lateinit var presenter: BlockedNumbersPresenter + @Inject + lateinit var colors: Colors + @Inject + lateinit var phoneNumberUtils: PhoneNumberUtils private val adapter = BlockedNumbersAdapter() private val saveAddressSubject: Subject = PublishSubject.create() @@ -80,11 +85,20 @@ class BlockedNumbersController : QkController - saveAddressSubject.onNext(layout.input.text.toString()) + if (!layout.input.text.toString().isEmpty()) { + saveAddressSubject.onNext(layout.input.text.toString()) + } else { + Toast.makeText(activity, "Not able to add empty text ! please try again", Toast.LENGTH_LONG).show() + } } .setNegativeButton(R.string.button_cancel) { _, _ -> } .setOnDismissListener { textWatcher.dispose() } - dialog.show() + dialog.show(); + + + +// +// } } -- GitLab From d3104ea3dfcae060e6bbfd00404c11567cd7d927 Mon Sep 17 00:00:00 2001 From: Narinder Rana Date: Wed, 30 Mar 2022 16:19:03 +0530 Subject: [PATCH 2/3] refine code --- .../feature/blocking/numbers/BlockedNumbersController.kt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersController.kt b/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersController.kt index fd2f57924..e32943d95 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersController.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersController.kt @@ -94,11 +94,6 @@ class BlockedNumbersController : QkController } .setOnDismissListener { textWatcher.dispose() } dialog.show(); - - - -// -// } } -- GitLab From 4256e1bc16928a73b8b2ac596adebb2041312f75 Mon Sep 17 00:00:00 2001 From: Narinder Rana Date: Wed, 30 Mar 2022 16:32:19 +0530 Subject: [PATCH 3/3] refine code as feedback --- .../feature/blocking/numbers/BlockedNumbersController.kt | 6 +++--- presentation/src/main/res/values/strings.xml | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersController.kt b/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersController.kt index e32943d95..83f7bfe70 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersController.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersController.kt @@ -85,15 +85,15 @@ class BlockedNumbersController : QkController - if (!layout.input.text.toString().isEmpty()) { + if (!layout.input.text.toString().trim().isEmpty()) { saveAddressSubject.onNext(layout.input.text.toString()) } else { - Toast.makeText(activity, "Not able to add empty text ! please try again", Toast.LENGTH_LONG).show() + Toast.makeText(activity, R.string.not_able_to_add_empty_text, Toast.LENGTH_LONG).show() } } .setNegativeButton(R.string.button_cancel) { _, _ -> } .setOnDismissListener { textWatcher.dispose() } - dialog.show(); + dialog.show() } } diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 3eba897cb..954a81429 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -502,4 +502,5 @@ Share some love and rate us on Google Play! OKAY! DISMISS + Not able to add empty text ! please try again -- GitLab