mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-24 23:27:40 +01:00
correcting the Edit screens top action button positions
This commit is contained in:
parent
d7f4dcd656
commit
4dab8d0740
@ -19,9 +19,7 @@ import com.bumptech.glide.request.RequestOptions
|
|||||||
import com.bumptech.glide.request.target.Target
|
import com.bumptech.glide.request.target.Target
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
import com.simplemobiletools.commons.extensions.getContrastColor
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.extensions.getNameLetter
|
|
||||||
import com.simplemobiletools.commons.extensions.realScreenSize
|
|
||||||
import com.simplemobiletools.commons.helpers.letterBackgroundColors
|
import com.simplemobiletools.commons.helpers.letterBackgroundColors
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
@ -43,29 +41,35 @@ abstract class ContactActivity : SimpleActivity() {
|
|||||||
contact?.photo = null
|
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
|
currentContactPhotoPath = path
|
||||||
val options = RequestOptions()
|
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
|
||||||
.centerCrop()
|
|
||||||
|
|
||||||
if (isDestroyed || isFinishing) {
|
if (isDestroyed || isFinishing) {
|
||||||
return
|
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)
|
Glide.with(this)
|
||||||
.load(bitmap ?: path)
|
.load(bitmap ?: path)
|
||||||
.transition(DrawableTransitionOptions.withCrossFade())
|
.transition(DrawableTransitionOptions.withCrossFade())
|
||||||
.apply(options)
|
.apply(options)
|
||||||
.apply(RequestOptions.circleCropTransform())
|
.override(wantedWidth, wantedHeight)
|
||||||
.listener(object : RequestListener<Drawable> {
|
.listener(object : RequestListener<Drawable> {
|
||||||
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
|
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
|
||||||
photoView.background = ColorDrawable(0)
|
photoView.background = ColorDrawable(0)
|
||||||
|
bottomShadow.beVisible()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
|
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
|
||||||
showPhotoPlaceholder(photoView)
|
showPhotoPlaceholder(photoView)
|
||||||
|
bottomShadow.beGone()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}).into(photoView)
|
}).into(photoView)
|
||||||
|
@ -108,7 +108,7 @@ class EditContactActivity : ContactActivity() {
|
|||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
when (requestCode) {
|
when (requestCode) {
|
||||||
INTENT_TAKE_PHOTO, INTENT_CHOOSE_PHOTO -> startCropPhotoIntent(lastPhotoIntentUri, resultData?.data)
|
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) {
|
if (contact!!.photoUri.isEmpty() && contact!!.photo == null) {
|
||||||
showPhotoPlaceholder(contact_photo)
|
showPhotoPlaceholder(contact_photo)
|
||||||
|
contact_photo_bottom_shadow.beGone()
|
||||||
} else {
|
} else {
|
||||||
updateContactPhoto(contact!!.photoUri, contact_photo, contact!!.photo)
|
updateContactPhoto(contact!!.photoUri, contact_photo, contact_photo_bottom_shadow, contact!!.photo)
|
||||||
}
|
}
|
||||||
|
|
||||||
val textColor = config.textColor
|
val textColor = config.textColor
|
||||||
|
@ -3,20 +3,11 @@ package com.simplemobiletools.contacts.pro.activities
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.ColorDrawable
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.graphics.drawable.Drawable
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.ContactsContract
|
import android.provider.ContactsContract
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.widget.RelativeLayout
|
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.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.CONTACT_ID
|
import com.simplemobiletools.commons.helpers.CONTACT_ID
|
||||||
@ -179,38 +170,7 @@ class ViewContactActivity : ContactActivity() {
|
|||||||
showPhotoPlaceholder(contact_photo)
|
showPhotoPlaceholder(contact_photo)
|
||||||
contact_photo_bottom_shadow.beGone()
|
contact_photo_bottom_shadow.beGone()
|
||||||
} else {
|
} else {
|
||||||
val path = contact!!.photoUri
|
updateContactPhoto(contact!!.photoUri, contact_photo, contact_photo_bottom_shadow, contact!!.photo)
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val textColor = config.textColor
|
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()
|
if (contact_prefix.isGone() && contact_first_name.isGone() && contact_middle_name.isGone() && contact_surname.isGone() && contact_suffix.isGone()
|
||||||
&& contact_nickname.isGone()) {
|
&& contact_nickname.isGone()) {
|
||||||
contact_name_image.beInvisible()
|
contact_name_image.beInvisible()
|
||||||
(contact_photo.layoutParams as RelativeLayout.LayoutParams).bottomMargin = resources.getDimension(R.dimen.medium_margin).toInt()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,27 +16,30 @@
|
|||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/contact_holder"
|
android:id="@+id/contact_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
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">
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/contact_photo"
|
android:id="@+id/contact_photo"
|
||||||
android:layout_width="@dimen/contact_photo_size"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/contact_photo_size"
|
android:layout_height="@dimen/top_contact_image_height"
|
||||||
android:layout_marginBottom="@dimen/normal_margin" />
|
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
|
<ImageView
|
||||||
android:id="@+id/contact_toggle_favorite"
|
android:id="@+id/contact_toggle_favorite"
|
||||||
android:layout_width="@dimen/contact_actions_size"
|
android:layout_width="@dimen/contact_actions_size"
|
||||||
android:layout_height="@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_alignBottom="@id/contact_photo"
|
||||||
android:layout_marginStart="@dimen/medium_margin"
|
android:layout_margin="@dimen/medium_margin"
|
||||||
android:layout_toEndOf="@+id/contact_photo"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:background="?attr/selectableItemBackgroundBorderless"
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
android:padding="@dimen/tiny_margin"
|
android:padding="@dimen/tiny_margin"
|
||||||
android:src="@drawable/ic_star_off_vector" />
|
android:src="@drawable/ic_star_off_vector" />
|
||||||
@ -47,7 +50,9 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignTop="@+id/contact_photo"
|
android:layout_alignTop="@+id/contact_photo"
|
||||||
android:layout_alignBottom="@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
|
<ImageView
|
||||||
android:id="@+id/contact_send_email"
|
android:id="@+id/contact_send_email"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/contact_wrapper"
|
android:id="@+id/contact_wrapper"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
@ -22,7 +23,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/top_contact_image_height"
|
android:layout_height="@dimen/top_contact_image_height"
|
||||||
android:layout_marginBottom="@dimen/normal_margin"
|
android:layout_marginBottom="@dimen/normal_margin"
|
||||||
android:src="@drawable/ic_person_vector" />
|
tools:src="@drawable/ic_person_vector" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/contact_photo_bottom_shadow"
|
android:id="@+id/contact_photo_bottom_shadow"
|
||||||
@ -39,6 +40,7 @@
|
|||||||
android:layout_alignStart="@+id/contact_photo"
|
android:layout_alignStart="@+id/contact_photo"
|
||||||
android:layout_alignBottom="@id/contact_photo"
|
android:layout_alignBottom="@id/contact_photo"
|
||||||
android:layout_margin="@dimen/medium_margin"
|
android:layout_margin="@dimen/medium_margin"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
android:padding="@dimen/tiny_margin"
|
android:padding="@dimen/tiny_margin"
|
||||||
android:src="@drawable/ic_star_off_vector"
|
android:src="@drawable/ic_star_off_vector"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user