summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/gallery3d/app/AlbumPage.java26
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java44
-rw-r--r--src/com/android/gallery3d/ui/BitmapScreenNail.java13
-rw-r--r--src/com/android/gallery3d/ui/PositionController.java3
-rw-r--r--src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java37
5 files changed, 119 insertions, 4 deletions
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java
index cfd1dc3d0..fe0e07836 100644
--- a/src/com/android/gallery3d/app/AlbumPage.java
+++ b/src/com/android/gallery3d/app/AlbumPage.java
@@ -49,6 +49,8 @@ import com.android.gallery3d.ui.GLCanvas;
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;
@@ -70,6 +72,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
public static final String KEY_AUTO_SELECT_ALL = "auto-select-all";
public static final String KEY_SHOW_CLUSTER_MENU = "cluster-menu";
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;
private static final int REQUEST_PHOTO = 2;
@@ -230,6 +233,27 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
}
}
+ private PreparePageFadeoutTexture mPrepareFadeoutTask;
+
+ private void startPrepareFadeOutTexture() {
+ GLRoot root = mActivity.getGLRoot();
+ mPrepareFadeoutTask = new PreparePageFadeoutTexture(
+ mSlotView.getWidth(), mSlotView.getHeight() +
+ mActivity.getGalleryActionBar().getHeight(), mRootPane);
+ root.unlockRenderThread();
+ try {
+ root.addOnGLIdleListener(mPrepareFadeoutTask);
+ } finally {
+ root.lockRenderThread();
+ }
+ }
+
+ private void finishPrepareFadeOutTexture() {
+ mActivity.getTransitionStore().put(KEY_FADE_TEXTURE,
+ mPrepareFadeoutTask.get());
+ mPrepareFadeoutTask = null;
+ }
+
private void onSingleTapUp(int slotIndex) {
if (!mIsActive) return;
@@ -242,6 +266,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
// Show pressed-up animation for the single-tap.
mAlbumView.setPressedIndex(slotIndex);
mAlbumView.setPressedUp();
+ startPrepareFadeOutTexture();
mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_PICK_PHOTO, slotIndex, 0),
FadeTexture.DURATION);
}
@@ -257,6 +282,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
} else {
// Get into the PhotoPage.
// mAlbumView.savePositions(PositionRepository.getInstance(mActivity));
+ finishPrepareFadeOutTexture();
Bundle data = new Bundle();
data.putInt(PhotoPage.KEY_INDEX_HINT, slotIndex);
data.putParcelable(PhotoPage.KEY_OPEN_ANIMATION_RECT,
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index 8f4fed988..2774440ba 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -30,10 +30,12 @@ import android.os.Handler;
import android.os.Message;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.animation.AccelerateInterpolator;
import android.widget.Toast;
import com.android.gallery3d.R;
import com.android.gallery3d.actionbar.ActionBarInterface.OnMenuVisibilityListener;
+import com.android.gallery3d.anim.FloatAnimation;
import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.DataManager;
@@ -48,17 +50,20 @@ import com.android.gallery3d.data.SnailAlbum;
import com.android.gallery3d.data.SnailItem;
import com.android.gallery3d.data.SnailSource;
import com.android.gallery3d.picasasource.PicasaSource;
+import com.android.gallery3d.ui.AnimationTime;
import com.android.gallery3d.ui.DetailsHelper;
import com.android.gallery3d.ui.DetailsHelper.CloseListener;
import com.android.gallery3d.ui.DetailsHelper.DetailsSource;
import com.android.gallery3d.ui.GLCanvas;
import com.android.gallery3d.ui.GLRoot;
import com.android.gallery3d.ui.GLRoot.OnGLIdleListener;
+import com.android.gallery3d.ui.BitmapScreenNail;
import com.android.gallery3d.ui.GLView;
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.RawTexture;
import com.android.gallery3d.ui.SelectionManager;
import com.android.gallery3d.ui.SynchronizedHandler;
import com.android.gallery3d.util.GalleryUtils;
@@ -126,6 +131,10 @@ public class PhotoPage extends ActivityState implements
private boolean mHasActivityResult;
private boolean mTreatBackAsUp;
+ private RawTexture mFadeOutTexture;
+ private Rect mOpenAnimationRect;
+ public static final int ANIM_TIME_OPENING = 300;
+
// The item that is deleted (but it can still be undeleted before commiting)
private Path mDeletePath;
private boolean mDeleteIsFocus; // whether the deleted item was in focus
@@ -150,10 +159,35 @@ public class PhotoPage extends ActivityState implements
}
}
- private final GLView mRootPane = new GLView() {
+ private static class BackgroundFadeOut extends FloatAnimation {
+ public BackgroundFadeOut() {
+ super(1f, 0f, ANIM_TIME_OPENING);
+ setInterpolator(new AccelerateInterpolator(2f));
+ }
+ }
+
+ private final FloatAnimation mBackgroundFade = new BackgroundFadeOut();
+ private final GLView mRootPane = new GLView() {
@Override
protected void renderBackground(GLCanvas view) {
+ if(mFadeOutTexture != null) {
+ if(mBackgroundFade.calculate(AnimationTime.get())) invalidate();
+ if(!mBackgroundFade.isActive()) {
+ mFadeOutTexture = null;
+ mOpenAnimationRect = null;
+ BitmapScreenNail.enableDrawPlaceholder();
+ } else {
+ float fadeAlpha = mBackgroundFade.get();
+ if(fadeAlpha < 1f) {
+ view.clearBuffer(0f, 0f, 0f, 1f);
+ view.setAlpha(fadeAlpha);
+ }
+ mFadeOutTexture.draw(view, 0, 0);
+ view.setAlpha(1f);
+ return;
+ }
+ }
view.clearBuffer(0f, 0f, 0f, 1f);
}
@@ -313,7 +347,13 @@ public class PhotoPage extends ActivityState implements
// start the opening animation only if it's not restored.
if (restoreState == null) {
- mPhotoView.setOpenAnimationRect((Rect) data.getParcelable(KEY_OPEN_ANIMATION_RECT));
+ mFadeOutTexture = mActivity.getTransitionStore().get(AlbumPage.KEY_FADE_TEXTURE);
+ if(mFadeOutTexture != null) {
+ mBackgroundFade.start();
+ BitmapScreenNail.disableDrawPlaceholder();
+ mOpenAnimationRect = (Rect) data.getParcelable(KEY_OPEN_ANIMATION_RECT);
+ mPhotoView.setOpenAnimationRect(mOpenAnimationRect);
+ }
}
}
diff --git a/src/com/android/gallery3d/ui/BitmapScreenNail.java b/src/com/android/gallery3d/ui/BitmapScreenNail.java
index 6cb36b092..57685e8e5 100644
--- a/src/com/android/gallery3d/ui/BitmapScreenNail.java
+++ b/src/com/android/gallery3d/ui/BitmapScreenNail.java
@@ -36,6 +36,7 @@ public class BitmapScreenNail implements ScreenNail {
private static final int PLACEHOLDER_COLOR = 0xFF222222;
// The duration of the fading animation in milliseconds
private static final int DURATION = 180;
+ private static boolean mDrawPlaceholder = true;
private static final int MAX_SIDE = 640;
@@ -139,13 +140,23 @@ public class BitmapScreenNail implements ScreenNail {
mBitmap = null;
}
+ public static void disableDrawPlaceholder() {
+ mDrawPlaceholder = false;
+ }
+
+ public static void enableDrawPlaceholder() {
+ mDrawPlaceholder = true;
+ }
+
@Override
public void draw(GLCanvas canvas, int x, int y, int width, int height) {
if (mBitmap == null) {
if (mAnimationStartTime == ANIMATION_NOT_NEEDED) {
mAnimationStartTime = ANIMATION_NEEDED;
}
- canvas.fillRect(x, y, width, height, PLACEHOLDER_COLOR);
+ if(mDrawPlaceholder) {
+ canvas.fillRect(x, y, width, height, PLACEHOLDER_COLOR);
+ }
return;
}
diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java
index 9b77d6814..b1b3c37ab 100644
--- a/src/com/android/gallery3d/ui/PositionController.java
+++ b/src/com/android/gallery3d/ui/PositionController.java
@@ -20,6 +20,7 @@ import android.content.Context;
import android.graphics.Rect;
import android.util.Log;
+import com.android.gallery3d.app.PhotoPage;
import com.android.gallery3d.common.OverScroller;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.util.GalleryUtils;
@@ -66,7 +67,7 @@ class PositionController {
SNAPBACK_ANIMATION_TIME, // ANIM_KIND_SNAPBACK
400, // ANIM_KIND_SLIDE
300, // ANIM_KIND_ZOOM
- 400, // ANIM_KIND_OPENING
+ PhotoPage.ANIM_TIME_OPENING, // ANIM_KIND_OPENING
0, // ANIM_KIND_FLING (the duration is calculated dynamically)
0, // ANIM_KIND_FLING_X (see the comment above)
0, // ANIM_KIND_DELETE (the duration is calculated dynamically)
diff --git a/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java b/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java
new file mode 100644
index 000000000..475906c81
--- /dev/null
+++ b/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java
@@ -0,0 +1,37 @@
+package com.android.gallery3d.ui;
+
+import com.android.gallery3d.ui.GLRoot.OnGLIdleListener;
+
+public class PreparePageFadeoutTexture implements OnGLIdleListener {
+ private RawTexture mTexture;
+ private boolean mResultReady = false;
+ private GLView mRootPane;
+
+ public PreparePageFadeoutTexture(int w, int h, GLView rootPane) {
+ mTexture = new RawTexture(w, h, true);
+ mRootPane = rootPane;
+ }
+
+ public synchronized RawTexture get() {
+ try {
+ while (!mResultReady) {
+ wait();
+ }
+ } catch (InterruptedException e) {
+ // Since this is just used for a transition, not that important
+ }
+ return mTexture;
+ }
+
+ @Override
+ public boolean onGLIdle(GLCanvas canvas, boolean renderRequested) {
+ canvas.beginRenderTarget(mTexture);
+ mRootPane.render(canvas);
+ canvas.endRenderTarget();
+ synchronized (this) {
+ mResultReady = true;
+ notifyAll();
+ }
+ return false;
+ }
+}