Merge change 3947 into donut

* changes:
  Fixes #1824492. Removes the clock from the default Home layout.
diff --git a/res/layout/gestures_settings_item.xml b/res/layout/gestures_settings_item.xml
index 3c47cab..1563dfe 100644
--- a/res/layout/gestures_settings_item.xml
+++ b/res/layout/gestures_settings_item.xml
@@ -24,7 +24,7 @@
 
     android:drawablePadding="12dip"
     android:paddingLeft="6dip"
-    android:paddingRight="2dip"
+    android:paddingRight="6dip"
 
     android:ellipsize="marquee"
     android:singleLine="true"
diff --git a/src/com/android/launcher/Launcher.java b/src/com/android/launcher/Launcher.java
index 88c411a..5131081 100644
--- a/src/com/android/launcher/Launcher.java
+++ b/src/com/android/launcher/Launcher.java
@@ -105,6 +105,8 @@
     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;
 
     private static final int MENU_GROUP_ADD = 1;
@@ -585,7 +587,6 @@
         mGesturesProcessor = new GesturesProcessor();
 
         final GestureOverlayView overlay = mGesturesOverlay;
-        overlay.setFadeOffset(GesturesConstants.MATCH_DELAY);
         overlay.addOnGestureListener(mGesturesProcessor);
         overlay.getGesturePaint().setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));
     }
@@ -2350,8 +2351,11 @@
         }
 
         public void onGestureStarted(GestureOverlayView overlay, MotionEvent event) {
-            overlay.removeCallbacks(mMatcher);
-            resetGesturesNextPrompt();
+            //noinspection PointlessBooleanExpression,ConstantConditions
+            if (!CONFIG_GESTURES_IMMEDIATE_MODE) {
+                overlay.removeCallbacks(mMatcher);
+                resetGesturesNextPrompt();
+            }
 
             mGesturesAdd.setAlpha(128);
             mGesturesAdd.setEnabled(false);
@@ -2364,13 +2368,22 @@
         }
 
         public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) {
-            overlay.removeCallbacks(mMatcher);
-
-            mMatcher.gesture = overlay.getGesture();
-            if (mMatcher.gesture.getLength() < GesturesConstants.LENGTH_THRESHOLD) {
-                overlay.clear(false);
+            if (CONFIG_GESTURES_IMMEDIATE_MODE) {
+                mMatcher.gesture = overlay.getGesture();
+                if (mMatcher.gesture.getLength() < GesturesConstants.LENGTH_THRESHOLD) {
+                    overlay.clear(false);
+                } else {
+                    mMatcher.run();
+                }
             } else {
-                overlay.postDelayed(mMatcher, GesturesConstants.MATCH_DELAY);
+                overlay.removeCallbacks(mMatcher);
+
+                mMatcher.gesture = overlay.getGesture();
+                if (mMatcher.gesture.getLength() < GesturesConstants.LENGTH_THRESHOLD) {
+                    overlay.clear(false);
+                } else {
+                    overlay.postDelayed(mMatcher, GesturesConstants.MATCH_DELAY);
+                }
             }
         }
 
@@ -2407,12 +2420,20 @@
         }
 
         private void updatePrompt(ApplicationInfo info) {
+            if (mGesturesAction.intent != null &&
+                    info.intent.toURI().equals(mGesturesAction.intent.toURI()) &&
+                    info.title.equals(((TextView) mGesturesPrompt.getCurrentView()).getText())) {
+                return;
+            }
             setGesturesNextPrompt(info.icon, info.title);
             mGesturesAction.intent = info.intent;
         }
 
         public void onGestureCancelled(GestureOverlayView overlay, MotionEvent event) {
-            overlay.removeCallbacks(mMatcher);
+            //noinspection PointlessBooleanExpression,ConstantConditions
+            if (!CONFIG_GESTURES_IMMEDIATE_MODE) {
+                overlay.removeCallbacks(mMatcher);
+            }
         }
 
         void addGesture(String name, Gesture gesture) {
diff --git a/src/com/android/launcher/LauncherModel.java b/src/com/android/launcher/LauncherModel.java
index 271f9f4..cd0ffd2 100644
--- a/src/com/android/launcher/LauncherModel.java
+++ b/src/com/android/launcher/LauncherModel.java
@@ -116,7 +116,7 @@
 
         if (localeChanged) {
             dropApplicationCache();
-        }        
+        }
 
         if (mApplicationsAdapter == null || isLaunching || localeChanged) {
             mApplications = new ArrayList<ApplicationInfo>(DEFAULT_APPLICATIONS_NUMBER);
@@ -126,7 +126,7 @@
         mApplicationsLoaded = false;
 
         if (!isLaunching) {
-            startApplicationsLoader(launcher);
+            startApplicationsLoader(launcher, false);
             return false;
         }
 
@@ -148,19 +148,19 @@
         }
     }
 
