Merge "Revert "launcher: use a different task menu for foldables"" into sc-v2-dev am: 5b4145e34b
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/16199031 Change-Id: I8b9063118660a6d9bd7f6b544096f0c079d4bc03
This commit is contained in:
+5
-4
@@ -258,8 +258,8 @@ android_library {
|
|||||||
"go/quickstep/res",
|
"go/quickstep/res",
|
||||||
],
|
],
|
||||||
static_libs: [
|
static_libs: [
|
||||||
"QuickstepResLib",
|
|
||||||
"Launcher3CommonDepsLib",
|
"Launcher3CommonDepsLib",
|
||||||
|
"QuickstepResLib",
|
||||||
],
|
],
|
||||||
manifest: "quickstep/AndroidManifest-launcher.xml",
|
manifest: "quickstep/AndroidManifest-launcher.xml",
|
||||||
additional_manifests: [
|
additional_manifests: [
|
||||||
@@ -278,15 +278,16 @@ android_library {
|
|||||||
srcs: [
|
srcs: [
|
||||||
":launcher-src-no-build-config",
|
":launcher-src-no-build-config",
|
||||||
],
|
],
|
||||||
resource_dirs: [],
|
resource_dirs: [
|
||||||
|
"quickstep/res",
|
||||||
|
],
|
||||||
libs: [
|
libs: [
|
||||||
"framework-statsd",
|
"framework-statsd",
|
||||||
],
|
],
|
||||||
static_libs: [
|
static_libs: [
|
||||||
"QuickstepResLib",
|
|
||||||
"SystemUI-statsd",
|
"SystemUI-statsd",
|
||||||
"SystemUISharedLib",
|
"SystemUISharedLib",
|
||||||
"Launcher3CommonDepsLib",
|
"Launcher3CommonDepsLib"
|
||||||
],
|
],
|
||||||
manifest: "quickstep/AndroidManifest.xml",
|
manifest: "quickstep/AndroidManifest.xml",
|
||||||
platform_apis: true,
|
platform_apis: true,
|
||||||
|
|||||||
@@ -15,8 +15,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
<solid android:color="?android:attr/colorPrimary"/>
|
||||||
<solid android:color="?androidprv:attr/colorSurface" />
|
<corners android:radius="@dimen/task_menu_item_corner_radius"/>
|
||||||
<corners android:radius="@dimen/task_menu_item_corner_radius" />
|
|
||||||
</shape>
|
</shape>
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
Copyright (C) 2021 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.
|
|
||||||
-->
|
|
||||||
<com.android.quickstep.views.TaskMenuViewWithArrow
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:animateLayoutChanges="true"
|
|
||||||
android:background="@drawable/task_menu_bg"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:visibility="invisible">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/menu_option_layout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:showDividers="middle" />
|
|
||||||
|
|
||||||
</com.android.quickstep.views.TaskMenuViewWithArrow>
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="vertical"
|
||||||
android:paddingTop="@dimen/task_card_menu_option_vertical_padding"
|
android:paddingTop="@dimen/task_card_menu_option_vertical_padding"
|
||||||
android:paddingBottom="@dimen/task_card_menu_option_vertical_padding"
|
android:paddingBottom="@dimen/task_card_menu_option_vertical_padding"
|
||||||
android:background="@drawable/task_menu_item_bg"
|
android:background="@drawable/task_menu_item_bg"
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
<dimen name="task_menu_corner_radius">22dp</dimen>
|
<dimen name="task_menu_corner_radius">22dp</dimen>
|
||||||
<dimen name="task_menu_item_corner_radius">4dp</dimen>
|
<dimen name="task_menu_item_corner_radius">4dp</dimen>
|
||||||
<dimen name="task_menu_spacing">2dp</dimen>
|
<dimen name="task_menu_spacing">2dp</dimen>
|
||||||
<dimen name="task_menu_width_grid">234dp</dimen>
|
<dimen name="task_menu_width_grid">200dp</dimen>
|
||||||
<dimen name="overview_proactive_row_height">48dp</dimen>
|
<dimen name="overview_proactive_row_height">48dp</dimen>
|
||||||
<dimen name="overview_proactive_row_bottom_margin">16dp</dimen>
|
<dimen name="overview_proactive_row_bottom_margin">16dp</dimen>
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
<dimen name="task_menu_vertical_padding">8dp</dimen>
|
<dimen name="task_menu_vertical_padding">8dp</dimen>
|
||||||
<dimen name="task_card_margin">8dp</dimen>
|
<dimen name="task_card_margin">8dp</dimen>
|
||||||
<dimen name="task_card_menu_shadow_height">3dp</dimen>
|
<dimen name="task_card_menu_shadow_height">3dp</dimen>
|
||||||
<dimen name="task_menu_option_start_margin">16dp</dimen>
|
<dimen name="task_menu_option_start_margin">12dp</dimen>
|
||||||
<!-- Copied from framework resource:
|
<!-- Copied from framework resource:
|
||||||
docked_stack_divider_thickness - 2 * docked_stack_divider_insets -->
|
docked_stack_divider_thickness - 2 * docked_stack_divider_insets -->
|
||||||
<dimen name="multi_window_task_divider_size">10dp</dimen>
|
<dimen name="multi_window_task_divider_size">10dp</dimen>
|
||||||
|
|||||||
@@ -270,9 +270,15 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange
|
|||||||
BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams();
|
BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams();
|
||||||
int padding = getResources()
|
int padding = getResources()
|
||||||
.getDimensionPixelSize(R.dimen.task_menu_vertical_padding);
|
.getDimensionPixelSize(R.dimen.task_menu_vertical_padding);
|
||||||
params.width = orientationHandler
|
if (deviceProfile.overviewShowAsGrid) {
|
||||||
.getTaskMenuWidth(taskContainer.getThumbnailView(),
|
// TODO(b/193432925) temporary so it doesn't look terrible on large screen
|
||||||
deviceProfile) - (2 * padding);
|
params.width =
|
||||||
|
getContext().getResources().getDimensionPixelSize(R.dimen.task_menu_width_grid);
|
||||||
|
} else {
|
||||||
|
params.width = orientationHandler
|
||||||
|
.getTaskMenuWidth(taskContainer.getThumbnailView(),
|
||||||
|
deviceProfile) - (2 * padding);
|
||||||
|
}
|
||||||
// Gravity set to Left instead of Start as sTempRect.left measures Left distance not Start
|
// Gravity set to Left instead of Start as sTempRect.left measures Left distance not Start
|
||||||
params.gravity = Gravity.LEFT;
|
params.gravity = Gravity.LEFT;
|
||||||
setLayoutParams(params);
|
setLayoutParams(params);
|
||||||
|
|||||||
@@ -1,150 +1,14 @@
|
|||||||
package com.android.quickstep.views
|
package com.android.quickstep.views
|
||||||
|
|
||||||
import android.animation.AnimatorSet
|
import android.util.Log
|
||||||
import android.animation.ObjectAnimator
|
|
||||||
import android.content.Context
|
|
||||||
import android.graphics.Rect
|
|
||||||
import android.graphics.drawable.ShapeDrawable
|
|
||||||
import android.graphics.drawable.shapes.RectShape
|
|
||||||
import android.util.AttributeSet
|
|
||||||
import android.view.MotionEvent
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.LinearLayout
|
|
||||||
import com.android.launcher3.BaseDraggingActivity
|
|
||||||
import com.android.launcher3.DeviceProfile
|
|
||||||
import com.android.launcher3.R
|
|
||||||
import com.android.launcher3.popup.ArrowPopup
|
|
||||||
import com.android.launcher3.popup.SystemShortcut
|
|
||||||
import com.android.launcher3.util.Themes
|
|
||||||
import com.android.quickstep.TaskOverlayFactory
|
|
||||||
import com.android.quickstep.views.TaskView.TaskIdAttributeContainer
|
|
||||||
|
|
||||||
class TaskMenuViewWithArrow<T : BaseDraggingActivity> : ArrowPopup<T> {
|
// TODO(http://b/193432925)
|
||||||
|
class TaskMenuViewWithArrow {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "TaskMenuViewWithArrow"
|
const val TAG = "TaskMenuViewWithArrow"
|
||||||
|
|
||||||
fun showForTask(taskContainer: TaskIdAttributeContainer): Boolean {
|
fun logSomething() {
|
||||||
val activity = BaseDraggingActivity
|
Log.d(TAG, "It worked!")
|
||||||
.fromContext<BaseDraggingActivity>(taskContainer.taskView.context)
|
|
||||||
val taskMenuViewWithArrow = activity.layoutInflater
|
|
||||||
.inflate(R.layout.task_menu_with_arrow, activity.dragLayer, false) as TaskMenuViewWithArrow<*>
|
|
||||||
|
|
||||||
return taskMenuViewWithArrow.populateAndShowForTask(taskContainer)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(context: Context) : super(context)
|
|
||||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
|
|
||||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
|
|
||||||
|
|
||||||
init {
|
|
||||||
clipToOutline = true
|
|
||||||
}
|
|
||||||
|
|
||||||
private val menuWidth = context.resources.getDimensionPixelSize(R.dimen.task_menu_width_grid)
|
|
||||||
|
|
||||||
private lateinit var taskView: TaskView
|
|
||||||
private lateinit var optionLayout: LinearLayout
|
|
||||||
private lateinit var taskContainer: TaskIdAttributeContainer
|
|
||||||
|
|
||||||
override fun isOfType(type: Int): Boolean = type and TYPE_TASK_MENU != 0
|
|
||||||
|
|
||||||
override fun getTargetObjectLocation(outPos: Rect?) {
|
|
||||||
popupContainer.getDescendantRectRelativeToSelf(taskView.iconView, outPos)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onControllerInterceptTouchEvent(ev: MotionEvent?): Boolean {
|
|
||||||
if (ev?.action == MotionEvent.ACTION_DOWN) {
|
|
||||||
if (!popupContainer.isEventOverView(this, ev)) {
|
|
||||||
close(true)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onFinishInflate() {
|
|
||||||
super.onFinishInflate()
|
|
||||||
optionLayout = findViewById(R.id.menu_option_layout)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun populateAndShowForTask(taskContainer: TaskIdAttributeContainer): Boolean {
|
|
||||||
if (isAttachedToWindow) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
taskView = taskContainer.taskView
|
|
||||||
this.taskContainer = taskContainer
|
|
||||||
if (!populateMenu()) return false
|
|
||||||
show()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @return true if successfully able to populate task view menu, false otherwise
|
|
||||||
*/
|
|
||||||
private fun populateMenu(): Boolean {
|
|
||||||
// Icon may not be loaded
|
|
||||||
if (taskContainer.task.icon == null) return false
|
|
||||||
|
|
||||||
addMenuOptions()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun addMenuOptions() {
|
|
||||||
// Add the options
|
|
||||||
TaskOverlayFactory
|
|
||||||
.getEnabledShortcuts(taskView, mActivityContext.deviceProfile, taskContainer)
|
|
||||||
.forEach { this.addMenuOption(it) }
|
|
||||||
|
|
||||||
// Add the spaces between items
|
|
||||||
val divider = ShapeDrawable(RectShape())
|
|
||||||
divider.paint.color = resources.getColor(android.R.color.transparent)
|
|
||||||
val dividerSpacing = resources.getDimension(R.dimen.task_menu_spacing).toInt()
|
|
||||||
optionLayout.showDividers = SHOW_DIVIDER_MIDDLE
|
|
||||||
|
|
||||||
// Set the orientation, which makes the menu show
|
|
||||||
val recentsView: RecentsView<*, *> = mActivityContext.getOverviewPanel()
|
|
||||||
val orientationHandler = recentsView.pagedOrientationHandler
|
|
||||||
val deviceProfile: DeviceProfile = mActivityContext.deviceProfile
|
|
||||||
orientationHandler.setTaskOptionsMenuLayoutOrientation(
|
|
||||||
deviceProfile,
|
|
||||||
optionLayout,
|
|
||||||
dividerSpacing,
|
|
||||||
divider
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun addMenuOption(menuOption: SystemShortcut<*>) {
|
|
||||||
val menuOptionView = mActivityContext.layoutInflater.inflate(
|
|
||||||
R.layout.task_view_menu_option, this, false
|
|
||||||
) as LinearLayout
|
|
||||||
menuOption.setIconAndLabelFor(
|
|
||||||
menuOptionView.findViewById(R.id.icon),
|
|
||||||
menuOptionView.findViewById(R.id.text)
|
|
||||||
)
|
|
||||||
val lp = menuOptionView.layoutParams as LayoutParams
|
|
||||||
lp.width = menuWidth
|
|
||||||
menuOptionView.setOnClickListener { view: View? -> menuOption.onClick(view) }
|
|
||||||
optionLayout.addView(menuOptionView)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun assignMarginsAndBackgrounds(viewGroup: ViewGroup) {
|
|
||||||
assignMarginsAndBackgrounds(this, Themes.getAttrColor(context, com.android.internal.R.attr.colorSurface))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateOpenAnimation(anim: AnimatorSet) {
|
|
||||||
anim.play(
|
|
||||||
ObjectAnimator.ofFloat(
|
|
||||||
taskContainer.thumbnailView, TaskThumbnailView.DIM_ALPHA,
|
|
||||||
TaskView.MAX_PAGE_SCRIM_ALPHA
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateCloseAnimation(anim: AnimatorSet) {
|
|
||||||
anim.play(
|
|
||||||
ObjectAnimator.ofFloat(taskContainer.thumbnailView, TaskThumbnailView.DIM_ALPHA, 0f)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -824,11 +824,9 @@ public class TaskView extends FrameLayout implements Reusable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean showTaskMenuWithContainer(IconView iconView) {
|
protected boolean showTaskMenuWithContainer(IconView iconView) {
|
||||||
if (mActivity.getDeviceProfile().overviewShowAsGrid) {
|
// TODO(http://b/193432925)
|
||||||
return TaskMenuViewWithArrow.Companion.showForTask(mTaskIdAttributeContainer[0]);
|
if (DEBUG) TaskMenuViewWithArrow.Companion.logSomething();
|
||||||
} else {
|
return TaskMenuView.showForTask(mTaskIdAttributeContainer[0]);
|
||||||
return TaskMenuView.showForTask(mTaskIdAttributeContainer[0]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setIcon(IconView iconView, Drawable icon) {
|
protected void setIcon(IconView iconView, Drawable icon) {
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ public abstract class ArrowPopup<T extends Context & ActivityContext>
|
|||||||
* @param backgroundColor When Color.TRANSPARENT, we get color from {@link #mColorIds}.
|
* @param backgroundColor When Color.TRANSPARENT, we get color from {@link #mColorIds}.
|
||||||
* Otherwise, we will use this color for all child views.
|
* Otherwise, we will use this color for all child views.
|
||||||
*/
|
*/
|
||||||
protected void assignMarginsAndBackgrounds(ViewGroup viewGroup, int backgroundColor) {
|
private void assignMarginsAndBackgrounds(ViewGroup viewGroup, int backgroundColor) {
|
||||||
int[] colors = null;
|
int[] colors = null;
|
||||||
if (backgroundColor == Color.TRANSPARENT) {
|
if (backgroundColor == Color.TRANSPARENT) {
|
||||||
// Lazily get the colors so they match the current wallpaper colors.
|
// Lazily get the colors so they match the current wallpaper colors.
|
||||||
@@ -445,7 +445,7 @@ public abstract class ArrowPopup<T extends Context & ActivityContext>
|
|||||||
animateOpen();
|
animateOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupForDisplay() {
|
private void setupForDisplay() {
|
||||||
setVisibility(View.INVISIBLE);
|
setVisibility(View.INVISIBLE);
|
||||||
mIsOpen = true;
|
mIsOpen = true;
|
||||||
getPopupContainer().addView(this);
|
getPopupContainer().addView(this);
|
||||||
@@ -482,7 +482,7 @@ public abstract class ArrowPopup<T extends Context & ActivityContext>
|
|||||||
mArrow.setVisibility(show && shouldAddArrow() ? VISIBLE : INVISIBLE);
|
mArrow.setVisibility(show && shouldAddArrow() ? VISIBLE : INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addArrow() {
|
private void addArrow() {
|
||||||
getPopupContainer().addView(mArrow);
|
getPopupContainer().addView(mArrow);
|
||||||
mArrow.setX(getX() + getArrowLeft());
|
mArrow.setX(getX() + getArrowLeft());
|
||||||
|
|
||||||
@@ -686,13 +686,12 @@ public abstract class ArrowPopup<T extends Context & ActivityContext>
|
|||||||
return getChildCount() > 0 ? getChildAt(0) : this;
|
return getChildCount() > 0 ? getChildAt(0) : this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void animateOpen() {
|
private void animateOpen() {
|
||||||
setVisibility(View.VISIBLE);
|
setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
mOpenCloseAnimator = getOpenCloseAnimator(true, OPEN_DURATION, OPEN_FADE_START_DELAY,
|
mOpenCloseAnimator = getOpenCloseAnimator(true, OPEN_DURATION, OPEN_FADE_START_DELAY,
|
||||||
OPEN_FADE_DURATION, OPEN_CHILD_FADE_START_DELAY, OPEN_CHILD_FADE_DURATION,
|
OPEN_FADE_DURATION, OPEN_CHILD_FADE_START_DELAY, OPEN_CHILD_FADE_DURATION,
|
||||||
DECELERATED_EASE);
|
DECELERATED_EASE);
|
||||||
onCreateOpenAnimation(mOpenCloseAnimator);
|
|
||||||
mOpenCloseAnimator.addListener(new AnimatorListenerAdapter() {
|
mOpenCloseAnimator.addListener(new AnimatorListenerAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animator animation) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
@@ -785,11 +784,6 @@ public abstract class ArrowPopup<T extends Context & ActivityContext>
|
|||||||
mOpenCloseAnimator.start();
|
mOpenCloseAnimator.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when creating the open transition allowing subclass can add additional animations.
|
|
||||||
*/
|
|
||||||
protected void onCreateOpenAnimation(AnimatorSet anim) { }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when creating the close transition allowing subclass can add additional animations.
|
* Called when creating the close transition allowing subclass can add additional animations.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user