Merge "[Wi-Fi] Add content description for the Openroaming help button." into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-03-21 05:10:39 +00:00
committed by Android (Google) Code Review
3 changed files with 38 additions and 0 deletions

View File

@@ -1281,4 +1281,7 @@
<!-- Name of the 3.5mm audio device. [CHAR LIMIT=40] --> <!-- Name of the 3.5mm audio device. [CHAR LIMIT=40] -->
<string name="media_transfer_wired_device_name">Wired audio device</string> <string name="media_transfer_wired_device_name">Wired audio device</string>
<!-- Help button label [CHAR LIMIT=40] -->
<string name="help_label">Help &amp; feedback</string>
</resources> </resources>

View File

@@ -107,6 +107,7 @@ public class WifiEntryPreference extends Preference implements WifiEntry.WifiEnt
final ImageView frictionImageView = (ImageView) view.findViewById( final ImageView frictionImageView = (ImageView) view.findViewById(
R.id.friction_icon); R.id.friction_icon);
if (mWifiEntry.canManageSubscription() && !mWifiEntry.isSaved() if (mWifiEntry.canManageSubscription() && !mWifiEntry.isSaved()
&& !mWifiEntry.isSubscription()
&& mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_DISCONNECTED) { && mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_DISCONNECTED) {
final Drawable drawablehelp = getDrawable(R.drawable.ic_help); final Drawable drawablehelp = getDrawable(R.drawable.ic_help);
drawablehelp.setTintList( drawablehelp.setTintList(
@@ -114,6 +115,9 @@ public class WifiEntryPreference extends Preference implements WifiEntry.WifiEnt
((ImageView) imageButton).setImageDrawable(drawablehelp); ((ImageView) imageButton).setImageDrawable(drawablehelp);
imageButton.setVisibility(View.VISIBLE); imageButton.setVisibility(View.VISIBLE);
imageButton.setOnClickListener(this); imageButton.setOnClickListener(this);
imageButton.setContentDescription(
getContext().getText(R.string.help_label));
if (frictionImageView != null) { if (frictionImageView != null) {
frictionImageView.setVisibility(View.GONE); frictionImageView.setVisibility(View.GONE);
} }

View File

@@ -167,4 +167,35 @@ public class WifiEntryPreferenceTest {
assertThat(view.findViewById(R.id.icon_button).getVisibility()).isEqualTo(View.VISIBLE); assertThat(view.findViewById(R.id.icon_button).getVisibility()).isEqualTo(View.VISIBLE);
} }
@Test
public void helpButton_whenCanManageSubscription_shouldSetCorrectContentDescription() {
when(mMockWifiEntry.canManageSubscription()).thenReturn(true);
final WifiEntryPreference pref =
new WifiEntryPreference(mContext, mMockWifiEntry, mMockIconInjector);
final LayoutInflater inflater = LayoutInflater.from(mContext);
final View view = inflater.inflate(pref.getLayoutResource(), new LinearLayout(mContext),
false);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(view);
pref.onBindViewHolder(holder);
assertThat(view.findViewById(R.id.icon_button).getContentDescription()).isEqualTo(
mContext.getString(R.string.help_label));
}
@Test
public void subscriptionEntry_shouldSetImageButtonGone() {
when(mMockWifiEntry.isSubscription()).thenReturn(true);
final WifiEntryPreference pref =
new WifiEntryPreference(mContext, mMockWifiEntry, mMockIconInjector);
final LayoutInflater inflater = LayoutInflater.from(mContext);
final View view = inflater.inflate(pref.getLayoutResource(), new LinearLayout(mContext),
false);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(view);
pref.onBindViewHolder(holder);
assertThat(view.findViewById(R.id.icon_button).getVisibility()).isEqualTo(View.GONE);
}
} }