use of com.android.contacts.common.model.dataitem.DataKind in project android_packages_apps_Dialer by LineageOS.
the class ExternalAccountType method inflate.
/**
* Inflate this {@link AccountType} from the given parser. This may only load details matching the
* publicly-defined schema.
*/
protected void inflate(Context context, XmlPullParser parser) throws DefinitionException {
final AttributeSet attrs = Xml.asAttributeSet(parser);
try {
int type;
while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) {
// Drain comments and whitespace
}
if (type != XmlPullParser.START_TAG) {
throw new IllegalStateException("No start tag found");
}
String rootTag = parser.getName();
if (!TAG_CONTACTS_ACCOUNT_TYPE.equals(rootTag) && !TAG_CONTACTS_SOURCE_LEGACY.equals(rootTag)) {
throw new IllegalStateException("Top level element must be " + TAG_CONTACTS_ACCOUNT_TYPE + ", not " + rootTag);
}
mHasContactsMetadata = true;
int attributeCount = parser.getAttributeCount();
for (int i = 0; i < attributeCount; i++) {
String attr = parser.getAttributeName(i);
String value = parser.getAttributeValue(i);
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, attr + "=" + value);
}
if (ATTR_EDIT_CONTACT_ACTIVITY.equals(attr)) {
mEditContactActivityClassName = value;
} else if (ATTR_CREATE_CONTACT_ACTIVITY.equals(attr)) {
mCreateContactActivityClassName = value;
} else if (ATTR_INVITE_CONTACT_ACTIVITY.equals(attr)) {
mInviteContactActivity = value;
} else if (ATTR_INVITE_CONTACT_ACTION_LABEL.equals(attr)) {
mInviteActionLabelAttribute = value;
} else if (ATTR_VIEW_CONTACT_NOTIFY_SERVICE.equals(attr)) {
mViewContactNotifyService = value;
} else if (ATTR_VIEW_GROUP_ACTIVITY.equals(attr)) {
mViewGroupActivity = value;
} else if (ATTR_VIEW_GROUP_ACTION_LABEL.equals(attr)) {
mViewGroupLabelAttribute = value;
} else if (ATTR_DATA_SET.equals(attr)) {
dataSet = value;
} else if (ATTR_EXTENSION_PACKAGE_NAMES.equals(attr)) {
mExtensionPackageNames.add(value);
} else if (ATTR_ACCOUNT_TYPE.equals(attr)) {
accountType = value;
} else if (ATTR_ACCOUNT_LABEL.equals(attr)) {
mAccountTypeLabelAttribute = value;
} else if (ATTR_ACCOUNT_ICON.equals(attr)) {
mAccountTypeIconAttribute = value;
} else {
Log.e(TAG, "Unsupported attribute " + attr);
}
}
// Parse all children kinds
final int startDepth = parser.getDepth();
while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > startDepth) && type != XmlPullParser.END_DOCUMENT) {
if (type != XmlPullParser.START_TAG || parser.getDepth() != startDepth + 1) {
// Not a direct child tag
continue;
}
String tag = parser.getName();
if (TAG_EDIT_SCHEMA.equals(tag)) {
mHasEditSchema = true;
parseEditSchema(context, parser, attrs);
} else if (TAG_CONTACTS_DATA_KIND.equals(tag)) {
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ContactsDataKind);
final DataKind kind = new DataKind();
kind.mimeType = a.getString(R.styleable.ContactsDataKind_android_mimeType);
final String summaryColumn = a.getString(R.styleable.ContactsDataKind_android_summaryColumn);
if (summaryColumn != null) {
// Inflate a specific column as summary when requested
kind.actionHeader = new SimpleInflater(summaryColumn);
}
final String detailColumn = a.getString(R.styleable.ContactsDataKind_android_detailColumn);
if (detailColumn != null) {
// Inflate specific column as summary
kind.actionBody = new SimpleInflater(detailColumn);
}
a.recycle();
addKind(kind);
}
}
} catch (XmlPullParserException e) {
throw new DefinitionException("Problem reading XML", e);
} catch (IOException e) {
throw new DefinitionException("Problem reading XML", e);
}
}
use of com.android.contacts.common.model.dataitem.DataKind in project android_packages_apps_Dialer by LineageOS.
the class GoogleAccountType method addDataKindRelation.
private DataKind addDataKindRelation(Context context) throws DefinitionException {
DataKind kind = addKind(new DataKind(Relation.CONTENT_ITEM_TYPE, R.string.relationLabelsGroup, Weight.RELATIONSHIP, true));
kind.actionHeader = new RelationActionInflater();
kind.actionBody = new SimpleInflater(Relation.NAME);
kind.typeColumn = Relation.TYPE;
kind.typeList = new ArrayList<>();
kind.typeList.add(buildRelationType(Relation.TYPE_ASSISTANT));
kind.typeList.add(buildRelationType(Relation.TYPE_BROTHER));
kind.typeList.add(buildRelationType(Relation.TYPE_CHILD));
kind.typeList.add(buildRelationType(Relation.TYPE_DOMESTIC_PARTNER));
kind.typeList.add(buildRelationType(Relation.TYPE_FATHER));
kind.typeList.add(buildRelationType(Relation.TYPE_FRIEND));
kind.typeList.add(buildRelationType(Relation.TYPE_MANAGER));
kind.typeList.add(buildRelationType(Relation.TYPE_MOTHER));
kind.typeList.add(buildRelationType(Relation.TYPE_PARENT));
kind.typeList.add(buildRelationType(Relation.TYPE_PARTNER));
kind.typeList.add(buildRelationType(Relation.TYPE_REFERRED_BY));
kind.typeList.add(buildRelationType(Relation.TYPE_RELATIVE));
kind.typeList.add(buildRelationType(Relation.TYPE_SISTER));
kind.typeList.add(buildRelationType(Relation.TYPE_SPOUSE));
kind.typeList.add(buildRelationType(Relation.TYPE_CUSTOM).setSecondary(true).setCustomColumn(Relation.LABEL));
kind.defaultValues = new ContentValues();
kind.defaultValues.put(Relation.TYPE, Relation.TYPE_SPOUSE);
kind.fieldList = new ArrayList<>();
kind.fieldList.add(new EditField(Relation.DATA, R.string.relationLabelsGroup, FLAGS_RELATION));
return kind;
}
use of com.android.contacts.common.model.dataitem.DataKind in project android_packages_apps_Dialer by LineageOS.
the class SamsungAccountType method addDataKindEvent.
private DataKind addDataKindEvent(Context context) throws DefinitionException {
DataKind kind = addKind(new DataKind(Event.CONTENT_ITEM_TYPE, R.string.eventLabelsGroup, 150, true));
kind.actionHeader = new EventActionInflater();
kind.actionBody = new SimpleInflater(Event.START_DATE);
kind.typeColumn = Event.TYPE;
kind.typeList = new ArrayList<>();
kind.dateFormatWithoutYear = CommonDateUtils.NO_YEAR_DATE_FORMAT;
kind.dateFormatWithYear = CommonDateUtils.FULL_DATE_FORMAT;
kind.typeList.add(buildEventType(Event.TYPE_BIRTHDAY, true).setSpecificMax(1));
kind.typeList.add(buildEventType(Event.TYPE_ANNIVERSARY, false));
kind.typeList.add(buildEventType(Event.TYPE_OTHER, false));
kind.typeList.add(buildEventType(Event.TYPE_CUSTOM, false).setSecondary(true).setCustomColumn(Event.LABEL));
kind.defaultValues = new ContentValues();
kind.defaultValues.put(Event.TYPE, Event.TYPE_BIRTHDAY);
kind.fieldList = new ArrayList<>();
kind.fieldList.add(new EditField(Event.DATA, R.string.eventLabelsGroup, FLAGS_EVENT));
return kind;
}
use of com.android.contacts.common.model.dataitem.DataKind in project android_packages_apps_Dialer by LineageOS.
the class SamsungAccountType method addDataKindEmail.
@Override
protected DataKind addDataKindEmail(Context context) throws DefinitionException {
final DataKind kind = super.addDataKindEmail(context);
kind.typeColumn = Email.TYPE;
kind.typeList = new ArrayList<>();
kind.typeList.add(buildEmailType(Email.TYPE_HOME));
kind.typeList.add(buildEmailType(Email.TYPE_WORK));
kind.typeList.add(buildEmailType(Email.TYPE_OTHER));
kind.typeList.add(buildEmailType(Email.TYPE_CUSTOM).setSecondary(true).setCustomColumn(Email.LABEL));
kind.fieldList = new ArrayList<>();
kind.fieldList.add(new EditField(Email.DATA, R.string.emailLabelsGroup, FLAGS_EMAIL));
return kind;
}
use of com.android.contacts.common.model.dataitem.DataKind in project packages_apps_Contacts by AOKP.
the class ConfirmAddDetailActivity method bindEditor.
/**
* Rebuild the editor to match our underlying {@link #mEntityDeltaList} object.
*/
private void bindEditor() {
if (mEntityDeltaList == null) {
throw new IllegalStateException();
}
// account type to use. In this case, display an error message and hide the "OK" button.
if (mIsReadOnly) {
mReadOnlyWarningView.setText(getString(R.string.contact_read_only));
mReadOnlyWarningView.setVisibility(View.VISIBLE);
mEditorContainerView.setVisibility(View.GONE);
findViewById(R.id.btn_done).setVisibility(View.GONE);
// Nothing more to be done, just show the UI
return;
}
// Otherwise display an editor that allows the user to add the data to this raw contact.
for (DataKind kind : mEditableAccountType.getSortedDataKinds()) {
// Skip kind that are not editable
if (!kind.editable)
continue;
if (mMimetype.equals(kind.mimeType)) {
final ArrayList<ValuesDelta> deltas = mRawContactDelta.getMimeEntries(mMimetype);
if (deltas != null) {
for (ValuesDelta valuesDelta : deltas) {
// Skip entries that aren't visible
if (!valuesDelta.isVisible())
continue;
if (valuesDelta.isInsert()) {
inflateEditorView(kind, valuesDelta, mRawContactDelta);
return;
}
}
}
}
}
}
Aggregations