diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ContactActivity.kt index 076d476c..43666a47 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ContactActivity.kt @@ -1,11 +1,14 @@ package com.simplemobiletools.contacts.pro.activities import android.graphics.Bitmap +import android.graphics.Canvas +import android.graphics.Paint import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.ColorDrawable import android.graphics.drawable.Drawable import android.provider.ContactsContract.CommonDataKinds.* import android.widget.ImageView +import android.widget.TextView import com.bumptech.glide.Glide import com.bumptech.glide.load.DataSource import com.bumptech.glide.load.engine.DiskCacheStrategy @@ -16,7 +19,10 @@ import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.target.Target import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.RadioGroupDialog -import com.simplemobiletools.commons.helpers.SimpleContactsHelper +import com.simplemobiletools.commons.extensions.getContrastColor +import com.simplemobiletools.commons.extensions.getNameLetter +import com.simplemobiletools.commons.extensions.realScreenSize +import com.simplemobiletools.commons.helpers.letterBackgroundColors import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.extensions.sendEmailIntent @@ -31,7 +37,7 @@ abstract class ContactActivity : SimpleActivity() { protected var currentContactPhotoPath = "" fun showPhotoPlaceholder(photoView: ImageView) { - val placeholder = BitmapDrawable(resources, SimpleContactsHelper(this).getContactLetterIcon(contact?.getNameToDisplay() ?: "A")) + val placeholder = BitmapDrawable(resources, getBigLetterPlaceholder(contact?.getNameToDisplay() ?: "A")) photoView.setImageDrawable(placeholder) currentContactPhotoPath = "" contact?.photo = null @@ -158,4 +164,35 @@ abstract class ContactActivity : SimpleActivity() { Event.TYPE_BIRTHDAY -> R.string.birthday else -> R.string.other } + + private fun getBigLetterPlaceholder(name: String): Bitmap { + val letter = name.getNameLetter() + val height = resources.getDimension(R.dimen.top_contact_image_height).toInt() + val bitmap = Bitmap.createBitmap(realScreenSize.x, height, Bitmap.Config.ARGB_8888) + val canvas = Canvas(bitmap) + val view = TextView(this) + view.layout(0, 0, bitmap.width, bitmap.height) + + val circlePaint = Paint().apply { + color = letterBackgroundColors[Math.abs(name.hashCode()) % letterBackgroundColors.size].toInt() + isAntiAlias = true + style = Paint.Style.FILL + } + + val wantedTextSize = bitmap.height / 2f + val textPaint = Paint().apply { + color = circlePaint.color.getContrastColor() + isAntiAlias = true + textAlign = Paint.Align.CENTER + textSize = wantedTextSize + } + + canvas.drawPaint(circlePaint) + + val xPos = canvas.width / 2f + val yPos = canvas.height / 2 - (textPaint.descent() + textPaint.ascent()) / 2 + canvas.drawText(letter, xPos, yPos, textPaint) + view.draw(canvas) + return bitmap + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt index 5b84ebcf..67623864 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt @@ -202,7 +202,6 @@ class ViewContactActivity : ContactActivity() { override fun onResourceReady(resource: Drawable?, model: Any?, target: Target?, dataSource: DataSource?, isFirstResource: Boolean): Boolean { contact_photo.background = ColorDrawable(0) contact_photo_bottom_shadow.beVisible() - contact_photo_divider.beInvisible() return false } diff --git a/app/src/main/res/layout/activity_edit_contact.xml b/app/src/main/res/layout/activity_edit_contact.xml index 48e1425b..f24bd75e 100644 --- a/app/src/main/res/layout/activity_edit_contact.xml +++ b/app/src/main/res/layout/activity_edit_contact.xml @@ -1,10 +1,10 @@ - + android:layout_marginBottom="@dimen/normal_margin" /> + android:src="@drawable/ic_star_off_vector" /> + android:src="@drawable/ic_email_vector" /> + android:src="@drawable/ic_phone_vector" /> + android:src="@drawable/ic_sms_vector" /> @@ -88,7 +88,7 @@ android:paddingTop="@dimen/medium_margin" android:paddingEnd="@dimen/small_margin" android:paddingBottom="@dimen/small_margin" - android:src="@drawable/ic_person_vector"/> + android:src="@drawable/ic_person_vector" /> + android:textSize="@dimen/bigger_text_size" /> + android:textSize="@dimen/bigger_text_size" /> + android:textSize="@dimen/bigger_text_size" /> + android:textSize="@dimen/bigger_text_size" /> + android:textSize="@dimen/bigger_text_size" /> + android:textSize="@dimen/bigger_text_size" /> + android:src="@drawable/ic_phone_vector" /> - + @@ -221,7 +221,7 @@ android:paddingTop="@dimen/medium_margin" android:paddingEnd="@dimen/activity_margin" android:paddingBottom="@dimen/medium_margin" - android:src="@drawable/ic_plus_vector"/> + android:src="@drawable/ic_plus_vector" /> + android:src="@drawable/ic_email_vector" /> - + @@ -257,7 +257,7 @@ android:paddingTop="@dimen/medium_margin" android:paddingEnd="@dimen/activity_margin" android:paddingBottom="@dimen/medium_margin" - android:src="@drawable/ic_plus_vector"/> + android:src="@drawable/ic_plus_vector" /> + android:src="@drawable/ic_place_vector" /> - + @@ -294,7 +294,7 @@ android:paddingTop="@dimen/medium_margin" android:paddingEnd="@dimen/activity_margin" android:paddingBottom="@dimen/medium_margin" - android:src="@drawable/ic_plus_vector"/> + android:src="@drawable/ic_plus_vector" /> + android:src="@drawable/ic_im" /> - + @@ -331,7 +331,7 @@ android:paddingTop="@dimen/medium_margin" android:paddingEnd="@dimen/activity_margin" android:paddingBottom="@dimen/medium_margin" - android:src="@drawable/ic_plus_vector"/> + android:src="@drawable/ic_plus_vector" /> + android:src="@drawable/ic_cake_vector" /> - + @@ -368,7 +368,7 @@ android:paddingTop="@dimen/medium_margin" android:paddingEnd="@dimen/activity_margin" android:paddingBottom="@dimen/medium_margin" - android:src="@drawable/ic_plus_vector"/> + android:src="@drawable/ic_plus_vector" /> + android:src="@drawable/ic_label_vector" /> + android:textSize="@dimen/bigger_text_size" /> + android:src="@drawable/ic_business_vector" /> + android:textSize="@dimen/bigger_text_size" /> + android:textSize="@dimen/bigger_text_size" /> + android:src="@drawable/ic_link_vector" /> - + @@ -468,7 +468,7 @@ android:paddingTop="@dimen/medium_margin" android:paddingEnd="@dimen/activity_margin" android:paddingBottom="@dimen/medium_margin" - android:src="@drawable/ic_plus_vector"/> + android:src="@drawable/ic_plus_vector" /> + android:src="@drawable/ic_people_vector" /> - + @@ -505,7 +505,7 @@ android:paddingTop="@dimen/medium_margin" android:paddingEnd="@dimen/activity_margin" android:paddingBottom="@dimen/medium_margin" - android:src="@drawable/ic_plus_vector"/> + android:src="@drawable/ic_plus_vector" /> + android:src="@drawable/ic_account_box_vector" /> + tools:text="hello@simplemobiletools.com" /> diff --git a/app/src/main/res/layout/activity_view_contact.xml b/app/src/main/res/layout/activity_view_contact.xml index b4b0cc44..6d6280de 100644 --- a/app/src/main/res/layout/activity_view_contact.xml +++ b/app/src/main/res/layout/activity_view_contact.xml @@ -9,6 +9,7 @@ android:id="@+id/contact_scrollview" android:layout_width="match_parent" android:layout_height="wrap_content" + android:scrollbars="none" android:visibility="gone"> - -