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

Commit b04d9336 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Modified ShapeState#newDrawable to pass a deep copy of ShapeState"

parents 28a368d3 a2d61be9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -594,12 +594,12 @@ public class ShapeDrawable extends Drawable {

        @Override
        public Drawable newDrawable() {
            return new ShapeDrawable(this, null);
            return new ShapeDrawable(new ShapeState(this), null);
        }

        @Override
        public Drawable newDrawable(Resources res) {
            return new ShapeDrawable(this, res);
            return new ShapeDrawable(new ShapeState(this), res);
        }

        @Override
+23 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.graphics.Canvas;
import android.graphics.Outline;
import android.graphics.Paint;

import java.util.Objects;

/**
 * Creates an arc shape. The arc shape starts at a specified angle and sweeps
 * clockwise, drawing slices of pie.
@@ -74,5 +76,26 @@ public class ArcShape extends RectShape {
    public ArcShape clone() throws CloneNotSupportedException {
        return (ArcShape) super.clone();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        ArcShape arcShape = (ArcShape) o;
        return Float.compare(arcShape.mStartAngle, mStartAngle) == 0
            && Float.compare(arcShape.mSweepAngle, mSweepAngle) == 0;
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), mStartAngle, mSweepAngle);
    }
}
+27 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;

import java.util.Objects;

/**
 * Creates geometric paths, utilizing the {@link android.graphics.Path} class.
 * <p>
@@ -74,5 +76,30 @@ public class PathShape extends Shape {
        shape.mPath = new Path(mPath);
        return shape;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        PathShape pathShape = (PathShape) o;
        return Float.compare(pathShape.mStdWidth, mStdWidth) == 0
            && Float.compare(pathShape.mStdHeight, mStdHeight) == 0
            && Float.compare(pathShape.mScaleX, mScaleX) == 0
            && Float.compare(pathShape.mScaleY, mScaleY) == 0
            // Path does not have equals implementation but incase it gains one, use it here
            && Objects.equals(mPath, pathShape.mPath);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), mStdWidth, mStdHeight, mPath, mScaleX, mScaleY);
    }
}
+22 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.RectF;

import java.util.Objects;

/**
 * Defines a rectangle shape.
 * <p>
@@ -63,4 +65,24 @@ public class RectShape extends Shape {
        shape.mRect = new RectF(mRect);
        return shape;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        RectShape rectShape = (RectShape) o;
        return Objects.equals(mRect, rectShape.mRect);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), mRect);
    }
}
+30 −0
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@ import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;

import java.util.Arrays;
import java.util.Objects;

/**
 * Creates a rounded-corner rectangle. Optionally, an inset (rounded) rectangle
 * can be included (to make a sort of "O" shape).
@@ -137,4 +140,31 @@ public class RoundRectShape extends RectShape {
        shape.mPath = new Path(mPath);
        return shape;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        RoundRectShape that = (RoundRectShape) o;
        return Arrays.equals(mOuterRadii, that.mOuterRadii)
            && Objects.equals(mInset, that.mInset)
            && Arrays.equals(mInnerRadii, that.mInnerRadii)
            && Objects.equals(mInnerRect, that.mInnerRect)
            && Objects.equals(mPath, that.mPath);
    }

    @Override
    public int hashCode() {
        int result = Objects.hash(super.hashCode(), mInset, mInnerRect, mPath);
        result = 31 * result + Arrays.hashCode(mOuterRadii);
        result = 31 * result + Arrays.hashCode(mInnerRadii);
        return result;
    }
}
Loading