mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
add website to the View screen
This commit is contained in:
@ -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_email.view.*
|
||||||
import kotlinx.android.synthetic.main.item_view_group.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_view_phone_number.view.*
|
||||||
|
import kotlinx.android.synthetic.main.item_website.view.*
|
||||||
|
|
||||||
class ViewContactActivity : ContactActivity() {
|
class ViewContactActivity : ContactActivity() {
|
||||||
private var isViewIntent = false
|
private var isViewIntent = false
|
||||||
@ -124,6 +125,7 @@ class ViewContactActivity : ContactActivity() {
|
|||||||
contact_source_image.applyColorFilter(textColor)
|
contact_source_image.applyColorFilter(textColor)
|
||||||
contact_notes_image.applyColorFilter(textColor)
|
contact_notes_image.applyColorFilter(textColor)
|
||||||
contact_organization_image.applyColorFilter(textColor)
|
contact_organization_image.applyColorFilter(textColor)
|
||||||
|
contact_websites_image.applyColorFilter(textColor)
|
||||||
contact_groups_image.applyColorFilter(textColor)
|
contact_groups_image.applyColorFilter(textColor)
|
||||||
|
|
||||||
contact_send_sms.setOnClickListener { trySendSMS() }
|
contact_send_sms.setOnClickListener { trySendSMS() }
|
||||||
@ -180,6 +182,7 @@ class ViewContactActivity : ContactActivity() {
|
|||||||
setupEvents()
|
setupEvents()
|
||||||
setupNotes()
|
setupNotes()
|
||||||
setupOrganization()
|
setupOrganization()
|
||||||
|
setupWebsites()
|
||||||
setupGroups()
|
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() {
|
private fun setupGroups() {
|
||||||
contact_groups_holder.removeAllViews()
|
contact_groups_holder.removeAllViews()
|
||||||
val groups = contact!!.groups
|
val groups = contact!!.groups
|
||||||
|
@ -68,11 +68,23 @@ fun Context.sendAddressIntent(address: String) {
|
|||||||
val location = Uri.encode(address)
|
val location = Uri.encode(address)
|
||||||
val uri = Uri.parse("geo:0,0?q=$location")
|
val uri = Uri.parse("geo:0,0?q=$location")
|
||||||
|
|
||||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
Intent(Intent.ACTION_VIEW, uri).apply {
|
||||||
if (intent.resolveActivity(packageManager) != null) {
|
if (resolveActivity(packageManager) != null) {
|
||||||
startActivity(intent)
|
startActivity(this)
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.no_app_found)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,3 +82,4 @@ const val SHOW_NOTES_FIELD = 512
|
|||||||
const val SHOW_ORGANIZATION_FIELD = 1024
|
const val SHOW_ORGANIZATION_FIELD = 1024
|
||||||
const val SHOW_GROUPS_FIELD = 2048
|
const val SHOW_GROUPS_FIELD = 2048
|
||||||
const val SHOW_CONTACT_SOURCE_FIELD = 4096
|
const val SHOW_CONTACT_SOURCE_FIELD = 4096
|
||||||
|
const val SHOW_WEBSITES_FIELD = 8192
|
||||||
|
@ -306,6 +306,25 @@
|
|||||||
android:paddingTop="@dimen/normal_margin"
|
android:paddingTop="@dimen/normal_margin"
|
||||||
android:textSize="@dimen/bigger_text_size"/>
|
android:textSize="@dimen/bigger_text_size"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/contact_websites_image"
|
||||||
|
android:layout_width="@dimen/contact_icons_size"
|
||||||
|
android:layout_height="@dimen/contact_icons_size"
|
||||||
|
android:layout_alignTop="@+id/contact_websites_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_link"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/contact_websites_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/contact_organization_job_position"
|
||||||
|
android:layout_toRightOf="@+id/contact_name_image"
|
||||||
|
android:orientation="vertical"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/contact_groups_image"
|
android:id="@+id/contact_groups_image"
|
||||||
android:layout_width="@dimen/contact_icons_size"
|
android:layout_width="@dimen/contact_icons_size"
|
||||||
@ -321,7 +340,7 @@
|
|||||||
android:id="@+id/contact_groups_holder"
|
android:id="@+id/contact_groups_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/contact_organization_job_position"
|
android:layout_below="@+id/contact_websites_holder"
|
||||||
android:layout_toRightOf="@+id/contact_name_image"
|
android:layout_toRightOf="@+id/contact_name_image"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="@dimen/small_margin"/>
|
android:paddingLeft="@dimen/small_margin"/>
|
||||||
|
14
app/src/main/res/layout/item_website.xml
Normal file
14
app/src/main/res/layout/item_website.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/contact_website"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:paddingBottom="@dimen/normal_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"/>
|
Reference in New Issue
Block a user