Skip to content

Commit

Permalink
implements #94
Browse files Browse the repository at this point in the history
On tab switch, the search string is not deleted and immedeatly applied to the selected tab
  • Loading branch information
Honk2 committed Jul 21, 2024
1 parent 0598a1c commit a29f8cb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
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()).replace(' ', '1')
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,18 @@ class ContactsAdapter(
if (name.contains(textToHighlight, true)) {
name.highlightTextPart(textToHighlight, properPrimaryColor)
} else {
name.highlightTextFromNumbers(textToHighlight.replace('1', ' '), properPrimaryColor)
val strippedName = PhoneNumberUtils.convertKeypadLettersToDigits(name.filterNot { it.isWhitespace() })
val startIndex = strippedName.indexOf(textToHighlight)

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

name.highlightTextFromNumbers(textToHighlight, properPrimaryColor)
}
}
}
Expand Down
9 changes: 0 additions & 9 deletions app/src/main/res/layout/dialpad.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="1" />

<org.fossify.commons.views.MyTextView
android:id="@+id/dialpad_1_letters"
style="@style/DialpadLetterStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/dialpad_1"
android:layout_marginBottom="@dimen/small_margin"
android:text="\u2423" />
</RelativeLayout>

<RelativeLayout
Expand Down

0 comments on commit a29f8cb

Please sign in to comment.