Merge "NotificationStackScroller: Fix scrollTo for notification groups" into nyc-dev
This commit is contained in:
@@ -1486,6 +1486,13 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
|||||||
updateBackground();
|
updateBackground();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPositionOfChild(ExpandableNotificationRow childRow) {
|
||||||
|
if (mIsSummaryWithChildren) {
|
||||||
|
return mChildrenContainer.getPositionInLinearLayout(childRow);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public void setExpansionLogger(ExpansionLogger logger, String key) {
|
public void setExpansionLogger(ExpansionLogger logger, String key) {
|
||||||
mLogger = logger;
|
mLogger = logger;
|
||||||
mLoggingKey = key;
|
mLoggingKey = key;
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import android.widget.TextView;
|
|||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.internal.logging.MetricsProto;
|
import com.android.internal.logging.MetricsProto;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
|
import com.android.systemui.statusbar.ExpandableView;
|
||||||
import com.android.systemui.statusbar.NotificationData;
|
import com.android.systemui.statusbar.NotificationData;
|
||||||
import com.android.systemui.statusbar.RemoteInputController;
|
import com.android.systemui.statusbar.RemoteInputController;
|
||||||
import com.android.systemui.statusbar.stack.ScrollContainer;
|
import com.android.systemui.statusbar.stack.ScrollContainer;
|
||||||
@@ -284,11 +285,17 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
|
|||||||
|
|
||||||
private void findScrollContainer() {
|
private void findScrollContainer() {
|
||||||
if (mScrollContainer == null) {
|
if (mScrollContainer == null) {
|
||||||
|
mScrollContainerChild = null;
|
||||||
ViewParent p = this;
|
ViewParent p = this;
|
||||||
while (p != null) {
|
while (p != null) {
|
||||||
|
if (mScrollContainerChild == null && p instanceof ExpandableView) {
|
||||||
|
mScrollContainerChild = (View) p;
|
||||||
|
}
|
||||||
if (p.getParent() instanceof ScrollContainer) {
|
if (p.getParent() instanceof ScrollContainer) {
|
||||||
mScrollContainer = (ScrollContainer) p.getParent();
|
mScrollContainer = (ScrollContainer) p.getParent();
|
||||||
mScrollContainerChild = (View) p;
|
if (mScrollContainerChild == null) {
|
||||||
|
mScrollContainerChild = (View) p;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
p = p.getParent();
|
p = p.getParent();
|
||||||
|
|||||||
@@ -677,6 +677,10 @@ public class NotificationChildrenContainer extends ViewGroup {
|
|||||||
mHeaderUtil = new NotificationHeaderUtil(mNotificationParent);
|
mHeaderUtil = new NotificationHeaderUtil(mNotificationParent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ExpandableNotificationRow getNotificationParent() {
|
||||||
|
return mNotificationParent;
|
||||||
|
}
|
||||||
|
|
||||||
public NotificationHeaderView getHeaderView() {
|
public NotificationHeaderView getHeaderView() {
|
||||||
return mNotificationHeader;
|
return mNotificationHeader;
|
||||||
}
|
}
|
||||||
@@ -854,4 +858,23 @@ public class NotificationChildrenContainer extends ViewGroup {
|
|||||||
child.setRemoved();
|
child.setRemoved();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPositionInLinearLayout(View childInGroup) {
|
||||||
|
int position = mNotificationHeaderMargin + mNotificatonTopPadding;
|
||||||
|
|
||||||
|
for (int i = 0; i < mChildren.size(); i++) {
|
||||||
|
ExpandableNotificationRow child = mChildren.get(i);
|
||||||
|
boolean notGone = child.getVisibility() != View.GONE;
|
||||||
|
if (notGone) {
|
||||||
|
position += mDividerHeight;
|
||||||
|
}
|
||||||
|
if (child == childInGroup) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
if (notGone) {
|
||||||
|
position += child.getIntrinsicHeight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -610,9 +610,13 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
ExpandableView expandableView = (ExpandableView) mForcedScroll;
|
ExpandableView expandableView = (ExpandableView) mForcedScroll;
|
||||||
int positionInLinearLayout = getPositionInLinearLayout(expandableView);
|
int positionInLinearLayout = getPositionInLinearLayout(expandableView);
|
||||||
int targetScroll = targetScrollForView(expandableView, positionInLinearLayout);
|
int targetScroll = targetScrollForView(expandableView, positionInLinearLayout);
|
||||||
|
int outOfViewScroll = positionInLinearLayout + expandableView.getIntrinsicHeight();
|
||||||
|
|
||||||
targetScroll = Math.max(0, Math.min(targetScroll, getScrollRange()));
|
targetScroll = Math.max(0, Math.min(targetScroll, getScrollRange()));
|
||||||
if (mOwnScrollY < targetScroll || positionInLinearLayout < mOwnScrollY) {
|
|
||||||
|
// Only apply the scroll if we're scrolling the view upwards, or the view is so far up
|
||||||
|
// that it is not visible anymore.
|
||||||
|
if (mOwnScrollY < targetScroll || outOfViewScroll < mOwnScrollY) {
|
||||||
mOwnScrollY = targetScroll;
|
mOwnScrollY = targetScroll;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1034,9 +1038,13 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
@Override
|
@Override
|
||||||
public boolean scrollTo(View v) {
|
public boolean scrollTo(View v) {
|
||||||
ExpandableView expandableView = (ExpandableView) v;
|
ExpandableView expandableView = (ExpandableView) v;
|
||||||
int targetScroll = targetScrollForView(expandableView, getPositionInLinearLayout(v));
|
int positionInLinearLayout = getPositionInLinearLayout(v);
|
||||||
|
int targetScroll = targetScrollForView(expandableView, positionInLinearLayout);
|
||||||
|
int outOfViewScroll = positionInLinearLayout + expandableView.getIntrinsicHeight();
|
||||||
|
|
||||||
if (mOwnScrollY < targetScroll) {
|
// Only apply the scroll if we're scrolling the view upwards, or the view is so far up
|
||||||
|
// that it is not visible anymore.
|
||||||
|
if (mOwnScrollY < targetScroll || outOfViewScroll < mOwnScrollY) {
|
||||||
mScroller.startScroll(mScrollX, mOwnScrollY, 0, targetScroll - mOwnScrollY);
|
mScroller.startScroll(mScrollX, mOwnScrollY, 0, targetScroll - mOwnScrollY);
|
||||||
mDontReportNextOverScroll = true;
|
mDontReportNextOverScroll = true;
|
||||||
postInvalidateOnAnimation();
|
postInvalidateOnAnimation();
|
||||||
@@ -1064,6 +1072,10 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
// animating away. To work around that we'll wait until things have settled.
|
// animating away. To work around that we'll wait until things have settled.
|
||||||
removeCallbacks(mReclamp);
|
removeCallbacks(mReclamp);
|
||||||
postDelayed(mReclamp, 50);
|
postDelayed(mReclamp, 50);
|
||||||
|
} else if (mForcedScroll != null) {
|
||||||
|
// The scroll was requested before we got the actual inset - in case we need
|
||||||
|
// to scroll up some more do so now.
|
||||||
|
scrollTo(mForcedScroll);
|
||||||
}
|
}
|
||||||
return insets;
|
return insets;
|
||||||
}
|
}
|
||||||
@@ -2363,7 +2375,15 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
return view.getHeight();
|
return view.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getPositionInLinearLayout(View requestedChild) {
|
private int getPositionInLinearLayout(View requestedView) {
|
||||||
|
ExpandableNotificationRow childInGroup = null;
|
||||||
|
ExpandableNotificationRow requestedRow = null;
|
||||||
|
if (isChildInGroup(requestedView)) {
|
||||||
|
// We're asking for a child in a group. Calculate the position of the parent first,
|
||||||
|
// then within the parent.
|
||||||
|
childInGroup = (ExpandableNotificationRow) requestedView;
|
||||||
|
requestedView = requestedRow = childInGroup.getNotificationParent();
|
||||||
|
}
|
||||||
int position = 0;
|
int position = 0;
|
||||||
float previousIncreasedAmount = 0.0f;
|
float previousIncreasedAmount = 0.0f;
|
||||||
for (int i = 0; i < getChildCount(); i++) {
|
for (int i = 0; i < getChildCount(); i++) {
|
||||||
@@ -2379,7 +2399,10 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
}
|
}
|
||||||
previousIncreasedAmount = increasedPaddingAmount;
|
previousIncreasedAmount = increasedPaddingAmount;
|
||||||
}
|
}
|
||||||
if (child == requestedChild) {
|
if (child == requestedView) {
|
||||||
|
if (requestedRow != null) {
|
||||||
|
position += requestedRow.getPositionOfChild(childInGroup);
|
||||||
|
}
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
if (notGone) {
|
if (notGone) {
|
||||||
|
|||||||
Reference in New Issue
Block a user