summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2019-09-05 16:53:18 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-09-05 16:53:18 +0000
commitd7a8e234e9b94ff36cd271555a0bbf8a01a10932 (patch)
treeb6c98b0e3e76f797dbc57e77a8aac776ca1d1324 /src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
parent1e53efc4c48ec80421bb0542b770332ab8efdab5 (diff)
parent7195e05dfaf1c848a7af9b844cd8bd05e9c220fe (diff)
downloadpackages_apps_Settings-d7a8e234e9b94ff36cd271555a0bbf8a01a10932.tar.gz
packages_apps_Settings-d7a8e234e9b94ff36cd271555a0bbf8a01a10932.tar.bz2
packages_apps_Settings-d7a8e234e9b94ff36cd271555a0bbf8a01a10932.zip
Merge "DO NOT MERGE - Merge Android 10 into master"
Diffstat (limited to 'src/com/android/settings/applications/AppAndNotificationDashboardFragment.java')
-rw-r--r--src/com/android/settings/applications/AppAndNotificationDashboardFragment.java96
1 files changed, 70 insertions, 26 deletions
diff --git a/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java b/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
index eb74fb1386..5e57908035 100644
--- a/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
+++ b/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
@@ -16,30 +16,43 @@
package com.android.settings.applications;
-import android.app.Activity;
-import android.app.Application;
-import android.app.Fragment;
+import android.app.settings.SettingsEnums;
+import android.app.usage.UsageStats;
import android.content.Context;
+import android.os.Bundle;
import android.provider.SearchIndexableResource;
+import android.view.View;
+
+import androidx.annotation.NonNull;
-import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
+import com.android.settings.Utils;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.notification.EmergencyBroadcastPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.widget.AppEntitiesHeaderController;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-public class AppAndNotificationDashboardFragment extends DashboardFragment {
+@SearchIndexable
+public class AppAndNotificationDashboardFragment extends DashboardFragment
+ implements RecentAppStatsMixin.RecentAppStatsListener {
private static final String TAG = "AppAndNotifDashboard";
+ private View mProgressHeader;
+ private View mProgressAnimation;
+ private RecentAppStatsMixin mRecentAppStatsMixin;
+ private RecentAppsPreferenceController mRecentAppsPreferenceController;
+ private AllAppsInfoPreferenceController mAllAppsInfoPreferenceController;
+
@Override
public int getMetricsCategory() {
- return MetricsProto.MetricsEvent.SETTINGS_APP_NOTIF_CATEGORY;
+ return SettingsEnums.SETTINGS_APP_NOTIF_CATEGORY;
}
@Override
@@ -58,24 +71,63 @@ public class AppAndNotificationDashboardFragment extends DashboardFragment {
}
@Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+
+ use(SpecialAppAccessPreferenceController.class).setSession(getSettingsLifecycle());
+
+ mRecentAppStatsMixin = new RecentAppStatsMixin(context,
+ AppEntitiesHeaderController.MAXIMUM_APPS);
+ getSettingsLifecycle().addObserver(mRecentAppStatsMixin);
+ mRecentAppStatsMixin.addListener(this);
+
+ mRecentAppsPreferenceController = use(RecentAppsPreferenceController.class);
+ mRecentAppsPreferenceController.setFragment(this /* fragment */);
+ mRecentAppStatsMixin.addListener(mRecentAppsPreferenceController);
+
+ mAllAppsInfoPreferenceController = use(AllAppsInfoPreferenceController.class);
+ mRecentAppStatsMixin.addListener(mAllAppsInfoPreferenceController);
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ mProgressHeader = setPinnedHeaderView(R.layout.progress_header);
+ mProgressAnimation = mProgressHeader.findViewById(R.id.progress_bar_animation);
+ setLoadingEnabled(false);
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ setLoadingEnabled(true);
+ }
+
+ @Override
+ public void onReloadDataCompleted(@NonNull List<UsageStats> recentApps) {
+ setLoadingEnabled(false);
+ if (!recentApps.isEmpty()) {
+ Utils.setActionBarShadowAnimation(getActivity(), getSettingsLifecycle(),
+ getListView());
+ }
+ }
+
+ @Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
- final Activity activity = getActivity();
- final Application app;
- if (activity != null) {
- app = activity.getApplication();
- } else {
- app = null;
+ return buildPreferenceControllers(context);
+ }
+
+ private void setLoadingEnabled(boolean enabled) {
+ if (mProgressHeader != null && mProgressAnimation != null) {
+ mProgressHeader.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
+ mProgressAnimation.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
}
- return buildPreferenceControllers(context, app, this);
}
- private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
- Application app, Fragment host) {
+ private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new EmergencyBroadcastPreferenceController(context,
"app_and_notif_cell_broadcast_settings"));
- controllers.add(new SpecialAppAccessPreferenceController(context));
- controllers.add(new RecentAppsPreferenceController(context, app, host));
return controllers;
}
@@ -92,15 +144,7 @@ public class AppAndNotificationDashboardFragment extends DashboardFragment {
@Override
public List<AbstractPreferenceController> createPreferenceControllers(
Context context) {
- return buildPreferenceControllers(context, null, null /* host */);
- }
-
- @Override
- public List<String> getNonIndexableKeys(Context context) {
- List<String> keys = super.getNonIndexableKeys(context);
- keys.add((new SpecialAppAccessPreferenceController(context))
- .getPreferenceKey());
- return keys;
+ return buildPreferenceControllers(context);
}
};
}