make the contact lists nicer, use colored avatars with letters
This commit is contained in:
parent
bff89317a3
commit
c7fda28544
|
@ -57,7 +57,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:5.25.17'
|
||||
implementation 'com.simplemobiletools:commons:5.25.18'
|
||||
implementation 'joda-time:joda-time:2.10.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
|
||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.5'
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.content.pm.ShortcutInfo
|
||||
import android.content.pm.ShortcutManager
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.Icon
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.simplemobiletools.contacts.pro.adapters
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.util.TypedValue
|
||||
import android.view.Menu
|
||||
import android.view.View
|
||||
|
@ -35,8 +35,6 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||
MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||
private val NEW_GROUP_ID = -1
|
||||
|
||||
private lateinit var contactDrawable: Drawable
|
||||
private lateinit var businessContactDrawable: Drawable
|
||||
private var config = activity.config
|
||||
private var textToHighlight = highlightText
|
||||
|
||||
|
@ -48,13 +46,8 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||
|
||||
private val itemLayout = if (showPhoneNumbers) R.layout.item_contact_with_number else R.layout.item_contact_without_number
|
||||
|
||||
private var smallPadding = activity.resources.getDimension(R.dimen.small_margin).toInt()
|
||||
private var mediumPadding = activity.resources.getDimension(R.dimen.medium_margin).toInt()
|
||||
private var bigPadding = activity.resources.getDimension(R.dimen.normal_margin).toInt()
|
||||
|
||||
init {
|
||||
setupDragListener(true)
|
||||
initDrawables()
|
||||
}
|
||||
|
||||
override fun getActionMenuId() = R.menu.cab
|
||||
|
@ -122,11 +115,6 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||
|
||||
private fun getItemWithKey(key: Int): Contact? = contactItems.firstOrNull { it.id == key }
|
||||
|
||||
fun initDrawables() {
|
||||
contactDrawable = activity.resources.getColoredDrawableWithColor(R.drawable.ic_person_vector, textColor)
|
||||
businessContactDrawable = activity.resources.getColoredDrawableWithColor(R.drawable.ic_business_vector, textColor)
|
||||
}
|
||||
|
||||
fun updateItems(newItems: ArrayList<Contact>, highlightText: String = "") {
|
||||
if (newItems.hashCode() != contactItems.hashCode()) {
|
||||
contactItems = newItems.clone() as ArrayList<Contact>
|
||||
|
@ -286,11 +274,6 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||
|
||||
contact_name.setTextColor(textColor)
|
||||
contact_name.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
||||
if (!showContactThumbnails && !showPhoneNumbers) {
|
||||
contact_name.setPadding(bigPadding, bigPadding, bigPadding, bigPadding)
|
||||
} else {
|
||||
contact_name.setPadding(if (showContactThumbnails) smallPadding else bigPadding, smallPadding, smallPadding, 0)
|
||||
}
|
||||
|
||||
if (contact_number != null) {
|
||||
val phoneNumberToUse = if (textToHighlight.isEmpty()) {
|
||||
|
@ -302,14 +285,13 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||
val numberText = phoneNumberToUse?.value ?: ""
|
||||
contact_number.text = if (textToHighlight.isEmpty()) numberText else numberText.highlightTextPart(textToHighlight, adjustedPrimaryColor, false, true)
|
||||
contact_number.setTextColor(textColor)
|
||||
contact_number.setPadding(if (showContactThumbnails) smallPadding else bigPadding, 0, smallPadding, 0)
|
||||
contact_number.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
||||
}
|
||||
|
||||
contact_tmb.beVisibleIf(showContactThumbnails)
|
||||
|
||||
if (showContactThumbnails) {
|
||||
val placeholderImage = if (contact.isABusinessContact()) businessContactDrawable else contactDrawable
|
||||
val placeholderImage = BitmapDrawable(resources, context.getContactLetterIcon(fullName))
|
||||
when {
|
||||
contact.photoUri.isNotEmpty() -> {
|
||||
val options = RequestOptions()
|
||||
|
@ -324,7 +306,6 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||
.apply(options)
|
||||
.apply(RequestOptions.circleCropTransform())
|
||||
.into(contact_tmb)
|
||||
contact_tmb.setPadding(smallPadding, smallPadding, smallPadding, smallPadding)
|
||||
}
|
||||
contact.photo != null -> {
|
||||
val options = RequestOptions()
|
||||
|
@ -339,10 +320,8 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||
.apply(options)
|
||||
.apply(RequestOptions.circleCropTransform())
|
||||
.into(contact_tmb)
|
||||
contact_tmb.setPadding(smallPadding, smallPadding, smallPadding, smallPadding)
|
||||
}
|
||||
else -> {
|
||||
contact_tmb.setPadding(mediumPadding, mediumPadding, mediumPadding, mediumPadding)
|
||||
contact_tmb.setImageDrawable(placeholderImage)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,6 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||
this is GroupsFragment -> (fragment_list.adapter as GroupsAdapter).updateTextColor(color)
|
||||
else -> (fragment_list.adapter as ContactsAdapter).apply {
|
||||
updateTextColor(color)
|
||||
initDrawables()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,11 @@
|
|||
android:id="@+id/contact_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/medium_margin"
|
||||
android:minHeight="@dimen/min_row_height"
|
||||
android:paddingStart="@dimen/tiny_margin"
|
||||
android:paddingTop="@dimen/normal_margin"
|
||||
android:paddingEnd="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/medium_margin">
|
||||
android:paddingBottom="@dimen/normal_margin">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/contact_tmb"
|
||||
|
@ -23,7 +25,7 @@
|
|||
android:layout_height="@dimen/normal_icon_size"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="@dimen/small_margin"
|
||||
android:padding="@dimen/medium_margin"
|
||||
android:padding="@dimen/tiny_margin"
|
||||
android:src="@drawable/ic_person_vector" />
|
||||
|
||||
<TextView
|
||||
|
@ -33,6 +35,8 @@
|
|||
android:layout_toEndOf="@+id/contact_tmb"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:paddingEnd="@dimen/activity_margin"
|
||||
android:textSize="@dimen/big_text_size"
|
||||
tools:text="John Doe" />
|
||||
|
||||
|
@ -45,6 +49,8 @@
|
|||
android:layout_toEndOf="@+id/contact_tmb"
|
||||
android:alpha="0.6"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:paddingEnd="@dimen/activity_margin"
|
||||
android:textSize="@dimen/big_text_size"
|
||||
tools:text="0123 456 789" />
|
||||
|
||||
|
|
|
@ -13,9 +13,11 @@
|
|||
android:id="@+id/contact_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/small_margin"
|
||||
android:minHeight="@dimen/min_row_height"
|
||||
android:paddingStart="@dimen/tiny_margin"
|
||||
android:paddingTop="@dimen/medium_margin"
|
||||
android:paddingEnd="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/small_margin">
|
||||
android:paddingBottom="@dimen/medium_margin">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/contact_tmb"
|
||||
|
@ -23,7 +25,7 @@
|
|||
android:layout_height="@dimen/normal_icon_size"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="@dimen/small_margin"
|
||||
android:padding="@dimen/medium_margin"
|
||||
android:padding="@dimen/tiny_margin"
|
||||
android:src="@drawable/ic_person_vector" />
|
||||
|
||||
<TextView
|
||||
|
@ -35,6 +37,8 @@
|
|||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:paddingEnd="@dimen/activity_margin"
|
||||
android:textSize="@dimen/big_text_size"
|
||||
tools:text="John Doe" />
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<dimen name="contact_photo_size">88dp</dimen>
|
||||
<dimen name="contact_actions_size">48dp</dimen>
|
||||
<dimen name="contact_icons_size">40dp</dimen>
|
||||
<dimen name="min_row_height">60dp</dimen>
|
||||
<dimen name="dialpad_button_size">60dp</dimen>
|
||||
|
||||
<dimen name="dialpad_text_size">34sp</dimen>
|
||||
|
|
Loading…
Reference in New Issue