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

Commit 0addfc7f authored by Doris Liu's avatar Doris Liu
Browse files

Save edited picasa to "Edited Online Photos" album

Bug: 7346157

This CL includes the following changes:
1) Save the new image to a new folder named "Edited Online Photos"
2) After the picture is saved, the user will be in the "Edited Online Photos" folder
3) Change the toast during saving to "Saving to" + new folder name

Change-Id: Ic505925425419ba9e3c7dac31fd403bf73d6887d
parent ef8597fe
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -70,6 +70,10 @@
    <string name="multiface_crop_help">Touch a face to begin.</string>
    <!-- Toast/alert that the image is being saved to the SD card -->
    <string name="saving_image">Saving picture\u2026</string>

    <!-- Toast/alert that the image is being saved after editing in filtershow [CHAR LIMIT=40]-->
    <string name="filtershow_saving_image">Saving picture to <xliff:g id="album_name">%1$s</xliff:g> \u2026</string>

    <!-- Eorror toast message that the image cannot be saved [CHAR LIMIT=40]-->
    <string name="save_error">Couldn\'t save cropped image.</string>

@@ -459,6 +463,9 @@
    <!-- The label for the folder contains downloaded pictures. [CHAR LIMIT=20]-->
    <string name="folder_download">Download</string>

    <!-- The label for the folder contains edited online pictures. [CHAR LIMIT=40]-->
    <string name="folder_edited_online_photos">Edited Online Photos</string>

    <!-- The label for the folder contains pictures that was imported from an
         external camera. [CHAR LIMIT=20]-->
    <string name="folder_imported">Imported</string>
+10 −0
Original line number Diff line number Diff line
@@ -1180,6 +1180,16 @@ public class PhotoPage extends ActivityState implements
        Path path = mApplication.getDataManager()
                .findPathByUri(intent.getData(), intent.getType());
        if (path != null) {
            Path albumPath = mApplication.getDataManager().getDefaultSetOf(path);
            if (!albumPath.equalsIgnoreCase(mOriginalSetPathString)) {
                // If the edited image is stored in a different album, we need
                // to start a new activity state to show the new image
                Bundle data = new Bundle(getData());
                data.putString(KEY_MEDIA_SET_PATH, albumPath.toString());
                data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, path.toString());
                mActivity.getStateManager().startState(PhotoPage.class, data);
                return;
            }
            mModel.setCurrentPhoto(path, mCurrentIndex);
        }
    }
+3 −1
Original line number Diff line number Diff line
@@ -274,7 +274,7 @@ public class LocalAlbum extends MediaSet {
        return true;
    }

    private static String getLocalizedName(Resources res, int bucketId,
    public static String getLocalizedName(Resources res, int bucketId,
            String name) {
        if (bucketId == MediaSetUtils.CAMERA_BUCKET_ID) {
            return res.getString(R.string.folder_camera);
@@ -284,6 +284,8 @@ public class LocalAlbum extends MediaSet {
            return res.getString(R.string.folder_imported);
        } else if (bucketId == MediaSetUtils.SNAPSHOT_BUCKET_ID) {
            return res.getString(R.string.folder_screenshot);
        } else if (bucketId == MediaSetUtils.EDITED_ONLINE_PHOTOS_BUCKET_ID) {
            return res.getString(R.string.folder_edited_online_photos);
        } else {
            return name;
        }
+6 −0
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ public class Path {
    }

    @Override
    // TODO: toString() should be more efficient, will fix it later
    public String toString() {
        synchronized (Path.class) {
            StringBuilder sb = new StringBuilder();
@@ -91,6 +92,11 @@ public class Path {
        }
    }

    public boolean equalsIgnoreCase (String p) {
        String path = toString();
        return path.equalsIgnoreCase(p);
    }

    public static Path fromString(String s) {
        synchronized (Path.class) {
            String[] segments = split(s);
+17 −4
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import android.app.ActionBar;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -34,6 +35,7 @@ import android.widget.ShareActionProvider.OnShareTargetSelectedListener;
import android.widget.Toast;

import com.android.gallery3d.R;
import com.android.gallery3d.data.LocalAlbum;
import com.android.gallery3d.filtershow.cache.ImageLoader;
import com.android.gallery3d.filtershow.filters.ImageFilter;
import com.android.gallery3d.filtershow.filters.ImageFilterBorder;
@@ -64,6 +66,7 @@ import com.android.gallery3d.filtershow.tools.SaveCopyTask;
import com.android.gallery3d.filtershow.ui.ImageButtonTitle;
import com.android.gallery3d.filtershow.ui.ImageCurves;
import com.android.gallery3d.filtershow.ui.Spline;
import com.android.gallery3d.util.GalleryUtils;

import java.io.File;
import java.lang.ref.WeakReference;
@@ -363,7 +366,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
        return (133 * msize) / metrics.densityDpi;
    }

    private void showSavingProgress() {
    private void showSavingProgress(String albumName) {
        ProgressDialog progress;
        if (mSavingProgressDialog != null) {
            progress = mSavingProgressDialog.get();
@@ -373,7 +376,13 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
            }
        }
        // TODO: Allow cancellation of the saving process
        progress = ProgressDialog.show(this, "", getString(R.string.saving_image), true, false);
        String progressText;
        if (albumName == null) {
            progressText = getString(R.string.saving_image);
        } else {
            progressText = getString(R.string.filtershow_saving_image, albumName);
        }
        progress = ProgressDialog.show(this, "", progressText, true, false);
        mSavingProgressDialog = new WeakReference<ProgressDialog>(progress);
    }

@@ -411,7 +420,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
        mSharingImage = true;

        // Process and save the image in the background.
        showSavingProgress();
        showSavingProgress(null);
        mImageShow.saveImage(this, mSharedOutputFile);
        return true;
    }
@@ -823,7 +832,11 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,

    public void saveImage() {
        if (mImageShow.hasModifications()) {
            showSavingProgress();
            // Get the name of the album, to which the image will be saved
            File saveDir = SaveCopyTask.getFinalSaveDirectory(this, mImageLoader.getUri());
            int bucketId = GalleryUtils.getBucketId(saveDir.getPath());
            String albumName = LocalAlbum.getLocalizedName(getResources(), bucketId, null);
            showSavingProgress(albumName);
            mImageShow.saveImage(this, null);
        } else {
            finish();
Loading