mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 00:06:47 +00:00
Use updateButtonLayoutSpacing() for all states
* During a merge conflict we prevented updateButtonLayoutSpacing() from running if device was in setup mode, however the code that does setup layout is in there. Fixes: 254589281 Test: Went through setup, back button shows up where expected Change-Id: Ib496bfc0e3ac9023a9fc5071867c3779721ab8ab
This commit is contained in:
@@ -694,14 +694,10 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the correct spacing to 3 button nav container. No-op if using gesture nav, setup
|
||||
* is incomplete, or in kids mode.
|
||||
* Adds the correct spacing to 3 button nav container depending on if device is in kids mode,
|
||||
* setup wizard, or normal 3 button nav.
|
||||
*/
|
||||
private void updateButtonLayoutSpacing() {
|
||||
if (!mContext.isThreeButtonNav() || mContext.isNavBarKidsModeActive()
|
||||
|| !mContext.isUserSetupComplete()) {
|
||||
return;
|
||||
}
|
||||
DeviceProfile dp = mContext.getDeviceProfile();
|
||||
Resources res = mContext.getResources();
|
||||
boolean isInSetup = !mContext.isUserSetupComplete();
|
||||
@@ -719,41 +715,6 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
|
||||
return;
|
||||
}
|
||||
|
||||
// Add spacing after the end of the last nav button
|
||||
FrameLayout.LayoutParams navButtonParams =
|
||||
(FrameLayout.LayoutParams) mNavButtonContainer.getLayoutParams();
|
||||
navButtonParams.gravity = Gravity.END;
|
||||
navButtonParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
|
||||
navButtonParams.height = MATCH_PARENT;
|
||||
|
||||
int navMarginEnd = (int) res.getDimension(dp.inv.inlineNavButtonsEndSpacing);
|
||||
int contextualWidth = mEndContextualContainer.getWidth();
|
||||
// If contextual buttons are showing, we check if the end margin is enough for the
|
||||
// contextual button to be showing - if not, move the nav buttons over a smidge
|
||||
if (isContextualButtonShowing() && navMarginEnd < contextualWidth) {
|
||||
// Additional spacing, eat up half of space between last icon and nav button
|
||||
navMarginEnd += res.getDimensionPixelSize(R.dimen.taskbar_hotseat_nav_spacing) / 2;
|
||||
}
|
||||
navButtonParams.setMarginEnd(navMarginEnd);
|
||||
mNavButtonContainer.setLayoutParams(navButtonParams);
|
||||
|
||||
// Add the spaces in between the nav buttons
|
||||
int spaceInBetween = res.getDimensionPixelSize(R.dimen.taskbar_button_space_inbetween);
|
||||
for (int i = 0; i < mNavButtonContainer.getChildCount(); i++) {
|
||||
View navButton = mNavButtonContainer.getChildAt(i);
|
||||
LinearLayout.LayoutParams buttonLayoutParams =
|
||||
(LinearLayout.LayoutParams) navButton.getLayoutParams();
|
||||
buttonLayoutParams.weight = 0;
|
||||
if (i == 0) {
|
||||
buttonLayoutParams.setMarginEnd(spaceInBetween / 2);
|
||||
} else if (i == mNavButtonContainer.getChildCount() - 1) {
|
||||
buttonLayoutParams.setMarginStart(spaceInBetween / 2);
|
||||
} else {
|
||||
buttonLayoutParams.setMarginStart(spaceInBetween / 2);
|
||||
buttonLayoutParams.setMarginEnd(spaceInBetween / 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (isInSetup) {
|
||||
handleSetupUi();
|
||||
|
||||
@@ -829,6 +790,42 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
|
||||
mNavButtonContainer.requestLayout();
|
||||
|
||||
mHomeButton.setOnLongClickListener(null);
|
||||
} else if (mContext.isThreeButtonNav()) {
|
||||
// Setup normal 3 button
|
||||
// Add spacing after the end of the last nav button
|
||||
FrameLayout.LayoutParams navButtonParams =
|
||||
(FrameLayout.LayoutParams) mNavButtonContainer.getLayoutParams();
|
||||
navButtonParams.gravity = Gravity.END;
|
||||
navButtonParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
|
||||
navButtonParams.height = MATCH_PARENT;
|
||||
|
||||
int navMarginEnd = (int) res.getDimension(dp.inv.inlineNavButtonsEndSpacing);
|
||||
int contextualWidth = mEndContextualContainer.getWidth();
|
||||
// If contextual buttons are showing, we check if the end margin is enough for the
|
||||
// contextual button to be showing - if not, move the nav buttons over a smidge
|
||||
if (isContextualButtonShowing() && navMarginEnd < contextualWidth) {
|
||||
// Additional spacing, eat up half of space between last icon and nav button
|
||||
navMarginEnd += res.getDimensionPixelSize(R.dimen.taskbar_hotseat_nav_spacing) / 2;
|
||||
}
|
||||
navButtonParams.setMarginEnd(navMarginEnd);
|
||||
mNavButtonContainer.setLayoutParams(navButtonParams);
|
||||
|
||||
// Add the spaces in between the nav buttons
|
||||
int spaceInBetween = res.getDimensionPixelSize(R.dimen.taskbar_button_space_inbetween);
|
||||
for (int i = 0; i < mNavButtonContainer.getChildCount(); i++) {
|
||||
View navButton = mNavButtonContainer.getChildAt(i);
|
||||
LinearLayout.LayoutParams buttonLayoutParams =
|
||||
(LinearLayout.LayoutParams) navButton.getLayoutParams();
|
||||
buttonLayoutParams.weight = 0;
|
||||
if (i == 0) {
|
||||
buttonLayoutParams.setMarginEnd(spaceInBetween / 2);
|
||||
} else if (i == mNavButtonContainer.getChildCount() - 1) {
|
||||
buttonLayoutParams.setMarginStart(spaceInBetween / 2);
|
||||
} else {
|
||||
buttonLayoutParams.setMarginStart(spaceInBetween / 2);
|
||||
buttonLayoutParams.setMarginEnd(spaceInBetween / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user