diff options
| author | Ruben Brunk <rubenbrunk@google.com> | 2013-03-30 01:03:24 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-03-30 01:03:24 +0000 |
| commit | e0e9fff3ff81faec02b243eabb1502a97a4e4adb (patch) | |
| tree | 7c58c44404f9b33015b0559a38075448c3c85abb /src | |
| parent | fe2aa4ba06d045895d0d038627547e02adc6b945 (diff) | |
| parent | a3dbbd7dcbd9aead7b10653b95685f5d2a71947a (diff) | |
| download | android_packages_apps_Gallery2-e0e9fff3ff81faec02b243eabb1502a97a4e4adb.tar.gz android_packages_apps_Gallery2-e0e9fff3ff81faec02b243eabb1502a97a4e4adb.tar.bz2 android_packages_apps_Gallery2-e0e9fff3ff81faec02b243eabb1502a97a4e4adb.zip | |
Merge "Added "discard unsaved changes" behavior for exiting." into gb-ub-photos-bryce
Diffstat (limited to 'src')
| -rw-r--r-- | src/com/android/gallery3d/filtershow/FilterShowActivity.java | 62 |
1 files changed, 47 insertions, 15 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index 409f1e366..90ef74e2f 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -18,10 +18,12 @@ package com.android.gallery3d.filtershow; import android.app.ActionBar; import android.app.Activity; +import android.app.AlertDialog; import android.app.ProgressDialog; import android.app.WallpaperManager; import android.content.ContentValues; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.res.Configuration; import android.content.res.Resources; @@ -972,7 +974,30 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, @Override public void onBackPressed() { if (mPanelController.onBackPressed()) { - saveImage(); + if (detectSpecialExitCases()) { + saveImage(); + } else if(!mImageShow.hasModifications()) { + done(); + } else { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage(R.string.unsaved).setTitle(R.string.save_before_exit); + builder.setPositiveButton(R.string.save_and_exit, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + saveImage(); + } + }); + builder.setNeutralButton(R.string.exit, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + done(); + } + }); + builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + } + }); + + AlertDialog dialog = builder.show(); + } } } @@ -1026,6 +1051,27 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, private boolean mOutputted = false; public void saveImage() { + handleSpecialExitCases(); + if (!mOutputted) { + if (mImageShow.hasModifications()) { + // 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 { + done(); + } + } + } + + public boolean detectSpecialExitCases() { + return mCropExtras != null && (mCropExtras.getExtraOutput() != null + || mCropExtras.getSetAsWallpaper() || mCropExtras.getReturnData()); + } + + public void handleSpecialExitCases() { if (mCropExtras != null) { if (mCropExtras.getExtraOutput() != null) { mSaveToExtraUri = true; @@ -1036,29 +1082,15 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, mOutputted = true; } if (mCropExtras.getReturnData()) { - mReturnAsExtra = true; mOutputted = true; } - if (mOutputted) { mImageShow.getImagePreset().mGeoData.setUseCropExtrasFlag(true); showSavingProgress(null); mImageShow.returnFilteredResult(this); } } - if (!mOutputted) { - if (mImageShow.hasModifications()) { - // 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 { - done(); - } - } } public void onFilteredResult(Bitmap filtered) { |
