Search in sources :

Example 21 with AccountWithDataSet

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;
}
Also used : TelephonyManager(android.telephony.TelephonyManager) AccountWithDataSet(com.android.contacts.common.model.account.AccountWithDataSet)

Example 22 with AccountWithDataSet

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;
}
Also used : AccountWithDataSet(com.android.contacts.common.model.account.AccountWithDataSet) MultiPickContactActivity(com.android.contacts.activities.MultiPickContactActivity) GroupEditorActivity(com.android.contacts.activities.GroupEditorActivity) Activity(android.app.Activity) Intent(android.content.Intent)

Example 23 with AccountWithDataSet

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);
}
Also used : AccountWithDataSet(com.android.contacts.common.model.account.AccountWithDataSet) AccountTypeWithDataSet(com.android.contacts.common.model.account.AccountTypeWithDataSet) ArrayMap(android.util.ArrayMap) AccountType(com.android.contacts.common.model.account.AccountType) FallbackAccountType(com.android.contacts.common.model.account.FallbackAccountType) ExchangeAccountType(com.android.contacts.common.model.account.ExchangeAccountType) SamsungAccountType(com.android.contacts.common.model.account.SamsungAccountType) ExternalAccountType(com.android.contacts.common.model.account.ExternalAccountType) GoogleAccountType(com.android.contacts.common.model.account.GoogleAccountType) VisibleForTesting(android.support.annotation.VisibleForTesting)

Example 24 with AccountWithDataSet

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);
}
Also used : AccountWithDataSet(com.android.contacts.common.model.account.AccountWithDataSet) AccountTypeManager(com.android.contacts.common.model.AccountTypeManager)

Aggregations

AccountWithDataSet (com.android.contacts.common.model.account.AccountWithDataSet)24 AccountType (com.android.contacts.common.model.account.AccountType)7 Intent (android.content.Intent)4 Activity (android.app.Activity)3 View (android.view.View)3 AdapterView (android.widget.AdapterView)3 AccountTypeManager (com.android.contacts.common.model.AccountTypeManager)3 RawContactDelta (com.android.contacts.common.model.RawContactDelta)3 AccountsListAdapter (com.android.contacts.common.util.AccountsListAdapter)3 Account (android.accounts.Account)2 Uri (android.net.Uri)2 ArrayMap (android.util.ArrayMap)2 ListPopupWindow (android.widget.ListPopupWindow)2 TextView (android.widget.TextView)2 RawContact (com.android.contacts.common.model.RawContact)2 ValuesDelta (com.android.contacts.common.model.ValuesDelta)2 AccountTypeWithDataSet (com.android.contacts.common.model.account.AccountTypeWithDataSet)2 ExchangeAccountType (com.android.contacts.common.model.account.ExchangeAccountType)2 ExternalAccountType (com.android.contacts.common.model.account.ExternalAccountType)2 FallbackAccountType (com.android.contacts.common.model.account.FallbackAccountType)2