Unbanish memory screen and new UX

Give memory screen a makeover so that it looks nice enough to be
restored to its rightful home.

Bug: 20694769
Change-Id: I2f6933037b3fbbfb0d9fe5e3ca821ef59e171faa
diff --git a/res/layout/app_item_linear_color.xml b/res/layout/app_item_linear_color.xml
index 62eebb9..7a4aad5 100755
--- a/res/layout/app_item_linear_color.xml
+++ b/res/layout/app_item_linear_color.xml
@@ -15,7 +15,7 @@
      limitations under the License.
 -->
 
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:minHeight="?android:attr/listPreferredItemHeight"
@@ -34,16 +34,19 @@
         android:duplicateParentState="true" />
 
     <LinearLayout
-        android:layout_width="0dp"
-        android:layout_height="match_parent"
-        android:layout_weight="1"
-        android:orientation="vertical"
+        android:id="@+id/text_area"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignParentTop="true"
+        android:layout_toEndOf="@android:id/icon"
+        android:orientation="horizontal"
         android:duplicateParentState="true">
 
         <TextView
             android:id="@android:id/title"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:layout_weight="1"
             android:layout_marginTop="2dip"
             android:singleLine="true"
             android:ellipsize="marquee"
@@ -55,20 +58,22 @@
             android:id="@android:id/summary"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:layout_weight="1"
             android:textAppearance="@android:style/TextAppearance.Material.Body1"
             android:textColor="?android:attr/textColorSecondary"
-            android:textAlignment="viewStart"
+            android:gravity="end|bottom"
             android:duplicateParentState="true" />
 
     </LinearLayout>
 
     <com.android.settings.applications.LinearColorBar
         android:id="@+id/linear_color_bar"
-        android:layout_width="0dp"
-        android:layout_height="match_parent"
-        android:layout_weight="1"
-        android:layout_marginTop="5dp"
+        android:layout_width="match_parent"
+        android:layout_height="10dp"
+        android:layout_marginTop="7dp"
         android:layout_marginBottom="5dp"
+        android:layout_toEndOf="@android:id/icon"
+        android:layout_below="@id/text_area"
         android:duplicateParentState="true" />
 
-</LinearLayout>
+</RelativeLayout>
diff --git a/res/layout/horizontal_preference.xml b/res/layout/horizontal_preference.xml
index 4e16e9a..722e053 100644
--- a/res/layout/horizontal_preference.xml
+++ b/res/layout/horizontal_preference.xml
@@ -38,6 +38,6 @@
         android:layout_height="wrap_content"
         android:layout_width="wrap_content"
         android:layout_weight="1"
-        android:gravity="end" />
+        android:gravity="end|bottom" />
 
 </LinearLayout>
diff --git a/res/layout/proc_stats_ui.xml b/res/layout/proc_stats_ui.xml
index 5f78178..9d0a22d 100644
--- a/res/layout/proc_stats_ui.xml
+++ b/res/layout/proc_stats_ui.xml
@@ -28,28 +28,18 @@
         android:id="@+id/memory_state"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_marginTop="20dp"
-        android:layout_marginBottom="10dp"
-        android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+        android:layout_marginTop="5dp"
+        android:layout_marginBottom="5dp"
+        android:textColor="?android:attr/colorAccent"
+        android:textAppearance="@android:style/TextAppearance.Material.Display1"
         />
 
     <com.android.settings.applications.LinearColorBar
         android:id="@+id/color_bar"
         android:layout_width="match_parent"
-        android:layout_height="30dp"
+        android:layout_height="28dp"
+        android:layout_marginBottom="15dp"
         />
 
-    <TextView
-        android:id="@+id/memory_used"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_marginTop="2dp"
-        android:layout_marginBottom="10dp"
-        android:textAppearance="@android:style/TextAppearance.Material.Small"
-        android:textColor="?android:attr/textColorSecondary"
-        />
-
-    <include layout="@layout/memory_key" />
-
 </LinearLayout>
 
diff --git a/res/layout/single_button_panel.xml b/res/layout/single_button_panel.xml
index 2af1765..348f7ce 100755
--- a/res/layout/single_button_panel.xml
+++ b/res/layout/single_button_panel.xml
@@ -25,8 +25,8 @@
         android:paddingStart="?android:attr/listPreferredItemPaddingStart"
         android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
         android:gravity="bottom"
-        android:paddingTop="6dip"
-        android:paddingBottom="6dip"
+        android:paddingTop="8dip"
+        android:paddingBottom="8dip"
         android:orientation="horizontal">
         <Button
             android:id="@+id/button"
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 1af15f9..36924ee 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1225,13 +1225,15 @@
     <!-- [CHAR LIMIT=40] Labels for memory states -->
     <string-array name="ram_states">
         <!-- Normal desired memory state. -->
