summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2013-06-25 03:18:31 +0200
committerJorge Ruesga <jorge@ruesga.com>2013-06-25 03:18:31 +0200
commit21d44da75e7b0d135033bab2aeab10f42b94ca8e (patch)
tree82f90d686846ec9a7e18f954f365c755d1af664f /src
parent7fd44abee142349dc97570f50851cbf0629706ca (diff)
downloadpackages_apps_trebuchet-21d44da75e7b0d135033bab2aeab10f42b94ca8e.zip
packages_apps_trebuchet-21d44da75e7b0d135033bab2aeab10f42b94ca8e.tar.gz
packages_apps_trebuchet-21d44da75e7b0d135033bab2aeab10f42b94ca8e.tar.bz2
Trebuchet: Make remove workspace items of hidden apps optional
Change-Id: Id5c1f7a105d4140747a9f841b210cd7a7d1825df Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'src')
-rw-r--r--src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java12
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherModel.java86
-rw-r--r--src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java12
3 files changed, 64 insertions, 46 deletions
diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
index 1b87c4f..42485a6 100644
--- a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
@@ -263,6 +263,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
private ArrayList<ApplicationInfo> mApps;
private ArrayList<ApplicationInfo> mFilteredApps;
private ArrayList<ComponentName> mHiddenApps;
+ private ArrayList<String> mHiddenAppsPackages;
private ArrayList<Object> mWidgets;
// Cling
@@ -370,6 +371,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
mApps = new ArrayList<ApplicationInfo>();
mFilteredApps = new ArrayList<ApplicationInfo>();
mHiddenApps = new ArrayList<ComponentName>();
+ mHiddenAppsPackages = new ArrayList<String>();
mWidgets = new ArrayList<Object>();
mIconCache = ((LauncherApplication) context.getApplicationContext()).getIconCache();
mCanvas = new Canvas();
@@ -392,7 +394,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
String[] flattened = PreferencesProvider.Interface.Drawer.getHiddenApps().split("\\|");
for (String flat : flattened) {
- mHiddenApps.add(ComponentName.unflattenFromString(flat));
+ ComponentName cmp = ComponentName.unflattenFromString(flat);
+ mHiddenApps.add(cmp);
+ mHiddenAppsPackages.add(cmp.getPackageName());
}
@@ -658,7 +662,11 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int minSpanY = Math.min(spanXY[1], minSpanXY[1]);
if (minSpanX <= LauncherModel.getWorkspaceCellCountX() &&
minSpanY <= LauncherModel.getWorkspaceCellCountY()) {
- mWidgets.add(widget);
+ if (widget.provider != null) {
+ if (!mHiddenAppsPackages.contains(widget.provider.getPackageName())) {
+ mWidgets.add(widget);
+ }
+ }
} else {
Log.e(TAG, "Widget " + widget.provider + " can not fit on this device (" +
widget.minWidth + ", " + widget.minHeight + ")");
diff --git a/src/com/cyanogenmod/trebuchet/LauncherModel.java b/src/com/cyanogenmod/trebuchet/LauncherModel.java
index 323be71..6aa109a 100644
--- a/src/com/cyanogenmod/trebuchet/LauncherModel.java
+++ b/src/com/cyanogenmod/trebuchet/LauncherModel.java
@@ -1667,56 +1667,60 @@ public class LauncherModel extends BroadcastReceiver {
}
// 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);
+ if (PreferencesProvider.Interface.Drawer.getRemoveShortcutsOfHiddenApps()) {
+ 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 {
- final FolderInfo folder = (FolderInfo)item;
- List<ShortcutInfo> shortcuts = folder.contents;
- int NN = shortcuts.size() - 1;
- for (int j = NN; j >= 0; j--) {
- ShortcutInfo sci = shortcuts.get(j);
- if (sci.intent != null && sci.intent.getComponent() != null) {
- if (mHiddenApps.contains(sci.intent.getComponent())) {
- LauncherModel.deleteItemFromDatabase(mContext, sci);
- folder.remove(sci);
+ } else {
+ final FolderInfo folder = (FolderInfo)item;
+ List<ShortcutInfo> shortcuts = folder.contents;
+ int NN = shortcuts.size() - 1;
+ for (int j = NN; j >= 0; j--) {
+ ShortcutInfo sci = shortcuts.get(j);
+ if (sci.intent != null && sci.intent.getComponent() != null) {
+ if (mHiddenApps.contains(sci.intent.getComponent())) {
+ LauncherModel.deleteItemFromDatabase(mContext, sci);
+ folder.remove(sci);
+ }
}
}
- }
- if (folder.contents.size() == 1) {
- ShortcutInfo finalItem = folder.contents.get(0);
- finalItem.container = folder.container;
- LauncherModel.deleteItemFromDatabase(mContext, folder);
- LauncherModel.addOrMoveItemInDatabase(mContext, finalItem, folder.container,
- folder.screen, folder.cellX, folder.cellY);
- workspaceItems.remove(i);
- workspaceItems.add(finalItem);
- 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));
+ if (folder.contents.size() == 1) {
+ ShortcutInfo finalItem = folder.contents.get(0);
+ finalItem.container = folder.container;
+ LauncherModel.deleteItemFromDatabase(mContext, folder);
+ LauncherModel.addOrMoveItemInDatabase(mContext, finalItem, folder.container,
+ folder.screen, folder.cellX, folder.cellY);
+ workspaceItems.remove(i);
+ workspaceItems.add(finalItem);
+ 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);
+ if (PreferencesProvider.Interface.Drawer.getRemoveWidgetsOfHiddenApps()) {
+ int 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);
+ }
}
}
}
diff --git a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
index 912d310..9f61f82 100644
--- a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
+++ b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
@@ -144,12 +144,18 @@ public final class PreferencesProvider {
public static boolean getVertical() {
return getString("ui_drawer_orientation", "horizontal").equals("vertical");
}
- public static boolean getJoinWidgetsApps() {
- return getBoolean("ui_drawer_widgets_join_apps", true);
- }
public static String getHiddenApps() {
return getString("ui_drawer_hidden_apps", "");
}
+ public static boolean getRemoveShortcutsOfHiddenApps() {
+ return getBoolean("ui_drawer_remove_hidden_apps_shortcuts", true);
+ }
+ public static boolean getRemoveWidgetsOfHiddenApps() {
+ return getBoolean("ui_drawer_remove_hidden_apps_widgets", true);
+ }
+ public static boolean getJoinWidgetsApps() {
+ return getBoolean("ui_drawer_widgets_join_apps", true);
+ }
public static class Scrolling {
public static AppsCustomizePagedView.TransitionEffect getTransitionEffect(String def) {
try {