Changing long-press-on-workspace behaviour to show Applications & Widgets.

- Disabling tap-on-widgets-to-add in favour of long press

Change-Id: Ia82143b74216a968ab11890cba83a01c4ab72a06
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 2a16e99..f8d3411 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2230,11 +2230,7 @@
                 mWorkspace.setAllowLongPress(false);
                 mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
                         HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
-                if (LauncherApplication.isScreenLarge()) {
-                    addItems();
-                } else {
-                    startWallpaper();
-                }
+                addItems();
             } else {
                 if (!(itemUnderLongClick instanceof Folder)) {
                     // User long pressed on an item
@@ -2970,9 +2966,8 @@
             // Change the state *after* we've called all the transition code
             mState = State.ALL_APPS;
         } else {
-            View appsCustomizePane = findViewById(R.id.apps_customize_pane);
             cameraZoomOut(State.APPS_CUSTOMIZE, animated, false);
-            appsCustomizePane.requestFocus();
+            mAppsCustomizeTabHost.requestFocus();
 
             // Change the state *after* we've called all the transition code
             mState = State.APPS_CUSTOMIZE;
@@ -3242,12 +3237,11 @@
         Dialog createDialog() {
             mAdapter = new AddAdapter(Launcher.this);
 
-            final AlertDialog.Builder builder = new AlertDialog.Builder(Launcher.this);
+            final AlertDialog.Builder builder = new AlertDialog.Builder(Launcher.this, 
+                    AlertDialog.THEME_HOLO_DARK);
             builder.setTitle(getString(R.string.menu_item_add_item));
             builder.setAdapter(mAdapter, this);
 
-            builder.setInverseBackgroundForced(true);
-
             AlertDialog dialog = builder.create();
             dialog.setOnCancelListener(this);
             dialog.setOnDismissListener(this);
@@ -3262,6 +3256,8 @@
         }
 
         public void onDismiss(DialogInterface dialog) {
+            mWaitingForResult = false;
+            cleanup();
         }
 
         private void cleanup() {
@@ -3279,22 +3275,26 @@
             Resources res = getResources();
             cleanup();
 
-            switch (which) {
+            AddAdapter.ListItem item = (AddAdapter.ListItem) mAdapter.getItem(which);
+            switch (item.actionTag) {
                 case AddAdapter.ITEM_SHORTCUT: {
                     pickShortcut();
                     break;
                 }
-
-                case AddAdapter.ITEM_APPWIDGET: {
-                    int appWidgetId = Launcher.this.mAppWidgetHost.allocateAppWidgetId();
-
-                    Intent pickIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_PICK);
-                    pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
-                    // start the pick activity
-                    startActivityForResult(pickIntent, REQUEST_PICK_APPWIDGET);
+                case AddAdapter.ITEM_APPLICATION: {
+                    if (mAppsCustomizeTabHost != null) {
+                        mAppsCustomizeTabHost.selectAppsTab();
+                    }
+                    showAllApps(true);
                     break;
                 }
-
+                case AddAdapter.ITEM_APPWIDGET: {
+                    if (mAppsCustomizeTabHost != null) {
+                        mAppsCustomizeTabHost.selectWidgetsTab();
+                    }
+                    showAllApps(true);
+                    break;
+                }
                 case AddAdapter.ITEM_WALLPAPER: {
                     startWallpaper();
                     break;