Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #139 ignore white space character for search with dialpad numbers #214

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class DialpadActivity : SimpleActivity() {
(binding.dialpadList.adapter as? ContactsAdapter)?.finishActMode()

val filtered = allContacts.filter {
var convertedName = PhoneNumberUtils.convertKeypadLettersToDigits(it.name.normalizeString())
var convertedName = PhoneNumberUtils.convertKeypadLettersToDigits(it.name.normalizeString()).filterNot { it.isWhitespace() }

if (hasRussianLocale) {
var currConvertedName = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.Intent
import android.content.pm.ShortcutInfo
import android.graphics.drawable.Icon
import android.net.Uri
import android.telephony.PhoneNumberUtils
import android.text.TextUtils
import android.util.TypedValue
import android.view.*
Expand Down Expand Up @@ -368,7 +369,19 @@ class ContactsAdapter(
if (name.contains(textToHighlight, true)) {
name.highlightTextPart(textToHighlight, properPrimaryColor)
} else {
name.highlightTextFromNumbers(textToHighlight, properPrimaryColor)
var spacedTextToHighlight = textToHighlight
val strippedName = PhoneNumberUtils.convertKeypadLettersToDigits(name.filterNot { it.isWhitespace() })
val startIndex = strippedName.indexOf(textToHighlight)

if ( strippedName.contains(textToHighlight)) {
for (i in 0..spacedTextToHighlight.length) {
if (name[startIndex+i].isWhitespace()) {
spacedTextToHighlight = spacedTextToHighlight.replaceRange(i, i, " ")
}
}
}

name.highlightTextFromNumbers(spacedTextToHighlight, properPrimaryColor)
}
}
}
Expand Down