summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaj Yengisetty <rajesh@cyngn.com>2015-03-09 21:58:00 (GMT)
committerRaj Yengisetty <rajesh@cyngn.com>2015-03-09 21:58:00 (GMT)
commit2372ffc2bbccac6a567488b76565213bae89d2ac (patch)
treefaeadd894cf132d64e1c03e89bd4a0bc35a50148
parent4e5c80ff91db217d2b06be5cd05544203f95f0b4 (diff)
downloadandroid_packages_apps_Trebuchet-2372ffc2bbccac6a567488b76565213bae89d2ac.zip
android_packages_apps_Trebuchet-2372ffc2bbccac6a567488b76565213bae89d2ac.tar.gz
android_packages_apps_Trebuchet-2372ffc2bbccac6a567488b76565213bae89d2ac.tar.bz2
App drawer: respect protected apps
Change-Id: I67d0af84cc8cad3d3e788280e34a9c2a95ab76a7
-rw-r--r--src/com/android/launcher3/AppDrawerListAdapter.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/com/android/launcher3/AppDrawerListAdapter.java b/src/com/android/launcher3/AppDrawerListAdapter.java
index f004421..84c96db 100644
--- a/src/com/android/launcher3/AppDrawerListAdapter.java
+++ b/src/com/android/launcher3/AppDrawerListAdapter.java
@@ -17,8 +17,10 @@
package com.android.launcher3;
import android.content.ComponentName;
+import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.provider.Settings;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
@@ -32,6 +34,7 @@ import com.android.launcher3.locale.LocaleUtils;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
@@ -53,6 +56,8 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
private Rect mIconRect;
private LocaleSetManager mLocaleSetManager;
+ private ArrayList<ComponentName> mProtectedApps;
+
public enum DrawerType {
Drawer(0),
Pager(1);
@@ -95,6 +100,8 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
mLocaleSetManager = new LocaleSetManager(mLauncher);
mLocaleSetManager.updateLocaleSet(mLocaleSetManager.getSystemLocaleSet());
initParams();
+
+ updateProtectedAppsList(mLauncher);
}
private void initParams() {
@@ -169,6 +176,8 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
public void setApps(ArrayList<AppInfo> list) {
if (!LauncherAppState.isDisableAllApps()) {
+ filterProtectedApps(list);
+
mHeaderList.clear();
populateByCharacter(list);
populateSectionHeaders();
@@ -197,6 +206,7 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
private void reset() {
ArrayList<AppInfo> infos = getAllApps();
+
setApps(infos);
}
@@ -519,4 +529,30 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
public int getSectionForPosition(int position) {
return mSectionHeaders.get(mHeaderList.get(position).mStartString);
}
+
+ private void filterProtectedApps(ArrayList<AppInfo> list) {
+ updateProtectedAppsList(mLauncher);
+
+ Iterator<AppInfo> iterator = list.iterator();
+ while (iterator.hasNext()) {
+ AppInfo appInfo = iterator.next();
+ if (mProtectedApps.contains(appInfo.componentName)) {
+ iterator.remove();
+ }
+ }
+ }
+
+ private void updateProtectedAppsList(Context context) {
+ String protectedComponents = Settings.Secure.getString(context.getContentResolver(),
+ LauncherModel.SETTINGS_PROTECTED_COMPONENTS);
+ protectedComponents = protectedComponents == null ? "" : protectedComponents;
+ String [] flattened = protectedComponents.split("\\|");
+ mProtectedApps = new ArrayList<ComponentName>(flattened.length);
+ for (String flat : flattened) {
+ ComponentName cmp = ComponentName.unflattenFromString(flat);
+ if (cmp != null) {
+ mProtectedApps.add(cmp);
+ }
+ }
+ }
}