am 0995ac8a: am deafb56c: am 014369d5: Bring Gallery2 manifest into parity with CROP support

* commit '0995ac8ab3d5be9db6fa819ae215da5f70303e5e':
diff --git a/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java b/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java
index a671ed2..99b1251 100644
--- a/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java
+++ b/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java
@@ -23,7 +23,6 @@
 import android.graphics.Matrix;
 import android.graphics.Paint;
 import android.os.Build;
-import android.util.FloatMath;
 import android.util.Log;
 
 import java.io.ByteArrayOutputStream;
@@ -72,7 +71,7 @@
                 && minSideLength == UNCONSTRAINED) return 1;
 
         int lowerBound = (maxNumOfPixels == UNCONSTRAINED) ? 1 :
-                (int) FloatMath.ceil(FloatMath.sqrt((float) (w * h) / maxNumOfPixels));
+                (int) Math.ceil(Math.sqrt((double) (w * h) / maxNumOfPixels));
 
         if (minSideLength == UNCONSTRAINED) {
             return lowerBound;
@@ -96,7 +95,7 @@
 
     // Find the min x that 1 / x >= scale
     public static int computeSampleSizeLarger(float scale) {
-        int initialSize = (int) FloatMath.floor(1f / scale);
+        int initialSize = (int) Math.floor(1d / scale);
         if (initialSize <= 1) return 1;
 
         return initialSize <= 8
@@ -107,7 +106,7 @@
     // Find the max x that 1 / x <= scale.
     public static int computeSampleSize(float scale) {
         Utils.assertTrue(scale > 0);
-        int initialSize = Math.max(1, (int) FloatMath.ceil(1 / scale));
+        int initialSize = Math.max(1, (int) Math.ceil(1 / scale));
         return initialSize <= 8
                 ? Utils.nextPowerOf2(initialSize)
                 : (initialSize + 7) / 8 * 8;
diff --git a/gallerycommon/src/com/android/gallery3d/common/OverScroller.java b/gallerycommon/src/com/android/gallery3d/common/OverScroller.java
index 1ab7953..a03c451 100644
--- a/gallerycommon/src/com/android/gallery3d/common/OverScroller.java
+++ b/gallerycommon/src/com/android/gallery3d/common/OverScroller.java
@@ -18,7 +18,6 @@
 
 import android.content.Context;
 import android.hardware.SensorManager;
-import android.util.FloatMath;
 import android.util.Log;
 import android.view.ViewConfiguration;
 import android.view.animation.AnimationUtils;
@@ -175,9 +174,7 @@
      * @return The original velocity less the deceleration, norm of the X and Y velocity vector.
      */
     public float getCurrVelocity() {
-        float squaredNorm = mScrollerX.mCurrVelocity * mScrollerX.mCurrVelocity;
-        squaredNorm += mScrollerY.mCurrVelocity * mScrollerY.mCurrVelocity;
-        return FloatMath.sqrt(squaredNorm);
+        return (float) Math.hypot(mScrollerX.mCurrVelocity, mScrollerY.mCurrVelocity);
     }
 
     /**
diff --git a/gallerycommon/src/com/android/gallery3d/common/Scroller.java b/gallerycommon/src/com/android/gallery3d/common/Scroller.java
index 6cefd6f..cce0c92 100644
--- a/gallerycommon/src/com/android/gallery3d/common/Scroller.java
+++ b/gallerycommon/src/com/android/gallery3d/common/Scroller.java
@@ -19,7 +19,6 @@
 import android.content.Context;
 import android.hardware.SensorManager;
 import android.os.Build;
-import android.util.FloatMath;
 import android.view.ViewConfiguration;
 import android.view.animation.AnimationUtils;
 import android.view.animation.Interpolator;
@@ -372,7 +371,7 @@
 
             float dx = mFinalX - mStartX;
             float dy = mFinalY - mStartY;
-            float hyp = FloatMath.sqrt(dx * dx + dy * dy);
+            float hyp = (float) Math.hypot(dx, dy);
 
             float ndx = dx / hyp;
             float ndy = dy / hyp;
@@ -389,7 +388,7 @@
         mMode = FLING_MODE;
         mFinished = false;
 
-        float velocity = FloatMath.sqrt(velocityX * velocityX + velocityY * velocityY);
+        float velocity = (float) Math.hypot(velocityX, velocityY);
 
         mVelocity = velocity;
         final double l = Math.log(START_TENSION * velocity / ALPHA);
diff --git a/src/com/android/gallery3d/app/EyePosition.java b/src/com/android/gallery3d/app/EyePosition.java
index d99d97b..4248f49 100644
--- a/src/com/android/gallery3d/app/EyePosition.java
+++ b/src/com/android/gallery3d/app/EyePosition.java
@@ -22,7 +22,6 @@
 import android.hardware.SensorEventListener;
 import android.hardware.SensorManager;
 import android.os.SystemClock;
-import android.util.FloatMath;
 import android.view.Display;
 import android.view.Surface;
 import android.view.WindowManager;
@@ -44,9 +43,9 @@
     private static final float GYROSCOPE_RESTORE_FACTOR = 0.995f;
 
     private static final float USER_ANGEL = (float) Math.toRadians(10);
-    private static final float USER_ANGEL_COS = FloatMath.cos(USER_ANGEL);
-    private static final float USER_ANGEL_SIN = FloatMath.sin(USER_ANGEL);
-    private static final float MAX_VIEW_RANGE = (float) 0.5;
+    private static final float USER_ANGEL_COS = (float) Math.cos(USER_ANGEL);
+    private static final float USER_ANGEL_SIN = (float) Math.sin(USER_ANGEL);
+    private static final float MAX_VIEW_RANGE = 0.5f;
     private static final int NOT_STARTED = -1;
 
     private static final float USER_DISTANCE_METER = 0.3f;
@@ -128,8 +127,8 @@
         float ty = -1 + t * y;
         float tz = t * z;
 
-        float length = FloatMath.sqrt(tx * tx + ty * ty + tz * tz);
-        float glength = FloatMath.sqrt(temp);
+        float length = (float) Math.sqrt(tx * tx + ty * ty + tz * tz);
+        float glength = (float) Math.sqrt(temp);
 
         mX = Utils.clamp((x * USER_ANGEL_COS / glength
                 + tx * USER_ANGEL_SIN / length) * mUserDistance,
@@ -137,7 +136,7 @@
         mY = -Utils.clamp((y * USER_ANGEL_COS / glength
                 + ty * USER_ANGEL_SIN / length) * mUserDistance,
                 -mLimit, mLimit);
-        mZ = -FloatMath.sqrt(
+        mZ = (float) -Math.sqrt(
                 mUserDistance * mUserDistance - mX * mX - mY * mY);
         mListener.onEyePositionChanged(mX, mY, mZ);
     }
@@ -175,7 +174,7 @@
         mY = Utils.clamp((float) (mY + y * t / Math.hypot(mZ, mY)),
                 -mLimit, mLimit) * GYROSCOPE_RESTORE_FACTOR;
 
-        mZ = -FloatMath.sqrt(
+        mZ = (float) -Math.sqrt(
                 mUserDistance * mUserDistance - mX * mX - mY * mY);
         mListener.onEyePositionChanged(mX, mY, mZ);
     }
diff --git a/src/com/android/gallery3d/data/DecodeUtils.java b/src/com/android/gallery3d/data/DecodeUtils.java
index fa70915..2853baf 100644
--- a/src/com/android/gallery3d/data/DecodeUtils.java
+++ b/src/com/android/gallery3d/data/DecodeUtils.java
@@ -23,7 +23,6 @@
 import android.graphics.BitmapFactory.Options;
 import android.graphics.BitmapRegionDecoder;
 import android.os.Build;
-import android.util.FloatMath;
 
 import com.android.gallery3d.common.ApiHelper;
 import com.android.gallery3d.common.BitmapUtils;
@@ -135,7 +134,7 @@
             final int MAX_PIXEL_COUNT = 640000; // 400 x 1600
             if ((w / options.inSampleSize) * (h / options.inSampleSize) > MAX_PIXEL_COUNT) {
                 options.inSampleSize = BitmapUtils.computeSampleSize(
-                        FloatMath.sqrt((float) MAX_PIXEL_COUNT / (w * h)));
+                        (float) Math.sqrt((double) MAX_PIXEL_COUNT / (w * h)));
             }
         } else {
             // For screen nail, we only want to keep the longer side >= targetSize.
diff --git a/src/com/android/gallery3d/data/LocationClustering.java b/src/com/android/gallery3d/data/LocationClustering.java
index 540322a..90ac41c 100644
--- a/src/com/android/gallery3d/data/LocationClustering.java
+++ b/src/com/android/gallery3d/data/LocationClustering.java
@@ -19,7 +19,6 @@
 import android.content.Context;
 import android.os.Handler;
 import android.os.Looper;
-import android.util.FloatMath;
 import android.widget.Toast;
 
 import com.android.gallery3d.R;
@@ -298,7 +297,7 @@
             }
 
             // step 5: calculate the final score
-            float score = totalDistance * FloatMath.sqrt(realK);
+            float score = totalDistance * (float) Math.sqrt(realK);
 
             if (score < bestScore) {
                 bestScore = score;
diff --git a/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java b/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java
index dada7dc..614b648 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java
@@ -151,7 +151,7 @@
     }
 
     public static float[] normalize(float[] a) {
-        float length = (float) Math.sqrt(a[0] * a[0] + a[1] * a[1]);
+        float length = (float) Math.hypot(a[0], a[1]);
         float[] b = {
                 a[0] / length, a[1] / length
         };
@@ -160,7 +160,7 @@
 
     // A onto B
     public static float scalarProjection(float[] a, float[] b) {
-        float length = (float) Math.sqrt(b[0] * b[0] + b[1] * b[1]);
+        float length = (float) Math.hypot(b[0], b[1]);
         return dotProduct(a, b) / length;
     }
 
@@ -175,7 +175,7 @@
         float[] p = {
                 point2[0] - point1[0], point2[1] - point1[1]
         };
-        float length = (float) Math.sqrt(p[0] * p[0] + p[1] * p[1]);
+        float length = (float) Math.hypot(p[0], p[1]);
         p[0] = p[0] / length;
         p[1] = p[1] / length;
         return p;
@@ -198,7 +198,7 @@
     }
 
     public static float vectorLength(float[] a) {
-        return (float) Math.sqrt(a[0] * a[0] + a[1] * a[1]);
+        return (float) Math.hypot(a[0], a[1]);
     }
 
     public static float scale(float oldWidth, float oldHeight, float newWidth, float newHeight) {
diff --git a/src/com/android/gallery3d/filtershow/imageshow/GradControl.java b/src/com/android/gallery3d/filtershow/imageshow/GradControl.java
index 964da99..2987015 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/GradControl.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/GradControl.java
@@ -110,7 +110,7 @@
         for (int i = 0; i < handlex.length; i++) {
             float dx = handlex[i] - x;
             float dy = handley[i] - y;
-            float dist = (float) Math.sqrt(dx * dx + dy * dy);
+            float dist = (float) Math.hypot(dx, dy);
         }
 
         return -1;
@@ -236,7 +236,7 @@
         float cy = (p1y + p2y) / 2;
         float dx = p1x - p2x;
         float dy = p1y - p2y;
-        float len = (float) Math.sqrt(dx * dx + dy * dy);
+        float len = (float) Math.hypot(dx, dy);
         dx *= 2048 / len;
         dy *= 2048 / len;
 
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageCurves.java b/src/com/android/gallery3d/filtershow/imageshow/ImageCurves.java
index 0d20322..3fb75c6 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageCurves.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageCurves.java
@@ -223,12 +223,11 @@
         Spline spline = getSpline(mCurrentCurveIndex);
         float px = spline.getPoint(0).x;
         float py = spline.getPoint(0).y;
-        double delta = Math.sqrt((px - x) * (px - x) + (py - y) * (py - y));
+        double delta = Math.hypot(px - x, py - y);
         for (int i = 1; i < spline.getNbPoints(); i++) {
             px = spline.getPoint(i).x;
             py = spline.getPoint(i).y;
-            double currentDelta = Math.sqrt((px - x) * (px - x) + (py - y)
-                    * (py - y));
+            double currentDelta = Math.hypot(px - x, py - y);
             if (currentDelta < delta) {
                 delta = currentDelta;
                 pick = i;
diff --git a/src/com/android/gallery3d/glrenderer/StringTexture.java b/src/com/android/gallery3d/glrenderer/StringTexture.java
index 56ca297..c18d91b 100644
--- a/src/com/android/gallery3d/glrenderer/StringTexture.java
+++ b/src/com/android/gallery3d/glrenderer/StringTexture.java
@@ -23,7 +23,6 @@
 import android.graphics.Typeface;
 import android.text.TextPaint;
 import android.text.TextUtils;
-import android.util.FloatMath;
 
 // StringTexture is a texture shows the content of a specified String.
 //
@@ -72,7 +71,7 @@
 
     private static StringTexture newInstance(String text, TextPaint paint) {
         FontMetricsInt metrics = paint.getFontMetricsInt();
-        int width = (int) FloatMath.ceil(paint.measureText(text));
+        int width = (int) Math.ceil(paint.measureText(text));
         int height = metrics.bottom - metrics.top;
         // The texture size needs to be at least 1x1.
         if (width <= 0) width = 1;
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
index 7afa203..e8c706f 100644
--- a/src/com/android/gallery3d/ui/PhotoView.java
+++ b/src/com/android/gallery3d/ui/PhotoView.java
@@ -23,7 +23,6 @@
 import android.graphics.Rect;
 import android.os.Build;
 import android.os.Message;
-import android.util.FloatMath;
 import android.view.MotionEvent;
 import android.view.View.MeasureSpec;
 import android.view.animation.AccelerateInterpolator;
@@ -1071,7 +1070,7 @@
                 delta = delta > 0 ? maxScrollDistance : -maxScrollDistance;
             } else {
                 delta = maxScrollDistance *
-                        FloatMath.sin((delta / size) * (float) (Math.PI / 2));
+                        (float) Math.sin((delta / size) * (Math.PI / 2));
             }
             return (int) (delta + 0.5f);
         }
diff --git a/src/com/android/gallery3d/ui/TileImageView.java b/src/com/android/gallery3d/ui/TileImageView.java
index 3185c75..1103ed8 100644
--- a/src/com/android/gallery3d/ui/TileImageView.java
+++ b/src/com/android/gallery3d/ui/TileImageView.java
@@ -23,7 +23,6 @@
 import android.graphics.RectF;
 import android.support.v4.util.LongSparseArray;
 import android.util.DisplayMetrics;
-import android.util.FloatMath;
 import android.view.WindowManager;
 
 import com.android.gallery3d.app.GalleryContext;
@@ -313,10 +312,10 @@
         int height = (int) Math.ceil(Math.max(
                 Math.abs(sin * w + cos * h), Math.abs(sin * w - cos * h)));
 
-        int left = (int) FloatMath.floor(cX - width / (2f * scale));
-        int top = (int) FloatMath.floor(cY - height / (2f * scale));
-        int right = (int) FloatMath.ceil(left + width / scale);
-        int bottom = (int) FloatMath.ceil(top + height / scale);
+        int left = (int) Math.floor(cX - width / (2f * scale));
+        int top = (int) Math.floor(cY - height / (2f * scale));
+        int right = (int) Math.ceil(left + width / scale);
+        int bottom = (int) Math.ceil(top + height / scale);
 
         // align the rectangle to tile boundary
         int size = sTileSize << level;
diff --git a/src/com/android/gallery3d/util/MotionEventHelper.java b/src/com/android/gallery3d/util/MotionEventHelper.java
index 715f7fa..dc01cd9 100644
--- a/src/com/android/gallery3d/util/MotionEventHelper.java
+++ b/src/com/android/gallery3d/util/MotionEventHelper.java
@@ -17,7 +17,6 @@
 
 import android.annotation.TargetApi;
 import android.graphics.Matrix;
-import android.util.FloatMath;
 import android.view.MotionEvent;
 import android.view.MotionEvent.PointerCoords;
 
@@ -104,8 +103,8 @@
         // angle from vertical.  Coordinate system: down is increasing Y, right is
         // increasing X.
         float[] v = new float[2];
-        v[0] = FloatMath.sin(angleRadians);
-        v[1] = -FloatMath.cos(angleRadians);
+        v[0] = (float) Math.sin(angleRadians);
+        v[1] = (float) -Math.cos(angleRadians);
         m.mapVectors(v);
 
         // Derive the transformed vector's clockwise angle from vertical.