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
xmlns:android="http://schemas.android.com/apk/res/android"
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
android:id="@+id/filter_spinner"

View File

@@ -21,57 +21,50 @@
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.core.widget.NestedScrollView
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
settings:layout_behavior="com.android.settings.widget.FloatingAppBarScrollingViewBehavior">
<FrameLayout
android:id="@+id/content_container"
<LinearLayout
android:id="@+id/list_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
android:id="@+id/list_container"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone">
android:layout_height="match_parent">
<FrameLayout
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/apps_list"
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
android:id="@+id/apps_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
settings:fastScrollEnabled="true"
settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
settings:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
settings:fastScrollVerticalTrackDrawable="@drawable/line_drawable"/>
<TextView
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"/>
<TextView
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>
</FrameLayout>
</LinearLayout>
</LinearLayout>
<include layout="@layout/loading_container"/>
<include layout="@layout/loading_container"/>
</FrameLayout>
</androidx.core.widget.NestedScrollView>
</FrameLayout>
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"

View File

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

View File

@@ -466,27 +466,27 @@ public class ManageApplicationsTest {
@Test
public void updateFilterView_hasFilterSet_shouldShowFilterAndHavePaddingTop() {
mFragment.mContentContainer = new View(mContext);
mFragment.mRecyclerView = new RecyclerView(mContext);
mFragment.mSpinnerHeader = new View(mContext);
mFragment.mFilterAdapter = new ManageApplications.FilterSpinnerAdapter(mFragment);
mFragment.mFilterAdapter.updateFilterView(true);
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));
}
@Test
public void updateFilterView_noFilterSet_shouldHideFilterAndNoPaddingTop() {
mFragment.mContentContainer = new View(mContext);
mFragment.mRecyclerView = new RecyclerView(mContext);
mFragment.mSpinnerHeader = new View(mContext);
mFragment.mFilterAdapter = new ManageApplications.FilterSpinnerAdapter(mFragment);
mFragment.mFilterAdapter.updateFilterView(false);
assertThat(mFragment.mSpinnerHeader.getVisibility()).isEqualTo(View.GONE);
assertThat(mFragment.mContentContainer.getPaddingTop()).isEqualTo(0);
assertThat(mFragment.mRecyclerView.getPaddingTop()).isEqualTo(0);
}
private void setUpOptionMenus() {