New small/large screen division for Launcher.

Previously the dp division between the two was set at 600dp
(7" tablets). This has now been bumped up to 720dp
(10" tablets).

Change-Id: I1f0419e504fc3bb606156c1cf6fbe03956274184
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java
index dc498a4..ad39541 100644
--- a/src/com/android/launcher2/BubbleTextView.java
+++ b/src/com/android/launcher2/BubbleTextView.java
@@ -176,6 +176,7 @@
         // The translate of scrollX and scrollY is necessary when drawing TextViews, because
         // they set scrollX and scrollY to large values to achieve centered text
         destCanvas.save();
+        destCanvas.scale(getScaleX(), getScaleY(), getWidth() / 2, getHeight() / 2);
         destCanvas.translate(-getScrollX() + padding / 2, -getScrollY() + padding / 2);
         destCanvas.clipRect(clipRect, Op.REPLACE);
         draw(destCanvas);
@@ -286,6 +287,14 @@
                 canvas.translate(-scrollX, -scrollY);
             }
         }
+
+        // If text is transparent, don't draw any shadow
+        if (getCurrentTextColor() == android.R.color.transparent) {
+            getPaint().clearShadowLayer();
+            super.draw(canvas);
+            return;
+        }
+
         // We enhance the shadow by drawing the shadow twice
         getPaint().setShadowLayer(SHADOW_LARGE_RADIUS, 0.0f, SHADOW_Y_OFFSET, SHADOW_LARGE_COLOUR);
         super.draw(canvas);
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 8aae809..a6c2c5f 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -28,6 +28,7 @@
 import android.content.res.TypedArray;
 import android.graphics.Bitmap;
 import android.graphics.Canvas;
+import android.graphics.Color;
 import android.graphics.Paint;
 import android.graphics.Point;
 import android.graphics.PointF;
@@ -135,6 +136,9 @@
     private TimeInterpolator mEaseOutInterpolator;
     private CellLayoutChildren mChildren;
 
+    private boolean mIsHotseat = false;
+    private final int mBubbleScalePercent;
+
     public CellLayout(Context context) {
         this(context, null);
     }
@@ -180,6 +184,8 @@
         mNormalBackground.setFilterBitmap(true);
         mActiveGlowBackground.setFilterBitmap(true);
 
+        mBubbleScalePercent = res.getInteger(R.integer.app_icon_hotseat_scale_percent);
+
         // Initialize the data structures used for the drag visualization.
 
         mCrosshairsDrawable = res.getDrawable(R.drawable.gardening_crosshairs);
