summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorMichael Kolb <kolby@google.com>2013-05-08 00:23:40 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-05-08 00:23:40 +0000
commite94d00bb84955b4928616af297b61b97f36f3345 (patch)
treec8b568521be3d280ab57a386551b0fb7fd020459 /src/com
parent59733de14afde5e9c1b34dd72f40837e486e43b4 (diff)
parentad2a745d44fdf5acdd98d3bd8212ca51f45c29e7 (diff)
downloadandroid_packages_apps_Snap-e94d00bb84955b4928616af297b61b97f36f3345.tar.gz
android_packages_apps_Snap-e94d00bb84955b4928616af297b61b97f36f3345.tar.bz2
android_packages_apps_Snap-e94d00bb84955b4928616af297b61b97f36f3345.zip
Merge "Add animation to slice selection" into gb-ub-photos-bryce
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/camera/ui/PieRenderer.java48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/com/android/camera/ui/PieRenderer.java b/src/com/android/camera/ui/PieRenderer.java
index 4328b95ae..bdbe6129f 100644
--- a/src/com/android/camera/ui/PieRenderer.java
+++ b/src/com/android/camera/ui/PieRenderer.java
@@ -71,6 +71,7 @@ public class PieRenderer extends OverlayRenderer
private static final long PIE_XFADE_DURATION = 200;
private static final long PIE_SELECT_FADE_DURATION = 300;
private static final long PIE_OPEN_SUB_DELAY = 400;
+ private static final long PIE_SLICE_DURATION = 80;
private static final int MSG_OPEN = 0;
private static final int MSG_CLOSE = 1;
@@ -133,6 +134,7 @@ public class PieRenderer extends OverlayRenderer
private LinearAnimation mXFade;
private LinearAnimation mFadeIn;
private FadeOutAnimation mFadeOut;
+ private LinearAnimation mSlice;
private volatile boolean mFocusCancelled;
private PointF mPolar = new PointF();
private TextDrawable mLabel;
@@ -571,7 +573,12 @@ public class PieRenderer extends OverlayRenderer
if (item.isSelected()) {
Paint p = mSelectedPaint;
int state = canvas.save();
- float angle = getArcCenter(item, pos, count) - SWEEP_ARC / 2f;
+ float angle = 0;
+ if (mSlice != null) {
+ angle = mSlice.getValue();
+ } else {
+ angle = getArcCenter(item, pos, count) - SWEEP_ARC / 2f;
+ }
angle = getDegrees(angle);
canvas.rotate(angle, mPieCenterX, y);
if (mFadeOut != null) {
@@ -715,6 +722,7 @@ public class PieRenderer extends OverlayRenderer
mCurrentItem.setSelected(false);
}
if (item != null && item.isEnabled()) {
+ moveSelection(mCurrentItem, item);
item.setSelected(true);
mCurrentItem = item;
mLabel.setText(mCurrentItem.getLabel());
@@ -764,6 +772,44 @@ public class PieRenderer extends OverlayRenderer
}
}
+ private int getItemPos(PieItem target) {
+ List<PieItem> items = getOpenItem().getItems();
+ return items.indexOf(target);
+ }
+
+ private int getCurrentCount() {
+ return getOpenItem().getItems().size();
+ }
+
+ private void moveSelection(PieItem from, PieItem to) {
+ final int count = getCurrentCount();
+ final int fromPos = getItemPos(from);
+ final int toPos = getItemPos(to);
+ if (fromPos != -1 && toPos != -1) {
+ float startAngle = getArcCenter(from, getItemPos(from), count)
+ - SWEEP_ARC / 2f;
+ float endAngle = getArcCenter(to, getItemPos(to), count)
+ - SWEEP_ARC / 2f;
+ mSlice = new LinearAnimation(startAngle, endAngle);
+ mSlice.setDuration(PIE_SLICE_DURATION);
+ mSlice.setAnimationListener(new AnimationListener() {
+ @Override
+ public void onAnimationEnd(Animation arg0) {
+ mSlice = null;
+ }
+
+ @Override
+ public void onAnimationRepeat(Animation arg0) {
+ }
+
+ @Override
+ public void onAnimationStart(Animation arg0) {
+ }
+ });
+ mOverlay.startAnimation(mSlice);
+ }
+ }
+
private void openCurrentItem() {
if ((mCurrentItem != null) && mCurrentItem.hasItems()) {
mOpen.add(mCurrentItem);