Merge "Removing some device profile dependencies in view contructors" into ub-launcher3-master

This commit is contained in:
Sunny Goyal
2018-01-16 22:46:30 +00:00
committed by Android (Google) Code Review
5 changed files with 19 additions and 27 deletions
@@ -102,8 +102,6 @@ public class DeviceProfile {
// All apps
public int allAppsCellHeightPx;
public int allAppsNumCols;
public int allAppsNumPredictiveCols;
public int allAppsIconSizePx;
public int allAppsIconDrawablePaddingPx;
public float allAppsIconTextSizePx;
@@ -385,10 +383,6 @@ public class DeviceProfile {
return mInsets;
}
public void updateAppsViewNumCols() {
allAppsNumCols = allAppsNumPredictiveCols = inv.numColumns;
}
public Point getCellSize() {
Point result = new Point();
// Since we are only concerned with the overall padding, layout direction does
+8 -9
View File
@@ -46,7 +46,7 @@ public class Hotseat extends FrameLayout implements LogContainerProvider, Insett
private CellLayout mContent;
@ViewDebug.ExportedProperty(category = "launcher")
private final boolean mHasVerticalHotseat;
private boolean mHasVerticalHotseat;
public Hotseat(Context context) {
this(context, null);
@@ -59,7 +59,6 @@ public class Hotseat extends FrameLayout implements LogContainerProvider, Insett
public Hotseat(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mLauncher = Launcher.getLauncher(context);
mHasVerticalHotseat = mLauncher.getDeviceProfile().isVerticalBarLayout();
}
public CellLayout getLayout() {
@@ -91,13 +90,7 @@ public class Hotseat extends FrameLayout implements LogContainerProvider, Insett
@Override
protected void onFinishInflate() {
super.onFinishInflate();
DeviceProfile grid = mLauncher.getDeviceProfile();
mContent = (CellLayout) findViewById(R.id.layout);
if (grid.isVerticalBarLayout()) {
mContent.setGridSize(1, grid.inv.numHotseatIcons);
} else {
mContent.setGridSize(grid.inv.numHotseatIcons, 1);
}
mContent = findViewById(R.id.layout);
resetLayout();
}
@@ -165,7 +158,11 @@ public class Hotseat extends FrameLayout implements LogContainerProvider, Insett
public void setInsets(Rect insets) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
DeviceProfile grid = mLauncher.getDeviceProfile();
mHasVerticalHotseat = mLauncher.getDeviceProfile().isVerticalBarLayout();
if (mHasVerticalHotseat) {
mContent.setGridSize(1, grid.inv.numHotseatIcons);
lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
if (insets.left > insets.right) {
lp.gravity = Gravity.LEFT;
@@ -180,6 +177,8 @@ public class Hotseat extends FrameLayout implements LogContainerProvider, Insett
grid.hotseatBarSidePaddingPx, insets.top, insets.right, insets.bottom);
}
} else {
mContent.setGridSize(grid.inv.numHotseatIcons, 1);
lp.gravity = Gravity.BOTTOM;
lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
lp.height = grid.hotseatBarSizePx + insets.bottom;
-4
View File
@@ -2552,10 +2552,6 @@ public class Launcher extends BaseActivity
return bounceAnim;
}
public boolean useVerticalBarLayout() {
return mDeviceProfile.isVerticalBarLayout();
}
/**
* Add the icons for all apps.
*
+11 -6
View File
@@ -207,7 +207,7 @@ public class Workspace extends PagedView
private boolean mStripScreensOnPageStopMoving = false;
private DragPreviewProvider mOutlineProvider = null;
private final boolean mWorkspaceFadeInAdjacentScreens;
private boolean mWorkspaceFadeInAdjacentScreens;
final WallpaperOffsetInterpolator mWallpaperOffset;
private boolean mUnlockWallpaperFromDefaultPageOnLayout;
@@ -292,8 +292,6 @@ public class Workspace extends PagedView
mLauncher = Launcher.getLauncher(context);
mStateTransitionAnimation = new WorkspaceStateTransitionAnimation(mLauncher, this);
DeviceProfile grid = mLauncher.getDeviceProfile();
mWorkspaceFadeInAdjacentScreens = grid.shouldFadeAdjacentWorkspaceScreens();
mWallpaperManager = WallpaperManager.getInstance(context);
mWallpaperOffset = new WallpaperOffsetInterpolator(this);
@@ -312,6 +310,9 @@ public class Workspace extends PagedView
mInsets.set(insets);
DeviceProfile grid = mLauncher.getDeviceProfile();
mMaxDistanceForFolderCreation = (0.55f * grid.iconSizePx);
mWorkspaceFadeInAdjacentScreens = grid.shouldFadeAdjacentWorkspaceScreens();
Rect padding = grid.workspacePadding;
setPadding(padding.left, padding.top, padding.right, padding.bottom);
@@ -324,6 +325,13 @@ public class Workspace extends PagedView
// We assume symmetrical padding in portrait mode.
setPageSpacing(Math.max(grid.defaultPageSpacingPx, padding.left + 1));
}
int paddingLeftRight = grid.cellLayoutPaddingLeftRightPx;
int paddingBottom = grid.cellLayoutBottomPaddingPx;
for (int i = mWorkspaceScreens.size() - 1; i >= 0; i--) {
mWorkspaceScreens.valueAt(i)
.setPadding(paddingLeftRight, 0, paddingLeftRight, paddingBottom);
}
}
/**
@@ -445,12 +453,9 @@ public class Workspace extends PagedView
*/
protected void initWorkspace() {
mCurrentPage = DEFAULT_PAGE;
DeviceProfile grid = mLauncher.getDeviceProfile();
setWillNotDraw(false);
setClipToPadding(false);
setupLayoutTransition();
mMaxDistanceForFolderCreation = (0.55f * grid.iconSizePx);
// Set the wallpaper dimensions when Launcher starts up
setWallpaperDimension();
@@ -275,8 +275,6 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
DeviceProfile grid = mLauncher.getDeviceProfile();
// Update the number of items in the grid before we measure the view
grid.updateAppsViewNumCols();
if (mNumAppsPerRow != grid.inv.numColumns ||
mNumPredictedAppsPerRow != grid.inv.numColumns) {