Update recently opened app string and "see all" summary

Change-Id: I84a01f01ac1c685db87970c3137f30ba58c800b3
Fix: 62040104
Test: make RunSettingsRoboTests
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index e09b4b1..8a50b01 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2530,8 +2530,6 @@
             </intent-filter>
             <meta-data android:name="com.android.settings.category"
                 android:value="com.android.settings.category.ia.apps"/>
-            <meta-data android:name="com.android.settings.summary"
-                android:resource="@string/summary_empty"/>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.notification.ConfigureNotificationSettings" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9c1beaa..311aea3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3521,9 +3521,9 @@
     <!-- Applications settings screen, setting check box title. If checked, the system allows installation of applications that are downloaded from random places, such as web sites.  [CHAR LIMIT=30] -->
     <string name="install_applications_title">Allow all app sources</string>
     <!-- Category title listing recently used apps [CHAR_LIMIT=50]-->
-    <string name="recent_app_category_title">Recently used apps</string>
+    <string name="recent_app_category_title">Recently opened</string>
     <!-- Preference title for showing all apps on device [CHAR_LIMIT=50]-->
-    <string name="see_all_apps_title">See all apps</string>
+    <string name="see_all_apps_title">See all <xliff:g>%1$d</xliff:g> installed apps</string>
 
     <!-- Warning that appears below the unknown sources switch in settings -->
     <string name="install_all_warning" product="tablet">
diff --git a/res/xml/app_and_notification.xml b/res/xml/app_and_notification.xml
index 9ddff85..47fc378 100644
--- a/res/xml/app_and_notification.xml
+++ b/res/xml/app_and_notification.xml
@@ -30,7 +30,6 @@
         <Preference
             android:title="@string/applications_settings"
             android:key="all_app_info"
-            android:summary="@string/summary_placeholder"
             android:order="20">
             <intent
                 android:action="android.intent.action.MAIN"
diff --git a/src/com/android/settings/applications/RecentAppsPreferenceController.java b/src/com/android/settings/applications/RecentAppsPreferenceController.java
index 43ede2f..7a99508 100644
--- a/src/com/android/settings/applications/RecentAppsPreferenceController.java
+++ b/src/com/android/settings/applications/RecentAppsPreferenceController.java
@@ -77,6 +77,7 @@
 
     private PreferenceCategory mCategory;
     private Preference mSeeAllPref;
+    private boolean mHasRecentApps;
 
     static {
         SKIP_SYSTEM_PACKAGES.addAll(Arrays.asList(
@@ -133,15 +134,20 @@
     @Override
     public void updateState(Preference preference) {
         super.updateState(preference);
+        refreshUi(mCategory.getContext());
         // Show total number of installed apps as See all's summary.
         new InstalledAppCounter(mContext, InstalledAppCounter.IGNORE_INSTALL_REASON,
                 new PackageManagerWrapperImpl(mContext.getPackageManager())) {
             @Override
             protected void onCountComplete(int num) {
-                mSeeAllPref.setSummary(mContext.getString(R.string.apps_summary, num));
+                if (mHasRecentApps) {
+                    mSeeAllPref.setTitle(mContext.getString(R.string.see_all_apps_title, num));
+                } else {
+                    mSeeAllPref.setSummary(mContext.getString(R.string.apps_summary, num));
+                }
             }
         }.execute();
-        refreshUi(mCategory.getContext());
+
     }
 
     @Override
@@ -155,8 +161,10 @@
         reloadData();
         final List<UsageStats> recentApps = getDisplayableRecentAppList();
         if (recentApps != null && !recentApps.isEmpty()) {
+            mHasRecentApps = true;
             displayRecentApps(prefContext, recentApps);
         } else {
+            mHasRecentApps = false;
             displayOnlyAppInfo();
         }
     }
@@ -185,7 +193,7 @@
 
     private void displayRecentApps(Context prefContext, List<UsageStats> recentApps) {
         mCategory.setTitle(R.string.recent_app_category_title);
-        mSeeAllPref.setTitle(R.string.see_all_apps_title);
+        mSeeAllPref.setSummary(null);
         mSeeAllPref.setIcon(R.drawable.ic_chevron_right_24dp);
 
         // Rebind prefs/avoid adding new prefs if possible. Adding/removing prefs causes jank.
diff --git a/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java
index c28eed0..4ddea13 100644
--- a/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java
@@ -178,7 +178,7 @@
         // it's invalid app.
         verify(mCategory, times(1)).addPreference(any(Preference.class));
 
-        verify(mSeeAllPref).setTitle(R.string.see_all_apps_title);
+        verify(mSeeAllPref).setSummary(null);
         verify(mSeeAllPref).setIcon(R.drawable.ic_chevron_right_24dp);
     }