Merge change Ibcade31c into eclair
* changes:
[Issue 2147295] Only showing visible contacts in contact Join UI
diff --git a/src/com/android/contacts/model/Editor.java b/src/com/android/contacts/model/Editor.java
index d6f7003..b7ae045 100644
--- a/src/com/android/contacts/model/Editor.java
+++ b/src/com/android/contacts/model/Editor.java
@@ -49,7 +49,7 @@
* builds any needed views. Any changes performed by the user will be
* written back to that same object.
*/
- public void setValues(DataKind kind, ValuesDelta values, EntityDelta state);
+ public void setValues(DataKind kind, ValuesDelta values, EntityDelta state, boolean readOnly);
/**
* Add a specific {@link EditorListener} to this {@link Editor}.
diff --git a/src/com/android/contacts/model/ExchangeSource.java b/src/com/android/contacts/model/ExchangeSource.java
index 0a7fb23..6d4e357 100644
--- a/src/com/android/contacts/model/ExchangeSource.java
+++ b/src/com/android/contacts/model/ExchangeSource.java
@@ -125,8 +125,6 @@
.add(buildPhoneType(Phone.TYPE_RADIO).setSecondary(true).setSpecificMax(1));
kind.typeList.add(buildPhoneType(Phone.TYPE_ASSISTANT).setSecondary(true)
.setSpecificMax(1).setCustomColumn(Phone.LABEL));
- kind.typeList.add(buildPhoneType(Phone.TYPE_CUSTOM).setSecondary(true)
- .setSpecificMax(1).setCustomColumn(Phone.LABEL));
kind.fieldList = Lists.newArrayList();
kind.fieldList.add(new EditField(Phone.NUMBER, R.string.phoneLabelsGroup, FLAGS_PHONE));
diff --git a/src/com/android/contacts/ui/widget/ContactEditorView.java b/src/com/android/contacts/ui/widget/ContactEditorView.java
index 35a32cf..cd94e52 100644
--- a/src/com/android/contacts/ui/widget/ContactEditorView.java
+++ b/src/com/android/contacts/ui/widget/ContactEditorView.java
@@ -173,6 +173,8 @@
EntityModifier.ensureKindExists(state, source, Photo.CONTENT_ITEM_TYPE);
mHasPhotoEditor = (source.getKindForMimetype(Photo.CONTENT_ITEM_TYPE) != null);
mPhoto.setVisibility(mHasPhotoEditor ? View.VISIBLE : View.GONE);
+ mPhoto.setEnabled(!source.readOnly);
+ mName.setEnabled(!source.readOnly);
mReadOnly.setVisibility(source.readOnly ? View.VISIBLE : View.GONE);
@@ -185,18 +187,18 @@
if (StructuredName.CONTENT_ITEM_TYPE.equals(mimeType)) {
// Handle special case editor for structured name
final ValuesDelta primary = state.getPrimaryEntry(mimeType);
- mName.setValues(kind, primary, state);
+ mName.setValues(kind, primary, state, source.readOnly);
} else if (Photo.CONTENT_ITEM_TYPE.equals(mimeType)) {
// Handle special case editor for photos
final ValuesDelta primary = state.getPrimaryEntry(mimeType);
- mPhoto.setValues(kind, primary, state);
+ mPhoto.setValues(kind, primary, state, source.readOnly);
} else {
// Otherwise use generic section-based editors
if (kind.fieldList == null) continue;
final ViewGroup parent = kind.secondary ? mSecondary : mGeneral;
final KindSectionView section = (KindSectionView)mInflater.inflate(
R.layout.item_kind_section, parent, false);
- section.setState(kind, state);
+ section.setState(kind, state, source.readOnly);
section.setId(kind.weight);
parent.addView(section);
}
diff --git a/src/com/android/contacts/ui/widget/GenericEditorView.java b/src/com/android/contacts/ui/widget/GenericEditorView.java
index 53dd2e0..6387374 100644
--- a/src/com/android/contacts/ui/widget/GenericEditorView.java
+++ b/src/com/android/contacts/ui/widget/GenericEditorView.java
@@ -70,6 +70,7 @@
protected DataKind mKind;
protected ValuesDelta mEntry;
protected EntityDelta mState;
+ protected boolean mReadOnly;
protected boolean mHideOptional = true;
@@ -113,6 +114,16 @@
mDelete.setVisibility(deletable ? View.VISIBLE : View.INVISIBLE);
}
+ public void setEnabled(boolean enabled) {
+ mLabel.setEnabled(enabled);
+ final int count = mFields.getChildCount();
+ for (int pos = 0; pos < count; pos++) {
+ final View v = mFields.getChildAt(pos);
+ v.setEnabled(enabled);
+ }
+ mMore.setEnabled(enabled);
+ }
+
/**
* Build the current label state based on selected {@link EditType} and
* possible custom label string.
@@ -144,17 +155,20 @@
}
private void rebuildValues() {
- setValues(mKind, mEntry, mState);
+ setValues(mKind, mEntry, mState, mReadOnly);
}
/**
* Prepare this editor using the given {@link DataKind} for defining
* structure and {@link ValuesDelta} describing the content to edit.
*/
- public void setValues(DataKind kind, ValuesDelta entry, EntityDelta state) {
+ public void setValues(DataKind kind, ValuesDelta entry, EntityDelta state, boolean readOnly) {
mKind = kind;
mEntry = entry;
mState = state;
+ mReadOnly = readOnly;
+
+ final boolean enabled = !readOnly;
if (!entry.isVisible()) {
// Hide ourselves entirely if deleted
@@ -167,6 +181,7 @@
// Display label selector if multiple types available
final boolean hasTypes = EntityModifier.hasEditTypes(kind);
mLabel.setVisibility(hasTypes ? View.VISIBLE : View.GONE);
+ mLabel.setEnabled(enabled);
if (hasTypes) {
mType = EntityModifier.getCurrentType(entry, kind);
rebuildLabel();
@@ -207,6 +222,7 @@
final boolean couldHide = (TextUtils.isEmpty(value) && field.optional);
final boolean willHide = (mHideOptional && couldHide);
fieldView.setVisibility(willHide ? View.GONE : View.VISIBLE);
+ fieldView.setEnabled(enabled);
hidePossible = hidePossible || couldHide;
mFields.addView(fieldView);
@@ -214,6 +230,7 @@
// When hiding fields, place expandable
mMore.setVisibility(hidePossible ? View.VISIBLE : View.GONE);
+ mMore.setEnabled(enabled);
}
/**
diff --git a/src/com/android/contacts/ui/widget/KindSectionView.java b/src/com/android/contacts/ui/widget/KindSectionView.java
index 5a63992..b52cfd0 100644
--- a/src/com/android/contacts/ui/widget/KindSectionView.java
+++ b/src/com/android/contacts/ui/widget/KindSectionView.java
@@ -50,6 +50,7 @@
private DataKind mKind;
private EntityDelta mState;
+ private boolean mReadOnly;
public KindSectionView(Context context) {
super(context);
@@ -87,9 +88,10 @@
// Ignore requests
}
- public void setState(DataKind kind, EntityDelta state) {
+ public void setState(DataKind kind, EntityDelta state, boolean readOnly) {
mKind = kind;
mState = state;
+ mReadOnly = readOnly;
// TODO: handle resources from remote packages
mTitle.setText(kind.titleRes);
@@ -114,7 +116,7 @@
final GenericEditorView editor = (GenericEditorView)mInflater.inflate(
R.layout.item_generic_editor, mEditors, false);
- editor.setValues(mKind, entry, mState);
+ editor.setValues(mKind, entry, mState, mReadOnly);
editor.setEditorListener(this);
editor.setId(entry.getViewId());
mEditors.addView(editor);
@@ -129,7 +131,8 @@
protected void updateAddEnabled() {
// Set enabled state on the "add" view
final boolean canInsert = EntityModifier.canInsert(mState, mKind);
- mAdd.setEnabled(canInsert);
+ final boolean isEnabled = !mReadOnly && canInsert;
+ mAdd.setEnabled(isEnabled);
}
/** {@inheritDoc} */
diff --git a/src/com/android/contacts/ui/widget/PhotoEditorView.java b/src/com/android/contacts/ui/widget/PhotoEditorView.java
index cde314d..184b907 100644
--- a/src/com/android/contacts/ui/widget/PhotoEditorView.java
+++ b/src/com/android/contacts/ui/widget/PhotoEditorView.java
@@ -74,7 +74,7 @@
}
/** {@inheritDoc} */
- public void setValues(DataKind kind, ValuesDelta values, EntityDelta state) {
+ public void setValues(DataKind kind, ValuesDelta values, EntityDelta state, boolean readOnly) {
mEntry = values;
if (values != null) {
// Try decoding photo if actual entry
@@ -85,6 +85,7 @@
setScaleType(ImageView.ScaleType.CENTER_CROP);
setImageBitmap(photo);
+ setEnabled(!readOnly);
mHasSetPhoto = true;
} else {
resetDefault();