Merge "First pass at Taskbar layout UI polish for SUW" into tm-qpr-dev

This commit is contained in:
TreeHugger Robot
2022-10-12 02:27:37 +00:00
committed by Android (Google) Code Review
6 changed files with 53 additions and 18 deletions

View File

@@ -80,4 +80,8 @@
<dimen name="taskbar_button_margin_6_5">219.6dp</dimen>
<dimen name="taskbar_button_margin_4_5">84dp</dimen>
<dimen name="taskbar_button_margin_4_4">79dp</dimen>
<dimen name="taskbar_contextual_button_margin">48dp</dimen>
<dimen name="taskbar_suw_frame">96dp</dimen>
<dimen name="taskbar_suw_insets">24dp</dimen>
</resources>

View File

@@ -258,7 +258,10 @@
<dimen name="taskbar_contextual_button_padding">16dp</dimen>
<dimen name="taskbar_contextual_padding_top">8dp</dimen>
<dimen name="taskbar_nav_buttons_size">44dp</dimen>
<dimen name="taskbar_contextual_button_margin">48dp</dimen>
<dimen name="taskbar_split_instructions_margin">48dp</dimen>
<dimen name="taskbar_contextual_button_margin">120dp</dimen>
<dimen name="taskbar_suw_insets">48dp</dimen>
<dimen name="taskbar_suw_frame">48dp</dimen>
<dimen name="taskbar_hotseat_nav_spacing">24dp</dimen>
<dimen name="taskbar_contextual_buttons_size">35dp</dimen>
<dimen name="taskbar_stashed_size">24dp</dimen>

View File

@@ -204,8 +204,10 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
DeviceProfile deviceProfile = mContext.getDeviceProfile();
Resources resources = mContext.getResources();
mNavButtonsView.getLayoutParams().height = !isPhoneMode(deviceProfile) ?
deviceProfile.taskbarSize :
resources.getDimensionPixelSize(R.dimen.taskbar_size);
mContext.isUserSetupComplete()
? deviceProfile.taskbarSize
: resources.getDimensionPixelSize(R.dimen.taskbar_suw_frame)
: resources.getDimensionPixelSize(R.dimen.taskbar_size);
mIsImeRenderingNavButtons =
InputMethodService.canImeRenderGesturalNavButtons() && mContext.imeDrawsImeNavBar();
@@ -267,15 +269,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
updateButtonLayoutSpacing();
updateStateForFlag(FLAG_SMALL_SCREEN, isPhoneButtonNavMode(mContext));
if (isInSetup) {
// Since setup wizard only has back button enabled, it looks strange to be
// end-aligned, so start-align instead.
FrameLayout.LayoutParams navButtonsLayoutParams = (FrameLayout.LayoutParams)
mNavButtonContainer.getLayoutParams();
navButtonsLayoutParams.setMarginStart(
resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_margin));
navButtonsLayoutParams.setMarginEnd(0);
navButtonsLayoutParams.gravity = Gravity.START;
mNavButtonContainer.requestLayout();
handleSetupUi();
// Hide back button in SUW if keyboard is showing (IME draws its own back).
mPropertyHolders.add(new StatePropertyHolder(
@@ -745,14 +739,38 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
if (mFloatingRotationButton != null) {
mFloatingRotationButton.onConfigurationChanged(configChanges);
}
if (!mContext.isUserSetupComplete()) {
handleSetupUi();
}
updateButtonLayoutSpacing();
}
private void handleSetupUi() {
// Since setup wizard only has back button enabled, it looks strange to be
// end-aligned, so start-align instead.
FrameLayout.LayoutParams navButtonsLayoutParams = (FrameLayout.LayoutParams)
mNavButtonContainer.getLayoutParams();
Resources resources = mContext.getResources();
DeviceProfile deviceProfile = mContext.getDeviceProfile();
int setupMargin = resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_margin);
navButtonsLayoutParams.setMarginStart(setupMargin);
navButtonsLayoutParams.bottomMargin = !deviceProfile.isLandscape
? 0
: setupMargin -
(resources.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size) / 2);
navButtonsLayoutParams.setMarginEnd(0);
navButtonsLayoutParams.gravity = Gravity.START;
mNavButtonContainer.setLayoutParams(navButtonsLayoutParams);
mNavButtonContainer.requestLayout();
}
/**
* Adds the correct spacing to 3 button nav container. No-op if using gesture nav or kids mode.
* Adds the correct spacing to 3 button nav container. No-op if using gesture nav, setup
* is incomplete, or in kids mode.
*/
private void updateButtonLayoutSpacing() {
if (!mContext.isThreeButtonNav() || mContext.isNavBarKidsModeActive()) {
if (!mContext.isThreeButtonNav() || mContext.isNavBarKidsModeActive()
|| !mContext.isUserSetupComplete()) {
return;
}

View File

@@ -148,11 +148,12 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
mImeDrawsImeNavBar = getBoolByName(IME_DRAWS_IME_NAV_BAR_RES_NAME, resources, false);
mIsSafeModeEnabled = TraceHelper.allowIpcs("isSafeMode",
() -> getPackageManager().isSafeMode());
mIsUserSetupComplete = SettingsCache.INSTANCE.get(this).getValue(
SettingsCache settingsCache = SettingsCache.INSTANCE.get(this);
mIsUserSetupComplete = settingsCache.getValue(
Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), 0);
mIsNavBarForceVisible = SettingsCache.INSTANCE.get(this).getValue(
mIsNavBarForceVisible = settingsCache.getValue(
Settings.Secure.getUriFor(Settings.Secure.NAV_BAR_KIDS_MODE), 0);
mIsNavBarKidsMode = SettingsCache.INSTANCE.get(this).getValue(
mIsNavBarKidsMode = settingsCache.getValue(
Settings.Secure.getUriFor(Settings.Secure.NAV_BAR_KIDS_MODE), 0);
updateIconSize(resources);
@@ -614,6 +615,10 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
resources.getDimensionPixelSize(R.dimen.taskbar_size) :
resources.getDimensionPixelSize(R.dimen.taskbar_stashed_size);
}
if (!isUserSetupComplete()) {
return getResources().getDimensionPixelSize(R.dimen.taskbar_suw_frame);
}
return mDeviceProfile.taskbarSize + Math.max(getLeftCornerRadius(), getRightCornerRadius());
}

View File

@@ -354,6 +354,11 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
}
return mStashedHeight;
}
if (!mActivity.isUserSetupComplete()) {
// Special insets for SUW.
return mActivity.getResources().getDimensionPixelSize(R.dimen.taskbar_suw_insets);
}
return mUnstashedHeight;
}

View File

@@ -121,7 +121,7 @@ public class SplitInstructionsView extends FrameLayout {
int navButtonWidth = getResources().getDimensionPixelSize(
R.dimen.taskbar_nav_buttons_size);
int extraMargin = getResources().getDimensionPixelSize(
R.dimen.taskbar_contextual_button_margin);
R.dimen.taskbar_split_instructions_margin);
// Explanation: The 3-button nav for non-phones sits on one side of the screen, taking
// up 3 buttons + a side margin worth of space. Our splitInstructionsView starts in the
// center of the screen and we want to center it in the remaining space, therefore we