blob: b152ad5f5fa9d1e7de62fddae7e97f380219e460 [file] [log] [blame]
Michael Jurka0e260592010-06-30 17:07:39 -07001package com.android.launcher2;
2
3import com.android.launcher.R;
4
5import android.content.ComponentName;
6import android.content.Context;
7import android.content.Intent;
8import android.content.pm.ResolveInfo;
9import android.provider.LiveFolders;
10import android.util.AttributeSet;
11import android.view.View;
12import android.widget.AdapterView;
13
14public 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}