From 5f8afe6280eae34620067696173e71943e1a30a3 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 12 Aug 2013 16:19:28 -0700 Subject: Initial Changes for Dynamic Grid Change-Id: I9e6f1e5167791cf8dc140778dfa447f86424e9bf --- src/com/android/launcher3/LauncherAppState.java | 28 ++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/com/android/launcher3/LauncherAppState.java') diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java index 03d2d3395..0c577e548 100644 --- a/src/com/android/launcher3/LauncherAppState.java +++ b/src/com/android/launcher3/LauncherAppState.java @@ -21,11 +21,14 @@ import android.content.*; 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 @@ public class LauncherAppState { 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 @@ public class LauncherAppState { } // 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 @@ public class LauncherAppState { 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; } -- cgit v1.2.3