fix #82, allow pressing phone number, email, address on the View screen
This commit is contained in:
parent
1165550ef4
commit
4bd4513ad9
|
@ -166,9 +166,14 @@ class ViewContactActivity : ContactActivity() {
|
||||||
val phoneNumbers = contact!!.phoneNumbers
|
val phoneNumbers = contact!!.phoneNumbers
|
||||||
phoneNumbers.forEach {
|
phoneNumbers.forEach {
|
||||||
layoutInflater.inflate(R.layout.item_view_phone_number, contact_numbers_holder, false).apply {
|
layoutInflater.inflate(R.layout.item_view_phone_number, contact_numbers_holder, false).apply {
|
||||||
|
val phoneNumber = it
|
||||||
contact_numbers_holder.addView(this)
|
contact_numbers_holder.addView(this)
|
||||||
contact_number.text = it.value
|
contact_number.text = phoneNumber.value
|
||||||
contact_number_type.setText(getPhoneNumberTextId(it.type))
|
contact_number_type.setText(getPhoneNumberTextId(phoneNumber.type))
|
||||||
|
|
||||||
|
setOnClickListener {
|
||||||
|
startCallIntent(phoneNumber.value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,9 +186,14 @@ class ViewContactActivity : ContactActivity() {
|
||||||
val emails = contact!!.emails
|
val emails = contact!!.emails
|
||||||
emails.forEach {
|
emails.forEach {
|
||||||
layoutInflater.inflate(R.layout.item_view_email, contact_emails_holder, false).apply {
|
layoutInflater.inflate(R.layout.item_view_email, contact_emails_holder, false).apply {
|
||||||
|
val email = it
|
||||||
contact_emails_holder.addView(this)
|
contact_emails_holder.addView(this)
|
||||||
contact_email.text = it.value
|
contact_email.text = email.value
|
||||||
contact_email_type.setText(getEmailTextId(it.type))
|
contact_email_type.setText(getEmailTextId(email.type))
|
||||||
|
|
||||||
|
setOnClickListener {
|
||||||
|
sendEmailIntent(email.value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,9 +206,14 @@ class ViewContactActivity : ContactActivity() {
|
||||||
val addresses = contact!!.addresses
|
val addresses = contact!!.addresses
|
||||||
addresses.forEach {
|
addresses.forEach {
|
||||||
layoutInflater.inflate(R.layout.item_view_address, contact_addresses_holder, false).apply {
|
layoutInflater.inflate(R.layout.item_view_address, contact_addresses_holder, false).apply {
|
||||||
|
val address = it
|
||||||
contact_addresses_holder.addView(this)
|
contact_addresses_holder.addView(this)
|
||||||
contact_address.text = it.value
|
contact_address.text = address.value
|
||||||
contact_address_type.setText(getAddressTextId(it.type))
|
contact_address_type.setText(getAddressTextId(address.type))
|
||||||
|
|
||||||
|
setOnClickListener {
|
||||||
|
sendAddressIntent(address.value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,18 @@ fun Context.sendSMSIntent(recipient: String) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Context.sendAddressIntent(address: String) {
|
||||||
|
val location = Uri.encode(address)
|
||||||
|
val uri = Uri.parse("geo:0,0?q=$location")
|
||||||
|
|
||||||
|
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||||
|
if (intent.resolveActivity(packageManager) != null) {
|
||||||
|
startActivity(intent)
|
||||||
|
} else {
|
||||||
|
toast(R.string.no_app_found)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
fun Context.getLookupUriRawId(dataUri: Uri): Int {
|
fun Context.getLookupUriRawId(dataUri: Uri): Int {
|
||||||
val lookupKey = getLookupKeyFromUri(dataUri)
|
val lookupKey = getLookupKeyFromUri(dataUri)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
android:id="@+id/contact_address_holder"
|
android:id="@+id/contact_address_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
android:paddingBottom="@dimen/normal_margin"
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
android:paddingTop="@dimen/normal_margin">
|
android:paddingTop="@dimen/normal_margin">
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
android:id="@+id/contact_email_holder"
|
android:id="@+id/contact_email_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
android:paddingBottom="@dimen/normal_margin"
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
android:paddingTop="@dimen/normal_margin">
|
android:paddingTop="@dimen/normal_margin">
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
android:id="@+id/contact_number_holder"
|
android:id="@+id/contact_number_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
android:paddingBottom="@dimen/normal_margin"
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
android:paddingTop="@dimen/normal_margin">
|
android:paddingTop="@dimen/normal_margin">
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue