Fix [a11y] Wi-Fi Easy Connect Talkback issues
1. Remove android:contentDescription from ButtonPreference layout file 'wifi_button_preference_widget.xml' because it should be a more general purpose component. Add ButtonPreference#setButtonContentDescription for this change. 2. Add a LinearLayout to group title & summary for better Talkback UX 3. Set android:contentDescription for Wi-Fi enrollee scan button 4. setTitle for Talkback actionbar back button of WifiDppQrCodeGeneratorFragment & WifiDppQrCodeScannerFragment 5. Auto trigger Talkback to speak title & summary in WifiDppAddDeviceFragment & WifiDppChooseSavedWifiNetworkFragment 6. Auto trigger Talkback to speak summary change in WifiDppAddDeviceFragment 7. Auto trigger Talkback to speak error message in WifiDppQrCodeScannerFragment Bug: 126007405 Bug: 124424996 Bug: 124424445 Test: manual test Change-Id: I54a3f033bb8871c47be12115ae8f97691fd83302
This commit is contained in:
@@ -49,6 +49,7 @@ public class ButtonPreference extends Preference {
|
||||
private ImageButton mImageButton;
|
||||
private Drawable mButtonIcon;
|
||||
private View.OnClickListener mClickListener;
|
||||
private String mContentDescription;
|
||||
|
||||
// Used for dummy pref.
|
||||
public ButtonPreference(Context context, AttributeSet attrs) {
|
||||
@@ -57,6 +58,7 @@ public class ButtonPreference extends Preference {
|
||||
mImageButton = null;
|
||||
mButtonIcon = null;
|
||||
mClickListener = null;
|
||||
mContentDescription = null;
|
||||
}
|
||||
|
||||
public ButtonPreference(Context context) {
|
||||
@@ -83,6 +85,7 @@ public class ButtonPreference extends Preference {
|
||||
if (mImageButton != null) {
|
||||
mImageButton.setImageDrawable(mButtonIcon);
|
||||
mImageButton.setOnClickListener(mClickListener);
|
||||
mImageButton.setContentDescription(mContentDescription);
|
||||
}
|
||||
setButtonVisibility();
|
||||
}
|
||||
@@ -96,9 +99,9 @@ public class ButtonPreference extends Preference {
|
||||
/**
|
||||
* Sets the drawable to be displayed in button.
|
||||
*/
|
||||
public ButtonPreference setButtonIcon(@DrawableRes int iconResId) {
|
||||
public void setButtonIcon(@DrawableRes int iconResId) {
|
||||
if (iconResId == 0) {
|
||||
return this;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -107,17 +110,26 @@ public class ButtonPreference extends Preference {
|
||||
} catch (Resources.NotFoundException exception) {
|
||||
Log.e(TAG, "Resource does not exist: " + iconResId);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback to be invoked when button is clicked.
|
||||
*/
|
||||
public ButtonPreference setButtonOnClickListener(View.OnClickListener listener) {
|
||||
public void setButtonOnClickListener(View.OnClickListener listener) {
|
||||
if (listener != mClickListener) {
|
||||
mClickListener = listener;
|
||||
notifyChanged();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A content description briefly describes the button and is primarily used for accessibility
|
||||
* support to determine how a button should be presented to the user.
|
||||
*/
|
||||
public void setButtonContentDescription(String contentDescription) {
|
||||
if (contentDescription != mContentDescription) {
|
||||
mContentDescription = contentDescription;
|
||||
notifyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user