Merge "Disabling aggregation suggestions while contact is being saved"
diff --git a/src/com/android/contacts/editor/AggregationSuggestionView.java b/src/com/android/contacts/editor/AggregationSuggestionView.java
index 5403731..af8e7f8 100644
--- a/src/com/android/contacts/editor/AggregationSuggestionView.java
+++ b/src/com/android/contacts/editor/AggregationSuggestionView.java
@@ -136,7 +136,7 @@
@Override
public boolean performClick() {
- if (mListener != null) {
+ if (mListener != null && isEnabled()) {
if (canEditSuggestedContact()) {
mListener.onEditAction(Contacts.getLookupUri(mContactId, mLookupKey));
} else {
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index f8415d2..6aea62a 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -241,6 +241,7 @@
mContent.getChildAt(i).setEnabled(enabled);
}
}
+ setAggregationSuggestionViewEnabled(enabled);
final Activity activity = getActivity();
if (activity != null) activity.invalidateOptionsMenu();
}
@@ -469,6 +470,8 @@
}
private void bindEditorsForNewContact(Account account, final AccountType accountType) {
+ mStatus = Status.EDITING;
+
final ContentValues values = new ContentValues();
if (account != null) {
values.put(RawContacts.ACCOUNT_NAME, account.name);
@@ -746,7 +749,7 @@
* finishes the activity.
*/
public boolean save(int saveMode) {
- if (!hasValidState()) {
+ if (!hasValidState() || mStatus != Status.EDITING) {
return false;
}
@@ -1218,7 +1221,7 @@
@Override
public void onAggregationSuggestionChange() {
- if (!isAdded() || mState == null) {
+ if (!isAdded() || mState == null || mStatus != Status.EDITING) {
return;
}
@@ -1265,6 +1268,7 @@
}
adjustAggregationSuggestionViewLayout(rawContactView);
+ setAggregationSuggestionViewEnabled(mEnabled);
mAggregationSuggestionView.setVisibility(View.VISIBLE);
if (requestOnScreen) {
@@ -1405,6 +1409,19 @@
mContent.requestRectangleOnScreen(rect);
}
+ public void setAggregationSuggestionViewEnabled(boolean enabled) {
+ if (mAggregationSuggestionView == null) {
+ return;
+ }
+
+ LinearLayout itemList = (LinearLayout) mAggregationSuggestionView.findViewById(
+ R.id.aggregation_suggestions);
+ int count = itemList.getChildCount();
+ for (int i = 0; i < count; i++) {
+ itemList.getChildAt(i).setEnabled(enabled);
+ }
+ }
+
/**
* Computes bounds of the supplied view relative to its ascendant.
*/