[automerger] Changed the Task Menu to overlay on top of the task view am: 1b9c3d6fe3

Change-Id: I572cb5fe8801b2374487d489f78f2bf232df7217
This commit is contained in:
Android Build Merger (Role) 2018-06-08 21:25:18 +00:00
commit 184e968628
12 changed files with 265 additions and 91 deletions

View File

@ -13,33 +13,16 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="88.0dp"
android:height="88.0dp"
android:viewportWidth="88.0"
android:viewportHeight="88.0" >
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 32,11
C 32,11 68,11 68,11
76.74,11.06 76.98,12.76 77,21
77.01,25.97 78.50,38.23 73.85,40.98
71.80,42.19 68.35,42 66,42
66,42 22,42 22,42
18.82,41.99 14.87,42.38 12.60,39.69
10.71,37.44 11.01,33.77 11,31
10.99,25.54 9.53,16.08 13.31,12.02
18.07,10.21 26.66,11 32,11 Z
M 32,46
C 32,46 68,46 68,46
76.74,46.06 76.98,47.76 77,56
77.01,60.97 78.50,73.23 73.85,75.98
71.80,77.19 68.35,77 66,77
66,77 22,77 22,77
18.82,76.99 14.87,77.38 12.60,74.69
10.71,72.44 11.01,68.77 11,66
10.99,60.54 9.53,51.08 13.31,47.02
18.07,45.21 26.66,46 32,46 Z"
android:fillColor="@android:color/white" />
</vector>
android:fillColor="@android:color/white"
android:pathData="M18,4v5H6V4H18 M18,2H6C4.9,2,4,2.9,4,4v5c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V4C20,2.9,19.1,2,18,2L18,2z" />
<path
android:fillColor="@android:color/white"
android:pathData="M18,15v5H6v-5H18 M18,13H6c-1.1,0-2,0.9-2,2v5c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2v-5C20,13.9,19.1,13,18,13L18,13z" />
</vector>

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:gravity="bottom">
<!-- Shadow -->
<shape>
<gradient android:angle="270"
android:endColor="@android:color/transparent"
android:startColor="#26000000" />
<size android:height="@dimen/task_card_menu_shadow_height" />
</shape>
</item>
<item android:bottom="@dimen/task_card_menu_shadow_height">
<!-- Background -->
<shape>
<corners
android:topLeftRadius="@dimen/task_corner_radius"
android:topRightRadius="@dimen/task_corner_radius"
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp" />
<solid android:color="?attr/popupColorPrimary" />
</shape>
</item>
</layer-list>

View File

@ -16,21 +16,31 @@
-->
<com.android.quickstep.views.TaskMenuView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/bg_popup_item_width"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"
android:elevation="@dimen/deep_shortcuts_elevation"
android:animateLayoutChanges="true"
android:background="@drawable/task_menu_bg"
android:paddingBottom="@dimen/task_card_menu_shadow_height"
android:orientation="vertical"
android:background="?attr/popupColorPrimary"
android:divider="@drawable/all_apps_divider"
android:showDividers="middle"
android:animateLayoutChanges="true">
<TextView
android:id="@+id/task_icon_and_name"
android:layout_width="match_parent"
android:layout_height="112dp"
android:textSize="14sp"
android:paddingTop="18dp"
android:drawablePadding="8dp"
android:gravity="center_horizontal"/>
android:visibility="invisible">
<TextView
android:id="@+id/task_icon_and_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="@dimen/deep_shortcut_drawable_padding"
android:gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:textSize="12sp"/>
<LinearLayout
android:id="@+id/menu_option_layout"
style="@style/TaskMenu"
android:divider="@drawable/all_apps_divider"
android:showDividers="beginning"
android:paddingStart="@dimen/task_card_menu_horizontal_padding"
android:paddingEnd="@dimen/task_card_menu_horizontal_padding"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.android.quickstep.views.TaskMenuView>

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/TaskMenu.Option"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:paddingTop="@dimen/task_card_menu_option_vertical_padding"
android:paddingBottom="@dimen/task_card_menu_option_vertical_padding"
android:background="?android:attr/selectableItemBackground"
android:theme="@style/PopupItem" >
<View
android:id="@+id/icon"
android:layout_width="@dimen/system_shortcut_icon_size"
android:layout_height="@dimen/system_shortcut_icon_size"
android:layout_marginTop="@dimen/system_shortcut_header_icon_padding"
android:layout_marginBottom="@dimen/deep_shortcut_drawable_padding"
android:layout_gravity="center_horizontal"
android:backgroundTint="?android:attr/textColorTertiary"/>
<TextView
style="@style/BaseIcon"
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/popup_padding_end"
android:textSize="12sp"
android:textColor="?android:attr/textColorPrimary"
android:fontFamily="sans-serif"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal"
android:focusable="false" />
</LinearLayout>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<dimen name="task_card_menu_horizontal_padding">24dp</dimen>
</resources>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<!-- Task Menu layout styles. -->
<style name="TaskMenu">
<item name="android:orientation">horizontal</item>
</style>
<!-- Task Menu Option layout styles. -->
<style name="TaskMenu.Option">
<item name="android:layout_width">0dp</item>
<item name="android:layout_weight">1</item>
</style>
</resources>

