Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5f35f34f authored by Jay Shrauner's avatar Jay Shrauner Committed by Gerrit Code Review
Browse files

Merge "Pop-up "couldn't save contact changes" while switch ap during change the contact photo."

parents 6b73f40a 3a4e7a28
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -317,6 +317,8 @@ public class ContactSaveService extends IntentService {
        serviceIntent.setAction(ContactSaveService.ACTION_SAVE_CONTACT);
        serviceIntent.putExtra(EXTRA_CONTACT_STATE, (Parcelable) state);
        serviceIntent.putExtra(EXTRA_SAVE_IS_PROFILE, isProfile);
        serviceIntent.putExtra(EXTRA_SAVE_MODE, saveMode);

        if (updatedPhotos != null) {
            serviceIntent.putExtra(EXTRA_UPDATED_PHOTOS, (Parcelable) updatedPhotos);
        }
@@ -337,7 +339,7 @@ public class ContactSaveService extends IntentService {
        RawContactDeltaList state = intent.getParcelableExtra(EXTRA_CONTACT_STATE);
        boolean isProfile = intent.getBooleanExtra(EXTRA_SAVE_IS_PROFILE, false);
        Bundle updatedPhotos = intent.getParcelableExtra(EXTRA_UPDATED_PHOTOS);

        int saveMode = intent.getIntExtra(EXTRA_SAVE_MODE, -1);
        // Trim any empty fields, and RawContacts, before persisting
        final AccountTypeManager accountTypes = AccountTypeManager.getInstance(this);
        RawContactModifier.trimEmpty(state, accountTypes);
@@ -469,7 +471,7 @@ public class ContactSaveService extends IntentService {
                    }
                }

                if (!saveUpdatedPhoto(rawContactId, photoUri)) succeeded = false;
                if (!saveUpdatedPhoto(rawContactId, photoUri, saveMode)) succeeded = false;
            }
        }

@@ -490,12 +492,12 @@ public class ContactSaveService extends IntentService {
     * Save updated photo for the specified raw-contact.
     * @return true for success, false for failure
     */
    private boolean saveUpdatedPhoto(long rawContactId, Uri photoUri) {
    private boolean saveUpdatedPhoto(long rawContactId, Uri photoUri, int saveMode) {
        final Uri outputUri = Uri.withAppendedPath(
                ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
                RawContacts.DisplayPhoto.CONTENT_DIRECTORY);

        return ContactPhotoUtils.savePhotoFromUriToUri(this, photoUri, outputUri, true);
        return ContactPhotoUtils.savePhotoFromUriToUri(this, photoUri, outputUri, (saveMode == 0));
    }

    /**