Cleaning up grid size specification in Launcher

This commit eliminates the notion of in-place rotations and a bunch of
associated complexities (including the notion of canonical coordinates).
Further, the number of x and y cells per workspace screen is now being stored
in a single location in the XML definition of Workspace. This fixes a couple
bugs where incorrect values were being used. Finally, eliminated the notion of
"shortAxis" and "longAxis" in terms of padding and cell count. These have been
translated to corresponding x and y axis values.

Change-Id: I30cfed66f82d739355b3f01730b28b6c0437989c
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index 1f13f1f..8d38a3d6 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -24,14 +24,16 @@
 
     <include layout="@layout/all_apps" />
 
-    <!-- The workspace contains 3 screens of cells -->
+    <!-- The workspace contains 5 screens of cells -->
     <com.android.launcher2.Workspace
         android:id="@+id/workspace"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:scrollbars="horizontal"
         android:fadeScrollbars="true"
-        launcher:defaultScreen="2">
+        launcher:defaultScreen="2"
+        launcher:cellCountX="4"
+        launcher:cellCountY="4">
 
         <include android:id="@+id/cell1" layout="@layout/workspace_screen" />
         <include android:id="@+id/cell2" layout="@layout/workspace_screen" />
diff --git a/res/layout-land/workspace_screen.xml b/res/layout-land/workspace_screen.xml
index 315e68b..9323f58 100644
--- a/res/layout-land/workspace_screen.xml
+++ b/res/layout-land/workspace_screen.xml
@@ -24,9 +24,7 @@
 
     launcher:cellWidth="@dimen/workspace_cell_width"
     launcher:cellHeight="@dimen/workspace_cell_height"
-    launcher:longAxisStartPadding="65dip"
-    launcher:longAxisEndPadding="65dip"
-    launcher:shortAxisStartPadding="0dip"
-    launcher:shortAxisEndPadding="0dip"
-    launcher:shortAxisCells="4"
-    launcher:longAxisCells="4" />
+    launcher:xAxisStartPadding="65dip"
+    launcher:xAxisEndPadding="65dip"
+    launcher:yAxisStartPadding="0dip"
+    launcher:yAxisEndPadding="0dip"/>
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index 8dc5092..c50dbca 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -24,12 +24,14 @@
 
     <include layout="@layout/all_apps" />
 
-    <!-- The workspace contains 3 screens of cells -->
+    <!-- The workspace contains 5 screens of cells -->
     <com.android.launcher2.Workspace
         android:id="@+id/workspace"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        launcher:defaultScreen="2">
+        launcher:defaultScreen="2"
+        launcher:cellCountX="4"
+        launcher:cellCountY="4">
 
         <include android:id="@+id/cell1" layout="@layout/workspace_screen" />
         <include android:id="@+id/cell2" layout="@layout/workspace_screen" />
diff --git a/res/layout-port/workspace_screen.xml b/res/layout-port/workspace_screen.xml
index 96df91b..f400c40 100644
--- a/res/layout-port/workspace_screen.xml
+++ b/res/layout-port/workspace_screen.xml
@@ -24,9 +24,7 @@
 
     launcher:cellWidth="@dimen/workspace_cell_width"
     launcher:cellHeight="@dimen/workspace_cell_height"
-    launcher:longAxisStartPadding="8dip"
-    launcher:longAxisEndPadding="@dimen/button_bar_height"
-    launcher:shortAxisStartPadding="0dip"
-    launcher:shortAxisEndPadding="0dip"
-    launcher:shortAxisCells="4"
-    launcher:longAxisCells="4" />
+    launcher:yAxisStartPadding="8dip"
+    launcher:yAxisEndPadding="@dimen/button_bar_height"
+    launcher:xAxisStartPadding="0dip"
+    launcher:xAxisEndPadding="0dip" />
diff --git a/res/layout-xlarge/launcher.xml b/res/layout-xlarge/launcher.xml
index fa323fd..0dd25d2 100644
--- a/res/layout-xlarge/launcher.xml
+++ b/res/layout-xlarge/launcher.xml
@@ -35,8 +35,8 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         launcher:defaultScreen="2"
-        launcher:canonicalDeviceWidth="8"
-        launcher:canonicalDeviceHeight="4">
+        launcher:cellCountX="8"
+        launcher:cellCountY="4">
 
         <include android:id="@+id/cell1" layout="@layout/workspace_screen" />
         <include android:id="@+id/cell2" layout="@layout/workspace_screen" />
diff --git a/res/layout-xlarge/workspace_screen.xml b/res/layout-xlarge/workspace_screen.xml
index aa892b9..6a34975 100644
--- a/res/layout-xlarge/workspace_screen.xml
+++ b/res/layout-xlarge/workspace_screen.xml
@@ -24,9 +24,7 @@
 
     launcher:cellWidth="@dimen/workspace_cell_width"
     launcher:cellHeight="@dimen/workspace_cell_height"
-    launcher:longAxisStartPadding="8dip"
-    launcher:longAxisEndPadding="8dip"
-    launcher:shortAxisStartPadding="8dip"
-    launcher:shortAxisEndPadding="8dip"
-    launcher:shortAxisCells="4"
-    launcher:longAxisCells="8" />
+    launcher:yAxisStartPadding="8dip"
+    launcher:yAxisEndPadding="8dip"
+    launcher:xAxisStartPadding="8dip"
+    launcher:xAxisEndPadding="8dip"/>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index c977f97..be27288 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -32,10 +32,10 @@
     <declare-styleable name="Workspace">
         <!-- The first screen the workspace should display. -->
         <attr name="defaultScreen" format="integer"  />
