Fix search highlight

- Fragments should not have advanced button when coming from search.

Change-Id: I10a192216b7ff702e73b791acbcc1eb1d71cb407
Fixes: 73348428
Test: robotests
This commit is contained in:
Fan Zhang
2018-02-20 11:25:56 -08:00
parent 6f367a79ce
commit 72456a9ea6
6 changed files with 118 additions and 43 deletions

View File

@@ -135,19 +135,7 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
if (icicle != null) {
mPreferenceHighlighted = icicle.getBoolean(SAVE_HIGHLIGHTED_KEY);
}
final Bundle arguments = getArguments();
// Check if we should keep the preferences expanded.
if (arguments != null) {
final String highlightKey =
arguments.getString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY);
if (!TextUtils.isEmpty(highlightKey)) {
final PreferenceScreen screen = getPreferenceScreen();
if (screen != null) {
screen.setInitialExpandedChildrenCount(Integer.MAX_VALUE);
}
}
}
HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(this /* host */);
}
@Override
@@ -264,6 +252,15 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
}
}
/**
* Returns initial expanded child count.
* <p/>
* Only override this method if the initial expanded child must be determined at run time.
*/
public int getInitialExpandedChildCount() {
return 0;
}
protected void onDataSetChanged() {
highlightPreferenceIfNeeded();
updateEmptyView();