Merge "Adjusting Taskbar Icons for larger display size" into 24D1-dev
This commit is contained in:
@@ -32,6 +32,7 @@ import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.DisplayCutout;
|
||||
import android.view.InputDevice;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
@@ -134,7 +135,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
|
||||
int actualMargin = resources.getDimensionPixelSize(R.dimen.taskbar_icon_spacing);
|
||||
int actualIconSize = mActivityContext.getDeviceProfile().taskbarIconSize;
|
||||
if (enableTaskbarPinning()) {
|
||||
if (enableTaskbarPinning() && !mActivityContext.isThreeButtonNav()) {
|
||||
DeviceProfile deviceProfile = mActivityContext.getTransientTaskbarDeviceProfile();
|
||||
actualIconSize = deviceProfile.taskbarIconSize;
|
||||
}
|
||||
@@ -472,6 +473,29 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
iconEnd = centerAlignIconEnd + offset;
|
||||
}
|
||||
|
||||
// Currently, we support only one device with display cutout and we only are concern about
|
||||
// it when the bottom rect is present and non empty
|
||||
DisplayCutout displayCutout = getDisplay().getCutout();
|
||||
if (displayCutout != null && !displayCutout.getBoundingRectBottom().isEmpty()) {
|
||||
Rect cutoutBottomRect = displayCutout.getBoundingRectBottom();
|
||||
// when cutout present at the bottom of screen align taskbar icons to cutout offset
|
||||
// if taskbar icon overlaps with cutout
|
||||
int taskbarIconLeftBound = iconEnd - spaceNeeded;
|
||||
int taskbarIconRightBound = iconEnd;
|
||||
|
||||
boolean doesTaskbarIconsOverlapWithCutout =
|
||||
taskbarIconLeftBound <= cutoutBottomRect.centerX()
|
||||
&& cutoutBottomRect.centerX() <= taskbarIconRightBound;
|
||||
|
||||
if (doesTaskbarIconsOverlapWithCutout) {
|
||||
if (!layoutRtl) {
|
||||
iconEnd = spaceNeeded + cutoutBottomRect.width();
|
||||
} else {
|
||||
iconEnd = right - cutoutBottomRect.width();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sTmpRect.set(mIconLayoutBounds);
|
||||
|
||||
// Layout the children
|
||||
|
||||
@@ -337,11 +337,6 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
|
||||
private void updateTaskbarIconTranslationXForPinning() {
|
||||
View[] iconViews = mTaskbarView.getIconViews();
|
||||
float scale = mTaskbarIconTranslationXForPinning.value;
|
||||
float taskbarCenterX =
|
||||
mTaskbarView.getLeft() + (mTaskbarView.getRight() - mTaskbarView.getLeft()) / 2.0f;
|
||||
|
||||
float finalMarginScale = mapRange(scale, 0f, mTransientIconSize - mPersistentIconSize);
|
||||
|
||||
float transientTaskbarAllAppsOffset = mActivity.getResources().getDimension(
|
||||
mTaskbarView.getAllAppsButtonTranslationXOffset(true));
|
||||
float persistentTaskbarAllAppsOffset = mActivity.getResources().getDimension(
|
||||
@@ -354,6 +349,17 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
|
||||
allAppIconTranslateRange *= -1;
|
||||
}
|
||||
|
||||
if (mActivity.isThreeButtonNav()) {
|
||||
((IconButtonView) mTaskbarView.getAllAppsButtonView())
|
||||
.setTranslationXForTaskbarAllAppsIcon(allAppIconTranslateRange);
|
||||
return;
|
||||
}
|
||||
|
||||
float taskbarCenterX =
|
||||
mTaskbarView.getLeft() + (mTaskbarView.getRight() - mTaskbarView.getLeft()) / 2.0f;
|
||||
|
||||
float finalMarginScale = mapRange(scale, 0f, mTransientIconSize - mPersistentIconSize);
|
||||
|
||||
float halfIconCount = iconViews.length / 2.0f;
|
||||
for (int iconIndex = 0; iconIndex < iconViews.length; iconIndex++) {
|
||||
View iconView = iconViews[iconIndex];
|
||||
|
||||
@@ -28,35 +28,39 @@ 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.
|
||||
*/
|
||||
/** Layoutter for rendering task bar in large screen, both in 3-button and gesture nav mode. */
|
||||
class TaskbarNavLayoutter(
|
||||
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?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space?
|
||||
) :
|
||||
AbstractNavButtonLayoutter(
|
||||
resources,
|
||||
navBarContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
resources,
|
||||
navBarContainer,
|
||||
endContextualContainer,
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
|
||||
override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
|
||||
// Add spacing after the end of the last nav button
|
||||
var navMarginEnd = resources
|
||||
.getDimension(context.deviceProfile.inv.inlineNavButtonsEndSpacing)
|
||||
.toInt()
|
||||
var navMarginEnd =
|
||||
resources.getDimension(context.deviceProfile.inv.inlineNavButtonsEndSpacing).toInt()
|
||||
|
||||
val cutout = context.display.cutout
|
||||
val bottomRect = cutout?.boundingRectBottom
|
||||
if (bottomRect != null && !bottomRect.isEmpty) {
|
||||
navMarginEnd = bottomRect.width()
|
||||
}
|
||||
|
||||
val contextualWidth = endContextualContainer.width
|
||||
// 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
|
||||
@@ -65,8 +69,11 @@ class TaskbarNavLayoutter(
|
||||
navMarginEnd += resources.getDimensionPixelSize(R.dimen.taskbar_hotseat_nav_spacing) / 2
|
||||
}
|
||||
|
||||
val navButtonParams = FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
||||
val navButtonParams =
|
||||
FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
navButtonParams.apply {
|
||||
gravity = Gravity.END or Gravity.CENTER_VERTICAL
|
||||
marginEnd = navMarginEnd
|
||||
|
||||
Reference in New Issue
Block a user