Merge "Gesture exclusion rects for Window" into qt-dev

am: 341ea09831

Change-Id: I07a9ad1a0d3ab20aeb1227c0895fa27bb4de3b19
This commit is contained in:
Adam Powell
2019-04-16 21:25:02 -07:00
committed by android-build-merger
5 changed files with 99 additions and 2 deletions

View File

@@ -51511,6 +51511,7 @@ package android.view {
method public android.transition.Transition getSharedElementReturnTransition();
method public boolean getSharedElementsUseOverlay();
method @ColorInt public abstract int getStatusBarColor();
method @NonNull public java.util.List<android.graphics.Rect> getSystemGestureExclusionRects();
method public long getTransitionBackgroundFadeDuration();
method public android.transition.TransitionManager getTransitionManager();
method public abstract int getVolumeControlStream();
@@ -51589,6 +51590,7 @@ package android.view {
method public void setSoftInputMode(int);
method public abstract void setStatusBarColor(@ColorInt int);
method public void setSustainedPerformanceMode(boolean);
method public void setSystemGestureExclusionRects(@NonNull java.util.List<android.graphics.Rect>);
method public abstract void setTitle(CharSequence);
method @Deprecated public abstract void setTitleColor(@ColorInt int);
method public void setTransitionBackgroundFadeDuration(long);

View File

@@ -20,6 +20,8 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.graphics.Rect;
import com.android.internal.util.Preconditions;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
@@ -31,6 +33,8 @@ import java.util.List;
*/
class GestureExclusionTracker {
private boolean mGestureExclusionViewsChanged = false;
private boolean mRootGestureExclusionRectsChanged = false;
private List<Rect> mRootGestureExclusionRects = Collections.emptyList();
private List<GestureExclusionViewInfo> mGestureExclusionViewInfos = new ArrayList<>();
private List<Rect> mGestureExclusionRects = Collections.emptyList();
@@ -59,9 +63,9 @@ class GestureExclusionTracker {
@Nullable
public List<Rect> computeChangedRects() {
boolean changed = false;
boolean changed = mRootGestureExclusionRectsChanged;
final Iterator<GestureExclusionViewInfo> i = mGestureExclusionViewInfos.iterator();
final List<Rect> rects = new ArrayList<>();
final List<Rect> rects = new ArrayList<>(mRootGestureExclusionRects);
while (i.hasNext()) {
final GestureExclusionViewInfo info = i.next();
switch (info.update()) {
@@ -79,6 +83,7 @@ class GestureExclusionTracker {
}
if (changed || mGestureExclusionViewsChanged) {
mGestureExclusionViewsChanged = false;
mRootGestureExclusionRectsChanged = false;
if (!mGestureExclusionRects.equals(rects)) {
mGestureExclusionRects = rects;
return rects;
@@ -87,6 +92,17 @@ class GestureExclusionTracker {
return null;
}
public void setRootSystemGestureExclusionRects(@NonNull List<Rect> rects) {
Preconditions.checkNotNull(rects, "rects must not be null");
mRootGestureExclusionRects = rects;
mRootGestureExclusionRectsChanged = true;
}
@NonNull
public List<Rect> getRootSystemGestureExclusionRects() {
return mRootGestureExclusionRects;
}
private static class GestureExclusionViewInfo {
public static final int CHANGED = 0;
public static final int UNCHANGED = 1;

View File

@@ -3828,6 +3828,24 @@ public final class ViewRootImpl implements ViewParent,
}
}
/**
* Set the root-level system gesture exclusion rects. These are added to those provided by
* the root's view hierarchy.
*/
public void setRootSystemGestureExclusionRects(@NonNull List<Rect> rects) {
mGestureExclusionTracker.setRootSystemGestureExclusionRects(rects);
mHandler.sendEmptyMessage(MSG_SYSTEM_GESTURE_EXCLUSION_CHANGED);
}
/**
* Returns the root-level system gesture exclusion rects. These do not include those provided by
* the root's view hierarchy.
*/
@NonNull
public List<Rect> getRootSystemGestureExclusionRects() {
return mGestureExclusionTracker.getRootSystemGestureExclusionRects();
}
/**
* Requests that the root render node is invalidated next time we perform a draw, such that
* {@link WindowCallbacks#onPostDraw} gets called.

View File

@@ -48,6 +48,7 @@ import android.transition.Transition;
import android.transition.TransitionManager;
import android.view.accessibility.AccessibilityEvent;
import java.util.Collections;
import java.util.List;
/**
@@ -2397,6 +2398,53 @@ public abstract class Window {
return false;
}
/**
* Sets a list of areas within this window's coordinate space where the system should not
* intercept touch or other pointing device gestures.
*
* <p>This method should be used by apps that make use of
* {@link #takeSurface(SurfaceHolder.Callback2)} and do not have a view hierarchy available.
* Apps that do have a view hierarchy should use
* {@link View#setSystemGestureExclusionRects(List)} instead. This method does not modify or
* replace the gesture exclusion rects populated by individual views in this window's view
* hierarchy using {@link View#setSystemGestureExclusionRects(List)}.</p>
*
* <p>Use this to tell the system which specific sub-areas of a view need to receive gesture
* input in order to function correctly in the presence of global system gestures that may
* conflict. For example, if the system wishes to capture swipe-in-from-screen-edge gestures
* to provide system-level navigation functionality, a view such as a navigation drawer
* container can mark the left (or starting) edge of itself as requiring gesture capture
* priority using this API. The system may then choose to relax its own gesture recognition
* to allow the app to consume the user's gesture. It is not necessary for an app to register
* exclusion rects for broadly spanning regions such as the entirety of a
* <code>ScrollView</code> or for simple press and release click targets such as
* <code>Button</code>. Mark an exclusion rect when interacting with a view requires
* a precision touch gesture in a small area in either the X or Y dimension, such as
* an edge swipe or dragging a <code>SeekBar</code> thumb.</p>
*
* <p>Do not modify the provided list after this method is called.</p>
*
* @param rects A list of precision gesture regions that this window needs to function correctly
*/
@SuppressWarnings("unused")
public void setSystemGestureExclusionRects(@NonNull List<Rect> rects) {
throw new UnsupportedOperationException("window does not support gesture exclusion rects");
}
/**
* Retrieve the list of areas within this window's coordinate space where the system should not
* intercept touch or other pointing device gestures. This is the list as set by
* {@link #setSystemGestureExclusionRects(List)} or an empty list if
* {@link #setSystemGestureExclusionRects(List)} has not been called. It does not include
* exclusion rects set by this window's view hierarchy.
*
* @return a list of system gesture exclusion rects specific to this window
*/
@NonNull
public List<Rect> getSystemGestureExclusionRects() {
return Collections.emptyList();
}
/** @hide */
public void setTheme(int resId) {
}

View File

@@ -45,6 +45,7 @@ import android.content.res.Configuration;
import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.media.session.MediaController;
@@ -115,6 +116,7 @@ import com.android.internal.widget.SwipeDismissLayout;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
/**
* Android-specific Window.
@@ -3926,4 +3928,15 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
public WindowInsetsController getInsetsController() {
return mDecor.getWindowInsetsController();
}
@Override
public void setSystemGestureExclusionRects(@NonNull List<Rect> rects) {
getViewRootImpl().setRootSystemGestureExclusionRects(rects);
}
@Override
@NonNull
public List<Rect> getSystemGestureExclusionRects() {
return getViewRootImpl().getRootSystemGestureExclusionRects();
}
}