diff options
Diffstat (limited to 'src/com/android/launcher3/Folder.java')
-rw-r--r-- | src/com/android/launcher3/Folder.java | 43 |
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; |