Fix the higlighted settings not work properly from search

Since the Andorid S, we introduce the CollapsingToolbarLayout
, the highlighted funcation might break for unkown reason.
I observed that broken cases with overlapping issue on tool bar.
The possible root cause is the interation bwtween
CoordinatorLayout v.s CollapsingToolbarLayout v.s Recycler
view.

This cl is definetly a workaround to prevent this issue.
I try to collapse the tool bar with an animation before
we start to scroll the list. This makes the overall transition smooth
but always collapse the tool bar.

Fix: 177968297
Test: Click a lot of search results, and screen should highlight
settings correctly.

Change-Id: Id9c32b642433dcc39c179a2cc83a06e77cc47888
This commit is contained in:
Tsung-Mao Fang
2021-02-24 16:37:39 +08:00
parent beefb25b48
commit ef87755c34
3 changed files with 37 additions and 14 deletions

View File

@@ -57,6 +57,8 @@ import com.android.settingslib.core.instrumentation.Instrumentable;
import com.android.settingslib.search.Indexable;
import com.android.settingslib.widget.LayoutPreference;
import com.google.android.material.appbar.AppBarLayout;
import java.util.UUID;
/**
@@ -112,9 +114,8 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
@VisibleForTesting
ViewGroup mPinnedHeaderFrameLayout;
private AppBarLayout mAppBarLayout;
private LayoutPreference mHeader;
private View mEmptyView;
private LinearLayoutManager mLayoutManager;
private ArrayMap<String, Preference> mPreferenceCache;
@@ -145,6 +146,7 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
Bundle savedInstanceState) {
final View root = super.onCreateView(inflater, container, savedInstanceState);
mPinnedHeaderFrameLayout = root.findViewById(R.id.pinned_header);
mAppBarLayout = getActivity().findViewById(R.id.app_bar);
return root;
}
@@ -250,7 +252,7 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
return;
}
if (mAdapter != null) {
mAdapter.requestHighlight(getView(), getListView());
mAdapter.requestHighlight(getView(), getListView(), mAppBarLayout);
}
}