Refactoring DeviceProfile
-> Pulling out the parts of device profile which can (and need to be) initialized and accessed without access to an Activity context, ie. the invariant bits. -> The invariant bits are stored in InvariantDeviceProfile which is initialized statically from LauncherAppState. -> The DeviceProfile contains the Activity context-dependent bits, and we will create one of these for each Activity instance, and this instance is accessed through the Launcher activity. -> It's possible that we can continue to refactor this such that all appropriate dimensions can be computed without an Activity context (by only specifying orientation). This would be an extension of this CL and allow us to know exactly how launcher will look in both orientations from any context. Sets the stage for some improvements around b/19514688 Change-Id: Ia7daccf14d8ca2b9cb340b8780b684769e9f1892
This commit is contained in:
1 parent
a9d012c6e6
commit
2e6da1539b
39 files changed
+651
-717
No files matched your search
@@ -307,13 +307,11 @@ public class Workspace extends SmoothPagedView
|
||||
mLauncher = (Launcher) context;
|
||||
mStateTransitionAnimation = new WorkspaceStateTransitionAnimation(mLauncher, this);
|
||||
final Resources res = getResources();
|
||||
mWorkspaceFadeInAdjacentScreens = LauncherAppState.getInstance().getDynamicGrid().
|
||||
getDeviceProfile().shouldFadeAdjacentWorkspaceScreens();
|
||||
DeviceProfile grid = mLauncher.getDeviceProfile();
|
||||
mWorkspaceFadeInAdjacentScreens = grid.shouldFadeAdjacentWorkspaceScreens();
|
||||
mFadeInAdjacentScreens = false;
|
||||
mWallpaperManager = WallpaperManager.getInstance(context);
|
||||
|
||||
LauncherAppState app = LauncherAppState.getInstance();
|
||||
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
|
||||
TypedArray a = context.obtainStyledAttributes(attrs,
|
||||
R.styleable.Workspace, defStyle, 0);
|
||||
mSpringLoadedShrinkFactor =
|
||||
@@ -422,7 +420,7 @@ public class Workspace extends SmoothPagedView
|
||||
protected void initWorkspace() {
|
||||
mCurrentPage = mDefaultPage;
|
||||
LauncherAppState app = LauncherAppState.getInstance();
|
||||
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
|
||||
DeviceProfile grid = mLauncher.getDeviceProfile();
|
||||
mIconCache = app.getIconCache();
|
||||
setWillNotDraw(false);
|
||||
setClipChildren(false);
|
||||
@@ -1901,8 +1899,7 @@ public class Workspace extends SmoothPagedView
|
||||
|
||||
public void onExternalDragStartedWithItem(View v) {
|
||||
// Compose a drag bitmap with the view scaled to the icon size
|
||||
LauncherAppState app = LauncherAppState.getInstance();
|
||||
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
|
||||
DeviceProfile grid = mLauncher.getDeviceProfile();
|
||||
int iconSize = grid.iconSizePx;
|
||||
int bmpWidth = v.getMeasuredWidth();
|
||||
int bmpHeight = v.getMeasuredHeight();
|
||||
@@ -1984,7 +1981,7 @@ public class Workspace extends SmoothPagedView
|
||||
|
||||
int getOverviewModeTranslationY() {
|
||||
LauncherAppState app = LauncherAppState.getInstance();
|
||||
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
|
||||
DeviceProfile grid = mLauncher.getDeviceProfile();
|
||||
Rect overviewBar = grid.getOverviewModeButtonBarRect();
|
||||
|
||||
int availableHeight = getViewportHeight();
|
||||
@@ -2285,8 +2282,7 @@ public class Workspace extends SmoothPagedView
|
||||
int dragLayerY = Math.round(mTempXY[1] - (bmpHeight - scale * bmpHeight) / 2
|
||||
- padding.get() / 2);
|
||||
|
||||
LauncherAppState app = LauncherAppState.getInstance();
|
||||
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
|
||||
DeviceProfile grid = mLauncher.getDeviceProfile();
|
||||
Point dragVisualizeOffset = null;
|
||||
Rect dragRect = null;
|
||||
if (child instanceof BubbleTextView) {
|
||||
@@ -2343,7 +2339,7 @@ public class Workspace extends SmoothPagedView
|
||||
|
||||
public void beginExternalDragShared(View child, DragSource source) {
|
||||
LauncherAppState app = LauncherAppState.getInstance();
|
||||
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
|
||||
DeviceProfile grid = mLauncher.getDeviceProfile();
|
||||
int iconSize = grid.iconSizePx;
|
||||
|
||||
// Notify launcher of drag start
|
||||
@@ -2852,14 +2848,14 @@ public class Workspace extends SmoothPagedView
|
||||
* widthGap/heightGap (right, bottom) */
|
||||
static Rect getCellLayoutMetrics(Launcher launcher, int orientation) {
|
||||
LauncherAppState app = LauncherAppState.getInstance();
|
||||
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
|
||||
DeviceProfile grid = launcher.getDeviceProfile();
|
||||
|
||||
Display display = launcher.getWindowManager().getDefaultDisplay();
|
||||
Point smallestSize = new Point();
|
||||
Point largestSize = new Point();
|
||||
display.getCurrentSizeRange(smallestSize, largestSize);
|
||||
int countX = (int) grid.numColumns;
|
||||
int countY = (int) grid.numRows;
|
||||
int countX = (int) grid.inv.numColumns;
|
||||
int countY = (int) grid.inv.numRows;
|
||||
if (orientation == CellLayout.LANDSCAPE) {
|
||||
if (mLandscapeCellLayoutMetrics == null) {
|
||||
Rect padding = grid.getWorkspacePadding(CellLayout.LANDSCAPE);
|
||||
@@ -3023,7 +3019,7 @@ public class Workspace extends SmoothPagedView
|
||||
mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempPt, true);
|
||||
|
||||
LauncherAppState app = LauncherAppState.getInstance();
|
||||
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
|
||||
DeviceProfile grid = mLauncher.getDeviceProfile();
|
||||
r = grid.getHotseatRect();
|
||||
if (r.contains(mTempPt[0], mTempPt[1])) {
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user