summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Folder.java
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2014-07-01 09:45:18 +0200
committerDanny Baumann <dannybaumann@web.de>2014-07-02 11:28:03 +0200
commit4ff96f59b1403b5949e706462d5e2e08b967dabf (patch)
treeed888591a8276eabeab4657ee55a4d9aaa20b41d /src/com/android/launcher3/Folder.java
parentebf8f37515c23a167cef2bb8cff04854c52fd35b (diff)
downloadandroid_packages_apps_Trebuchet-4ff96f59b1403b5949e706462d5e2e08b967dabf.tar.gz
android_packages_apps_Trebuchet-4ff96f59b1403b5949e706462d5e2e08b967dabf.tar.bz2
android_packages_apps_Trebuchet-4ff96f59b1403b5949e706462d5e2e08b967dabf.zip
Clean up protected apps code (2/2)
- Work with actual component names instead of converting them between ComponentName and String all the time - Some misc. coding style adaptions Change-Id: I7401ea471d618936e880e6d542744f80f89ce40f
Diffstat (limited to 'src/com/android/launcher3/Folder.java')
-rw-r--r--src/com/android/launcher3/Folder.java43
1 files changed, 16 insertions, 27 deletions
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index 71183c342..b584b950d 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -34,6 +34,7 @@ import android.text.Selection;
import android.text.Spannable;
import android.util.AttributeSet;
import android.util.Log;
+import android.util.Pair;
import android.view.ActionMode;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -57,6 +58,7 @@ import com.android.launcher3.settings.SettingsProvider;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.List;
/**
* Represents a set of icons chosen by the user or generated by the system.
@@ -69,8 +71,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
private static final String PROTECTED_ACTION = "cyanogenmod.intent.action.PACKAGE_PROTECTED";
private static final String PROTECTED_STATE =
"cyanogenmod.intent.action.PACKAGE_PROTECTED_STATE";
- private static final String PROTECTED_COMPONENT =
- "cyanogenmod.intent.action.PACKAGE_PROTECTED_COMPONENT";
+ private static final String PROTECTED_COMPONENTS =
+ "cyanogenmod.intent.action.PACKAGE_PROTECTED_COMPONENTS";
protected DragController mDragController;
protected Launcher mLauncher;
@@ -267,50 +269,37 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mLauncher.validateLockForHiddenFolders(bundle, mFolderIcon);
}
- public String[] getComponentTitles() {
+ public List<Pair<ComponentName, CharSequence>> getComponents() {
int size = mItemsInReadingOrder.size();
- String[] componentsTitles = new String[size];
+ List<Pair<ComponentName, CharSequence>> components =
+ new ArrayList<Pair<ComponentName, CharSequence>>();
+
for (int i = 0; i < size; i++) {
View v = mItemsInReadingOrder.get(i);
Object tag = v.getTag();
if (tag instanceof ShortcutInfo) {
- componentsTitles[i] = ((ShortcutInfo) tag).title.toString();
+ ShortcutInfo shortcut = (ShortcutInfo) tag;
+ components.add(Pair.create(shortcut.getIntent().getComponent(), shortcut.title));
}
}
- return componentsTitles;
- }
- public String[] getComponents() {
- String components = getComponentString();
- return components.split("\\|");
+ return components;
}
public void modifyProtectedApps(boolean protect) {
- String components = getComponentString();
+ ArrayList<ComponentName> components = new ArrayList<ComponentName>();
+ for (Pair<ComponentName, CharSequence> item : getComponents()) {
+ components.add(item.first);
+ }
Intent intent = new Intent();
intent.setAction(PROTECTED_ACTION);
intent.putExtra(PROTECTED_STATE, protect);
- intent.putExtra(PROTECTED_COMPONENT, components);
+ intent.putExtra(PROTECTED_COMPONENTS, components);
mLauncher.sendBroadcast(intent);
}
- private String getComponentString() {
- int size = mItemsInReadingOrder.size();
- String components = "";
- for (int i = 0; i < size; i++) {
- View v = mItemsInReadingOrder.get(i);
- Object tag = v.getTag();
- if (tag instanceof ShortcutInfo) {
- ComponentName componentName = ((ShortcutInfo) tag).getIntent().getComponent();
- components += componentName.flattenToString() + "|";
- }
- }
-
- return components;
- }
-
public boolean onLongClick(View v) {
// Return if global dragging is not enabled
if (!mLauncher.isDraggingEnabled()) return true;