mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-18 10:18:20 +00:00
Merge "Replace Contextual Rotation Button with Floating Action Button" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
43f65905ab
@@ -317,38 +317,28 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
|
||||
mPropertyHolders.add(new StatePropertyHolder(
|
||||
mControllers.taskbarDragLayerController.getNavbarBackgroundAlpha(),
|
||||
flags -> (flags & FLAG_ONLY_BACK_FOR_BOUNCER_VISIBLE) != 0));
|
||||
|
||||
// Rotation button
|
||||
RotationButton rotationButton = new RotationButtonImpl(
|
||||
addButton(mEndContextualContainer, R.id.rotate_suggestion,
|
||||
R.layout.taskbar_contextual_button));
|
||||
rotationButton.hide();
|
||||
mControllers.rotationButtonController.setRotationButton(rotationButton, null);
|
||||
} else {
|
||||
mFloatingRotationButton = new FloatingRotationButton(
|
||||
ENABLE_TASKBAR_NAVBAR_UNIFICATION ? mNavigationBarPanelContext : mContext,
|
||||
R.string.accessibility_rotate_button,
|
||||
R.layout.rotate_suggestion,
|
||||
R.id.rotate_suggestion,
|
||||
R.dimen.floating_rotation_button_min_margin,
|
||||
R.dimen.rounded_corner_content_padding,
|
||||
R.dimen.floating_rotation_button_taskbar_left_margin,
|
||||
R.dimen.floating_rotation_button_taskbar_bottom_margin,
|
||||
R.dimen.floating_rotation_button_diameter,
|
||||
R.dimen.key_button_ripple_max_width,
|
||||
R.bool.floating_rotation_button_position_left);
|
||||
mControllers.rotationButtonController.setRotationButton(mFloatingRotationButton,
|
||||
mRotationButtonListener);
|
||||
|
||||
if (!mIsImeRenderingNavButtons) {
|
||||
View imeDownButton = addButton(R.drawable.ic_sysbar_back, BUTTON_BACK,
|
||||
mStartContextualContainer, mControllers.navButtonController, R.id.back);
|
||||
imeDownButton.setRotation(Utilities.isRtl(resources) ? 90 : -90);
|
||||
// Only show when IME is visible.
|
||||
mPropertyHolders.add(new StatePropertyHolder(imeDownButton,
|
||||
flags -> (flags & FLAG_IME_VISIBLE) != 0));
|
||||
}
|
||||
} else if (!mIsImeRenderingNavButtons) {
|
||||
View imeDownButton = addButton(R.drawable.ic_sysbar_back, BUTTON_BACK,
|
||||
mStartContextualContainer, mControllers.navButtonController, R.id.back);
|
||||
imeDownButton.setRotation(Utilities.isRtl(resources) ? 90 : -90);
|
||||
// Only show when IME is visible.
|
||||
mPropertyHolders.add(new StatePropertyHolder(imeDownButton,
|
||||
flags -> (flags & FLAG_IME_VISIBLE) != 0));
|
||||
}
|
||||
mFloatingRotationButton = new FloatingRotationButton(
|
||||
ENABLE_TASKBAR_NAVBAR_UNIFICATION ? mNavigationBarPanelContext : mContext,
|
||||
R.string.accessibility_rotate_button,
|
||||
R.layout.rotate_suggestion,
|
||||
R.id.rotate_suggestion,
|
||||
R.dimen.floating_rotation_button_min_margin,
|
||||
R.dimen.rounded_corner_content_padding,
|
||||
R.dimen.floating_rotation_button_taskbar_left_margin,
|
||||
R.dimen.floating_rotation_button_taskbar_bottom_margin,
|
||||
R.dimen.floating_rotation_button_diameter,
|
||||
R.dimen.key_button_ripple_max_width,
|
||||
R.bool.floating_rotation_button_position_left);
|
||||
mControllers.rotationButtonController.setRotationButton(mFloatingRotationButton,
|
||||
mRotationButtonListener);
|
||||
|
||||
applyState();
|
||||
mPropertyHolders.forEach(StatePropertyHolder::endAnimation);
|
||||
@@ -791,7 +781,6 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
|
||||
NavButtonLayoutter navButtonLayoutter =
|
||||
NavButtonLayoutFactory.Companion.getUiLayoutter(
|
||||
dp, mNavButtonsView, mImeSwitcherButton,
|
||||
mControllers.rotationButtonController.getRotationButton(),
|
||||
mA11yButton, mSpace, res, isInKidsMode, isInSetup, isThreeButtonNav,
|
||||
mContext.isPhoneMode(), mWindowManagerProxy.getRotation(mContext));
|
||||
navButtonLayoutter.layoutButtons(mContext, isA11yButtonPersistent());
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.widget.Space
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.Utilities
|
||||
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.NavButtonLayoutter
|
||||
import com.android.systemui.shared.rotation.RotationButton
|
||||
|
||||
/**
|
||||
* Meant to be a simple container for data subclasses will need
|
||||
@@ -41,14 +40,13 @@ import com.android.systemui.shared.rotation.RotationButton
|
||||
* @property startContextualContainer ViewGroup that holds the start contextual button (ex, A11y).
|
||||
*/
|
||||
abstract class AbstractNavButtonLayoutter(
|
||||
val resources: Resources,
|
||||
val navButtonContainer: LinearLayout,
|
||||
protected val endContextualContainer: ViewGroup,
|
||||
protected val startContextualContainer: ViewGroup,
|
||||
protected val imeSwitcher: ImageView?,
|
||||
protected val rotationButton: RotationButton?,
|
||||
protected val a11yButton: ImageView?,
|
||||
protected val space: Space?
|
||||
val resources: Resources,
|
||||
val navButtonContainer: LinearLayout,
|
||||
protected val endContextualContainer: ViewGroup,
|
||||
protected val startContextualContainer: ViewGroup,
|
||||
protected val imeSwitcher: ImageView?,
|
||||
protected val a11yButton: ImageView?,
|
||||
protected val space: Space?
|
||||
) : NavButtonLayoutter {
|
||||
protected val homeButton: ImageView? = navButtonContainer.findViewById(R.id.home)
|
||||
protected val recentsButton: ImageView? = navButtonContainer.findViewById(R.id.recent_apps)
|
||||
@@ -66,17 +64,24 @@ abstract class AbstractNavButtonLayoutter(
|
||||
}
|
||||
|
||||
fun getParamsToCenterView(): FrameLayout.LayoutParams {
|
||||
val params = FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
||||
val params =
|
||||
FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
params.gravity = Gravity.CENTER
|
||||
return params;
|
||||
return params
|
||||
}
|
||||
|
||||
open fun repositionContextualContainer(contextualContainer: ViewGroup, buttonSize: Int,
|
||||
barAxisMarginStart: Int, barAxisMarginEnd: Int,
|
||||
gravity: Int) {
|
||||
val contextualContainerParams = FrameLayout.LayoutParams(
|
||||
buttonSize, ViewGroup.LayoutParams.MATCH_PARENT)
|
||||
open fun repositionContextualContainer(
|
||||
contextualContainer: ViewGroup,
|
||||
buttonSize: Int,
|
||||
barAxisMarginStart: Int,
|
||||
barAxisMarginEnd: Int,
|
||||
gravity: Int
|
||||
) {
|
||||
val contextualContainerParams =
|
||||
FrameLayout.LayoutParams(buttonSize, ViewGroup.LayoutParams.MATCH_PARENT)
|
||||
contextualContainerParams.apply {
|
||||
marginStart = barAxisMarginStart
|
||||
marginEnd = barAxisMarginEnd
|
||||
|
||||
@@ -29,27 +29,24 @@ import android.widget.Space
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext
|
||||
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.*
|
||||
import com.android.systemui.shared.rotation.RotationButton
|
||||
|
||||
class KidsNavLayoutter(
|
||||
resources: Resources,
|
||||
navBarContainer: LinearLayout,
|
||||
endContextualContainer: ViewGroup,
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?
|
||||
resources: Resources,
|
||||
navBarContainer: LinearLayout,
|
||||
endContextualContainer: ViewGroup,
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?
|
||||
) :
|
||||
AbstractNavButtonLayoutter(
|
||||
resources,
|
||||
navBarContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
resources,
|
||||
navBarContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
|
||||
override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
|
||||
@@ -105,11 +102,16 @@ class KidsNavLayoutter(
|
||||
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)
|
||||
@@ -119,9 +121,5 @@ class KidsNavLayoutter(
|
||||
endContextualContainer.addView(a11yButton)
|
||||
a11yButton.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
if (rotationButton != null) {
|
||||
endContextualContainer.addView(rotationButton.currentView)
|
||||
rotationButton.currentView.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,11 @@ import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
import com.android.launcher3.DeviceProfile
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext
|
||||
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.*
|
||||
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_END_CONTEXTUAL_BUTTONS
|
||||
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_END_NAV_BUTTONS
|
||||
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_START_CONTEXTUAL_BUTTONS
|
||||
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.Companion
|
||||
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.NavButtonLayoutter
|
||||
import com.android.systemui.shared.rotation.RotationButton
|
||||
|
||||
/**
|
||||
* Select the correct layout for nav buttons
|
||||
@@ -58,7 +59,6 @@ class NavButtonLayoutFactory {
|
||||
deviceProfile: DeviceProfile,
|
||||
navButtonsView: NearestTouchFrame,
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?,
|
||||
resources: Resources,
|
||||
@@ -86,7 +86,6 @@ class NavButtonLayoutFactory {
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
@@ -98,7 +97,6 @@ class NavButtonLayoutFactory {
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
@@ -110,7 +108,6 @@ class NavButtonLayoutFactory {
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
@@ -123,7 +120,6 @@ class NavButtonLayoutFactory {
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
@@ -138,7 +134,6 @@ class NavButtonLayoutFactory {
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
@@ -150,7 +145,6 @@ class NavButtonLayoutFactory {
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
@@ -162,7 +156,6 @@ class NavButtonLayoutFactory {
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
|
||||
@@ -22,29 +22,26 @@ import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext
|
||||
import com.android.systemui.shared.rotation.RotationButton
|
||||
|
||||
/** Layoutter for showing gesture navigation on phone screen. No buttons here, no-op container */
|
||||
class PhoneGestureLayoutter(
|
||||
resources: Resources,
|
||||
navBarContainer: LinearLayout,
|
||||
endContextualContainer: ViewGroup,
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?
|
||||
resources: Resources,
|
||||
navBarContainer: LinearLayout,
|
||||
endContextualContainer: ViewGroup,
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?
|
||||
) :
|
||||
AbstractNavButtonLayoutter(
|
||||
resources,
|
||||
navBarContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
AbstractNavButtonLayoutter(
|
||||
resources,
|
||||
navBarContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
|
||||
override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
|
||||
endContextualContainer.removeAllViews()
|
||||
|
||||
@@ -26,35 +26,32 @@ import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext
|
||||
import com.android.systemui.shared.rotation.RotationButton
|
||||
|
||||
open class PhoneLandscapeNavLayoutter(
|
||||
resources: Resources,
|
||||
navBarContainer: LinearLayout,
|
||||
endContextualContainer: ViewGroup,
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?
|
||||
resources: Resources,
|
||||
navBarContainer: LinearLayout,
|
||||
endContextualContainer: ViewGroup,
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?
|
||||
) :
|
||||
AbstractNavButtonLayoutter(
|
||||
resources,
|
||||
navBarContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
resources,
|
||||
navBarContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
|
||||
override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
|
||||
val totalHeight = context.deviceProfile.heightPx
|
||||
val homeButtonHeight = resources.getDimensionPixelSize(
|
||||
R.dimen.taskbar_phone_home_button_size)
|
||||
val roundedCornerContentMargin = resources.getDimensionPixelSize(
|
||||
R.dimen.taskbar_phone_rounded_corner_content_margin)
|
||||
val homeButtonHeight =
|
||||
resources.getDimensionPixelSize(R.dimen.taskbar_phone_home_button_size)
|
||||
val roundedCornerContentMargin =
|
||||
resources.getDimensionPixelSize(R.dimen.taskbar_phone_rounded_corner_content_margin)
|
||||
val contentPadding = resources.getDimensionPixelSize(R.dimen.taskbar_phone_content_padding)
|
||||
val contentWidth = totalHeight - roundedCornerContentMargin * 2 - contentPadding * 2
|
||||
|
||||
@@ -63,13 +60,13 @@ open class PhoneLandscapeNavLayoutter(
|
||||
val sideButtonHeight = contextualButtonHeight * 2
|
||||
val navButtonContainerHeight = contentWidth - contextualButtonHeight * 2
|
||||
|
||||
val navContainerParams = FrameLayout.LayoutParams(
|
||||
MATCH_PARENT, navButtonContainerHeight.toInt())
|
||||
val navContainerParams =
|
||||
FrameLayout.LayoutParams(MATCH_PARENT, navButtonContainerHeight.toInt())
|
||||
navContainerParams.apply {
|
||||
topMargin =
|
||||
(contextualButtonHeight + contentPadding + roundedCornerContentMargin).toInt()
|
||||
(contextualButtonHeight + contentPadding + roundedCornerContentMargin).toInt()
|
||||
bottomMargin =
|
||||
(contextualButtonHeight + contentPadding + roundedCornerContentMargin).toInt()
|
||||
(contextualButtonHeight + contentPadding + roundedCornerContentMargin).toInt()
|
||||
marginEnd = 0
|
||||
marginStart = 0
|
||||
}
|
||||
@@ -84,8 +81,8 @@ open class PhoneLandscapeNavLayoutter(
|
||||
navButtonContainer.gravity = Gravity.CENTER
|
||||
|
||||
// Add the spaces in between the nav buttons
|
||||
val spaceInBetween = (navButtonContainerHeight - homeButtonHeight -
|
||||
sideButtonHeight * 2) / 2.0f
|
||||
val spaceInBetween =
|
||||
(navButtonContainerHeight - homeButtonHeight - sideButtonHeight * 2) / 2.0f
|
||||
for (i in 0 until navButtonContainer.childCount) {
|
||||
val navButton = navButtonContainer.getChildAt(i)
|
||||
val buttonLayoutParams = navButton.layoutParams as LinearLayout.LayoutParams
|
||||
@@ -124,13 +121,23 @@ open class PhoneLandscapeNavLayoutter(
|
||||
endContextualContainer.removeAllViews()
|
||||
startContextualContainer.removeAllViews()
|
||||
|
||||
val roundedCornerContentMargin = resources.getDimensionPixelSize(
|
||||
R.dimen.taskbar_phone_rounded_corner_content_margin)
|
||||
val roundedCornerContentMargin =
|
||||
resources.getDimensionPixelSize(R.dimen.taskbar_phone_rounded_corner_content_margin)
|
||||
val contentPadding = resources.getDimensionPixelSize(R.dimen.taskbar_phone_content_padding)
|
||||
repositionContextualContainer(startContextualContainer, buttonSize,
|
||||
roundedCornerContentMargin + contentPadding, 0, Gravity.TOP)
|
||||
repositionContextualContainer(endContextualContainer, buttonSize,
|
||||
0, roundedCornerContentMargin + contentPadding, Gravity.BOTTOM)
|
||||
repositionContextualContainer(
|
||||
startContextualContainer,
|
||||
buttonSize,
|
||||
roundedCornerContentMargin + contentPadding,
|
||||
0,
|
||||
Gravity.TOP
|
||||
)
|
||||
repositionContextualContainer(
|
||||
endContextualContainer,
|
||||
buttonSize,
|
||||
0,
|
||||
roundedCornerContentMargin + contentPadding,
|
||||
Gravity.BOTTOM
|
||||
)
|
||||
|
||||
if (imeSwitcher != null) {
|
||||
startContextualContainer.addView(imeSwitcher)
|
||||
@@ -140,16 +147,16 @@ open class PhoneLandscapeNavLayoutter(
|
||||
startContextualContainer.addView(a11yButton)
|
||||
a11yButton.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
if (rotationButton != null) {
|
||||
startContextualContainer.addView(rotationButton.currentView)
|
||||
rotationButton.currentView.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
endContextualContainer.addView(space, MATCH_PARENT, MATCH_PARENT)
|
||||
}
|
||||
|
||||
override fun repositionContextualContainer(contextualContainer: ViewGroup, buttonSize: Int,
|
||||
barAxisMarginTop: Int, barAxisMarginBottom: Int,
|
||||
gravity: Int) {
|
||||
override fun repositionContextualContainer(
|
||||
contextualContainer: ViewGroup,
|
||||
buttonSize: Int,
|
||||
barAxisMarginTop: Int,
|
||||
barAxisMarginBottom: Int,
|
||||
gravity: Int
|
||||
) {
|
||||
val contextualContainerParams = FrameLayout.LayoutParams(MATCH_PARENT, buttonSize)
|
||||
contextualContainerParams.apply {
|
||||
marginStart = 0
|
||||
|
||||
@@ -26,34 +26,32 @@ import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext
|
||||
import com.android.systemui.shared.rotation.RotationButton
|
||||
|
||||
class PhonePortraitNavLayoutter(
|
||||
resources: Resources,
|
||||
navBarContainer: LinearLayout,
|
||||
endContextualContainer: ViewGroup,
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?
|
||||
resources: Resources,
|
||||
navBarContainer: LinearLayout,
|
||||
endContextualContainer: ViewGroup,
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?
|
||||
) :
|
||||
AbstractNavButtonLayoutter(
|
||||
resources,
|
||||
navBarContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
resources,
|
||||
navBarContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
|
||||
override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
|
||||
val totalWidth = context.deviceProfile.widthPx
|
||||
val homeButtonWidth = resources.getDimensionPixelSize(R.dimen.taskbar_phone_home_button_size)
|
||||
val roundedCornerContentMargin = resources.getDimensionPixelSize(
|
||||
R.dimen.taskbar_phone_rounded_corner_content_margin)
|
||||
val homeButtonWidth =
|
||||
resources.getDimensionPixelSize(R.dimen.taskbar_phone_home_button_size)
|
||||
val roundedCornerContentMargin =
|
||||
resources.getDimensionPixelSize(R.dimen.taskbar_phone_rounded_corner_content_margin)
|
||||
val contentPadding = resources.getDimensionPixelSize(R.dimen.taskbar_phone_content_padding)
|
||||
val contentWidth = totalWidth - roundedCornerContentMargin * 2 - contentPadding * 2
|
||||
|
||||
@@ -62,15 +60,18 @@ class PhonePortraitNavLayoutter(
|
||||
val sideButtonWidth = contextualButtonWidth * 2
|
||||
val navButtonContainerWidth = contentWidth - contextualButtonWidth * 2
|
||||
|
||||
val navContainerParams = FrameLayout.LayoutParams(navButtonContainerWidth.toInt(),
|
||||
ViewGroup.LayoutParams.MATCH_PARENT)
|
||||
val navContainerParams =
|
||||
FrameLayout.LayoutParams(
|
||||
navButtonContainerWidth.toInt(),
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
navContainerParams.apply {
|
||||
topMargin = 0
|
||||
bottomMargin = 0
|
||||
marginEnd =
|
||||
(contextualButtonWidth + contentPadding + roundedCornerContentMargin).toInt()
|
||||
(contextualButtonWidth + contentPadding + roundedCornerContentMargin).toInt()
|
||||
marginStart =
|
||||
(contextualButtonWidth + contentPadding + roundedCornerContentMargin).toInt()
|
||||
(contextualButtonWidth + contentPadding + roundedCornerContentMargin).toInt()
|
||||
}
|
||||
|
||||
// Ensure order of buttons is correct
|
||||
@@ -85,8 +86,8 @@ class PhonePortraitNavLayoutter(
|
||||
navButtonContainer.gravity = Gravity.CENTER
|
||||
|
||||
// Add the spaces in between the nav buttons
|
||||
val spaceInBetween = (navButtonContainerWidth - homeButtonWidth -
|
||||
sideButtonWidth * 2) / 2.0f
|
||||
val spaceInBetween =
|
||||
(navButtonContainerWidth - homeButtonWidth - sideButtonWidth * 2) / 2.0f
|
||||
for (i in 0 until navButtonContainer.childCount) {
|
||||
val navButton = navButtonContainer.getChildAt(i)
|
||||
val buttonLayoutParams = navButton.layoutParams as LinearLayout.LayoutParams
|
||||
@@ -114,10 +115,20 @@ class PhonePortraitNavLayoutter(
|
||||
endContextualContainer.removeAllViews()
|
||||
startContextualContainer.removeAllViews()
|
||||
|
||||
repositionContextualContainer(startContextualContainer, contextualButtonWidth.toInt(),
|
||||
roundedCornerContentMargin + contentPadding, 0, Gravity.START)
|
||||
repositionContextualContainer(endContextualContainer, contextualButtonWidth.toInt(), 0,
|
||||
roundedCornerContentMargin + contentPadding, Gravity.END)
|
||||
repositionContextualContainer(
|
||||
startContextualContainer,
|
||||
contextualButtonWidth.toInt(),
|
||||
roundedCornerContentMargin + contentPadding,
|
||||
0,
|
||||
Gravity.START
|
||||
)
|
||||
repositionContextualContainer(
|
||||
endContextualContainer,
|
||||
contextualButtonWidth.toInt(),
|
||||
0,
|
||||
roundedCornerContentMargin + contentPadding,
|
||||
Gravity.END
|
||||
)
|
||||
|
||||
startContextualContainer.addView(space, MATCH_PARENT, MATCH_PARENT)
|
||||
if (imeSwitcher != null) {
|
||||
@@ -128,9 +139,5 @@ class PhonePortraitNavLayoutter(
|
||||
endContextualContainer.addView(a11yButton)
|
||||
a11yButton.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
if (rotationButton != null) {
|
||||
endContextualContainer.addView(rotationButton.currentView)
|
||||
rotationButton.currentView.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
*/
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
*/
|
||||
|
||||
package com.android.launcher3.taskbar.navbutton
|
||||
|
||||
@@ -24,28 +24,25 @@ import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
import com.android.launcher3.R
|
||||
import com.android.systemui.shared.rotation.RotationButton
|
||||
|
||||
class PhoneSeascapeNavLayoutter(
|
||||
resources: Resources,
|
||||
navBarContainer: LinearLayout,
|
||||
endContextualContainer: ViewGroup,
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?
|
||||
resources: Resources,
|
||||
navBarContainer: LinearLayout,
|
||||
endContextualContainer: ViewGroup,
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?
|
||||
) :
|
||||
PhoneLandscapeNavLayoutter(
|
||||
resources,
|
||||
navBarContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
PhoneLandscapeNavLayoutter(
|
||||
resources,
|
||||
navBarContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
|
||||
override fun addThreeButtons() {
|
||||
// Flip ordering of back and recents buttons
|
||||
@@ -58,13 +55,23 @@ class PhoneSeascapeNavLayoutter(
|
||||
endContextualContainer.removeAllViews()
|
||||
startContextualContainer.removeAllViews()
|
||||
|
||||
val roundedCornerContentMargin = resources.getDimensionPixelSize(
|
||||
R.dimen.taskbar_phone_rounded_corner_content_margin)
|
||||
val roundedCornerContentMargin =
|
||||
resources.getDimensionPixelSize(R.dimen.taskbar_phone_rounded_corner_content_margin)
|
||||
val contentPadding = resources.getDimensionPixelSize(R.dimen.taskbar_phone_content_padding)
|
||||
repositionContextualContainer(startContextualContainer, buttonSize,
|
||||
roundedCornerContentMargin + contentPadding, 0, Gravity.TOP)
|
||||
repositionContextualContainer(endContextualContainer, buttonSize, 0,
|
||||
roundedCornerContentMargin + contentPadding, Gravity.BOTTOM)
|
||||
repositionContextualContainer(
|
||||
startContextualContainer,
|
||||
buttonSize,
|
||||
roundedCornerContentMargin + contentPadding,
|
||||
0,
|
||||
Gravity.TOP
|
||||
)
|
||||
repositionContextualContainer(
|
||||
endContextualContainer,
|
||||
buttonSize,
|
||||
0,
|
||||
roundedCornerContentMargin + contentPadding,
|
||||
Gravity.BOTTOM
|
||||
)
|
||||
|
||||
startContextualContainer.addView(space, MATCH_PARENT, MATCH_PARENT)
|
||||
if (imeSwitcher != null) {
|
||||
@@ -75,9 +82,5 @@ class PhoneSeascapeNavLayoutter(
|
||||
endContextualContainer.addView(a11yButton)
|
||||
a11yButton.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
if (rotationButton != null) {
|
||||
endContextualContainer.addView(rotationButton.currentView)
|
||||
rotationButton.currentView.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ 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
|
||||
@@ -39,7 +38,6 @@ class SetupNavLayoutter(
|
||||
endContextualContainer: ViewGroup,
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?
|
||||
) :
|
||||
@@ -49,7 +47,6 @@ class SetupNavLayoutter(
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
@@ -116,9 +113,5 @@ class SetupNavLayoutter(
|
||||
endContextualContainer.addView(a11yButton)
|
||||
a11yButton.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
if (rotationButton != null) {
|
||||
endContextualContainer.addView(rotationButton.currentView)
|
||||
rotationButton.currentView.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext
|
||||
import com.android.systemui.shared.rotation.RotationButton
|
||||
|
||||
/** Layoutter for rendering task bar in large screen, both in 3-button and gesture nav mode. */
|
||||
class TaskbarNavLayoutter(
|
||||
@@ -35,7 +34,6 @@ class TaskbarNavLayoutter(
|
||||
endContextualContainer: ViewGroup,
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?
|
||||
) :
|
||||
@@ -45,7 +43,6 @@ class TaskbarNavLayoutter(
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
@@ -137,10 +134,6 @@ class TaskbarNavLayoutter(
|
||||
endContextualContainer.addView(a11yButton)
|
||||
a11yButton.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
if (rotationButton != null) {
|
||||
endContextualContainer.addView(rotationButton.currentView)
|
||||
rotationButton.currentView.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ import com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATI
|
||||
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_END_CONTEXTUAL_BUTTONS
|
||||
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_END_NAV_BUTTONS
|
||||
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_START_CONTEXTUAL_BUTTONS
|
||||
import com.android.systemui.shared.rotation.RotationButton
|
||||
import java.lang.IllegalStateException
|
||||
import org.junit.Assume.assumeTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@@ -39,10 +37,9 @@ class NavButtonLayoutFactoryTest {
|
||||
private val mockRecentsButton: ImageView = mock()
|
||||
private val mockHomeButton: ImageView = mock()
|
||||
private val mockImeSwitcher: ImageView = mock()
|
||||
private val mockRotationButton: RotationButton = mock()
|
||||
private val mockA11yButton: ImageView = mock()
|
||||
private val mockSpace: Space = mock()
|
||||
private val mockConfiguration: Configuration = mock();
|
||||
private val mockConfiguration: Configuration = mock()
|
||||
|
||||
private var surfaceRotation = Surface.ROTATION_0
|
||||
|
||||
@@ -210,7 +207,6 @@ class NavButtonLayoutFactoryTest {
|
||||
phoneMode = phoneMode,
|
||||
surfaceRotation = surfaceRotation,
|
||||
imeSwitcher = mockImeSwitcher,
|
||||
rotationButton = mockRotationButton,
|
||||
a11yButton = mockA11yButton,
|
||||
space = mockSpace,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user