Merge "Update recently opened app string and "see all" summary"

This commit is contained in:
TreeHugger Robot
2017-05-27 00:13:01 +00:00
committed by Android (Google) Code Review
5 changed files with 14 additions and 9 deletions

View File

@@ -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"

View File

@@ -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">

View File

@@ -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"

View File

@@ -77,6 +77,7 @@ public class RecentAppsPreferenceController extends PreferenceController
private PreferenceCategory mCategory;
private Preference mSeeAllPref;
private boolean mHasRecentApps;
static {
SKIP_SYSTEM_PACKAGES.addAll(Arrays.asList(
@@ -133,15 +134,20 @@ public class RecentAppsPreferenceController extends PreferenceController
@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 @@ public class RecentAppsPreferenceController extends PreferenceController
reloadData();
final List<UsageStats> recentApps = getDisplayableRecentAppList();
if (recentApps != null && !recentApps.isEmpty()) {
mHasRecentApps = true;
displayRecentApps(prefContext, recentApps);
} else {
mHasRecentApps = false;
displayOnlyAppInfo();
}
}
@@ -185,7 +193,7 @@ public class RecentAppsPreferenceController extends PreferenceController
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.

View File

@@ -178,7 +178,7 @@ public class RecentAppsPreferenceControllerTest {
// 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);
}