View File

@ -18,7 +18,6 @@
<dimen name="task_thumbnail_top_margin">24dp</dimen>
<dimen name="task_thumbnail_icon_size">48dp</dimen>
<dimen name="task_menu_background_radius">12dp</dimen>
<dimen name="task_corner_radius">2dp</dimen>
<dimen name="recents_page_spacing">10dp</dimen>
<dimen name="quickscrub_adjacent_visible_width">20dp</dimen>
@ -41,6 +40,9 @@
<!-- Total space (start + end) between the task card and the edge of the screen
in various configurations -->
<dimen name="task_card_vert_space">40dp</dimen>
<dimen name="task_card_menu_option_vertical_padding">8dp</dimen>
<dimen name="task_card_menu_shadow_height">3dp</dimen>
<dimen name="task_card_menu_horizontal_padding">0dp</dimen>
<dimen name="portrait_task_card_horz_space">136dp</dimen>
<dimen name="landscape_task_card_horz_space">200dp</dimen>
<dimen name="multi_window_task_card_horz_space">100dp</dimen>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<!-- Task Menu layout styles. -->
<style name="TaskMenu">
<item name="android:orientation">vertical</item>
</style>
<!-- Task Menu Option layout styles. -->
<style name="TaskMenu.Option">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
</resources>

View File

