Skip "null" string when building advanced button summary
- Also added help string to SoundSettings as a side fix. Change-Id: Ia81a46c6e199b72b52ae1fa9d996c094193b506c Fix: 37933524 Test: robotests
This commit is contained in:
@@ -231,7 +231,7 @@ public class ProgressiveDisclosureMixin implements Preference.OnPreferenceClickL
|
||||
/**
|
||||
* Add preference to collapsed list.
|
||||
*/
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
@VisibleForTesting
|
||||
void addToCollapsedList(Preference preference) {
|
||||
// Insert preference based on it's order.
|
||||
int insertionIndex = Collections.binarySearch(mCollapsedPrefs, preference);
|
||||
@@ -242,12 +242,12 @@ public class ProgressiveDisclosureMixin implements Preference.OnPreferenceClickL
|
||||
updateExpandButtonSummary();
|
||||
}
|
||||
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
@VisibleForTesting
|
||||
List<Preference> getCollapsedPrefs() {
|
||||
return mCollapsedPrefs;
|
||||
}
|
||||
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
@VisibleForTesting
|
||||
void updateExpandButtonSummary() {
|
||||
final int size = mCollapsedPrefs.size();
|
||||
if (size == 0) {
|
||||
@@ -257,8 +257,11 @@ public class ProgressiveDisclosureMixin implements Preference.OnPreferenceClickL
|
||||
} else {
|
||||
CharSequence summary = mCollapsedPrefs.get(0).getTitle();
|
||||
for (int i = 1; i < size; i++) {
|
||||
summary = mContext.getString(R.string.join_many_items_middle, summary,
|
||||
mCollapsedPrefs.get(i).getTitle());
|
||||
final CharSequence nextSummary = mCollapsedPrefs.get(i).getTitle();
|
||||
if (!TextUtils.isEmpty(nextSummary)) {
|
||||
summary = mContext.getString(R.string.join_many_items_middle, summary,
|
||||
nextSummary);
|
||||
}
|
||||
}
|
||||
mExpandButton.setSummary(summary);
|
||||
}
|
||||
|
@@ -75,6 +75,11 @@ public class SoundSettings extends DashboardFragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHelpResource() {
|
||||
return R.string.help_url_sound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
@@ -25,7 +25,6 @@ import android.support.v7.preference.PreferenceScreen;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -58,8 +57,6 @@ public class ProgressiveDisclosureTest {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private FakeFeatureFactory mFakeFeatureFactory;
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private PreferenceFragment mPreferenceFragment;
|
||||
@Mock
|
||||
@@ -75,7 +72,6 @@ public class ProgressiveDisclosureTest {
|
||||
FakeFeatureFactory.setupForTest(mContext);
|
||||
mScreen = mPreferenceFragment.getPreferenceScreen();
|
||||
mAppContext = ShadowApplication.getInstance().getApplicationContext();
|
||||
mFakeFeatureFactory = (FakeFeatureFactory) FeatureFactory.getFactory(mContext);
|
||||
mMixin = new ProgressiveDisclosureMixin(mAppContext,
|
||||
mPreferenceFragment, false /* keepExpanded */);
|
||||
ReflectionHelpers.setField(mMixin, "mExpandButton", mExpandButton);
|
||||
@@ -314,6 +310,25 @@ public class ProgressiveDisclosureTest {
|
||||
verify(mExpandButton).setSummary(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateExpandSummary_doNotIncludeEmptyPrefTitle() {
|
||||
final Preference pref1 = new Preference(mAppContext);
|
||||
pref1.setTitle("1");
|
||||
final Preference pref2 = new Preference(mAppContext);
|
||||
pref2.setTitle(null);
|
||||
final Preference pref3 = new Preference(mAppContext);
|
||||
pref3.setTitle("3");
|
||||
final Preference pref4 = new Preference(mAppContext);
|
||||
pref4.setTitle("");
|
||||
|
||||
mMixin.addToCollapsedList(pref1);
|
||||
mMixin.addToCollapsedList(pref2);
|
||||
mMixin.addToCollapsedList(pref3);
|
||||
mMixin.addToCollapsedList(pref4);
|
||||
|
||||
verify(mExpandButton).setSummary("1, 3");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateExapndSummary_singlePref_expandSummarySameAsPrefTitle() {
|
||||
final String TEST = "test";
|
||||
|
Reference in New Issue
Block a user