Michael Jurka | 0e26059 | 2010-06-30 17:07:39 -0700 | [diff] [blame] | 1 | package com.android.launcher2; |
| 2 | |
| 3 | import com.android.launcher.R; |
| 4 | |
| 5 | import android.content.ComponentName; |
| 6 | import android.content.Context; |
| 7 | import android.content.Intent; |
| 8 | import android.content.pm.ResolveInfo; |
| 9 | import android.provider.LiveFolders; |
| 10 | import android.util.AttributeSet; |
| 11 | import android.view.View; |
| 12 | import android.widget.AdapterView; |
| 13 | |
| 14 | public class FolderChooser extends HomeCustomizationItemGallery { |
| 15 | |
| 16 | public FolderChooser(Context context, AttributeSet attrs) { |
| 17 | super(context, attrs); |
| 18 | } |
| 19 | |
| 20 | public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { |
| 21 | // todo: this code sorta overlaps with other places |
| 22 | ResolveInfo info = (ResolveInfo)getAdapter().getItem(position); |
| 23 | mLauncher.prepareAddItemFromHomeCustomizationDrawer(); |
| 24 | |
| 25 | Intent createFolderIntent = new Intent(LiveFolders.ACTION_CREATE_LIVE_FOLDER); |
| 26 | if (info.labelRes == R.string.group_folder) { |
| 27 | // Create app shortcuts is a special built-in case of shortcuts |
| 28 | createFolderIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getContext().getString(R.string.group_folder)); |
| 29 | } else { |
| 30 | ComponentName name = new ComponentName(info.activityInfo.packageName, info.activityInfo.name); |
| 31 | createFolderIntent.setComponent(name); |
| 32 | } |
| 33 | mLauncher.addLiveFolder(createFolderIntent); |
| 34 | |
| 35 | return true; |
| 36 | } |
| 37 | } |