Skip to content

Commit cf7bc3b

Browse files
committed
update primary color at Search selection if it changes
1 parent d9133ca commit cf7bc3b

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ ext {
4545
}
4646

4747
dependencies {
48-
implementation 'com.simplemobiletools:commons:3.19.3'
48+
implementation 'com.simplemobiletools:commons:3.19.4'
4949
implementation 'joda-time:joda-time:2.9.9'
5050
implementation 'com.facebook.stetho:stetho:1.5.0'
5151

app/src/main/kotlin/com/simplemobiletools/contacts/adapters/ContactsAdapter.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ import com.bumptech.glide.signature.ObjectKey
1212
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
1313
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
1414
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
15-
import com.simplemobiletools.commons.extensions.beVisibleIf
16-
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
17-
import com.simplemobiletools.commons.extensions.highlightTextPart
18-
import com.simplemobiletools.commons.extensions.isActivityDestroyed
15+
import com.simplemobiletools.commons.extensions.*
1916
import com.simplemobiletools.commons.models.RadioItem
2017
import com.simplemobiletools.commons.views.FastScroller
2118
import com.simplemobiletools.commons.views.MyRecyclerView
@@ -38,6 +35,8 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
3835
private lateinit var contactDrawable: Drawable
3936
private var config = activity.config
4037
private var textToHighlight = ""
38+
39+
var adjustedPrimaryColor = activity.getAdjustedPrimaryColor()
4140
var startNameWithSurname: Boolean
4241
var showContactThumbnails: Boolean
4342
var showPhoneNumbers: Boolean
@@ -250,14 +249,14 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
250249
private fun setupView(view: View, contact: Contact) {
251250
view.apply {
252251
val fullName = contact.getFullName()
253-
val nameText = if (textToHighlight.isEmpty()) fullName else fullName.highlightTextPart(textToHighlight, primaryColor)
252+
val nameText = if (textToHighlight.isEmpty()) fullName else fullName.highlightTextPart(textToHighlight, adjustedPrimaryColor)
254253
contact_name.text = nameText
255254
contact_name.setTextColor(textColor)
256255
contact_name.setPadding(if (showContactThumbnails) smallPadding else bigPadding, smallPadding, smallPadding, 0)
257256

258257
if (contact_number != null) {
259258
val numberText = contact.phoneNumbers.firstOrNull()?.value ?: ""
260-
contact_number.text = if (textToHighlight.isEmpty()) numberText else numberText.highlightTextPart(textToHighlight, primaryColor)
259+
contact_number.text = if (textToHighlight.isEmpty()) numberText else numberText.highlightTextPart(textToHighlight, adjustedPrimaryColor)
261260
contact_number.setTextColor(textColor)
262261
contact_number.setPadding(if (showContactThumbnails) smallPadding else bigPadding, 0, smallPadding, 0)
263262
}

app/src/main/kotlin/com/simplemobiletools/contacts/fragments/MyViewPagerFragment.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
7474
fun primaryColorChanged() {
7575
fragment_fastscroller.updatePrimaryColor()
7676
fragment_fastscroller.updateBubblePrimaryColor()
77+
(fragment_list.adapter as? ContactsAdapter)?.apply {
78+
adjustedPrimaryColor = context.getAdjustedPrimaryColor()
79+
}
7780
}
7881

7982
fun startNameWithSurnameChanged(startNameWithSurname: Boolean) {

0 commit comments

Comments
 (0)