Use raw string when setting wifi preference title.

This is necessary for talkback to correctly recognize content
description on the whole viewgroup.

Merged-In: Ic792102b269b9a8db09c632f7e70d8773048c840
Change-Id: I555f94afcd6f4c681bb16dd23d94b2ae0fd4c116
Fixes: 65202862
Test: robotests
This commit is contained in:
Fan Zhang
2017-09-05 11:02:03 -07:00
parent 6f8afdc501
commit 70efb670c8
2 changed files with 27 additions and 7 deletions

View File

@@ -160,7 +160,7 @@ public class AccessPointPreference extends Preference {
drawable.setLevel(mLevel);
}
mTitleView = (TextView) view.findViewById(com.android.internal.R.id.title);
mTitleView = (TextView) view.findViewById(android.R.id.title);
if (mTitleView != null) {
// Attach to the end of the title view
mTitleView.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, mBadge, null);
@@ -231,12 +231,7 @@ public class AccessPointPreference extends Preference {
* Updates the title and summary; may indirectly call notifyChanged().
*/
public void refresh() {
if (mForSavedNetworks) {
setTitle(mAccessPoint.getConfigName());
} else {
setTitle(mAccessPoint.getSsid());
}
setTitle(this, mAccessPoint, mForSavedNetworks);
final Context context = getContext();
int level = mAccessPoint.getLevel();
int wifiSpeed = mAccessPoint.getSpeed();
@@ -265,6 +260,15 @@ public class AccessPointPreference extends Preference {
}
}
@VisibleForTesting
static void setTitle(AccessPointPreference preference, AccessPoint ap, boolean savedNetworks) {
if (savedNetworks) {
preference.setTitle(ap.getConfigName());
} else {
preference.setTitle(ap.getSsidStr());
}
}
/**
* Helper method to generate content description string.
*/

View File

@@ -17,6 +17,7 @@ package com.android.settingslib.wifi;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
@@ -78,4 +79,19 @@ public class AccessPointPreferenceTest {
RuntimeEnvironment.application, pref, ap))
.isEqualTo("ssid,connected,Wifi signal full.,Secure network");
}
@Test
public void refresh_setTitle_shouldUseSsidString() {
final String ssid = "ssid";
final String summary = "connected";
final int security = AccessPoint.SECURITY_WEP;
final AccessPoint ap = new TestAccessPointBuilder(mContext)
.setSsid(ssid)
.setSecurity(security)
.build();
final AccessPointPreference preference = mock(AccessPointPreference.class);
AccessPointPreference.setTitle(preference, ap, false /* savedNetwork */);
verify(preference).setTitle(ssid);
}
}