allow managing visible contact fields directly from View Contact screen

This commit is contained in:
tibbi 2022-02-05 11:59:37 +01:00
parent 5c4935f4f7
commit 1907003b75
3 changed files with 25 additions and 7 deletions

View File

@ -296,7 +296,7 @@ class EditContactActivity : ContactActivity() {
}
}
private fun hasContactChanged() = contact != fillContactValues() || originalRingtone != contact?.ringtone
private fun hasContactChanged() = contact != null && contact != fillContactValues() || originalRingtone != contact?.ringtone
private fun openWith() {
Intent().apply {

View File

@ -22,6 +22,7 @@ import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.dialogs.ChooseSocialDialog
import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleFieldsDialog
import com.simplemobiletools.contacts.pro.extensions.*
import com.simplemobiletools.contacts.pro.helpers.*
import com.simplemobiletools.contacts.pro.models.*
@ -112,6 +113,16 @@ class ViewContactActivity : ContactActivity() {
deleteContactFromAllSources()
true
}
findItem(R.id.manage_visible_fields).setOnMenuItemClickListener {
ManageVisibleFieldsDialog(this@ViewContactActivity) {
showFields = config.showContactFields
ensureBackgroundThread {
initContact()
}
}
true
}
}
contact_toolbar.setNavigationOnClickListener {
@ -296,9 +307,12 @@ class ViewContactActivity : ContactActivity() {
displayName += " (${contact!!.nickname})"
}
val showNameFields = showFields and SHOW_PREFIX_FIELD != 0 || showFields and SHOW_FIRST_NAME_FIELD != 0 || showFields and SHOW_MIDDLE_NAME_FIELD != 0 ||
showFields and SHOW_SURNAME_FIELD != 0 || showFields and SHOW_SUFFIX_FIELD != 0
contact_name.text = displayName
contact_name.copyOnLongClick(displayName)
contact_name.beVisibleIf(displayName.isNotEmpty() && !contact!!.isABusinessContact())
contact_name.beVisibleIf(displayName.isNotEmpty() && !contact!!.isABusinessContact() && showNameFields)
contact_name_image.beInvisibleIf(contact_name.isGone())
}

View File

@ -1,23 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/edit"
android:icon="@drawable/ic_edit_vector"
android:title="@string/edit_contact"
app:showAsAction="always"/>
app:showAsAction="always" />
<item
android:id="@+id/share"
android:icon="@drawable/ic_share_vector"
android:title="@string/share"
app:showAsAction="always"/>
app:showAsAction="always" />
<item
android:id="@+id/delete"
android:icon="@drawable/ic_delete_vector"
android:title="@string/delete"
app:showAsAction="always"/>
app:showAsAction="always" />
<item
android:id="@+id/open_with"
android:title="@string/open_with"
app:showAsAction="never"/>
app:showAsAction="never" />
<item
android:id="@+id/manage_visible_fields"
android:title="@string/manage_shown_contact_fields"
app:showAsAction="never" />
</menu>