Updating accessibility content for buttons in SysUI for captions
Bug:129923766 Test: manual Change-Id: Icf78a20d8b2b967082e815de95c3421ed865be22
This commit is contained in:
@@ -1331,6 +1331,14 @@
|
||||
<!-- Content description for accessibility: Clear the odi caption tool tip. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_volume_close_odi_captions_tip">Close captions tip</string>
|
||||
|
||||
<!-- Content description for accessibility: Captions button. [CHAR LIMIT=NONE] -->
|
||||
<string name="volume_odi_captions_content_description">Captions overlay</string>
|
||||
|
||||
<!-- Content description for accessibility: Hint if click will enable. [CHAR LIMIT=NONE] -->
|
||||
<string name="volume_odi_captions_hint_enable">enable</string>
|
||||
<!-- Content description for accessibility: Hint if click will disable. [CHAR LIMIT=NONE] -->
|
||||
<string name="volume_odi_captions_hint_disable">disable</string>
|
||||
|
||||
<!-- content description for audio output chooser [CHAR LIMIT=NONE]-->
|
||||
<string name="accessibility_output_chooser">Switch output device</string>
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@ import android.util.AttributeSet;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat;
|
||||
|
||||
import com.android.keyguard.AlphaOptimizedImageButton;
|
||||
import com.android.systemui.R;
|
||||
|
||||
@@ -31,7 +34,7 @@ public class CaptionsToggleImageButton extends AlphaOptimizedImageButton {
|
||||
private static final int[] OPTED_OUT_STATE = new int[] { R.attr.optedOut };
|
||||
|
||||
private ConfirmedTapListener mConfirmedTapListener;
|
||||
private boolean mComponentEnabled = false;
|
||||
private boolean mCaptionsEnabled = false;
|
||||
private boolean mOptedOut = false;
|
||||
|
||||
private GestureDetector mGestureDetector;
|
||||
@@ -39,16 +42,14 @@ public class CaptionsToggleImageButton extends AlphaOptimizedImageButton {
|
||||
new GestureDetector.SimpleOnGestureListener() {
|
||||
@Override
|
||||
public boolean onSingleTapConfirmed(MotionEvent e) {
|
||||
if (mConfirmedTapListener != null) {
|
||||
mConfirmedTapListener.onConfirmedTap();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return tryToSendTapConfirmedEvent();
|
||||
}
|
||||
};
|
||||
|
||||
public CaptionsToggleImageButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
this.setContentDescription(
|
||||
getContext().getString(R.string.volume_odi_captions_content_description));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,16 +67,32 @@ public class CaptionsToggleImageButton extends AlphaOptimizedImageButton {
|
||||
return state;
|
||||
}
|
||||
|
||||
Runnable setComponentEnabled(boolean isComponentEnabled) {
|
||||
this.mComponentEnabled = isComponentEnabled;
|
||||
Runnable setCaptionsEnabled(boolean areCaptionsEnabled) {
|
||||
this.mCaptionsEnabled = areCaptionsEnabled;
|
||||
|
||||
return this.setImageResourceAsync(this.mComponentEnabled
|
||||
ViewCompat.replaceAccessibilityAction(
|
||||
this,
|
||||
AccessibilityActionCompat.ACTION_CLICK,
|
||||
mCaptionsEnabled
|
||||
? getContext().getString(R.string.volume_odi_captions_hint_disable)
|
||||
: getContext().getString(R.string.volume_odi_captions_hint_enable),
|
||||
(view, commandArguments) -> tryToSendTapConfirmedEvent());
|
||||
|
||||
return this.setImageResourceAsync(mCaptionsEnabled
|
||||
? R.drawable.ic_volume_odi_captions
|
||||
: R.drawable.ic_volume_odi_captions_disabled);
|
||||
}
|
||||
|
||||
boolean getComponentEnabled() {
|
||||
return this.mComponentEnabled;
|
||||
private boolean tryToSendTapConfirmedEvent() {
|
||||
if (mConfirmedTapListener != null) {
|
||||
mConfirmedTapListener.onConfirmedTap();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean getCaptionsEnabled() {
|
||||
return this.mCaptionsEnabled;
|
||||
}
|
||||
|
||||
/** Sets whether or not the current stream has opted out of captions */
|
||||
|
||||
@@ -596,9 +596,9 @@ public class VolumeDialogImpl implements VolumeDialog,
|
||||
}
|
||||
|
||||
private void updateCaptionsIcon() {
|
||||
boolean componentEnabled = mController.areCaptionsEnabled();
|
||||
if (mODICaptionsIcon.getComponentEnabled() != componentEnabled) {
|
||||
mHandler.post(mODICaptionsIcon.setComponentEnabled(componentEnabled));
|
||||
boolean captionsEnabled = mController.areCaptionsEnabled();
|
||||
if (mODICaptionsIcon.getCaptionsEnabled() != captionsEnabled) {
|
||||
mHandler.post(mODICaptionsIcon.setCaptionsEnabled(captionsEnabled));
|
||||
}
|
||||
|
||||
boolean isOptedOut = mController.isCaptionStreamOptedOut();
|
||||
@@ -878,7 +878,6 @@ public class VolumeDialogImpl implements VolumeDialog,
|
||||
}
|
||||
|
||||
view.setContentDescription(mContext.getString(currStateResId));
|
||||
|
||||
view.setAccessibilityDelegate(new AccessibilityDelegate() {
|
||||
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
|
||||
super.onInitializeAccessibilityNodeInfo(host, info);
|
||||
|
||||
Reference in New Issue
Block a user