diff options
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/view/WindowInfo.java | 12 | ||||
| -rw-r--r-- | core/java/android/view/WindowManager.java | 17 | ||||
| -rw-r--r-- | core/java/android/view/accessibility/AccessibilityWindowInfo.java | 62 | ||||
| -rw-r--r-- | core/java/android/widget/PopupWindow.java | 8 |
4 files changed, 96 insertions, 3 deletions
diff --git a/core/java/android/view/WindowInfo.java b/core/java/android/view/WindowInfo.java index b72107447541..737e46071313 100644 --- a/core/java/android/view/WindowInfo.java +++ b/core/java/android/view/WindowInfo.java @@ -44,6 +44,8 @@ public class WindowInfo implements Parcelable { public boolean focused; public final Rect boundsInScreen = new Rect(); public List<IBinder> childTokens; + public CharSequence title; + public int accessibilityIdOfAnchor = View.NO_ID; private WindowInfo() { /* do nothing - hide constructor */ @@ -65,6 +67,8 @@ public class WindowInfo implements Parcelable { window.parentToken = other.parentToken; window.focused = other.focused; window.boundsInScreen.set(other.boundsInScreen); + window.title = other.title; + window.accessibilityIdOfAnchor = other.accessibilityIdOfAnchor; if (other.childTokens != null && !other.childTokens.isEmpty()) { if (window.childTokens == null) { @@ -95,6 +99,8 @@ public class WindowInfo implements Parcelable { parcel.writeStrongBinder(parentToken); parcel.writeInt(focused ? 1 : 0); boundsInScreen.writeToParcel(parcel, flags); + parcel.writeCharSequence(title); + parcel.writeInt(accessibilityIdOfAnchor); if (childTokens != null && !childTokens.isEmpty()) { parcel.writeInt(1); @@ -108,13 +114,15 @@ public class WindowInfo implements Parcelable { public String toString() { StringBuilder builder = new StringBuilder(); builder.append("WindowInfo["); - builder.append("type=").append(type); + builder.append("title=").append(title); + builder.append(", type=").append(type); builder.append(", layer=").append(layer); builder.append(", token=").append(token); builder.append(", bounds=").append(boundsInScreen); builder.append(", parent=").append(parentToken); builder.append(", focused=").append(focused); builder.append(", children=").append(childTokens); + builder.append(", accessibility anchor=").append(accessibilityIdOfAnchor); builder.append(']'); return builder.toString(); } @@ -126,6 +134,8 @@ public class WindowInfo implements Parcelable { parentToken = parcel.readStrongBinder(); focused = (parcel.readInt() == 1); boundsInScreen.readFromParcel(parcel); + title = parcel.readCharSequence(); + accessibilityIdOfAnchor = parcel.readInt(); final boolean hasChildren = (parcel.readInt() == 1); if (hasChildren) { diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 03dcf99258ab..c372c30915f2 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -1693,6 +1693,14 @@ public interface WindowManager extends ViewManager { */ public long userActivityTimeout = -1; + /** + * For windows with an anchor (e.g. PopupWindow), keeps track of the View that anchors the + * window. + * + * @hide + */ + public int accessibilityIdOfAnchor = -1; + public LayoutParams() { super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); type = TYPE_APPLICATION; @@ -1799,6 +1807,7 @@ public interface WindowManager extends ViewManager { out.writeInt(surfaceInsets.bottom); out.writeInt(hasManualSurfaceInsets ? 1 : 0); out.writeInt(needsMenuKey); + out.writeInt(accessibilityIdOfAnchor); } public static final Parcelable.Creator<LayoutParams> CREATOR @@ -1849,6 +1858,7 @@ public interface WindowManager extends ViewManager { surfaceInsets.bottom = in.readInt(); hasManualSurfaceInsets = in.readInt() != 0; needsMenuKey = in.readInt(); + accessibilityIdOfAnchor = in.readInt(); } @SuppressWarnings({"PointlessBitwiseExpression"}) @@ -1888,6 +1898,8 @@ public interface WindowManager extends ViewManager { /** {@hide} */ public static final int PREFERRED_DISPLAY_MODE_ID = 1 << 23; /** {@hide} */ + public static final int ACCESSIBILITY_ANCHOR_CHANGED = 1 << 24; + /** {@hide} */ public static final int EVERYTHING_CHANGED = 0xffffffff; // internal buffer to backup/restore parameters under compatibility mode. @@ -2048,6 +2060,11 @@ public interface WindowManager extends ViewManager { changes |= NEEDS_MENU_KEY_CHANGED; } + if (accessibilityIdOfAnchor != o.accessibilityIdOfAnchor) { + accessibilityIdOfAnchor = o.accessibilityIdOfAnchor; + changes |= ACCESSIBILITY_ANCHOR_CHANGED; + } + return changes; } diff --git a/core/java/android/view/accessibility/AccessibilityWindowInfo.java b/core/java/android/view/accessibility/AccessibilityWindowInfo.java index ad78b686b8de..d0d4507e7b62 100644 --- a/core/java/android/view/accessibility/AccessibilityWindowInfo.java +++ b/core/java/android/view/accessibility/AccessibilityWindowInfo.java @@ -89,6 +89,8 @@ public final class AccessibilityWindowInfo implements Parcelable { private int mParentId = UNDEFINED; private final Rect mBoundsInScreen = new Rect(); private LongArray mChildIds; + private CharSequence mTitle; + private int mAnchorId = UNDEFINED; private int mConnectionId = UNDEFINED; @@ -97,6 +99,26 @@ public final class AccessibilityWindowInfo implements Parcelable { } /** + * Gets the title of the window. + * + * @return The title. + */ + public CharSequence getTitle() { + return mTitle; + } + + /** + * Sets the title of the window. + * + * @param title The title. + * + * @hide + */ + public void setTitle(CharSequence title) { + mTitle = title; + } + + /** * Gets the type of the window. * * @return The type. @@ -159,9 +181,35 @@ public final class AccessibilityWindowInfo implements Parcelable { } /** - * Gets the parent window if such. + * Sets the anchor node's ID. + * + * @param anchorId The anchor's accessibility id in its window. + * + * @hide + */ + public void setAnchorId(int anchorId) { + mAnchorId = anchorId; + } + + /** + * Gets the node that anchors this window to another. + * + * @return The anchor node, or {@code null} if none exists. + */ + public AccessibilityNodeInfo getAnchor() { + if ((mConnectionId == UNDEFINED) || (mAnchorId == UNDEFINED) || (mParentId == UNDEFINED)) { + return null; + } + + AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance(); + return client.findAccessibilityNodeInfoByAccessibilityId(mConnectionId, + mParentId, mAnchorId, true, 0); + } + + /** + * Gets the parent window. * - * @return The parent window. + * @return The parent window, or {@code null} if none exists. */ public AccessibilityWindowInfo getParent() { if (mConnectionId == UNDEFINED || mParentId == UNDEFINED) { @@ -370,6 +418,8 @@ public final class AccessibilityWindowInfo implements Parcelable { infoClone.mId = info.mId; infoClone.mParentId = info.mParentId; infoClone.mBoundsInScreen.set(info.mBoundsInScreen); + infoClone.mTitle = info.mTitle; + infoClone.mAnchorId = info.mAnchorId; if (info.mChildIds != null && info.mChildIds.size() > 0) { if (infoClone.mChildIds == null) { @@ -410,6 +460,8 @@ public final class AccessibilityWindowInfo implements Parcelable { parcel.writeInt(mId); parcel.writeInt(mParentId); mBoundsInScreen.writeToParcel(parcel, flags); + parcel.writeCharSequence(mTitle); + parcel.writeInt(mAnchorId); final LongArray childIds = mChildIds; if (childIds == null) { @@ -432,6 +484,8 @@ public final class AccessibilityWindowInfo implements Parcelable { mId = parcel.readInt(); mParentId = parcel.readInt(); mBoundsInScreen.readFromParcel(parcel); + mTitle = parcel.readCharSequence(); + mAnchorId = parcel.readInt(); final int childCount = parcel.readInt(); if (childCount > 0) { @@ -471,6 +525,7 @@ public final class AccessibilityWindowInfo implements Parcelable { public String toString() { StringBuilder builder = new StringBuilder(); builder.append("AccessibilityWindowInfo["); + builder.append("title=").append(mTitle); builder.append("id=").append(mId); builder.append(", type=").append(typeToString(mType)); builder.append(", layer=").append(mLayer); @@ -494,6 +549,7 @@ public final class AccessibilityWindowInfo implements Parcelable { builder.append(']'); } else { builder.append(", hasParent=").append(mParentId != UNDEFINED); + builder.append(", isAnchored=").append(mAnchorId != UNDEFINED); builder.append(", hasChildren=").append(mChildIds != null && mChildIds.size() > 0); } @@ -515,6 +571,8 @@ public final class AccessibilityWindowInfo implements Parcelable { mChildIds.clear(); } mConnectionId = UNDEFINED; + mAnchorId = UNDEFINED; + mTitle = null; } /** diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java index 18687c975432..9cdbc6c3e3fd 100644 --- a/core/java/android/widget/PopupWindow.java +++ b/core/java/android/widget/PopupWindow.java @@ -1217,6 +1217,7 @@ public class PopupWindow { final boolean aboveAnchor = findDropDownPosition(anchor, p, xoff, yoff, p.width, p.height, gravity); updateAboveAnchor(aboveAnchor); + p.accessibilityIdOfAnchor = (anchor != null) ? anchor.getAccessibilityViewId() : -1; invokePopup(p); } @@ -1989,6 +1990,13 @@ public class PopupWindow { update = true; } + int newAccessibilityIdOfAnchor = + (mAnchor != null) ? mAnchor.get().getAccessibilityViewId() : -1; + if (newAccessibilityIdOfAnchor != p.accessibilityIdOfAnchor) { + p.accessibilityIdOfAnchor = newAccessibilityIdOfAnchor; + update = true; + } + if (update) { setLayoutDirectionFromAnchor(); mWindowManager.updateViewLayout(mDecorView, p); |
