summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
author Andrey Epin <ayepin@google.com> 2022-11-28 11:54:33 -0800
committer Andrey Epin <ayepin@google.com> 2022-12-28 18:50:25 +0000
commitf9a8f40c27f1b0188cbfa9b20af44ea04614cf93 (patch)
treea6f9c93cdc5d039ac248854b1292471ea90300ca /java/src
parentebe0fe5ad0528f2f6e90ee24e3041054fac1ed22 (diff)
ResolverDrawerLayout: unify mCollapsibleHeight calculation.
(an ag/20419209 cherry-pick) mCollapsibleHeight was calculated differently in two places: in onMeasure() and in setCollapsibleHeightReserved() methods. The latter is updated to use the same logic as the former. There was two particular aspects of the onMeasure() logic: - It calculated mCollapsibleHeight and mUncollapsibleHeight so the sum of the two yields the total children height; - mCollapsibleHeight was calculated based on the total childrens height. Thus a correct mCollapsibleHeight calculation in the setCollapsibleHeightReserved() method would need to know the total children height and maintain the invariant that mCollapsibleHeight + mUncollapsibleHeight would yield that height. Instead of deriving the total children height as a sum of mCollapsibleHeight + mUncollapsibleHeight, a new field, mHeightUsed, is added to store the total children height and mUncollapsibleHeight is deleted. This way we don’t have to also update mUncollapsibleHeight in setCollapsibleHeightReserved() plus mUncollapsibleHeight was always used as a part of the sum mCollapsibleHeight + mUncollapsibleHeight so it is a natural replacement. Flag: IntentResolver package entirely behind the CHOOSER_UNBUNDLED which is in teamfood Bug: 256869196 Test: reproduce the issue in a separate test environment, make sure that the change acutally fixes it Test: manual Chooser smoke test Test: manual Resolver smoke test Test: atest FrameworksCoreTests:ChooserActivityTest Test: atest FrameworksCoreTests:ResolverActivityTest Change-Id: Id169bd1c4b9f7270d75baab2e5e3841b76ab00e6
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/intentresolver/widget/ResolverDrawerLayout.java37
1 files changed, 18 insertions, 19 deletions
diff --git a/java/src/com/android/intentresolver/widget/ResolverDrawerLayout.java b/java/src/com/android/intentresolver/widget/ResolverDrawerLayout.java
index a2c5afc6..f5e20510 100644
--- a/java/src/com/android/intentresolver/widget/ResolverDrawerLayout.java
+++ b/java/src/com/android/intentresolver/widget/ResolverDrawerLayout.java
@@ -89,8 +89,8 @@ public class ResolverDrawerLayout extends ViewGroup {
* out of sync due to frequently dropping fractions of a pixel from '(int) dy' casts.
*/
private float mDragRemainder = 0.0f;
+ private int mHeightUsed;
private int mCollapsibleHeight;
- private int mUncollapsibleHeight;
private int mAlwaysShowHeight;
/**
@@ -244,9 +244,7 @@ public class ResolverDrawerLayout extends ViewGroup {
mLastTouchY -= dReserved;
}
- final int oldCollapsibleHeight = mCollapsibleHeight;
- mCollapsibleHeight = Math.min(mCollapsibleHeight, getMaxCollapsedHeight());
-
+ final int oldCollapsibleHeight = updateCollapsibleHeight();
if (updateCollapseOffset(oldCollapsibleHeight, !isDragging())) {
return;
}
@@ -485,7 +483,7 @@ public class ResolverDrawerLayout extends ViewGroup {
} else {
if (isDismissable()
&& yvel > 0 && mCollapseOffset > mCollapsibleHeight) {
- smoothScrollTo(mCollapsibleHeight + mUncollapsibleHeight, yvel);
+ smoothScrollTo(mHeightUsed, yvel);
mDismissOnScrollerFinished = true;
} else {
scrollNestedScrollableChildBackToTop();
@@ -575,8 +573,7 @@ public class ResolverDrawerLayout extends ViewGroup {
return 0;
}
- final float newPos = Math.max(0, Math.min(mCollapseOffset + dy,
- mCollapsibleHeight + mUncollapsibleHeight));
+ final float newPos = Math.max(0, Math.min(mCollapseOffset + dy, mHeightUsed));
if (newPos != mCollapseOffset) {
dy = newPos - mCollapseOffset;
@@ -855,7 +852,7 @@ public class ResolverDrawerLayout extends ViewGroup {
} else {
if (isDismissable()
&& velocityY < 0 && mCollapseOffset > mCollapsibleHeight) {
- smoothScrollTo(mCollapsibleHeight + mUncollapsibleHeight, velocityY);
+ smoothScrollTo(mHeightUsed, velocityY);
mDismissOnScrollerFinished = true;
} else {
smoothScrollTo(velocityY > 0 ? 0 : mCollapsibleHeight, velocityY);
@@ -883,9 +880,8 @@ public class ResolverDrawerLayout extends ViewGroup {
}
break;
case AccessibilityNodeInfo.ACTION_DISMISS:
- if ((mCollapseOffset < mCollapsibleHeight + mUncollapsibleHeight)
- && isDismissable()) {
- smoothScrollTo(mCollapsibleHeight + mUncollapsibleHeight, 0);
+ if ((mCollapseOffset < mHeightUsed) && isDismissable()) {
+ smoothScrollTo(mHeightUsed, 0);
mDismissOnScrollerFinished = true;
return true;
}
@@ -923,7 +919,7 @@ public class ResolverDrawerLayout extends ViewGroup {
info.addAction(AccessibilityAction.ACTION_SCROLL_DOWN);
info.setScrollable(true);
}
- if ((mCollapseOffset < mCollapsibleHeight + mUncollapsibleHeight)
+ if ((mCollapseOffset < mHeightUsed)
&& ((mCollapseOffset < mCollapsibleHeight) || isDismissable())) {
info.addAction(AccessibilityAction.ACTION_SCROLL_UP);
info.setScrollable(true);
@@ -931,7 +927,7 @@ public class ResolverDrawerLayout extends ViewGroup {
if (mCollapseOffset < mCollapsibleHeight) {
info.addAction(AccessibilityAction.ACTION_COLLAPSE);
}
- if (mCollapseOffset < mCollapsibleHeight + mUncollapsibleHeight && isDismissable()) {
+ if (mCollapseOffset < mHeightUsed && isDismissable()) {
info.addAction(AccessibilityAction.ACTION_DISMISS);
}
}
@@ -1022,22 +1018,25 @@ public class ResolverDrawerLayout extends ViewGroup {
}
}
- final int oldCollapsibleHeight = mCollapsibleHeight;
- mCollapsibleHeight = Math.max(0,
- heightUsed - mAlwaysShowHeight - getMaxCollapsedHeight());
- mUncollapsibleHeight = heightUsed - mCollapsibleHeight;
-
+ mHeightUsed = heightUsed;
+ int oldCollapsibleHeight = updateCollapsibleHeight();
updateCollapseOffset(oldCollapsibleHeight, !isDragging());
if (getShowAtTop()) {
mTopOffset = 0;
} else {
- mTopOffset = Math.max(0, heightSize - heightUsed) + (int) mCollapseOffset;
+ mTopOffset = Math.max(0, heightSize - mHeightUsed) + (int) mCollapseOffset;
}
setMeasuredDimension(sourceWidth, heightSize);
}
+ private int updateCollapsibleHeight() {
+ final int oldCollapsibleHeight = mCollapsibleHeight;
+ mCollapsibleHeight = Math.max(0, mHeightUsed - mAlwaysShowHeight - getMaxCollapsedHeight());
+ return oldCollapsibleHeight;
+ }
+
/**
* @return The space reserved by views with 'alwaysShow=true'
*/