Search in sources :

Example 1 with AccountType

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();
        }
    });
}
Also used : ListPopupWindow(android.widget.ListPopupWindow) AdapterView(android.widget.AdapterView) AccountTypeManager(com.android.contacts.common.model.AccountTypeManager) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) Uri(android.net.Uri) RawContactDelta(com.android.contacts.common.model.RawContactDelta) AccountType(com.android.contacts.common.model.account.AccountType)

Example 2 with AccountType

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

Example 3 with AccountType

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

Example 4 with AccountType

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

Example 5 with AccountType

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

Aggregations

AccountType (com.android.contacts.common.model.account.AccountType)34 AccountTypeManager (com.android.contacts.common.model.AccountTypeManager)13 Intent (android.content.Intent)7 RawContactDelta (com.android.contacts.common.model.RawContactDelta)7 AccountWithDataSet (com.android.contacts.common.model.account.AccountWithDataSet)7 Uri (android.net.Uri)6 ValuesDelta (com.android.contacts.common.model.ValuesDelta)6 GoogleAccountType (com.android.contacts.common.model.account.GoogleAccountType)6 View (android.view.View)4 TextView (android.widget.TextView)4 RawContact (com.android.contacts.common.model.RawContact)4 AccountTypeWithDataSet (com.android.contacts.common.model.account.AccountTypeWithDataSet)4 ExchangeAccountType (com.android.contacts.common.model.account.ExchangeAccountType)4 ExternalAccountType (com.android.contacts.common.model.account.ExternalAccountType)4 FallbackAccountType (com.android.contacts.common.model.account.FallbackAccountType)4 SamsungAccountType (com.android.contacts.common.model.account.SamsungAccountType)4 ArrayMap (android.util.ArrayMap)3 OnClickListener (android.view.View.OnClickListener)3 ImageView (android.widget.ImageView)3 DataKind (com.android.contacts.common.model.dataitem.DataKind)3