blob: 5041e0dccc26d444e726c37aee892edd19b12ca9 [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;
Jason Monkcafda1f2016-02-05 10:16:22 -050031import android.provider.Settings;
Jason Monk744b6362015-11-03 18:24:29 -050032import android.support.v4.widget.DrawerLayout;
Jason Monkfcad09a2016-06-07 14:01:32 -040033import android.util.ArraySet;
Jason Monke79790b2015-12-02 15:39:19 -050034import android.util.Log;
Jason Monk744b6362015-11-03 18:24:29 -050035import android.util.Pair;
36import android.view.Gravity;
37import android.view.LayoutInflater;
38import android.view.MenuItem;
39import android.view.View;
40import android.view.ViewGroup;
41import android.view.Window;
Jason Monkcafda1f2016-02-05 10:16:22 -050042import android.view.WindowManager.LayoutParams;
Jason Monk744b6362015-11-03 18:24:29 -050043import android.widget.AdapterView;
Fan Zhang7163d772016-03-29 10:30:13 -070044import android.widget.FrameLayout;
Jason Monk744b6362015-11-03 18:24:29 -050045import android.widget.ListView;
46import android.widget.Toolbar;
Fan Zhang7163d772016-03-29 10:30:13 -070047
Jason Monk744b6362015-11-03 18:24:29 -050048import com.android.settingslib.R;
Jason Monkec02e472016-03-28 10:44:43 -040049import com.android.settingslib.applications.InterestingConfigChanges;
Jason Monk744b6362015-11-03 18:24:29 -050050
Jason Monke79790b2015-12-02 15:39:19 -050051import java.util.ArrayList;
Jason Monk744b6362015-11-03 18:24:29 -050052import java.util.HashMap;
53import java.util.List;
54
55public class SettingsDrawerActivity extends Activity {
56
Jason Monke79790b2015-12-02 15:39:19 -050057 protected static final boolean DEBUG_TIMING = false;
58 private static final String TAG = "SettingsDrawerActivity";
Fan Zhang089a2c02016-09-15 14:28:19 -070059 private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
Jason Monke79790b2015-12-02 15:39:19 -050060
Clara Bayarri962694d2016-04-29 16:56:02 +010061 public static final String EXTRA_SHOW_MENU = "show_drawer_menu";
Jason Monk946483a2016-01-22 15:19:44 -050062
Jason Monkfcad09a2016-06-07 14:01:32 -040063 // Serves as a temporary list of tiles to ignore until we heard back from the PM that they
64 // are disabled.
65 private static ArraySet<ComponentName> sTileBlacklist = new ArraySet<>();
Jason Monke79790b2015-12-02 15:39:19 -050066
67 private final PackageReceiver mPackageReceiver = new PackageReceiver();
68 private final List<CategoryListener> mCategoryListeners = new ArrayList<>();
69
Jason Monk744b6362015-11-03 18:24:29 -050070 private SettingsDrawerAdapter mDrawerAdapter;
Fan Zhang7163d772016-03-29 10:30:13 -070071 private FrameLayout mContentHeaderContainer;
Jason Monk744b6362015-11-03 18:24:29 -050072 private DrawerLayout mDrawerLayout;
Jason Monk946483a2016-01-22 15:19:44 -050073 private boolean mShowingMenu;
Jason Monk744b6362015-11-03 18:24:29 -050074
Fan Zhang22a56d72016-09-27 17:52:00 -070075 // Remove below after new IA
76 @Deprecated
77 private static List<DashboardCategory> sDashboardCategories;
78 @Deprecated
79 private static HashMap<Pair<String, String>, Tile> sTileCache;
80 @Deprecated
81 private static InterestingConfigChanges sConfigTracker;
82 // Remove above after new IA
83
Jason Monk744b6362015-11-03 18:24:29 -050084 @Override
85 protected void onCreate(@Nullable Bundle savedInstanceState) {
86 super.onCreate(savedInstanceState);
87
Jason Monke79790b2015-12-02 15:39:19 -050088 long startTime = System.currentTimeMillis();
89
Udam Saini48987f62016-03-03 13:20:18 -080090 TypedArray theme = getTheme().obtainStyledAttributes(android.R.styleable.Theme);
91 if (!theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
92 getWindow().addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
93 getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
94 requestWindowFeature(Window.FEATURE_NO_TITLE);
95 }
Jason Monk744b6362015-11-03 18:24:29 -050096 super.setContentView(R.layout.settings_with_drawer);
Fan Zhang7163d772016-03-29 10:30:13 -070097 mContentHeaderContainer = (FrameLayout) findViewById(R.id.content_header_container);
Jason Monk744b6362015-11-03 18:24:29 -050098 mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
Jason Monk51a94232015-11-04 14:57:15 -050099 if (mDrawerLayout == null) {
100 return;
101 }
Jason Monk744b6362015-11-03 18:24:29 -0500102 Toolbar toolbar = (Toolbar) findViewById(R.id.action_bar);
Jason Monkf18a55d2015-11-12 10:52:21 -0500103 if (theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
104 toolbar.setVisibility(View.GONE);
105 mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
106 mDrawerLayout = null;
107 return;
108 }
Fan Zhangcf439c02017-01-03 13:06:11 -0800109 if (!isNavDrawerEnabled()) {
110 setIsDrawerPresent(false);
111 }
Fan Zhang22a56d72016-09-27 17:52:00 -0700112 if (!isDashboardFeatureEnabled()) {
113 getDashboardCategories();
114 }
Jason Monk744b6362015-11-03 18:24:29 -0500115 setActionBar(toolbar);
116 mDrawerAdapter = new SettingsDrawerAdapter(this);
117 ListView listView = (ListView) findViewById(R.id.left_drawer);
118 listView.setAdapter(mDrawerAdapter);
119 listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
120 public void onItemClick(android.widget.AdapterView<?> parent, View view, int position,
121 long id) {
122 onTileClicked(mDrawerAdapter.getTile(position));
Fan Zhangf311b742016-09-16 08:46:09 -0700123 }
Jason Monk744b6362015-11-03 18:24:29 -0500124 });
jackqdyuleidfc6ce52016-08-24 09:48:54 -0700125
Jason Monke79790b2015-12-02 15:39:19 -0500126 if (DEBUG_TIMING) Log.d(TAG, "onCreate took " + (System.currentTimeMillis() - startTime)
127 + " ms");
Jason Monk744b6362015-11-03 18:24:29 -0500128 }
129
130 @Override
131 public boolean onOptionsItemSelected(MenuItem item) {
Jason Monk946483a2016-01-22 15:19:44 -0500132 if (mShowingMenu && mDrawerLayout != null && item.getItemId() == android.R.id.home
Jason Monk51a94232015-11-04 14:57:15 -0500133 && mDrawerAdapter.getCount() != 0) {
Jason Monk744b6362015-11-03 18:24:29 -0500134 openDrawer();
135 return true;
136 }
137 return super.onOptionsItemSelected(item);
138 }
139
140 @Override
Fan Zhangcf439c02017-01-03 13:06:11 -0800141 public boolean onNavigateUp() {
142 if (!isNavDrawerEnabled()) {
143 finish();
144 return true;
145 }
146 return super.onNavigateUp();
147 }
148
149 @Override
Jason Monk744b6362015-11-03 18:24:29 -0500150 protected void onResume() {
151 super.onResume();
152
Jason Monk2a5d79a2015-12-03 10:51:58 -0500153 if (mDrawerLayout != null) {
154 final IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
155 filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
156 filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
157 filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
158 filter.addDataScheme("package");
159 registerReceiver(mPackageReceiver, filter);
Jason Monke79790b2015-12-02 15:39:19 -0500160
Fan Zhang22a56d72016-09-27 17:52:00 -0700161 if (isDashboardFeatureEnabled()) {
162 new CategoriesUpdateTask().execute();
163 } else {
164 new CategoriesUpdater().execute();
165 }
Jason Monk2a5d79a2015-12-03 10:51:58 -0500166 }
Fan Zhangf311b742016-09-16 08:46:09 -0700167 final Intent intent = getIntent();
168 if (intent != null) {
169 if (intent.hasExtra(EXTRA_SHOW_MENU)) {
170 if (intent.getBooleanExtra(EXTRA_SHOW_MENU, false)) {
171 // Intent explicitly set to show menu.
172 showMenuIcon();
173 }
174 } else if (isTopLevelTile(intent)) {
175 showMenuIcon();
176 }
Jason Monk946483a2016-01-22 15:19:44 -0500177 }
Jason Monke79790b2015-12-02 15:39:19 -0500178 }
179
180 @Override
181 protected void onPause() {
Jason Monk2a5d79a2015-12-03 10:51:58 -0500182 if (mDrawerLayout != null) {
183 unregisterReceiver(mPackageReceiver);
184 }
Jason Monke79790b2015-12-02 15:39:19 -0500185
186 super.onPause();
187 }
188
Fan Zhangf311b742016-09-16 08:46:09 -0700189 private boolean isTopLevelTile(Intent intent) {
190 final ComponentName componentName = intent.getComponent();
191 if (componentName == null) {
192 return false;
193 }
Fan Zhang22a56d72016-09-27 17:52:00 -0700194 if (isDashboardFeatureEnabled()) {
Fan Zhang5adc2662016-10-04 15:12:58 -0700195 final DashboardCategory homepageCategories = CategoryManager.get(this)
Fan Zhang22a56d72016-09-27 17:52:00 -0700196 .getTilesByCategory(this, CategoryKey.CATEGORY_HOMEPAGE);
197 return homepageCategories.containsComponent(componentName);
198 } else {
199 // Look for a tile that has the same component as incoming intent
200 final List<DashboardCategory> categories = getDashboardCategories();
201 for (DashboardCategory category : categories) {
202 if (category.containsComponent(componentName)) {
Fan Zhangf311b742016-09-16 08:46:09 -0700203 return true;
204 }
205 }
Fan Zhang22a56d72016-09-27 17:52:00 -0700206 if (DEBUG) {
207 Log.d(TAG, "Intent is not for top level settings " + intent);
208 }
209 return false;
Fan Zhangf311b742016-09-16 08:46:09 -0700210 }
Fan Zhangf311b742016-09-16 08:46:09 -0700211 }
212
Jason Monke79790b2015-12-02 15:39:19 -0500213 public void addCategoryListener(CategoryListener listener) {
214 mCategoryListeners.add(listener);
215 }
216
217 public void remCategoryListener(CategoryListener listener) {
218 mCategoryListeners.remove(listener);
Jason Monk744b6362015-11-03 18:24:29 -0500219 }
220
Anna Galusza1774a272016-02-01 15:44:00 -0800221 public void setIsDrawerPresent(boolean isPresent) {
Anna Galuszafb695c62016-02-02 10:06:05 -0800222 if (isPresent) {
Anna Galusza1774a272016-02-01 15:44:00 -0800223 mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
224 updateDrawer();
225 } else {
Udam Saini68dab672016-03-29 10:49:18 -0700226 if (mDrawerLayout != null) {
227 mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
228 mDrawerLayout = null;
229 }
Anna Galusza1774a272016-02-01 15:44:00 -0800230 }
231 }
232
Jason Monk744b6362015-11-03 18:24:29 -0500233 public void openDrawer() {
Jason Monk51a94232015-11-04 14:57:15 -0500234 if (mDrawerLayout != null) {
235 mDrawerLayout.openDrawer(Gravity.START);
236 }
Jason Monk744b6362015-11-03 18:24:29 -0500237 }
238
239 public void closeDrawer() {
Jason Monk51a94232015-11-04 14:57:15 -0500240 if (mDrawerLayout != null) {
241 mDrawerLayout.closeDrawers();
242 }
Jason Monk744b6362015-11-03 18:24:29 -0500243 }
244
Fan Zhang7163d772016-03-29 10:30:13 -0700245 public void setContentHeaderView(View headerView) {
246 mContentHeaderContainer.removeAllViews();
247 if (headerView != null) {
248 mContentHeaderContainer.addView(headerView);
249 }
250 }
251
Jason Monk744b6362015-11-03 18:24:29 -0500252 @Override
253 public void setContentView(@LayoutRes int layoutResID) {
Jason Monk4ea66572016-03-30 11:05:51 -0400254 final ViewGroup parent = (ViewGroup) findViewById(R.id.content_frame);
255 if (parent != null) {
256 parent.removeAllViews();
257 }
258 LayoutInflater.from(this).inflate(layoutResID, parent);
Jason Monk744b6362015-11-03 18:24:29 -0500259 }
260
261 @Override
262 public void setContentView(View view) {
263 ((ViewGroup) findViewById(R.id.content_frame)).addView(view);
264 }
265
266 @Override
267 public void setContentView(View view, ViewGroup.LayoutParams params) {
268 ((ViewGroup) findViewById(R.id.content_frame)).addView(view, params);
269 }
270
271 public void updateDrawer() {
Jason Monk51a94232015-11-04 14:57:15 -0500272 if (mDrawerLayout == null) {
273 return;
274 }
Jason Monk744b6362015-11-03 18:24:29 -0500275 // TODO: Do this in the background with some loading.
Fan Zhang22a56d72016-09-27 17:52:00 -0700276 if (isDashboardFeatureEnabled()) {
277 mDrawerAdapter.updateHomepageCategories();
278 } else {
279 mDrawerAdapter.updateCategories();
280 }
Jason Monk51a94232015-11-04 14:57:15 -0500281 if (mDrawerAdapter.getCount() != 0) {
282 mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
Jason Monk51a94232015-11-04 14:57:15 -0500283 } else {
284 mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
285 }
Jason Monk744b6362015-11-03 18:24:29 -0500286 }
287
Jason Monk946483a2016-01-22 15:19:44 -0500288 public void showMenuIcon() {
Jason Monk946483a2016-01-22 15:19:44 -0500289 getActionBar().setDisplayHomeAsUpEnabled(true);
Fan Zhangcf439c02017-01-03 13:06:11 -0800290 if (isNavDrawerEnabled()) {
291 mShowingMenu = true;
292 getActionBar().setHomeAsUpIndicator(R.drawable.ic_menu);
293 getActionBar().setHomeActionContentDescription(
294 R.string.content_description_menu_button);
295 }
Jason Monk946483a2016-01-22 15:19:44 -0500296 }
297
Jason Monke79790b2015-12-02 15:39:19 -0500298 public List<DashboardCategory> getDashboardCategories() {
Jason Monk2a5d79a2015-12-03 10:51:58 -0500299 if (sDashboardCategories == null) {
300 sTileCache = new HashMap<>();
Jason Monkec02e472016-03-28 10:44:43 -0400301 sConfigTracker = new InterestingConfigChanges();
Jason Monkb0ae8f82016-04-12 10:30:43 -0400302 // Apply initial current config.
303 sConfigTracker.applyNewConfig(getResources());
Jason Monk2a5d79a2015-12-03 10:51:58 -0500304 sDashboardCategories = TileUtils.getCategories(this, sTileCache);
305 }
Jason Monke79790b2015-12-02 15:39:19 -0500306 return sDashboardCategories;
307 }
308
309 protected void onCategoriesChanged() {
310 updateDrawer();
311 final int N = mCategoryListeners.size();
312 for (int i = 0; i < N; i++) {
313 mCategoryListeners.get(i).onCategoriesChanged();
Jason Monk744b6362015-11-03 18:24:29 -0500314 }
Jason Monk744b6362015-11-03 18:24:29 -0500315 }
316
Jason Monkf509d7e2016-01-07 16:22:53 -0500317 public boolean openTile(Tile tile) {
Jason Monk744b6362015-11-03 18:24:29 -0500318 closeDrawer();
Jason Monk3175a6e2015-11-30 15:05:35 -0500319 if (tile == null) {
Jason Monkcafda1f2016-02-05 10:16:22 -0500320 startActivity(new Intent(Settings.ACTION_SETTINGS).addFlags(
321 Intent.FLAG_ACTIVITY_CLEAR_TASK));
322 return true;
Jason Monk3175a6e2015-11-30 15:05:35 -0500323 }
Jason Monk6bea9502016-02-25 13:07:41 -0500324 try {
Fan Zhang11b65072016-10-31 16:45:00 -0700325 ProfileSelectDialog.updateUserHandlesIfNeeded(this /* context */, tile);
Jason Monk6bea9502016-02-25 13:07:41 -0500326 int numUserHandles = tile.userHandle.size();
327 if (numUserHandles > 1) {
328 ProfileSelectDialog.show(getFragmentManager(), tile);
329 return false;
330 } else if (numUserHandles == 1) {
331 // Show menu on top level items.
332 tile.intent.putExtra(EXTRA_SHOW_MENU, true);
333 tile.intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
334 startActivityAsUser(tile.intent, tile.userHandle.get(0));
335 } else {
336 // Show menu on top level items.
337 tile.intent.putExtra(EXTRA_SHOW_MENU, true);
338 tile.intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
339 startActivity(tile.intent);
340 }
341 } catch (ActivityNotFoundException e) {
342 Log.w(TAG, "Couldn't find tile " + tile.intent, e);
Jason Monk0d72d202015-11-04 13:16:00 -0500343 }
344 return true;
Jason Monk744b6362015-11-03 18:24:29 -0500345 }
346
Jason Monkf509d7e2016-01-07 16:22:53 -0500347 protected void onTileClicked(Tile tile) {
Jason Monk0d72d202015-11-04 13:16:00 -0500348 if (openTile(tile)) {
349 finish();
350 }
351 }
352
353 public void onProfileTileOpen() {
Jason Monk744b6362015-11-03 18:24:29 -0500354 finish();
355 }
Jason Monke79790b2015-12-02 15:39:19 -0500356
Jason Monkfcad09a2016-06-07 14:01:32 -0400357 public void setTileEnabled(ComponentName component, boolean enabled) {
358 PackageManager pm = getPackageManager();
359 int state = pm.getComponentEnabledSetting(component);
360 boolean isEnabled = state == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
361 if (isEnabled != enabled || state == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) {
362 if (enabled) {
363 sTileBlacklist.remove(component);
364 } else {
365 sTileBlacklist.add(component);
366 }
367 pm.setComponentEnabledSetting(component, enabled
368 ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
369 : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
370 PackageManager.DONT_KILL_APP);
Fan Zhang22a56d72016-09-27 17:52:00 -0700371 if (isDashboardFeatureEnabled()) {
372 new CategoriesUpdateTask().execute();
373 } else {
374 new CategoriesUpdater().execute();
375 }
Jason Monkfcad09a2016-06-07 14:01:32 -0400376 }
377 }
378
Jason Monke79790b2015-12-02 15:39:19 -0500379 public interface CategoryListener {
380 void onCategoriesChanged();
381 }
382
Fan Zhang22a56d72016-09-27 17:52:00 -0700383 /**
384 * @deprecated remove after new IA
385 */
386 @Deprecated
Jason Monke79790b2015-12-02 15:39:19 -0500387 private class CategoriesUpdater extends AsyncTask<Void, Void, List<DashboardCategory>> {
388 @Override
389 protected List<DashboardCategory> doInBackground(Void... params) {
Jason Monkec02e472016-03-28 10:44:43 -0400390 if (sConfigTracker.applyNewConfig(getResources())) {
391 sTileCache.clear();
392 }
Jason Monke79790b2015-12-02 15:39:19 -0500393 return TileUtils.getCategories(SettingsDrawerActivity.this, sTileCache);
394 }
395
396 @Override
Richard Ho8c4e4b02016-06-13 16:54:04 -0700397 protected void onPreExecute() {
398 if (sConfigTracker == null || sTileCache == null) {
399 getDashboardCategories();
400 }
401 }
402
403 @Override
Jason Monke79790b2015-12-02 15:39:19 -0500404 protected void onPostExecute(List<DashboardCategory> dashboardCategories) {
Jason Monkfcad09a2016-06-07 14:01:32 -0400405 for (int i = 0; i < dashboardCategories.size(); i++) {
406 DashboardCategory category = dashboardCategories.get(i);
407 for (int j = 0; j < category.tiles.size(); j++) {
408 Tile tile = category.tiles.get(j);
409 if (sTileBlacklist.contains(tile.intent.getComponent())) {
410 category.tiles.remove(j--);
411 }
412 }
413 }
Jason Monke79790b2015-12-02 15:39:19 -0500414 sDashboardCategories = dashboardCategories;
415 onCategoriesChanged();
416 }
417 }
418
Fan Zhang22a56d72016-09-27 17:52:00 -0700419 private class CategoriesUpdateTask extends AsyncTask<Void, Void, Void> {
420
421 private final CategoryManager mCategoryManager;
422
423 public CategoriesUpdateTask() {
Fan Zhang5adc2662016-10-04 15:12:58 -0700424 mCategoryManager = CategoryManager.get(SettingsDrawerActivity.this);
Fan Zhang22a56d72016-09-27 17:52:00 -0700425 }
426
427 @Override
428 protected Void doInBackground(Void... params) {
Fan Zhangc8a5b792016-10-03 15:05:53 -0700429 mCategoryManager.reloadAllCategories(SettingsDrawerActivity.this);
Fan Zhang22a56d72016-09-27 17:52:00 -0700430 return null;
431 }
432
433 @Override
434 protected void onPostExecute(Void result) {
435 mCategoryManager.updateCategoryFromBlacklist(sTileBlacklist);
436 onCategoriesChanged();
437 }
438 }
439
440 protected boolean isDashboardFeatureEnabled() {
441 return false;
442 }
443
Fan Zhangcf439c02017-01-03 13:06:11 -0800444 boolean isNavDrawerEnabled() {
445 return !isDashboardFeatureEnabled()
446 || getResources().getBoolean(R.bool.config_enable_nav_drawer);
447 }
448
Jason Monke79790b2015-12-02 15:39:19 -0500449 private class PackageReceiver extends BroadcastReceiver {
450 @Override
451 public void onReceive(Context context, Intent intent) {
Fan Zhang22a56d72016-09-27 17:52:00 -0700452 if (isDashboardFeatureEnabled()) {
453 new CategoriesUpdateTask().execute();
454 } else {
455 new CategoriesUpdater().execute();
456 }
Jason Monke79790b2015-12-02 15:39:19 -0500457 }
458 }
Jason Monk744b6362015-11-03 18:24:29 -0500459}