@@ -492,6 +498,25 @@
 
     @Override
     protected void dispatchDraw(Canvas canvas) {
+        // Debug drawing for hit space
+        if (false) {
+            final Rect frame = mRect;
+            for (int i = mChildren.getChildCount() - 1; i >= 0; i--) {
+                final View child = mChildren.getChildAt(i);
+                final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+
+                if ((child.getVisibility() == VISIBLE || child.getAnimation() != null) &&
+                        lp.isLockedToGrid) {
+                    child.getHitRect(frame);
+                    frame.offset(mPaddingLeft, mPaddingTop);
+
+                    Paint p = new Paint();
+                    p.setColor(Color.GREEN);
+                    canvas.drawRect(frame, p);
+                }
+            }
+        }
+
         super.dispatchDraw(canvas);
         if (mForegroundAlpha > 0) {
             mOverScrollForegroundDrawable.setBounds(mForegroundRect);
@@ -554,10 +579,55 @@
         return mCountY;
     }
 
+    public void setIsHotseat(boolean isHotseat) {
+        mIsHotseat = isHotseat;
+    }
+
     public boolean addViewToCellLayout(
             View child, int index, int childId, LayoutParams params, boolean markCells) {
+        return addViewToCellLayout(child, index, childId, params, markCells, false);
+    }
+
+    public boolean addViewToCellLayout(View child, int index, int childId, LayoutParams params,
+            boolean markCells, boolean allApps) {
         final LayoutParams lp = params;
 
+        // Hotseat icons - scale down and remove text
+        // Don't scale the all apps button
+        // scale percent set to -1 means do not scale
+        // Only scale BubbleTextViews
+        if (child instanceof BubbleTextView) {
+            BubbleTextView bubbleChild = (BubbleTextView) child;
+
+            if (mIsHotseat && !allApps && mBubbleScalePercent >= 0) {
+                // If we haven't measured the child yet, do it now
+                // (this happens if we're being dropped from all-apps
+                if ((bubbleChild.getMeasuredWidth() | bubbleChild.getMeasuredHeight()) == 0) {
+                    getChildrenLayout().measureChild(bubbleChild);
+                }
+                int measuredWidth = bubbleChild.getMeasuredWidth();
+                int measuredHeight = bubbleChild.getMeasuredHeight();
+
+                float bubbleScale = mBubbleScalePercent / 100f;
+                bubbleChild.setPivotX(0);
+                bubbleChild.setPivotY(0);
+                bubbleChild.setScaleX(bubbleScale);
+                bubbleChild.setScaleY(bubbleScale);
+                bubbleChild.setTranslationX(measuredWidth * (1 - bubbleScale) / 2);
+                bubbleChild.setTranslationY(measuredHeight * (1 - bubbleScale) / 2);
+
+                bubbleChild.setTextColor(android.R.color.transparent);
+            } else {
+                bubbleChild.setScaleX(1f);
+                bubbleChild.setScaleY(1f);
+                bubbleChild.setTranslationX(0f);
+                bubbleChild.setTranslationY(0f);
+
+                bubbleChild.setTextColor(
+                        getResources().getColor(R.color.workspace_icon_text_color));
+            }
+        }
+
         // Generate an id for each view, this assumes we have at most 256x256 cells
         // per workspace screen
         if (lp.cellX >= 0 && lp.cellX <= mCountX - 1 && lp.cellY >= 0 && lp.cellY <= mCountY - 1) {
diff --git a/src/com/android/launcher2/Hotseat.java b/src/com/android/launcher2/Hotseat.java
index f7fa380..add62c0 100644
--- a/src/com/android/launcher2/Hotseat.java
+++ b/src/com/android/launcher2/Hotseat.java
@@ -29,13 +29,13 @@
 
 public class Hotseat extends FrameLayout {
     private static final String TAG = "Hotseat";
-    private static final int sAllAppsButtonRank = 2; // In the middle of the dock
 
     private Launcher mLauncher;
     private CellLayout mContent;
 
     private int mCellCountX;
     private int mCellCountY;
+    private int mAllAppsButtonRank;
     private boolean mIsLandscape;
 
     public Hotseat(Context context) {
@@ -53,6 +53,7 @@
                 R.styleable.Hotseat, defStyle, 0);
         mCellCountX = a.getInt(R.styleable.Hotseat_cellCountX, -1);
         mCellCountY = a.getInt(R.styleable.Hotseat_cellCountY, -1);
+        mAllAppsButtonRank = context.getResources().getInteger(R.integer.hotseat_all_apps_index);
         mIsLandscape = context.getResources().getConfiguration().orientation ==
             Configuration.ORIENTATION_LANDSCAPE;
     }
@@ -77,8 +78,8 @@
     int getCellYFromOrder(int rank) {
         return mIsLandscape ? (mContent.getCountY() - (rank + 1)) : 0;
     }
-    public static boolean isAllAppsButtonRank(int rank) {
-        return rank == sAllAppsButtonRank;
+    public boolean isAllAppsButtonRank(int rank) {
+        return rank == mAllAppsButtonRank;
     }
 
     @Override
@@ -88,6 +89,7 @@
         if (mCellCountY < 0) mCellCountY = LauncherModel.getCellCountY();
         mContent = (CellLayout) findViewById(R.id.layout);
         mContent.setGridSize(mCellCountX, mCellCountY);
+        mContent.setIsHotseat(true);
 
         resetLayout();
     }
@@ -126,9 +128,9 @@
 
         // Note: We do this to ensure that the hotseat is always laid out in the orientation of
         // the hotseat in order regardless of which orientation they were added
-        int x = getCellXFromOrder(sAllAppsButtonRank);
-        int y = getCellYFromOrder(sAllAppsButtonRank);
+        int x = getCellXFromOrder(mAllAppsButtonRank);
+        int y = getCellYFromOrder(mAllAppsButtonRank);
         mContent.addViewToCellLayout(allAppsButton, -1, 0, new CellLayout.LayoutParams(x,y,1,1),
-                true);
+                true, true);
     }
 }
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 8e074b5..63fb12c 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2129,6 +2129,10 @@
         return (mState == State.APPS_CUSTOMIZE);
     }
 
