[Fix] prevent Talkback from reading out Bluetooth ImageView ContentDescription

- set View.IMPORTANT_FOR_ACCESSIBILITY_NO to ImageView

Bug: 128396030
Test: RunSettingsRoboTests
Change-Id: I267921057ede734a3c9be7087f34c96631e04859
This commit is contained in:
timpeng
2019-04-12 16:53:56 +08:00
committed by tim peng
parent 0ea58e740d
commit 0dde3a3b34

View File

@@ -29,6 +29,7 @@ import android.text.Html;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Pair; import android.util.Pair;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
@@ -170,6 +171,8 @@ public final class BluetoothDevicePreference extends GearPreference implements
final ImageView imageView = (ImageView) view.findViewById(android.R.id.icon); final ImageView imageView = (ImageView) view.findViewById(android.R.id.icon);
if (imageView != null) { if (imageView != null) {
imageView.setContentDescription(contentDescription); imageView.setContentDescription(contentDescription);
// Set property to prevent Talkback from reading out.
imageView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
imageView.setElevation( imageView.setElevation(
getContext().getResources().getDimension(R.dimen.bt_icon_elevation)); getContext().getResources().getDimension(R.dimen.bt_icon_elevation));
} }