Add recent apps in app & notification

- Introduce a RecentAppsPreferenceControler, which queries
  UsageStatsManager and displays a list of recently used apps.

- Add a control flag for this feature, intially set to false.

- Make ManageApplications a static pref item instead of dynamic one.
  This makes the RecentAppController easier to control "See all"
  preference, which is backed by ManageApplications.

- Also adjust app_items.xml layout to make app item UI consistent with
  preference item.

Change-Id: I0b9e1784faed32b3055ebf96ef98b6a5e422de50
Fix: 33265548
Test: robotests
This commit is contained in:
fanzhang172
2017-05-01 19:15:17 -07:00
committed by Fan Zhang
parent c90502627b
commit ae2f2b5268
10 changed files with 596 additions and 14 deletions

View File

@@ -16,6 +16,9 @@
package com.android.settings.applications;
import android.app.Activity;
import android.app.Application;
import android.app.Fragment;
import android.content.Context;
import android.provider.SearchIndexableResource;
@@ -56,13 +59,22 @@ public class AppAndNotificationDashboardFragment extends DashboardFragment {
@Override
protected List<PreferenceController> getPreferenceControllers(Context context) {
return buildPreferenceControllers(context);
final Activity activity = getActivity();
final Application app;
if (activity != null) {
app = activity.getApplication();
} else {
app = null;
}
return buildPreferenceControllers(context, app, this);
}
private static List<PreferenceController> buildPreferenceControllers(Context context) {
private static List<PreferenceController> buildPreferenceControllers(Context context,
Application app, Fragment host) {
final List<PreferenceController> controllers = new ArrayList<>();
controllers.add(new SpecialAppAccessPreferenceController(context));
controllers.add(new AppPermissionsPreferenceController(context));
controllers.add(new RecentAppsPreferenceController(context, app, host));
return controllers;
}
@@ -78,7 +90,7 @@ public class AppAndNotificationDashboardFragment extends DashboardFragment {
@Override
public List<PreferenceController> getPreferenceControllers(Context context) {
return buildPreferenceControllers(context);
return buildPreferenceControllers(context, null, null /* host */);
}
};
}