-        <item>Good performance</item>
+        <item>Normal</item>
         <!-- Moderate memory state, not as good as normal. -->
-        <item>Ok performance</item>
+        <item>Moderate</item>
         <!-- Memory is running low. -->
-        <item>Poor performance</item>
+        <item>Low</item>
         <!-- Memory is critical. -->
-        <item>Very poor performance</item>
+        <item>Critical</item>
+        <!-- Unknown memory state -->
+        <item>\?</item>
     </string-array>
 
     <array name="ram_colors">
diff --git a/res/values/strings.xml b/res/values/strings.xml
index b1628d9..0071926 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6556,13 +6556,13 @@
     <string name="memory_details_title">Memory details</string>
 
     <!-- Description of app always running [CHAR LIMIT=45] -->
-    <string name="always_running">Always running</string>
+    <string name="always_running">Always running (<xliff:g id="percentage" example="5%">%s</xliff:g>)</string>
 
     <!-- Description of app sometimes running [CHAR LIMIT=45] -->
-    <string name="sometimes_running">Sometimes running</string>
+    <string name="sometimes_running">Sometimes running (<xliff:g id="percentage" example="5%">%s</xliff:g>)</string>
 
     <!-- Description of app rarely running [CHAR LIMIT=45] -->
-    <string name="rarely_running">Rarely running</string>
+    <string name="rarely_running">Rarely running (<xliff:g id="percentage" example="5%">%s</xliff:g>)</string>
 
     <!-- Maximum memory usage key [CHAR LIMIT=25] -->
     <string name="memory_max_use">Maximum</string>
@@ -6657,4 +6657,43 @@
 
     <!-- Footer text in the manage assist screen. [CHAR LIMIT=NONE] -->
     <string name="assist_footer">Assist apps help you identify and act on useful information without having to ask. Some apps support both launcher and voice input services to give you integrated assistance.</string>
