reworking the View contact UI a bit

This commit is contained in:
tibbi 2020-10-26 11:53:17 +01:00
parent a996a40f82
commit 516d847037
4 changed files with 71 additions and 25 deletions

View File

@ -57,7 +57,7 @@ android {
}
dependencies {
implementation 'com.simplemobiletools:commons:5.31.9'
implementation 'com.simplemobiletools:commons:5.31.10'
implementation 'joda-time:joda-time:2.10.1'
implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.5'
implementation 'com.github.tibbi:IndicatorFastScroll:08f512858a'

View File

@ -3,11 +3,20 @@ 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
@ -77,8 +86,8 @@ class ViewContactActivity : ContactActivity() {
}
private fun setupMenu() {
(activity_track_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
activity_track_toolbar.menu.apply {
(contact_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
contact_toolbar.menu.apply {
findItem(R.id.share).setOnMenuItemClickListener {
shareContact(fullContact!!)
true
@ -100,7 +109,7 @@ class ViewContactActivity : ContactActivity() {
}
}
activity_track_toolbar.setNavigationOnClickListener {
contact_toolbar.setNavigationOnClickListener {
finish()
}
}
@ -168,8 +177,40 @@ class ViewContactActivity : ContactActivity() {
if (contact!!.photoUri.isEmpty() && contact!!.photo == null) {
showPhotoPlaceholder(contact_photo)
contact_photo_bottom_shadow.beGone()
} else {
updateContactPhoto(contact!!.photoUri, contact_photo, contact!!.photo)
val path = contact!!.photoUri
currentContactPhotoPath = path
val options = RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.centerCrop()
if (isDestroyed || isFinishing) {
return
}
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
@ -184,7 +225,7 @@ class ViewContactActivity : ContactActivity() {
contact_send_email.setOnClickListener { trySendEmail() }
updateTextColors(contact_scrollview)
activity_track_toolbar.menu.findItem(R.id.open_with).isVisible = contact?.isPrivate() == false
contact_toolbar.menu.findItem(R.id.open_with).isVisible = contact?.isPrivate() == false
}
private fun setupViewContact() {

View File

@ -14,39 +14,43 @@
<RelativeLayout
android:id="@+id/contact_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingRight="@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"
android: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:background="?attr/selectableItemBackgroundBorderless"
android:layout_margin="@dimen/medium_margin"
android:padding="@dimen/tiny_margin"
android:src="@drawable/ic_star_off_vector"
android:visibility="gone" />
<LinearLayout
android:id="@+id/contact_actions_holder"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/contact_photo"
android:layout_alignEnd="@+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"
@ -428,7 +432,7 @@
</ScrollView>
<ImageView
android:id="@+id/activity_track_top_shadow"
android:id="@+id/contact_photo_top_shadow"
android:layout_width="match_parent"
android:layout_height="@dimen/top_shadow_height"
android:layout_alignParentTop="true"
@ -436,7 +440,7 @@
android:contentDescription="@null" />
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/activity_track_appbar"
android:id="@+id/contact_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
@ -445,7 +449,7 @@
app:elevation="0dp">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/activity_track_toolbar"
android:id="@+id/contact_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:menu="@menu/menu_view_contact"

View File

@ -4,4 +4,5 @@
<dimen name="contact_actions_size">48dp</dimen>
<dimen name="contact_icons_size">40dp</dimen>
<dimen name="dialpad_button_size">60dp</dimen>
<dimen name="top_contact_image_height">300dp</dimen>
</resources>