diff options
| author | Yuli Huang <yuli@google.com> | 2011-10-04 19:56:15 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-10-04 19:56:15 -0700 |
| commit | a7bbb047782014cf794c6386df2ef20c57f3a164 (patch) | |
| tree | ba81ea293facfe56bfd870b1a216188fbae5767b | |
| parent | 26e879403f006fc59464b73352b9da68750825ca (diff) | |
| parent | 915d58379336d1c19df77f26336d82def95968de (diff) | |
| download | android_packages_apps_Gallery2-a7bbb047782014cf794c6386df2ef20c57f3a164.tar.gz android_packages_apps_Gallery2-a7bbb047782014cf794c6386df2ef20c57f3a164.tar.bz2 android_packages_apps_Gallery2-a7bbb047782014cf794c6386df2ef20c57f3a164.zip | |
Merge "Fix b/5032231: Allow share in Photo Editor."
| -rw-r--r-- | res/layout/photoeditor_actionbar.xml | 21 | ||||
| -rw-r--r-- | src/com/android/gallery3d/photoeditor/ActionBar.java | 14 | ||||
| -rw-r--r-- | src/com/android/gallery3d/photoeditor/PhotoEditor.java | 35 |
3 files changed, 61 insertions, 9 deletions
diff --git a/res/layout/photoeditor_actionbar.xml b/res/layout/photoeditor_actionbar.xml index 82ed41ffc..40c18d828 100644 --- a/res/layout/photoeditor_actionbar.xml +++ b/res/layout/photoeditor_actionbar.xml @@ -44,9 +44,22 @@ android:id="@+id/redo_button" style="@style/ImageActionButton" android:src="@drawable/photoeditor_redo"/> - <Button - android:id="@+id/save_button" - style="@style/TextActionButton" - android:text="@string/save"/> + + <ViewSwitcher + android:id="@+id/save_share_buttons" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + <Button + android:id="@+id/save_button" + style="@style/TextActionButton" + android:layout_width="fill_parent" + android:text="@string/save"/> + <ImageButton + android:id="@+id/share_button" + style="@style/ImageActionButton" + android:layout_width="fill_parent" + android:src="@drawable/ic_menu_share_holo_light"/> + </ViewSwitcher> + </LinearLayout> </com.android.gallery3d.photoeditor.ActionBar> 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() { |
