summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/photoeditor
diff options
context:
space:
mode:
authorYuli Huang <yuli@google.com>2011-10-05 00:01:02 +0800
committerYuli Huang <yuli@google.com>2011-10-05 02:56:35 +0800
commit3807c5774cc60d0a8745d8e396ecc679dc7b7270 (patch)
tree0cb28496bd5d414e99bc13c65d80275389445c9e /src/com/android/gallery3d/photoeditor
parentc8957b85a13e9993c7620076be132876cb9ad6b7 (diff)
downloadandroid_packages_apps_Snap-3807c5774cc60d0a8745d8e396ecc679dc7b7270.tar.gz
android_packages_apps_Snap-3807c5774cc60d0a8745d8e396ecc679dc7b7270.tar.bz2
android_packages_apps_Snap-3807c5774cc60d0a8745d8e396ecc679dc7b7270.zip
Fix b/5032231: Allow share in Photo Editor.
Change-Id: I5fd48243df76fd0c2617c92d7f73936172bf6c47
Diffstat (limited to 'src/com/android/gallery3d/photoeditor')
-rw-r--r--src/com/android/gallery3d/photoeditor/ActionBar.java14
-rw-r--r--src/com/android/gallery3d/photoeditor/PhotoEditor.java35
2 files changed, 44 insertions, 5 deletions
diff --git a/src/com/android/gallery3d/photoeditor/ActionBar.java b/src/com/android/gallery3d/photoeditor/ActionBar.java
index 5a423b905..db18c7454 100644
--- a/src/com/android/gallery3d/photoeditor/ActionBar.java
+++ b/src/com/android/gallery3d/photoeditor/ActionBar.java
@@ -20,6 +20,7 @@ import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
+import android.widget.ViewSwitcher;
import com.android.gallery3d.R;
@@ -104,8 +105,19 @@ public class ActionBar extends RelativeLayout {
View button = findViewById(buttonId);
button.setEnabled(enabled);
button.setAlpha(enabled ? ENABLED_ALPHA : DISABLED_ALPHA);
-
// Track buttons whose enabled status has been updated.
changedButtons.add(buttonId);
+
+ if (buttonId == R.id.save_button) {
+ // Show share-button only after photo is edited and saved; otherwise, show save-button.
+ // TODO: Fix the assumption of undo enabled status must be updated before reaching here.
+ boolean showShare = findViewById(R.id.undo_button).isEnabled() && !enabled;
+ ViewSwitcher switcher = (ViewSwitcher) findViewById(R.id.save_share_buttons);
+ int next = switcher.getNextView().getId();
+ if ((showShare && (next == R.id.share_button))
+ || (!showShare && (next == R.id.save_button))) {
+ switcher.showNext();
+ }
+ }
}
}
diff --git a/src/com/android/gallery3d/photoeditor/PhotoEditor.java b/src/com/android/gallery3d/photoeditor/PhotoEditor.java
index e36071eea..3a6face68 100644
--- a/src/com/android/gallery3d/photoeditor/PhotoEditor.java
+++ b/src/com/android/gallery3d/photoeditor/PhotoEditor.java
@@ -33,7 +33,8 @@ import com.android.gallery3d.R;
*/
public class PhotoEditor extends Activity {
- private Uri uri;
+ private Uri sourceUri;
+ private Uri saveUri;
private FilterStack filterStack;
private ActionBar actionBar;
@@ -43,7 +44,9 @@ public class PhotoEditor extends Activity {
setContentView(R.layout.photoeditor_main);
Intent intent = getIntent();
- uri = Intent.ACTION_EDIT.equalsIgnoreCase(intent.getAction()) ? intent.getData() : null;
+ if (Intent.ACTION_EDIT.equalsIgnoreCase(intent.getAction())) {
+ sourceUri = intent.getData();
+ }
actionBar = (ActionBar) findViewById(R.id.action_bar);
filterStack = new FilterStack((PhotoView) findViewById(R.id.photo_view),
@@ -63,6 +66,7 @@ public class PhotoEditor extends Activity {
actionBar.setRunnable(R.id.undo_button, createUndoRedoRunnable(true, effectsBar));
actionBar.setRunnable(R.id.redo_button, createUndoRedoRunnable(false, effectsBar));
actionBar.setRunnable(R.id.save_button, createSaveRunnable(effectsBar));
+ actionBar.setRunnable(R.id.share_button, createShareRunnable(effectsBar));
actionBar.setRunnable(R.id.action_bar_back, createBackRunnable(effectsBar));
}
@@ -106,7 +110,7 @@ public class PhotoEditor extends Activity {
});
}
};
- new LoadScreennailTask(this, callback).execute(uri);
+ new LoadScreennailTask(this, callback).execute(sourceUri);
}
private Runnable createUndoRedoRunnable(final boolean undo, final EffectsBar effectsBar) {
@@ -157,9 +161,11 @@ public class PhotoEditor extends Activity {
public void onComplete(Uri result) {
progressDialog.dismiss();
actionBar.enableButton(R.id.save_button, (result == null));
+ saveUri = result;
}
};
- new SaveCopyTask(PhotoEditor.this, uri, callback).execute(bitmap);
+ new SaveCopyTask(PhotoEditor.this, sourceUri, callback).execute(
+ bitmap);
}
});
}
@@ -168,6 +174,27 @@ public class PhotoEditor extends Activity {
};
}
+ private Runnable createShareRunnable(final EffectsBar effectsBar) {
+ return new Runnable() {
+
+ @Override
+ public void run() {
+ effectsBar.exit(new Runnable() {
+
+ @Override
+ public void run() {
+ if (saveUri != null) {
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.putExtra(Intent.EXTRA_STREAM, saveUri);
+ intent.setType("image/*");
+ startActivity(intent);
+ }
+ }
+ });
+ }
+ };
+ }
+
private Runnable createBackRunnable(final EffectsBar effectsBar) {
return new Runnable() {