Loading packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java +12 −2 Original line number Diff line number Diff line Loading @@ -110,6 +110,10 @@ public class TaskStackLayoutAlgorithm { public static final float STATE_FOCUSED = 1f; public static final float STATE_UNFOCUSED = 0f; public interface TaskStackLayoutAlgorithmCallbacks { void onFocusStateChanged(float prevFocusState, float curFocusState); } /** * The various stack/freeform states. */ Loading Loading @@ -210,6 +214,7 @@ public class TaskStackLayoutAlgorithm { Context mContext; private Interpolator mLinearOutSlowInInterpolator; private StackState mState = StackState.SPLIT; private TaskStackLayoutAlgorithmCallbacks mCb; // The task bounds (untransformed) for layout. This rect is anchored at mTaskRoot. public Rect mTaskRect = new Rect(); Loading Loading @@ -279,8 +284,10 @@ public class TaskStackLayoutAlgorithm { TaskViewTransform mBackOfStackTransform = new TaskViewTransform(); TaskViewTransform mFrontOfStackTransform = new TaskViewTransform(); public TaskStackLayoutAlgorithm(Context context) { public TaskStackLayoutAlgorithm(Context context, TaskStackLayoutAlgorithmCallbacks cb) { Resources res = context.getResources(); mContext = context; mCb = cb; mFocusedRange = new Range(res.getFloat(R.integer.recents_layout_focused_range_min), res.getFloat(R.integer.recents_layout_focused_range_max)); Loading @@ -291,7 +298,6 @@ public class TaskStackLayoutAlgorithm { mMinTranslationZ = res.getDimensionPixelSize(R.dimen.recents_task_view_z_min); mMaxTranslationZ = res.getDimensionPixelSize(R.dimen.recents_task_view_z_max); mContext = context; mFreeformLayoutAlgorithm = new FreeformWorkspaceLayoutAlgorithm(context); mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, com.android.internal.R.interpolator.linear_out_slow_in); Loading @@ -315,8 +321,12 @@ public class TaskStackLayoutAlgorithm { * Sets the focused state. */ public void setFocusState(float focusState) { float prevFocusState = mFocusState; mFocusState = focusState; updateFrontBackTransforms(); if (mCb != null) { mCb.onFocusStateChanged(prevFocusState, focusState); } } /** Loading packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +20 −10 Original line number Diff line number Diff line Loading @@ -88,6 +88,7 @@ import static android.app.ActivityManager.StackId.INVALID_STACK_ID; /* The visual representation of a task stack view */ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCallbacks, TaskView.TaskViewCallbacks, TaskStackViewScroller.TaskStackViewScrollerCallbacks, TaskStackLayoutAlgorithm.TaskStackLayoutAlgorithmCallbacks, ViewPool.ViewPoolConsumer<TaskView, Task> { private final static String KEY_SAVED_STATE_SUPER = "saved_instance_state_super"; Loading Loading @@ -192,9 +193,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal setStack(stack); mViewPool = new ViewPool<>(context, this); mInflater = LayoutInflater.from(context); mLayoutAlgorithm = new TaskStackLayoutAlgorithm(context); mStackScroller = new TaskStackViewScroller(context, mLayoutAlgorithm); mStackScroller.setCallbacks(this); mLayoutAlgorithm = new TaskStackLayoutAlgorithm(context, this); mStackScroller = new TaskStackViewScroller(context, this, mLayoutAlgorithm); mTouchHandler = new TaskStackViewTouchHandler(context, this, mStackScroller); mAnimationHelper = new TaskStackAnimationHelper(context, this); mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, Loading Loading @@ -623,7 +623,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal */ void relayoutTaskViewsOnNextFrame(TaskViewAnimation animation) { mDeferredTaskViewLayoutAnimation = animation; postInvalidateOnAnimation(); invalidate(); } /** Loading Loading @@ -852,17 +852,17 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal }; if (scrollToTask) { // Cancel any running enter animations at this point when we scroll or change focus if (!mEnterAnimationComplete) { cancelAllTaskViewAnimations(); } // TODO: Center the newly focused task view, only if not freeform float newScroll = mLayoutAlgorithm.getStackScrollForTask(newFocusedTask); if (Float.compare(newScroll, mStackScroller.getStackScroll()) != 0) { mStackScroller.animateScroll(mStackScroller.getStackScroll(), newScroll, focusTaskRunnable); willScroll = true; // Cancel any running enter animations at this point when we scroll as well if (!mEnterAnimationComplete) { cancelAllTaskViewAnimations(); } } else { focusTaskRunnable.run(); } Loading Loading @@ -902,7 +902,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal */ public void setRelativeFocusedTask(boolean forward, boolean stackTasksOnly, boolean animated, boolean cancelWindowAnimations) { setRelativeFocusedTask(forward, stackTasksOnly, animated, false, false); setRelativeFocusedTask(forward, stackTasksOnly, animated, cancelWindowAnimations, false); } /** Loading Loading @@ -1448,6 +1448,16 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal } } /**** TaskStackLayoutAlgorithm.TaskStackLayoutAlgorithmCallbacks ****/ @Override public void onFocusStateChanged(float prevFocusState, float curFocusState) { if (mDeferredTaskViewLayoutAnimation == null) { mUIDozeTrigger.poke(); relayoutTaskViewsOnNextFrame(TaskViewAnimation.IMMEDIATE); } } /**** TaskStackViewScroller.TaskStackViewScrollerCallbacks ****/ @Override Loading packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java +24 −7 Original line number Diff line number Diff line Loading @@ -20,7 +20,9 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.content.Context; import android.util.FloatProperty; import android.util.Log; import android.util.Property; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; import android.widget.OverScroller; Loading @@ -37,6 +39,24 @@ public class TaskStackViewScroller { void onScrollChanged(float prevScroll, float curScroll, TaskViewAnimation animation); } /** * A Property wrapper around the <code>stackScroll</code> functionality handled by the * {@link #setStackScroll(float)} and * {@link #getStackScroll()} methods. */ private static final Property<TaskStackViewScroller, Float> STACK_SCROLL = new FloatProperty<TaskStackViewScroller>("stackScroll") { @Override public void setValue(TaskStackViewScroller object, float value) { object.setStackScroll(value); } @Override public Float get(TaskStackViewScroller object) { return object.getStackScroll(); } }; Context mContext; TaskStackLayoutAlgorithm mLayoutAlgorithm; TaskStackViewScrollerCallbacks mCb; Loading @@ -51,8 +71,10 @@ public class TaskStackViewScroller { private Interpolator mLinearOutSlowInInterpolator; public TaskStackViewScroller(Context context, TaskStackLayoutAlgorithm layoutAlgorithm) { public TaskStackViewScroller(Context context, TaskStackViewScrollerCallbacks cb, TaskStackLayoutAlgorithm layoutAlgorithm) { mContext = context; mCb = cb; mScroller = new OverScroller(context); mLayoutAlgorithm = layoutAlgorithm; mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, Loading @@ -64,11 +86,6 @@ public class TaskStackViewScroller { mStackScrollP = 0f; } /** Sets the callbacks */ void setCallbacks(TaskStackViewScrollerCallbacks cb) { mCb = cb; } /** Gets the current stack scroll */ public float getStackScroll() { return mStackScrollP; Loading Loading @@ -172,7 +189,7 @@ public class TaskStackViewScroller { stopBoundScrollAnimation(); mFinalAnimatedScroll = newScroll; mScrollAnimator = ObjectAnimator.ofFloat(this, "stackScroll", curScroll, newScroll); mScrollAnimator = ObjectAnimator.ofFloat(this, STACK_SCROLL, curScroll, newScroll); mScrollAnimator.setDuration(mContext.getResources().getInteger( R.integer.recents_animate_task_stack_scroll_duration)); mScrollAnimator.setInterpolator(mLinearOutSlowInInterpolator); Loading Loading
packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java +12 −2 Original line number Diff line number Diff line Loading @@ -110,6 +110,10 @@ public class TaskStackLayoutAlgorithm { public static final float STATE_FOCUSED = 1f; public static final float STATE_UNFOCUSED = 0f; public interface TaskStackLayoutAlgorithmCallbacks { void onFocusStateChanged(float prevFocusState, float curFocusState); } /** * The various stack/freeform states. */ Loading Loading @@ -210,6 +214,7 @@ public class TaskStackLayoutAlgorithm { Context mContext; private Interpolator mLinearOutSlowInInterpolator; private StackState mState = StackState.SPLIT; private TaskStackLayoutAlgorithmCallbacks mCb; // The task bounds (untransformed) for layout. This rect is anchored at mTaskRoot. public Rect mTaskRect = new Rect(); Loading Loading @@ -279,8 +284,10 @@ public class TaskStackLayoutAlgorithm { TaskViewTransform mBackOfStackTransform = new TaskViewTransform(); TaskViewTransform mFrontOfStackTransform = new TaskViewTransform(); public TaskStackLayoutAlgorithm(Context context) { public TaskStackLayoutAlgorithm(Context context, TaskStackLayoutAlgorithmCallbacks cb) { Resources res = context.getResources(); mContext = context; mCb = cb; mFocusedRange = new Range(res.getFloat(R.integer.recents_layout_focused_range_min), res.getFloat(R.integer.recents_layout_focused_range_max)); Loading @@ -291,7 +298,6 @@ public class TaskStackLayoutAlgorithm { mMinTranslationZ = res.getDimensionPixelSize(R.dimen.recents_task_view_z_min); mMaxTranslationZ = res.getDimensionPixelSize(R.dimen.recents_task_view_z_max); mContext = context; mFreeformLayoutAlgorithm = new FreeformWorkspaceLayoutAlgorithm(context); mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, com.android.internal.R.interpolator.linear_out_slow_in); Loading @@ -315,8 +321,12 @@ public class TaskStackLayoutAlgorithm { * Sets the focused state. */ public void setFocusState(float focusState) { float prevFocusState = mFocusState; mFocusState = focusState; updateFrontBackTransforms(); if (mCb != null) { mCb.onFocusStateChanged(prevFocusState, focusState); } } /** Loading
packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +20 −10 Original line number Diff line number Diff line Loading @@ -88,6 +88,7 @@ import static android.app.ActivityManager.StackId.INVALID_STACK_ID; /* The visual representation of a task stack view */ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCallbacks, TaskView.TaskViewCallbacks, TaskStackViewScroller.TaskStackViewScrollerCallbacks, TaskStackLayoutAlgorithm.TaskStackLayoutAlgorithmCallbacks, ViewPool.ViewPoolConsumer<TaskView, Task> { private final static String KEY_SAVED_STATE_SUPER = "saved_instance_state_super"; Loading Loading @@ -192,9 +193,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal setStack(stack); mViewPool = new ViewPool<>(context, this); mInflater = LayoutInflater.from(context); mLayoutAlgorithm = new TaskStackLayoutAlgorithm(context); mStackScroller = new TaskStackViewScroller(context, mLayoutAlgorithm); mStackScroller.setCallbacks(this); mLayoutAlgorithm = new TaskStackLayoutAlgorithm(context, this); mStackScroller = new TaskStackViewScroller(context, this, mLayoutAlgorithm); mTouchHandler = new TaskStackViewTouchHandler(context, this, mStackScroller); mAnimationHelper = new TaskStackAnimationHelper(context, this); mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, Loading Loading @@ -623,7 +623,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal */ void relayoutTaskViewsOnNextFrame(TaskViewAnimation animation) { mDeferredTaskViewLayoutAnimation = animation; postInvalidateOnAnimation(); invalidate(); } /** Loading Loading @@ -852,17 +852,17 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal }; if (scrollToTask) { // Cancel any running enter animations at this point when we scroll or change focus if (!mEnterAnimationComplete) { cancelAllTaskViewAnimations(); } // TODO: Center the newly focused task view, only if not freeform float newScroll = mLayoutAlgorithm.getStackScrollForTask(newFocusedTask); if (Float.compare(newScroll, mStackScroller.getStackScroll()) != 0) { mStackScroller.animateScroll(mStackScroller.getStackScroll(), newScroll, focusTaskRunnable); willScroll = true; // Cancel any running enter animations at this point when we scroll as well if (!mEnterAnimationComplete) { cancelAllTaskViewAnimations(); } } else { focusTaskRunnable.run(); } Loading Loading @@ -902,7 +902,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal */ public void setRelativeFocusedTask(boolean forward, boolean stackTasksOnly, boolean animated, boolean cancelWindowAnimations) { setRelativeFocusedTask(forward, stackTasksOnly, animated, false, false); setRelativeFocusedTask(forward, stackTasksOnly, animated, cancelWindowAnimations, false); } /** Loading Loading @@ -1448,6 +1448,16 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal } } /**** TaskStackLayoutAlgorithm.TaskStackLayoutAlgorithmCallbacks ****/ @Override public void onFocusStateChanged(float prevFocusState, float curFocusState) { if (mDeferredTaskViewLayoutAnimation == null) { mUIDozeTrigger.poke(); relayoutTaskViewsOnNextFrame(TaskViewAnimation.IMMEDIATE); } } /**** TaskStackViewScroller.TaskStackViewScrollerCallbacks ****/ @Override Loading
packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java +24 −7 Original line number Diff line number Diff line Loading @@ -20,7 +20,9 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.content.Context; import android.util.FloatProperty; import android.util.Log; import android.util.Property; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; import android.widget.OverScroller; Loading @@ -37,6 +39,24 @@ public class TaskStackViewScroller { void onScrollChanged(float prevScroll, float curScroll, TaskViewAnimation animation); } /** * A Property wrapper around the <code>stackScroll</code> functionality handled by the * {@link #setStackScroll(float)} and * {@link #getStackScroll()} methods. */ private static final Property<TaskStackViewScroller, Float> STACK_SCROLL = new FloatProperty<TaskStackViewScroller>("stackScroll") { @Override public void setValue(TaskStackViewScroller object, float value) { object.setStackScroll(value); } @Override public Float get(TaskStackViewScroller object) { return object.getStackScroll(); } }; Context mContext; TaskStackLayoutAlgorithm mLayoutAlgorithm; TaskStackViewScrollerCallbacks mCb; Loading @@ -51,8 +71,10 @@ public class TaskStackViewScroller { private Interpolator mLinearOutSlowInInterpolator; public TaskStackViewScroller(Context context, TaskStackLayoutAlgorithm layoutAlgorithm) { public TaskStackViewScroller(Context context, TaskStackViewScrollerCallbacks cb, TaskStackLayoutAlgorithm layoutAlgorithm) { mContext = context; mCb = cb; mScroller = new OverScroller(context); mLayoutAlgorithm = layoutAlgorithm; mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, Loading @@ -64,11 +86,6 @@ public class TaskStackViewScroller { mStackScrollP = 0f; } /** Sets the callbacks */ void setCallbacks(TaskStackViewScrollerCallbacks cb) { mCb = cb; } /** Gets the current stack scroll */ public float getStackScroll() { return mStackScrollP; Loading Loading @@ -172,7 +189,7 @@ public class TaskStackViewScroller { stopBoundScrollAnimation(); mFinalAnimatedScroll = newScroll; mScrollAnimator = ObjectAnimator.ofFloat(this, "stackScroll", curScroll, newScroll); mScrollAnimator = ObjectAnimator.ofFloat(this, STACK_SCROLL, curScroll, newScroll); mScrollAnimator.setDuration(mContext.getResources().getInteger( R.integer.recents_animate_task_stack_scroll_duration)); mScrollAnimator.setInterpolator(mLinearOutSlowInInterpolator); Loading