blob: bad7ba4047abe1a197145c602c5e32c331d7ea0d [file] [log] [blame]
Jason Monk744b6362015-11-03 18:24:29 -05001/**
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.android.settingslib.drawer;
17
18import android.annotation.LayoutRes;
19import android.annotation.Nullable;
20import android.app.Activity;
Jason Monk6bea9502016-02-25 13:07:41 -050021import android.content.ActivityNotFoundException;
Jason Monke79790b2015-12-02 15:39:19 -050022import android.content.BroadcastReceiver;
Jason Monkfcad09a2016-06-07 14:01:32 -040023import android.content.ComponentName;
Jason Monke79790b2015-12-02 15:39:19 -050024import android.content.Context;
25import android.content.Intent;
26import android.content.IntentFilter;
Jason Monkfcad09a2016-06-07 14:01:32 -040027import android.content.pm.PackageManager;
Jason Monkf18a55d2015-11-12 10:52:21 -050028import android.content.res.TypedArray;
Jason Monke79790b2015-12-02 15:39:19 -050029import android.os.AsyncTask;
Jason Monk744b6362015-11-03 18:24:29 -050030import android.os.Bundle;
jackqdyuleidfc6ce52016-08-24 09:48:54 -070031import android.os.UserHandle;
32import android.os.UserManager;
Jason Monkcafda1f2016-02-05 10:16:22 -050033import android.provider.Settings;
jackqdyulei8accac92016-09-13 15:07:42 -070034import android.support.annotation.VisibleForTesting;
Jason Monk744b6362015-11-03 18:24:29 -050035import android.support.v4.widget.DrawerLayout;
Jason Monkfcad09a2016-06-07 14:01:32 -040036import android.util.ArraySet;
Jason Monke79790b2015-12-02 15:39:19 -050037import android.util.Log;
Jason Monk744b6362015-11-03 18:24:29 -050038import android.util.Pair;
39import android.view.Gravity;
40import android.view.LayoutInflater;
41import android.view.MenuItem;
42import android.view.View;
43import android.view.ViewGroup;
44import android.view.Window;
Jason Monkcafda1f2016-02-05 10:16:22 -050045import android.view.WindowManager.LayoutParams;
Jason Monk744b6362015-11-03 18:24:29 -050046import android.widget.AdapterView;
Fan Zhang7163d772016-03-29 10:30:13 -070047import android.widget.FrameLayout;
Jason Monk744b6362015-11-03 18:24:29 -050048import android.widget.ListView;
49import android.widget.Toolbar;
Fan Zhang7163d772016-03-29 10:30:13 -070050
Jason Monk744b6362015-11-03 18:24:29 -050051import com.android.settingslib.R;
Jason Monkec02e472016-03-28 10:44:43 -040052import com.android.settingslib.applications.InterestingConfigChanges;
Jason Monk744b6362015-11-03 18:24:29 -050053
Jason Monke79790b2015-12-02 15:39:19 -050054import java.util.ArrayList;
Jason Monk744b6362015-11-03 18:24:29 -050055import java.util.HashMap;
56import java.util.List;
57
58public class SettingsDrawerActivity extends Activity {
59
Jason Monke79790b2015-12-02 15:39:19 -050060 protected static final boolean DEBUG_TIMING = false;
61 private static final String TAG = "SettingsDrawerActivity";
Fan Zhang089a2c02016-09-15 14:28:19 -070062 private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
Jason Monke79790b2015-12-02 15:39:19 -050063
Clara Bayarri962694d2016-04-29 16:56:02 +010064 public static final String EXTRA_SHOW_MENU = "show_drawer_menu";
Jason Monk946483a2016-01-22 15:19:44 -050065
Jason Monkfcad09a2016-06-07 14:01:32 -040066 // Serves as a temporary list of tiles to ignore until we heard back from the PM that they
67 // are disabled.
68 private static ArraySet<ComponentName> sTileBlacklist = new ArraySet<>();
Jason Monke79790b2015-12-02 15:39:19 -050069
70 private final PackageReceiver mPackageReceiver = new PackageReceiver();
71 private final List<CategoryListener> mCategoryListeners = new ArrayList<>();
72
Jason Monk744b6362015-11-03 18:24:29 -050073 private SettingsDrawerAdapter mDrawerAdapter;
Fan Zhang7163d772016-03-29 10:30:13 -070074 private FrameLayout mContentHeaderContainer;
Jason Monk744b6362015-11-03 18:24:29 -050075 private DrawerLayout mDrawerLayout;
Jason Monk946483a2016-01-22 15:19:44 -050076 private boolean mShowingMenu;
jackqdyuleidfc6ce52016-08-24 09:48:54 -070077 private UserManager mUserManager;
Jason Monk744b6362015-11-03 18:24:29 -050078
Fan Zhang22a56d72016-09-27 17:52:00 -070079 // Remove below after new IA
80 @Deprecated
81 private static List<DashboardCategory> sDashboardCategories;
82 @Deprecated
83 private static HashMap<Pair<String, String>, Tile> sTileCache;
84 @Deprecated
85 private static InterestingConfigChanges sConfigTracker;
86 // Remove above after new IA
87
Jason Monk744b6362015-11-03 18:24:29 -050088 @Override
89 protected void onCreate(@Nullable Bundle savedInstanceState) {
90 super.onCreate(savedInstanceState);
91
Jason Monke79790b2015-12-02 15:39:19 -050092 long startTime = System.currentTimeMillis();
93
Udam Saini48987f62016-03-03 13:20:18 -080094 TypedArray theme = getTheme().obtainStyledAttributes(android.R.styleable.Theme);
95 if (!theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
96 getWindow().addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
97 getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
98 requestWindowFeature(Window.FEATURE_NO_TITLE);
99 }
Jason Monk744b6362015-11-03 18:24:29 -0500100 super.setContentView(R.layout.settings_with_drawer);
Fan Zhang7163d772016-03-29 10:30:13 -0700101 mContentHeaderContainer = (FrameLayout) findViewById(R.id.content_header_container);
Jason Monk744b6362015-11-03 18:24:29 -0500102 mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
Jason Monk51a94232015-11-04 14:57:15 -0500103 if (mDrawerLayout == null) {
104 return;
105 }
Jason Monk744b6362015-11-03 18:24:29 -0500106 Toolbar toolbar = (Toolbar) findViewById(R.id.action_bar);
Jason Monkf18a55d2015-11-12 10:52:21 -0500107 if (theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
108 toolbar.setVisibility(View.GONE);
109 mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
110 mDrawerLayout = null;
111 return;
112 }
Fan Zhang22a56d72016-09-27 17:52:00 -0700113 if (!isDashboardFeatureEnabled()) {
114 getDashboardCategories();
115 }
Jason Monk744b6362015-11-03 18:24:29 -0500116 setActionBar(toolbar);
117 mDrawerAdapter = new SettingsDrawerAdapter(this);
118 ListView listView = (ListView) findViewById(R.id.left_drawer);
119 listView.setAdapter(mDrawerAdapter);
120 listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
121 public void onItemClick(android.widget.AdapterView<?> parent, View view, int position,
122 long id) {
123 onTileClicked(mDrawerAdapter.getTile(position));
Fan Zhangf311b742016-09-16 08:46:09 -0700124 }
Jason Monk744b6362015-11-03 18:24:29 -0500125 });
jackqdyuleidfc6ce52016-08-24 09:48:54 -0700126
127 mUserManager = UserManager.get(this);
Jason Monke79790b2015-12-02 15:39:19 -0500128 if (DEBUG_TIMING) Log.d(TAG, "onCreate took " + (System.currentTimeMillis() - startTime)
129 + " ms");
Jason Monk744b6362015-11-03 18:24:29 -0500130 }
131
132 @Override
133 public boolean onOptionsItemSelected(MenuItem item) {
Jason Monk946483a2016-01-22 15:19:44 -0500134 if (mShowingMenu && mDrawerLayout != null && item.getItemId() == android.R.id.home
Jason Monk51a94232015-11-04 14:57:15 -0500135 && mDrawerAdapter.getCount() != 0) {
Jason Monk744b6362015-11-03 18:24:29 -0500136 openDrawer();
137 return true;
138 }
139 return super.onOptionsItemSelected(item);
140 }
141
142 @Override
143 protected void onResume() {
144 super.onResume();
145
Jason Monk2a5d79a2015-12-03 10:51:58 -0500146 if (mDrawerLayout != null) {
147 final IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
148 filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
149 filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
150 filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
151 filter.addDataScheme("package");
152 registerReceiver(mPackageReceiver, filter);
Jason Monke79790b2015-12-02 15:39:19 -0500153
Fan Zhang22a56d72016-09-27 17:52:00 -0700154 if (isDashboardFeatureEnabled()) {
155 new CategoriesUpdateTask().execute();
156 } else {
157 new CategoriesUpdater().execute();
158 }
Jason Monk2a5d79a2015-12-03 10:51:58 -0500159 }
Fan Zhangf311b742016-09-16 08:46:09 -0700160 final Intent intent = getIntent();
161 if (intent != null) {
162 if (intent.hasExtra(EXTRA_SHOW_MENU)) {
163 if (intent.getBooleanExtra(EXTRA_SHOW_MENU, false)) {
164 // Intent explicitly set to show menu.
165 showMenuIcon();
166 }
167 } else if (isTopLevelTile(intent)) {
168 showMenuIcon();
169 }
Jason Monk946483a2016-01-22 15:19:44 -0500170 }
Jason Monke79790b2015-12-02 15:39:19 -0500171 }
172
173 @Override
174 protected void onPause() {
Jason Monk2a5d79a2015-12-03 10:51:58 -0500175 if (mDrawerLayout != null) {
176 unregisterReceiver(mPackageReceiver);
177 }
Jason Monke79790b2015-12-02 15:39:19 -0500178
179 super.onPause();
180 }
181
Fan Zhangf311b742016-09-16 08:46:09 -0700182 private boolean isTopLevelTile(Intent intent) {
183 final ComponentName componentName = intent.getComponent();
184 if (componentName == null) {
185 return false;
186 }
Fan Zhang22a56d72016-09-27 17:52:00 -0700187 if (isDashboardFeatureEnabled()) {
Fan Zhang5adc2662016-10-04 15:12:58 -0700188 final DashboardCategory homepageCategories = CategoryManager.get(this)
Fan Zhang22a56d72016-09-27 17:52:00 -0700189 .getTilesByCategory(this, CategoryKey.CATEGORY_HOMEPAGE);
190 return homepageCategories.containsComponent(componentName);
191 } else {
192 // Look for a tile that has the same component as incoming intent
193 final List<DashboardCategory> categories = getDashboardCategories();
194 for (DashboardCategory category : categories) {
195 if (category.containsComponent(componentName)) {
Fan Zhangf311b742016-09-16 08:46:09 -0700196 return true;
197 }
198 }
Fan Zhang22a56d72016-09-27 17:52:00 -0700199 if (DEBUG) {
200 Log.d(TAG, "Intent is not for top level settings " + intent);
201 }
202 return false;
Fan Zhangf311b742016-09-16 08:46:09 -0700203 }
Fan Zhangf311b742016-09-16 08:46:09 -0700204 }
205
Jason Monke79790b2015-12-02 15:39:19 -0500206 public void addCategoryListener(CategoryListener listener) {
207 mCategoryListeners.add(listener);
208 }
209
210 public void remCategoryListener(CategoryListener listener) {
211 mCategoryListeners.remove(listener);
Jason Monk744b6362015-11-03 18:24:29 -0500212 }
213
Anna Galusza1774a272016-02-01 15:44:00 -0800214 public void setIsDrawerPresent(boolean isPresent) {
Anna Galuszafb695c62016-02-02 10:06:05 -0800215 if (isPresent) {
Anna Galusza1774a272016-02-01 15:44:00 -0800216 mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
217 updateDrawer();
218 } else {
Udam Saini68dab672016-03-29 10:49:18 -0700219 if (mDrawerLayout != null) {
220 mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
221 mDrawerLayout = null;
222 }
Anna Galusza1774a272016-02-01 15:44:00 -0800223 }
224 }
225
Jason Monk744b6362015-11-03 18:24:29 -0500226 public void openDrawer() {
Jason Monk51a94232015-11-04 14:57:15 -0500227 if (mDrawerLayout != null) {
228 mDrawerLayout.openDrawer(Gravity.START);
229 }
Jason Monk744b6362015-11-03 18:24:29 -0500230 }
231
232 public void closeDrawer() {
Jason Monk51a94232015-11-04 14:57:15 -0500233 if (mDrawerLayout != null) {
234 mDrawerLayout.closeDrawers();
235 }
Jason Monk744b6362015-11-03 18:24:29 -0500236 }
237
Fan Zhang7163d772016-03-29 10:30:13 -0700238 public void setContentHeaderView(View headerView) {
239 mContentHeaderContainer.removeAllViews();
240 if (headerView != null) {
241 mContentHeaderContainer.addView(headerView);
242 }
243 }
244
Jason Monk744b6362015-11-03 18:24:29 -0500245 @Override
246 public void setContentView(@LayoutRes int layoutResID) {
Jason Monk4ea66572016-03-30 11:05:51 -0400247 final ViewGroup parent = (ViewGroup) findViewById(R.id.content_frame);
248 if (parent != null) {
249 parent.removeAllViews();
250 }
251 LayoutInflater.from(this).inflate(layoutResID, parent);
Jason Monk744b6362015-11-03 18:24:29 -0500252 }
253
254 @Override
255 public void setContentView(View view) {
256 ((ViewGroup) findViewById(R.id.content_frame)).addView(view);
257 }
258
259 @Override
260 public void setContentView(View view, ViewGroup.LayoutParams params) {
261 ((ViewGroup) findViewById(R.id.content_frame)).addView(view, params);
262 }
263
264 public void updateDrawer() {
Jason Monk51a94232015-11-04 14:57:15 -0500265 if (mDrawerLayout == null) {
266 return;
267 }
Jason Monk744b6362015-11-03 18:24:29 -0500268 // TODO: Do this in the background with some loading.
Fan Zhang22a56d72016-09-27 17:52:00 -0700269 if (isDashboardFeatureEnabled()) {
270 mDrawerAdapter.updateHomepageCategories();
271 } else {
272 mDrawerAdapter.updateCategories();
273 }
Jason Monk51a94232015-11-04 14:57:15 -0500274 if (mDrawerAdapter.getCount() != 0) {
275 mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
Jason Monk51a94232015-11-04 14:57:15 -0500276 } else {
277 mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
278 }
Jason Monk744b6362015-11-03 18:24:29 -0500279 }
280
Jason Monk946483a2016-01-22 15:19:44 -0500281 public void showMenuIcon() {
282 mShowingMenu = true;
283 getActionBar().setHomeAsUpIndicator(R.drawable.ic_menu);
Fan Zhangc10db982016-08-11 13:52:04 -0700284 getActionBar().setHomeActionContentDescription(R.string.content_description_menu_button);
Jason Monk946483a2016-01-22 15:19:44 -0500285 getActionBar().setDisplayHomeAsUpEnabled(true);
286 }
287
Jason Monke79790b2015-12-02 15:39:19 -0500288 public List<DashboardCategory> getDashboardCategories() {
Jason Monk2a5d79a2015-12-03 10:51:58 -0500289 if (sDashboardCategories == null) {
290 sTileCache = new HashMap<>();
Jason Monkec02e472016-03-28 10:44:43 -0400291 sConfigTracker = new InterestingConfigChanges();
Jason Monkb0ae8f82016-04-12 10:30:43 -0400292 // Apply initial current config.
293 sConfigTracker.applyNewConfig(getResources());
Jason Monk2a5d79a2015-12-03 10:51:58 -0500294 sDashboardCategories = TileUtils.getCategories(this, sTileCache);
295 }
Jason Monke79790b2015-12-02 15:39:19 -0500296 return sDashboardCategories;
297 }
298
299 protected void onCategoriesChanged() {
300 updateDrawer();
301 final int N = mCategoryListeners.size();
302 for (int i = 0; i < N; i++) {
303 mCategoryListeners.get(i).onCategoriesChanged();
Jason Monk744b6362015-11-03 18:24:29 -0500304 }
Jason Monk744b6362015-11-03 18:24:29 -0500305 }
306
Jason Monkf509d7e2016-01-07 16:22:53 -0500307 public boolean openTile(Tile tile) {
Jason Monk744b6362015-11-03 18:24:29 -0500308 closeDrawer();
Jason Monk3175a6e2015-11-30 15:05:35 -0500309 if (tile == null) {
Jason Monkcafda1f2016-02-05 10:16:22 -0500310 startActivity(new Intent(Settings.ACTION_SETTINGS).addFlags(
311 Intent.FLAG_ACTIVITY_CLEAR_TASK));
312 return true;
Jason Monk3175a6e2015-11-30 15:05:35 -0500313 }
Jason Monk6bea9502016-02-25 13:07:41 -0500314 try {
jackqdyuleidfc6ce52016-08-24 09:48:54 -0700315 updateUserHandlesIfNeeded(tile);
Jason Monk6bea9502016-02-25 13:07:41 -0500316 int numUserHandles = tile.userHandle.size();
317 if (numUserHandles > 1) {
318 ProfileSelectDialog.show(getFragmentManager(), tile);
319 return false;
320 } else if (numUserHandles == 1) {
321 // Show menu on top level items.
322 tile.intent.putExtra(EXTRA_SHOW_MENU, true);
323 tile.intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
324 startActivityAsUser(tile.intent, tile.userHandle.get(0));
325 } else {
326 // Show menu on top level items.
327 tile.intent.putExtra(EXTRA_SHOW_MENU, true);
328 tile.intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
329 startActivity(tile.intent);
330 }
331 } catch (ActivityNotFoundException e) {
332 Log.w(TAG, "Couldn't find tile " + tile.intent, e);
Jason Monk0d72d202015-11-04 13:16:00 -0500333 }
334 return true;
Jason Monk744b6362015-11-03 18:24:29 -0500335 }
336
jackqdyuleidfc6ce52016-08-24 09:48:54 -0700337 private void updateUserHandlesIfNeeded(Tile tile) {
338 List<UserHandle> userHandles = tile.userHandle;
339
Fan Zhangf311b742016-09-16 08:46:09 -0700340 for (int i = userHandles.size() - 1; i >= 0; i--) {
jackqdyuleidfc6ce52016-08-24 09:48:54 -0700341 if (mUserManager.getUserInfo(userHandles.get(i).getIdentifier()) == null) {
Fan Zhang089a2c02016-09-15 14:28:19 -0700342 if (DEBUG) {
jackqdyuleidfc6ce52016-08-24 09:48:54 -0700343 Log.d(TAG, "Delete the user: " + userHandles.get(i).getIdentifier());
344 }
345 userHandles.remove(i);
346 }
347 }
348 }
349
jackqdyulei8accac92016-09-13 15:07:42 -0700350 @VisibleForTesting
351 public void setUserManager(UserManager userManager) {
352 mUserManager = userManager;
353 }
354
Jason Monkf509d7e2016-01-07 16:22:53 -0500355 protected void onTileClicked(Tile tile) {
Jason Monk0d72d202015-11-04 13:16:00 -0500356 if (openTile(tile)) {
357 finish();
358 }
359 }
360
361 public void onProfileTileOpen() {
Jason Monk744b6362015-11-03 18:24:29 -0500362 finish();
363 }
Jason Monke79790b2015-12-02 15:39:19 -0500364
Jason Monkfcad09a2016-06-07 14:01:32 -0400365 public void setTileEnabled(ComponentName component, boolean enabled) {
366 PackageManager pm = getPackageManager();
367 int state = pm.getComponentEnabledSetting(component);
368 boolean isEnabled = state == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
369 if (isEnabled != enabled || state == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) {
370 if (enabled) {
371 sTileBlacklist.remove(component);
372 } else {
373 sTileBlacklist.add(component);
374 }
375 pm.setComponentEnabledSetting(component, enabled
376 ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
377 : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
378 PackageManager.DONT_KILL_APP);
Fan Zhang22a56d72016-09-27 17:52:00 -0700379 if (isDashboardFeatureEnabled()) {
380 new CategoriesUpdateTask().execute();
381 } else {
382 new CategoriesUpdater().execute();
383 }
Jason Monkfcad09a2016-06-07 14:01:32 -0400384 }
385 }
386
Jason Monke79790b2015-12-02 15:39:19 -0500387 public interface CategoryListener {
388 void onCategoriesChanged();
389 }
390
Fan Zhang22a56d72016-09-27 17:52:00 -0700391 /**
392 * @deprecated remove after new IA
393 */
394 @Deprecated
Jason Monke79790b2015-12-02 15:39:19 -0500395 private class CategoriesUpdater extends AsyncTask<Void, Void, List<DashboardCategory>> {
396 @Override
397 protected List<DashboardCategory> doInBackground(Void... params) {
Jason Monkec02e472016-03-28 10:44:43 -0400398 if (sConfigTracker.applyNewConfig(getResources())) {
399 sTileCache.clear();
400 }
Jason Monke79790b2015-12-02 15:39:19 -0500401 return TileUtils.getCategories(SettingsDrawerActivity.this, sTileCache);
402 }
403
404 @Override
Richard Ho8c4e4b02016-06-13 16:54:04 -0700405 protected void onPreExecute() {
406 if (sConfigTracker == null || sTileCache == null) {
407 getDashboardCategories();
408 }
409 }
410
411 @Override
Jason Monke79790b2015-12-02 15:39:19 -0500412 protected void onPostExecute(List<DashboardCategory> dashboardCategories) {
Jason Monkfcad09a2016-06-07 14:01:32 -0400413 for (int i = 0; i < dashboardCategories.size(); i++) {
414 DashboardCategory category = dashboardCategories.get(i);
415 for (int j = 0; j < category.tiles.size(); j++) {
416 Tile tile = category.tiles.get(j);
417 if (sTileBlacklist.contains(tile.intent.getComponent())) {
418 category.tiles.remove(j--);
419 }
420 }
421 }
Jason Monke79790b2015-12-02 15:39:19 -0500422 sDashboardCategories = dashboardCategories;
423 onCategoriesChanged();
424 }
425 }
426
Fan Zhang22a56d72016-09-27 17:52:00 -0700427 private class CategoriesUpdateTask extends AsyncTask<Void, Void, Void> {
428
429 private final CategoryManager mCategoryManager;
430
431 public CategoriesUpdateTask() {
Fan Zhang5adc2662016-10-04 15:12:58 -0700432 mCategoryManager = CategoryManager.get(SettingsDrawerActivity.this);
Fan Zhang22a56d72016-09-27 17:52:00 -0700433 }
434
435 @Override
436 protected Void doInBackground(Void... params) {
Fan Zhangc8a5b792016-10-03 15:05:53 -0700437 mCategoryManager.reloadAllCategories(SettingsDrawerActivity.this);
Fan Zhang22a56d72016-09-27 17:52:00 -0700438 return null;
439 }
440
441 @Override
442 protected void onPostExecute(Void result) {
443 mCategoryManager.updateCategoryFromBlacklist(sTileBlacklist);
444 onCategoriesChanged();
445 }
446 }
447
448 protected boolean isDashboardFeatureEnabled() {
449 return false;
450 }
451
Jason Monke79790b2015-12-02 15:39:19 -0500452 private class PackageReceiver extends BroadcastReceiver {
453 @Override
454 public void onReceive(Context context, Intent intent) {
Fan Zhang22a56d72016-09-27 17:52:00 -0700455 if (isDashboardFeatureEnabled()) {
456 new CategoriesUpdateTask().execute();
457 } else {
458 new CategoriesUpdater().execute();
459 }
Jason Monke79790b2015-12-02 15:39:19 -0500460 }
461 }
Jason Monk744b6362015-11-03 18:24:29 -0500462}