Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c1faf43 authored by Neil Fuller's avatar Neil Fuller Committed by Gerrit Code Review
Browse files

Merge "Switch from FloatMath -> Math and Math.hypot where possible"

parents 31629651 33253a4b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -635,7 +635,7 @@ public class GestureOverlayView extends FrameLayout {
            mStrokeBuffer.add(new GesturePoint(x, y, event.getEventTime()));

            if (mHandleGestureActions && !mIsGesturing) {
                mTotalLength += (float) Math.sqrt(dx * dx + dy * dy);
                mTotalLength += (float) Math.hypot(dx, dy);

                if (mTotalLength > mGestureStrokeLengthThreshold) {
                    final OrientedBoundingBox box =
+1 −2
Original line number Diff line number Diff line
@@ -69,8 +69,7 @@ public class GestureStroke {
                bx.bottom = p.y;
                len = 0;
            } else {
                len += Math.sqrt(Math.pow(p.x - tmpPoints[(i - 1) * 2], 2)
                        + Math.pow(p.y - tmpPoints[(i -1 ) * 2 + 1], 2));
                len += Math.hypot(p.x - tmpPoints[(i - 1) * 2], p.y - tmpPoints[(i -1 ) * 2 + 1]);
                bx.union(p.x, p.y);
            }
            index++;
+4 −4
Original line number Diff line number Diff line
@@ -293,7 +293,7 @@ public final class GestureUtils {
            }
            float deltaX = currentPointX - lstPointX;
            float deltaY = currentPointY - lstPointY;
            float distance = (float) Math.sqrt(deltaX * deltaX + deltaY * deltaY);
            float distance = (float) Math.hypot(deltaX, deltaY);
            if (distanceSoFar + distance >= increment) {
                float ratio = (increment - distanceSoFar) / distance;
                float nx = lstPointX + ratio * deltaX;
@@ -379,7 +379,7 @@ public final class GestureUtils {
        for (int i = 0; i < count; i += 2) {
            float dx = points[i + 2] - points[i];
            float dy = points[i + 3] - points[i + 1];
            sum += Math.sqrt(dx * dx + dy * dy);
            sum += Math.hypot(dx, dy);
        }
        return sum;
    }
@@ -388,13 +388,13 @@ public final class GestureUtils {
        float totalLen = computeTotalLength(points);
        float dx = points[2] - points[0];
        float dy = points[3] - points[1];
        return (float) Math.sqrt(dx * dx + dy * dy) / totalLen;
        return (float) Math.hypot(dx, dy) / totalLen;
    }

    static float computeStraightness(float[] points, float totalLen) {
        float dx = points[2] - points[0];
        float dy = points[3] - points[1];
        return (float) Math.sqrt(dx * dx + dy * dy) / totalLen;
        return (float) Math.hypot(dx, dy) / totalLen;
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -281,7 +281,7 @@ public class GeomagneticField {
     * @return  Horizontal component of the field strength in nonoteslas.
     */
    public float getHorizontalStrength() {
        return (float) Math.sqrt(mX * mX + mY * mY);
        return (float) Math.hypot(mX, mY);
    }

    /**
+2 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.text.style.ParagraphStyle;
import android.util.FloatMath;

/**
 * A BoringLayout is a very simple Layout implementation for text that
@@ -211,7 +210,7 @@ public class BoringLayout extends Layout implements TextUtils.EllipsizeCallback
            TextLine line = TextLine.obtain();
            line.set(paint, source, 0, source.length(), Layout.DIR_LEFT_TO_RIGHT,
                    Layout.DIRS_ALL_LEFT_TO_RIGHT, false, null);
            mMax = (int) FloatMath.ceil(line.metrics(null));
            mMax = (int) Math.ceil(line.metrics(null));
            TextLine.recycle(line);
        }

@@ -305,7 +304,7 @@ public class BoringLayout extends Layout implements TextUtils.EllipsizeCallback
            TextLine line = TextLine.obtain();
            line.set(paint, text, 0, length, Layout.DIR_LEFT_TO_RIGHT,
                    Layout.DIRS_ALL_LEFT_TO_RIGHT, false, null);
            fm.width = (int) FloatMath.ceil(line.metrics(fm));
            fm.width = (int) Math.ceil(line.metrics(fm));
            TextLine.recycle(line);

            return fm;
Loading