+
+    <!-- Label for average memory use section [CHAR LIMIT=30] -->
+    <string name="average_memory_use">Average memory use</string>
+
+    <!-- Label for maximum memory use section [CHAR LIMIT=30] -->
+    <string name="maximum_memory_use">Maximum memory use</string>
+
+    <!-- Menu item for Sorting list by average memory use [CHAR LIMIT=NONE]-->
+    <string name="sort_avg_use">Sort by avg use</string>
+
+    <!-- Menu item for Sorting list by maximum memory use [CHAR LIMIT=NONE] -->
+    <string name="sort_max_use">Sort by max use</string>
+
+    <!-- Label for the current performance of the device [CHAR LIMIT=25] -->
+    <string name="memory_performance">Performance</string>
+
+    <!-- Label for total memory of device [CHAR LIMIT=25] -->
+    <string name="total_memory">Total memory</string>
+
+    <!-- Label for average memory usage of device [CHAR LIMIT=25] -->
+    <string name="average_used">Average used (&#x0025;)</string>
+
+    <!-- Label for free memory of device [CHAR LIMIT=25] -->
+    <string name="free_memory">Free</string>
+
+    <!-- Label for button that leads to list of apps and their memory usage [CHAR LIMIT=40]-->
+    <string name="memory_usage_apps">Memory used by apps</string>
+
+    <!-- Description of number of apps using memory [CHAR LIMIT=NONE] -->
+    <plurals name="memory_usage_apps_summary">
+        <item quantity="one">1 app used memory in the last <xliff:g id="duration" example="3 hours">%2$s</xliff:g></item>
+        <item quantity="other"><xliff:g id="count" example="10">%1$d</xliff:g> apps used memory in the last <xliff:g id="duration" example="3 hours">%2$s</xliff:g></item>
+    </plurals>
+
+    <!-- Label for frequency that the app is runnig (e.g. always, sometimes, etc.) [CHAR LIMIT=25] -->
+    <string name="running_frequency">Frequency</string>
+
+    <!-- Label for maximum amount of memory app has used [CHAR LIMIT=25] -->
+    <string name="memory_maximum_usage">Maximum usage</string>
 </resources>
diff --git a/res/xml/advanced_apps.xml b/res/xml/advanced_apps.xml
index 1e2d516..b38900b 100644
--- a/res/xml/advanced_apps.xml
+++ b/res/xml/advanced_apps.xml
@@ -49,8 +49,4 @@
             android:value="com.android.settings.Settings$HighPowerApplicationsActivity" />
     </PreferenceScreen>
 
-    <PreferenceScreen
-        android:title="@string/memory_settings_title"
-        android:fragment="com.android.settings.applications.ProcessStatsUi" />
-
 </PreferenceScreen>
diff --git a/res/xml/app_memory_settings.xml b/res/xml/app_memory_settings.xml
index 2c3db21..41de52f 100644
--- a/res/xml/app_memory_settings.xml
+++ b/res/xml/app_memory_settings.xml
@@ -17,8 +17,26 @@
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
                   android:title="@string/memory_details_title">
 
+    <PreferenceCategory
+        android:title="@string/average_memory_use" />
+
     <com.android.settings.applications.LayoutPreference
-        android:key="details_header"
-        android:layout="@layout/process_stats_details" />
+        android:key="status_header"
+        android:layout="@layout/proc_stats_ui" />
+
+    <Preference
+        android:key="frequency"
+        android:selectable="false"
+        android:layout="@layout/horizontal_preference"
+        android:title="@string/running_frequency" />
+
+    <Preference
+        android:key="max_usage"
+        android:selectable="false"
+        android:layout="@layout/horizontal_preference"
+        android:title="@string/memory_maximum_usage" />
+
+    <com.android.settings.applications.SpacePreference
+        android:layout_height="15dp" />
 
 </PreferenceScreen>
diff --git a/res/xml/app_storage_settings.xml b/res/xml/app_storage_settings.xml
index 5bb9204..7c5c25c 100644
--- a/res/xml/app_storage_settings.xml
+++ b/res/xml/app_storage_settings.xml
@@ -63,9 +63,13 @@
             android:layout="@layout/single_button_panel" />
     </PreferenceCategory>
 
+    <com.android.settings.applications.SpacePreference
+        android:layout_height="8dp" />
+
     <Preference
         android:key="cache_size"
         android:title="@string/cache_size_label"
+        android:selectable="false"
         android:layout="@layout/horizontal_preference" />
 
     <com.android.settings.applications.LayoutPreference
diff --git a/res/xml/dashboard_categories.xml b/res/xml/dashboard_categories.xml
index 14a4db6..5b8c243 100644
--- a/res/xml/dashboard_categories.xml
+++ b/res/xml/dashboard_categories.xml
@@ -134,13 +134,13 @@
                 android:icon="@drawable/ic_settings_multiuser"
                 />
 
-        <!-- Memory (hidden for now)
+        <!-- Memory -->
         <dashboard-tile
                 android:id="@+id/manage_memory"
                 android:title="@string/memory_settings_title"
-                android:fragment="com.android.settings.applications.ProcessStatsUi"
+                android:fragment="com.android.settings.applications.ProcessStatsSummary"
                 android:icon="@drawable/ic_settings_memory"
-                /> -->
+                />
 
         <!-- Manage NFC payment apps -->
         <dashboard-tile
diff --git a/res/xml/process_stats_summary.xml b/res/xml/process_stats_summary.xml
index 46bb160..d267272 100644
--- a/res/xml/process_stats_summary.xml
+++ b/res/xml/process_stats_summary.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 The Android Open Source Project
+<!-- Copyright (C) 2015 The Android Open Source Project
 
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
@@ -18,7 +18,43 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:title="@string/app_memory_use"
     android:key="app_list">
+    <PreferenceCategory
+        android:title="@string/average_memory_use" />
+
     <com.android.settings.applications.LayoutPreference
         android:key="status_header"
+        android:selectable="false"
         android:layout="@layout/proc_stats_ui" />
+
+    <Preference
+        android:key="performance"
+        android:selectable="false"
+        android:layout="@layout/horizontal_preference"
+        android:title="@string/memory_performance" />
+
+    <Preference
+        android:key="total_memory"
+        android:selectable="false"
+        android:layout="@layout/horizontal_preference"
+        android:title="@string/total_memory" />
+
+    <Preference
+        android:key="average_used"
+        android:selectable="false"
+        android:layout="@layout/horizontal_preference"
+        android:title="@string/average_used" />
+
+    <Preference
+        android:key="free"
+        android:selectable="false"
+        android:layout="@layout/horizontal_preference"
+        android:title="@string/free_memory" />
+
+    <com.android.settings.applications.SpacePreference
+        android:layout_height="15dp" />
+
+    <Preference
+        android:key="apps_list"
+        android:title="@string/memory_usage_apps" />
+
 </PreferenceScreen>
diff --git a/res/xml/process_stats_ui.xml b/res/xml/process_stats_ui.xml
new file mode 100644
index 0000000..ba9066e
--- /dev/null
+++ b/res/xml/process_stats_ui.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:title="@string/app_memory_use">
+
+    <PreferenceCategory
+        android:key="app_list"
+        android:title="@string/average_memory_use" />
+
+</PreferenceScreen>