Merge "Putting clear-all button on the right to match design." into nyc-dev

This commit is contained in:
Winson Chung
2016-03-31 21:58:16 +00:00
committed by Android (Google) Code Review
4 changed files with 35 additions and 18 deletions

View File

@@ -18,7 +18,6 @@
android:id="@+id/button" android:id="@+id/button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="start|center_vertical"
android:paddingStart="14dp" android:paddingStart="14dp"
android:paddingEnd="14dp" android:paddingEnd="14dp"
android:paddingTop="12dp" android:paddingTop="12dp"

View File

@@ -23,7 +23,7 @@ import com.android.systemui.recents.views.DropTarget;
/** /**
* This event is sent when a user drags in/out of a drop target. * This event is sent when a user drags in/out of a drop target.
*/ */
public class DragDropTargetChangedEvent extends EventBus.Event { public class DragDropTargetChangedEvent extends EventBus.AnimatedEvent {
// The task that is currently being dragged // The task that is currently being dragged
public final Task task; public final Task task;

View File

@@ -59,7 +59,6 @@ import com.android.systemui.recents.events.activity.HideStackActionButtonEvent;
import com.android.systemui.recents.events.activity.LaunchTaskEvent; import com.android.systemui.recents.events.activity.LaunchTaskEvent;
import com.android.systemui.recents.events.activity.ShowStackActionButtonEvent; import com.android.systemui.recents.events.activity.ShowStackActionButtonEvent;
import com.android.systemui.recents.events.ui.AllTaskViewsDismissedEvent; import com.android.systemui.recents.events.ui.AllTaskViewsDismissedEvent;
import com.android.systemui.recents.events.ui.DeleteTaskDataEvent;
import com.android.systemui.recents.events.ui.DismissAllTaskViewsEvent; import com.android.systemui.recents.events.ui.DismissAllTaskViewsEvent;
import com.android.systemui.recents.events.ui.DraggingInRecentsEndedEvent; import com.android.systemui.recents.events.ui.DraggingInRecentsEndedEvent;
import com.android.systemui.recents.events.ui.DraggingInRecentsEvent; import com.android.systemui.recents.events.ui.DraggingInRecentsEvent;
@@ -344,10 +343,10 @@ public class RecentsView extends FrameLayout {
if (RecentsDebugFlags.Static.EnableStackActionButton) { if (RecentsDebugFlags.Static.EnableStackActionButton) {
// Measure the stack action button within the constraints of the space above the stack // Measure the stack action button within the constraints of the space above the stack
Rect actionButtonRect = mTaskStackView.mLayoutAlgorithm.mStackActionButtonRect; Rect buttonBounds = getStackActionButtonBoundsFromStackLayout();
measureChild(mStackActionButton, measureChild(mStackActionButton,
MeasureSpec.makeMeasureSpec(actionButtonRect.width(), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(buttonBounds.width(), MeasureSpec.AT_MOST),
MeasureSpec.makeMeasureSpec(actionButtonRect.height(), MeasureSpec.AT_MOST)); MeasureSpec.makeMeasureSpec(buttonBounds.height(), MeasureSpec.AT_MOST));
} }
setMeasuredDimension(width, height); setMeasuredDimension(width, height);
@@ -376,16 +375,9 @@ public class RecentsView extends FrameLayout {
if (RecentsDebugFlags.Static.EnableStackActionButton) { if (RecentsDebugFlags.Static.EnableStackActionButton) {
// Layout the stack action button such that its drawable is start-aligned with the // Layout the stack action button such that its drawable is start-aligned with the
// stack, vertically centered in the available space above the stack // stack, vertically centered in the available space above the stack
Rect actionButtonRect = mTaskStackView.mLayoutAlgorithm.mStackActionButtonRect; Rect buttonBounds = getStackActionButtonBoundsFromStackLayout();
int buttonLeft = isLayoutRtl() mStackActionButton.layout(buttonBounds.left, buttonBounds.top, buttonBounds.right,
? actionButtonRect.right + mStackActionButton.getPaddingStart() buttonBounds.bottom);
- mStackActionButton.getMeasuredWidth()
: actionButtonRect.left - mStackActionButton.getPaddingStart();
int buttonTop = actionButtonRect.top +
(actionButtonRect.height() - mStackActionButton.getMeasuredHeight()) / 2;
mStackActionButton.layout(buttonLeft, buttonTop,
buttonLeft + mStackActionButton.getMeasuredWidth(),
buttonTop + mStackActionButton.getMeasuredHeight());
} }
if (mAwaitingFirstLayout) { if (mAwaitingFirstLayout) {
@@ -479,6 +471,17 @@ public class RecentsView extends FrameLayout {
false /* isDefaultDockState */, -1, true /* animateAlpha */, false /* isDefaultDockState */, -1, true /* animateAlpha */,
true /* animateBounds */); true /* animateBounds */);
} }
if (mStackActionButton != null) {
event.addPostAnimationCallback(new Runnable() {
@Override
public void run() {
// Move the clear all button to its new position
Rect buttonBounds = getStackActionButtonBoundsFromStackLayout();
mStackActionButton.setLeftTopRightBottom(buttonBounds.left, buttonBounds.top,
buttonBounds.right, buttonBounds.bottom);
}
});
}
} }
public final void onBusEvent(final DragEndEvent event) { public final void onBusEvent(final DragEndEvent event) {
@@ -735,4 +738,19 @@ public class RecentsView extends FrameLayout {
: Interpolators.ALPHA_IN); : Interpolators.ALPHA_IN);
mBackgroundScrimAnimator.start(); mBackgroundScrimAnimator.start();
} }
/**
* @return the bounds of the stack action button.
*/
private Rect getStackActionButtonBoundsFromStackLayout() {
Rect actionButtonRect = new Rect(mTaskStackView.mLayoutAlgorithm.mStackActionButtonRect);
int left = isLayoutRtl()
? actionButtonRect.left - mStackActionButton.getPaddingLeft()
: actionButtonRect.right + mStackActionButton.getPaddingRight()
- mStackActionButton.getMeasuredWidth();
int top = actionButtonRect.top +
(actionButtonRect.height() - mStackActionButton.getMeasuredHeight()) / 2;
actionButtonRect.offsetTo(left, top);
return actionButtonRect;
}
} }

View File

@@ -267,9 +267,9 @@ public class TaskViewHeader extends FrameLayout
lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL); ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL);
lp.setMarginStart(mHeaderBarHeight); lp.setMarginStart(mHeaderBarHeight);
lp.rightMargin = mMoveTaskButton != null lp.setMarginEnd(mMoveTaskButton != null
? 2 * mHeaderBarHeight ? 2 * mHeaderBarHeight
: mHeaderBarHeight; : mHeaderBarHeight);
title.setLayoutParams(lp); title.setLayoutParams(lp);
if (secondaryButton != null) { if (secondaryButton != null) {
lp = new FrameLayout.LayoutParams(mHeaderBarHeight, mHeaderBarHeight, Gravity.END); lp = new FrameLayout.LayoutParams(mHeaderBarHeight, mHeaderBarHeight, Gravity.END);