-        <!-- The number of horizontal cells for the device in its natural orientation -->
-        <attr name="canonicalDeviceWidth" format="integer"  />
-        <!-- The number of vertical cells for the device in its natural orientation -->
-        <attr name="canonicalDeviceHeight" format="integer"  />
+        <!-- The number of horizontal cells in the CellLayout -->
+        <attr name="cellCountX" format="integer"  />
+        <!-- The number of vertical cells in the CellLayout -->
+        <attr name="cellCountY" format="integer"  />
     </declare-styleable>
     
     <!-- CellLayout specific attributes. These attributes are used to customize
@@ -46,17 +46,13 @@
         <!-- The height of a single cell -->
         <attr name="cellHeight" format="dimension"  />
         <!-- Padding to apply at the start of the long axis -->
-        <attr name="longAxisStartPadding" format="dimension"  />
+        <attr name="xAxisStartPadding" format="dimension"  />
         <!-- Padding to apply at the end of the long axis -->
-        <attr name="longAxisEndPadding" format="dimension"  />
+        <attr name="xAxisEndPadding" format="dimension"  />
         <!-- Padding to apply at the start of the short axis -->
-        <attr name="shortAxisStartPadding" format="dimension"  />
+        <attr name="yAxisStartPadding" format="dimension"  />
         <!-- Padding to apply at the end of the short axis -->
-        <attr name="shortAxisEndPadding" format="dimension"  />
-        <!-- Number of cells on the short axis of the CellLayout -->
-        <attr name="shortAxisCells" format="integer" />
-        <!-- Number of cells on the long axis of the CellLayout -->
-        <attr name="longAxisCells" format="integer" />
+        <attr name="yAxisEndPadding" format="dimension"  />
     </declare-styleable>
 
     <!-- DeleteZone specific attributes. These attributes are used to customize
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 16f8135..2a8c573 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -53,18 +53,13 @@
     private int mCellWidth;
     private int mCellHeight;
 
-    private int mLongAxisStartPadding;
-    private int mLongAxisEndPadding;
-    private int mShortAxisStartPadding;
-    private int mShortAxisEndPadding;
-
     private int mLeftPadding;
     private int mRightPadding;
     private int mTopPadding;
     private int mBottomPadding;
 
-    private int mShortAxisCells;
-    private int mLongAxisCells;
+    private int mCountX;
+    private int mCountY;
 
     private int mWidthGap;
     private int mHeightGap;
@@ -132,17 +127,17 @@
         mCellWidth = a.getDimensionPixelSize(R.styleable.CellLayout_cellWidth, 10);
         mCellHeight = a.getDimensionPixelSize(R.styleable.CellLayout_cellHeight, 10);
 
-        mLongAxisStartPadding =
-            a.getDimensionPixelSize(R.styleable.CellLayout_longAxisStartPadding, 10);
-        mLongAxisEndPadding =
-            a.getDimensionPixelSize(R.styleable.CellLayout_longAxisEndPadding, 10);
-        mShortAxisStartPadding =
-            a.getDimensionPixelSize(R.styleable.CellLayout_shortAxisStartPadding, 10);
-        mShortAxisEndPadding =
-            a.getDimensionPixelSize(R.styleable.CellLayout_shortAxisEndPadding, 10);
+        mLeftPadding =
+            a.getDimensionPixelSize(R.styleable.CellLayout_xAxisStartPadding, 10);
+        mRightPadding =
+            a.getDimensionPixelSize(R.styleable.CellLayout_xAxisEndPadding, 10);
+        mTopPadding =
+            a.getDimensionPixelSize(R.styleable.CellLayout_yAxisStartPadding, 10);
+        mBottomPadding =
+            a.getDimensionPixelSize(R.styleable.CellLayout_yAxisEndPadding, 10);
 
-        mShortAxisCells = a.getInt(R.styleable.CellLayout_shortAxisCells, 4);
-        mLongAxisCells = a.getInt(R.styleable.CellLayout_longAxisCells, 4);
+        mCountX = LauncherModel.getCellCountX();
+        mCountY = LauncherModel.getCellCountY();
 
         a.recycle();
 
@@ -196,11 +191,11 @@
     }
 
     int getCountX() {
-        return mPortrait ? mShortAxisCells : mLongAxisCells;
+        return mCountX;
     }
 
     int getCountY() {
-        return mPortrait ? mLongAxisCells : mShortAxisCells;
+        return mCountY;
     }
 
     // Takes canonical layout parameters
@@ -209,11 +204,11 @@
 
         // Generate an id for each view, this assumes we have at most 256x256 cells
         // per workspace screen
