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:
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
@@ -43,6 +44,8 @@ import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -85,8 +88,11 @@ public class HighlightablePreferenceGroupAdapterTest {
|
||||
|
||||
@Test
|
||||
public void requestHighlight_hasKey_notHighlightedBefore_shouldRequest() {
|
||||
mAdapter.requestHighlight(mRoot, mock(RecyclerView.class));
|
||||
when(mAdapter.getPreferenceAdapterPosition(anyString())).thenReturn(1);
|
||||
mAdapter.requestHighlight(mRoot, mock(RecyclerView.class), mock(AppBarLayout.class));
|
||||
|
||||
verify(mRoot).postDelayed(any(),
|
||||
eq(HighlightablePreferenceGroupAdapter.DELAY_COLLAPSE_DURATION_MILLIS));
|
||||
verify(mRoot).postDelayed(any(),
|
||||
eq(HighlightablePreferenceGroupAdapter.DELAY_HIGHLIGHT_DURATION_MILLIS));
|
||||
}
|
||||
@@ -95,21 +101,21 @@ public class HighlightablePreferenceGroupAdapterTest {
|
||||
public void requestHighlight_noKey_highlightedBefore_noRecyclerView_shouldNotRequest() {
|
||||
ReflectionHelpers.setField(mAdapter, "mHighlightKey", null);
|
||||
ReflectionHelpers.setField(mAdapter, "mHighlightRequested", false);
|
||||
mAdapter.requestHighlight(mRoot, mock(RecyclerView.class));
|
||||
mAdapter.requestHighlight(mRoot, mock(RecyclerView.class), mock(AppBarLayout.class));
|
||||
|
||||
ReflectionHelpers.setField(mAdapter, "mHighlightKey", TEST_KEY);
|
||||
ReflectionHelpers.setField(mAdapter, "mHighlightRequested", true);
|
||||
mAdapter.requestHighlight(mRoot, mock(RecyclerView.class));
|
||||
mAdapter.requestHighlight(mRoot, mock(RecyclerView.class), mock(AppBarLayout.class));
|
||||
|
||||
ReflectionHelpers.setField(mAdapter, "mHighlightKey", TEST_KEY);
|
||||
ReflectionHelpers.setField(mAdapter, "mHighlightRequested", false);
|
||||
mAdapter.requestHighlight(mRoot, null /* recyclerView */);
|
||||
mAdapter.requestHighlight(mRoot, null /* recyclerView */, mock(AppBarLayout.class));
|
||||
|
||||
verifyZeroInteractions(mRoot);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void adjustInitialExpandedChildCount_invalidInput_shouldNotadjust() {
|
||||
public void adjustInitialExpandedChildCount_invalidInput_shouldNotAdjust() {
|
||||
HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(null /* host */);
|
||||
HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(mFragment);
|
||||
final Bundle args = new Bundle();
|
||||
|
Reference in New Issue
Block a user