summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d
diff options
context:
space:
mode:
authorRay Chen <raychen@google.com>2012-04-05 17:25:43 +0800
committerRay Chen <raychen@google.com>2012-04-23 16:20:15 +0800
commit85c9ea40b0026befe79c4ba866a73f5d58ee5555 (patch)
treedcb196007bac84cd4692cf1246cd6ecf4b616426 /src/com/android/gallery3d
parent6e98a5bb1862af0056fe009184dc8aa2fc4611a2 (diff)
downloadandroid_packages_apps_Snap-85c9ea40b0026befe79c4ba866a73f5d58ee5555.tar.gz
android_packages_apps_Snap-85c9ea40b0026befe79c4ba866a73f5d58ee5555.tar.bz2
android_packages_apps_Snap-85c9ea40b0026befe79c4ba866a73f5d58ee5555.zip
Fix 6046544 Deleting a photo takes multiple steps and the flow is inconsistent with other deleting flows on other core apps
This CL adds a confirm dialog to delete command and removes all confirm/cancel menu items from the actionbar. b:6046544 Change-Id: I3afe7b59b4f6d1216e192a621621f7bf544e1919
Diffstat (limited to 'src/com/android/gallery3d')
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java8
-rw-r--r--src/com/android/gallery3d/ui/ActionModeHandler.java16
-rw-r--r--src/com/android/gallery3d/ui/MenuExecutor.java34
3 files changed, 42 insertions, 16 deletions
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index 78bb34cab..6be302b24 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -435,6 +435,7 @@ public class PhotoPage extends ActivityState
DataManager manager = mActivity.getDataManager();
int action = item.getItemId();
+ boolean needsConfirm = false;
switch (action) {
case android.R.id.home: {
if (mSetPathString != null) {
@@ -480,20 +481,21 @@ public class PhotoPage extends ActivityState
}
return true;
}
+ case R.id.action_delete:
+ needsConfirm = true;
case R.id.action_setas:
- case R.id.action_confirm_delete:
case R.id.action_rotate_ccw:
case R.id.action_rotate_cw:
case R.id.action_show_on_map:
case R.id.action_edit:
mSelectionManager.deSelectAll();
mSelectionManager.toggle(path);
- mMenuExecutor.onMenuClicked(item, null);
+ mMenuExecutor.onMenuClicked(item, needsConfirm, null);
return true;
case R.id.action_import:
mSelectionManager.deSelectAll();
mSelectionManager.toggle(path);
- mMenuExecutor.onMenuClicked(item,
+ mMenuExecutor.onMenuClicked(item, needsConfirm,
new ImportCompleteListener(mActivity));
return true;
default :
diff --git a/src/com/android/gallery3d/ui/ActionModeHandler.java b/src/com/android/gallery3d/ui/ActionModeHandler.java
index 32820f327..018839314 100644
--- a/src/com/android/gallery3d/ui/ActionModeHandler.java
+++ b/src/com/android/gallery3d/ui/ActionModeHandler.java
@@ -110,6 +110,10 @@ public class ActionModeHandler implements ActionMode.Callback {
root.lockRenderThread();
try {
boolean result;
+ // Give listener a chance to process this command before it's routed to
+ // ActionModeHandler, which handles command only based on the action id.
+ // Sometimes the listener may have more background information to handle
+ // an action command.
if (mListener != null) {
result = mListener.onActionItemClicked(item);
if (result) {
@@ -118,18 +122,22 @@ public class ActionModeHandler implements ActionMode.Callback {
}
}
ProgressListener listener = null;
- if (item.getItemId() == R.id.action_import) {
+ boolean needsConfirm = false;
+ int action = item.getItemId();
+ if (action == R.id.action_import) {
listener = new ImportCompleteListener(mActivity);
+ } else if (item.getItemId() == R.id.action_delete) {
+ needsConfirm = true;
}
- result = mMenuExecutor.onMenuClicked(item, listener);
- if (item.getItemId() == R.id.action_select_all) {
+ mMenuExecutor.onMenuClicked(item, needsConfirm, listener);
+ if (action == R.id.action_select_all) {
updateSupportedOperation();
updateSelectionMenu();
}
- return result;
} finally {
root.unlockRenderThread();
}
+ return true;
}
private void updateSelectionMenu() {
diff --git a/src/com/android/gallery3d/ui/MenuExecutor.java b/src/com/android/gallery3d/ui/MenuExecutor.java
index 918feead9..a0f344982 100644
--- a/src/com/android/gallery3d/ui/MenuExecutor.java
+++ b/src/com/android/gallery3d/ui/MenuExecutor.java
@@ -17,8 +17,11 @@
package com.android.gallery3d.ui;
import android.app.Activity;
+import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
@@ -172,10 +175,9 @@ public class MenuExecutor {
return ids.get(0);
}
- public boolean onMenuClicked(MenuItem menuItem, ProgressListener listener) {
+ private void onMenuClicked(int action, ProgressListener listener) {
int title;
DataManager manager = mActivity.getDataManager();
- int action = menuItem.getItemId();
switch (action) {
case R.id.action_select_all:
if (mSelectionManager.inSelectAllMode()) {
@@ -183,14 +185,12 @@ public class MenuExecutor {
} else {
mSelectionManager.selectAll();
}
- return true;
case R.id.action_crop: {
Path path = getSingleSelectedPath();
String mimeType = getMimeType(manager.getMediaType(path));
Intent intent = new Intent(CropImage.ACTION_CROP)
.setDataAndType(manager.getContentUri(path), mimeType);
((Activity) mActivity).startActivity(intent);
- return true;
}
case R.id.action_setas: {
Path path = getSingleSelectedPath();
@@ -203,9 +203,8 @@ public class MenuExecutor {
Activity activity = (Activity) mActivity;
activity.startActivity(Intent.createChooser(
intent, activity.getString(R.string.set_as)));
- return true;
}
- case R.id.action_confirm_delete:
+ case R.id.action_delete:
title = R.string.delete;
break;
case R.id.action_rotate_cw:
@@ -224,10 +223,27 @@ public class MenuExecutor {
title = R.string.Import;
break;
default:
- return false;
+ return;
}
startAction(action, title, listener);
- return true;
+ }
+
+ public void onMenuClicked(MenuItem menuItem, boolean needsConfirm,
+ final ProgressListener listener) {
+ final int action = menuItem.getItemId();
+
+ if (needsConfirm) {
+ new AlertDialog.Builder(mActivity.getAndroidContext())
+ .setMessage(R.string.confirm_action)
+ .setPositiveButton(R.string.confirm, new OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ onMenuClicked(action, listener);
+ }
+ })
+ .setNegativeButton(R.string.cancel, null).create().show();
+ } else {
+ onMenuClicked(action, listener);
+ }
}
public void startAction(int action, int title, ProgressListener listener) {
@@ -257,7 +273,7 @@ public class MenuExecutor {
long startTime = System.currentTimeMillis();
switch (cmd) {
- case R.id.action_confirm_delete:
+ case R.id.action_delete:
manager.delete(path);
break;
case R.id.action_rotate_cw: