API review: Constants to Gravity and Epicenter.
Bug 15432037
Constants for LEFT, RIGHT, TOP, BOTTOM moved to using Gravity.
Epicenter method name changed.
Change-Id: If226613794623fd50fdaf8fc61b0020d17628f68
diff --git a/api/current.txt b/api/current.txt
index 79fb8df..052a64d 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -29903,20 +29903,12 @@
method public long getStartDelay(android.view.ViewGroup, android.transition.Transition, android.transition.TransitionValues, android.transition.TransitionValues);
method public void setPropagationSpeed(float);
method public void setSide(int);
- field public static final int BOTTOM = 3; // 0x3
- field public static final int LEFT = 0; // 0x0
- field public static final int RIGHT = 2; // 0x2
- field public static final int TOP = 1; // 0x1
}
public class Slide extends android.transition.Visibility {
ctor public Slide();
ctor public Slide(int);
method public void setSlideEdge(int);
- field public static final int BOTTOM = 3; // 0x3
- field public static final int LEFT = 0; // 0x0
- field public static final int RIGHT = 2; // 0x2
- field public static final int TOP = 1; // 0x1
}
public abstract class Transition implements java.lang.Cloneable {
@@ -29970,7 +29962,7 @@
public static abstract class Transition.EpicenterCallback {
ctor public Transition.EpicenterCallback();
- method public abstract android.graphics.Rect getEpicenter(android.transition.Transition);
+ method public abstract android.graphics.Rect onGetEpicenter(android.transition.Transition);
}
public static abstract interface Transition.TransitionListener {
diff --git a/core/java/android/app/ActivityTransitionCoordinator.java b/core/java/android/app/ActivityTransitionCoordinator.java
index b739387..b658597 100644
--- a/core/java/android/app/ActivityTransitionCoordinator.java
+++ b/core/java/android/app/ActivityTransitionCoordinator.java
@@ -563,7 +563,7 @@
public void setEpicenter(Rect epicenter) { mEpicenter = epicenter; }
@Override
- public Rect getEpicenter(Transition transition) {
+ public Rect onGetEpicenter(Transition transition) {
return mEpicenter;
}
}
diff --git a/core/java/android/transition/SidePropagation.java b/core/java/android/transition/SidePropagation.java
index 5d38ac8..623cdd1 100644
--- a/core/java/android/transition/SidePropagation.java
+++ b/core/java/android/transition/SidePropagation.java
@@ -18,6 +18,7 @@
import android.graphics.Rect;
import android.util.FloatMath;
import android.util.Log;
+import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
@@ -32,38 +33,19 @@
public class SidePropagation extends VisibilityPropagation {
private static final String TAG = "SlidePropagation";
- /**
- * Transition propagates relative to the distance of the left side of the scene.
- */
- public static final int LEFT = Slide.LEFT;
-
- /**
- * Transition propagates relative to the distance of the top of the scene.
- */
- public static final int TOP = Slide.TOP;
-
- /**
- * Transition propagates relative to the distance of the right side of the scene.
- */
- public static final int RIGHT = Slide.RIGHT;
-
- /**
- * Transition propagates relative to the distance of the bottom of the scene.
- */
- public static final int BOTTOM = Slide.BOTTOM;
-
private float mPropagationSpeed = 3.0f;
- private int mSide = BOTTOM;
+ private int mSide = Gravity.BOTTOM;
/**
* Sets the side that is used to calculate the transition propagation. If the transitioning
* View is visible in the start of the transition, then it will transition sooner when
* closer to the side and later when farther. If the view is not visible in the start of
* the transition, then it will transition later when closer to the side and sooner when
- * farther from the edge. The default is {@link #BOTTOM}.
+ * farther from the edge. The default is {@link Gravity#BOTTOM}.
*
* @param side The side that is used to calculate the transition propagation. Must be one of
- * {@link #LEFT}, {@link #TOP}, {@link #RIGHT}, or {@link #BOTTOM}.
+ * {@link Gravity#LEFT}, {@link Gravity#TOP}, {@link Gravity#RIGHT}, or
+ * {@link Gravity#BOTTOM}.
*/
public void setSide(int side) {
mSide = side;
@@ -141,16 +123,16 @@
int left, int top, int right, int bottom) {
int distance = 0;
switch (mSide) {
- case LEFT:
+ case Gravity.LEFT:
distance = right - viewX + Math.abs(epicenterY - viewY);
break;
- case TOP:
+ case Gravity.TOP:
distance = bottom - viewY + Math.abs(epicenterX - viewX);
break;
- case RIGHT:
+ case Gravity.RIGHT:
distance = viewX - left + Math.abs(epicenterY - viewY);
break;
- case BOTTOM:
+ case Gravity.BOTTOM:
distance = viewY - top + Math.abs(epicenterX - viewX);
break;
}
@@ -159,8 +141,8 @@
private int getMaxDistance(ViewGroup sceneRoot) {
switch (mSide) {
- case LEFT:
- case RIGHT:
+ case Gravity.LEFT:
+ case Gravity.RIGHT:
return sceneRoot.getWidth();
default:
return sceneRoot.getHeight();
diff --git a/core/java/android/transition/Slide.java b/core/java/android/transition/Slide.java
index 0ff8ddd..8269258 100644
--- a/core/java/android/transition/Slide.java
+++ b/core/java/android/transition/Slide.java
@@ -24,6 +24,7 @@
import android.graphics.Rect;
import android.util.Log;
import android.util.Property;
+import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
@@ -41,35 +42,9 @@
public class Slide extends Visibility {
private static final String TAG = "Slide";
- /**
- * Move Views in or out of the left edge of the scene.
- * @see #setSlideEdge(int)
- */
- public static final int LEFT = 0;
-
- /**
- * Move Views in or out of the top edge of the scene.
- * @see #setSlideEdge(int)
- */
- public static final int TOP = 1;
-
- /**
- * Move Views in or out of the right edge of the scene.
- * @see #setSlideEdge(int)
- */
- public static final int RIGHT = 2;
-
- /**
- * Move Views in or out of the bottom edge of the scene. This is the
- * default slide direction.
- * @see #setSlideEdge(int)
- */
- public static final int BOTTOM = 3;
-
private static final TimeInterpolator sDecelerate = new DecelerateInterpolator();
private static final TimeInterpolator sAccelerate = new AccelerateInterpolator();
- private int[] mTempLoc = new int[2];
private CalculateSlide mSlideCalculator = sCalculateBottom;
private interface CalculateSlide {
@@ -136,11 +111,11 @@
};
/**
- * Constructor using the default {@link android.transition.Slide#BOTTOM}
+ * Constructor using the default {@link Gravity#BOTTOM}
* slide edge direction.
*/
public Slide() {
- setSlideEdge(BOTTOM);
+ setSlideEdge(Gravity.BOTTOM);
}
/**
@@ -152,20 +127,22 @@
/**
* Change the edge that Views appear and disappear from.
- * @param slideEdge The edge of the scene to use for Views appearing and disappearing.
+ * @param slideEdge The edge of the scene to use for Views appearing and disappearing. One of
+ * {@link android.view.Gravity#LEFT}, {@link android.view.Gravity#TOP},
+ * {@link android.view.Gravity#RIGHT}, {@link android.view.Gravity#BOTTOM}.
*/
public void setSlideEdge(int slideEdge) {
switch (slideEdge) {
- case LEFT:
+ case Gravity.LEFT:
mSlideCalculator = sCalculateLeft;
break;
- case TOP:
+ case Gravity.TOP:
mSlideCalculator = sCalculateTop;
break;
- case RIGHT:
+ case Gravity.RIGHT:
mSlideCalculator = sCalculateRight;
break;
- case BOTTOM:
+ case Gravity.BOTTOM:
mSlideCalculator = sCalculateBottom;
break;
default:
diff --git a/core/java/android/transition/Transition.java b/core/java/android/transition/Transition.java
index 9a70099..e9c2bba 100644
--- a/core/java/android/transition/Transition.java
+++ b/core/java/android/transition/Transition.java
@@ -1763,7 +1763,7 @@
/**
* Sets the callback to use to find the epicenter of a Transition. A null value indicates
- * that there is no epicenter in the Transition and getEpicenter() will return null.
+ * that there is no epicenter in the Transition and onGetEpicenter() will return null.
* Transitions like {@link android.transition.Explode} use a point or Rect to orient
* the direction of travel. This is called the epicenter of the Transition and is
* typically centered on a touched View. The
@@ -1799,7 +1799,7 @@
if (mEpicenterCallback == null) {
return null;
}
- return mEpicenterCallback.getEpicenter(this);
+ return mEpicenterCallback.onGetEpicenter(this);
}
/**
@@ -2112,6 +2112,6 @@
* @return The Rect region of the epicenter of <code>transition</code> or null if
* there is no epicenter.
*/
- public abstract Rect getEpicenter(Transition transition);
+ public abstract Rect onGetEpicenter(Transition transition);
}
}
diff --git a/core/java/android/transition/TransitionInflater.java b/core/java/android/transition/TransitionInflater.java
index f4b562f..5b7c737 100644
--- a/core/java/android/transition/TransitionInflater.java
+++ b/core/java/android/transition/TransitionInflater.java
@@ -22,6 +22,7 @@
import android.content.res.XmlResourceParser;
import android.util.AttributeSet;
import android.util.Xml;
+import android.view.Gravity;
import android.view.InflateException;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
@@ -208,7 +209,7 @@
private Slide createSlideTransition(AttributeSet attrs) {
TypedArray a = mContext.obtainStyledAttributes(attrs,
com.android.internal.R.styleable.Slide);
- int edge = a.getInt(com.android.internal.R.styleable.Slide_slideEdge, Slide.BOTTOM);
+ int edge = a.getInt(com.android.internal.R.styleable.Slide_slideEdge, Gravity.BOTTOM);
Slide slide = new Slide(edge);
a.recycle();
return slide;