@ -16,19 +16,19 @@
package com.android.quickstep.views;
import static com.android.quickstep.views.TaskThumbnailView.DIM_ALPHA;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Outline;
import android.graphics.Point;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewOutlineProvider;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.launcher3.AbstractFloatingView;
@ -37,8 +37,8 @@ import com.android.launcher3.LauncherAnimUtils;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.anim.RoundedRectRevealOutlineProvider;
import com.android.launcher3.shortcuts.DeepShortcutView;
import com.android.launcher3.views.BaseDragLayer;
import com.android.quickstep.TaskSystemShortcut;
import com.android.quickstep.TaskUtils;
@ -58,12 +58,14 @@ public class TaskMenuView extends AbstractFloatingView {
new TaskSystemShortcut.Install(),
};
private static final long OPEN_CLOSE_DURATION = 220;
private static final int REVEAL_OPEN_DURATION = 150;
private static final int REVEAL_CLOSE_DURATION = 100;
private BaseDraggingActivity mActivity;
private TextView mTaskIconAndName;
private AnimatorSet mOpenCloseAnimator;
private TaskView mTaskView;
private LinearLayout mOptionLayout;
public TaskMenuView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
@ -73,20 +75,13 @@ public class TaskMenuView extends AbstractFloatingView {
super(context, attrs, defStyleAttr);
mActivity = BaseDraggingActivity.fromContext(context);
setClipToOutline(true);
setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
float r = getResources().getDimensionPixelSize(R.dimen.task_menu_background_radius);
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), r);
}
});
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mTaskIconAndName = findViewById(R.id.task_icon_and_name);
mOptionLayout = findViewById(R.id.menu_option_layout);
}
@Override
@ -148,6 +143,12 @@ public class TaskMenuView extends AbstractFloatingView {
mTaskIconAndName.setText(TaskUtils.getTitle(getContext(), taskView.getTask()));
mTaskIconAndName.setOnClickListener(v -> close(true));
// Move the icon and text up half an icon size to lay over the TaskView
LinearLayout.LayoutParams params =
(LinearLayout.LayoutParams) mTaskIconAndName.getLayoutParams();
params.topMargin = (int) -getResources().getDimension(R.dimen.task_thumbnail_top_margin);
mTaskIconAndName.setLayoutParams(params);
for (TaskSystemShortcut menuOption : MENU_OPTIONS) {
OnClickListener onClickListener = menuOption.getOnClickListener(mActivity, taskView);
if (onClickListener != null) {
@ -157,21 +158,24 @@ public class TaskMenuView extends AbstractFloatingView {
}
private void addMenuOption(TaskSystemShortcut menuOption, OnClickListener onClickListener) {
DeepShortcutView menuOptionView = (DeepShortcutView) mActivity.getLayoutInflater().inflate(
R.layout.system_shortcut, this, false);
menuOptionView.getIconView().setBackgroundResource(menuOption.iconResId);
menuOptionView.getBubbleText().setText(menuOption.labelResId);
ViewGroup menuOptionView = (ViewGroup) mActivity.getLayoutInflater().inflate(
R.layout.task_view_menu_option, this, false);
menuOptionView.findViewById(R.id.icon).setBackgroundResource(menuOption.iconResId);
((TextView) menuOptionView.findViewById(R.id.text)).setText(menuOption.labelResId);
menuOptionView.setOnClickListener(onClickListener);
addView(menuOptionView);
mOptionLayout.addView(menuOptionView);
}
private void orientAroundTaskView(TaskView taskView) {
measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
mActivity.getDragLayer().getDescendantRectRelativeToSelf(taskView, sTempRect);
Rect insets = mActivity.getDragLayer().getInsets();
int x = sTempRect.left + (sTempRect.width() - getMeasuredWidth()) / 2 - insets.left;
setX(Utilities.isRtl(getResources()) ? -x : x);
setY(sTempRect.top - mTaskIconAndName.getPaddingTop() - insets.top);
BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams();
params.width = sTempRect.width();
setLayoutParams(params);
setX(Utilities.isRtl(getResources()) ? -sTempRect.left : sTempRect.left);
setY(sTempRect.top + getResources().getDimension(R.dimen.task_thumbnail_top_margin)
- insets.top);
}
private void animateOpen() {
@ -188,8 +192,13 @@ public class TaskMenuView extends AbstractFloatingView {
return;
}
mOpenCloseAnimator = LauncherAnimUtils.createAnimatorSet();
mOpenCloseAnimator.play(createOpenCloseOutlineProvider()
.createRevealAnimator(this, closing));
final Animator revealAnimator = createOpenCloseOutlineProvider()
.createRevealAnimator(this, closing);
revealAnimator.setInterpolator(Interpolators.DEACCEL);
mOpenCloseAnimator.play(revealAnimator);
mOpenCloseAnimator.play(ObjectAnimator.ofFloat(mTaskView.getThumbnail(), DIM_ALPHA,
closing ? 0 : TaskView.MAX_PAGE_SCRIM_ALPHA));
mOpenCloseAnimator.addListener(new AnimationSuccessListener() {
@Override
public void onAnimationStart(Animator animation) {
@ -204,8 +213,7 @@ public class TaskMenuView extends AbstractFloatingView {
}
});
mOpenCloseAnimator.play(ObjectAnimator.ofFloat(this, ALPHA, closing ? 0 : 1));
mOpenCloseAnimator.setDuration(OPEN_CLOSE_DURATION);
mOpenCloseAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
mOpenCloseAnimator.setDuration(closing ? REVEAL_CLOSE_DURATION: REVEAL_OPEN_DURATION);
mOpenCloseAnimator.start();
}
@ -215,18 +223,9 @@ public class TaskMenuView extends AbstractFloatingView {
}
private RoundedRectRevealOutlineProvider createOpenCloseOutlineProvider() {
int iconSize = getResources().getDimensionPixelSize(R.dimen.task_thumbnail_icon_size);
float fromRadius = iconSize / 2;
float toRadius = getResources().getDimensionPixelSize(
R.dimen.task_menu_background_radius);
Point iconCenter = new Point(getWidth() / 2, mTaskIconAndName.getPaddingTop() + iconSize / 2);
Rect fromRect = new Rect(iconCenter.x, iconCenter.y, iconCenter.x, iconCenter.y);
float radius = getResources().getDimension(R.dimen.task_corner_radius);
Rect fromRect = new Rect(0, 0, getWidth(), 0);
Rect toRect = new Rect(0, 0, getWidth(), getHeight());
return new RoundedRectRevealOutlineProvider(fromRadius, toRadius, fromRect, toRect) {
@Override
public boolean shouldRemoveElevationDuringAnimation() {
return true;
}
};
return new RoundedRectRevealOutlineProvider(radius, radius, fromRect, toRect);
}
}

View File

@ -29,7 +29,6 @@ import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Shader;
import android.support.v4.graphics.ColorUtils;
import android.util.AttributeSet;
import android.util.FloatProperty;
import android.util.Property;
@ -68,6 +67,19 @@ public class TaskThumbnailView extends View {
}
};
public static final Property<TaskThumbnailView, Float> DIM_ALPHA =
new FloatProperty<TaskThumbnailView>("dimAlpha") {
@Override
public void setValue(TaskThumbnailView thumbnail, float dimAlpha) {
thumbnail.setDimAlpha(dimAlpha);
}
@Override
public Float get(TaskThumbnailView thumbnailView) {
return thumbnailView.mDimAlpha;
}
};
private final float mCornerRadius;
private final BaseActivity mActivity;

View File

@ -71,7 +71,7 @@ public class TaskView extends FrameLayout implements TaskCallbacks, PageCallback
* The alpha of a black scrim on a page in the carousel as it leaves the screen.
* In the resting position of the carousel, the adjacent pages have about half this scrim.
*/
private static final float MAX_PAGE_SCRIM_ALPHA = 0.4f;
public static final float MAX_PAGE_SCRIM_ALPHA = 0.4f;
/**
* How much to scale down pages near the edge of the screen.

View File

@ -16,12 +16,17 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/textColorPrimary" >
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?android:attr/textColorPrimary">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M12,17L12,17c0.55,0,1-0.45,1-1v-4c0-0.55-0.45-1-1-1l0,0c-0.55,0-1,0.45-1,1v4C11,16.55,11.45,17,12,17z M12,2C6.48,
2,2,6.48,2,12s4.48,10,10,10s10-4.48,10-10S17.52,2,12,2z M12,20c-4.41,0-8-3.59-8-8s3.59-8,8-8s8,3.59,8,8S16.41,20,12,20zM12,
9.1L12,9.1c0.61,0,1.1-0.49,1.1-1.1l0,0c0-0.61-0.49-1.1-1.1-1.1l0,0c-0.61,0-1.1,0.49-1.1,1.1l0,0C10.9,8.61,11.39,9.1,12,9.1z"/>
android:fillColor="#FFFFFF"
android:pathData="M 11 7 H 13 V 9 H 11 V 7 Z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M 11 11 H 13 V 17 H 11 V 11 Z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M12,2C6.48,2,2,6.48,2,12c0,5.52,4.48,10,10,10s10-4.48,10-10C22,6.48,17.52,2,12,2z M12,20c-4.41,0-8-3.59-8-8 c0-4.41,3.59-8,8-8s8,3.59,8,8C20,16.41,16.41,20,12,20z" />
</vector>