From: pkanwar Date: Sat, 30 Apr 2016 00:43:24 +0000 (-0700) Subject: The "device type" icons in "Bluetooth device list" screen are X-Git-Tag: android-x86-7.1-r1~456^2~140 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=8fa3d44;p=android-x86%2Fpackages-apps-Settings.git The "device type" icons in "Bluetooth device list" screen are not accessible to TalkBack users. b/28199679 Changed method to for setting the talk-back attribute on "device type". Change-Id: I63820d861ea1075195b98c82004ba95470448a53 --- diff --git a/res/values/strings.xml b/res/values/strings.xml index ea4da30658..51c54c9be0 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -7473,4 +7473,24 @@ Allow contact searches by your organization to identify callers and contacts + + Computer + + + Headset + + + Phone + + + Imaging + + + Headphone + + + Input Peripheral + + + Bluetooth diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java index 6d95351976..a45e7b40a5 100644 --- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java +++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java @@ -21,12 +21,14 @@ import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; import android.content.Context; import android.content.DialogInterface; +import android.content.res.Resources; import android.os.UserManager; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceViewHolder; import android.text.Html; import android.text.TextUtils; import android.util.Log; +import android.util.Pair; import android.util.TypedValue; import android.view.View; import android.view.View.OnClickListener; @@ -59,6 +61,19 @@ public final class BluetoothDevicePreference extends Preference implements private AlertDialog mDisconnectDialog; + private String contentDescription = null; + + /* Talk-back descriptions for various BT icons */ + Resources r = getContext().getResources(); + public final String COMPUTER = r.getString(R.string.bluetooth_talkback_computer); + public final String INPUT_PERIPHERAL = r.getString( + R.string.bluetooth_talkback_input_peripheral); + public final String HEADSET = r.getString(R.string.bluetooth_talkback_headset); + public final String PHONE = r.getString(R.string.bluetooth_talkback_phone); + public final String IMAGING = r.getString(R.string.bluetooth_talkback_imaging); + public final String HEADPHONE = r.getString(R.string.bluetooth_talkback_headphone); + public final String BLUETOOTH = r.getString(R.string.bluetooth_talkback_bluetooth); + public BluetoothDevicePreference(Context context, CachedBluetoothDevice cachedDevice) { super(context); @@ -121,9 +136,11 @@ public final class BluetoothDevicePreference extends Preference implements setSummary(null); // empty summary for unpaired devices } - int iconResId = getBtClassDrawable(); - if (iconResId != 0) { - setIcon(iconResId); + + Pair pair = getBtClassDrawableWithDescription(); + if (pair.first != 0) { + setIcon(pair.first); + contentDescription = pair.second; } // Used to gray out the item @@ -148,7 +165,10 @@ public final class BluetoothDevicePreference extends Preference implements deviceDetails.setTag(mCachedDevice); } } - + final ImageView imageView = (ImageView) view.findViewById(android.R.id.icon); + if (imageView != null) { + imageView.setContentDescription(contentDescription); + } super.onBindViewHolder(view); } @@ -234,21 +254,22 @@ public final class BluetoothDevicePreference extends Preference implements } } - private int getBtClassDrawable() { + private Pair getBtClassDrawableWithDescription() { BluetoothClass btClass = mCachedDevice.getBtClass(); if (btClass != null) { switch (btClass.getMajorDeviceClass()) { case BluetoothClass.Device.Major.COMPUTER: - return R.drawable.ic_bt_laptop; + return new Pair(R.drawable.ic_bt_laptop, COMPUTER); case BluetoothClass.Device.Major.PHONE: - return R.drawable.ic_bt_cellphone; + return new Pair(R.drawable.ic_bt_cellphone, PHONE); case BluetoothClass.Device.Major.PERIPHERAL: - return HidProfile.getHidClassDrawable(btClass); + return new Pair(HidProfile.getHidClassDrawable(btClass), + INPUT_PERIPHERAL); case BluetoothClass.Device.Major.IMAGING: - return R.drawable.ic_bt_imaging; + return new Pair(R.drawable.ic_bt_imaging, IMAGING); default: // unrecognized device class; continue @@ -261,18 +282,17 @@ public final class BluetoothDevicePreference extends Preference implements for (LocalBluetoothProfile profile : profiles) { int resId = profile.getDrawableResource(btClass); if (resId != 0) { - return resId; + return new Pair(resId, null); } } if (btClass != null) { if (btClass.doesClassMatch(BluetoothClass.PROFILE_A2DP)) { - return R.drawable.ic_bt_headphones_a2dp; - + return new Pair(R.drawable.ic_bt_headphones_a2dp, HEADPHONE); } if (btClass.doesClassMatch(BluetoothClass.PROFILE_HEADSET)) { - return R.drawable.ic_bt_headset_hfp; + return new Pair(R.drawable.ic_bt_headset_hfp, HEADSET); } } - return R.drawable.ic_settings_bluetooth; + return new Pair(R.drawable.ic_settings_bluetooth, BLUETOOTH); } }