use of com.android.contacts.common.model.account.AccountType in project packages_apps_Contacts by AOKP.
the class CompactRawContactsEditorView method addRawContactAccountSelector.
private void addRawContactAccountSelector(String accountsSummary, final RawContactAccountListAdapter adapter) {
mRawContactContainer.setVisibility(View.VISIBLE);
mRawContactSummary.setText(accountsSummary);
mRawContactContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final ListPopupWindow popup = new ListPopupWindow(getContext(), null);
popup.setWidth(mRawContactContainer.getWidth());
popup.setAnchorView(mRawContactContainer);
popup.setAdapter(adapter);
popup.setModal(true);
popup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
UiClosables.closeQuietly(popup);
if (mListener != null) {
final long rawContactId = adapter.getItemId(position);
final Uri rawContactUri = ContentUris.withAppendedId(ContactsContract.RawContacts.CONTENT_URI, rawContactId);
final RawContactDelta rawContactDelta = adapter.getItem(position);
final AccountTypeManager accountTypes = AccountTypeManager.getInstance(getContext());
final AccountType accountType = rawContactDelta.getAccountType(accountTypes);
final boolean isReadOnly = !accountType.areContactsWritable();
mListener.onRawContactSelected(rawContactUri, rawContactId, isReadOnly);
}
}
});
popup.show();
}
});
}
use of com.android.contacts.common.model.account.AccountType in project packages_apps_Contacts by AOKP.
the class CompactRawContactsEditorView method addAccountHeader.
private void addAccountHeader(Pair<String, String> accountInfo) {
mAccountHeaderContainer.setVisibility(View.VISIBLE);
// Set the account name
final String accountName = TextUtils.isEmpty(accountInfo.first) ? accountInfo.second : accountInfo.first;
mAccountHeaderName.setVisibility(View.VISIBLE);
mAccountHeaderName.setText(accountName);
// Set the account type
final String selectorTitle = getResources().getString(R.string.compact_editor_account_selector_title);
mAccountHeaderType.setText(selectorTitle);
// Set the icon
if (mPrimaryNameKindSectionData != null) {
final RawContactDelta rawContactDelta = mPrimaryNameKindSectionData.first.getRawContactDelta();
if (rawContactDelta != null) {
final AccountType accountType = rawContactDelta.getRawContactAccountType(getContext());
mAccountHeaderIcon.setImageDrawable(accountType.getDisplayIcon(getContext()));
}
}
// Set the content description
mAccountHeaderContainer.setContentDescription(EditorUiUtils.getAccountInfoContentDescription(accountName, selectorTitle));
}
use of com.android.contacts.common.model.account.AccountType in project packages_apps_Contacts by AOKP.
the class ContactEditorBaseFragment method setState.
//
// Data binding
//
private void setState(Contact contact) {
// If we have already loaded data, we do not want to change it here to not confuse the user
if (!mState.isEmpty()) {
Log.v(TAG, "Ignoring background change. This will have to be rebased later");
return;
}
// See if this edit operation needs to be redirected to a custom editor
mRawContacts = contact.getRawContacts();
if (mRawContacts.size() == 1) {
RawContact rawContact = mRawContacts.get(0);
String type = rawContact.getAccountTypeString();
String dataSet = rawContact.getDataSet();
AccountType accountType = rawContact.getAccountType(mContext);
if (accountType.getEditContactActivityClassName() != null && !accountType.areContactsWritable()) {
if (mListener != null) {
String name = rawContact.getAccountName();
long rawContactId = rawContact.getId();
mListener.onCustomEditContactActivityRequested(new AccountWithDataSet(name, type, dataSet), ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), mIntentExtras, true);
}
return;
}
}
String readOnlyDisplayName = null;
// can edit. For the user profile case, there is already an editable contact.
if (!contact.isUserProfile() && !contact.isWritableContact(mContext)) {
mHasNewContact = true;
// This is potentially an asynchronous call and will add deltas to list.
selectAccountAndCreateContact();
readOnlyDisplayName = contact.getDisplayName();
} else {
mHasNewContact = false;
}
// This also adds deltas to list. If readOnlyDisplayName is null at this point it is
// simply ignored later on by the editor.
setStateForExistingContact(readOnlyDisplayName, contact.isUserProfile(), mRawContacts);
}
use of com.android.contacts.common.model.account.AccountType in project packages_apps_Contacts by AOKP.
the class ContactEditorBaseFragment method rebindEditorsForNewContact.
/**
* Removes a current editor ({@link #mState}) and rebinds new editor for a new account.
* Some of old data are reused with new restriction enforced by the new account.
*
* @param oldState Old data being edited.
* @param oldAccount Old account associated with oldState.
* @param newAccount New account to be used.
*/
protected void rebindEditorsForNewContact(RawContactDelta oldState, AccountWithDataSet oldAccount, AccountWithDataSet newAccount) {
AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
AccountType oldAccountType = accountTypes.getAccountTypeForAccount(oldAccount);
AccountType newAccountType = accountTypes.getAccountTypeForAccount(newAccount);
if (newAccountType.getCreateContactActivityClassName() != null) {
Log.w(TAG, "external activity called in rebind situation");
if (mListener != null) {
mListener.onCustomCreateContactActivityRequested(newAccount, mIntentExtras);
}
} else {
mExistingContactDataReady = false;
mNewContactDataReady = false;
mState = new RawContactDeltaList();
setStateForNewContact(newAccount, newAccountType, oldState, oldAccountType, isEditingUserProfile());
if (mIsEdit) {
setStateForExistingContact(mReadOnlyDisplayName, isEditingUserProfile(), mRawContacts);
}
}
}
use of com.android.contacts.common.model.account.AccountType in project packages_apps_Contacts by AOKP.
the class GroupDetailFragment method updateSize.
/**
* Display the count of the number of group members.
* @param size of the group (can be -1 if no size could be determined)
*/
private void updateSize(int size) {
String groupSizeString;
if (size == -1) {
groupSizeString = null;
} else {
AccountType accountType = mAccountTypeManager.getAccountType(mAccountTypeString, mDataSet);
final CharSequence dispLabel = accountType.getDisplayLabel(mContext);
if (!TextUtils.isEmpty(dispLabel)) {
String groupSizeTemplateString = getResources().getQuantityString(R.plurals.num_contacts_in_group, size);
groupSizeString = String.format(groupSizeTemplateString, size, dispLabel);
} else {
String groupSizeTemplateString = getResources().getQuantityString(R.plurals.group_list_num_contacts_in_group, size);
groupSizeString = String.format(groupSizeTemplateString, size);
}
}
if (mGroupSize != null) {
mGroupSize.setText(groupSizeString);
} else {
mListener.onGroupSizeUpdated(groupSizeString);
}
}
Aggregations