Merge "Use event text for partial accessibility state change in quicksettings"
This commit is contained in:
@@ -605,7 +605,10 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
|
||||
/**
|
||||
* Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event:
|
||||
* state description of the node as returned by
|
||||
* {@link AccessibilityNodeInfo#getStateDescription} changed.
|
||||
* {@link AccessibilityNodeInfo#getStateDescription} changed. If part of the state description
|
||||
* changes, the changed part can be put into event text. For example, if state description
|
||||
* changed from "on, wifi signal full" to "on, wifi three bars", "wifi three bars" can be put
|
||||
* into the event text.
|
||||
*/
|
||||
public static final int CONTENT_CHANGE_TYPE_STATE_DESCRIPTION = 0x00000040;
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
*/
|
||||
package com.android.systemui.qs.tileimpl;
|
||||
|
||||
import static android.view.accessibility.AccessibilityEvent.CONTENT_CHANGE_TYPE_STATE_DESCRIPTION;
|
||||
|
||||
import static com.android.systemui.qs.tileimpl.QSIconViewImpl.QS_ANIM_LENGTH;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
@@ -73,6 +75,10 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
|
||||
private int mCircleColor;
|
||||
private int mBgSize;
|
||||
|
||||
private static final int INVALID = -1;
|
||||
private CharSequence mStateDescriptionDeltas = null;
|
||||
private CharSequence mLastStateDescription;
|
||||
private int mLastState = INVALID;
|
||||
|
||||
public QSTileBaseView(Context context, QSIconView icon) {
|
||||
this(context, icon, false);
|
||||
@@ -250,8 +256,14 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
|
||||
if (!TextUtils.isEmpty(state.stateDescription)) {
|
||||
stateDescription.append(", ");
|
||||
stateDescription.append(state.stateDescription);
|
||||
if (mLastState != INVALID && state.state == mLastState
|
||||
&& !state.stateDescription.equals(mLastStateDescription)) {
|
||||
mStateDescriptionDeltas = state.stateDescription;
|
||||
}
|
||||
}
|
||||
setStateDescription(stateDescription.toString());
|
||||
mLastState = state.state;
|
||||
mLastStateDescription = state.stateDescription;
|
||||
|
||||
mAccessibilityClass =
|
||||
state.state == Tile.STATE_UNAVAILABLE ? null : state.expandedAccessibilityClassName;
|
||||
@@ -314,6 +326,11 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
|
||||
if (!TextUtils.isEmpty(mAccessibilityClass)) {
|
||||
event.setClassName(mAccessibilityClass);
|
||||
}
|
||||
if (event.getContentChangeTypes() == CONTENT_CHANGE_TYPE_STATE_DESCRIPTION
|
||||
&& mStateDescriptionDeltas != null) {
|
||||
event.getText().add(mStateDescriptionDeltas);
|
||||
mStateDescriptionDeltas = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -130,7 +130,8 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {
|
||||
state.label = mContext.getString(R.string.quick_settings_bluetooth_label);
|
||||
state.secondaryLabel = TextUtils.emptyIfNull(
|
||||
getSecondaryLabel(enabled, connecting, connected, state.isTransient));
|
||||
state.contentDescription = state.label;
|
||||
state.contentDescription = mContext.getString(
|
||||
R.string.accessibility_quick_settings_bluetooth);
|
||||
state.stateDescription = "";
|
||||
if (enabled) {
|
||||
if (connected) {
|
||||
@@ -148,15 +149,11 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {
|
||||
} else {
|
||||
state.icon =
|
||||
ResourceIcon.get(com.android.internal.R.drawable.ic_qs_bluetooth);
|
||||
state.contentDescription = mContext.getString(
|
||||
R.string.accessibility_quick_settings_bluetooth);
|
||||
state.stateDescription = mContext.getString(R.string.accessibility_not_connected);
|
||||
}
|
||||
state.state = Tile.STATE_ACTIVE;
|
||||
} else {
|
||||
state.icon = ResourceIcon.get(com.android.internal.R.drawable.ic_qs_bluetooth);
|
||||
state.contentDescription = mContext.getString(
|
||||
R.string.accessibility_quick_settings_bluetooth);
|
||||
state.state = Tile.STATE_INACTIVE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user