Remove gestures from Home.
diff --git a/src/com/android/launcher/Launcher.java b/src/com/android/launcher/Launcher.java
index 25ad4e5..3fd141d 100644
--- a/src/com/android/launcher/Launcher.java
+++ b/src/com/android/launcher/Launcher.java
@@ -32,7 +32,6 @@
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.IntentFilter;
-import android.content.SharedPreferences;
 import android.content.Intent.ShortcutIconResource;
 import android.content.pm.ActivityInfo;
 import android.content.pm.PackageManager;
@@ -67,8 +66,6 @@
 import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.MotionEvent;
-import android.view.Gravity;
 import android.view.View.OnLongClickListener;
 import android.view.inputmethod.InputMethodManager;
 import android.widget.EditText;
@@ -76,16 +73,8 @@
 import android.widget.SlidingDrawer;
 import android.widget.TextView;
 import android.widget.Toast;
-import android.widget.ImageView;
-import android.widget.PopupWindow;
-import android.widget.Button;
 import android.appwidget.AppWidgetManager;
 import android.appwidget.AppWidgetProviderInfo;
-import android.gesture.GestureOverlayView;
-import android.gesture.GestureLibraries;
-import android.gesture.GestureLibrary;
-import android.gesture.Gesture;
-import android.gesture.Prediction;
 
 import java.lang.ref.WeakReference;
 import java.util.ArrayList;
@@ -106,9 +95,6 @@
     private static final boolean PROFILE_DRAWER = false;
     private static final boolean PROFILE_ROTATE = false;
     private static final boolean DEBUG_USER_INTERFACE = false;
-    private static final boolean DEBUG_GESTURES = false;
-
-    private static final boolean CONFIG_GESTURES_IMMEDIATE_MODE = true;
 
     private static final int WALLPAPER_SCREENS_SPAN = 2;
 
@@ -117,8 +103,7 @@
     private static final int MENU_WALLPAPER_SETTINGS = MENU_ADD + 1;
     private static final int MENU_SEARCH = MENU_WALLPAPER_SETTINGS + 1;
     private static final int MENU_NOTIFICATIONS = MENU_SEARCH + 1;
-    private static final int MENU_GESTURES = MENU_NOTIFICATIONS + 1;
-    private static final int MENU_SETTINGS = MENU_GESTURES + 1;
+    private static final int MENU_SETTINGS = MENU_NOTIFICATIONS + 1;
 
     private static final int REQUEST_CREATE_SHORTCUT = 1;
     private static final int REQUEST_CREATE_LIVE_FOLDER = 4;
@@ -127,9 +112,6 @@
     private static final int REQUEST_PICK_SHORTCUT = 7;
     private static final int REQUEST_PICK_LIVE_FOLDER = 8;
     private static final int REQUEST_PICK_APPWIDGET = 9;
-    private static final int REQUEST_PICK_GESTURE_ACTION = 10;
-    private static final int REQUEST_CREATE_GESTURE_ACTION = 11;
-    private static final int REQUEST_CREATE_GESTURE_APPLICATION_ACTION = 12;
 
     static final String EXTRA_SHORTCUT_DUPLICATE = "duplicate";
 
@@ -172,12 +154,6 @@
     private static final String RUNTIME_STATE_PENDING_FOLDER_RENAME = "launcher.rename_folder";
     // Type: long
     private static final String RUNTIME_STATE_PENDING_FOLDER_RENAME_ID = "launcher.rename_folder_id";
-    // Type: Gesture (Parcelable)
-    private static final String RUNTIME_STATE_PENDING_GESTURE = "launcher.gesture";
-    // Type: boolean
-    private static final String RUNTIME_STATE_GESTURES_PANEL = "launcher.gesture_panel_showing";
-    // Type: Gesture (Parcelable)
-    private static final String RUNTIME_STATE_GESTURES_PANEL_GESTURE = "launcher.gesture_panel_gesture";
 
     private static final LauncherModel sModel = new LauncherModel();
 
@@ -188,8 +164,6 @@
 
     private static WallpaperIntentReceiver sWallpaperReceiver;
 
-    private static GestureLibrary sLibrary;
-
     private final BroadcastReceiver mApplicationsReceiver = new ApplicationsIntentReceiver();
     private final ContentObserver mObserver = new FavoritesChangeObserver();
 
@@ -230,24 +204,11 @@
 
     private DesktopBinder mBinder;
 
