create a separate activity for viewing contact details, without editing

This commit is contained in:
tibbi 2018-02-10 21:19:34 +01:00
parent 02850c99b6
commit 32a9fa6884
14 changed files with 766 additions and 23 deletions

View File

@ -45,7 +45,7 @@ ext {
}
dependencies {
implementation 'com.simplemobiletools:commons:3.11.2'
implementation 'com.simplemobiletools:commons:3.11.3'
implementation 'joda-time:joda-time:2.9.9'
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"

View File

@ -74,6 +74,11 @@
android:label="@string/settings"
android:parentActivityName=".activities.MainActivity"/>
<activity
android:name=".activities.ViewContactActivity"
android:label="@string/details"
android:parentActivityName=".activities.MainActivity"/>
<activity
android:name=".activities.EditContactActivity"
android:parentActivityName=".activities.MainActivity">

View File

@ -39,9 +39,9 @@ import com.simplemobiletools.contacts.models.Email
import com.simplemobiletools.contacts.models.Event
import com.simplemobiletools.contacts.models.PhoneNumber
import kotlinx.android.synthetic.main.activity_edit_contact.*
import kotlinx.android.synthetic.main.item_email.view.*
import kotlinx.android.synthetic.main.item_edit_email.view.*
import kotlinx.android.synthetic.main.item_edit_phone_number.view.*
import kotlinx.android.synthetic.main.item_event.view.*
import kotlinx.android.synthetic.main.item_phone_number.view.*
import org.joda.time.DateTime
import org.joda.time.format.DateTimeFormat
import java.text.DateFormat
@ -88,7 +88,7 @@ class EditContactActivity : SimpleActivity() {
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_contact, menu)
menuInflater.inflate(R.menu.menu_edit_contact, menu)
if (wasActivityInitialized) {
menu.findItem(R.id.delete).isVisible = contact?.id != 0
menu.findItem(R.id.share).isVisible = contact?.id != 0
@ -244,11 +244,11 @@ class EditContactActivity : SimpleActivity() {
contact!!.phoneNumbers.forEachIndexed { index, number ->
var numberHolder = contact_numbers_holder.getChildAt(index)
if (numberHolder == null) {
numberHolder = layoutInflater.inflate(R.layout.item_phone_number, contact_numbers_holder, false)
numberHolder = layoutInflater.inflate(R.layout.item_edit_phone_number, contact_numbers_holder, false)
contact_numbers_holder.addView(numberHolder)
}
(numberHolder as? ViewGroup)?.apply {
numberHolder!!.apply {
contact_number.setText(number.value)
setupPhoneNumberTypePicker(contact_number_type, number.type)
}
@ -259,11 +259,11 @@ class EditContactActivity : SimpleActivity() {
contact!!.emails.forEachIndexed { index, email ->
var emailHolder = contact_emails_holder.getChildAt(index)
if (emailHolder == null) {
emailHolder = layoutInflater.inflate(R.layout.item_email, contact_emails_holder, false)
emailHolder = layoutInflater.inflate(R.layout.item_edit_email, contact_emails_holder, false)
contact_emails_holder.addView(emailHolder)
}
(emailHolder as? ViewGroup)?.apply {
emailHolder!!.apply {
contact_email.setText(email.value)
setupEmailTypePicker(contact_email_type, email.type)
}
@ -278,7 +278,7 @@ class EditContactActivity : SimpleActivity() {
contact_events_holder.addView(eventHolder)
}
(eventHolder as? ViewGroup)?.apply {
(eventHolder as ViewGroup).apply {
val contactEvent = contact_event.apply {
getDateTime(event.value, this)
tag = event.value
@ -609,7 +609,7 @@ class EditContactActivity : SimpleActivity() {
}
private fun addNewPhoneNumberField() {
val numberHolder = layoutInflater.inflate(R.layout.item_phone_number, contact_numbers_holder, false) as ViewGroup
val numberHolder = layoutInflater.inflate(R.layout.item_edit_phone_number, contact_numbers_holder, false) as ViewGroup
updateTextColors(numberHolder)
setupPhoneNumberTypePicker(numberHolder.contact_number_type)
contact_numbers_holder.addView(numberHolder)
@ -620,7 +620,7 @@ class EditContactActivity : SimpleActivity() {
}
private fun addNewEmailField() {
val emailHolder = layoutInflater.inflate(R.layout.item_email, contact_emails_holder, false) as ViewGroup
val emailHolder = layoutInflater.inflate(R.layout.item_edit_email, contact_emails_holder, false) as ViewGroup
updateTextColors(emailHolder)
setupEmailTypePicker(emailHolder.contact_email_type)
contact_emails_holder.addView(emailHolder)

View File

@ -0,0 +1,401 @@
package com.simplemobiletools.contacts.activities
import android.content.Intent
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.provider.ContactsContract
import android.provider.ContactsContract.CommonDataKinds
import android.view.Menu
import android.view.MenuItem
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.RelativeLayout
import android.widget.TextView
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.RadioGroupDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
import com.simplemobiletools.commons.helpers.getDateFormats
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.contacts.R
import com.simplemobiletools.contacts.extensions.*
import com.simplemobiletools.contacts.helpers.*
import com.simplemobiletools.contacts.models.Contact
import kotlinx.android.synthetic.main.activity_view_contact.*
import kotlinx.android.synthetic.main.item_event.view.*
import kotlinx.android.synthetic.main.item_view_email.view.*
import kotlinx.android.synthetic.main.item_view_phone_number.view.*
import org.joda.time.DateTime
import org.joda.time.format.DateTimeFormat
import java.text.DateFormat
import java.text.SimpleDateFormat
import java.util.*
class ViewContactActivity : SimpleActivity() {
private var currentContactPhotoPath = ""
private var contact: Contact? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_view_contact)
handlePermission(PERMISSION_READ_CONTACTS) {
if (it) {
initContact()
} else {
toast(R.string.no_contacts_permission)
finish()
}
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_view_contact, menu)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.edit -> editContact()
R.id.share -> shareContact()
R.id.delete -> deleteContact()
else -> return super.onOptionsItemSelected(item)
}
return true
}
private fun initContact() {
var contactId = intent.getIntExtra(CONTACT_ID, 0)
val action = intent.action
if (contactId == 0 && (action == ContactsContract.QuickContact.ACTION_QUICK_CONTACT || action == Intent.ACTION_VIEW)) {
val data = intent.data
if (data != null) {
val rawId = if (data.path.contains("lookup")) {
getLookupUriRawId(data)
} else {
getContactUriRawId(data)
}
if (rawId != -1) {
contactId = rawId
}
}
}
if (contactId != 0) {
contact = ContactsHelper(this).getContactWithId(contactId)
if (contact == null) {
toast(R.string.unknown_error_occurred)
finish()
return
}
}
if (contact == null) {
finish()
return
}
setupEditContact()
setupTypePickers()
contact_send_sms.beVisibleIf(contact!!.phoneNumbers.isNotEmpty())
contact_start_call.beVisibleIf(contact!!.phoneNumbers.isNotEmpty())
contact_send_email.beVisibleIf(contact!!.emails.isNotEmpty())
contact_photo.background = ColorDrawable(config.primaryColor)
if (contact!!.photoUri.isEmpty()) {
showPhotoPlaceholder()
} else {
updateContactPhoto(contact!!.photoUri)
}
val textColor = config.textColor
contact_send_sms.applyColorFilter(textColor)
contact_start_call.applyColorFilter(textColor)
contact_send_email.applyColorFilter(textColor)
contact_name_image.applyColorFilter(textColor)
contact_number_image.applyColorFilter(textColor)
contact_email_image.applyColorFilter(textColor)
contact_event_image.applyColorFilter(textColor)
contact_source_image.applyColorFilter(textColor)
contact_send_sms.setOnClickListener { trySendSMS() }
contact_start_call.setOnClickListener { tryStartCall(contact!!) }
contact_send_email.setOnClickListener { trySendEmail() }
updateTextColors(contact_scrollview)
invalidateOptionsMenu()
}
private fun setupEditContact() {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
contact!!.apply {
contact_first_name.text = firstName
contact_first_name.beVisibleIf(firstName.isNotEmpty())
contact_middle_name.text = middleName
contact_middle_name.beVisibleIf(middleName.isNotEmpty())
contact_surname.text = surname
contact_surname.beVisibleIf(surname.isNotEmpty())
if (firstName.isEmpty() && middleName.isEmpty() && surname.isEmpty()) {
contact_name_image.beInvisible()
(contact_photo.layoutParams as RelativeLayout.LayoutParams).bottomMargin = resources.getDimension(R.dimen.medium_margin).toInt()
}
contact_source.text = getPublicContactSource(source)
}
contact_toggle_favorite.apply {
beVisible()
setImageDrawable(getStarDrawable(contact!!.starred == 1))
tag = contact!!.starred
applyColorFilter(config.textColor)
}
setupPhoneNumbers()
setupEmails()
setupEvents()
}
private fun setupPhoneNumbers() {
val phoneNumbers = contact!!.phoneNumbers
phoneNumbers.forEachIndexed { index, number ->
var numberHolder = contact_numbers_holder.getChildAt(index)
if (numberHolder == null) {
numberHolder = layoutInflater.inflate(R.layout.item_view_phone_number, contact_numbers_holder, false)
contact_numbers_holder.addView(numberHolder)
}
numberHolder?.apply {
contact_number.text = number.value
setupPhoneNumberTypePicker(contact_number_type, number.type)
}
}
contact_number_image.beVisibleIf(phoneNumbers.isNotEmpty())
contact_numbers_holder.beVisibleIf(phoneNumbers.isNotEmpty())
}
private fun setupEmails() {
val emails = contact!!.emails
emails.forEachIndexed { index, email ->
var emailHolder = contact_emails_holder.getChildAt(index)
if (emailHolder == null) {
emailHolder = layoutInflater.inflate(R.layout.item_view_email, contact_emails_holder, false)
contact_emails_holder.addView(emailHolder)
}
emailHolder?.apply {
contact_email.text = email.value
setupEmailTypePicker(contact_email_type, email.type)
}
}
contact_email_image.beVisibleIf(emails.isNotEmpty())
contact_emails_holder.beVisibleIf(emails.isNotEmpty())
}
private fun setupEvents() {
val events = contact!!.events
events.forEachIndexed { index, event ->
var eventHolder = contact_events_holder.getChildAt(index)
if (eventHolder == null) {
eventHolder = layoutInflater.inflate(R.layout.item_event, contact_events_holder, false)
contact_events_holder.addView(eventHolder)
}
(eventHolder as? ViewGroup)?.apply {
contact_event.apply {
getDateTime(event.value, this)
tag = event.value
alpha = 1f
}
setupEventTypePicker(this, event.type)
contact_event_remove.beGone()
}
}
contact_event_image.beVisibleIf(events.isNotEmpty())
contact_events_holder.beVisibleIf(events.isNotEmpty())
}
private fun editContact() {
Intent(applicationContext, EditContactActivity::class.java).apply {
putExtra(CONTACT_ID, contact!!.id)
startActivity(this)
}
}
private fun shareContact() {
shareContacts(arrayListOf(contact!!))
}
private fun showPhotoPlaceholder() {
val placeholder = resources.getColoredBitmap(R.drawable.ic_person, config.primaryColor.getContrastColor())
val padding = resources.getDimension(R.dimen.activity_margin).toInt()
contact_photo.setPadding(padding, padding, padding, padding)
contact_photo.setImageBitmap(placeholder)
currentContactPhotoPath = ""
}
private fun updateContactPhoto(path: String) {
currentContactPhotoPath = path
val options = RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.centerCrop()
Glide.with(this)
.load(path)
.transition(DrawableTransitionOptions.withCrossFade())
.apply(options)
.listener(object : RequestListener<Drawable> {
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
contact_photo.setPadding(0, 0, 0, 0)
return false
}
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
showPhotoPlaceholder()
return true
}
}).into(contact_photo)
}
private fun setupTypePickers() {
if (contact!!.phoneNumbers.isEmpty()) {
val numberHolder = contact_numbers_holder.getChildAt(0)
(numberHolder as? ViewGroup)?.contact_number_type?.apply {
setupPhoneNumberTypePicker(this)
}
}
if (contact!!.emails.isEmpty()) {
val emailHolder = contact_emails_holder.getChildAt(0)
(emailHolder as? ViewGroup)?.contact_email_type?.apply {
setupEmailTypePicker(this)
}
}
if (contact!!.events.isEmpty()) {
val eventHolder = contact_events_holder.getChildAt(0)
(eventHolder as? ViewGroup)?.apply {
setupEventTypePicker(this)
}
}
}
private fun setupPhoneNumberTypePicker(numberTypeField: TextView, type: Int = DEFAULT_PHONE_NUMBER_TYPE) {
numberTypeField.setText(getPhoneNumberTextId(type))
}
private fun setupEmailTypePicker(emailTypeField: TextView, type: Int = DEFAULT_EMAIL_TYPE) {
emailTypeField.setText(getEmailTextId(type))
}
private fun setupEventTypePicker(eventHolder: ViewGroup, type: Int = DEFAULT_EVENT_TYPE) {
eventHolder.contact_event_type.setText(getEventTextId(type))
}
private fun getDateTime(dateString: String, viewToUpdate: TextView? = null): DateTime {
val dateFormats = getDateFormats()
var date = DateTime()
for (format in dateFormats) {
try {
date = DateTime.parse(dateString, DateTimeFormat.forPattern(format))
val formatter = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.getDefault())
var localPattern = (formatter as SimpleDateFormat).toLocalizedPattern()
val hasYear = format.contains("y")
if (!hasYear) {
localPattern = localPattern.replace("y", "").trim()
date = date.withYear(DateTime().year)
}
val formattedString = date.toString(localPattern)
viewToUpdate?.text = formattedString
break
} catch (ignored: Exception) {
}
}
return date
}
private fun deleteContact() {
ConfirmationDialog(this) {
ContactsHelper(this).deleteContact(contact!!)
finish()
}
}
private fun getStarDrawable(on: Boolean) = resources.getDrawable(if (on) R.drawable.ic_star_on_big else R.drawable.ic_star_off_big)
private fun trySendSMS() {
val numbers = contact!!.phoneNumbers
if (numbers.size == 1) {
sendSMSIntent(numbers.first().value)
} else if (numbers.size > 1) {
val items = ArrayList<RadioItem>()
numbers.forEachIndexed { index, phoneNumber ->
items.add(RadioItem(index, phoneNumber.value, phoneNumber.value))
}
RadioGroupDialog(this, items) {
sendSMSIntent(it as String)
}
}
}
private fun trySendEmail() {
val emails = contact!!.emails
if (emails.size == 1) {
sendEmailIntent(emails.first().value)
} else if (emails.size > 1) {
val items = ArrayList<RadioItem>()
emails.forEachIndexed { index, email ->
items.add(RadioItem(index, email.value, email.value))
}
RadioGroupDialog(this, items) {
sendEmailIntent(it as String)
}
}
}
private fun getPhoneNumberTextId(type: Int) = when (type) {
CommonDataKinds.Phone.TYPE_MOBILE -> R.string.mobile
CommonDataKinds.Phone.TYPE_HOME -> R.string.home
CommonDataKinds.Phone.TYPE_WORK -> R.string.work
CommonDataKinds.Phone.TYPE_MAIN -> R.string.main_number
CommonDataKinds.Phone.TYPE_FAX_WORK -> R.string.work_fax
CommonDataKinds.Phone.TYPE_FAX_HOME -> R.string.home_fax
CommonDataKinds.Phone.TYPE_PAGER -> R.string.pager
else -> R.string.other
}
private fun getEmailTextId(type: Int) = when (type) {
CommonDataKinds.Email.TYPE_HOME -> R.string.home
CommonDataKinds.Email.TYPE_WORK -> R.string.work
CommonDataKinds.Email.TYPE_MOBILE -> R.string.mobile
else -> R.string.other
}
private fun getEventTextId(type: Int) = when (type) {
CommonDataKinds.Event.TYPE_BIRTHDAY -> R.string.birthday
CommonDataKinds.Event.TYPE_ANNIVERSARY -> R.string.anniversary
else -> R.string.other
}
}

View File

@ -13,7 +13,7 @@ import com.simplemobiletools.commons.extensions.getIntValue
import com.simplemobiletools.commons.extensions.isLollipopPlus
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.contacts.BuildConfig
import com.simplemobiletools.contacts.activities.EditContactActivity
import com.simplemobiletools.contacts.activities.ViewContactActivity
import com.simplemobiletools.contacts.helpers.CONTACT_ID
import com.simplemobiletools.contacts.helpers.Config
import com.simplemobiletools.contacts.models.Contact
@ -22,7 +22,7 @@ import java.io.File
val Context.config: Config get() = Config.newInstance(applicationContext)
fun Context.openContact(contact: Contact) {
Intent(applicationContext, EditContactActivity::class.java).apply {
Intent(applicationContext, ViewContactActivity::class.java).apply {
putExtra(CONTACT_ID, contact.id)
startActivity(this)
}

View File

@ -10,7 +10,10 @@
android:id="@+id/contact_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/activity_margin">
android:paddingBottom="@dimen/medium_margin"
android:paddingLeft="@dimen/normal_margin"
android:paddingRight="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin">
<ImageView
android:id="@+id/contact_photo"
@ -155,7 +158,7 @@
android:layout_toRightOf="@+id/contact_number_image"
android:orientation="vertical">
<include layout="@layout/item_phone_number"/>
<include layout="@layout/item_edit_phone_number"/>
</LinearLayout>
@ -193,7 +196,7 @@
android:layout_toRightOf="@+id/contact_name_image"
android:orientation="vertical">
<include layout="@layout/item_email"/>
<include layout="@layout/item_edit_email"/>
</LinearLayout>

View File

@ -0,0 +1,239 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/contact_scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/contact_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_margin"
android:paddingLeft="@dimen/normal_margin"
android:paddingRight="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin">
<ImageView
android:id="@+id/contact_photo"
android:layout_width="@dimen/contact_photo_size"
android:layout_height="@dimen/contact_photo_size"/>
<ImageView
android:id="@+id/contact_toggle_favorite"
style="@style/MyBorderlessBackgroundStyle"
android:layout_width="@dimen/contact_actions_size"
android:layout_height="@dimen/contact_actions_size"
android:layout_alignBottom="@id/contact_photo"
android:layout_alignTop="@+id/contact_photo"
android:layout_marginLeft="@dimen/medium_margin"
android:layout_toRightOf="@+id/contact_photo"
android:adjustViewBounds="true"
android:padding="@dimen/tiny_margin"
android:src="@drawable/ic_star_off_big"
android:visibility="gone"/>
<LinearLayout
android:id="@+id/contact_actions_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/contact_photo"
android:layout_alignTop="@+id/contact_photo"
android:gravity="center_vertical|right">
<ImageView
android:id="@+id/contact_send_email"
style="@style/MyBorderlessBackgroundStyle"
android:layout_width="@dimen/contact_actions_size"
android:layout_height="@dimen/contact_actions_size"
android:adjustViewBounds="true"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:scaleType="center"
android:src="@drawable/ic_email"/>
<ImageView
android:id="@+id/contact_start_call"
style="@style/MyBorderlessBackgroundStyle"
android:layout_width="@dimen/contact_actions_size"
android:layout_height="@dimen/contact_actions_size"
android:layout_marginLeft="@dimen/normal_margin"
android:adjustViewBounds="true"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:scaleType="center"
android:src="@drawable/ic_phone"/>
<ImageView
android:id="@+id/contact_send_sms"
style="@style/MyBorderlessBackgroundStyle"
android:layout_width="@dimen/contact_actions_size"
android:layout_height="@dimen/contact_actions_size"
android:layout_marginLeft="@dimen/normal_margin"
android:adjustViewBounds="true"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:scaleType="center"
android:src="@drawable/ic_sms"/>
</LinearLayout>
<ImageView
android:id="@+id/contact_name_image"
android:layout_width="@dimen/contact_icons_size"
android:layout_height="@dimen/contact_icons_size"
android:layout_alignTop="@+id/contact_first_name"
android:paddingBottom="@dimen/small_margin"
android:paddingEnd="@dimen/small_margin"
android:paddingRight="@dimen/small_margin"
android:paddingTop="@dimen/medium_margin"
android:src="@drawable/ic_person"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/contact_first_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/contact_photo"
android:layout_centerVertical="true"
android:layout_marginTop="@dimen/normal_margin"
android:layout_toRightOf="@+id/contact_name_image"
android:lines="1"
android:maxLines="1"
android:paddingBottom="@dimen/normal_margin"
android:paddingLeft="@dimen/small_margin"
android:paddingTop="@dimen/normal_margin"
android:singleLine="true"
android:textSize="@dimen/bigger_text_size"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/contact_middle_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/contact_first_name"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/contact_name_image"
android:lines="1"
android:maxLines="1"
android:paddingBottom="@dimen/normal_margin"
android:paddingLeft="@dimen/small_margin"
android:paddingTop="@dimen/normal_margin"
android:singleLine="true"
android:textSize="@dimen/bigger_text_size"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/contact_surname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/contact_middle_name"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/contact_name_image"
android:lines="1"
android:maxLines="1"
android:paddingBottom="@dimen/normal_margin"
android:paddingLeft="@dimen/small_margin"
android:paddingTop="@dimen/normal_margin"
android:singleLine="true"
android:textSize="@dimen/bigger_text_size"/>
<ImageView
android:id="@+id/contact_number_image"
android:layout_width="@dimen/contact_icons_size"
android:layout_height="@dimen/contact_icons_size"
android:layout_alignTop="@+id/contact_numbers_holder"
android:paddingBottom="@dimen/small_margin"
android:paddingEnd="@dimen/small_margin"
android:paddingRight="@dimen/small_margin"
android:paddingTop="@dimen/medium_margin"
android:src="@drawable/ic_phone"/>
<LinearLayout
android:id="@+id/contact_numbers_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/contact_surname"
android:layout_toRightOf="@+id/contact_number_image"
android:orientation="vertical"
android:paddingLeft="@dimen/small_margin">
<include layout="@layout/item_view_phone_number"/>
</LinearLayout>
<ImageView
android:id="@+id/contact_email_image"
android:layout_width="@dimen/contact_icons_size"
android:layout_height="@dimen/contact_icons_size"
android:layout_alignTop="@+id/contact_emails_holder"
android:paddingBottom="@dimen/small_margin"
android:paddingEnd="@dimen/small_margin"
android:paddingRight="@dimen/small_margin"
android:paddingTop="@dimen/medium_margin"
android:src="@drawable/ic_email"/>
<LinearLayout
android:id="@+id/contact_emails_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/contact_numbers_holder"
android:layout_toRightOf="@+id/contact_name_image"
android:orientation="vertical"
android:paddingLeft="@dimen/small_margin">
<include layout="@layout/item_view_email"/>
</LinearLayout>
<ImageView
android:id="@+id/contact_event_image"
android:layout_width="@dimen/contact_icons_size"
android:layout_height="@dimen/contact_icons_size"
android:layout_alignTop="@+id/contact_events_holder"
android:paddingBottom="@dimen/small_margin"
android:paddingEnd="@dimen/small_margin"
android:paddingRight="@dimen/small_margin"
android:paddingTop="@dimen/medium_margin"
android:src="@drawable/ic_cake"/>
<LinearLayout
android:id="@+id/contact_events_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/contact_emails_holder"
android:layout_toRightOf="@+id/contact_name_image"
android:orientation="vertical">
<include layout="@layout/item_event"/>
</LinearLayout>
<ImageView
android:id="@+id/contact_source_image"
android:layout_width="@dimen/contact_icons_size"
android:layout_height="@dimen/contact_icons_size"
android:layout_alignTop="@+id/contact_source"
android:paddingBottom="@dimen/small_margin"
android:paddingEnd="@dimen/small_margin"
android:paddingRight="@dimen/small_margin"
android:paddingTop="@dimen/medium_margin"
android:src="@drawable/ic_account_box"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/contact_source"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/contact_events_holder"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/contact_name_image"
android:background="?attr/selectableItemBackground"
android:lines="1"
android:maxLines="1"
android:paddingBottom="@dimen/normal_margin"
android:paddingLeft="@dimen/small_margin"
android:paddingTop="@dimen/normal_margin"
android:singleLine="true"
android:textSize="@dimen/bigger_text_size"
tools:text="hello@simplemobiletools.com"/>
</RelativeLayout>
</ScrollView>

View File

@ -15,8 +15,8 @@
android:alpha="0.5"
android:background="?attr/selectableItemBackground"
android:paddingBottom="@dimen/normal_margin"
android:paddingLeft="@dimen/medium_margin"
android:paddingRight="@dimen/medium_margin"
android:paddingLeft="@dimen/small_margin"
android:paddingRight="@dimen/small_margin"
android:paddingTop="@dimen/normal_margin"
android:text="@string/unknown"
android:textSize="@dimen/bigger_text_size"/>

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/contact_email_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/contact_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/contact_email_type"
android:layout_toStartOf="@+id/contact_email_type"
android:lines="1"
android:maxLines="1"
android:singleLine="true"
android:textSize="@dimen/bigger_text_size"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/contact_email_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/contact_email"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/contact_email"
android:layout_centerVertical="true"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:paddingLeft="@dimen/medium_margin"
android:paddingRight="@dimen/medium_margin"
android:text="@string/home"
android:textSize="@dimen/bigger_text_size"/>
</RelativeLayout>

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/contact_number_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/contact_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/contact_number_type"
android:layout_toStartOf="@+id/contact_number_type"
android:lines="1"
android:maxLines="1"
android:singleLine="true"
android:textSize="@dimen/bigger_text_size"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/contact_number_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/contact_number"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/contact_number"
android:layout_centerVertical="true"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:paddingLeft="@dimen/medium_margin"
android:paddingRight="@dimen/medium_margin"
android:text="@string/mobile"
android:textSize="@dimen/bigger_text_size"/>
</RelativeLayout>

View File

@ -6,14 +6,14 @@
android:icon="@drawable/ic_check"
android:title="@string/save"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/delete"
android:icon="@drawable/ic_delete"
android:title="@string/delete"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/share"
android:icon="@drawable/ic_share"
android:title="@string/share"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/delete"
android:icon="@drawable/ic_delete"
android:title="@string/delete"
app:showAsAction="ifRoom"/>
</menu>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/edit"
android:icon="@drawable/ic_rename"
android:title="@string/edit_contact"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/share"
android:icon="@drawable/ic_share"
android:title="@string/share"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/delete"
android:icon="@drawable/ic_delete"
android:title="@string/delete"
app:showAsAction="ifRoom"/>
</menu>