Merge "Refine the conditionals layout"
diff --git a/res/layout/manage_applications_apps.xml b/res/layout/manage_applications_apps.xml
index 765ced6..c2f58c3 100644
--- a/res/layout/manage_applications_apps.xml
+++ b/res/layout/manage_applications_apps.xml
@@ -14,60 +14,73 @@
      limitations under the License.
 -->
 
-<LinearLayout
+<androidx.coordinatorlayout.widget.CoordinatorLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
 
-    <FrameLayout
+    <androidx.core.widget.NestedScrollView
         android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:layout_weight="1">
+        android:layout_height="match_parent"
+        android:fillViewport="true"
+        settings:layout_behavior="com.android.settings.widget.FloatingAppBarScrollingViewBehavior">
 
-        <LinearLayout
-            android:id="@+id/list_container"
+        <FrameLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:orientation="vertical"
-            android:visibility="gone">
+            android:paddingTop="@dimen/app_bar_height">
 
-            <FrameLayout
-                android:id="@+id/pinned_header"
+            <LinearLayout
+                android:id="@+id/list_container"
                 android:layout_width="match_parent"
-                android:layout_height="wrap_content" />
+                android:layout_height="match_parent"
+                android:orientation="vertical"
+                android:visibility="gone">
 
-            <FrameLayout
-                android:layout_width="match_parent"
-                android:layout_height="0px"
-                android:layout_weight="1">
-
-                <androidx.recyclerview.widget.RecyclerView
-                    android:id="@+id/apps_list"
+                <FrameLayout
                     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"/>
+                    android:layout_height="match_parent">
 
-                <TextView
-                    android:id="@android:id/empty"
-                    android:layout_width="match_parent"
-                    android:layout_height="match_parent"
-                    android:gravity="center"
-                    android:text="@string/no_applications"
-                    android:textAppearance="?android:attr/textAppearanceLarge"
-                    android:visibility="invisible" />
+                    <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"/>
 
-            </FrameLayout>
+                    <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"/>
 
-        </LinearLayout>
+                </FrameLayout>
 
-        <include layout="@layout/loading_container" />
+            </LinearLayout>
 
-    </FrameLayout>
+            <include layout="@layout/loading_container"/>
 
-</LinearLayout>
+        </FrameLayout>
+
+    </androidx.core.widget.NestedScrollView>
+
+    <com.google.android.material.appbar.AppBarLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+        <FrameLayout
+            android:id="@+id/pinned_header"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            settings:layout_scrollFlags="scroll|enterAlways"/>
+    </com.google.android.material.appbar.AppBarLayout>
+
+</androidx.coordinatorlayout.widget.CoordinatorLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index b8dbef3..1a3d6ff 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -114,6 +114,8 @@
     <dimen name="wifi_assistant_height">182dp</dimen>
     <dimen name="wifi_assistant_image_top">32dp</dimen>
     <dimen name="wifi_assistant_image_start">24dp</dimen>
+    <!-- appbar height is equal search bar height (48dp) plus search bar top and bottom margin  -->
+    <dimen name="app_bar_height">80dp</dimen>
 
     <!-- CryptKeeper top margin for password/pin screen -->
     <dimen name="crypt_keeper_password_top_margin">88dip</dimen>