use of com.android.contacts.common.model.account.AccountWithDataSet in project packages_apps_Contacts by AOKP.
the class ContactEditorUtils method getOverlayDefualtAccount.
private AccountWithDataSet getOverlayDefualtAccount() {
// if set the value of store contacts defalut
if (mContext.getResources().getBoolean(R.bool.def_storage_behavior_enabled)) {
List<AccountWithDataSet> accounts = getWritableAccounts();
if (accounts != null && accounts.size() != 0) {
String name = "";
String type = "";
// default Contacts storage postion
int store_pos = mContext.getResources().getInteger(R.integer.def_storage_position);
switch(store_pos) {
case DEFAULT_STORAGE_PHONE:
name = SimContactsConstants.PHONE_NAME;
type = SimContactsConstants.ACCOUNT_TYPE_PHONE;
break;
case DEFAULT_STORAGE_SIM_1:
TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
name = tm.getPhoneCount() > 1 ? SimContactsConstants.SIM_NAME_1 : SimContactsConstants.SIM_NAME;
type = SimContactsConstants.ACCOUNT_TYPE_SIM;
break;
case DEFAULT_STORAGE_SIM_2:
name = SimContactsConstants.SIM_NAME_2;
type = SimContactsConstants.ACCOUNT_TYPE_SIM;
break;
default:
Log.e(TAG, "Bad default contacts storage position," + " def_storage_position is " + store_pos);
break;
}
for (AccountWithDataSet account : accounts) {
if (name.equals(account.name) && type.equals(account.type)) {
return account;
}
}
}
}
return null;
}
use of com.android.contacts.common.model.account.AccountWithDataSet in project packages_apps_Contacts by AOKP.
the class GroupEditorFragment method save.
/**
* Saves or creates the group based on the mode, and if successful
* finishes the activity. This actually only handles saving the group name.
* @return true when successful
*/
public boolean save() {
if (!hasValidGroupName() || mStatus != Status.EDITING) {
mStatus = Status.CLOSING;
if (mListener != null) {
mListener.onReverted();
}
return false;
}
mClose = true;
// If we are about to close the editor - there is no need to refresh the data
getLoaderManager().destroyLoader(LOADER_EXISTING_MEMBERS);
// If there are no changes, then go straight to onSaveCompleted()
if (!hasNameChange() && !hasMembershipChange()) {
onSaveCompleted(false, mGroupUri);
return true;
}
mStatus = Status.SAVING;
Activity activity = getActivity();
// If the activity is not there anymore, then we can't continue with the save process.
if (activity == null) {
return false;
}
Intent saveIntent = null;
if (Intent.ACTION_INSERT.equals(mAction)) {
// Create array of raw contact IDs for contacts to add to the group
long[] membersToAddArray = convertToArray(mListMembersToAdd);
// Create the save intent to create the group and add members at the same time
saveIntent = ContactSaveService.createNewGroupIntent(activity, new AccountWithDataSet(mAccountName, mAccountType, mDataSet), mGroupNameView.getText().toString(), membersToAddArray, activity.getClass(), GroupEditorActivity.ACTION_SAVE_COMPLETED);
} else if (Intent.ACTION_EDIT.equals(mAction)) {
// Create array of raw contact IDs for contacts to add to the group
long[] membersToAddArray = convertToArray(mListMembersToAdd);
// Create array of raw contact IDs for contacts to add to the group
long[] membersToRemoveArray = convertToArray(mListMembersToRemove);
// Create the update intent (which includes the updated group name if necessary)
saveIntent = ContactSaveService.createGroupUpdateIntent(activity, mGroupId, getUpdatedName(), membersToAddArray, membersToRemoveArray, activity.getClass(), GroupEditorActivity.ACTION_SAVE_COMPLETED);
} else {
throw new IllegalStateException("Invalid intent action type " + mAction);
}
activity.startService(saveIntent);
return true;
}
use of com.android.contacts.common.model.account.AccountWithDataSet in project android_packages_apps_Dialer by LineageOS.
the class AccountTypeManagerImpl method findAllInvitableAccountTypes.
/**
* Return all {@link AccountType}s with at least one account which supports "invite", i.e. its
* {@link AccountType#getInviteContactActivityClassName()} is not empty.
*/
@VisibleForTesting
static Map<AccountTypeWithDataSet, AccountType> findAllInvitableAccountTypes(Context context, Collection<AccountWithDataSet> accounts, Map<AccountTypeWithDataSet, AccountType> accountTypesByTypeAndDataSet) {
Map<AccountTypeWithDataSet, AccountType> result = new ArrayMap<>();
for (AccountWithDataSet account : accounts) {
AccountTypeWithDataSet accountTypeWithDataSet = account.getAccountTypeWithDataSet();
AccountType type = accountTypesByTypeAndDataSet.get(accountTypeWithDataSet);
if (type == null) {
// just in case
continue;
}
if (result.containsKey(accountTypeWithDataSet)) {
continue;
}
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Type " + accountTypeWithDataSet + " inviteClass=" + type.getInviteContactActivityClassName());
}
if (!TextUtils.isEmpty(type.getInviteContactActivityClassName())) {
result.put(accountTypeWithDataSet, type);
}
}
return Collections.unmodifiableMap(result);
}
use of com.android.contacts.common.model.account.AccountWithDataSet in project android_packages_apps_Dialer by LineageOS.
the class ContactListFilterControllerImpl method filterAccountExists.
/**
* @return true if the Account for the current filter exists.
*/
private boolean filterAccountExists() {
final AccountTypeManager accountTypeManager = AccountTypeManager.getInstance(mAppContext);
final AccountWithDataSet filterAccount = new AccountWithDataSet(mFilter.accountName, mFilter.accountType, mFilter.dataSet);
return accountTypeManager.contains(filterAccount, false);
}
Aggregations