Search in sources :

Example 6 with RawContactDeltaList

use of com.android.contacts.common.model.RawContactDeltaList in project packages_apps_Contacts by AOKP.

the class AttachPhotoActivity method saveContact.

/**
 * If prerequisites have been met, attach the photo to a raw-contact and save.
 * The prerequisites are:
 * - photo has been cropped
 * - contact has been loaded
 */
private void saveContact(Contact contact) {
    if (contact.getRawContacts() == null) {
        Log.w(TAG, "No raw contacts found for contact");
        finish();
        return;
    }
    // Obtain the raw-contact that we will save to.
    RawContactDeltaList deltaList = contact.createRawContactDeltaList();
    RawContactDelta raw = deltaList.getFirstWritableRawContact(this);
    if (raw == null) {
        // We can't directly insert this photo since no raw contacts exist in the contact.
        selectAccountAndCreateContact();
        return;
    }
    saveToContact(contact, deltaList, raw);
}
Also used : RawContactDeltaList(com.android.contacts.common.model.RawContactDeltaList) RawContactDelta(com.android.contacts.common.model.RawContactDelta)

Example 7 with RawContactDeltaList

use of com.android.contacts.common.model.RawContactDeltaList in project packages_apps_Contacts by AOKP.

the class ContactEditorBaseFragment method onCreate.

@Override
public void onCreate(Bundle savedState) {
    if (savedState != null) {
        // Restore mUri before calling super.onCreate so that onInitializeLoaders
        // would already have a uri and an action to work with
        mAction = savedState.getString(KEY_ACTION);
        mLookupUri = savedState.getParcelable(KEY_URI);
    }
    super.onCreate(savedState);
    if (savedState == null) {
        mViewIdGenerator = new ViewIdGenerator();
    } else {
        mViewIdGenerator = savedState.getParcelable(KEY_VIEW_ID_GENERATOR);
        mAutoAddToDefaultGroup = savedState.getBoolean(KEY_AUTO_ADD_TO_DEFAULT_GROUP);
        mDisableDeleteMenuOption = savedState.getBoolean(KEY_DISABLE_DELETE_MENU_OPTION);
        mNewLocalProfile = savedState.getBoolean(KEY_NEW_LOCAL_PROFILE);
        mMaterialPalette = savedState.getParcelable(KEY_MATERIAL_PALETTE);
        mPhotoId = savedState.getLong(KEY_PHOTO_ID);
        mRawContacts = ImmutableList.copyOf(savedState.<RawContact>getParcelableArrayList(KEY_RAW_CONTACTS));
        // NOTE: mGroupMetaData is not saved/restored
        // Read state from savedState. No loading involved here
        mState = savedState.<RawContactDeltaList>getParcelable(KEY_EDIT_STATE);
        mStatus = savedState.getInt(KEY_STATUS);
        mRawContactDisplayAloneIsReadOnly = savedState.getBoolean(KEY_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY);
        mHasNewContact = savedState.getBoolean(KEY_HAS_NEW_CONTACT);
        mNewContactDataReady = savedState.getBoolean(KEY_NEW_CONTACT_READY);
        mIsEdit = savedState.getBoolean(KEY_IS_EDIT);
        mExistingContactDataReady = savedState.getBoolean(KEY_EXISTING_CONTACT_READY);
        mIsUserProfile = savedState.getBoolean(KEY_IS_USER_PROFILE);
        // Phone specific options menus
        mSendToVoicemailState = savedState.getBoolean(KEY_SEND_TO_VOICE_MAIL_STATE);
        mArePhoneOptionsChangable = savedState.getBoolean(KEY_ARE_PHONE_OPTIONS_CHANGEABLE);
        mCustomRingtone = savedState.getString(KEY_CUSTOM_RINGTONE);
        mEnabled = savedState.getBoolean(KEY_ENABLED);
        // Aggregation PopupWindow
        mAggregationSuggestionsRawContactId = savedState.getLong(KEY_AGGREGATION_SUGGESTIONS_RAW_CONTACT_ID);
        // Join Activity
        mContactIdForJoin = savedState.getLong(KEY_CONTACT_ID_FOR_JOIN);
        mReadOnlyDisplayName = savedState.getString(KEY_READ_ONLY_DISPLAY_NAME);
    }
    // onSaveInstanceState was called.
    if (mState == null) {
        mState = new RawContactDeltaList();
    }
}
Also used : RawContact(com.android.contacts.common.model.RawContact) RawContactDeltaList(com.android.contacts.common.model.RawContactDeltaList)

Aggregations

RawContactDeltaList (com.android.contacts.common.model.RawContactDeltaList)7 RawContactDelta (com.android.contacts.common.model.RawContactDelta)4 Intent (android.content.Intent)3 AccountTypeManager (com.android.contacts.common.model.AccountTypeManager)3 Uri (android.net.Uri)2 AccountType (com.android.contacts.common.model.account.AccountType)2 ContentProviderOperation (android.content.ContentProviderOperation)1 ContentProviderResult (android.content.ContentProviderResult)1 ContentResolver (android.content.ContentResolver)1 OperationApplicationException (android.content.OperationApplicationException)1 Cursor (android.database.Cursor)1 Bundle (android.os.Bundle)1 RemoteException (android.os.RemoteException)1 CPOWrapper (com.android.contacts.common.model.CPOWrapper)1 RawContact (com.android.contacts.common.model.RawContact)1 ValuesDelta (com.android.contacts.common.model.ValuesDelta)1 SimAccountType (com.android.contacts.common.model.account.SimAccountType)1 DataKind (com.android.contacts.common.model.dataitem.DataKind)1 ArrayList (java.util.ArrayList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1