Avoid showing error if contact removed on save.
Because removing all data from a local contact can actually cause
the raw contact and contact to be deleted, we need to track that
case so that the caller does not consider the lack of a lookup
URI to be an error.
Also made "Me" header all-caps for no-profile case.
Bug 5346614
Bug 5354364
Change-Id: If1e1d67da9c14eb8782be05b2e39ece19b5ac026
diff --git a/src/com/android/contacts/ContactSaveService.java b/src/com/android/contacts/ContactSaveService.java
index 2697589..be84cc4 100644
--- a/src/com/android/contacts/ContactSaveService.java
+++ b/src/com/android/contacts/ContactSaveService.java
@@ -79,6 +79,7 @@
public static final String EXTRA_CONTACT_STATE = "state";
public static final String EXTRA_SAVE_MODE = "saveMode";
public static final String EXTRA_SAVE_IS_PROFILE = "saveIsProfile";
+ public static final String EXTRA_SAVE_SUCCEEDED = "saveSucceeded";
public static final String ACTION_CREATE_GROUP = "createGroup";
public static final String ACTION_RENAME_GROUP = "renameGroup";
@@ -345,6 +346,10 @@
lookupUri = RawContacts.getContactLookupUri(resolver, rawContactUri);
}
Log.v(TAG, "Saved contact. New URI: " + lookupUri);
+ // Mark the intent to indicate that the save was successful (even if the lookup URI
+ // is now null). For local contacts or the local profile, it's possible that the
+ // save triggered removal of the contact, so no lookup URI would exist..
+ callbackIntent.putExtra(EXTRA_SAVE_SUCCEEDED, true);
break;
} catch (RemoteException e) {
diff --git a/src/com/android/contacts/activities/ContactEditorActivity.java b/src/com/android/contacts/activities/ContactEditorActivity.java
index abdde87..07f340e 100644
--- a/src/com/android/contacts/activities/ContactEditorActivity.java
+++ b/src/com/android/contacts/activities/ContactEditorActivity.java
@@ -16,6 +16,7 @@
package com.android.contacts.activities;
+import com.android.contacts.ContactSaveService;
import com.android.contacts.ContactsActivity;
import com.android.contacts.R;
import com.android.contacts.editor.ContactEditorFragment;
@@ -115,6 +116,7 @@
} else if (ACTION_SAVE_COMPLETED.equals(action)) {
mFragment.onSaveCompleted(true,
intent.getIntExtra(ContactEditorFragment.SAVE_MODE_EXTRA_KEY, SaveMode.CLOSE),
+ intent.getBooleanExtra(ContactSaveService.EXTRA_SAVE_SUCCEEDED, false),
intent.getData());
} else if (ACTION_JOIN_COMPLETED.equals(action)) {
mFragment.onJoinCompleted(intent.getData());
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index a8c0b36..c09d8cd 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -392,7 +392,7 @@
mAutoAddToDefaultGroup = mIntentExtras != null
&& mIntentExtras.containsKey(INTENT_EXTRA_ADD_TO_DEFAULT_DIRECTORY);
mNewLocalProfile = mIntentExtras != null
- && mIntentExtras.getBoolean(INTENT_EXTRA_NEW_LOCAL_PROFILE);
+ && mIntentExtras.getBoolean(INTENT_EXTRA_NEW_LOCAL_PROFILE);
}
public void setListener(Listener value) {
@@ -979,7 +979,7 @@
final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
if (!EntityModifier.hasChanges(mState, accountTypes)) {
- onSaveCompleted(false, saveMode, mLookupUri);
+ onSaveCompleted(false, saveMode, mLookupUri != null, mLookupUri);
return true;
}
@@ -1041,14 +1041,14 @@
}
public void onJoinCompleted(Uri uri) {
- onSaveCompleted(false, SaveMode.RELOAD, uri);
+ onSaveCompleted(false, SaveMode.RELOAD, uri != null, uri);
}
- public void onSaveCompleted(boolean hadChanges, int saveMode, Uri contactLookupUri) {
- boolean success = contactLookupUri != null;
+ public void onSaveCompleted(boolean hadChanges, int saveMode, boolean saveSucceeded,
+ Uri contactLookupUri) {
Log.d(TAG, "onSaveCompleted(" + saveMode + ", " + contactLookupUri);
if (hadChanges) {
- if (success) {
+ if (saveSucceeded) {
if (saveMode != SaveMode.JOIN) {
Toast.makeText(mContext, R.string.contactSavedToast, Toast.LENGTH_SHORT).show();
}
@@ -1060,7 +1060,7 @@
case SaveMode.CLOSE:
case SaveMode.HOME:
final Intent resultIntent;
- if (success && contactLookupUri != null) {
+ if (saveSucceeded && contactLookupUri != null) {
final String requestAuthority =
mLookupUri == null ? null : mLookupUri.getAuthority();
@@ -1091,7 +1091,7 @@
case SaveMode.RELOAD:
case SaveMode.JOIN:
- if (success && contactLookupUri != null) {
+ if (saveSucceeded && contactLookupUri != null) {
// If it was a JOIN, we are now ready to bring up the join activity.
if (saveMode == SaveMode.JOIN) {
showJoinAggregateActivity(contactLookupUri);
diff --git a/src/com/android/contacts/list/DefaultContactBrowseListFragment.java b/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
index 608d3ad..30c3c48 100644
--- a/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
+++ b/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
@@ -49,7 +49,7 @@
private View mProfileHeader;
private Button mProfileMessage;
private FrameLayout mMessageContainer;
- private View mProfileTitle;
+ private TextView mProfileTitle;
private View mPaddingView;
@@ -273,7 +273,8 @@
mProfileHeaderContainer = new FrameLayout(inflater.getContext());
mProfileHeader = inflater.inflate(R.layout.user_profile_header, null, false);
mCounterHeaderView = (TextView) mProfileHeader.findViewById(R.id.contacts_count);
- mProfileTitle = mProfileHeader.findViewById(R.id.profile_title);
+ mProfileTitle = (TextView) mProfileHeader.findViewById(R.id.profile_title);
+ mProfileTitle.setAllCaps(true);
mProfileHeaderContainer.addView(mProfileHeader);
list.addHeaderView(mProfileHeaderContainer, null, false);