Fix stale header height being used in scroll to header calculation

- This fixes the inconsistency of how far down is needed to scroll to since
the values used to calculate the header during drawOnScrimWithScaleAndBottomOffset() is faulty.
- Tweaked the row to scroll to when there are tabs vs no tabs. When there are no tabs, its possible the
header gets cut off most of the time hence subtracting by 1 will help this problem.

bug:332543940
Test locally: https://screenshot.googleplex.com/5y4vYiQcnSMKcA6
manual - before: https://drive.google.com/file/d/14Zj_FyO-3bVfXwuxaqgG_DXMELYS5bQn/view?usp=sharing
after with tabs:
after 5x5: https://drive.google.com/file/d/16rjaut6VqBMxG6uLQSnVTLRhUQnAANZ5/view?usp=sharing
after 4x5: https://drive.google.com/file/d/16jCPN8BewwuIQobt0t6tdVouUKpp1CdI/view?usp=sharing
after 4x4: https://drive.google.com/file/d/16VFQb5s6IfrpjRU9PmLlAJWjh1zIo77o/view?usp=sharing
after 3x3: https://drive.google.com/file/d/16VFQb5s6IfrpjRU9PmLlAJWjh1zIo77o/view?usp=sharing
after 2x2: https://drive.google.com/file/d/16N6Myuv9VtXgI1p4sIuV23iupea7jYLQ/view?usp=sharing

after no tabs:
after 5x5: https://drive.google.com/file/d/17H1oF_9fJnrtSqmJJqQyyn4upuM2CsoG/view?usp=sharing
after 4x5: https://drive.google.com/file/d/178Vu3SvnvSPODIfaR0oz6-jPVYDDNMaA/view?usp=sharing
after 4x4: https://drive.google.com/file/d/16yt_5ePPR7kwSrZlo5Sj3x0DqHoQKqYP/view?usp=sharing
after 3x3: https://drive.google.com/file/d/17HqebtHWcEHg-i9AfqHEVdl4YnQhX06P/view?usp=sharing
after 2x2: https://drive.google.com/file/d/17HqebtHWcEHg-i9AfqHEVdl4YnQhX06P/view?usp=sharing

after tablet:
landscape: https://drive.google.com/file/d/16JQGs0A3ifKpgqrpQwIzssrXbH-OC0Ej/view?usp=sharing
portrait: https://drive.google.com/file/d/16LmLnOEB6XkuAkAcgvP2mKHe5QQqG1oh/view?usp=sharing

Flag: ACONFIG com.android.launcher3.Flags.private_space_animation TRUNKFOOD

Change-Id: If8a70cc71e9cff4a7f8d3b648e3e59c414e40ee5
This commit is contained in:
Brandon Dayauon
2024-04-05 08:31:28 -07:00
parent 221117bcfd
commit 5da04b231f
4 changed files with 63 additions and 12 deletions

View File

@@ -191,7 +191,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
private float mBottomSheetAlpha = 1f;
private boolean mForceBottomSheetVisible;
private int mTabsProtectionAlpha;
private float mTotalHeaderProtectionHeight;
@Nullable private AllAppsTransitionController mAllAppsTransitionController;
public ActivityAllAppsContainerView(Context context) {
@@ -778,7 +777,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
protected void updateHeaderScroll(int scrolledOffset) {
float prog1 = Utilities.boundToRange((float) scrolledOffset / mHeaderThreshold, 0f, 1f);
int headerColor = getHeaderColor(prog1);
int tabsAlpha = mHeader.getPeripheralProtectionHeight() == 0 ? 0
int tabsAlpha = mHeader.getPeripheralProtectionHeight(/* expectedHeight */ false) == 0 ? 0
: (int) (Utilities.boundToRange(
(scrolledOffset + mHeader.mSnappedScrolledY) / mHeaderThreshold, 0f, 1f)
* 255);
@@ -1448,15 +1447,13 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
mTmpPath.reset();
mTmpPath.addRoundRect(mTmpRectF, mBottomSheetCornerRadii, Direction.CW);
canvas.drawPath(mTmpPath, mHeaderPaint);
mTotalHeaderProtectionHeight = headerBottomWithScaleOnTablet;
}
} else {
canvas.drawRect(0, 0, canvas.getWidth(), headerBottomWithScaleOnPhone, mHeaderPaint);
mTotalHeaderProtectionHeight = headerBottomWithScaleOnPhone;
}
// If tab exist (such as work profile), extend header with tab height
final int tabsHeight = headerView.getPeripheralProtectionHeight();
final int tabsHeight = headerView.getPeripheralProtectionHeight(/* expectedHeight */ false);
if (mTabsProtectionAlpha > 0 && tabsHeight != 0) {
if (DEBUG_HEADER_PROTECTION) {
mHeaderPaint.setColor(Color.BLUE);
@@ -1482,16 +1479,19 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
right,
tabBottomWithScale,
mHeaderPaint);
mTotalHeaderProtectionHeight = tabBottomWithScale;
}
}
/**
* The height of the header protection is dynamically calculated during the time of drawing the
* header.
* The height of the header protection as if the user scrolled down the app list.
*/
float getHeaderProtectionHeight() {
return mTotalHeaderProtectionHeight;
float headerBottom = getHeaderBottom() - getTranslationY();
if (mUsingTabs) {
return headerBottom + mHeader.getPeripheralProtectionHeight(/* expectedHeight */ true);
} else {
return headerBottom;
}
}
/**
@@ -1515,6 +1515,10 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
return bottom + mHeader.getTop();
}
boolean isUsingTabs() {
return mUsingTabs;
}
/**
* Returns a view that denotes the visible part of all apps container view.
*/