Initial Changes for Dynamic Grid

Change-Id: I9e6f1e5167791cf8dc140778dfa447f86424e9bf
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index 03d2d33..0c577e5 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -21,11 +21,14 @@
 import android.content.res.Configuration;
 import android.database.ContentObserver;
 import android.os.Handler;
+import android.provider.Settings;
 import android.util.Log;
+import android.view.Display;
 
 import java.lang.ref.WeakReference;
 
 public class LauncherAppState {
+    private static final String TAG = "LauncherAppState";
     private static final String SHARED_PREFERENCES_KEY = "com.android.launcher3.prefs";
 
     private LauncherModel mModel;
@@ -41,6 +44,8 @@
     private static Object mLock = new Object();
     private static LauncherAppState INSTANCE;
 
+    private DynamicGrid mDynamicGrid;
+
     public static LauncherAppState getInstance() {
         if (INSTANCE == null) {
             INSTANCE = new LauncherAppState();
@@ -71,7 +76,7 @@
         }
 
         // set sIsScreenXLarge and mScreenDensity *before* creating icon cache
-        mIsScreenLarge = sContext.getResources().getBoolean(R.bool.is_large_screen);
+        mIsScreenLarge = sContext.getResources().getBoolean(R.bool.is_large_tablet);
         mScreenDensity = sContext.getResources().getDisplayMetrics().density;
 
         mWidgetPreviewCacheDb = new WidgetPreviewLoader.CacheDb(sContext);
@@ -158,6 +163,27 @@
         return SHARED_PREFERENCES_KEY;
     }
 
+    DeviceProfile initDynamicGrid(Context context, int minWidth, int minHeight, int width, int height) {
+        boolean created = false;
+        if (mDynamicGrid == null) {
+            mDynamicGrid = new DynamicGrid(context.getResources(),
+                    minWidth, minHeight, width, height);
+            created = true;
+        }
+
+        DeviceProfile grid = mDynamicGrid.getDeviceProfile();
+        if (created) {
+            LauncherModel.updateWorkspaceLayoutCells((int) grid.numColumns, (int) grid.numRows);
+        }
+        // Update the icon size
+        Utilities.setIconSize(grid.iconSizePx);
+        grid.updateFromConfiguration(context.getResources(), width, height);
+        return grid;
+    }
+    DynamicGrid getDynamicGrid() {
+        return mDynamicGrid;
+    }
+
     public boolean isScreenLarge() {
         return mIsScreenLarge;
     }