Merge "Add View.findOnBackInvokedDispatcher" into tm-dev
This commit is contained in:
@@ -49645,6 +49645,7 @@ package android.view {
|
||||
method @CallSuper public void drawableHotspotChanged(float, float);
|
||||
method @CallSuper protected void drawableStateChanged();
|
||||
method public android.view.View findFocus();
|
||||
method @Nullable public final android.window.OnBackInvokedDispatcher findOnBackInvokedDispatcher();
|
||||
method public final <T extends android.view.View> T findViewById(@IdRes int);
|
||||
method public final <T extends android.view.View> T findViewWithTag(Object);
|
||||
method public void findViewsWithText(java.util.ArrayList<android.view.View>, CharSequence, int);
|
||||
@@ -50822,6 +50823,7 @@ package android.view {
|
||||
method public void childHasTransientStateChanged(@NonNull android.view.View, boolean);
|
||||
method public void clearChildFocus(android.view.View);
|
||||
method public void createContextMenu(android.view.ContextMenu);
|
||||
method @Nullable public default android.window.OnBackInvokedDispatcher findOnBackInvokedDispatcherForChild(@NonNull android.view.View, @NonNull android.view.View);
|
||||
method public android.view.View focusSearch(android.view.View, int);
|
||||
method public void focusableViewAvailable(android.view.View);
|
||||
method public boolean getChildVisibleRect(android.view.View, android.graphics.Rect, android.graphics.Point);
|
||||
|
||||
@@ -162,6 +162,7 @@ import android.view.translation.ViewTranslationResponse;
|
||||
import android.widget.Checkable;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ScrollBarDrawable;
|
||||
import android.window.OnBackInvokedDispatcher;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
@@ -12098,6 +12099,23 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Walk up the View hierarchy to find the nearest {@link OnBackInvokedDispatcher}.
|
||||
*
|
||||
* @return The {@link OnBackInvokedDispatcher} from this or the nearest
|
||||
* ancestor, or null if this view is both not attached and have no ancestor providing an
|
||||
* {@link OnBackInvokedDispatcher}.
|
||||
*/
|
||||
@Nullable
|
||||
public final OnBackInvokedDispatcher findOnBackInvokedDispatcher() {
|
||||
ViewParent parent = getParent();
|
||||
if (parent != null) {
|
||||
return parent.findOnBackInvokedDispatcherForChild(this, this);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide Compute the insets that should be consumed by this view and the ones
|
||||
* that should propagate to those under it.
|
||||
|
||||
@@ -72,6 +72,7 @@ import android.view.inspector.InspectableProperty.EnumEntry;
|
||||
import android.view.translation.TranslationCapability;
|
||||
import android.view.translation.TranslationSpec.DataFormat;
|
||||
import android.view.translation.ViewTranslationRequest;
|
||||
import android.window.OnBackInvokedDispatcher;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
@@ -9296,4 +9297,25 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
|
||||
requests);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Walk up the View hierarchy to find the nearest {@link OnBackInvokedDispatcher}.
|
||||
*
|
||||
* @return The {@link OnBackInvokedDispatcher} from this or the nearest
|
||||
* ancestor, or null if the view is both not attached and have no ancestor providing an
|
||||
* {@link OnBackInvokedDispatcher}.
|
||||
*
|
||||
* @param child The direct child of this view for which to find a dispatcher.
|
||||
* @param requester The requester that will use the dispatcher. Can be the same as child.
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public OnBackInvokedDispatcher findOnBackInvokedDispatcherForChild(@NonNull View child,
|
||||
@NonNull View requester) {
|
||||
ViewParent parent = getParent();
|
||||
if (parent != null) {
|
||||
return parent.findOnBackInvokedDispatcherForChild(this, requester);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.os.Bundle;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.window.OnBackInvokedDispatcher;
|
||||
|
||||
/**
|
||||
* Defines the responsibilities for a class that will be a parent of a View.
|
||||
@@ -697,4 +698,20 @@ public interface ViewParent {
|
||||
getParent().onDescendantUnbufferedRequested();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Walk up the View hierarchy to find the nearest {@link OnBackInvokedDispatcher}.
|
||||
*
|
||||
* @return The {@link OnBackInvokedDispatcher} from this or the nearest
|
||||
* ancestor, or null if the view is both not attached and have no ancestor providing an
|
||||
* {@link OnBackInvokedDispatcher}.
|
||||
*
|
||||
* @param child The direct child of this view for which to find a dispatcher.
|
||||
* @param requester The requester that will use the dispatcher. Can be the same as child.
|
||||
*/
|
||||
@Nullable
|
||||
default OnBackInvokedDispatcher findOnBackInvokedDispatcherForChild(@NonNull View child,
|
||||
@NonNull View requester) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10736,6 +10736,13 @@ public final class ViewRootImpl implements ViewParent,
|
||||
return mOnBackInvokedDispatcher;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public OnBackInvokedDispatcher findOnBackInvokedDispatcherForChild(
|
||||
@NonNull View child, @NonNull View requester) {
|
||||
return getOnBackInvokedDispatcher();
|
||||
}
|
||||
|
||||
/**
|
||||
* When this ViewRootImpl is added to the window manager, transfers the first
|
||||
* {@link OnBackInvokedCallback} to be called to the server.
|
||||
|
||||
Reference in New Issue
Block a user