diff options
author | Danny Baumann <dannybaumann@web.de> | 2014-07-01 09:45:18 +0200 |
---|---|---|
committer | Abhisek Devkota <ciwrl@cyanogenmod.com> | 2014-12-02 01:17:02 +0000 |
commit | c398b8b621f284295b8eafb9c729743a53f40ad2 (patch) | |
tree | aebfcfa32ce00caad80325370625b9154b5c1e34 /src/com/android/launcher3/Folder.java | |
parent | b96792dcc654626cf1a57bd1b23efbb330de4664 (diff) | |
download | android_packages_apps_Trebuchet-c398b8b621f284295b8eafb9c729743a53f40ad2.tar.gz android_packages_apps_Trebuchet-c398b8b621f284295b8eafb9c729743a53f40ad2.tar.bz2 android_packages_apps_Trebuchet-c398b8b621f284295b8eafb9c729743a53f40ad2.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.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 89785fe0a..3a43ec102 100644 --- a/src/com/android/launcher3/Folder.java +++ b/src/com/android/launcher3/Folder.java @@ -35,6 +35,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; @@ -59,6 +60,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. @@ -71,8 +73,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; @@ -277,50 +279,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; |