summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBobby Georgescu <georgescu@google.com>2012-09-13 15:46:40 -0700
committerBobby Georgescu <georgescu@google.com>2012-09-13 16:40:57 -0700
commitee96fa8b2c67ab4ae2ac1cb3c0d9795af04cc9b7 (patch)
treed804ef0a30b0fa3c9fd566090b17b96ccd0c6eae /src
parent2cd3567be7f92c5e89beecc2d672768ef05507c7 (diff)
downloadandroid_packages_apps_Snap-ee96fa8b2c67ab4ae2ac1cb3c0d9795af04cc9b7.tar.gz
android_packages_apps_Snap-ee96fa8b2c67ab4ae2ac1cb3c0d9795af04cc9b7.tar.bz2
android_packages_apps_Snap-ee96fa8b2c67ab4ae2ac1cb3c0d9795af04cc9b7.zip
Animate correctly when opening single-photo album
Bug: 7164177 Change-Id: I5ce60a8e842e3ddf0e356568f17ee488edef23cd
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/app/AlbumPage.java39
-rw-r--r--src/com/android/gallery3d/app/AlbumSetPage.java6
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java3
-rw-r--r--src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java23
-rw-r--r--src/com/android/gallery3d/ui/SlotView.java10
5 files changed, 45 insertions, 36 deletions
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java
index 363b87689..298e083c6 100644
--- a/src/com/android/gallery3d/app/AlbumPage.java
+++ b/src/com/android/gallery3d/app/AlbumPage.java
@@ -48,7 +48,6 @@ import com.android.gallery3d.ui.GLRoot;
import com.android.gallery3d.ui.GLView;
import com.android.gallery3d.ui.PhotoFallbackEffect;
import com.android.gallery3d.ui.PreparePageFadeoutTexture;
-import com.android.gallery3d.ui.RawTexture;
import com.android.gallery3d.ui.RelativePosition;
import com.android.gallery3d.ui.SelectionManager;
import com.android.gallery3d.ui.SlotView;
@@ -68,7 +67,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
public static final String KEY_SHOW_CLUSTER_MENU = "cluster-menu";
public static final String KEY_EMPTY_ALBUM = "empty-album";
public static final String KEY_RESUME_ANIMATION = "resume_animation";
- public static final String KEY_FADE_TEXTURE = "fade_texture";
private static final int REQUEST_SLIDESHOW = 1;
public static final int REQUEST_PHOTO = 2;
@@ -233,25 +231,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
}
}
- private void prepareFadeOutTexture() {
- GLRoot root = mActivity.getGLRoot();
- PreparePageFadeoutTexture task = new PreparePageFadeoutTexture(
- mSlotView.getWidth(), mSlotView.getHeight() +
- mActivity.getGalleryActionBar().getHeight(), mRootPane);
- RawTexture texture = null;
- root.unlockRenderThread();
- try {
- root.addOnGLIdleListener(task);
- texture = task.get();
- } finally {
- root.lockRenderThread();
- }
-
- if (texture != null) {
- mActivity.getTransitionStore().put(KEY_FADE_TEXTURE, texture);
- }
- }
-
private void onSingleTapUp(int slotIndex) {
if (!mIsActive) return;
@@ -263,7 +242,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
} else {
// Render transition in pressed state
mAlbumView.setPressedIndex(slotIndex);
- prepareFadeOutTexture();
+ PreparePageFadeoutTexture.prepareFadeOutTexture(mActivity, mSlotView, mRootPane);
mAlbumView.setPressedIndex(-1);
pickPhoto(slotIndex);
@@ -299,7 +278,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
Bundle data = new Bundle();
data.putInt(PhotoPage.KEY_INDEX_HINT, slotIndex);
data.putParcelable(PhotoPage.KEY_OPEN_ANIMATION_RECT,
- getSlotRect(slotIndex));
+ mSlotView.getSlotRect(slotIndex, mRootPane));
data.putString(PhotoPage.KEY_MEDIA_SET_PATH,
mMediaSetPath.toString());
data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH,
@@ -313,16 +292,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
}
}
- private Rect getSlotRect(int slotIndex) {
- // Get slot rectangle relative to this root pane.
- Rect offset = new Rect();
- mRootPane.getBoundsOf(mSlotView, offset);
- Rect r = mSlotView.getSlotRect(slotIndex);
- r.offset(offset.left - mSlotView.getScrollX(),
- offset.top - mSlotView.getScrollY());
- return r;
- }
-
private void onGetContent(final MediaItem item) {
DataManager dm = mActivity.getDataManager();
Activity activity = mActivity;
@@ -561,13 +530,13 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
private void prepareAnimationBackToFilmstrip(int slotIndex) {
if (mAlbumDataAdapter == null || !mAlbumDataAdapter.isActive(slotIndex)) return;
- prepareFadeOutTexture();
+ PreparePageFadeoutTexture.prepareFadeOutTexture(mActivity, mSlotView, mRootPane);
TransitionStore transitions = mActivity.getTransitionStore();
transitions.put(PhotoPage.KEY_INDEX_HINT, slotIndex);
transitions.put(PhotoPage.KEY_MEDIA_ITEM_PATH,
mAlbumDataAdapter.get(slotIndex).getPath());
transitions.put(PhotoPage.KEY_OPEN_ANIMATION_RECT,
- getSlotRect(slotIndex));
+ mSlotView.getSlotRect(slotIndex, mRootPane));
}
@Override
diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java
index ed632ac30..6941f2914 100644
--- a/src/com/android/gallery3d/app/AlbumSetPage.java
+++ b/src/com/android/gallery3d/app/AlbumSetPage.java
@@ -47,6 +47,7 @@ import com.android.gallery3d.ui.FadeTexture;
import com.android.gallery3d.ui.GLCanvas;
import com.android.gallery3d.ui.GLRoot;
import com.android.gallery3d.ui.GLView;
+import com.android.gallery3d.ui.PreparePageFadeoutTexture;
import com.android.gallery3d.ui.SelectionManager;
import com.android.gallery3d.ui.SlotView;
import com.android.gallery3d.ui.SynchronizedHandler;
@@ -261,6 +262,11 @@ public class AlbumSetPage extends ActivityState implements
& MediaObject.SUPPORT_IMPORT) != 0) {
data.putBoolean(AlbumPage.KEY_AUTO_SELECT_ALL, true);
} else if (!mGetContent && albumShouldOpenInFilmstrip(targetSet)) {
+ if (targetSet.getMediaItemCount() == 1) {
+ PreparePageFadeoutTexture.prepareFadeOutTexture(mActivity, mSlotView, mRootPane);
+ data.putParcelable(PhotoPage.KEY_OPEN_ANIMATION_RECT,
+ mSlotView.getSlotRect(slotIndex, mRootPane));
+ }
data.putInt(PhotoPage.KEY_INDEX_HINT, 0);
data.putString(PhotoPage.KEY_MEDIA_SET_PATH,
mediaPath);
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index 7c7ac6d76..980090898 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -71,6 +71,7 @@ import com.android.gallery3d.ui.ImportCompleteListener;
import com.android.gallery3d.ui.MenuExecutor;
import com.android.gallery3d.ui.PhotoFallbackEffect;
import com.android.gallery3d.ui.PhotoView;
+import com.android.gallery3d.ui.PreparePageFadeoutTexture;
import com.android.gallery3d.ui.RawTexture;
import com.android.gallery3d.ui.SelectionManager;
import com.android.gallery3d.ui.SynchronizedHandler;
@@ -1109,7 +1110,7 @@ public class PhotoPage extends ActivityState implements
&& albumPageTransition == MSG_ALBUMPAGE_RESUMED);
}
- mFadeOutTexture = transitions.get(AlbumPage.KEY_FADE_TEXTURE);
+ mFadeOutTexture = transitions.get(PreparePageFadeoutTexture.KEY_FADE_TEXTURE);
if (mFadeOutTexture != null) {
mBackgroundFade.start();
BitmapScreenNail.disableDrawPlaceholder();
diff --git a/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java b/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java
index f2b306ef5..b4310662f 100644
--- a/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java
+++ b/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java
@@ -2,10 +2,13 @@ package com.android.gallery3d.ui;
import android.os.ConditionVariable;
+import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.ui.GLRoot.OnGLIdleListener;
public class PreparePageFadeoutTexture implements OnGLIdleListener {
private static final long TIMEOUT = FadeTexture.DURATION;
+ public static final String KEY_FADE_TEXTURE = "fade_texture";
+
private RawTexture mTexture;
private ConditionVariable mResultReady = new ConditionVariable(false);
private boolean mCancelled = false;
@@ -39,4 +42,24 @@ public class PreparePageFadeoutTexture implements OnGLIdleListener {
mResultReady.open();
return false;
}
+
+ public static void prepareFadeOutTexture(AbstractGalleryActivity activity,
+ SlotView slotView, GLView rootPane) {
+ GLRoot root = activity.getGLRoot();
+ PreparePageFadeoutTexture task = new PreparePageFadeoutTexture(
+ slotView.getWidth(), slotView.getHeight() +
+ activity.getGalleryActionBar().getHeight(), rootPane);
+ RawTexture texture = null;
+ root.unlockRenderThread();
+ try {
+ root.addOnGLIdleListener(task);
+ texture = task.get();
+ } finally {
+ root.lockRenderThread();
+ }
+
+ if (texture != null) {
+ activity.getTransitionStore().put(KEY_FADE_TEXTURE, texture);
+ }
+ }
}
diff --git a/src/com/android/gallery3d/ui/SlotView.java b/src/com/android/gallery3d/ui/SlotView.java
index d77080adb..15a583e5c 100644
--- a/src/com/android/gallery3d/ui/SlotView.java
+++ b/src/com/android/gallery3d/ui/SlotView.java
@@ -737,6 +737,16 @@ public class SlotView extends GLView {
return mScrollY;
}
+ public Rect getSlotRect(int slotIndex, GLView rootPane) {
+ // Get slot rectangle relative to this root pane.
+ Rect offset = new Rect();
+ rootPane.getBoundsOf(this, offset);
+ Rect r = getSlotRect(slotIndex);
+ r.offset(offset.left - getScrollX(),
+ offset.top - getScrollY());
+ return r;
+ }
+
private static class IntegerAnimation extends Animation {
private int mTarget;
private int mCurrent = 0;