Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b25ba299 authored by govenliu's avatar govenliu
Browse files

[Wi-Fi] Add content description for the Openroaming help button.

1. Add content description for the Openroaming help button.
2. Exclude the showing of help button when isSubscription is true (e.g., Passpoint network)

Bug: 146669261
Test: Add 2 unit test cases:
      1. helpButton_whenCanManageSubscription_shouldSetCorrectContentDescription: to check content description is set correctly.
      2. subscriptionEntry_shouldSetImageButtonGone: to check button should hide when isSubscription true.
Change-Id: I51e927de3b9d2b35096364fd93835e02b29004fc
parent 9c11d2ec
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1279,4 +1279,7 @@

    <!-- Name of the 3.5mm audio device. [CHAR LIMIT=40] -->
    <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>
+4 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ public class WifiEntryPreference extends Preference implements WifiEntry.WifiEnt
        final ImageView frictionImageView = (ImageView) view.findViewById(
                R.id.friction_icon);
        if (mWifiEntry.canManageSubscription() && !mWifiEntry.isSaved()
                && !mWifiEntry.isSubscription()
                && mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_DISCONNECTED) {
            final Drawable drawablehelp = getDrawable(R.drawable.ic_help);
            drawablehelp.setTintList(
@@ -114,6 +115,9 @@ public class WifiEntryPreference extends Preference implements WifiEntry.WifiEnt
            ((ImageView) imageButton).setImageDrawable(drawablehelp);
            imageButton.setVisibility(View.VISIBLE);
            imageButton.setOnClickListener(this);
            imageButton.setContentDescription(
                    getContext().getText(R.string.help_label));

            if (frictionImageView != null) {
                frictionImageView.setVisibility(View.GONE);
            }
+31 −0
Original line number Diff line number Diff line
@@ -167,4 +167,35 @@ public class WifiEntryPreferenceTest {

        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);
    }
}