Skip to content

Commit

Permalink
Correct Launcher sizing
Browse files Browse the repository at this point in the history
Signed-off-by: validcube <[email protected]>
  • Loading branch information
validcube committed Dec 21, 2023
1 parent eb0d4ea commit ed35272
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 30 deletions.
14 changes: 7 additions & 7 deletions src/com/android/launcher3/DeviceProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ public class DeviceProfile {
numShownAllAppsColumns =
isTwoPanels ? inv.numDatabaseAllAppsColumns : inv.numAllAppsColumns;

int hotseatBarBottomSpace = isQsbEnable ? 0 : pxFromDp(inv.hotseatBarBottomSpace[mTypeIndex], mMetrics);
int hotseatBarBottomSpace = !isQsbEnable ? 0 : pxFromDp(inv.hotseatBarBottomSpace[mTypeIndex], mMetrics);
int minQsbMargin = res.getDimensionPixelSize(R.dimen.min_qsb_margin);
hotseatQsbSpace = pxFromDp(inv.hotseatQsbSpace[mTypeIndex], mMetrics);
// Have a little space between the inset and the QSB
Expand Down Expand Up @@ -705,15 +705,16 @@ private void updateHotseatSizes(int hotseatIconSizePx) {

if (isVerticalBarLayout()) {
hotseatBarSizePx = hotseatIconSizePx + hotseatBarSidePaddingStartPx
+ hotseatBarSidePaddingEndPx;
+ hotseatBarSidePaddingEndPx + space;
} else if (isQsbInline) {
hotseatBarSizePx = Math.max(hotseatIconSizePx, hotseatQsbVisualHeight)
+ hotseatBarBottomSpacePx ;
+ hotseatBarBottomSpacePx + space;
} else {
hotseatBarSizePx = hotseatIconSizePx
+ hotseatQsbSpace
+ hotseatQsbVisualHeight
+ hotseatBarBottomSpacePx;
+ hotseatBarBottomSpacePx
+ space;
}
var isHotseatEnabled = PreferenceExtensionsKt.firstBlocking(preferenceManager2.isHotseatEnabled());
if (!isHotseatEnabled) {
Expand Down Expand Up @@ -1071,9 +1072,8 @@ public void updateIconSize(float scale, Resources res) {
*/
private int calculateHotseatBorderSpace(float hotseatWidthPx, int numExtraBorder) {
float hotseatIconsTotalPx = iconSizePx * numShownHotseatIcons;
int hotseatBorderSpacePx =
(int) (hotseatWidthPx - hotseatIconsTotalPx)
/ (numShownHotseatIcons - 1 + numExtraBorder);
int hotseatBorderSpacePx = (int) (hotseatWidthPx - hotseatIconsTotalPx)
/ (numShownHotseatIcons - 1 + numExtraBorder);
return Math.min(hotseatBorderSpacePx, mMaxHotseatIconSpacePx);
}

Expand Down
25 changes: 6 additions & 19 deletions src/com/android/launcher3/Hotseat.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void setInsets(Rect insets) {

if (grid.isVerticalBarLayout()) {
mQsb.setVisibility(View.GONE);
lp.height = LayoutParams.MATCH_PARENT;
lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
if (grid.isSeascape()) {
lp.gravity = Gravity.LEFT;
lp.width = grid.hotseatBarSizePx + insets.left;
Expand All @@ -130,29 +130,14 @@ public void setInsets(Rect insets) {
} else {
mQsb.setVisibility(View.VISIBLE);
lp.gravity = Gravity.BOTTOM;
lp.width = LayoutParams.MATCH_PARENT;
lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
lp.height = grid.hotseatBarSizePx;
lp.topMargin = grid.hotseatBarBottomSpacePx;
}

Rect padding = grid.getHotseatLayoutPadding(getContext());
setPadding(padding.left, padding.top, padding.right, padding.bottom);
if(!PreferenceExtensionsKt.firstBlocking(preferenceManager2.getEnableTaskbarOnPhone())){
FrameLayout.LayoutParams qsbLp = (FrameLayout.LayoutParams) getLayoutParams();
qsbLp.topMargin = grid.hotseatBarBottomSpacePx;
qsbLp.height = (grid.hotseatBarSizePx * 2) - (padding.bottom + grid.hotseatBarBottomSpacePx);
mQsb.setLayoutParams (qsbLp);
setLayoutParams(lp);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
if(mQsb.getSourceLayoutResId () == R.layout.empty_view){
mQsb.setVisibility (View.GONE);
mQsb.setLayoutParams ((FrameLayout.LayoutParams) getLayoutParams());
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) getLayoutParams();
layoutParams.height = grid.hotseatBarSizePx;
setLayoutParams(layoutParams);
}
}
setLayoutParams(lp);
InsettableFrameLayout.dispatchInsets(this, insets);
}

Expand Down Expand Up @@ -195,9 +180,11 @@ public boolean onTouchEvent(MotionEvent event) {
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);

DeviceProfile dp = mActivity.getDeviceProfile();

int width = getShortcutsAndWidgets().getMeasuredWidth();
mQsb.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(mQsbHeight, MeasureSpec.EXACTLY));
MeasureSpec.makeMeasureSpec(dp.hotseatQsbHeight, MeasureSpec.EXACTLY));
}

@Override
Expand Down
5 changes: 1 addition & 4 deletions src/com/android/launcher3/Workspace.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,7 @@ private void setPageIndicatorInset() {
} else {
lp.leftMargin = lp.rightMargin = 0;
lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
boolean isDisabledHotseat = Utilities.ATLEAST_Q &&
getHotseat() != null &&
getHotseat().getQsb().getSourceLayoutResId() == R.layout.empty_view;
lp.bottomMargin = (padding.bottom) + grid.hotseatBarBottomSpacePx - (isDisabledHotseat ? grid.workspaceCellPaddingXPx * 3 : 0);
lp.bottomMargin = grid.hotseatBarSizePx;
}
mPageIndicator.setLayoutParams(lp);
}
Expand Down

0 comments on commit ed35272

Please sign in to comment.