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

Commit 418137e5 authored by Joel Galenson's avatar Joel Galenson
Browse files

Show the bar chart detail after hiding it.

In a previous commit I made the bar chart detail text GONE when no
text was provided to avoid a crash.  But I forgot to mark it visible
when text is passed afterwards.  This fixes that bug.

Test: Create bar chart with an empty detail text, set some text, and
then see the detail text.
Test: atest com.android.settingslib.widget.BarChartPreferenceTest

Change-Id: I4a352245c3dc7b02ab3d1de21c348f2d431e95cf
parent 46d40a2b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -168,6 +168,7 @@ public class BarChartPreference extends Preference {
        if (mDetailsId == 0) {
            detailsView.setVisibility(View.GONE);
        } else {
            detailsView.setVisibility(View.VISIBLE);
            detailsView.setText(mDetailsId);
            detailsView.setOnClickListener(mDetailsOnClickListener);
        }
+14 −0
Original line number Diff line number Diff line
@@ -80,6 +80,20 @@ public class BarChartPreferenceTest {
        assertThat(mDetailsView.getVisibility()).isEqualTo(View.GONE);
    }

    @Test
    public void onBindViewHolder_notSetDetailsRes_barChartDetailsViewIsGoneThenReappears() {
        // We don't call BarChartPreference#setBarChartDetails yet.
        mPreference.onBindViewHolder(mHolder);

        assertThat(mDetailsView.getVisibility()).isEqualTo(View.GONE);

        mPreference.setBarChartDetails(R.string.debug_app);
        mPreference.onBindViewHolder(mHolder);

        assertThat(mDetailsView.getVisibility()).isEqualTo(View.VISIBLE);
        assertThat(mDetailsView.getText()).isEqualTo(mContext.getText(R.string.debug_app));
    }

    @Test
    public void setBarChartDetailsRes_setDetailsRes_showInBarChartDetails() {
        mPreference.setBarChartDetails(R.string.debug_app);