diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt index c337c600..d47c2073 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt @@ -19,6 +19,7 @@ import kotlinx.android.synthetic.main.item_view_address.view.* import kotlinx.android.synthetic.main.item_view_email.view.* import kotlinx.android.synthetic.main.item_view_group.view.* import kotlinx.android.synthetic.main.item_view_phone_number.view.* +import kotlinx.android.synthetic.main.item_website.view.* class ViewContactActivity : ContactActivity() { private var isViewIntent = false @@ -124,6 +125,7 @@ class ViewContactActivity : ContactActivity() { contact_source_image.applyColorFilter(textColor) contact_notes_image.applyColorFilter(textColor) contact_organization_image.applyColorFilter(textColor) + contact_websites_image.applyColorFilter(textColor) contact_groups_image.applyColorFilter(textColor) contact_send_sms.setOnClickListener { trySendSMS() } @@ -180,6 +182,7 @@ class ViewContactActivity : ContactActivity() { setupEvents() setupNotes() setupOrganization() + setupWebsites() setupGroups() } @@ -303,6 +306,29 @@ class ViewContactActivity : ContactActivity() { } } + private fun setupWebsites() { + contact_websites_holder.removeAllViews() + val websites = contact!!.websites + if (websites.isNotEmpty() && showFields and SHOW_WEBSITES_FIELD != 0) { + websites.forEach { + val url = it + layoutInflater.inflate(R.layout.item_website, contact_websites_holder, false).apply { + contact_websites_holder.addView(this) + contact_website.text = url + + setOnClickListener { + openWebsiteIntent(url) + } + } + } + contact_websites_image.beVisible() + contact_websites_holder.beVisible() + } else { + contact_websites_image.beGone() + contact_websites_holder.beGone() + } + } + private fun setupGroups() { contact_groups_holder.removeAllViews() val groups = contact!!.groups diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/extensions/Context.kt index 2507d169..dfcafded 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/extensions/Context.kt @@ -68,11 +68,23 @@ 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) + Intent(Intent.ACTION_VIEW, uri).apply { + if (resolveActivity(packageManager) != null) { + startActivity(this) + } else { + toast(R.string.no_app_found) + } + } +} + +fun Context.openWebsiteIntent(url: String) { + Intent(Intent.ACTION_VIEW).apply { + data = Uri.parse(url) + if (resolveActivity(packageManager) != null) { + startActivity(this) + } else { + toast(R.string.no_app_found) + } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt index 11084ef4..03e65cbe 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt @@ -82,3 +82,4 @@ const val SHOW_NOTES_FIELD = 512 const val SHOW_ORGANIZATION_FIELD = 1024 const val SHOW_GROUPS_FIELD = 2048 const val SHOW_CONTACT_SOURCE_FIELD = 4096 +const val SHOW_WEBSITES_FIELD = 8192 diff --git a/app/src/main/res/layout/activity_view_contact.xml b/app/src/main/res/layout/activity_view_contact.xml index 523627b0..d72416a6 100644 --- a/app/src/main/res/layout/activity_view_contact.xml +++ b/app/src/main/res/layout/activity_view_contact.xml @@ -306,6 +306,25 @@ android:paddingTop="@dimen/normal_margin" android:textSize="@dimen/bigger_text_size"/> + + + + diff --git a/app/src/main/res/layout/item_website.xml b/app/src/main/res/layout/item_website.xml new file mode 100644 index 00000000..39d029bc --- /dev/null +++ b/app/src/main/res/layout/item_website.xml @@ -0,0 +1,14 @@ + +