Merge "Improve accessibility window title behavior" into nyc-dev
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package android.view.accessibility;
|
package android.view.accessibility;
|
||||||
|
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
@@ -101,8 +102,9 @@ public final class AccessibilityWindowInfo implements Parcelable {
|
|||||||
/**
|
/**
|
||||||
* Gets the title of the window.
|
* Gets the title of the window.
|
||||||
*
|
*
|
||||||
* @return The title.
|
* @return The title of the window, or {@code null} if none is available.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public CharSequence getTitle() {
|
public CharSequence getTitle() {
|
||||||
return mTitle;
|
return mTitle;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -521,16 +521,22 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTitle(CharSequence title) {
|
public void setTitle(CharSequence title) {
|
||||||
|
setTitle(title, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(CharSequence title, boolean updateAccessibilityTitle) {
|
||||||
if (mTitleView != null) {
|
if (mTitleView != null) {
|
||||||
mTitleView.setText(title);
|
mTitleView.setText(title);
|
||||||
} else if (mDecorContentParent != null) {
|
} else if (mDecorContentParent != null) {
|
||||||
mDecorContentParent.setWindowTitle(title);
|
mDecorContentParent.setWindowTitle(title);
|
||||||
}
|
}
|
||||||
mTitle = title;
|
mTitle = title;
|
||||||
WindowManager.LayoutParams params = getAttributes();
|
if (updateAccessibilityTitle) {
|
||||||
if (!TextUtils.equals(title, params.accessibilityTitle)) {
|
WindowManager.LayoutParams params = getAttributes();
|
||||||
params.accessibilityTitle = TextUtils.stringOrSpannedString(title);
|
if (!TextUtils.equals(title, params.accessibilityTitle)) {
|
||||||
dispatchWindowAttributesChanged(getAttributes());
|
params.accessibilityTitle = TextUtils.stringOrSpannedString(title);
|
||||||
|
dispatchWindowAttributesChanged(getAttributes());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2589,8 +2589,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
final PhoneWindow win = new PhoneWindow(context);
|
final PhoneWindow win = new PhoneWindow(context);
|
||||||
win.setIsStartingWindow(true);
|
win.setIsStartingWindow(true);
|
||||||
|
|
||||||
|
final WindowManager.LayoutParams params = win.getAttributes();
|
||||||
final Resources r = context.getResources();
|
final Resources r = context.getResources();
|
||||||
win.setTitle(r.getText(labelRes, nonLocalizedLabel));
|
CharSequence label = r.getText(labelRes);
|
||||||
|
// Only change the accessibility title if the label is localized
|
||||||
|
if (label != null) {
|
||||||
|
win.setTitle(label, true);
|
||||||
|
} else {
|
||||||
|
win.setTitle(nonLocalizedLabel, false);
|
||||||
|
}
|
||||||
|
|
||||||
win.setType(
|
win.setType(
|
||||||
WindowManager.LayoutParams.TYPE_APPLICATION_STARTING);
|
WindowManager.LayoutParams.TYPE_APPLICATION_STARTING);
|
||||||
@@ -2624,7 +2631,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
win.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
|
win.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
|
||||||
WindowManager.LayoutParams.MATCH_PARENT);
|
WindowManager.LayoutParams.MATCH_PARENT);
|
||||||
|
|
||||||
final WindowManager.LayoutParams params = win.getAttributes();
|
|
||||||
params.token = appToken;
|
params.token = appToken;
|
||||||
params.packageName = packageName;
|
params.packageName = packageName;
|
||||||
params.windowAnimations = win.getWindowStyle().getResourceId(
|
params.windowAnimations = win.getWindowStyle().getResourceId(
|
||||||
|
|||||||
@@ -1203,9 +1203,6 @@ final class AccessibilityController {
|
|||||||
window.layer = windowState.mLayer;
|
window.layer = windowState.mLayer;
|
||||||
window.token = windowState.mClient.asBinder();
|
window.token = windowState.mClient.asBinder();
|
||||||
window.title = windowState.mAttrs.accessibilityTitle;
|
window.title = windowState.mAttrs.accessibilityTitle;
|
||||||
if (window.title == null) {
|
|
||||||
window.title = windowState.mAttrs.getTitle();
|
|
||||||
}
|
|
||||||
window.accessibilityIdOfAnchor = windowState.mAttrs.accessibilityIdOfAnchor;
|
window.accessibilityIdOfAnchor = windowState.mAttrs.accessibilityIdOfAnchor;
|
||||||
|
|
||||||
WindowState attachedWindow = windowState.mAttachedWindow;
|
WindowState attachedWindow = windowState.mAttachedWindow;
|
||||||
|
|||||||
Reference in New Issue
Block a user