Hide account container in compact editor.
Show account container when editing ME profile.
Hide account container when linking a writable contact with
a readonly one in editor. Also, showing unlink menu in this case.
BUG 25231329
Change-Id: Ia8cb59b93e0a3e46bcfa265d2d16518b3900204a
diff --git a/src/com/android/contacts/editor/CompactRawContactsEditorView.java b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
index 303a450..ef4ce92 100644
--- a/src/com/android/contacts/editor/CompactRawContactsEditorView.java
+++ b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
@@ -756,10 +756,10 @@
if (accounts.size() > 1) {
addAccountSelector(accountInfo, rawContactDelta);
} else {
- addAccountHeader(accountInfo, rawContactDeltas);
+ addAccountHeader(accountInfo);
}
- } else {
- addAccountHeader(accountInfo, rawContactDeltas);
+ } else if (mIsUserProfile || !shouldHideAccountContainer(rawContactDeltas)) {
+ addAccountHeader(accountInfo);
}
// The raw contact selector should only display linked raw contacts that can be edited in
@@ -796,9 +796,9 @@
return result;
}
- // Returns true if there're multiple writable and no read only, or there're both writable and
- // read only. For ME profile, return false if there's a read only contact and unsaved local one.
- private boolean shouldHideAccountHeader(RawContactDeltaList rawContactDeltas) {
+ // Returns true if there are multiple writable rawcontacts and no read-only ones,
+ // or there are both writable and read-only rawcontacts.
+ private boolean shouldHideAccountContainer(RawContactDeltaList rawContactDeltas) {
int writable = 0;
int readonly = 0;
for (RawContactDelta rawContactDelta : rawContactDeltas) {
@@ -813,12 +813,8 @@
return (writable > 1 || (writable > 0 && readonly > 0));
}
- private void addAccountHeader(Pair<String,String> accountInfo,
- RawContactDeltaList rawContactDeltas) {
+ private void addAccountHeader(Pair<String,String> accountInfo) {
mAccountHeaderContainer.setVisibility(View.VISIBLE);
- if (shouldHideAccountHeader(rawContactDeltas)) {
- mAccountHeaderContainer.setVisibility(View.GONE);
- }
// Set the account name
final String accountName = TextUtils.isEmpty(accountInfo.first)
diff --git a/src/com/android/contacts/editor/ContactEditorBaseFragment.java b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
index 91fc81f..320ebe9 100644
--- a/src/com/android/contacts/editor/ContactEditorBaseFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
@@ -1140,6 +1140,8 @@
selectAccountAndCreateContact();
readOnlyDisplayName = contact.getDisplayName();
+ } else {
+ mHasNewContact = false;
}
// This also adds deltas to list. If readOnlyDisplayName is null at this point it is