diff options
author | Ruben Brunk <rubenbrunk@google.com> | 2013-03-29 12:36:30 -0700 |
---|---|---|
committer | Ruben Brunk <rubenbrunk@google.com> | 2013-03-29 16:02:03 -0700 |
commit | 3171c21d51cc6b3197b0d25167f09237cb05840d (patch) | |
tree | e557e386670c0abb5d26418ed6ced1a91019f3ea /src/com/android | |
parent | d6f3162a473066a24838c8dc6f2c6f96d4db0f0c (diff) | |
download | android_packages_apps_Snap-3171c21d51cc6b3197b0d25167f09237cb05840d.tar.gz android_packages_apps_Snap-3171c21d51cc6b3197b0d25167f09237cb05840d.tar.bz2 android_packages_apps_Snap-3171c21d51cc6b3197b0d25167f09237cb05840d.zip |
Added "discard unsaved changes" behavior for exiting.
Bug: 7534778
Change-Id: I3136fa04585a42912bad6235a776937a4cb4dcac
Diffstat (limited to 'src/com/android')
-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) { |