diff --git a/src/com/android/launcher2/ApplicationInfoDropTarget.java b/src/com/android/launcher2/ApplicationInfoDropTarget.java
index ce359d4..f42aaf5 100644
--- a/src/com/android/launcher2/ApplicationInfoDropTarget.java
+++ b/src/com/android/launcher2/ApplicationInfoDropTarget.java
@@ -50,7 +50,7 @@
         int colour = getContext().getResources().getColor(R.color.app_info_filter);
         mHoverPaint.setColorFilter(new PorterDuffColorFilter(colour, PorterDuff.Mode.SRC_ATOP));
 
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             // For the application info drop target, we just ignore the left padding since we don't want
             // to overlap with the delete zone padding
             int tb = getResources().getDimensionPixelSize(
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 5173672..14e051c 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -319,7 +319,7 @@
                     public void run() {
                         cl.calculateSpans(itemInfo);
                         if (cl.findCellForSpan(null, itemInfo.spanX, itemInfo.spanY)) {
-                            if (LauncherApplication.isScreenXLarge()) {
+                            if (LauncherApplication.isScreenLarge()) {
                                 animateItemOntoScreen(dragView, cl, itemInfo);
                             } else {
                                 mLauncher.addExternalItemToScreen(itemInfo, cl);
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 52b59f1..8efb6ce 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -167,7 +167,7 @@
 
         final Resources res = getResources();
 
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             mNormalBackground = res.getDrawable(R.drawable.homescreen_large_blue);
             mActiveBackground = res.getDrawable(R.drawable.homescreen_large_green);
             mActiveGlowBackground = res.getDrawable(R.drawable.homescreen_large_green_strong);
@@ -353,7 +353,7 @@
     }
 
     void animateDrop() {
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             Resources res = getResources();
             float onDropScale = res.getInteger(R.integer.config_screenOnDropScalePercent) / 100.0f;
             ObjectAnimator scaleUp = ObjectAnimator.ofFloat(this, "hoverScale", onDropScale);
@@ -391,7 +391,7 @@
         // When we're small, we are either drawn normally or in the "accepts drops" state (during
         // a drag). However, we also drag the mini hover background *over* one of those two
         // backgrounds
-        if (LauncherApplication.isScreenXLarge() && mBackgroundAlpha > 0.0f) {
+        if (LauncherApplication.isScreenLarge() && mBackgroundAlpha > 0.0f) {
             Drawable bg;
             boolean mini = getScaleX() < 0.5f;
 
diff --git a/src/com/android/launcher2/DeleteZone.java b/src/com/android/launcher2/DeleteZone.java
index 4b35921..fdd4125 100644
--- a/src/com/android/launcher2/DeleteZone.java
+++ b/src/com/android/launcher2/DeleteZone.java
@@ -68,7 +68,7 @@
         mOrientation = a.getInt(R.styleable.DeleteZone_direction, ORIENTATION_HORIZONTAL);
         a.recycle();
 
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             int tb = getResources().getDimensionPixelSize(
                     R.dimen.delete_zone_vertical_drag_padding);
             int lr = getResources().getDimensionPixelSize(
@@ -81,7 +81,7 @@
     protected void onFinishInflate() {
         super.onFinishInflate();
         mTransition = (TransitionDrawable) getCompoundDrawables()[LEFT_DRAWABLE];
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             mTransition.setCrossFadeEnabled(false);
         }
 
@@ -102,7 +102,7 @@
         final ItemInfo item = (ItemInfo) dragInfo;
 
         // On x-large screens, you can uninstall an app by dragging from all apps
-        if (item instanceof ApplicationInfo && LauncherApplication.isScreenXLarge()) {
+        if (item instanceof ApplicationInfo && LauncherApplication.isScreenLarge()) {
             mLauncher.startApplicationUninstallActivity((ApplicationInfo) item);
         }
 
@@ -166,7 +166,7 @@
             getHitRect(mRegion);
             mRegionF.set(mRegion);
 
-            if (LauncherApplication.isScreenXLarge()) {
+            if (LauncherApplication.isScreenLarge()) {
                 // This region will be a "dead zone" for scrolling; make it extend to the edge of
                 // the screen so users don't accidentally trigger a scroll while deleting items
                 mRegionF.top = mLauncher.getWorkspace().getTop();
@@ -223,7 +223,7 @@
             mInAnimation = new AnimatorSet();
             mInAnimation.setInterpolator(new AccelerateInterpolator());
             mInAnimation.setDuration(duration);
-            if (!LauncherApplication.isScreenXLarge()) {
+            if (!LauncherApplication.isScreenLarge()) {
                 Animator translateAnim;
                 if (mOrientation == ORIENTATION_HORIZONTAL) {
                     translateAnim = ObjectAnimator.ofFloat(this, "translationY", 
@@ -243,7 +243,7 @@
             mOutAnimation = new AnimatorSet();
             mOutAnimation.setInterpolator(new AccelerateInterpolator());
             mOutAnimation.setDuration(duration);
-            if (!LauncherApplication.isScreenXLarge()) {
+            if (!LauncherApplication.isScreenLarge()) {
                 Animator translateAnim;
                 if (mOrientation == ORIENTATION_HORIZONTAL) {
                     translateAnim = ObjectAnimator.ofFloat(this, "translationY", 0f, 
@@ -269,12 +269,12 @@
     }
 
     private int getTransitionAnimationDuration() {
-        return LauncherApplication.isScreenXLarge() ?
+        return LauncherApplication.isScreenLarge() ?
                 XLARGE_TRANSITION_DURATION : TRANSITION_DURATION;
     }
 
     private int getAnimationDuration() {
-        return LauncherApplication.isScreenXLarge() ?
+        return LauncherApplication.isScreenLarge() ?
                 XLARGE_ANIMATION_DURATION : ANIMATION_DURATION;
     }
 }
diff --git a/src/com/android/launcher2/FocusHelper.java b/src/com/android/launcher2/FocusHelper.java
index f14ebae..861a70b 100644
--- a/src/com/android/launcher2/FocusHelper.java
+++ b/src/com/android/launcher2/FocusHelper.java
@@ -132,7 +132,7 @@
      * To be deprecated.
      */
     static boolean handlePagedViewWidgetKeyEvent(PagedViewWidget w, int keyCode, KeyEvent e) {
-        if (!LauncherApplication.isScreenXLarge()) return false;
+        if (!LauncherApplication.isScreenLarge()) return false;
 
         final PagedViewExtendedLayout parent = (PagedViewExtendedLayout) w.getParent();
         final ViewGroup container = (ViewGroup) parent.getParent();
@@ -522,7 +522,7 @@
      * Handles key events in the tab widget.
      */
     static boolean handleTabKeyEvent(AccessibleTabView v, int keyCode, KeyEvent e) {
-        if (!LauncherApplication.isScreenXLarge()) return false;
+        if (!LauncherApplication.isScreenLarge()) return false;
 
         final FocusOnlyTabWidget parent = (FocusOnlyTabWidget) v.getParent();
         final TabHost tabHost = findTabHostParent(parent);
@@ -577,7 +577,7 @@
      * Handles key events in the workspace button bar.
      */
     static boolean handleButtonBarButtonKeyEvent(View v, int keyCode, KeyEvent e) {
-        if (!LauncherApplication.isScreenXLarge()) return false;
+        if (!LauncherApplication.isScreenLarge()) return false;
 
         final ViewGroup parent = (ViewGroup) v.getParent();
         final ViewGroup launcher = (ViewGroup) parent.getParent();
diff --git a/src/com/android/launcher2/IconCache.java b/src/com/android/launcher2/IconCache.java
index 0c26bf0..7e37afe 100644
--- a/src/com/android/launcher2/IconCache.java
+++ b/src/com/android/launcher2/IconCache.java
@@ -54,7 +54,7 @@
         mContext = context;
         mPackageManager = context.getPackageManager();
         mBubble = new Utilities.BubbleText(context);
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             mIconDpi = DisplayMetrics.DENSITY_HIGH;
         } else {
             mIconDpi = context.getResources().getDisplayMetrics().densityDpi;
diff --git a/src/com/android/launcher2/IconDropTarget.java b/src/com/android/launcher2/IconDropTarget.java
index fb5d0f0..4d018e6 100644
--- a/src/com/android/launcher2/IconDropTarget.java
+++ b/src/com/android/launcher2/IconDropTarget.java
@@ -126,7 +126,7 @@
     @Override
     public void getHitRect(Rect outRect) {
         super.getHitRect(outRect);
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             outRect.top -= mDragPadding[0];
             outRect.right += mDragPadding[1];
             outRect.bottom += mDragPadding[2];
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 9b136c4..2fe1c7d 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -346,7 +346,7 @@
         registerReceiver(mCloseSystemDialogsReceiver, filter);
 
         // If we have a saved version of these external icons, we load them up immediately
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             if (sGlobalSearchIcon == null || sVoiceSearchIcon == null || sAppMarketIcon == null) {
                 updateIconsAffectedByPackageManagerChanges();
             }
@@ -895,7 +895,7 @@
         DragLayer dragLayer = (DragLayer) findViewById(R.id.drag_layer);
         dragLayer.setDragController(dragController);
 
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             mAllAppsGrid = (AllAppsView) dragLayer.findViewById(R.id.all_apps_view);
             mAllAppsGrid.setup(this, dragController);
             // We don't want a hole punched in our window.
@@ -963,7 +963,7 @@
         final View divider = findViewById(R.id.all_apps_divider);
         final View configureButton = findViewById(R.id.configure_button);
 
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             deleteZone.setOverlappingViews(new View[] { allAppsButton, divider, configureButton });
         } else {
             deleteZone.setOverlappingView(findViewById(R.id.all_apps_button_cluster));
@@ -1013,7 +1013,7 @@
         }
         mButtonCluster = (ViewGroup) findViewById(R.id.all_apps_button_cluster);
         View.OnKeyListener listener = null;
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             // For tablets, AllApps lives in the button bar at the top
             listener = new ButtonBarKeyEventListener();
         } else {
@@ -1695,7 +1695,7 @@
     }
 
     private void addItems() {
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             // Animate the widget chooser up from the bottom of the screen
             if (mState != State.CUSTOMIZE) {
                 showCustomizationDrawer(true);
@@ -2198,7 +2198,7 @@
                 mWorkspace.setAllowLongPress(false);
                 mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
                         HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
-                if (LauncherApplication.isScreenXLarge()) {
+                if (LauncherApplication.isScreenLarge()) {
                     addItems();
                 } else {
                     startWallpaper();
@@ -2513,7 +2513,7 @@
     // AllAppsView.Watcher
     public void zoomed(float zoom) {
         // In XLarge view, we zoom down the workspace below all apps so it's still visible
-        if (zoom == 1.0f && !LauncherApplication.isScreenXLarge()) {
+        if (zoom == 1.0f && !LauncherApplication.isScreenLarge()) {
             mWorkspace.setVisibility(View.GONE);
         }
     }
@@ -2586,7 +2586,7 @@
         case WORKSPACE:
             hideOrShowToolbarButton(true, mButtonCluster, showSeq);
             mDeleteZone.setDragAndDropEnabled(true);
-            if (LauncherApplication.isScreenXLarge()) {
+            if (LauncherApplication.isScreenLarge()) {
                 mDeleteZone.setText(getResources().getString(R.string.delete_zone_label_workspace));
             }
             break;
@@ -2594,7 +2594,7 @@
         case APPS_CUSTOMIZE:
             hideOrShowToolbarButton(false, mButtonCluster, hideSeq);
             mDeleteZone.setDragAndDropEnabled(false);
-            if (LauncherApplication.isScreenXLarge()) {
+            if (LauncherApplication.isScreenLarge()) {
                 mDeleteZone.setText(getResources().getString(R.string.delete_zone_label_all_apps));
             }
             break;
@@ -2651,7 +2651,7 @@
 
         View tmpView;
         if (toAllApps) {
-            tmpView = (LauncherApplication.isScreenXLarge())
+            tmpView = (LauncherApplication.isScreenLarge())
                     ? (View) mAllAppsGrid : mAppsCustomizeTabHost;
         } else {
             tmpView = mHomeCustomizationDrawer;
@@ -2664,7 +2664,7 @@
             if (!springLoaded) {
                 mWorkspace.shrink(ShrinkState.BOTTOM_HIDDEN, animated);
 
-                if (LauncherApplication.isScreenXLarge()) {
+                if (LauncherApplication.isScreenLarge()) {
                     // Everytime we launch into AllApps, we reset the successful drop flag which
                     // controls when it should hide/show the mini workspaces
                     mAllAppsPagedView.resetSuccessfulDropFlag();
@@ -2781,14 +2781,14 @@
 
         View tmpView;
         if (fromAllApps) {
-            tmpView = (LauncherApplication.isScreenXLarge())
+            tmpView = (LauncherApplication.isScreenLarge())
                     ? (View) mAllAppsGrid : mAppsCustomizeTabHost;
         } else {
             tmpView = mHomeCustomizationDrawer;
         }
         final View fromView = tmpView;
 
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             mCustomizePagedView.endChoiceMode();
             mAllAppsPagedView.endChoiceMode();
         }
@@ -2894,7 +2894,7 @@
         mWorkspace.enterSpringLoadedDragMode(layout);
         if (mState == State.ALL_APPS || mState == State.APPS_CUSTOMIZE) {
             mState = State.ALL_APPS_SPRING_LOADED;
-            if (LauncherApplication.isScreenXLarge()) {
+            if (LauncherApplication.isScreenLarge()) {
                 cameraZoomIn(State.ALL_APPS, true, true);
             } else {
                 cameraZoomIn(State.APPS_CUSTOMIZE, true, true);
@@ -2910,7 +2910,7 @@
     void exitSpringLoadedDragMode() {
         if (mState == State.ALL_APPS_SPRING_LOADED) {
             mWorkspace.exitSpringLoadedDragMode(Workspace.ShrinkState.BOTTOM_VISIBLE);
-            if (LauncherApplication.isScreenXLarge()) {
+            if (LauncherApplication.isScreenLarge()) {
                 cameraZoomOut(State.ALL_APPS, true, true);
                 mState = State.ALL_APPS;
             } else {
@@ -2928,7 +2928,7 @@
 
     void showAllApps(boolean animated) {
         if (mState != State.WORKSPACE) return;
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             cameraZoomOut(State.ALL_APPS, animated, false);
             ((View) mAllAppsGrid).requestFocus();
 
@@ -2994,7 +2994,7 @@
      *          - From another workspace
      */
     void closeAllApps(boolean animated) {
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             if (mState == State.ALL_APPS || mState == State.ALL_APPS_SPRING_LOADED) {
                 mWorkspace.setVisibility(View.VISIBLE);
                 cameraZoomIn(State.ALL_APPS, animated, false);
@@ -3125,7 +3125,7 @@
     }
 
     private void updateGlobalSearchIcon() {
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             final View searchButton = findViewById(R.id.search_button);
             final View searchDivider = findViewById(R.id.search_divider);
 
@@ -3149,7 +3149,7 @@
     }
 
     private void updateVoiceSearchIcon() {
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             final View searchDivider = findViewById(R.id.search_divider);
             final View voiceButton = findViewById(R.id.voice_button);
 
@@ -3501,7 +3501,7 @@
 
         // Workaround a bug that occurs when rotating the device while the customization mode is
         // open, we trigger a new layout on all the CellLayout children.
-        if (LauncherApplication.isScreenXLarge() && (mState == State.CUSTOMIZE)) {
+        if (LauncherApplication.isScreenLarge() && (mState == State.CUSTOMIZE)) {
             final int childCount = mWorkspace.getChildCount();
             for (int i = 0; i < childCount; ++i) {
                 mWorkspace.getChildAt(i).requestLayout();
diff --git a/src/com/android/launcher2/LauncherApplication.java b/src/com/android/launcher2/LauncherApplication.java
index 041392c..67573e0 100644
--- a/src/com/android/launcher2/LauncherApplication.java
+++ b/src/com/android/launcher2/LauncherApplication.java
@@ -27,7 +27,7 @@
 public class LauncherApplication extends Application {
     public LauncherModel mModel;
     public IconCache mIconCache;
-    private static boolean sIsScreenXLarge;
+    private static boolean sIsScreenLarge;
     private static float sScreenDensity;
     private static final boolean ENABLE_ROTATION = false;
 
@@ -36,7 +36,9 @@
         super.onCreate();
 
         // set sIsScreenXLarge and sScreenDensity *before* creating icon cache
-        sIsScreenXLarge = (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
+        final int screenSize = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
+        sIsScreenLarge = screenSize == Configuration.SCREENLAYOUT_SIZE_LARGE ||
+            screenSize == Configuration.SCREENLAYOUT_SIZE_XLARGE;
         sScreenDensity = getResources().getDisplayMetrics().density;
 
         mIconCache = new IconCache(this);
@@ -97,11 +99,11 @@
     }
 
     public static boolean isInPlaceRotationEnabled() {
-        return sIsScreenXLarge && ENABLE_ROTATION;
+        return sIsScreenLarge && ENABLE_ROTATION;
     }
 
-    public static boolean isScreenXLarge() {
-        return sIsScreenXLarge;
+    public static boolean isScreenLarge() {
+        return sIsScreenLarge;
     }
 
     public static float getScreenDensity() {
diff --git a/src/com/android/launcher2/PagedViewCellLayout.java b/src/com/android/launcher2/PagedViewCellLayout.java
index 92459d8..54bdec4 100644
--- a/src/com/android/launcher2/PagedViewCellLayout.java
+++ b/src/com/android/launcher2/PagedViewCellLayout.java
@@ -259,7 +259,7 @@
     }
 
     int getContentWidth() {
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             // Return the distance from the left edge of the content of the leftmost icon to
             // the right edge of the content of the rightmost icon
 
@@ -283,7 +283,7 @@
         int count = getChildCount();
         for (int i = 0; i < count; i++) {
             View child = getChildAt(i);
-            if (LauncherApplication.isScreenXLarge()) {
+            if (LauncherApplication.isScreenLarge()) {
                 child.layout(0, 0, r - l, b - t);
             } else {
                 child.layout(mPaddingLeft, mPaddingTop, getMeasuredWidth() - mPaddingRight,
@@ -477,7 +477,7 @@
             height = myCellVSpan * cellHeight + ((myCellVSpan - 1) * heightGap) -
                     topMargin - bottomMargin;
 
-            if (LauncherApplication.isScreenXLarge()) {
+            if (LauncherApplication.isScreenLarge()) {
                 x = hStartPadding + myCellX * (cellWidth + widthGap) + leftMargin;
                 y = vStartPadding + myCellY * (cellHeight + heightGap) + topMargin;
             } else {
diff --git a/src/com/android/launcher2/PagedViewExtendedLayout.java b/src/com/android/launcher2/PagedViewExtendedLayout.java
index f471b76..94890d8 100644
--- a/src/com/android/launcher2/PagedViewExtendedLayout.java
+++ b/src/com/android/launcher2/PagedViewExtendedLayout.java
@@ -42,7 +42,7 @@
     }
 
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             super.onMeasure(widthMeasureSpec, heightMeasureSpec);
         } else {
             // PagedView currently has issues with different-sized pages since it calculates the
diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java
index 6492888..2ffa398 100644
--- a/src/com/android/launcher2/PagedViewWidget.java
+++ b/src/com/android/launcher2/PagedViewWidget.java
@@ -257,7 +257,7 @@
 
     @Override
     public boolean onKeyDown(int keyCode, KeyEvent event) {
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             return FocusHelper.handlePagedViewWidgetKeyEvent(this, keyCode, event)
                     || super.onKeyDown(keyCode, event);
         } else {
@@ -268,7 +268,7 @@
 
     @Override
     public boolean onKeyUp(int keyCode, KeyEvent event) {
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             return FocusHelper.handlePagedViewWidgetKeyEvent(this, keyCode, event)
                     || super.onKeyUp(keyCode, event);
         } else {
diff --git a/src/com/android/launcher2/Utilities.java b/src/com/android/launcher2/Utilities.java
index cd98cab..ba25893 100644
--- a/src/com/android/launcher2/Utilities.java
+++ b/src/com/android/launcher2/Utilities.java
@@ -243,7 +243,7 @@
         final float density = metrics.density;
 
         sIconWidth = sIconHeight = (int) resources.getDimension(R.dimen.app_icon_size);
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             sIconContentSize = (int) resources.getDimension(R.dimen.app_icon_content_size);
         }
         sIconTextureWidth = sIconTextureHeight = sIconWidth + 2;
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 192787e..1373996 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -249,7 +249,7 @@
         super(context, attrs, defStyle);
         mContentIsRefreshable = false;
 
-        if (!LauncherApplication.isScreenXLarge()) {
+        if (!LauncherApplication.isScreenLarge()) {
             mFadeInAdjacentScreens = false;
         }
 
@@ -333,7 +333,7 @@
 
     @Override
     protected int getScrollMode() {
-        if (LauncherApplication.isScreenXLarge()) {
+        if (LauncherApplication.isScreenLarge()) {
             return SmoothPagedView.X_LARGE_MODE;
         } else {
             return SmoothPagedView.DEFAULT_MODE;
@@ -1063,7 +1063,7 @@
         // If the screen is not xlarge, then don't rotate the CellLayouts
         // NOTE: If we don't update the side pages alpha, then we should not hide the side pages.
         //       see unshrink().
-        if (!LauncherApplication.isScreenXLarge()) return;
+        if (!LauncherApplication.isScreenLarge()) return;
 
         final int halfScreenSize = getMeasuredWidth() / 2;
 
@@ -1292,7 +1292,7 @@
     public boolean onTouchEvent(MotionEvent ev) {
         if (mLauncher.isAllAppsVisible() && mShrinkState == ShrinkState.BOTTOM_HIDDEN) {
             PagedView appsPane;
-            if (LauncherApplication.isScreenXLarge()) {
+            if (LauncherApplication.isScreenLarge()) {
                 appsPane = (PagedView) mLauncher.findViewById(R.id.all_apps_paged_view);
             } else {
                 appsPane = (PagedView) mLauncher.findViewById(R.id.apps_customize_pane_content);
@@ -1864,7 +1864,7 @@
                 final CellLayout cl = (CellLayout)getChildAt(i);
                 float finalAlphaValue = 0f;
                 float rotation = 0f;
-                if (LauncherApplication.isScreenXLarge()) {
+                if (LauncherApplication.isScreenLarge()) {
                     finalAlphaValue = (i == mCurrentPage) ? 1.0f : 0.0f;
 
                     if (i < mCurrentPage) {
@@ -1886,7 +1886,7 @@
                 // If the screen is not xlarge, then don't rotate the CellLayouts
                 // NOTE: If we don't update the side pages alpha, then we should not hide the side
                 //       pages. see unshrink().
-                if (LauncherApplication.isScreenXLarge()) {
+                if (LauncherApplication.isScreenLarge()) {
                     translation = getOffsetXForRotation(rotation, cl.getWidth(), cl.getHeight());
                 }
 
@@ -2407,7 +2407,7 @@
         if (source != this) {
             final int[] touchXY = new int[] { (int) mDragViewVisualCenter[0],
                     (int) mDragViewVisualCenter[1] };
-            if (LauncherApplication.isScreenXLarge() && (mIsSmall || mIsInUnshrinkAnimation)
+            if (LauncherApplication.isScreenLarge() && (mIsSmall || mIsInUnshrinkAnimation)
                     && !mLauncher.isAllAppsVisible()) {
                 // When the workspace is shrunk and the drop comes from customize, don't actually
                 // add the item to the screen -- customize will do this itself
@@ -2921,7 +2921,7 @@
 
                     // Workaround the fact that we don't actually want spring-loaded mode in phone
                     // UI yet.
-                    if (LauncherApplication.isScreenXLarge()) {
+                    if (LauncherApplication.isScreenLarge()) {
                         // In spring-loaded mode, we still want the user to be able to hover over a
                         // full screen (which is traditionally set to not accept drops) if they want
                         // to get to pages beyond the screen that is full.
