add websites to the Edit screen too

This commit is contained in:
tibbi 2018-04-13 13:46:31 +02:00
parent 2fca861fc6
commit 97bd5dacef
3 changed files with 98 additions and 5 deletions

View File

@ -29,6 +29,7 @@ import kotlinx.android.synthetic.main.item_edit_address.view.*
import kotlinx.android.synthetic.main.item_edit_email.view.* import kotlinx.android.synthetic.main.item_edit_email.view.*
import kotlinx.android.synthetic.main.item_edit_group.view.* import kotlinx.android.synthetic.main.item_edit_group.view.*
import kotlinx.android.synthetic.main.item_edit_phone_number.view.* import kotlinx.android.synthetic.main.item_edit_phone_number.view.*
import kotlinx.android.synthetic.main.item_edit_website.view.*
import kotlinx.android.synthetic.main.item_event.view.* import kotlinx.android.synthetic.main.item_event.view.*
import org.joda.time.DateTime import org.joda.time.DateTime
import org.joda.time.format.DateTimeFormat import org.joda.time.format.DateTimeFormat
@ -179,9 +180,10 @@ class EditContactActivity : ContactActivity() {
contact_addresses_image.applyColorFilter(textColor) contact_addresses_image.applyColorFilter(textColor)
contact_events_image.applyColorFilter(textColor) contact_events_image.applyColorFilter(textColor)
contact_notes_image.applyColorFilter(textColor) contact_notes_image.applyColorFilter(textColor)
contact_source_image.applyColorFilter(textColor)
contact_groups_image.applyColorFilter(textColor)
contact_organization_image.applyColorFilter(textColor) contact_organization_image.applyColorFilter(textColor)
contact_websites_image.applyColorFilter(textColor)
contact_groups_image.applyColorFilter(textColor)
contact_source_image.applyColorFilter(textColor)
val adjustedPrimaryColor = getAdjustedPrimaryColor() val adjustedPrimaryColor = getAdjustedPrimaryColor()
contact_numbers_add_new.applyColorFilter(adjustedPrimaryColor) contact_numbers_add_new.applyColorFilter(adjustedPrimaryColor)
@ -192,6 +194,8 @@ class EditContactActivity : ContactActivity() {
contact_addresses_add_new.background.applyColorFilter(textColor) contact_addresses_add_new.background.applyColorFilter(textColor)
contact_events_add_new.applyColorFilter(adjustedPrimaryColor) contact_events_add_new.applyColorFilter(adjustedPrimaryColor)
contact_events_add_new.background.applyColorFilter(textColor) contact_events_add_new.background.applyColorFilter(textColor)
contact_websites_add_new.applyColorFilter(adjustedPrimaryColor)
contact_websites_add_new.background.applyColorFilter(textColor)
contact_groups_add_new.applyColorFilter(adjustedPrimaryColor) contact_groups_add_new.applyColorFilter(adjustedPrimaryColor)
contact_groups_add_new.background.applyColorFilter(textColor) contact_groups_add_new.background.applyColorFilter(textColor)
@ -204,6 +208,7 @@ class EditContactActivity : ContactActivity() {
contact_emails_add_new.setOnClickListener { addNewEmailField() } contact_emails_add_new.setOnClickListener { addNewEmailField() }
contact_addresses_add_new.setOnClickListener { addNewAddressField() } contact_addresses_add_new.setOnClickListener { addNewAddressField() }
contact_events_add_new.setOnClickListener { addNewEventField() } contact_events_add_new.setOnClickListener { addNewEventField() }
contact_websites_add_new.setOnClickListener { addNewWebsiteField() }
contact_groups_add_new.setOnClickListener { showSelectGroupsDialog() } contact_groups_add_new.setOnClickListener { showSelectGroupsDialog() }
setupFieldVisibility() setupFieldVisibility()
@ -285,6 +290,11 @@ class EditContactActivity : ContactActivity() {
contact_events_holder.beVisibleIf(areEventsVisible) contact_events_holder.beVisibleIf(areEventsVisible)
contact_events_add_new.beVisibleIf(areEventsVisible) contact_events_add_new.beVisibleIf(areEventsVisible)
val areWebsitesVisible = showFields and SHOW_WEBSITES_FIELD != 0
contact_websites_image.beVisibleIf(areWebsitesVisible)
contact_websites_holder.beVisibleIf(areWebsitesVisible)
contact_websites_add_new.beVisibleIf(areWebsitesVisible)
val areGroupsVisible = showFields and SHOW_GROUPS_FIELD != 0 val areGroupsVisible = showFields and SHOW_GROUPS_FIELD != 0
contact_groups_image.beVisibleIf(areGroupsVisible) contact_groups_image.beVisibleIf(areGroupsVisible)
contact_groups_holder.beVisibleIf(areGroupsVisible) contact_groups_holder.beVisibleIf(areGroupsVisible)
@ -311,6 +321,7 @@ class EditContactActivity : ContactActivity() {
setupAddresses() setupAddresses()
setupNotes() setupNotes()
setupOrganization() setupOrganization()
setupWebsites()
setupEvents() setupEvents()
setupGroups() setupGroups()
} }
@ -379,6 +390,20 @@ class EditContactActivity : ContactActivity() {
} }
} }
private fun setupWebsites() {
if (showFields and SHOW_WEBSITES_FIELD != 0) {
contact!!.websites.forEachIndexed { index, website ->
var websitesHolder = contact_websites_holder.getChildAt(index)
if (websitesHolder == null) {
websitesHolder = layoutInflater.inflate(R.layout.item_edit_website, contact_websites_holder, false)
contact_websites_holder.addView(websitesHolder)
}
websitesHolder!!.contact_website.setText(website)
}
}
}
private fun setupEvents() { private fun setupEvents() {
if (showFields and SHOW_EVENTS_FIELD != 0) { if (showFields and SHOW_EVENTS_FIELD != 0) {
contact!!.events.forEachIndexed { index, event -> contact!!.events.forEachIndexed { index, event ->
@ -463,7 +488,6 @@ class EditContactActivity : ContactActivity() {
} }
private fun setupNewContact() { private fun setupNewContact() {
//window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE)
supportActionBar?.title = resources.getString(R.string.new_contact) supportActionBar?.title = resources.getString(R.string.new_contact)
val contactSource = if (hasContactPermissions()) config.lastUsedContactSource else SMT_PRIVATE val contactSource = if (hasContactPermissions()) config.lastUsedContactSource else SMT_PRIVATE
val organization = Organization("", "") val organization = Organization("", "")
@ -844,6 +868,16 @@ class EditContactActivity : ContactActivity() {
} }
} }
private fun addNewWebsiteField() {
val websitesHolder = layoutInflater.inflate(R.layout.item_edit_website, contact_websites_holder, false) as ViewGroup
updateTextColors(websitesHolder)
contact_websites_holder.addView(websitesHolder)
contact_websites_holder.onGlobalLayout {
websitesHolder.contact_website.requestFocus()
showKeyboard(websitesHolder.contact_website)
}
}
private fun isContactStarred() = contact_toggle_favorite.tag == 1 private fun isContactStarred() = contact_toggle_favorite.tag == 1
private fun getStarDrawable(on: Boolean) = resources.getDrawable(if (on) R.drawable.ic_star_on_big else R.drawable.ic_star_off_big) private fun getStarDrawable(on: Boolean) = resources.getDrawable(if (on) R.drawable.ic_star_on_big else R.drawable.ic_star_off_big)

View File

@ -200,9 +200,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/contact_numbers_holder" android:layout_below="@+id/contact_numbers_holder"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/medium_margin"
android:background="@drawable/button_background" android:background="@drawable/button_background"
android:paddingBottom="@dimen/medium_margin" android:paddingBottom="@dimen/medium_margin"
android:layout_marginBottom="@dimen/medium_margin"
android:paddingLeft="@dimen/activity_margin" android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin" android:paddingRight="@dimen/activity_margin"
android:paddingTop="@dimen/medium_margin" android:paddingTop="@dimen/medium_margin"
@ -386,6 +386,44 @@
android:textCursorDrawable="@null" android:textCursorDrawable="@null"
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_marginTop="@dimen/medium_margin"
android:layout_toRightOf="@+id/contact_name_image"
android:orientation="vertical">
<include layout="@layout/item_edit_website"/>
</LinearLayout>
<ImageView
android:id="@+id/contact_websites_add_new"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/contact_websites_holder"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/small_margin"
android:background="@drawable/button_background"
android:paddingBottom="@dimen/medium_margin"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:paddingTop="@dimen/medium_margin"
android:src="@drawable/ic_plus"/>
<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"
@ -401,7 +439,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_add_new"
android:layout_marginTop="@dimen/medium_margin" android:layout_marginTop="@dimen/medium_margin"
android:layout_toRightOf="@+id/contact_name_image" android:layout_toRightOf="@+id/contact_name_image"
android:orientation="vertical"> android:orientation="vertical">

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/contact_website_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.simplemobiletools.commons.views.MyEditText
android:id="@+id/contact_website"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:hint="@string/website"
android:inputType="textWebEditText"
android:lines="1"
android:maxLines="1"
android:singleLine="true"
android:textCursorDrawable="@null"
android:textSize="@dimen/bigger_text_size"/>
</RelativeLayout>