correcting the Edit screens top action button positions

This commit is contained in:
tibbi 2020-10-26 16:26:43 +01:00
parent d7f4dcd656
commit 4dab8d0740
5 changed files with 37 additions and 66 deletions

View File

@ -19,9 +19,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.getContrastColor
import com.simplemobiletools.commons.extensions.getNameLetter
import com.simplemobiletools.commons.extensions.realScreenSize
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.letterBackgroundColors
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.contacts.pro.R
@ -43,29 +41,35 @@ abstract class ContactActivity : SimpleActivity() {
contact?.photo = null
}
fun updateContactPhoto(path: String, photoView: ImageView, bitmap: Bitmap? = null) {
fun updateContactPhoto(path: String, photoView: ImageView, bottomShadow: ImageView, bitmap: Bitmap? = null) {
currentContactPhotoPath = path
val options = RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.centerCrop()
if (isDestroyed || isFinishing) {
return
}
val options = RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.centerCrop()
val wantedWidth = realScreenSize.x
val wantedHeight = resources.getDimension(R.dimen.top_contact_image_height).toInt()
Glide.with(this)
.load(bitmap ?: path)
.transition(DrawableTransitionOptions.withCrossFade())
.apply(options)
.apply(RequestOptions.circleCropTransform())
.override(wantedWidth, wantedHeight)
.listener(object : RequestListener<Drawable> {
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
photoView.background = ColorDrawable(0)
bottomShadow.beVisible()
return false
}
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
showPhotoPlaceholder(photoView)
bottomShadow.beGone()
return true
}
}).into(photoView)

View File

@ -108,7 +108,7 @@ class EditContactActivity : ContactActivity() {
if (resultCode == RESULT_OK) {
when (requestCode) {
INTENT_TAKE_PHOTO, INTENT_CHOOSE_PHOTO -> startCropPhotoIntent(lastPhotoIntentUri, resultData?.data)
INTENT_CROP_PHOTO -> updateContactPhoto(lastPhotoIntentUri.toString(), contact_photo)
INTENT_CROP_PHOTO -> updateContactPhoto(lastPhotoIntentUri.toString(), contact_photo, contact_photo_bottom_shadow)
}
}
}
@ -196,8 +196,9 @@ class EditContactActivity : ContactActivity() {
if (contact!!.photoUri.isEmpty() && contact!!.photo == null) {
showPhotoPlaceholder(contact_photo)
contact_photo_bottom_shadow.beGone()
} else {
updateContactPhoto(contact!!.photoUri, contact_photo, contact!!.photo)
updateContactPhoto(contact!!.photoUri, contact_photo, contact_photo_bottom_shadow, contact!!.photo)
}
val textColor = config.textColor

View File

@ -3,20 +3,11 @@ package com.simplemobiletools.contacts.pro.activities
import android.content.Intent
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.provider.ContactsContract
import android.view.View
import android.view.WindowManager
import android.widget.RelativeLayout
import com.bumptech.glide.Glide
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.Target
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.CONTACT_ID
@ -179,38 +170,7 @@ class ViewContactActivity : ContactActivity() {
showPhotoPlaceholder(contact_photo)
contact_photo_bottom_shadow.beGone()
} else {
val path = contact!!.photoUri
currentContactPhotoPath = path
if (isDestroyed || isFinishing) {
return
}
val options = RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.centerCrop()
val wantedWidth = realScreenSize.x
val wantedHeight = resources.getDimension(R.dimen.top_contact_image_height).toInt()
Glide.with(this)
.load(contact!!.photo ?: path)
.transition(DrawableTransitionOptions.withCrossFade())
.apply(options)
.override(wantedWidth, wantedHeight)
.listener(object : RequestListener<Drawable> {
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
contact_photo.background = ColorDrawable(0)
contact_photo_bottom_shadow.beVisible()
return false
}
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
showPhotoPlaceholder(contact_photo)
contact_photo_bottom_shadow.beGone()
return true
}
}).into(contact_photo)
updateContactPhoto(contact!!.photoUri, contact_photo, contact_photo_bottom_shadow, contact!!.photo)
}
val textColor = config.textColor
@ -325,7 +285,6 @@ class ViewContactActivity : ContactActivity() {
if (contact_prefix.isGone() && contact_first_name.isGone() && contact_middle_name.isGone() && contact_surname.isGone() && contact_suffix.isGone()
&& contact_nickname.isGone()) {
contact_name_image.beInvisible()
(contact_photo.layoutParams as RelativeLayout.LayoutParams).bottomMargin = resources.getDimension(R.dimen.medium_margin).toInt()
}
}
}

View File

@ -16,27 +16,30 @@
<RelativeLayout
android:id="@+id/contact_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingEnd="@dimen/normal_margin"
android:paddingBottom="@dimen/medium_margin">
android:layout_height="wrap_content">
<ImageView
android:id="@+id/contact_photo"
android:layout_width="@dimen/contact_photo_size"
android:layout_height="@dimen/contact_photo_size"
android:layout_marginBottom="@dimen/normal_margin" />
android:layout_width="match_parent"
android:layout_height="@dimen/top_contact_image_height"
android:layout_marginBottom="@dimen/normal_margin"
tools:src="@drawable/ic_person_vector" />
<ImageView
android:id="@+id/contact_photo_bottom_shadow"
android:layout_width="match_parent"
android:layout_height="@dimen/top_shadow_height"
android:layout_alignBottom="@+id/contact_photo"
android:background="@drawable/gradient_background"
android:contentDescription="@null" />
<ImageView
android:id="@+id/contact_toggle_favorite"
android:layout_width="@dimen/contact_actions_size"
android:layout_height="@dimen/contact_actions_size"
android:layout_alignTop="@+id/contact_photo"
android:layout_alignStart="@+id/contact_photo"
android:layout_alignBottom="@id/contact_photo"
android:layout_marginStart="@dimen/medium_margin"
android:layout_toEndOf="@+id/contact_photo"
android:adjustViewBounds="true"
android:layout_margin="@dimen/medium_margin"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="@dimen/tiny_margin"
android:src="@drawable/ic_star_off_vector" />
@ -47,7 +50,9 @@
android:layout_height="wrap_content"
android:layout_alignTop="@+id/contact_photo"
android:layout_alignBottom="@id/contact_photo"
android:gravity="center_vertical|end">
android:gravity="bottom|end"
android:paddingEnd="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin">
<ImageView
android:id="@+id/contact_send_email"

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/contact_wrapper"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -22,7 +23,7 @@
android:layout_width="match_parent"
android:layout_height="@dimen/top_contact_image_height"
android:layout_marginBottom="@dimen/normal_margin"
android:src="@drawable/ic_person_vector" />
tools:src="@drawable/ic_person_vector" />
<ImageView
android:id="@+id/contact_photo_bottom_shadow"
@ -39,6 +40,7 @@
android:layout_alignStart="@+id/contact_photo"
android:layout_alignBottom="@id/contact_photo"
android:layout_margin="@dimen/medium_margin"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="@dimen/tiny_margin"
android:src="@drawable/ic_star_off_vector"
android:visibility="gone" />