mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
fix #182, ignore hidden fields during editing instead of removing them
This commit is contained in:
@ -35,7 +35,6 @@ import java.util.*
|
|||||||
abstract class ContactActivity : SimpleActivity() {
|
abstract class ContactActivity : SimpleActivity() {
|
||||||
protected var contact: Contact? = null
|
protected var contact: Contact? = null
|
||||||
protected var currentContactPhotoPath = ""
|
protected var currentContactPhotoPath = ""
|
||||||
protected var showFields = 0
|
|
||||||
|
|
||||||
fun showPhotoPlaceholder(photoView: ImageView) {
|
fun showPhotoPlaceholder(photoView: ImageView) {
|
||||||
val placeholder = resources.getColoredBitmap(R.drawable.ic_person, config.primaryColor.getContrastColor())
|
val placeholder = resources.getColoredBitmap(R.drawable.ic_person, config.primaryColor.getContrastColor())
|
||||||
|
@ -58,7 +58,6 @@ class EditContactActivity : ContactActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_edit_contact)
|
setContentView(R.layout.activity_edit_contact)
|
||||||
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_cross)
|
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_cross)
|
||||||
showFields = config.showContactFields
|
|
||||||
|
|
||||||
val action = intent.action
|
val action = intent.action
|
||||||
isThirdPartyIntent = action == Intent.ACTION_EDIT || action == Intent.ACTION_INSERT_OR_EDIT || action == Intent.ACTION_INSERT
|
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() {
|
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) {
|
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()
|
contact_name_image.beInvisible()
|
||||||
}
|
}
|
||||||
@ -352,108 +352,94 @@ class EditContactActivity : ContactActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupPhoneNumbers() {
|
private fun setupPhoneNumbers() {
|
||||||
if (showFields and SHOW_PHONE_NUMBERS_FIELD != 0) {
|
contact!!.phoneNumbers.forEachIndexed { index, number ->
|
||||||
contact!!.phoneNumbers.forEachIndexed { index, number ->
|
var numberHolder = contact_numbers_holder.getChildAt(index)
|
||||||
var numberHolder = contact_numbers_holder.getChildAt(index)
|
if (numberHolder == null) {
|
||||||
if (numberHolder == null) {
|
numberHolder = layoutInflater.inflate(R.layout.item_edit_phone_number, contact_numbers_holder, false)
|
||||||
numberHolder = layoutInflater.inflate(R.layout.item_edit_phone_number, contact_numbers_holder, false)
|
contact_numbers_holder.addView(numberHolder)
|
||||||
contact_numbers_holder.addView(numberHolder)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
numberHolder!!.apply {
|
numberHolder!!.apply {
|
||||||
contact_number.setText(number.value)
|
contact_number.setText(number.value)
|
||||||
setupPhoneNumberTypePicker(contact_number_type, number.type)
|
setupPhoneNumberTypePicker(contact_number_type, number.type)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupEmails() {
|
private fun setupEmails() {
|
||||||
if (showFields and SHOW_EMAILS_FIELD != 0) {
|
contact!!.emails.forEachIndexed { index, email ->
|
||||||
contact!!.emails.forEachIndexed { index, email ->
|
var emailHolder = contact_emails_holder.getChildAt(index)
|
||||||
var emailHolder = contact_emails_holder.getChildAt(index)
|
if (emailHolder == null) {
|
||||||
if (emailHolder == null) {
|
emailHolder = layoutInflater.inflate(R.layout.item_edit_email, contact_emails_holder, false)
|
||||||
emailHolder = layoutInflater.inflate(R.layout.item_edit_email, contact_emails_holder, false)
|
contact_emails_holder.addView(emailHolder)
|
||||||
contact_emails_holder.addView(emailHolder)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
emailHolder!!.apply {
|
emailHolder!!.apply {
|
||||||
contact_email.setText(email.value)
|
contact_email.setText(email.value)
|
||||||
setupEmailTypePicker(contact_email_type, email.type)
|
setupEmailTypePicker(contact_email_type, email.type)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAddresses() {
|
private fun setupAddresses() {
|
||||||
if (showFields and SHOW_ADDRESSES_FIELD != 0) {
|
contact!!.addresses.forEachIndexed { index, address ->
|
||||||
contact!!.addresses.forEachIndexed { index, address ->
|
var addressHolder = contact_addresses_holder.getChildAt(index)
|
||||||
var addressHolder = contact_addresses_holder.getChildAt(index)
|
if (addressHolder == null) {
|
||||||
if (addressHolder == null) {
|
addressHolder = layoutInflater.inflate(R.layout.item_edit_address, contact_addresses_holder, false)
|
||||||
addressHolder = layoutInflater.inflate(R.layout.item_edit_address, contact_addresses_holder, false)
|
contact_addresses_holder.addView(addressHolder)
|
||||||
contact_addresses_holder.addView(addressHolder)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
addressHolder!!.apply {
|
addressHolder!!.apply {
|
||||||
contact_address.setText(address.value)
|
contact_address.setText(address.value)
|
||||||
setupAddressTypePicker(contact_address_type, address.type)
|
setupAddressTypePicker(contact_address_type, address.type)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupNotes() {
|
private fun setupNotes() {
|
||||||
if (showFields and SHOW_NOTES_FIELD != 0) {
|
contact_notes.setText(contact!!.notes)
|
||||||
contact_notes.setText(contact!!.notes)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOrganization() {
|
private fun setupOrganization() {
|
||||||
if (showFields and SHOW_ORGANIZATION_FIELD != 0) {
|
contact_organization_company.setText(contact!!.organization.company)
|
||||||
contact_organization_company.setText(contact!!.organization.company)
|
contact_organization_job_position.setText(contact!!.organization.jobPosition)
|
||||||
contact_organization_job_position.setText(contact!!.organization.jobPosition)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupWebsites() {
|
private fun setupWebsites() {
|
||||||
if (showFields and SHOW_WEBSITES_FIELD != 0) {
|
contact!!.websites.forEachIndexed { index, website ->
|
||||||
contact!!.websites.forEachIndexed { index, website ->
|
var websitesHolder = contact_websites_holder.getChildAt(index)
|
||||||
var websitesHolder = contact_websites_holder.getChildAt(index)
|
if (websitesHolder == null) {
|
||||||
if (websitesHolder == null) {
|
websitesHolder = layoutInflater.inflate(R.layout.item_edit_website, contact_websites_holder, false)
|
||||||
websitesHolder = layoutInflater.inflate(R.layout.item_edit_website, contact_websites_holder, false)
|
contact_websites_holder.addView(websitesHolder)
|
||||||
contact_websites_holder.addView(websitesHolder)
|
|
||||||
}
|
|
||||||
|
|
||||||
websitesHolder!!.contact_website.setText(website)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
websitesHolder!!.contact_website.setText(website)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupEvents() {
|
private fun setupEvents() {
|
||||||
if (showFields and SHOW_EVENTS_FIELD != 0) {
|
contact!!.events.forEachIndexed { index, event ->
|
||||||
contact!!.events.forEachIndexed { index, event ->
|
var eventHolder = contact_events_holder.getChildAt(index)
|
||||||
var eventHolder = contact_events_holder.getChildAt(index)
|
if (eventHolder == null) {
|
||||||
if (eventHolder == null) {
|
eventHolder = layoutInflater.inflate(R.layout.item_event, contact_events_holder, false)
|
||||||
eventHolder = layoutInflater.inflate(R.layout.item_event, contact_events_holder, false)
|
contact_events_holder.addView(eventHolder)
|
||||||
contact_events_holder.addView(eventHolder)
|
}
|
||||||
|
|
||||||
|
(eventHolder as ViewGroup).apply {
|
||||||
|
val contactEvent = contact_event.apply {
|
||||||
|
getDateTime(event.value, this)
|
||||||
|
tag = event.value
|
||||||
|
alpha = 1f
|
||||||
}
|
}
|
||||||
|
|
||||||
(eventHolder as ViewGroup).apply {
|
setupEventTypePicker(this, event.type)
|
||||||
val contactEvent = contact_event.apply {
|
|
||||||
getDateTime(event.value, this)
|
|
||||||
tag = event.value
|
|
||||||
alpha = 1f
|
|
||||||
}
|
|
||||||
|
|
||||||
setupEventTypePicker(this, event.type)
|
contact_event_remove.apply {
|
||||||
|
beVisible()
|
||||||
contact_event_remove.apply {
|
applyColorFilter(getAdjustedPrimaryColor())
|
||||||
beVisible()
|
background.applyColorFilter(config.textColor)
|
||||||
applyColorFilter(getAdjustedPrimaryColor())
|
setOnClickListener {
|
||||||
background.applyColorFilter(config.textColor)
|
resetContactEvent(contactEvent, this)
|
||||||
setOnClickListener {
|
|
||||||
resetContactEvent(contactEvent, this)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -461,52 +447,50 @@ class EditContactActivity : ContactActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupGroups() {
|
private fun setupGroups() {
|
||||||
if (showFields and SHOW_GROUPS_FIELD != 0) {
|
contact_groups_holder.removeAllViews()
|
||||||
contact_groups_holder.removeAllViews()
|
val groups = contact!!.groups
|
||||||
val groups = contact!!.groups
|
groups.forEachIndexed { index, group ->
|
||||||
groups.forEachIndexed { index, group ->
|
var groupHolder = contact_groups_holder.getChildAt(index)
|
||||||
var groupHolder = contact_groups_holder.getChildAt(index)
|
if (groupHolder == null) {
|
||||||
if (groupHolder == null) {
|
groupHolder = layoutInflater.inflate(R.layout.item_edit_group, contact_groups_holder, false)
|
||||||
groupHolder = layoutInflater.inflate(R.layout.item_edit_group, contact_groups_holder, false)
|
contact_groups_holder.addView(groupHolder)
|
||||||
contact_groups_holder.addView(groupHolder)
|
}
|
||||||
|
|
||||||
|
(groupHolder as ViewGroup).apply {
|
||||||
|
contact_group.apply {
|
||||||
|
text = group.title
|
||||||
|
setTextColor(config.textColor)
|
||||||
|
tag = group.id
|
||||||
|
alpha = 1f
|
||||||
}
|
}
|
||||||
|
|
||||||
(groupHolder as ViewGroup).apply {
|
setOnClickListener {
|
||||||
contact_group.apply {
|
showSelectGroupsDialog()
|
||||||
text = group.title
|
}
|
||||||
setTextColor(config.textColor)
|
|
||||||
tag = group.id
|
|
||||||
alpha = 1f
|
|
||||||
}
|
|
||||||
|
|
||||||
|
contact_group_remove.apply {
|
||||||
|
beVisible()
|
||||||
|
applyColorFilter(getAdjustedPrimaryColor())
|
||||||
|
background.applyColorFilter(config.textColor)
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
showSelectGroupsDialog()
|
removeGroup(group.id)
|
||||||
}
|
|
||||||
|
|
||||||
contact_group_remove.apply {
|
|
||||||
beVisible()
|
|
||||||
applyColorFilter(getAdjustedPrimaryColor())
|
|
||||||
background.applyColorFilter(config.textColor)
|
|
||||||
setOnClickListener {
|
|
||||||
removeGroup(group.id)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (groups.isEmpty()) {
|
if (groups.isEmpty()) {
|
||||||
layoutInflater.inflate(R.layout.item_edit_group, contact_groups_holder, false).apply {
|
layoutInflater.inflate(R.layout.item_edit_group, contact_groups_holder, false).apply {
|
||||||
contact_group.apply {
|
contact_group.apply {
|
||||||
alpha = 0.5f
|
alpha = 0.5f
|
||||||
text = getString(R.string.no_groups)
|
text = getString(R.string.no_groups)
|
||||||
setTextColor(config.textColor)
|
setTextColor(config.textColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_groups_holder.addView(this)
|
contact_groups_holder.addView(this)
|
||||||
contact_group_remove.beGone()
|
contact_group_remove.beGone()
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
showSelectGroupsDialog()
|
showSelectGroupsDialog()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import kotlinx.android.synthetic.main.item_website.view.*
|
|||||||
|
|
||||||
class ViewContactActivity : ContactActivity() {
|
class ViewContactActivity : ContactActivity() {
|
||||||
private var isViewIntent = false
|
private var isViewIntent = false
|
||||||
|
private var showFields = 0
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
Reference in New Issue
Block a user