summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mihai Popa <popam@google.com> 2019-01-29 21:26:26 +0000
committer Mihai Popa <popam@google.com> 2019-01-29 21:26:26 +0000
commit520e447586c3caa93c1222613ae6d8d6ac6a0b1c (patch)
tree3047447ec571914f76868d0a55138a73a260362e
parent00075f9245ab38ab011c03f371951cffe827269b (diff)
[Magnifier-74] Remove MAX_IN_VIEW sourcebound type
The CL removes the MAX_IN_VIEW type of source bounds, used to define where the content of the magnifier can be copied from. MAX_IN_VIEW was not used anywhere, and it is easily replaceable if developers need it: setting the source bound to MAX_IN_SURFACE and use the View#getWidth() and View#getHeight() methods to coerce the coordinates passed to the show() methods. Bug: 72211470 Test: atest CtsWidgetTestCases:android.widget.cts.MagnifierTest Change-Id: I3acaad0ec0c68d3ecaba1e0f5f490889d9ebc949
-rw-r--r--api/current.txt3
-rw-r--r--core/java/android/widget/Magnifier.java33
2 files changed, 5 insertions, 31 deletions
diff --git a/api/current.txt b/api/current.txt
index d431e3920661..9d9a4574326a 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -55950,8 +55950,7 @@ package android.widget {
method public void show(@FloatRange(from=0) float, @FloatRange(from=0) float, float, float);
method public void update();
field public static final int SOURCE_BOUND_MAX_IN_SURFACE = 0; // 0x0
- field public static final int SOURCE_BOUND_MAX_IN_VIEW = 1; // 0x1
- field public static final int SOURCE_BOUND_MAX_VISIBLE = 2; // 0x2
+ field public static final int SOURCE_BOUND_MAX_VISIBLE = 1; // 0x1
}
public static class Magnifier.Builder {
diff --git a/core/java/android/widget/Magnifier.java b/core/java/android/widget/Magnifier.java
index 5147306d277c..d5b1a3d69dfe 100644
--- a/core/java/android/widget/Magnifier.java
+++ b/core/java/android/widget/Magnifier.java
@@ -579,24 +579,11 @@ public final class Magnifier {
zoomCenterY = Math.round(yPosInView + mViewCoordinatesInSurface[1]);
}
- final Rect[] bounds = new Rect[3]; // [MAX_IN_SURFACE, MAX_IN_VIEW, MAX_VISIBLE]
+ final Rect[] bounds = new Rect[2]; // [MAX_IN_SURFACE, MAX_VISIBLE]
// Obtain the surface bounds rectangle.
final Rect surfaceBounds = new Rect(0, 0,
mContentCopySurface.mWidth, mContentCopySurface.mHeight);
bounds[0] = surfaceBounds;
- // Obtain the view bounds rectangle.
- final Rect viewBounds;
- if (mView instanceof SurfaceView) {
- viewBounds = new Rect(0, 0, mContentCopySurface.mWidth, mContentCopySurface.mHeight);
- } else {
- viewBounds = new Rect(
- mViewCoordinatesInSurface[0],
- mViewCoordinatesInSurface[1],
- mViewCoordinatesInSurface[0] + mView.getWidth(),
- mViewCoordinatesInSurface[1] + mView.getHeight()
- );
- }
- bounds[1] = viewBounds;
// Obtain the visible view region rectangle.
final Rect viewVisibleRegion = new Rect();
mView.getGlobalVisibleRect(viewVisibleRegion);
@@ -609,7 +596,7 @@ public final class Magnifier {
// If we copy content from a SurfaceView, clamp coordinates relative to it.
viewVisibleRegion.offset(-mViewCoordinatesInSurface[0], -mViewCoordinatesInSurface[1]);
}
- bounds[2] = viewVisibleRegion;
+ bounds[1] = viewVisibleRegion;
// Aggregate the above to obtain the bounds where the content copy will be restricted.
int resolvedLeft = Integer.MIN_VALUE;
@@ -1301,11 +1288,6 @@ public final class Magnifier {
* {@link android.view.View#getGlobalVisibleRect(Rect)}. For example, this will take into
* account the case when the view is contained in a scrollable container, and the
* magnifier will refuse to copy content outside of the visible view region</li>
- * <li>{@link #SOURCE_BOUND_MAX_IN_VIEW}, which extends the bound as much as possible
- * while remaining in the bounds of the view. Note that, although this option is
- * used, the magnifier will always only display content visible on the screen: if the
- * view lays outside the screen or is covered by a different view either partially or
- * totally, the magnifier will not show any view region not visible on the screen.</li>
* <li>{@link #SOURCE_BOUND_MAX_IN_SURFACE}, which extends the bound as much
* as possible while remaining inside the surface the content is copied from.</li>
* </ul>
@@ -1349,21 +1331,14 @@ public final class Magnifier {
* A source bound that will extend as much as possible, while remaining within the surface
* the content is copied from.
*/
-
public static final int SOURCE_BOUND_MAX_IN_SURFACE = 0;
- /**
- * A source bound that will extend as much as possible, while remaining within the
- * magnified view.
- */
-
- public static final int SOURCE_BOUND_MAX_IN_VIEW = 1;
/**
* A source bound that will extend as much as possible, while remaining within the
* visible region of the magnified view, as determined by
* {@link View#getGlobalVisibleRect(Rect)}.
*/
- public static final int SOURCE_BOUND_MAX_VISIBLE = 2;
+ public static final int SOURCE_BOUND_MAX_VISIBLE = 1;
/**
@@ -1373,7 +1348,7 @@ public final class Magnifier {
*
* @hide
*/
- @IntDef({SOURCE_BOUND_MAX_IN_SURFACE, SOURCE_BOUND_MAX_IN_VIEW, SOURCE_BOUND_MAX_VISIBLE})
+ @IntDef({SOURCE_BOUND_MAX_IN_SURFACE, SOURCE_BOUND_MAX_VISIBLE})
@Retention(RetentionPolicy.SOURCE)
public @interface SourceBound {}