summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2013-04-11 11:07:45 -0400
committerChris Wren <cwren@android.com>2013-04-11 11:09:22 -0400
commit3910ecc7c3a93485d32f8c1eac79e47dbf3753fb (patch)
treedcd8fa2e8efabcf14f545291db68627608569df4 /src
parent84c3d5580e7168d1d150c1dd24340b19eb501cd2 (diff)
downloadandroid_packages_screensavers_PhotoTable-3910ecc7c3a93485d32f8c1eac79e47dbf3753fb.tar.gz
android_packages_screensavers_PhotoTable-3910ecc7c3a93485d32f8c1eac79e47dbf3753fb.tar.bz2
android_packages_screensavers_PhotoTable-3910ecc7c3a93485d32f8c1eac79e47dbf3753fb.zip
story mode: declutter by fading out the backgroun images.
Bug: 8573228 Change-Id: I8b62f9fcf6c7ae82bcb990428a421722c7197e1c
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dreams/phototable/PhotoTable.java57
1 files changed, 51 insertions, 6 deletions
diff --git a/src/com/android/dreams/phototable/PhotoTable.java b/src/com/android/dreams/phototable/PhotoTable.java
index 4480818..7f4f61a 100644
--- a/src/com/android/dreams/phototable/PhotoTable.java
+++ b/src/com/android/dreams/phototable/PhotoTable.java
@@ -15,6 +15,9 @@
*/
package com.android.dreams.phototable;
+import android.animation.Animator;
+import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -34,6 +37,7 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewPropertyAnimator;
+import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
@@ -41,6 +45,7 @@ import android.widget.ImageView;
import java.util.Formatter;
import java.util.LinkedList;
+import java.util.List;
import java.util.Random;
/**
@@ -174,6 +179,9 @@ public class PhotoTable extends FrameLayout {
if (hasSelection()) {
dropOnTable(mSelection);
mPhotoSource.donePaging(getBitmap(mSelection));
+ if (mStoryModeEnabled) {
+ fadeInExcept(mSelection);
+ }
mSelection = null;
}
for (int slot = 0; slot < mOnDeck.length; slot++) {
@@ -194,6 +202,9 @@ public class PhotoTable extends FrameLayout {
clearSelection();
mSelection = selected;
promoteSelection();
+ if (mStoryModeEnabled) {
+ fadeOutExcept(mSelection);
+ }
}
}
@@ -581,6 +592,44 @@ public class PhotoTable extends FrameLayout {
}
}
+ /** De-emphasize the other photos on the table. */
+ public void fadeOutExcept(final View photo) {
+ List<Animator> animations = new LinkedList<Animator>();
+ for (View background: mOnTable) {
+ if (background != photo) {
+ // fade out to transparent.
+ background.animate().cancel();
+ animations.add(ObjectAnimator.ofFloat(background, "alpha", 0f));
+ }
+ }
+ if (animations.size() > 0) {
+ AnimatorSet set = new AnimatorSet();
+ set.playTogether(animations);
+ set.setDuration(mPickUpDuration);
+ set.start();
+ }
+ }
+
+
+ /** Return the other photos to foreground status. */
+ public void fadeInExcept(final View photo) {
+ List<Animator> animations = new LinkedList<Animator>();
+ for (View background: mOnTable) {
+ if (background != photo) {
+ // fade back to full opacity.
+ background.animate().cancel();
+ animations.add(ObjectAnimator.ofFloat(background, "alpha", 1f));
+ }
+ }
+ if (animations.size() > 0) {
+ AnimatorSet set = new AnimatorSet();
+ set.playTogether(animations);
+ set.setDuration(mPickUpDuration);
+ set.start();
+ }
+ }
+
+
/** Dispose of the photo gracefully, in case we can see some of it. */
public void fadeAway(final View photo, final boolean replace) {
// fade out of view
@@ -589,7 +638,7 @@ public class PhotoTable extends FrameLayout {
photo.animate()
.withLayer()
.alpha(0f)
- .setDuration(1000)
+ .setDuration(mPickUpDuration)
.withEndAction(new Runnable() {
@Override
public void run() {
@@ -797,11 +846,6 @@ public class PhotoTable extends FrameLayout {
float x = (getWidth() - photoWidth) / 2f;
float y = (getHeight() - photoHeight) / 2f;
- float x0 = photo.getX();
- float y0 = photo.getY();
- float dx = x - x0;
- float dy = y - y0;
-
photo.setRotation(wrapAngle(photo.getRotation()));
log("animate it");
@@ -809,6 +853,7 @@ public class PhotoTable extends FrameLayout {
photo.animate()
.rotation(0f)
.rotationY(0f)
+ .alpha(1f)
.scaleX(scale)
.scaleY(scale)
.x(x)