+    public boolean isAllAppsButtonRank(int rank) {
+        return mHotseat.isAllAppsButtonRank(rank);
+    }
+
     // AllAppsView.Watcher
     public void zoomed(float zoom) {
         if (zoom == 1.0f) {
diff --git a/src/com/android/launcher2/LauncherApplication.java b/src/com/android/launcher2/LauncherApplication.java
index 9936ca6..29c93be 100644
--- a/src/com/android/launcher2/LauncherApplication.java
+++ b/src/com/android/launcher2/LauncherApplication.java
@@ -26,6 +26,8 @@
 import android.database.ContentObserver;
 import android.os.Handler;
 
+import com.android.launcher.R;
+
 import java.lang.ref.WeakReference;
 
 public class LauncherApplication extends Application {
@@ -40,10 +42,7 @@
         super.onCreate();
 
         // set sIsScreenXLarge and sScreenDensity *before* creating icon cache
-        final int screenSize = getResources().getConfiguration().screenLayout &
-                Configuration.SCREENLAYOUT_SIZE_MASK;
-        sIsScreenLarge = screenSize == Configuration.SCREENLAYOUT_SIZE_LARGE ||
-            screenSize == Configuration.SCREENLAYOUT_SIZE_XLARGE;
+        sIsScreenLarge = getResources().getBoolean(R.bool.is_large_screen);
         sScreenDensity = getResources().getDisplayMetrics().density;
 
         mIconCache = new IconCache(this);
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index 7da55db..159ddb0 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -138,6 +138,7 @@
         public void bindAppsRemoved(ArrayList<ApplicationInfo> apps, boolean permanent);
         public void bindPackagesUpdated();
         public boolean isAllAppsVisible();
+        public boolean isAllAppsButtonRank(int rank);
         public void bindSearchablesChanged();
     }
 
@@ -920,7 +921,7 @@
             int containerIndex = item.screen;
             if (item.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
                 // Return early if we detect that an item is under the hotseat button
-                if (Hotseat.isAllAppsButtonRank(item.screen)) {
+                if (mCallbacks == null || mCallbacks.get().isAllAppsButtonRank(item.screen)) {
                     return false;
                 }
 
diff --git a/src/com/android/launcher2/LauncherProvider.java b/src/com/android/launcher2/LauncherProvider.java
index a01cc47..de9a9b2 100644
--- a/src/com/android/launcher2/LauncherProvider.java
+++ b/src/com/android/launcher2/LauncherProvider.java
@@ -706,6 +706,8 @@
             ContentValues values = new ContentValues();
 
             PackageManager packageManager = mContext.getPackageManager();
+            int allAppsButtonRank =
+                    mContext.getResources().getInteger(R.integer.hotseat_all_apps_index);
             int i = 0;
             try {
                 XmlResourceParser parser = mContext.getResources().getXml(workspaceResourceId);
@@ -739,8 +741,8 @@
                     // If we are adding to the hotseat, the screen is used as the position in the
                     // hotseat. This screen can't be at position 0 because AllApps is in the
                     // zeroth position.
-                    if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT &&
-                            Hotseat.isAllAppsButtonRank(Integer.valueOf(screen))) {
+                    if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT
+                            && Integer.valueOf(screen) == allAppsButtonRank) {
                         throw new RuntimeException("Invalid screen position for hotseat item");
                     }
 
diff --git a/src/com/android/launcher2/Utilities.java b/src/com/android/launcher2/Utilities.java
index d7562a9..0387011 100644
--- a/src/com/android/launcher2/Utilities.java
+++ b/src/com/android/launcher2/Utilities.java
@@ -113,7 +113,6 @@
             }
             int sourceWidth = icon.getIntrinsicWidth();
             int sourceHeight = icon.getIntrinsicHeight();
-
             if (sourceWidth > 0 && sourceHeight > 0) {
                 // There are intrinsic sizes.
                 if (width < sourceWidth || height < sourceHeight) {
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 7ba3950..a6a1ed5 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -658,7 +658,7 @@
                 return;
             } else if (theta > START_DAMPING_TOUCH_SLOP_ANGLE) {
                 // Above START_DAMPING_TOUCH_SLOP_ANGLE and below MAX_SWIPE_ANGLE, we want to
-                // increase the touch slop to make it harder to begin scrolling the workspace. This 
+                // increase the touch slop to make it harder to begin scrolling the workspace. This
                 // results in vertically scrolling widgets to more easily. The higher the angle, the
                 // more we increase touch slop.
                 theta -= START_DAMPING_TOUCH_SLOP_ANGLE;
@@ -1444,7 +1444,7 @@
      * This interpolator emulates the rate at which the perceived scale of an object changes
      * as its distance from a camera increases. When this interpolator is applied to a scale
      * animation on a view, it evokes the sense that the object is shrinking due to moving away
-     * from the camera. 
+     * from the camera.
      */
     static class ZInterpolator implements TimeInterpolator {
         private float focalLength;
@@ -1621,7 +1621,7 @@
             setLayoutScale(1.0f);
         }
 
-        final int duration = zoomIn ? 
+        final int duration = zoomIn ?
                 getResources().getInteger(R.integer.config_workspaceUnshrinkTime) :
                 getResources().getInteger(R.integer.config_appsCustomizeWorkspaceShrinkTime);
         for (int i = 0; i < getChildCount(); i++) {
@@ -2056,7 +2056,7 @@
                 // is full
                 if (mTargetCell != null && mLauncher.isHotseatLayout(mDragTargetLayout)) {
                     Hotseat hotseat = mLauncher.getHotseat();
-                    if (Hotseat.isAllAppsButtonRank(
+                    if (hotseat.isAllAppsButtonRank(
                             hotseat.getOrderInHotseat(mTargetCell[0], mTargetCell[1]))) {
                         return false;
                     }
@@ -3043,6 +3043,7 @@
             CellLayout.LayoutParams lp = (CellLayout.LayoutParams) view.getLayoutParams();
             cellLayout.getChildrenLayout().measureChild(view);
 
+
             LauncherModel.addOrMoveItemInDatabase(mLauncher, info, container, screen,
                     lp.cellX, lp.cellY);