-    private View mGesturesPanel;
-    private GestureOverlayView mGesturesOverlay;
-    private ImageView mGesturesAdd;
-    private PopupWindow mGesturesWindow;
-    private Launcher.GesturesProcessor mGesturesProcessor;
-    private Gesture mCurrentGesture;
-    private GesturesAction mGesturesAction;
-    private boolean mHideGesturesPanel;
-    private TextView mGesturesPrompt;
-    private Button mGesturesSend;
-
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         mInflater = getLayoutInflater();
 
-        getGestureLibrary(this);
-
         mAppWidgetManager = AppWidgetManager.getInstance(this);
 
         mAppWidgetHost = new LauncherAppWidgetHost(this, APPWIDGET_HOST_ID);
@@ -405,11 +366,7 @@
         // For example, the user would PICK_SHORTCUT for "Music playlist", and we
         // launch over to the Music app to actually CREATE_SHORTCUT.
 
-        if (resultCode == RESULT_OK && (mAddItemCellInfo != null ||
-                ((requestCode == REQUEST_PICK_GESTURE_ACTION ||
-                requestCode == REQUEST_CREATE_GESTURE_ACTION ||
-                requestCode == REQUEST_CREATE_GESTURE_APPLICATION_ACTION) && mCurrentGesture != null))) {
-
+        if (resultCode == RESULT_OK && mAddItemCellInfo != null) {
             switch (requestCode) {
                 case REQUEST_PICK_APPLICATION:
                     completeAddApplication(this, data, mAddItemCellInfo, !mDesktopLocked);
@@ -432,16 +389,6 @@
                 case REQUEST_CREATE_APPWIDGET:
                     completeAddAppWidget(data, mAddItemCellInfo, !mDesktopLocked);
                     break;
-                case REQUEST_PICK_GESTURE_ACTION:
-                    processShortcut(data, REQUEST_CREATE_GESTURE_APPLICATION_ACTION,
-                            REQUEST_CREATE_GESTURE_ACTION);
-                    break;
-                case REQUEST_CREATE_GESTURE_ACTION:
-                    completeCreateGesture(data, true);
-                    break;
-                case REQUEST_CREATE_GESTURE_APPLICATION_ACTION:
-                    completeCreateGesture(data, false);
-                    break;
             }
         } else if (requestCode == REQUEST_PICK_APPWIDGET &&
                 resultCode == RESULT_CANCELED && data != null) {
@@ -486,23 +433,10 @@
     @Override
     protected void onPause() {
         super.onPause();
-        if (mGesturesWindow != null) {
-            mGesturesWindow.setAnimationStyle(0);
-            mGesturesWindow.update();
-        }
         closeDrawer(false);
     }
 
     @Override
-    protected void onStop() {
-        super.onStop();
-        if (mHideGesturesPanel) {
-            mHideGesturesPanel = false;
-            hideGesturesPanel();
-        }
-    }
-
-    @Override
     public Object onRetainNonConfigurationInstance() {
         // Flag any binder to stop early before switching
         if (mBinder != null) {
@@ -589,31 +523,6 @@
             mFolderInfo = sModel.getFolderById(this, id);
             mRestoring = true;
         }
-
-        mCurrentGesture = (Gesture) savedState.get(RUNTIME_STATE_PENDING_GESTURE);
-
-        boolean gesturesShowing = savedState.getBoolean(RUNTIME_STATE_GESTURES_PANEL, false);
-        if (gesturesShowing) {
-            if (mCurrentGesture == null) {
-                mCurrentGesture = (Gesture) savedState.get(RUNTIME_STATE_GESTURES_PANEL_GESTURE);
-            }
-            final Gesture gesture = mCurrentGesture;
-            mWorkspace.post(new Runnable() {
-                public void run() {
-                    showGesturesPanel(false);
-                    if (gesture != null && mWorkspace.getParent() != null) {
-                        mGesturesProcessor.matchGesture(gesture);
-                        mWorkspace.post(new Runnable() {
-                            public void run() {
-                                if (gesture != null && mWorkspace.getParent() != null) {
-                                    mGesturesOverlay.setGesture(gesture);
-                                }
-                            }
-                        });
-                    }
-                }
-            });
-        }
     }
 
     /**
@@ -661,72 +570,6 @@
         dragLayer.setIgnoredDropTarget(grid);
         dragLayer.setDragScoller(workspace);
         dragLayer.setDragListener(deleteZone);
-
-        mGesturesPanel = mInflater.inflate(R.layout.gestures, mDragLayer, false);
-        final View gesturesPanel = mGesturesPanel;
-
-        mGesturesAction = new GesturesAction();
-
-        mGesturesPrompt = (TextView) gesturesPanel.findViewById(R.id.gestures_prompt);
-        mGesturesSend = (Button) gesturesPanel.findViewById(R.id.gestures_action);
-        mGesturesSend.setOnClickListener(mGesturesAction);
-       
-        mGesturesAdd = (ImageView) gesturesPanel.findViewById(R.id.gestures_add);
-        final ImageView gesturesAdd = mGesturesAdd;
-        gesturesAdd.setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                createGesture();
-            }
-        });
-
-        gesturesPanel.findViewById(R.id.gestures_list).setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                startActivity(new Intent(Launcher.this, GesturesActivity.class));
-            }
-        });
-
-        mGesturesOverlay = (GestureOverlayView) gesturesPanel.findViewById(R.id.gestures_overlay);
-        mGesturesProcessor = new GesturesProcessor();
-
-        final GestureOverlayView overlay = mGesturesOverlay;
-        overlay.addOnGestureListener(mGesturesProcessor);
-    }
-
-    private void createGesture() {
-        if (!mWaitingForResult) {
-            mCurrentGesture = mGesturesOverlay.getGesture();
-            mWaitingForResult = true;
-            pickShortcut(REQUEST_PICK_GESTURE_ACTION, R.string.title_select_shortcut);
-        }
-    }
-
-    private void completeCreateGesture(Intent data, boolean isShortcut) {
-        ApplicationInfo info;
-
-        if (isShortcut) {
-            info = infoFromShortcutIntent(this, data);
-        } else {
-            info = infoFromApplicationIntent(this, data);
-        }
-
-        boolean success = false;
-        if (info != null) {
-            info.isGesture = true;
-
-            if (LauncherModel.addGestureToDatabase(this, info, false)) {
-                mGesturesProcessor.addGesture(String.valueOf(info.id), mCurrentGesture);
-                mGesturesProcessor.update(info, mCurrentGesture);
-                Toast.makeText(this, getString(R.string.gestures_created, info.title),
-                        Toast.LENGTH_SHORT).show();
-                success = true;
-            }
-        }
-
-        if (!success) {
-            Toast.makeText(this, getString(R.string.gestures_failed), Toast.LENGTH_SHORT).show();
-        }
-
-        mCurrentGesture = null;
     }
 
     /**
@@ -977,32 +820,8 @@
             if ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) !=
                     Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) {
 
-                // TODO: This really should not be done here every time
-                final SharedPreferences preferences =
-                        getSharedPreferences(GesturesConstants.PREFERENCES_NAME, MODE_PRIVATE);
-                final boolean homeKey = preferences.getBoolean(
-                        GesturesConstants.PREFERENCES_HOME_KEY, false);
-
-                if (!homeKey) {
-                    if (!mWorkspace.isDefaultScreenShowing()) {
-                        mWorkspace.moveToDefaultScreen();
-                    }
-
-                    if (mGesturesWindow == null || mGesturesWindow.isShowing()) {
-                        hideGesturesPanel();
-                    }                    
-                } else {
-                    if (mGesturesPanel != null && mDragLayer.getWindowVisibility() == View.VISIBLE
-                            && (mDragLayer.hasWindowFocus() || (mGesturesWindow != null
-                            && mGesturesWindow.isShowing()))) {
-
-                        SearchManager searchManager =
-                                (SearchManager) getSystemService(Context.SEARCH_SERVICE);
-
-                        if (!searchManager.isVisible()) {
-                            onHomeKeyPressed();
-                        }
-                    }
+                if (!mWorkspace.isDefaultScreenShowing()) {
+                    mWorkspace.moveToDefaultScreen();
                 }
 
                 closeDrawer();
@@ -1019,83 +838,6 @@
         }
     }
 
-    private void onHomeKeyPressed() {
-        if (mGesturesWindow == null || !mGesturesWindow.isShowing()) {
-            showGesturesPanel();
-        } else {
-            hideGesturesPanel();
-        }
-    }
-
-    private void showGesturesPanel() {
-        showGesturesPanel(true);
-    }
-
-    private void showGesturesPanel(boolean animate) {
-        resetGesturesPrompt();
-
-        mGesturesAdd.setVisibility(View.GONE);
-
-        mGesturesOverlay.clear(false);
-
-        PopupWindow window;
-        if (mGesturesWindow == null) {
-            mGesturesWindow = new PopupWindow(this);
-            window = mGesturesWindow;
-            window.setFocusable(true);
-            window.setTouchable(true);
-            window.setBackgroundDrawable(getResources().getDrawable(
-                    android.R.drawable.screen_background_dark));
-            window.setContentView(mGesturesPanel);
-        } else {
-            window = mGesturesWindow;
-        }
-        window.setAnimationStyle(animate ? com.android.internal.R.style.Animation_Toast : 0);
-
-        final int[] xy = new int[2];
-        final DragLayer dragLayer = mDragLayer;
-        dragLayer.getLocationOnScreen(xy);
-
-        window.setWidth(dragLayer.getWidth());
-        window.setHeight(dragLayer.getHeight() - 1);
-        window.showAtLocation(dragLayer, Gravity.TOP | Gravity.LEFT, xy[0], xy[1] + 1);
-    }
-
-    private void resetGesturesPrompt() {
-        mGesturesAction.intent = null;
-        mGesturesPrompt.setText(R.string.gestures_instructions);
-        mGesturesPrompt.setVisibility(View.VISIBLE);
-        mGesturesSend.setVisibility(View.GONE);
-    }
-
-    private void setGestureUnknown() {
-        mGesturesAction.intent = null;
-        mGesturesPrompt.setText(R.string.gestures_unknown);
-        mGesturesPrompt.setVisibility(View.VISIBLE);
-        mGesturesSend.setVisibility(View.GONE);
-    }
-
-    private void setGestureAction(Drawable icon, CharSequence title) {
-        mGesturesPrompt.setVisibility(View.GONE);
-        mGesturesSend.setVisibility(View.VISIBLE);
-        mGesturesSend.setText(title);
-        mGesturesSend.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
-    }
-
-    void hideGesturesPanel() {
-        hideGesturesPanel(true);
-    }
-
-    void hideGesturesPanel(boolean animate) {
-        if (mGesturesWindow != null) {
-            final PopupWindow popupWindow = mGesturesWindow;
-            popupWindow.setAnimationStyle(animate ?
-                    com.android.internal.R.style.Animation_Toast : 0);
-            popupWindow.update();
-            popupWindow.dismiss();
-        }
-    }
-
     @Override
     protected void onRestoreInstanceState(Bundle savedInstanceState) {
         // Do not call super here
@@ -1146,21 +888,6 @@
             outState.putBoolean(RUNTIME_STATE_PENDING_FOLDER_RENAME, true);
             outState.putLong(RUNTIME_STATE_PENDING_FOLDER_RENAME_ID, mFolderInfo.id);
         }
-
-        if (mCurrentGesture != null && mWaitingForResult) {
-            outState.putParcelable(RUNTIME_STATE_PENDING_GESTURE, mCurrentGesture);
-        }
-
-        if (mGesturesWindow != null && mGesturesWindow.isShowing()) {
-            outState.putBoolean(RUNTIME_STATE_GESTURES_PANEL, true);
-
-            if (mCurrentGesture == null || !mWaitingForResult) {
-                final Gesture gesture = mGesturesOverlay.getGesture();
-                if (gesture != null) {
-                    outState.putParcelable(RUNTIME_STATE_GESTURES_PANEL_GESTURE, gesture);
-                }
-            }
-        }
     }
 
     @Override
@@ -1177,7 +904,6 @@
 
         TextKeyListener.getInstance().release();
 
-        hideGesturesPanel(false);
         mAllAppsGrid.clearTextFilter();
         mAllAppsGrid.setAdapter(null);
         sModel.unbind();
@@ -1280,11 +1006,6 @@
                 .setIcon(com.android.internal.R.drawable.ic_menu_notifications)
                 .setAlphabeticShortcut('N');
 
-        // TODO: Remove
-        menu.add(0, MENU_GESTURES, 0, R.string.menu_gestures)
-                .setIcon(com.android.internal.R.drawable.ic_menu_compose)
-                .setAlphabeticShortcut('G');
-
         final Intent settings = new Intent(android.provider.Settings.ACTION_SETTINGS);
         settings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
                 Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
@@ -1321,9 +1042,6 @@
             case MENU_NOTIFICATIONS:
                 showNotifications();
                 return true;
-            case MENU_GESTURES:
-                showGesturesPanel();
-                return true;
         }
 
         return super.onOptionsItemSelected(item);
@@ -1852,7 +1570,6 @@
     }
 
     void startActivitySafely(Intent intent) {
-        mHideGesturesPanel = true;
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         try {
             startActivity(intent);
@@ -1979,14 +1696,6 @@
         return sModel;
     }
 
-    static GestureLibrary getGestureLibrary(Context context) {
-        if (sLibrary == null) {
-            // The context is not kept by the library so it's safe to do this
-            sLibrary = GestureLibraries.fromPrivateFile(context, GesturesConstants.STORE_NAME);
-        }
-        return sLibrary;
-    }
-
     void closeAllApplications() {
         mDrawer.close();
     }
@@ -2511,139 +2220,4 @@
             }
         }
     }
-
-    private class GesturesProcessor implements GestureOverlayView.OnGestureListener {
-
-        private final GestureMatcher mMatcher = new GestureMatcher();
-
-        GesturesProcessor() {
-            // TODO: Maybe the load should happen on a background thread?
-            sLibrary.load();
-        }
-
-        public void onGestureStarted(GestureOverlayView overlay, MotionEvent event) {
-            //noinspection PointlessBooleanExpression,ConstantConditions
-            if (!CONFIG_GESTURES_IMMEDIATE_MODE) {
-                overlay.removeCallbacks(mMatcher);
-                resetGesturesPrompt();
-            }
-
-            mGesturesAdd.setVisibility(View.GONE);
-        }
-
-        public void onGesture(GestureOverlayView overlay, MotionEvent event) {
-        }
-
-        public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) {
-            if (CONFIG_GESTURES_IMMEDIATE_MODE) {
-                mMatcher.gesture = overlay.getGesture();
-                if (mMatcher.gesture.getLength() < GesturesConstants.LENGTH_THRESHOLD) {
-                    overlay.clear(false);
-                    if (mGesturesAction.intent != null) {
-                        mGesturesAction.intent = null;
-                        setGestureAction(null, getString(R.string.gestures_unknown));
-                    }
-                } else {
-                    mMatcher.run();
-                }
-            } else {
-                overlay.removeCallbacks(mMatcher);
-
-                mMatcher.gesture = overlay.getGesture();
-                if (mMatcher.gesture.getLength() < GesturesConstants.LENGTH_THRESHOLD) {
-                    overlay.clear(false);
-                    if (mGesturesAction.intent != null) {
-                        mGesturesAction.intent = null;
-                        setGestureAction(null, getString(R.string.gestures_unknown));
-                    }
-                } else {
-                    overlay.postDelayed(mMatcher, GesturesConstants.MATCH_DELAY);
-                }
-            }
-        }
-
-        void matchGesture(Gesture gesture) {
-            mGesturesAdd.setVisibility(View.VISIBLE);
-
-            if (gesture != null) {
-                final ArrayList<Prediction> predictions = sLibrary.recognize(gesture);
-
-                if (DEBUG_GESTURES) {
-                    for (Prediction p : predictions) {
-                        d(LOG_TAG, String.format("name=%s, score=%f", p.name, p.score));
-                    }
-                }
-
-                boolean match = false;
-                if (predictions.size() > 0) {
-                    final Prediction prediction = predictions.get(0);
-                    if (prediction.score > GesturesConstants.PREDICTION_THRESHOLD) {
-                        match = true;
-
-                        ApplicationInfo info = sModel.queryGesture(Launcher.this, prediction.name);
-                        if (info != null) {
-                            updatePrompt(info);
-                        }
-                    }
-                }
-
-                if (!match){
-                    mGesturesAction.intent = null;
-                    setGestureUnknown();
-                }
-            }
-        }
-
-        private void updatePrompt(ApplicationInfo info) {
-            // TODO: BRING BACK            
-            if (mGesturesAction.intent != null &&
-                    info.intent.toUri(0).equals(mGesturesAction.intent.toUri(0)) &&
-                    info.title.equals(mGesturesSend.getText())) {
-                return;
-            }
-
-            setGestureAction(info.icon, info.title);
-
-            mGesturesAction.intent = info.intent;
-        }
-
-        public void onGestureCancelled(GestureOverlayView overlay, MotionEvent event) {
-            //noinspection PointlessBooleanExpression,ConstantConditions
-            if (!CONFIG_GESTURES_IMMEDIATE_MODE) {
-                overlay.removeCallbacks(mMatcher);
-            }
-        }
-
-        void addGesture(String name, Gesture gesture) {
-            sLibrary.addGesture(name, gesture);
-            // TODO: On a background thread?
-            sLibrary.save();
-        }
-
-        void update(ApplicationInfo info, Gesture gesture) {
-            mGesturesOverlay.setGesture(gesture);
-            updatePrompt(info);
-        }
-
-        class GestureMatcher implements Runnable {
-            Gesture gesture;
-
-            public void run() {
-                if (gesture != null) {
-                    matchGesture(gesture);
-                }
-            }
-        }
-    }
-
-    private class GesturesAction implements View.OnClickListener {
-        Intent intent;
-
-        public void onClick(View v) {
-            if (intent != null) {
-                startActivitySafely(intent);
-            }
-        }
-    }
 }
-