use circular photos at the edit and view screens too

This commit is contained in:
tibbi 2019-03-07 15:45:54 +01:00
parent 11fac47ae7
commit 4345bb7a9e
4 changed files with 18 additions and 4 deletions

View file

@ -15,6 +15,7 @@ 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.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.getColoredBitmap
import com.simplemobiletools.commons.extensions.getContrastColor
import com.simplemobiletools.commons.models.RadioItem
@ -32,6 +33,10 @@ abstract class ContactActivity : SimpleActivity() {
protected var currentContactPhotoPath = ""
fun showPhotoPlaceholder(photoView: ImageView) {
val background = resources.getDrawable(R.drawable.contact_circular_background)
background.applyColorFilter(config.primaryColor)
photoView.background = background
val placeholder = resources.getColoredBitmap(R.drawable.ic_person, config.primaryColor.getContrastColor())
val padding = resources.getDimension(R.dimen.activity_margin).toInt()
photoView.setPadding(padding, padding, padding, padding)

View file

@ -6,7 +6,6 @@ import android.content.ClipData
import android.content.ContentValues
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.drawable.ColorDrawable
import android.net.Uri
import android.os.Bundle
import android.provider.ContactsContract.CommonDataKinds
@ -195,7 +194,9 @@ class EditContactActivity : ContactActivity() {
contact_start_call.beVisibleIf(contact!!.phoneNumbers.isNotEmpty())
contact_send_email.beVisibleIf(contact!!.emails.isNotEmpty())
contact_photo.background = ColorDrawable(config.primaryColor)
val background = resources.getDrawable(R.drawable.contact_circular_background)
background.applyColorFilter(config.primaryColor)
contact_photo.background = background
if (contact!!.photoUri.isEmpty() && contact!!.photo == null) {
showPhotoPlaceholder(contact_photo)

View file

@ -1,7 +1,6 @@
package com.simplemobiletools.contacts.pro.activities
import android.content.Intent
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.provider.ContactsContract
import android.view.Menu
@ -133,7 +132,9 @@ class ViewContactActivity : ContactActivity() {
contact_start_call.beVisibleIf(contact!!.phoneNumbers.isNotEmpty())
contact_send_email.beVisibleIf(contact!!.emails.isNotEmpty())
contact_photo.background = ColorDrawable(config.primaryColor)
val background = resources.getDrawable(R.drawable.contact_circular_background)
background.applyColorFilter(config.primaryColor)
contact_photo.background = background
if (contact!!.photoUri.isEmpty() && contact!!.photo == null) {
showPhotoPlaceholder(contact_photo)

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/color_primary"/>
</shape>