Skip to content

Commit

Permalink
Allow manual blocking of non-numeric addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
moezbhatti committed Nov 28, 2019
1 parent 6bd8480 commit a83901a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Expand Up @@ -32,16 +32,21 @@ class BlockedNumberTextWatcher(
editText.addTextChangedListener(this)
}

override fun afterTextChanged(s: Editable?) = Unit

override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) = Unit
override fun afterTextChanged(s: Editable?) {
editText.removeTextChangedListener(this)

override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
val formatted = s?.let(phoneNumberUtils::formatNumber)
if (s?.toString() != formatted && formatted != null) {
editText.setText(formatted)
editText.setSelection(formatted.length)
}

editText.addTextChangedListener(this)
}

override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) = Unit

override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}

fun dispose() {
Expand Down
Expand Up @@ -39,7 +39,6 @@
android:layout_height="wrap_content"
android:background="@null"
android:hint="@string/blocked_numbers_dialog_hint"
android:inputType="phone"
android:paddingStart="24dp"
android:paddingTop="16dp"
android:paddingEnd="24dp"
Expand Down

0 comments on commit a83901a

Please sign in to comment.