fix #182, ignore hidden fields during editing instead of removing them

This commit is contained in:
tibbi
2018-06-19 15:39:26 +02:00
parent 15316f0103
commit 824a8d18f0
3 changed files with 93 additions and 109 deletions

View File

@ -35,7 +35,6 @@ import java.util.*
abstract class ContactActivity : SimpleActivity() {
protected var contact: Contact? = null
protected var currentContactPhotoPath = ""
protected var showFields = 0
fun showPhotoPlaceholder(photoView: ImageView) {
val placeholder = resources.getColoredBitmap(R.drawable.ic_person, config.primaryColor.getContrastColor())

View File

@ -58,7 +58,6 @@ class EditContactActivity : ContactActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_edit_contact)
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_cross)
showFields = config.showContactFields
val action = intent.action
isThirdPartyIntent = action == Intent.ACTION_EDIT || action == Intent.ACTION_INSERT_OR_EDIT || action == Intent.ACTION_INSERT
@ -272,6 +271,7 @@ class EditContactActivity : ContactActivity() {
}
private fun setupFieldVisibility() {
val showFields = config.showContactFields
if (showFields and (SHOW_PREFIX_FIELD or SHOW_FIRST_NAME_FIELD or SHOW_MIDDLE_NAME_FIELD or SHOW_SURNAME_FIELD or SHOW_SUFFIX_FIELD) == 0) {
contact_name_image.beInvisible()
}
@ -352,7 +352,6 @@ class EditContactActivity : ContactActivity() {
}
private fun setupPhoneNumbers() {
if (showFields and SHOW_PHONE_NUMBERS_FIELD != 0) {
contact!!.phoneNumbers.forEachIndexed { index, number ->
var numberHolder = contact_numbers_holder.getChildAt(index)
if (numberHolder == null) {
@ -366,10 +365,8 @@ class EditContactActivity : ContactActivity() {
}
}
}
}
private fun setupEmails() {
if (showFields and SHOW_EMAILS_FIELD != 0) {
contact!!.emails.forEachIndexed { index, email ->
var emailHolder = contact_emails_holder.getChildAt(index)
if (emailHolder == null) {
@ -383,10 +380,8 @@ class EditContactActivity : ContactActivity() {
}
}
}
}
private fun setupAddresses() {
if (showFields and SHOW_ADDRESSES_FIELD != 0) {
contact!!.addresses.forEachIndexed { index, address ->
var addressHolder = contact_addresses_holder.getChildAt(index)
if (addressHolder == null) {
@ -400,23 +395,17 @@ class EditContactActivity : ContactActivity() {
}
}
}
}
private fun setupNotes() {
if (showFields and SHOW_NOTES_FIELD != 0) {
contact_notes.setText(contact!!.notes)
}
}
private fun setupOrganization() {
if (showFields and SHOW_ORGANIZATION_FIELD != 0) {
contact_organization_company.setText(contact!!.organization.company)
contact_organization_job_position.setText(contact!!.organization.jobPosition)
}
}
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) {
@ -427,10 +416,8 @@ class EditContactActivity : ContactActivity() {
websitesHolder!!.contact_website.setText(website)
}
}
}
private fun setupEvents() {
if (showFields and SHOW_EVENTS_FIELD != 0) {
contact!!.events.forEachIndexed { index, event ->
var eventHolder = contact_events_holder.getChildAt(index)
if (eventHolder == null) {
@ -458,10 +445,8 @@ class EditContactActivity : ContactActivity() {
}
}
}
}
private fun setupGroups() {
if (showFields and SHOW_GROUPS_FIELD != 0) {
contact_groups_holder.removeAllViews()
val groups = contact!!.groups
groups.forEachIndexed { index, group ->
@ -510,7 +495,6 @@ class EditContactActivity : ContactActivity() {
}
}
}
}
private fun setupContactSource() {
contact_source.text = getPublicContactSource(contact!!.source)

View File

@ -23,6 +23,7 @@ import kotlinx.android.synthetic.main.item_website.view.*
class ViewContactActivity : ContactActivity() {
private var isViewIntent = false
private var showFields = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)