-        if (lp.cellX >= 0 && lp.cellX <= getCountX() - 1 && lp.cellY >= 0 && lp.cellY <= getCountY() - 1) {
+        if (lp.cellX >= 0 && lp.cellX <= mCountX - 1 && lp.cellY >= 0 && lp.cellY <= mCountY - 1) {
             // If the horizontal or vertical span is set to -1, it is taken to
             // mean that it spans the extent of the CellLayout
-            if (lp.cellHSpan < 0) lp.cellHSpan = getCountX();
-            if (lp.cellVSpan < 0) lp.cellVSpan = getCountY();
+            if (lp.cellHSpan < 0) lp.cellHSpan = mCountX;
+            if (lp.cellVSpan < 0) lp.cellVSpan = mCountY;
 
             child.setId(childId);
 
@@ -287,8 +282,8 @@
             pointToCellExact(x, y, cellXY);
 
             final boolean portrait = mPortrait;
-            final int xCount = portrait ? mShortAxisCells : mLongAxisCells;
-            final int yCount = portrait ? mLongAxisCells : mShortAxisCells;
+            final int xCount = mCountX;
+            final int yCount = mCountY;
 
             final boolean[][] occupied = mOccupied;
             findOccupiedCells(xCount, yCount, occupied, null, true);
@@ -340,9 +335,8 @@
     public CellInfo getTag() {
         final CellInfo info = (CellInfo) super.getTag();
         if (mDirtyTag && info.valid) {
-            final boolean portrait = mPortrait;
-            final int xCount = portrait ? mShortAxisCells : mLongAxisCells;
-            final int yCount = portrait ? mLongAxisCells : mShortAxisCells;
+            final int xCount = mCountX;
+            final int yCount = mCountY;
 
             final boolean[][] occupied = mOccupied;
             findOccupiedCells(xCount, yCount, occupied, null, true);
@@ -452,9 +446,8 @@
     }
 
     CellInfo findAllVacantCells(boolean[] occupiedCells, View ignoreView) {
-        final boolean portrait = mPortrait;
-        final int xCount = portrait ? mShortAxisCells : mLongAxisCells;
-        final int yCount = portrait ? mLongAxisCells : mShortAxisCells;
+        final int xCount = mCountX;
+        final int yCount = mCountY;
 
         boolean[][] occupied = mOccupied;
 
@@ -507,16 +500,14 @@
      * @param result Array of 2 ints to hold the x and y coordinate of the cell
      */
     void pointToCellExact(int x, int y, int[] result) {
-        final boolean portrait = mPortrait;
-
         final int hStartPadding = getLeftPadding();
         final int vStartPadding = getTopPadding();
 
         result[0] = (x - hStartPadding) / (mCellWidth + mWidthGap);
         result[1] = (y - vStartPadding) / (mCellHeight + mHeightGap);
 
-        final int xAxis = portrait ? mShortAxisCells : mLongAxisCells;
-        final int yAxis = portrait ? mLongAxisCells : mShortAxisCells;
+        final int xAxis = mCountX;
+        final int yAxis = mCountY;
 
         if (result[0] < 0) result[0] = 0;
         if (result[0] >= xAxis) result[0] = xAxis - 1;
@@ -588,75 +579,24 @@
             throw new RuntimeException("CellLayout cannot have UNSPECIFIED dimensions");
         }
 
-        final int shortAxisCells = mShortAxisCells;
-        final int longAxisCells = mLongAxisCells;
         final int cellWidth = mCellWidth;
         final int cellHeight = mCellHeight;
 
-        boolean portrait = heightSpecSize > widthSpecSize;
-        if (portrait != mPortrait || mOccupied == null) {
-            if (portrait) {
-                mOccupied = new boolean[mShortAxisCells][mLongAxisCells];
-            } else {
-                mOccupied = new boolean[mLongAxisCells][mShortAxisCells];
-            }
+        if (mOccupied == null) {
+            mOccupied = new boolean[mCountX][mCountY];
         }
-        mPortrait = portrait;
 
-        int numShortGaps = shortAxisCells - 1;
-        int numLongGaps = longAxisCells - 1;
+        int numWidthGaps = mCountX - 1;
+        int numHeightGaps = mCountY - 1;
 
-        if (mPortrait) {
-            int vSpaceLeft = heightSpecSize - mLongAxisStartPadding
-                    - mLongAxisEndPadding - (cellHeight * longAxisCells);
-            mHeightGap = vSpaceLeft / numLongGaps;
+        int vSpaceLeft = heightSpecSize - mTopPadding
+                - mBottomPadding - (cellHeight * mCountY);
+        mHeightGap = vSpaceLeft / numHeightGaps;
 
-            int hSpaceLeft = widthSpecSize - mShortAxisStartPadding
-                    - mShortAxisEndPadding - (cellWidth * shortAxisCells);
-            if (numShortGaps > 0) {
-                mWidthGap = hSpaceLeft / numShortGaps;
-            } else {
-                mWidthGap = 0;
-            }
+        int hSpaceLeft = widthSpecSize - mLeftPadding
+                - mRightPadding - (cellWidth * mCountX);
+        mWidthGap = hSpaceLeft / numWidthGaps;
 
-            if (LauncherApplication.isInPlaceRotationEnabled()) {
-                mWidthGap = mHeightGap = Math.min(mHeightGap, mWidthGap);
-                mLeftPadding = mRightPadding = (widthSpecSize - cellWidth
-                        * shortAxisCells - (shortAxisCells - 1) * mWidthGap) / 2;
-                mTopPadding = mBottomPadding = (heightSpecSize - cellHeight
-                        * longAxisCells - (longAxisCells - 1) * mHeightGap) / 2;
-            } else {
-                mLeftPadding = mShortAxisStartPadding;
-                mRightPadding = mShortAxisEndPadding;
-                mTopPadding = mLongAxisStartPadding;
-                mBottomPadding = mLongAxisEndPadding;
-            }
-        } else {
-            int hSpaceLeft = widthSpecSize - mLongAxisStartPadding
-                    - mLongAxisEndPadding - (cellWidth * longAxisCells);
-            mWidthGap = hSpaceLeft / numLongGaps;
-
-            int vSpaceLeft = heightSpecSize - mShortAxisStartPadding
-                    - mShortAxisEndPadding - (cellHeight * shortAxisCells);
-            if (numShortGaps > 0) {
-                mHeightGap = vSpaceLeft / numShortGaps;
-            } else {
-                mHeightGap = 0;
-            }
-
-            if (LauncherApplication.isScreenXLarge()) {
-                mWidthGap = mHeightGap = Math.min(mHeightGap, mWidthGap);
-                mLeftPadding = mRightPadding = (widthSpecSize - cellWidth
-                        * longAxisCells - (longAxisCells - 1) * mWidthGap) / 2 ;
-                mTopPadding = mBottomPadding = (heightSpecSize - cellHeight
-                        * shortAxisCells - (shortAxisCells - 1) * mHeightGap) / 2;
-            } else {
-                mLeftPadding = mLongAxisStartPadding;
-                mRightPadding = mLongAxisEndPadding;
-                mTopPadding = mShortAxisStartPadding;
-                mBottomPadding = mShortAxisEndPadding;
-            }
-        }
         int count = getChildCount();
 
         for (int i = 0; i < count; i++) {
@@ -821,8 +761,8 @@
      * @param result The estimated drop cell X and Y.
      */
     void estimateDropCell(int originX, int originY, int spanX, int spanY, int[] result) {
-        final int countX = getCountX();
-        final int countY = getCountY();
+        final int countX = mCountX;
+        final int countY = mCountY;
 
         pointToCellRounded(originX, originY, result);
 
@@ -861,8 +801,8 @@
             bottomRight[0] += mCellWidth;
             bottomRight[1] += mCellHeight;
 
-            final int countX = mPortrait ? mShortAxisCells : mLongAxisCells;
-            final int countY = mPortrait ? mLongAxisCells : mShortAxisCells;
+            final int countX = mCountX;
+            final int countY = mCountY;
             // TODO: It's not necessary to do this every time, but it's not especially expensive
             findOccupiedCells(countX, countY, mOccupied, view, false);
 
@@ -987,7 +927,6 @@
      * @param resultRect Rect into which to put the results
      */
     public void cellToRect(int cellX, int cellY, int cellHSpan, int cellVSpan, RectF resultRect) {
-        final boolean portrait = mPortrait;
         final int cellWidth = mCellWidth;
         final int cellHeight = mCellHeight;
         final int widthGap = mWidthGap;
@@ -1043,9 +982,8 @@
      * @return True if a vacant cell was found
      */
     public boolean getVacantCell(int[] vacant, int spanX, int spanY) {
-        final boolean portrait = mPortrait;
-        final int xCount = portrait ? mShortAxisCells : mLongAxisCells;
-        final int yCount = portrait ? mLongAxisCells : mShortAxisCells;
+        final int xCount = mCountX;
+        final int yCount = mCountY;
         final boolean[][] occupied = mOccupied;
 
         findOccupiedCells(xCount, yCount, occupied, null, true);
@@ -1081,9 +1019,8 @@
      * Update the array of occupied cells (mOccupied), and return a flattened copy of the array.
      */
     boolean[] getOccupiedCellsFlattened() {
-        final boolean portrait = mPortrait;
-        final int xCount = portrait ? mShortAxisCells : mLongAxisCells;
-        final int yCount = portrait ? mLongAxisCells : mShortAxisCells;
+        final int xCount = mCountX;
+        final int yCount = mCountY;
         final boolean[][] occupied = mOccupied;
 
         findOccupiedCells(xCount, yCount, occupied, null, true);
diff --git a/src/com/android/launcher2/InstallShortcutReceiver.java b/src/com/android/launcher2/InstallShortcutReceiver.java
index 3638054..992bab1 100644
--- a/src/com/android/launcher2/InstallShortcutReceiver.java
+++ b/src/com/android/launcher2/InstallShortcutReceiver.java
@@ -84,8 +84,8 @@
     }
 
     private static boolean findEmptyCell(Context context, int[] xy, int screen) {
-        final int xCount = Launcher.NUMBER_CELLS_X;
-        final int yCount = Launcher.NUMBER_CELLS_Y;
+        final int xCount = LauncherModel.getCellCountX();
+        final int yCount = LauncherModel.getCellCountY();
         boolean[][] occupied = new boolean[xCount][yCount];
 
         ArrayList<ItemInfo> items = LauncherModel.getItemsInLocalCoordinates(context);
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 83fe114..ee85436 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -128,8 +128,6 @@
 
     static final int SCREEN_COUNT = 5;
     static final int DEFAULT_SCREEN = 2;
-    static final int NUMBER_CELLS_X = 4;
-    static final int NUMBER_CELLS_Y = 4;
 
     static final int DIALOG_CREATE_SHORTCUT = 1;
     static final int DIALOG_RENAME_FOLDER = 2;
@@ -294,12 +292,6 @@
     public void onConfigurationChanged(Configuration newConfig) {
         // TODO Auto-generated method stub
         super.onConfigurationChanged(newConfig);
-
-        if (LauncherApplication.isInPlaceRotationEnabled()) {
-            mModel.updateOrientation();
-            mWorkspace.refreshWorkspaceChildren();
-            mWorkspace.rotateCurrentScreensChildren();
-        }
     }
 
 
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index 45cef43..6c3ddd2 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -90,7 +90,8 @@
 
     private Bitmap mDefaultIcon;
 
-    private static LauncherModelOrientationHelper mModelOrientationHelper;
+    private static int mCellCountX;
+    private static int mCellCountY;
 
     public interface Callbacks {
         public int getCurrentWorkspaceScreen();
@@ -110,7 +111,6 @@
         mApp = app;
         mAllAppsList = new AllAppsList(iconCache);
         mIconCache = iconCache;
-        mModelOrientationHelper = new LauncherModelOrientationHelper(mApp);
 
         mDefaultIcon = Utilities.createIconBitmap(
                 app.getPackageManager().getDefaultActivityIcon(), app);
@@ -143,14 +143,6 @@
         }
     }
 
-    static int getCurrentOrientation() {
-        return mModelOrientationHelper.getCurrentOrientation();
-    }
-
-    static int getPreviousOrientationRelativeToCurrent() {
-        return mModelOrientationHelper.getPreviousOrientationRelativeToCurrent();
-    }
-
     /**
      * Move an item in the DB to a new <container, screen, cellX, cellY>
      */
@@ -164,11 +156,10 @@
 
         final ContentValues values = new ContentValues();
         final ContentResolver cr = context.getContentResolver();
-        final LauncherModelOrientationHelper.Coordinates coord = mModelOrientationHelper.getCanonicalCoordinates(item);
 
         values.put(LauncherSettings.Favorites.CONTAINER, item.container);
-        values.put(LauncherSettings.Favorites.CELLX, coord.x);
-        values.put(LauncherSettings.Favorites.CELLY, coord.y);
+        values.put(LauncherSettings.Favorites.CELLX, cellX);
+        values.put(LauncherSettings.Favorites.CELLY, cellY);
         values.put(LauncherSettings.Favorites.SCREEN, item.screen);
 
         cr.update(LauncherSettings.Favorites.getContentUri(item.id, false), values, null, null);
@@ -264,13 +255,12 @@
                         break;
                 }
 
-                final LauncherModelOrientationHelper.Coordinates coord = mModelOrientationHelper.getLocalCoordinates(c.getInt(cellXIndex), c.getInt(cellYIndex), 1, 1);
                 folderInfo.title = c.getString(titleIndex);
                 folderInfo.id = id;
                 folderInfo.container = c.getInt(containerIndex);
                 folderInfo.screen = c.getInt(screenIndex);
-                folderInfo.cellX = coord.x;
-                folderInfo.cellY = coord.y;
+                folderInfo.cellX = c.getInt(cellXIndex);
+                folderInfo.cellY = c.getInt(cellYIndex);
 
                 return folderInfo;
             }
@@ -296,9 +286,7 @@
         final ContentResolver cr = context.getContentResolver();
         item.onAddToDatabase(values);
 
-        // update the values to be written with their canonical counterparts
-        final LauncherModelOrientationHelper.Coordinates coord = mModelOrientationHelper.getCanonicalCoordinates(item);
-        item.updateValuesWithCoordinates(values, coord.x, coord.y);
+        item.updateValuesWithCoordinates(values, cellX, cellY);
 
         Uri result = cr.insert(notify ? LauncherSettings.Favorites.CONTENT_URI :
                 LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, values);
@@ -311,31 +299,16 @@
     /**
      * Creates a new unique child id, for a given cell span across all layouts.
      */
-    static int getCanonicalCellLayoutChildId(int cellId, int screen, int localCellX, int localCellY, int spanX, int spanY) {
-        if (LauncherApplication.isInPlaceRotationEnabled()) {
-            LauncherModelOrientationHelper.Coordinates coord = mModelOrientationHelper.getCanonicalCoordinates(localCellX, localCellY, spanX, spanY);
-            return ((screen & 0xFF) << 16) | (coord.x & 0xFF) << 8 | (coord.y & 0xFF);
-        } else {
-            return ((cellId & 0xFF) << 16) | (localCellX & 0xFF) << 8 | (localCellY & 0xFF);
-        }
+    static int getCellLayoutChildId(int cellId, int screen, int localCellX, int localCellY, int spanX, int spanY) {
+        return ((cellId & 0xFF) << 16) | (localCellX & 0xFF) << 8 | (localCellY & 0xFF);
     }
 
-    /*
-     * Convenience functions to help return the local device width and height.
-     */
-    static int getLocalDeviceWidth() {
-        return mModelOrientationHelper.getLocalDeviceWidth();
+    static int getCellCountX() {
+        return mCellCountX;
     }
 
-    static int getLocalDeviceHeight() {
-        return mModelOrientationHelper.getLocalDeviceHeight();
-    }
-
-    /**
-     * Return the new local coordinates given the local coordinates from the previous orientation.
-     */
-    static LauncherModelOrientationHelper.Coordinates getLocalCoordinatesFromPreviousLocalCoordinates(CellLayout.LayoutParams lp) {
-        return mModelOrientationHelper.getLocalCoordinatesFromPreviousLocalCoordinates(lp.cellX, lp.cellY, lp.cellHSpan, lp.cellVSpan);
+    static int getCellCountY() {
+        return mCellCountY;
     }
 
     /**
@@ -343,7 +316,8 @@
      * when performing local/canonical coordinate transformations.
      */
     static void updateWorkspaceLayoutCells(int shortAxisCellCount, int longAxisCellCount) {
-        mModelOrientationHelper.updateDeviceDimensions(shortAxisCellCount, longAxisCellCount);
+        mCellCountX = shortAxisCellCount;
+        mCellCountY = longAxisCellCount;
     }
 
     /**
@@ -354,10 +328,7 @@
         final ContentResolver cr = context.getContentResolver();
 
         item.onAddToDatabase(values);
-
-        // update the values to be written with their canonical counterparts
-        final LauncherModelOrientationHelper.Coordinates coord = mModelOrientationHelper.getCanonicalCoordinates(item);
-        item.updateValuesWithCoordinates(values, coord.x, coord.y);
+        item.updateValuesWithCoordinates(values, item.cellX, item.cellY);
 
         cr.update(LauncherSettings.Favorites.getContentUri(item.id, false), values, null, null);
     }
@@ -393,11 +364,6 @@
         }
     }
 
-    public void updateOrientation() {
-        // we update the LauncherModelOrientationHelper orientation whenever we re-initialize
-        mModelOrientationHelper.updateOrientation(mApp);
-    }
-
     /**
      * Call from the handler for ACTION_PACKAGE_ADDED, ACTION_PACKAGE_REMOVED and
      * ACTION_PACKAGE_CHANGED.
@@ -712,7 +678,8 @@
             final Cursor c = contentResolver.query(
                     LauncherSettings.Favorites.CONTENT_URI, null, null, null, null);
 
-            final ItemInfo occupied[][][] = new ItemInfo[Launcher.SCREEN_COUNT][Launcher.NUMBER_CELLS_X][Launcher.NUMBER_CELLS_Y];
+            final ItemInfo occupied[][][] =
+                    new ItemInfo[Launcher.SCREEN_COUNT][mCellCountX][mCellCountY];
 
             try {
                 final int idIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites._ID);
@@ -747,11 +714,6 @@
                 final int displayModeIndex = c.getColumnIndexOrThrow(
                         LauncherSettings.Favorites.DISPLAY_MODE);
 
-
-                LauncherModelOrientationHelper.Coordinates localCoords;
-                int cellX;
-                int cellY;
-
                 ShortcutInfo info;
                 String intentDescription;
                 LauncherAppWidgetInfo appWidgetInfo;
@@ -785,17 +747,13 @@
                             if (info != null) {
                                 updateSavedIcon(context, info, c, iconIndex);
 
-                                cellX = c.getInt(cellXIndex);
-                                cellY = c.getInt(cellYIndex);
-                                localCoords = mModelOrientationHelper.getLocalCoordinates(cellX, cellY, 1, 1);
-
                                 info.intent = intent;
                                 info.id = c.getLong(idIndex);
                                 container = c.getInt(containerIndex);
                                 info.container = container;
                                 info.screen = c.getInt(screenIndex);
-                                info.cellX = localCoords.x;
-                                info.cellY = localCoords.y;
+                                info.cellX = c.getInt(cellXIndex);
+                                info.cellY = c.getInt(cellYIndex);
 
                                 // check & update map of what's occupied
                                 if (!checkItemPlacement(occupied, info)) {
@@ -829,17 +787,13 @@
                             id = c.getLong(idIndex);
                             UserFolderInfo folderInfo = findOrMakeUserFolder(mFolders, id);
 
-                            cellX = c.getInt(cellXIndex);
-                            cellY = c.getInt(cellYIndex);
-                            localCoords = mModelOrientationHelper.getLocalCoordinates(cellX, cellY, 1, 1);
-
                             folderInfo.title = c.getString(titleIndex);
                             folderInfo.id = id;
                             container = c.getInt(containerIndex);
                             folderInfo.container = container;
                             folderInfo.screen = c.getInt(screenIndex);
-                            folderInfo.cellX = localCoords.x;
-                            folderInfo.cellY = localCoords.y;
+                            folderInfo.cellX = c.getInt(cellXIndex);
+                            folderInfo.cellY = c.getInt(cellYIndex);
 
                             // check & update map of what's occupied
                             if (!checkItemPlacement(occupied, folderInfo)) {
@@ -877,18 +831,14 @@
                                     }
                                 }
 
-                                cellX = c.getInt(cellXIndex);
-                                cellY = c.getInt(cellYIndex);
-                                localCoords = mModelOrientationHelper.getLocalCoordinates(cellX, cellY, 1, 1);
-
                                 liveFolderInfo.title = c.getString(titleIndex);
                                 liveFolderInfo.id = id;
                                 liveFolderInfo.uri = uri;
                                 container = c.getInt(containerIndex);
                                 liveFolderInfo.container = container;
                                 liveFolderInfo.screen = c.getInt(screenIndex);
-                                liveFolderInfo.cellX = localCoords.x;
-                                liveFolderInfo.cellY = localCoords.y;
+                                liveFolderInfo.cellX = c.getInt(cellXIndex);
+                                liveFolderInfo.cellY = c.getInt(cellYIndex);
                                 liveFolderInfo.baseIntent = intent;
                                 liveFolderInfo.displayMode = c.getInt(displayModeIndex);
 
@@ -923,19 +873,13 @@
                                         + id + " appWidgetId=" + appWidgetId);
                                 itemsToRemove.add(id);
                             } else {
-                                cellX = c.getInt(cellXIndex);
-                                cellY = c.getInt(cellYIndex);
-                                int spanX = c.getInt(spanXIndex);
-                                int spanY = c.getInt(spanYIndex);
-                                localCoords = mModelOrientationHelper.getLocalCoordinates(cellX, cellY, spanX, spanY);
-
                                 appWidgetInfo = new LauncherAppWidgetInfo(appWidgetId);
                                 appWidgetInfo.id = id;
                                 appWidgetInfo.screen = c.getInt(screenIndex);
-                                appWidgetInfo.cellX = localCoords.x;
-                                appWidgetInfo.cellY = localCoords.y;
-                                appWidgetInfo.spanX = spanX;
-                                appWidgetInfo.spanY = spanY;
+                                appWidgetInfo.cellX = c.getInt(cellXIndex);
+                                appWidgetInfo.cellY = c.getInt(cellYIndex);
+                                appWidgetInfo.spanX = c.getInt(spanXIndex);
+                                appWidgetInfo.spanY = c.getInt(spanYIndex);
 
                                 container = c.getInt(containerIndex);
                                 if (container != LauncherSettings.Favorites.CONTAINER_DESKTOP) {
@@ -983,13 +927,13 @@
             if (DEBUG_LOADERS) {
                 Log.d(TAG, "loaded workspace in " + (SystemClock.uptimeMillis()-t) + "ms");
                 Log.d(TAG, "workspace layout: ");
-                for (int y = 0; y < Launcher.NUMBER_CELLS_Y; y++) {
+                for (int y = 0; y < mCellCountY; y++) {
                     String line = "";
                     for (int s = 0; s < Launcher.SCREEN_COUNT; s++) {
                         if (s > 0) {
                             line += " | ";
                         }
-                        for (int x = 0; x < Launcher.NUMBER_CELLS_X; x++) {
+                        for (int x = 0; x < mCellCountX; x++) {
                             line += ((occupied[s][x][y] != null) ? "#" : ".");
                         }
                     }
diff --git a/src/com/android/launcher2/LauncherModelOrientationHelper.java b/src/com/android/launcher2/LauncherModelOrientationHelper.java
deleted file mode 100644
index 6a9473d..0000000
--- a/src/com/android/launcher2/LauncherModelOrientationHelper.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher2;
-
-import android.content.Context;
-import android.view.Display;
-import android.view.Surface;
-import android.view.WindowManager;
-
-public class LauncherModelOrientationHelper {
-
-    static final String TAG = "LauncherModelOrientationHelper";
-
-    public class Coordinates {
-        public Coordinates(int newX, int newY) {
-            x = newX;
-            y = newY;
-        }
-
-        public int x;
-        public int y;
-    }
-
-    private int mOrientation;
-    private int mLocalDeviceWidth;
-    private int mLocalDeviceHeight;
-    private int mPreviousOrientation;
-    private int mPreviousLocalDeviceWidth;
-    private int mPreviousLocalDeviceHeight;
-    private int mCanonicalDeviceWidth;
-    private int mCanonicalDeviceHeight;
-
-    protected LauncherModelOrientationHelper(Context ctx) {
-        updateOrientation(ctx);
-    }
-
-    public int getCurrentOrientation() {
-        return mOrientation;
-    }
-
-    public int getPreviousOrientationRelativeToCurrent() {
-        int orientationDifference = -(mOrientation - mPreviousOrientation);
-
-        if (Math.abs(orientationDifference) > 180) {
-            orientationDifference = (int) -Math.signum(orientationDifference)
-                    * (360 - Math.abs(orientationDifference));
-        }
-        return orientationDifference;
-    }
-
-    private void updateLocalDeviceDimensions() {
-        mPreviousLocalDeviceHeight = mLocalDeviceHeight;
-        mPreviousLocalDeviceWidth = mLocalDeviceWidth;
-
-        if (mOrientation % 180 != 0) {
-            mLocalDeviceWidth = mCanonicalDeviceHeight;
-            mLocalDeviceHeight = mCanonicalDeviceWidth;
-        } else {
-            mLocalDeviceWidth = mCanonicalDeviceWidth;
-            mLocalDeviceHeight = mCanonicalDeviceHeight;
-        }
-    }
-
-    public void updateOrientation(Context ctx) {
-        Display display = ((WindowManager) ctx
-                .getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
-
-        mPreviousOrientation = mOrientation;
-        switch (display.getRotation()) {
-        case Surface.ROTATION_0:
-            mOrientation = 0;
-            break;
-        case Surface.ROTATION_90:
-            mOrientation = 90;
-            break;
-        case Surface.ROTATION_180:
-            mOrientation = 180;
-            break;
-        case Surface.ROTATION_270:
-            mOrientation = 270;
-            break;
-        }
-        updateLocalDeviceDimensions();
-    }
-
-    public void updateDeviceDimensions(int deviceWidth, int deviceHeight) {
-        mCanonicalDeviceWidth = deviceWidth;
-        mCanonicalDeviceHeight = deviceHeight;
-
-        updateLocalDeviceDimensions();
-    }
-
-    public Coordinates getLocalCoordinatesFromPreviousLocalCoordinates(
-            int cellX, int cellY, int spanX, int spanY) {
-        return getTransformedLayoutParams(cellX, cellY, spanX, spanY,
-                getPreviousOrientationRelativeToCurrent(),
-                mPreviousLocalDeviceWidth, mPreviousLocalDeviceHeight);
-    }
-
-    public Coordinates getCanonicalCoordinates(ItemInfo localItem) {
-        return getTransformedLayoutParams(localItem.cellX, localItem.cellY,
-                localItem.spanX, localItem.spanY, mOrientation,
-                mLocalDeviceWidth, mLocalDeviceHeight);
-    }
-
-    public Coordinates getCanonicalCoordinates(int cellX, int cellY,
-            int spanX, int spanY) {
-        return getTransformedLayoutParams(cellX, cellY, spanX, spanY,
-                mOrientation, mLocalDeviceWidth, mLocalDeviceHeight);
-    }
-
-    public Coordinates getLocalCoordinates(int cellX, int cellY, int spanX,
-            int spanY) {
-        return getTransformedLayoutParams(cellX, cellY, spanX, spanY,
-                -mOrientation, mCanonicalDeviceWidth, mCanonicalDeviceHeight);
-    }
-
-    public int getLocalDeviceWidth() {
-        return mLocalDeviceWidth;
-    }
-
-    public int getLocalDeviceHeight() {
-        return mLocalDeviceHeight;
-    }
-
-    /**
-     * Transform the coordinates based on the current device rotation
-     */
-    private Coordinates getTransformedLayoutParams(int cellX, int cellY,
-            int spanX, int spanY, int deviceRotationClockwise,
-            int initialDeviceWidth, int initialDeviceHeight) {
-        if (LauncherApplication.isScreenXLarge()) {
-            int x = cellX;
-            int y = cellY;
-            int width = spanX;
-            int height = spanY;
-            int finalDeviceWidth = initialDeviceWidth;
-            int finalDeviceHeight = initialDeviceHeight;
-
-            // item rotation is opposite of device rotation to maintain an
-            // absolute
-            // spatial layout
-            double phi = Math.toRadians(-deviceRotationClockwise);
-
-            double x1 = x + width / 2.0f - initialDeviceWidth / 2.0f;
-            double y1 = y + height / 2.0f - initialDeviceHeight / 2.0f;
-
-            // multiply x and y by a clockwise rotation matrix
-            double x2 = x1 * Math.cos(phi) + y1 * Math.sin(phi);
-            double y2 = -x1 * Math.sin(phi) + y1 * Math.cos(phi);
-
-            // Get the rotated device dimensions
-            if (deviceRotationClockwise % 180 != 0) {
-                finalDeviceWidth = initialDeviceHeight;
-                finalDeviceHeight = initialDeviceWidth;
-            }
-
-            x2 = x2 + finalDeviceWidth / 2.0f - width / 2.0f;
-            y2 = y2 + finalDeviceHeight / 2.0f - height / 2.0f;
-
-            return new Coordinates((int) Math.round(x2), (int) Math.round(y2));
-        } else {
-            return new Coordinates(cellX, cellY);
-        }
-    }
-}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index cb37b92..6d94eaa 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -136,6 +136,8 @@
     private int mMaximumVelocity;
 
     private static final int INVALID_POINTER = -1;
+    private static final int DEFAULT_CELL_COUNT_X = 4;
+    private static final int DEFAULT_CELL_COUNT_Y = 4;
 
     private int mActivePointerId = INVALID_POINTER;
 
@@ -208,13 +210,12 @@
 
         TypedArray a = context.obtainStyledAttributes(attrs,
                 R.styleable.Workspace, defStyle, 0);
-        int canonicalDeviceWidth = a.getInt(R.styleable.Workspace_canonicalDeviceWidth, 4);
-        int canonicalDeviceHeight = a.getInt(R.styleable.Workspace_canonicalDeviceHeight, 4);
+        int cellCountX = a.getInt(R.styleable.Workspace_cellCountX, DEFAULT_CELL_COUNT_X);
+        int cellCountY = a.getInt(R.styleable.Workspace_cellCountY, DEFAULT_CELL_COUNT_Y);
         mDefaultScreen = a.getInt(R.styleable.Workspace_defaultScreen, 1);
         a.recycle();
 
-        LauncherModel.updateWorkspaceLayoutCells(canonicalDeviceWidth,
-                canonicalDeviceHeight);
+        LauncherModel.updateWorkspaceLayoutCells(cellCountX, cellCountY);
         setHapticFeedbackEnabled(false);
         initWorkspace();
     }
@@ -416,81 +417,6 @@
         addInScreen(child, screen, 0, 0, -1, -1);
     }
 
-    public void rotateCurrentScreensChildren() {
-
-        // close all the folders first
-        final ArrayList<Folder> openFolders = getOpenFolders();
-
-        WorkspaceOvershootInterpolator wi = new WorkspaceOvershootInterpolator();
-        RotateAnimation ra = new RotateAnimation((float) LauncherModel
-                .getPreviousOrientationRelativeToCurrent(), 0,
-                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
-                0.5f);
-        ra.setInterpolator(wi);
-        CellLayout currentScreen = (CellLayout) getChildAt(mCurrentScreen);
-        ra.setStartOffset(150);
-        ra.setDuration(650 + (int) (Math.random() * 400) - 200);
-
-        CellLayout.CellLayoutAnimationController animationController = new CellLayout.CellLayoutAnimationController(
-                ra, 0.0f);
-        currentScreen.setLayoutAnimation(animationController);
-        currentScreen.setLayoutAnimationListener(new AnimationListener() {
-            public void onAnimationStart(Animation animation) {
-                // do nothing
-            }
-
-            public void onAnimationRepeat(Animation animation) {
-                // do nothing
-            }
-
-            public void onAnimationEnd(Animation animation) {
-                for (int j = 0; j < openFolders.size(); ++j) {
-                    Folder folder = openFolders.get(j);
-                    if (!folder.getInfo().opened) {
-                        mLauncher.openFolder(folder.getInfo());
-                    }
-                }
-            }
-        });
-        animationController.start();
-
-        for (int j = 0; j < openFolders.size(); ++j) {
-            mLauncher.closeFolder(openFolders.get(j));
-        }
-    }
-
-    public void refreshWorkspaceChildren() {
-        final int screenCount = getChildCount();
-        View child;
-
-        CellLayout.LayoutParams lp;
-        int widthMeasureSpec = MeasureSpec.makeMeasureSpec(LauncherModel
-                .getLocalDeviceWidth(), MeasureSpec.EXACTLY);
-        int heightMeasureSpec = MeasureSpec.makeMeasureSpec(LauncherModel
-                .getLocalDeviceHeight(), MeasureSpec.EXACTLY);
-
-        clearVacantCache();
-
-        for (int i = 0; i < screenCount; i++) {
-            final CellLayout layout = (CellLayout) getChildAt(i);
-            final int count = layout.getChildCount();
-
-            // save reference to all current children
-            for (int j = 0; j < count; j++) {
-                child = layout.getChildAt(j);
-
-                lp = (CellLayout.LayoutParams) child.getLayoutParams();
-                LauncherModelOrientationHelper.Coordinates localCoord = LauncherModel
-                        .getLocalCoordinatesFromPreviousLocalCoordinates(lp);
-
-                lp.cellX = localCoord.x;
-                lp.cellY = localCoord.y;
-            }
-
-            layout.measure(widthMeasureSpec, heightMeasureSpec);
-        }
-    }
-
     /**
      * Adds the specified child in the specified screen. The position and dimension of
      * the child are defined by x, y, spanX and spanY.
@@ -524,7 +450,7 @@
         }
 
         // Get the canonical child id to uniquely represent this view in this screen
-        int childId = LauncherModel.getCanonicalCellLayoutChildId(child.getId(), screen, x, y, spanX, spanY);
+        int childId = LauncherModel.getCellLayoutChildId(child.getId(), screen, x, y, spanX, spanY);
         if (!group.addViewToCellLayout(child, insert ? 0 : -1, childId, lp)) {
             // TODO: This branch occurs when the workspace is adding views
             // outside of the defined grid