summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/anim
diff options
context:
space:
mode:
authorBobby Georgescu <georgescu@google.com>2012-10-15 13:48:08 -0700
committerBobby Georgescu <georgescu@google.com>2012-10-16 16:30:17 -0700
commit641b838e49a445592b17e56b11374d92f99789f2 (patch)
tree1663518062277bad145c2f5d55a907728d51c244 /src/com/android/gallery3d/anim
parentc057d64b701fc2de9f0d5fec7dbd34779647a442 (diff)
downloadandroid_packages_apps_Snap-641b838e49a445592b17e56b11374d92f99789f2.tar.gz
android_packages_apps_Snap-641b838e49a445592b17e56b11374d92f99789f2.tar.bz2
android_packages_apps_Snap-641b838e49a445592b17e56b11374d92f99789f2.zip
Consistent animations & up button behavior in Gallery
Bug: 7302857 Bug: 7295464 This CL makes all of the transition animations throughout the Gallery app consistent. The animation is the previous view shrinking and fading out while the new view starts out bigger than the view port and is coming in to the viewport size as it fades in. Having consistent animations allows us to not keep PhotoPage/AlbumPage instances around in certain cases, making it possible to have consistent up button behavior when switching between the grid and filmstrip. Finally, this also makes the transitions in the camera app filmstrip/grid switching consistent with those in the gallery app. Change-Id: I77bac6a0cde1e439738c78f9e16ab15ed5910cfb
Diffstat (limited to 'src/com/android/gallery3d/anim')
-rw-r--r--src/com/android/gallery3d/anim/StateTransitionAnimation.java77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/anim/StateTransitionAnimation.java b/src/com/android/gallery3d/anim/StateTransitionAnimation.java
new file mode 100644
index 000000000..ffe753db7
--- /dev/null
+++ b/src/com/android/gallery3d/anim/StateTransitionAnimation.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.anim;
+
+import android.view.animation.DecelerateInterpolator;
+
+import com.android.gallery3d.ui.GLCanvas;
+import com.android.gallery3d.ui.GLView;
+import com.android.gallery3d.ui.RawTexture;
+
+public class StateTransitionAnimation extends Animation {
+ private static final float BACKGROUND_ALPHA_FROM = 1f;
+ private static final float BACKGROUND_ALPHA_TO = 0f;
+ private static final float BACKGROUND_SCALE_FROM = 1f;
+ private static final float BACKGROUND_SCALE_TO = 0f;
+ private static final float FOREGROUND_ALPHA_FROM = 0.9f;
+ private static final float FOREGROUND_ALPHA_TO = 1f;
+ private static final float FOREGROUND_SCALE_FROM = 3f;
+ private static final float FOREGROUND_SCALE_TO = 1f;
+
+ private float mCurrentForegroundScale;
+ private float mCurrentBackgroundScale;
+ private float mCurrentBackgroundAlpha;
+ private float mCurrentForegroundAlpha;
+
+ public StateTransitionAnimation(int duration) {
+ setDuration(duration);
+ setInterpolator(new DecelerateInterpolator());
+ }
+
+ @Override
+ protected void onCalculate(float progress) {
+ mCurrentForegroundScale = FOREGROUND_SCALE_FROM
+ + (FOREGROUND_SCALE_TO - FOREGROUND_SCALE_FROM) * progress;
+ mCurrentForegroundAlpha = FOREGROUND_ALPHA_FROM
+ + (FOREGROUND_ALPHA_TO - FOREGROUND_ALPHA_FROM) * progress;
+ mCurrentBackgroundAlpha = BACKGROUND_ALPHA_FROM
+ + (BACKGROUND_ALPHA_TO - BACKGROUND_ALPHA_FROM) * progress;
+ mCurrentBackgroundScale = BACKGROUND_SCALE_FROM
+ + (BACKGROUND_SCALE_TO - BACKGROUND_SCALE_FROM) * progress;
+ }
+
+ public void applyBackground(GLView view, GLCanvas canvas, RawTexture fadeTexture) {
+ canvas.clearBuffer(view.getBackgroundColor());
+ canvas.save();
+ canvas.setAlpha(mCurrentBackgroundAlpha);
+ int xOffset = view.getWidth() / 2;
+ int yOffset = view.getHeight() / 2;
+ canvas.translate(xOffset, yOffset);
+ canvas.scale(mCurrentBackgroundScale, mCurrentBackgroundScale, 1);
+ fadeTexture.draw(canvas, -xOffset, -yOffset);
+ canvas.restore();
+ }
+
+ public void applyForegroundTransformation(GLView view, GLCanvas canvas) {
+ int xOffset = view.getWidth() / 2;
+ int yOffset = view.getHeight() / 2;
+ canvas.translate(xOffset, yOffset);
+ canvas.scale(mCurrentForegroundScale, mCurrentForegroundScale, 1);
+ canvas.translate(-xOffset, -yOffset);
+ canvas.setAlpha(mCurrentForegroundAlpha);
+ }
+}