-    private synchronized void startApplicationsLoader(Launcher launcher) {
+    private synchronized void startApplicationsLoader(Launcher launcher, boolean isLaunching) {
         if (DEBUG_LOADERS) d(LOG_TAG, "  --> starting applications loader");
 
         stopAndWaitForApplicationsLoader();
 
-        mApplicationsLoader = new ApplicationsLoader(launcher);
+        mApplicationsLoader = new ApplicationsLoader(launcher, isLaunching);
         mApplicationsLoaderThread = new Thread(mApplicationsLoader, "Applications Loader");
         mApplicationsLoaderThread.start();
     }
 
     synchronized void addPackage(Launcher launcher, String packageName) {
         if (mApplicationsLoader != null && mApplicationsLoader.isRunning()) {
-            startApplicationsLoader(launcher);
+            startApplicationsLoader(launcher, false);
             return;
         }
 
@@ -186,7 +186,7 @@
     synchronized void removePackage(Launcher launcher, String packageName) {
         if (mApplicationsLoader != null && mApplicationsLoader.isRunning()) {
             dropApplicationCache(); // TODO: this could be optimized
-            startApplicationsLoader(launcher);
+            startApplicationsLoader(launcher, false);
             return;
         }
 
@@ -221,7 +221,7 @@
 
     synchronized void updatePackage(Launcher launcher, String packageName) {
         if (mApplicationsLoader != null && mApplicationsLoader.isRunning()) {
-            startApplicationsLoader(launcher);
+            startApplicationsLoader(launcher, false);
             return;
         }
 
@@ -263,7 +263,7 @@
 
     synchronized void syncPackage(Launcher launcher, String packageName) {
         if (mApplicationsLoader != null && mApplicationsLoader.isRunning()) {
-            startApplicationsLoader(launcher);
+            startApplicationsLoader(launcher, false);
             return;
         }
 
@@ -461,8 +461,10 @@
 
         private volatile boolean mStopped;
         private volatile boolean mRunning;
+        private final boolean mIsLaunching;
 
-        ApplicationsLoader(Launcher launcher) {
+        ApplicationsLoader(Launcher launcher, boolean isLaunching) {
+            mIsLaunching = isLaunching;
             mLauncher = new WeakReference<Launcher>(launcher);
         }
 
@@ -477,7 +479,10 @@
         public void run() {
             mRunning = true;
 
-            android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
+            // Elevate priority when Home launches for the first time to avoid
+            // starving at boot time. Staring at a blank home is not cool.
+            android.os.Process.setThreadPriority(mIsLaunching ? Process.THREAD_PRIORITY_DEFAULT :
+                    Process.THREAD_PRIORITY_BACKGROUND);
 
             final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
             mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
@@ -580,7 +585,7 @@
 
         if (isLaunching && isDesktopLoaded()) {
             if (DEBUG_LOADERS) d(LOG_TAG, "  --> items loaded, return");
-            if (loadApplications) startApplicationsLoader(launcher);
+            if (loadApplications) startApplicationsLoader(launcher, true);
             // We have already loaded our data from the DB
             launcher.onDesktopItemsLoaded();
             return;
@@ -607,7 +612,8 @@
 
         if (DEBUG_LOADERS) d(LOG_TAG, "  --> starting workspace loader");
         mDesktopItemsLoaded = false;
-        mDesktopItemsLoader = new DesktopItemsLoader(launcher, localeChanged, loadApplications);
+        mDesktopItemsLoader = new DesktopItemsLoader(launcher, localeChanged, loadApplications,
+                isLaunching);
         mDesktopLoaderThread = new Thread(mDesktopItemsLoader, "Desktop Items Loader");
         mDesktopLoaderThread.start();
     }
@@ -688,9 +694,12 @@
         private final WeakReference<Launcher> mLauncher;
         private final boolean mLocaleChanged;
         private final boolean mLoadApplications;
+        private final boolean mIsLaunching;
 
-        DesktopItemsLoader(Launcher launcher, boolean localeChanged, boolean loadApplications) {
+        DesktopItemsLoader(Launcher launcher, boolean localeChanged, boolean loadApplications,
+                boolean isLaunching) {
             mLoadApplications = loadApplications;
+            mIsLaunching = isLaunching;
             mLauncher = new WeakReference<Launcher>(launcher);
             mLocaleChanged = localeChanged;
         }
@@ -706,6 +715,8 @@
         public void run() {
             mRunning = true;
 
+            android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);
+
             final Launcher launcher = mLauncher.get();
             final ContentResolver contentResolver = launcher.getContentResolver();
             final PackageManager manager = launcher.getPackageManager();
@@ -912,7 +923,7 @@
                         launcher.onDesktopItemsLoaded();
                     }
                 });
-                if (mLoadApplications) startApplicationsLoader(launcher);
+                if (mLoadApplications) startApplicationsLoader(launcher, mIsLaunching);
             }
 
             if (!mStopped) {
@@ -1076,7 +1087,7 @@
     ArrayList<ItemInfo> getDesktopItems() {
         return mDesktopItems;
     }
-    
+
     /**
      * @return The current list of desktop items
      */
@@ -1092,7 +1103,7 @@
         // TODO: write to DB; also check that folder has been added to folders list
         mDesktopItems.add(info);
     }
-    
+
     /**
      * Remove an item from the desktop
      * @param info
@@ -1108,7 +1119,7 @@
     void addDesktopAppWidget(LauncherAppWidgetInfo info) {
         mDesktopAppWidgets.add(info);
     }
-    
+
     /**
      * Remove a widget from the desktop
      */
@@ -1126,7 +1137,7 @@
         if (resolveInfo == null) {
             return null;
         }
-        
+
         final ApplicationInfo info = new ApplicationInfo();
         final ActivityInfo activityInfo = resolveInfo.activityInfo;
         info.icon = Utilities.createIconThumbnail(activityInfo.loadIcon(manager), context);
@@ -1139,7 +1150,7 @@
         info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
         return info;
     }
-    
+
     /**
      * Make an ApplicationInfo object for a sortcut
      */
@@ -1195,7 +1206,7 @@
         //noinspection SuspiciousMethodCalls
         folder.contents.remove(info);
     }
-    
+
     /**
      * Removes a UserFolder from the in-memory list of folders. Does not change the DB.
      * @param userFolderInfo
@@ -1203,7 +1214,7 @@
     void removeUserFolder(UserFolderInfo userFolderInfo) {
         mFolders.remove(userFolderInfo.id);
     }
-    
+
     /**
      * Adds an item to the DB if it was not created previously, or move it to a new
      * <container, screen, cellX, cellY>
@@ -1218,7 +1229,7 @@
             moveItemInDatabase(context, item, container, screen, cellX, cellY);
         }
     }
-    
+
     /**
      * Move an item in the DB to a new <container, screen, cellX, cellY>
      */
@@ -1228,7 +1239,7 @@
         item.screen = screen;
         item.cellX = cellX;
         item.cellY = cellY;
-     
+
         final ContentValues values = new ContentValues();
         final ContentResolver cr = context.getContentResolver();
 
@@ -1311,12 +1322,12 @@
         item.screen = screen;
         item.cellX = cellX;
         item.cellY = cellY;
-        
+
         final ContentValues values = new ContentValues();
         final ContentResolver cr = context.getContentResolver();
-        
+
         item.onAddToDatabase(values);
-        
+
         Uri result = cr.insert(notify ? LauncherSettings.Favorites.CONTENT_URI :
                 LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, values);
 
@@ -1356,7 +1367,7 @@
 
         cr.update(LauncherSettings.Favorites.getContentUri(item.id, false), values, null, null);
     }
-    
+
     /**
      * Removes the specified item from the database
      * @param context