Merge "Tweaking layout to make two-task stacks to closer match design." into nyc-dev am: 8a9100caae

am: 0786743a94

* commit '0786743a94e67b9c505d49738325bae6c8cddf9a':
  Tweaking layout to make two-task stacks to closer match design.

Change-Id: I040c56f34972dffe6cfdd290f3e93da725137450
This commit is contained in:
Winson Chung
2016-05-28 00:18:58 +00:00
committed by android-build-merger
2 changed files with 63 additions and 17 deletions

View File

@@ -404,7 +404,7 @@ public class TaskStackLayoutAlgorithm {
* Sets the system insets. * Sets the system insets.
*/ */
public boolean setSystemInsets(Rect systemInsets) { public boolean setSystemInsets(Rect systemInsets) {
boolean changed = mSystemInsets.equals(systemInsets); boolean changed = !mSystemInsets.equals(systemInsets);
mSystemInsets.set(systemInsets); mSystemInsets.set(systemInsets);
return changed; return changed;
} }
@@ -583,11 +583,25 @@ public class TaskStackLayoutAlgorithm {
if (getInitialFocusState() == STATE_UNFOCUSED && mNumStackTasks > 1) { if (getInitialFocusState() == STATE_UNFOCUSED && mNumStackTasks > 1) {
if (ignoreScrollToFront || (!launchState.launchedWithAltTab && !scrollToFront)) { if (ignoreScrollToFront || (!launchState.launchedWithAltTab && !scrollToFront)) {
// Set the initial scroll to the predefined state (which differs from the stack) // Set the initial scroll to the predefined state (which differs from the stack)
float [] initialNormX = new float[] { float [] initialNormX = null;
getNormalizedXFromUnfocusedY(mSystemInsets.bottom + mInitialBottomOffset, float minBottomTaskNormX = getNormalizedXFromUnfocusedY(mSystemInsets.bottom +
FROM_BOTTOM), mInitialBottomOffset, FROM_BOTTOM);
float maxBottomTaskNormX = getNormalizedXFromUnfocusedY(mFocusedTopPeekHeight +
mTaskRect.height() - mMinMargin, FROM_TOP);
if (mNumStackTasks <= 2) {
// For small stacks, position the tasks so that they are top aligned to under
// the action button, but ensure that it is at least a certain offset from the
// bottom of the stack
initialNormX = new float[] {
Math.min(maxBottomTaskNormX, minBottomTaskNormX),
getNormalizedXFromUnfocusedY(mFocusedTopPeekHeight, FROM_TOP)
};
} else {
initialNormX = new float[] {
minBottomTaskNormX,
getNormalizedXFromUnfocusedY(mInitialTopOffset, FROM_TOP) getNormalizedXFromUnfocusedY(mInitialTopOffset, FROM_TOP)
}; };
}
mUnfocusedRange.offset(0f); mUnfocusedRange.offset(0f);
List<Task> tasks = stack.getStackTasks(); List<Task> tasks = stack.getStackTasks();
@@ -881,14 +895,7 @@ public class TaskStackLayoutAlgorithm {
TaskViewTransform frontTransform, boolean ignoreSingleTaskCase, boolean forceUpdate) { TaskViewTransform frontTransform, boolean ignoreSingleTaskCase, boolean forceUpdate) {
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
// Compute the focused and unfocused offset // Ensure that the task is in range
float boundedStackScroll = Utilities.clamp(stackScroll, mMinScrollP, mMaxScrollP);
mUnfocusedRange.offset(boundedStackScroll);
mFocusedRange.offset(boundedStackScroll);
float boundedScrollUnfocusedRangeX = mUnfocusedRange.getNormalizedX(taskProgress);
float boundedScrollFocusedRangeX = mFocusedRange.getNormalizedX(taskProgress);
float boundedScrollUnfocusedNonOverrideRangeX =
mUnfocusedRange.getNormalizedX(nonOverrideTaskProgress);
mUnfocusedRange.offset(stackScroll); mUnfocusedRange.offset(stackScroll);
mFocusedRange.offset(stackScroll); mFocusedRange.offset(stackScroll);
boolean unfocusedVisible = mUnfocusedRange.isInRange(taskProgress); boolean unfocusedVisible = mUnfocusedRange.isInRange(taskProgress);
@@ -900,9 +907,30 @@ public class TaskStackLayoutAlgorithm {
return; return;
} }
// Map the absolute task progress to the normalized x at the stack scroll. We use this to
// calculate positions along the curve.
mUnfocusedRange.offset(stackScroll);
mFocusedRange.offset(stackScroll);
float unfocusedRangeX = mUnfocusedRange.getNormalizedX(taskProgress); float unfocusedRangeX = mUnfocusedRange.getNormalizedX(taskProgress);
float focusedRangeX = mFocusedRange.getNormalizedX(taskProgress); float focusedRangeX = mFocusedRange.getNormalizedX(taskProgress);
// Map the absolute task progress to the normalized x at the bounded stack scroll. We use
// this to calculate bounded properties, like translationZ and outline alpha.
float boundedStackScroll = Utilities.clamp(stackScroll, mMinScrollP, mMaxScrollP);
mUnfocusedRange.offset(boundedStackScroll);
mFocusedRange.offset(boundedStackScroll);
float boundedScrollUnfocusedRangeX = mUnfocusedRange.getNormalizedX(taskProgress);
float boundedScrollUnfocusedNonOverrideRangeX =
mUnfocusedRange.getNormalizedX(nonOverrideTaskProgress);
// Map the absolute task progress to the normalized x at the upper bounded stack scroll.
// We use this to calculate the dim, which is bounded only on one end.
float lowerBoundedStackScroll = Utilities.clamp(stackScroll, -Float.MAX_VALUE, mMaxScrollP);
mUnfocusedRange.offset(lowerBoundedStackScroll);
mFocusedRange.offset(lowerBoundedStackScroll);
float lowerBoundedUnfocusedRangeX = mUnfocusedRange.getNormalizedX(taskProgress);
float lowerBoundedFocusedRangeX = mFocusedRange.getNormalizedX(taskProgress);
int x = (mStackRect.width() - mTaskRect.width()) / 2; int x = (mStackRect.width() - mTaskRect.width()) / 2;
int y; int y;
float z; float z;
@@ -917,7 +945,8 @@ public class TaskStackLayoutAlgorithm {
y = centerYOffset + getYForDeltaP(tmpP, 0); y = centerYOffset + getYForDeltaP(tmpP, 0);
z = mMaxTranslationZ; z = mMaxTranslationZ;
dimAlpha = 0f; dimAlpha = 0f;
viewOutlineAlpha = (OUTLINE_ALPHA_MIN_VALUE + OUTLINE_ALPHA_MAX_VALUE) / 2f; viewOutlineAlpha = OUTLINE_ALPHA_MIN_VALUE +
(OUTLINE_ALPHA_MAX_VALUE - OUTLINE_ALPHA_MIN_VALUE) / 2f;
} else { } else {
// Otherwise, update the task to the stack layout // Otherwise, update the task to the stack layout
@@ -926,9 +955,22 @@ public class TaskStackLayoutAlgorithm {
int focusedY = (int) ((1f - mFocusedCurveInterpolator.getInterpolation( int focusedY = (int) ((1f - mFocusedCurveInterpolator.getInterpolation(
focusedRangeX)) * mStackRect.height()); focusedRangeX)) * mStackRect.height());
float unfocusedDim = mUnfocusedDimCurveInterpolator.getInterpolation( float unfocusedDim = mUnfocusedDimCurveInterpolator.getInterpolation(
boundedScrollUnfocusedRangeX); lowerBoundedUnfocusedRangeX);
float focusedDim = mFocusedDimCurveInterpolator.getInterpolation( float focusedDim = mFocusedDimCurveInterpolator.getInterpolation(
boundedScrollFocusedRangeX); lowerBoundedFocusedRangeX);
// Special case, because we override the initial task positions differently for small
// stacks, we clamp the dim to 0 in the initial position, and then only modulate the
// dim when the task is scrolled back towards the top of the screen
if (mNumStackTasks <= 2 && nonOverrideTaskProgress == 0f) {
if (boundedScrollUnfocusedRangeX >= 0.5f) {
unfocusedDim = 0f;
} else {
float offset = mUnfocusedDimCurveInterpolator.getInterpolation(0.5f);
unfocusedDim -= offset;
unfocusedDim *= MAX_DIM / (MAX_DIM - offset);
}
}
y = (mStackRect.top - mTaskRect.top) + y = (mStackRect.top - mTaskRect.top) +
(int) Utilities.mapRange(focusState, unfocusedY, focusedY); (int) Utilities.mapRange(focusState, unfocusedY, focusedY);

View File

@@ -1996,6 +1996,10 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
if (event.fromDeviceOrientationChange) { if (event.fromDeviceOrientationChange) {
mDisplayOrientation = Utilities.getAppConfiguration(mContext).orientation; mDisplayOrientation = Utilities.getAppConfiguration(mContext).orientation;
mDisplayRect = Recents.getSystemServices().getDisplayRect(); mDisplayRect = Recents.getSystemServices().getDisplayRect();
// Always stop the scroller, otherwise, we may continue setting the stack scroll to the
// wrong bounds in the new layout
mStackScroller.stopScroller();
} }
reloadOnConfigurationChange(); reloadOnConfigurationChange();