Merge "Fix janky in App info screen"

This commit is contained in:
TreeHugger Robot
2019-02-19 03:48:53 +00:00
committed by Android (Google) Code Review
4 changed files with 39 additions and 47 deletions

View File

@@ -18,7 +18,8 @@
<RelativeLayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:background="@android:color/transparent">
<com.android.settingslib.widget.settingsspinner.SettingsSpinner <com.android.settingslib.widget.settingsspinner.SettingsSpinner
android:id="@+id/filter_spinner" android:id="@+id/filter_spinner"

View File

@@ -21,57 +21,50 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<androidx.core.widget.NestedScrollView <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fillViewport="true"
settings:layout_behavior="com.android.settings.widget.FloatingAppBarScrollingViewBehavior"> settings:layout_behavior="com.android.settings.widget.FloatingAppBarScrollingViewBehavior">
<FrameLayout <LinearLayout
android:id="@+id/content_container" android:id="@+id/list_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout <FrameLayout
android:id="@+id/list_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:orientation="vertical"
android:visibility="gone">
<FrameLayout <androidx.recyclerview.widget.RecyclerView
android:id="@+id/apps_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:clipToPadding="false"
settings:fastScrollEnabled="true"
settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
settings:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
settings:fastScrollVerticalTrackDrawable="@drawable/line_drawable"/>
<androidx.recyclerview.widget.RecyclerView <TextView
android:id="@+id/apps_list" android:id="@android:id/empty"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
settings:fastScrollEnabled="true" android:gravity="center"
settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable" android:layout_gravity="center"
settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable" android:text="@string/no_applications"
settings:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable" android:textAppearance="?android:attr/textAppearanceLarge"
settings:fastScrollVerticalTrackDrawable="@drawable/line_drawable"/> android:visibility="invisible"/>
<TextView </FrameLayout>
android:id="@android:id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_gravity="center"
android:text="@string/no_applications"
android:textAppearance="?android:attr/textAppearanceLarge"
android:visibility="invisible"/>
</FrameLayout> </LinearLayout>
</LinearLayout> <include layout="@layout/loading_container"/>
<include layout="@layout/loading_container"/> </FrameLayout>
</FrameLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -186,7 +186,6 @@ public class ManageApplications extends InstrumentedFragment
private View mLoadingContainer; private View mLoadingContainer;
private View mListContainer; private View mListContainer;
private RecyclerView mRecyclerView;
private SearchView mSearchView; private SearchView mSearchView;
// Size resource used for packages whose size computation failed for some reason // Size resource used for packages whose size computation failed for some reason
@@ -220,7 +219,7 @@ public class ManageApplications extends InstrumentedFragment
@VisibleForTesting @VisibleForTesting
FilterSpinnerAdapter mFilterAdapter; FilterSpinnerAdapter mFilterAdapter;
@VisibleForTesting @VisibleForTesting
View mContentContainer; RecyclerView mRecyclerView;
private View mRootView; private View mRootView;
private Spinner mFilterSpinner; private Spinner mFilterSpinner;
@@ -330,7 +329,6 @@ public class ManageApplications extends InstrumentedFragment
Bundle savedInstanceState) { Bundle savedInstanceState) {
mRootView = inflater.inflate(R.layout.manage_applications_apps, null); mRootView = inflater.inflate(R.layout.manage_applications_apps, null);
mLoadingContainer = mRootView.findViewById(R.id.loading_container); mLoadingContainer = mRootView.findViewById(R.id.loading_container);
mContentContainer = mRootView.findViewById(R.id.content_container);
mListContainer = mRootView.findViewById(R.id.list_container); mListContainer = mRootView.findViewById(R.id.list_container);
if (mListContainer != null) { if (mListContainer != null) {
// Create adapter and list view here // Create adapter and list view here
@@ -861,14 +859,14 @@ public class ManageApplications extends InstrumentedFragment
// overlapped by floating filter. // overlapped by floating filter.
if (hasFilter) { if (hasFilter) {
mManageApplications.mSpinnerHeader.setVisibility(View.VISIBLE); mManageApplications.mSpinnerHeader.setVisibility(View.VISIBLE);
mManageApplications.mContentContainer.setPadding(0 /* left */, mManageApplications.mRecyclerView.setPadding(0 /* left */,
mContext.getResources().getDimensionPixelSize( mContext.getResources().getDimensionPixelSize(
R.dimen.app_bar_height) /* top */, R.dimen.app_bar_height) /* top */,
0 /* right */, 0 /* right */,
0 /* bottom */); 0 /* bottom */);
} else { } else {
mManageApplications.mSpinnerHeader.setVisibility(View.GONE); mManageApplications.mSpinnerHeader.setVisibility(View.GONE);
mManageApplications.mContentContainer.setPadding(0 /* left */, 0 /* top */, mManageApplications.mRecyclerView.setPadding(0 /* left */, 0 /* top */,
0 /* right */, 0 /* right */,
0 /* bottom */); 0 /* bottom */);
} }

View File

@@ -466,27 +466,27 @@ public class ManageApplicationsTest {
@Test @Test
public void updateFilterView_hasFilterSet_shouldShowFilterAndHavePaddingTop() { public void updateFilterView_hasFilterSet_shouldShowFilterAndHavePaddingTop() {
mFragment.mContentContainer = new View(mContext); mFragment.mRecyclerView = new RecyclerView(mContext);
mFragment.mSpinnerHeader = new View(mContext); mFragment.mSpinnerHeader = new View(mContext);
mFragment.mFilterAdapter = new ManageApplications.FilterSpinnerAdapter(mFragment); mFragment.mFilterAdapter = new ManageApplications.FilterSpinnerAdapter(mFragment);
mFragment.mFilterAdapter.updateFilterView(true); mFragment.mFilterAdapter.updateFilterView(true);
assertThat(mFragment.mSpinnerHeader.getVisibility()).isEqualTo(View.VISIBLE); assertThat(mFragment.mSpinnerHeader.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(mFragment.mContentContainer.getPaddingTop()).isEqualTo( assertThat(mFragment.mRecyclerView.getPaddingTop()).isEqualTo(
mContext.getResources().getDimensionPixelSize(R.dimen.app_bar_height)); mContext.getResources().getDimensionPixelSize(R.dimen.app_bar_height));
} }
@Test @Test
public void updateFilterView_noFilterSet_shouldHideFilterAndNoPaddingTop() { public void updateFilterView_noFilterSet_shouldHideFilterAndNoPaddingTop() {
mFragment.mContentContainer = new View(mContext); mFragment.mRecyclerView = new RecyclerView(mContext);
mFragment.mSpinnerHeader = new View(mContext); mFragment.mSpinnerHeader = new View(mContext);
mFragment.mFilterAdapter = new ManageApplications.FilterSpinnerAdapter(mFragment); mFragment.mFilterAdapter = new ManageApplications.FilterSpinnerAdapter(mFragment);
mFragment.mFilterAdapter.updateFilterView(false); mFragment.mFilterAdapter.updateFilterView(false);
assertThat(mFragment.mSpinnerHeader.getVisibility()).isEqualTo(View.GONE); assertThat(mFragment.mSpinnerHeader.getVisibility()).isEqualTo(View.GONE);
assertThat(mFragment.mContentContainer.getPaddingTop()).isEqualTo(0); assertThat(mFragment.mRecyclerView.getPaddingTop()).isEqualTo(0);
} }
private void setUpOptionMenus() { private void setUpOptionMenus() {