summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYvonne Wong <ywong@cyngn.com>2015-12-07 17:41:38 -0800
committerYvonne Wong <ywong@cyngn.com>2015-12-08 15:14:43 -0800
commitd0c2bbfb775fbdd16d7c81e82c828c3134e633e0 (patch)
tree6117f9beaebe8a4c9ac0aad1fe9036d4c2c4afed
parent68434271efc7c4d0c7cac15de19a6befa2787150 (diff)
downloadandroid_packages_apps_Trebuchet-d0c2bbfb775fbdd16d7c81e82c828c3134e633e0.tar.gz
android_packages_apps_Trebuchet-d0c2bbfb775fbdd16d7c81e82c828c3134e633e0.tar.bz2
android_packages_apps_Trebuchet-d0c2bbfb775fbdd16d7c81e82c828c3134e633e0.zip
Reimplement CM Settings Overview Panel Part 4
- Enable protected apps and update workspace/app drawer/widgets view when protected apps change - Change reload launcher to happen after each setting toggle to reduce UI lag Change-Id: I0a4a4a077c3cb94eaccfb4e8c4213135cb99d57e
-rw-r--r--src/com/android/launcher3/AppInfo.java4
-rw-r--r--src/com/android/launcher3/Launcher.java100
-rw-r--r--src/com/android/launcher3/LauncherModel.java109
-rw-r--r--src/com/android/launcher3/OverviewSettingsPanel.java8
-rw-r--r--src/com/android/launcher3/ProtectedComponentsHelper.java83
-rw-r--r--src/com/android/launcher3/allapps/AlphabeticalAppsList.java9
-rw-r--r--src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java19
-rw-r--r--src/com/android/launcher3/model/WidgetsModel.java15
8 files changed, 283 insertions, 64 deletions
diff --git a/src/com/android/launcher3/AppInfo.java b/src/com/android/launcher3/AppInfo.java
index c513153a5..a03e6081a 100644
--- a/src/com/android/launcher3/AppInfo.java
+++ b/src/com/android/launcher3/AppInfo.java
@@ -58,10 +58,10 @@ public class AppInfo extends ItemInfo {
public ComponentName componentName;
- static final int DOWNLOADED_FLAG = 1;
+ public static final int DOWNLOADED_FLAG = 1;
static final int UPDATED_SYSTEM_APP_FLAG = 2;
- int flags = 0;
+ public int flags = 0;
AppInfo() {
itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT;
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index fd6ab26e4..3198c0ff5 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -369,9 +369,6 @@ public class Launcher extends Activity
// the press state and keep this reference to reset the press state when we return to launcher.
private BubbleTextView mWaitingForResume;
- private boolean mReloadLauncher;
- private boolean mResizeGridRequired;
-
public Animator.AnimatorListener mAnimatorListener = new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator arg0) {}
@@ -385,6 +382,25 @@ public class Launcher extends Activity
public void onAnimationCancel(Animator arg0) {}
};
+ Runnable mUpdateDynamicGridRunnable = new Runnable() {
+ @Override
+ public void run() {
+ reloadLauncher(mWorkspace.getRestorePage(), true, false);
+ }
+ };
+
+ private BroadcastReceiver protectedAppsChangedReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ // Update the workspace
+ if (waitUntilResume(mUpdateDynamicGridRunnable, true)) {
+ return;
+ }
+
+ reloadLauncher(mWorkspace.getRestorePage(), true, false);
+ }
+ };
+
// Preferences
private boolean mHideIconLabels;
@@ -551,6 +567,11 @@ public class Launcher extends Activity
showFirstRunActivity();
showFirstRunClings();
}
+
+ IntentFilter protectedAppsFilter = new IntentFilter(
+ cyanogenmod.content.Intent.ACTION_PROTECTED_CHANGED);
+ registerReceiver(protectedAppsChangedReceiver, protectedAppsFilter,
+ cyanogenmod.platform.Manifest.permission.PROTECTED_APP, null);
}
@Override
@@ -1142,16 +1163,12 @@ public class Launcher extends Activity
mDynamicGridSizeFragment.setSize();
}
- reloadLauncherIfNeeded();
-
- //Close out Fragments
- Fragment f1 = getFragmentManager().findFragmentByTag(
+ Fragment hiddenFolderFragment = getFragmentManager().findFragmentByTag(
HiddenFolderFragment.HIDDEN_FOLDER_FRAGMENT);
- if (f1 != null && !mHiddenFolderAuth) {
+ if (hiddenFolderFragment != null && !mHiddenFolderAuth) {
mHiddenFolderFragment.saveHiddenFolderStatus(-1);
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
- fragmentTransaction
- .remove(mHiddenFolderFragment).commit();
+ fragmentTransaction.remove(mHiddenFolderFragment).commit();
} else {
mHiddenFolderAuth = false;
}
@@ -1778,38 +1795,24 @@ public class Launcher extends Activity
}
/**
- * Sets the reload launcher flag to true and the resize grid flag to the parameter value,
- * which will reload the launcher/grid size at the next appropriate time.
- * @param shouldResizeGrid Indicates whether the grid needs to be resized.
- */
- public void setReloadLauncher(boolean shouldResizeGrid) {
- mReloadLauncher = true;
- mResizeGridRequired = shouldResizeGrid;
- }
-
- /**
- * If the reload launcher flag is set to true, the launcher will be reloaded.
- * @return Whether the launcher was actually reloaded.
+ * Re-initializes the device profile and layout and reloads the workspace and app drawer as
+ * appropriate
+ * @param resizeGrid Indicates whether the grid should be resized
+ * @param reloadAppDrawer Indicates whether the app drawer should be reloaded
*/
- public boolean reloadLauncherIfNeeded() {
- if (mReloadLauncher) {
- reloadLauncher(mWorkspace.getCurrentPage());
- mReloadLauncher = false;
- mResizeGridRequired = false;
- return true;
- }
-
- return false;
+ public void reloadLauncher(boolean resizeGrid, boolean reloadAppDrawer) {
+ reloadLauncher(mWorkspace.getCurrentPage(), resizeGrid, reloadAppDrawer);
}
/**
- * Reloads the launcher by re-initializing the device profile and layout
- * @param page
+ * Re-initializes the device profile and layout and reloads the workspace and app drawer as
+ * appropriate
+ * @param page The page to bind to
+ * @param resizeGrid Indicates whether the grid should be resized
+ * @param reloadAppDrawer Indicates whether the app drawer should be reloaded
*/
- public void reloadLauncher(int page)
+ private void reloadLauncher(int page, boolean resizeGrid, boolean reloadAppDrawer)
{
- mSearchDropTargetBar.setupQsb(this);
-
// Re-initialize device profile
LauncherAppState app = LauncherAppState.getInstance();
app.initInvariantDeviceProfile();
@@ -1819,12 +1822,18 @@ public class Launcher extends Activity
// Reload
mModel.resetLoadedState(true, true);
- int flag = mResizeGridRequired ? LauncherModel.LOADER_FLAG_RESIZE_GRID :
+ int flag = resizeGrid ? LauncherModel.LOADER_FLAG_RESIZE_GRID :
LauncherModel.LOADER_FLAG_NONE;
mModel.startLoader(page, flag);
+
mWorkspace.updateCustomContentVisibility();
- mAppsView.reset();
+ mSearchDropTargetBar.setupQsb(this);
+ mSearchDropTargetBar.setVisibility(View.INVISIBLE);
+
+ if (reloadAppDrawer) {
+ reloadAppDrawer();
+ }
}
public void reloadAppDrawer() {
@@ -1881,8 +1890,7 @@ public class Launcher extends Activity
if (gridSize != size.getValue() || customValuesChanged) {
SettingsProvider.putInt(this,
SettingsProvider.SETTINGS_UI_DYNAMIC_GRID_SIZE, size.getValue());
-
- setReloadLauncher(true);
+ reloadLauncher(false, true);
}
mOverviewSettingsPanel.notifyDataSetInvalidated();
@@ -2142,8 +2150,6 @@ public class Launcher extends Activity
}
super.onNewIntent(intent);
- reloadLauncherIfNeeded();
-
// Close the menu
Folder openFolder = mWorkspace.getOpenFolder();
boolean alreadyOnHome = mHasFocus && ((intent.getFlags() &
@@ -2305,6 +2311,8 @@ public class Launcher extends Activity
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onDestroy();
}
+
+ unregisterReceiver(protectedAppsChangedReceiver);
}
public DragController getDragController() {
@@ -3630,8 +3638,6 @@ public class Launcher extends Activity
}
void showWorkspace(int snapToPage, boolean animated, Runnable onCompleteRunnable) {
- reloadLauncherIfNeeded();
-
boolean changed = mState != State.WORKSPACE ||
mWorkspace.getState() != Workspace.State.NORMAL;
if (changed) {
@@ -3660,8 +3666,6 @@ public class Launcher extends Activity
}
void showOverviewMode(boolean animated) {
- reloadLauncherIfNeeded();
-
mWorkspace.setVisibility(View.VISIBLE);
mStateTransitionAnimation.startAnimationToWorkspace(mState, mWorkspace.getState(),
Workspace.State.OVERVIEW,
@@ -4412,9 +4416,7 @@ public class Launcher extends Activity
mLauncherCallbacks.finishBindingItems(false);
}
- if (mWorkspace.isInOverviewMode()) {
- reloadLauncherIfNeeded();
- }
+ mWorkspace.stripEmptyScreens();
}
private void sendLoadingCompleteBroadcastIfNecessary() {
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 4f2491f8d..7a12eb8ef 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -62,6 +62,7 @@ import com.android.launcher3.util.CursorIconInfo;
import com.android.launcher3.util.LongArrayMap;
import com.android.launcher3.util.ManagedProfileHeuristic;
import com.android.launcher3.util.Thunk;
+import cyanogenmod.providers.CMSettings;
import java.lang.ref.WeakReference;
import java.net.URISyntaxException;
@@ -982,6 +983,7 @@ public class LauncherModel extends BroadcastReceiver
final int cellXIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLX);
final int cellYIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLY);
final int optionsIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.OPTIONS);
+ final int hiddenIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.HIDDEN);
FolderInfo folderInfo = null;
switch (c.getInt(itemTypeIndex)) {
@@ -998,6 +1000,7 @@ public class LauncherModel extends BroadcastReceiver
folderInfo.cellX = c.getInt(cellXIndex);
folderInfo.cellY = c.getInt(cellYIndex);
folderInfo.options = c.getInt(optionsIndex);
+ folderInfo.hidden = c.getInt(hiddenIndex) > 0;
return folderInfo;
}
@@ -1901,6 +1904,8 @@ public class LauncherModel extends BroadcastReceiver
LauncherSettings.Favorites.PROFILE_ID);
final int optionsIndex = c.getColumnIndexOrThrow(
LauncherSettings.Favorites.OPTIONS);
+ final int hiddenIndex = c.getColumnIndexOrThrow(
+ LauncherSettings.Favorites.HIDDEN);
final CursorIconInfo cursorIconInfo = new CursorIconInfo(c);
final LongSparseArray<UserHandleCompat> allUsers = new LongSparseArray<>();
@@ -2179,6 +2184,7 @@ public class LauncherModel extends BroadcastReceiver
folderInfo.spanX = 1;
folderInfo.spanY = 1;
folderInfo.options = c.getInt(optionsIndex);
+ folderInfo.hidden = c.getInt(hiddenIndex) > 0;
// check & update map of what's occupied
if (!checkItemPlacement(occupied, folderInfo, sBgWorkspaceScreens,
@@ -2587,6 +2593,107 @@ public class LauncherModel extends BroadcastReceiver
runOnMainThread(r);
}
+ private void removeHiddenAppsWorkspaceItems(
+ final ArrayList<ItemInfo> workspaceItems,
+ final ArrayList<LauncherAppWidgetInfo> appWidgets,
+ final LongArrayMap<FolderInfo> folders) {
+
+ // Get hidden apps
+ ArrayList<ComponentName> mHiddenApps = new ArrayList<ComponentName>();
+ ArrayList<String> mHiddenAppsPackages = new ArrayList<String>();
+ Context context = mApp.getContext();
+ String protectedComponents = CMSettings.Secure.getString(context.getContentResolver(),
+ CMSettings.Secure.PROTECTED_COMPONENTS);
+ protectedComponents = protectedComponents == null ? "" : protectedComponents;
+ String[] flattened = protectedComponents.split("\\|");
+
+ for (String flat : flattened) {
+ ComponentName cmp = ComponentName.unflattenFromString(flat);
+ if (cmp != null) {
+ mHiddenApps.add(cmp);
+ mHiddenAppsPackages.add(cmp.getPackageName());
+ }
+ }
+
+ // Shortcuts
+ int N = workspaceItems.size() - 1;
+ for (int i = N; i >= 0; i--) {
+ final ItemInfo item = workspaceItems.get(i);
+ if (item instanceof ShortcutInfo) {
+ ShortcutInfo shortcut = (ShortcutInfo)item;
+ if (shortcut.intent != null && shortcut.intent.getComponent() != null) {
+ if (mHiddenApps.contains(shortcut.intent.getComponent())) {
+ LauncherModel.deleteItemFromDatabase(mContext, shortcut);
+ workspaceItems.remove(i);
+ }
+ }
+ } else {
+ // Only remove items from folders that aren't hidden
+ final FolderInfo folder = (FolderInfo)item;
+ List<ShortcutInfo> shortcuts = folder.contents;
+
+ int NN = shortcuts.size() - 1;
+ for (int j = NN; j >= 0; j--) {
+ final ShortcutInfo sci = shortcuts.get(j);
+ if (sci.intent != null && sci.intent.getComponent() != null) {
+ if (!folder.hidden){
+ if (mHiddenApps.contains(sci.intent.getComponent())) {
+ LauncherModel.deleteItemFromDatabase(mContext, sci);
+ Runnable r = new Runnable() {
+ public void run() {
+ folder.remove(sci);
+ }
+ };
+ runOnMainThread(r);
+ }
+ } else {
+ if (!mHiddenApps.contains(sci.intent.getComponent())) {
+ LauncherModel.deleteItemFromDatabase(mContext, sci);
+ Runnable r = new Runnable() {
+ public void run() {
+ folder.remove(sci);
+ }
+ };
+ runOnMainThread(r);
+ }
+ }
+
+ }
+ }
+
+ if (folder.contents.size() == 1 && !folder.hidden) {
+ ShortcutInfo finalItem = folder.contents.get(0);
+ finalItem.container = folder.container;
+ LauncherModel.deleteItemFromDatabase(mContext, folder);
+ // only replace this item back on the workspace if it's not protected
+ if (!mHiddenApps.contains(finalItem.intent.getComponent())) {
+ LauncherModel.addOrMoveItemInDatabase(mContext, finalItem,
+ folder.container, folder.screenId, folder.cellX, folder.cellY);
+ workspaceItems.add(finalItem);
+ }
+ workspaceItems.remove(i);
+ folders.remove(Long.valueOf(item.id));
+ } else if (folder.contents.size() == 0) {
+ LauncherModel.deleteFolderContentsFromDatabase(mContext, folder);
+ workspaceItems.remove(i);
+ folders.remove(Long.valueOf(item.id));
+ }
+ }
+ }
+
+ // AppWidgets
+ N = appWidgets.size() - 1;
+ for (int i = N; i >= 0; i--) {
+ final LauncherAppWidgetInfo item = appWidgets.get(i);
+ if (item.providerName != null) {
+ if (mHiddenAppsPackages.contains(item.providerName.getPackageName())) {
+ LauncherModel.deleteItemFromDatabase(mContext, item);
+ appWidgets.remove(i);
+ }
+ }
+ }
+ }
+
private void bindWorkspaceItems(final Callbacks oldCallbacks,
final ArrayList<ItemInfo> workspaceItems,
final ArrayList<LauncherAppWidgetInfo> appWidgets,
@@ -2595,6 +2702,8 @@ public class LauncherModel extends BroadcastReceiver
final boolean postOnMainThread = (deferredBindRunnables != null);
+ removeHiddenAppsWorkspaceItems(workspaceItems, appWidgets, folders);
+
// Bind the workspace items
int N = workspaceItems.size();
for (int i = 0; i < N; i += ITEMS_CHUNK) {
diff --git a/src/com/android/launcher3/OverviewSettingsPanel.java b/src/com/android/launcher3/OverviewSettingsPanel.java
index cac40e6a4..f00b2f95a 100644
--- a/src/com/android/launcher3/OverviewSettingsPanel.java
+++ b/src/com/android/launcher3/OverviewSettingsPanel.java
@@ -8,6 +8,9 @@ import com.android.launcher3.list.PinnedHeaderListView;
import com.android.launcher3.list.SettingsPinnedHeaderAdapter;
public class OverviewSettingsPanel {
+ public static final String ANDROID_SETTINGS = "com.android.settings";
+ public static final String ANDROID_PROTECTED_APPS =
+ "com.android.settings.applications.ProtectedAppsActivity";
public static final int HOME_SETTINGS_POSITION = 0;
public static final int DRAWER_SETTINGS_POSITION = 1;
public static final int APP_SETTINGS_POSITION = 2;
@@ -45,9 +48,8 @@ public class OverviewSettingsPanel {
res.getString(R.string.fast_scroller_type)};
String[] valuesApp = new String[] {
- res.getString(R.string.larger_icons_text)/*,
- TODO: Uncomment
- res.getString(R.string.protected_app_settings)*/};
+ res.getString(R.string.larger_icons_text),
+ res.getString(R.string.protected_app_settings)};
mSettingsAdapter = new SettingsPinnedHeaderAdapter(mLauncher);
mSettingsAdapter.setHeaders(headers);
diff --git a/src/com/android/launcher3/ProtectedComponentsHelper.java b/src/com/android/launcher3/ProtectedComponentsHelper.java
new file mode 100644
index 000000000..12ec96da4
--- /dev/null
+++ b/src/com/android/launcher3/ProtectedComponentsHelper.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2015 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3;
+
+import android.content.ComponentName;
+import android.content.Context;
+import cyanogenmod.providers.CMSettings;
+
+import java.util.ArrayList;
+
+public class ProtectedComponentsHelper {
+ private static final int FILTER_APPS_SYSTEM_FLAG = 1;
+ private static final int FILTER_APPS_DOWNLOADED_FLAG = 2;
+ private static int sFilterApps = FILTER_APPS_SYSTEM_FLAG | FILTER_APPS_DOWNLOADED_FLAG;
+
+ private static ArrayList<ComponentName> sProtectedApps = new ArrayList<ComponentName>();
+ private static ArrayList<String> sProtectedPackages = new ArrayList<String>();
+
+ /**
+ * Gets the list of protected components from {@link CMSettings} and updates the existing list
+ * of protected apps and packages
+ * @param context Context
+ */
+ public static void updateProtectedComponentsLists(Context context) {
+ String protectedComponents = CMSettings.Secure.getString(context.getContentResolver(),
+ CMSettings.Secure.PROTECTED_COMPONENTS);
+ protectedComponents = protectedComponents == null ? "" : protectedComponents;
+ String [] flattened = protectedComponents.split("\\|");
+ sProtectedApps = new ArrayList<ComponentName>(flattened.length);
+ sProtectedPackages = new ArrayList<String>(flattened.length);
+ for (String flat : flattened) {
+ ComponentName cmp = ComponentName.unflattenFromString(flat);
+ if (cmp != null) {
+ sProtectedApps.add(cmp);
+ sProtectedPackages.add(cmp.getPackageName());
+ }
+ }
+ }
+
+ /**
+ * Checks if the given combination of {@link ComponentName} and flags is for a protected app
+ */
+ public static boolean isProtectedApp(int flags, ComponentName componentName) {
+ boolean system = isSystemFlag(flags);
+ return sProtectedApps.contains(componentName) || (system && !getShowSystemApps()) ||
+ (!system && !getShowDownloadedApps());
+ }
+
+ /**
+ * Checks if the given combination of package name and flags is for a protected package
+ */
+ public static boolean isProtectedPackage(int flags, String packageName) {
+ boolean system = isSystemFlag(flags);
+ return (sProtectedPackages.contains(packageName) || (system && !getShowSystemApps()) ||
+ (!system && !getShowDownloadedApps()));
+ }
+
+ private static boolean isSystemFlag(int flags) {
+ return (flags & AppInfo.DOWNLOADED_FLAG) == 0;
+ }
+
+ private static boolean getShowSystemApps() {
+ return (sFilterApps & FILTER_APPS_SYSTEM_FLAG) != 0;
+ }
+
+ private static boolean getShowDownloadedApps() {
+ return (sFilterApps & FILTER_APPS_DOWNLOADED_FLAG) != 0;
+ }
+}
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index dac0df12a..98d747936 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -15,16 +15,19 @@
*/
package com.android.launcher3.allapps;
+import android.content.ComponentName;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import com.android.launcher3.AppInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
+import com.android.launcher3.ProtectedComponentsHelper;
import com.android.launcher3.compat.AlphabeticIndexCompat;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.model.AppNameComparator;
import com.android.launcher3.util.ComponentKey;
+import cyanogenmod.providers.CMSettings;
import java.util.ArrayList;
import java.util.Collections;
@@ -452,9 +455,15 @@ public class AlphabeticalAppsList {
}
}
+ ProtectedComponentsHelper.updateProtectedComponentsLists(mLauncher);
+
// Recreate the filtered and sectioned apps (for convenience for the grid layout) from the
// ordered set of sections
for (AppInfo info : getFiltersAppInfos()) {
+ if (ProtectedComponentsHelper.isProtectedApp(info.flags, info.componentName)) {
+ continue;
+ }
+
String sectionName = getAndUpdateCachedSectionName(info.title);
// Create a new section if the section names do not match
diff --git a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
index 89ea1574a..034fd4903 100644
--- a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
+++ b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
@@ -1,6 +1,7 @@
package com.android.launcher3.list;
import android.content.Context;
+import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.Cursor;
@@ -13,7 +14,6 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
-import com.android.launcher3.DeviceProfile;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.OverviewSettingsPanel;
@@ -234,19 +234,20 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
switch (position) {
case 0:
updateSearchBarVisibility(v);
- mLauncher.setReloadLauncher(false);
+ mLauncher.reloadLauncher(false, false);
break;
case 1:
onIconLabelsBooleanChanged(v,
SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS,
R.bool.preferences_interface_homescreen_hide_icon_labels_default);
- mLauncher.setReloadLauncher(false);
+ mLauncher.reloadLauncher(false, false);
break;
case 2:
onSettingsBooleanChanged(v,
- SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_WALLPAPER_SCROLL,
+ SettingsProvider
+ .SETTINGS_UI_HOMESCREEN_SCROLLING_WALLPAPER_SCROLL,
R.bool.preferences_interface_homescreen_scrolling_wallpaper_scroll_default);
- mLauncher.setReloadLauncher(false);
+ mLauncher.reloadLauncher(false, false);
break;
case 3:
mLauncher.onClickDynamicGridSizeButton();
@@ -259,7 +260,7 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
onIconLabelsBooleanChanged(v,
SettingsProvider.SETTINGS_UI_DRAWER_HIDE_ICON_LABELS,
R.bool.preferences_interface_drawer_hide_icon_labels_default);
- mLauncher.setReloadLauncher(false);
+ mLauncher.reloadAppDrawer();
break;
case 1:
onDrawerStyleBooleanChanged(v,
@@ -287,14 +288,14 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
onSettingsBooleanChanged(v,
SettingsProvider.SETTINGS_UI_GENERAL_ICONS_LARGE,
R.bool.preferences_interface_general_icons_large_default);
- mLauncher.setReloadLauncher(false);
+ mLauncher.reloadLauncher(true, false);
break;
- /*case 1:
+ case 1:
Intent intent = new Intent();
intent.setClassName(OverviewSettingsPanel.ANDROID_SETTINGS,
OverviewSettingsPanel.ANDROID_PROTECTED_APPS);
mLauncher.startActivity(intent);
- break;*/
+ break;
}
}
diff --git a/src/com/android/launcher3/model/WidgetsModel.java b/src/com/android/launcher3/model/WidgetsModel.java
index eef4f9173..d0fdad32a 100644
--- a/src/com/android/launcher3/model/WidgetsModel.java
+++ b/src/com/android/launcher3/model/WidgetsModel.java
@@ -7,15 +7,18 @@ import android.content.pm.ResolveInfo;
import android.util.Log;
import com.android.launcher3.AppFilter;
+import com.android.launcher3.AppInfo;
import com.android.launcher3.IconCache;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherAppWidgetProviderInfo;
+import com.android.launcher3.ProtectedComponentsHelper;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AlphabeticIndexCompat;
import com.android.launcher3.compat.AppWidgetManagerCompat;
import com.android.launcher3.compat.UserHandleCompat;
+import cyanogenmod.providers.CMSettings;
import java.util.ArrayList;
import java.util.Collections;
@@ -41,6 +44,7 @@ public class WidgetsModel {
private ArrayList<Object> mRawList;
+ private Context mContext;
private final AppWidgetManagerCompat mAppWidgetMgr;
private final WidgetsAndShortcutNameComparator mWidgetAndShortcutNameComparator;
private final Comparator<ItemInfo> mAppNameComparator;
@@ -49,6 +53,7 @@ public class WidgetsModel {
private AlphabeticIndexCompat mIndexer;
public WidgetsModel(Context context, IconCache iconCache, AppFilter appFilter) {
+ mContext = context;
mAppWidgetMgr = AppWidgetManagerCompat.getInstance(context);
mWidgetAndShortcutNameComparator = new WidgetsAndShortcutNameComparator(context);
mAppNameComparator = (new AppNameComparator(context)).getAppInfoComparator();
@@ -110,6 +115,7 @@ public class WidgetsModel {
mWidgetAndShortcutNameComparator.reset();
InvariantDeviceProfile idp = LauncherAppState.getInstance().getInvariantDeviceProfile();
+ ProtectedComponentsHelper.updateProtectedComponentsLists(mContext);
// add and update.
for (Object o: rawWidgetsShortcuts) {
@@ -158,11 +164,18 @@ public class WidgetsModel {
PackageItemInfo pInfo = tmpPackageItemInfos.get(packageName);
ArrayList<Object> widgetsShortcutsList = mWidgetsList.get(pInfo);
if (widgetsShortcutsList != null) {
+ if (pInfo != null && ProtectedComponentsHelper.isProtectedPackage(pInfo.flags,
+ packageName)) {
+ continue;
+ }
widgetsShortcutsList.add(o);
} else {
+ pInfo = new PackageItemInfo(packageName);
+ if (ProtectedComponentsHelper.isProtectedPackage(pInfo.flags, packageName)) {
+ continue;
+ }
widgetsShortcutsList = new ArrayList<>();
widgetsShortcutsList.add(o);
- pInfo = new PackageItemInfo(packageName);
mIconCache.getTitleAndIconForApp(packageName, userHandle,
true /* userLowResIcon */, pInfo);
pInfo.titleSectionName = mIndexer.computeSectionName(pInfo.title);