mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 18:58:19 +00:00
Merge "Adjust where the back button is rendered for new SUW requirements." into 24D1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f44e8e5feb
@@ -78,7 +78,8 @@
|
||||
<!-- Taskbar 3 button spacing -->
|
||||
<dimen name="taskbar_button_margin_split">88dp</dimen>
|
||||
<dimen name="taskbar_button_margin_6_5">219.6dp</dimen>
|
||||
<dimen name="taskbar_contextual_button_margin">48dp</dimen>
|
||||
<dimen name="taskbar_contextual_button_suw_margin">48dp</dimen>
|
||||
<dimen name="taskbar_contextual_button_suw_height">48dp</dimen>
|
||||
<dimen name="taskbar_suw_frame">96dp</dimen>
|
||||
<dimen name="taskbar_suw_insets">24dp</dimen>
|
||||
|
||||
|
||||
@@ -325,9 +325,8 @@
|
||||
<dimen name="taskbar_contextual_padding_top">8dp</dimen>
|
||||
<dimen name="taskbar_nav_buttons_size">44dp</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_suw_frame">96dp</dimen>
|
||||
<dimen name="taskbar_hotseat_nav_spacing">24dp</dimen>
|
||||
<dimen name="taskbar_contextual_buttons_size">35dp</dimen>
|
||||
<dimen name="taskbar_stashed_size">24dp</dimen>
|
||||
@@ -346,6 +345,11 @@
|
||||
<dimen name="taskbar_icon_size_kids">32dp</dimen>
|
||||
<dimen name="taskbar_all_apps_button_translation_x_offset">6dp</dimen>
|
||||
<dimen name="taskbar_all_apps_search_button_translation_x_offset">6dp</dimen>
|
||||
<dimen name="taskbar_contextual_button_suw_margin">64dp</dimen>
|
||||
<dimen name="taskbar_contextual_button_suw_height">64dp</dimen>
|
||||
<dimen name="taskbar_back_button_suw_start_margin">48dp</dimen>
|
||||
<dimen name="taskbar_back_button_suw_bottom_margin">1dp</dimen>
|
||||
<dimen name="taskbar_back_button_suw_height">72dp</dimen>
|
||||
|
||||
<!-- Transient taskbar -->
|
||||
<dimen name="transient_taskbar_padding">12dp</dimen>
|
||||
|
||||
@@ -142,6 +142,9 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
|
||||
|
||||
private static final String NAV_BUTTONS_SEPARATE_WINDOW_TITLE = "Taskbar Nav Buttons";
|
||||
|
||||
private static final double SQUARE_ASPECT_RATIO_BOTTOM_BOUND = 0.95;
|
||||
private static final double SQUARE_ASPECT_RATIO_UPPER_BOUND = 1.05;
|
||||
|
||||
public static final int ALPHA_INDEX_IMMERSIVE_MODE = 0;
|
||||
public static final int ALPHA_INDEX_KEYGUARD_OR_DISABLE = 1;
|
||||
public static final int ALPHA_INDEX_SUW = 2;
|
||||
@@ -735,18 +738,39 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
|
||||
// end-aligned, so start-align instead.
|
||||
FrameLayout.LayoutParams navButtonsLayoutParams = (FrameLayout.LayoutParams)
|
||||
mNavButtonContainer.getLayoutParams();
|
||||
FrameLayout.LayoutParams navButtonsViewLayoutParams = (FrameLayout.LayoutParams)
|
||||
mNavButtonsView.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;
|
||||
mNavButtonsView.getLayoutParams().height =
|
||||
mControllers.taskbarActivityContext.getSetupWindowSize();
|
||||
mControllers.taskbarActivityContext.setTaskbarWindowSize(
|
||||
mControllers.taskbarActivityContext.getSetupWindowSize());
|
||||
|
||||
// If SUW is on a large screen device that is landscape (or has a square aspect
|
||||
// ratio) the back button has to be placed accordingly
|
||||
if ((deviceProfile.isTablet && deviceProfile.isLandscape)
|
||||
|| (deviceProfile.aspectRatio > SQUARE_ASPECT_RATIO_BOTTOM_BOUND
|
||||
&& deviceProfile.aspectRatio < SQUARE_ASPECT_RATIO_UPPER_BOUND)) {
|
||||
navButtonsLayoutParams.setMarginStart(
|
||||
resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_start_margin));
|
||||
navButtonsViewLayoutParams.bottomMargin = resources.getDimensionPixelSize(
|
||||
R.dimen.taskbar_back_button_suw_bottom_margin);
|
||||
navButtonsLayoutParams.height = resources.getDimensionPixelSize(
|
||||
R.dimen.taskbar_back_button_suw_height);
|
||||
} else {
|
||||
int phoneOrPortraitSetupMargin = resources.getDimensionPixelSize(
|
||||
R.dimen.taskbar_contextual_button_suw_margin);
|
||||
navButtonsLayoutParams.setMarginStart(phoneOrPortraitSetupMargin);
|
||||
navButtonsLayoutParams.bottomMargin = !deviceProfile.isLandscape
|
||||
? 0
|
||||
: phoneOrPortraitSetupMargin - (resources.getDimensionPixelSize(
|
||||
R.dimen.taskbar_nav_buttons_size) / 2);
|
||||
navButtonsViewLayoutParams.height = resources.getDimensionPixelSize(
|
||||
R.dimen.taskbar_contextual_button_suw_height);
|
||||
}
|
||||
mNavButtonsView.setLayoutParams(navButtonsViewLayoutParams);
|
||||
mNavButtonContainer.setLayoutParams(navButtonsLayoutParams);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.content.res.Resources
|
||||
import android.view.Surface.ROTATION_90
|
||||
import android.view.Surface.Rotation
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
@@ -56,18 +55,18 @@ class NavButtonLayoutFactory {
|
||||
* @param isThreeButtonNav are no-ops when taskbar is present/showing
|
||||
*/
|
||||
fun getUiLayoutter(
|
||||
deviceProfile: DeviceProfile,
|
||||
navButtonsView: NearestTouchFrame,
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?,
|
||||
resources: Resources,
|
||||
isKidsMode: Boolean,
|
||||
isInSetup: Boolean,
|
||||
isThreeButtonNav: Boolean,
|
||||
phoneMode: Boolean,
|
||||
@Rotation surfaceRotation: Int
|
||||
deviceProfile: DeviceProfile,
|
||||
navButtonsView: NearestTouchFrame,
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?,
|
||||
resources: Resources,
|
||||
isKidsMode: Boolean,
|
||||
isInSetup: Boolean,
|
||||
isThreeButtonNav: Boolean,
|
||||
phoneMode: Boolean,
|
||||
@Rotation surfaceRotation: Int
|
||||
): NavButtonLayoutter {
|
||||
val navButtonContainer =
|
||||
navButtonsView.requireViewById<LinearLayout>(ID_END_NAV_BUTTONS)
|
||||
@@ -82,43 +81,6 @@ class NavButtonLayoutFactory {
|
||||
if (!deviceProfile.isLandscape) {
|
||||
navButtonsView.setIsVertical(false)
|
||||
PhonePortraitNavLayoutter(
|
||||
resources,
|
||||
navButtonContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
} else if (surfaceRotation == ROTATION_90) {
|
||||
navButtonsView.setIsVertical(true)
|
||||
PhoneLandscapeNavLayoutter(
|
||||
resources,
|
||||
navButtonContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
} else {
|
||||
navButtonsView.setIsVertical(true)
|
||||
PhoneSeascapeNavLayoutter(
|
||||
resources,
|
||||
navButtonContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
}
|
||||
}
|
||||
isPhoneGestureMode ->{
|
||||
PhoneGestureLayoutter(
|
||||
resources,
|
||||
navButtonContainer,
|
||||
endContextualContainer,
|
||||
@@ -127,44 +89,82 @@ class NavButtonLayoutFactory {
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
} else if (surfaceRotation == ROTATION_90) {
|
||||
navButtonsView.setIsVertical(true)
|
||||
PhoneLandscapeNavLayoutter(
|
||||
resources,
|
||||
navButtonContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
} else {
|
||||
navButtonsView.setIsVertical(true)
|
||||
PhoneSeascapeNavLayoutter(
|
||||
resources,
|
||||
navButtonContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
}
|
||||
}
|
||||
isPhoneGestureMode -> {
|
||||
PhoneGestureLayoutter(
|
||||
resources,
|
||||
navButtonContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
}
|
||||
deviceProfile.isTaskbarPresent -> {
|
||||
return when {
|
||||
isInSetup -> {
|
||||
SetupNavLayoutter(
|
||||
resources,
|
||||
navButtonContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
resources,
|
||||
navButtonsView,
|
||||
navButtonContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
}
|
||||
isKidsMode -> {
|
||||
KidsNavLayoutter(
|
||||
resources,
|
||||
navButtonContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
resources,
|
||||
navButtonContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
}
|
||||
else ->
|
||||
TaskbarNavLayoutter(
|
||||
resources,
|
||||
navButtonContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
resources,
|
||||
navButtonContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,50 +24,89 @@ import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
import com.android.launcher3.DeviceProfile
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext
|
||||
import com.android.systemui.shared.rotation.RotationButton
|
||||
|
||||
const val SQUARE_ASPECT_RATIO_BOTTOM_BOUND = 0.95
|
||||
const val SQUARE_ASPECT_RATIO_UPPER_BOUND = 1.05
|
||||
|
||||
class SetupNavLayoutter(
|
||||
resources: Resources,
|
||||
navButtonContainer: LinearLayout,
|
||||
endContextualContainer: ViewGroup,
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?
|
||||
resources: Resources,
|
||||
navButtonsView: NearestTouchFrame,
|
||||
navButtonContainer: LinearLayout,
|
||||
endContextualContainer: ViewGroup,
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?
|
||||
) :
|
||||
AbstractNavButtonLayoutter(
|
||||
resources,
|
||||
navButtonContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
resources,
|
||||
navButtonContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
private val mNavButtonsView = navButtonsView
|
||||
|
||||
override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
|
||||
// Since setup wizard only has back button enabled, it looks strange to be
|
||||
// end-aligned, so start-align instead.
|
||||
val navButtonsLayoutParams = navButtonContainer.layoutParams as FrameLayout.LayoutParams
|
||||
navButtonsLayoutParams.apply {
|
||||
marginStart = navButtonsLayoutParams.marginEnd
|
||||
marginEnd = 0
|
||||
gravity = Gravity.START
|
||||
val navButtonsViewLayoutParams = mNavButtonsView.layoutParams as FrameLayout.LayoutParams
|
||||
val deviceProfile: DeviceProfile = context.deviceProfile
|
||||
|
||||
navButtonsLayoutParams.marginEnd = 0
|
||||
navButtonsLayoutParams.gravity = Gravity.START
|
||||
context.setTaskbarWindowSize(context.setupWindowSize)
|
||||
|
||||
// If SUW is on a large screen device that is landscape (or has a square aspect
|
||||
// ratio) the back button has to be placed accordingly
|
||||
if (
|
||||
deviceProfile.isTablet && deviceProfile.isLandscape ||
|
||||
(deviceProfile.aspectRatio > SQUARE_ASPECT_RATIO_BOTTOM_BOUND &&
|
||||
deviceProfile.aspectRatio < SQUARE_ASPECT_RATIO_UPPER_BOUND)
|
||||
) {
|
||||
navButtonsLayoutParams.marginStart =
|
||||
resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_start_margin)
|
||||
navButtonsViewLayoutParams.bottomMargin =
|
||||
resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_bottom_margin)
|
||||
navButtonsLayoutParams.height =
|
||||
resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_height)
|
||||
} else {
|
||||
val phoneOrPortraitSetupMargin =
|
||||
resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_suw_margin)
|
||||
navButtonsLayoutParams.marginStart = phoneOrPortraitSetupMargin
|
||||
navButtonsLayoutParams.bottomMargin =
|
||||
if (!deviceProfile.isLandscape) 0
|
||||
else
|
||||
phoneOrPortraitSetupMargin -
|
||||
resources.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size) / 2
|
||||
navButtonsViewLayoutParams.height =
|
||||
resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_suw_height)
|
||||
}
|
||||
navButtonContainer.requestLayout()
|
||||
mNavButtonsView.layoutParams = navButtonsViewLayoutParams
|
||||
navButtonContainer.layoutParams = navButtonsLayoutParams
|
||||
|
||||
endContextualContainer.removeAllViews()
|
||||
startContextualContainer.removeAllViews()
|
||||
|
||||
val contextualMargin = resources.getDimensionPixelSize(
|
||||
R.dimen.taskbar_contextual_button_padding)
|
||||
val contextualMargin =
|
||||
resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_padding)
|
||||
repositionContextualContainer(endContextualContainer, WRAP_CONTENT, 0, 0, Gravity.END)
|
||||
repositionContextualContainer(startContextualContainer, WRAP_CONTENT, contextualMargin,
|
||||
contextualMargin, Gravity.START)
|
||||
repositionContextualContainer(
|
||||
startContextualContainer,
|
||||
WRAP_CONTENT,
|
||||
contextualMargin,
|
||||
contextualMargin,
|
||||
Gravity.START
|
||||
)
|
||||
|
||||
if (imeSwitcher != null) {
|
||||
startContextualContainer.addView(imeSwitcher)
|
||||
|
||||
@@ -396,7 +396,7 @@
|
||||
<dimen name="transient_taskbar_clamped_offset_bound">0dp</dimen>
|
||||
<dimen name="taskbar_icon_spacing">0dp</dimen>
|
||||
<dimen name="taskbar_nav_buttons_size">0dp</dimen>
|
||||
<dimen name="taskbar_contextual_button_margin">0dp</dimen>
|
||||
<dimen name="taskbar_contextual_button_suw_margin">0dp</dimen>
|
||||
<dimen name="taskbar_hotseat_nav_spacing">0dp</dimen>
|
||||
<dimen name="taskbar_button_margin_default">0dp</dimen>
|
||||
<dimen name="taskbar_button_space_inbetween">0dp</dimen>
|
||||
|
||||
Reference in New Issue
Block a user