diff options
| author | Alan Viverette <alanv@google.com> | 2015-11-17 09:47:11 -0500 |
|---|---|---|
| committer | Alan Viverette <alanv@google.com> | 2015-11-17 09:48:25 -0500 |
| commit | 214fb68767502f5fede643a062c1dc5975d75b27 (patch) | |
| tree | be57cc6559c777d04c54dae2e3c0f17601ed6b97 /core/java/android/view/MagnificationSpec.java | |
| parent | 0283d44c0856499b5aabc3212487a44d6f4b2f63 (diff) | |
APIs for querying and controlling display magnification
Also separates magnification state and touch event handling. Moves
callbacks for window manager changes and display state changes into
the magnification controller.
Bug: 22718911
Change-Id: I3a8ba060a07d8f1f51856855a5f85601766fd45d
Diffstat (limited to 'core/java/android/view/MagnificationSpec.java')
| -rw-r--r-- | core/java/android/view/MagnificationSpec.java | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/core/java/android/view/MagnificationSpec.java b/core/java/android/view/MagnificationSpec.java index 0ee6714f7b5f..49242bb5aa65 100644 --- a/core/java/android/view/MagnificationSpec.java +++ b/core/java/android/view/MagnificationSpec.java @@ -28,10 +28,21 @@ import android.util.Pools.SynchronizedPool; public class MagnificationSpec implements Parcelable { private static final int MAX_POOL_SIZE = 20; private static final SynchronizedPool<MagnificationSpec> sPool = - new SynchronizedPool<MagnificationSpec>(MAX_POOL_SIZE); + new SynchronizedPool<>(MAX_POOL_SIZE); + /** The magnification scaling factor. */ public float scale = 1.0f; + + /** + * The X coordinate, in unscaled screen-relative pixels, around which + * magnification is focused. + */ public float offsetX; + + /** + * The Y coordinate, in unscaled screen-relative pixels, around which + * magnification is focused. + */ public float offsetY; private MagnificationSpec() { @@ -75,6 +86,12 @@ public class MagnificationSpec implements Parcelable { offsetY = 0.0f; } + public void setTo(MagnificationSpec other) { + scale = other.scale; + offsetX = other.offsetX; + offsetY = other.offsetY; + } + @Override public int describeContents() { return 0; @@ -89,6 +106,28 @@ public class MagnificationSpec implements Parcelable { } @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + + if (other == null || getClass() != other.getClass()) { + return false; + } + + final MagnificationSpec s = (MagnificationSpec) other; + return scale == s.scale && offsetX == s.offsetX && offsetY == s.offsetY; + } + + @Override + public int hashCode() { + int result = (scale != +0.0f ? Float.floatToIntBits(scale) : 0); + result = 31 * result + (offsetX != +0.0f ? Float.floatToIntBits(offsetX) : 0); + result = 31 * result + (offsetY != +0.0f ? Float.floatToIntBits(offsetY) : 0); + return result; + } + + @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("<scale:"); |
