Merge "Change TaskIconMenu to lay out vertically" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
127714094a
@@ -16,7 +16,7 @@
|
||||
-->
|
||||
<com.android.quickstep.views.TaskMenuView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:animateLayoutChanges="true"
|
||||
android:background="@drawable/task_menu_bg"
|
||||
@@ -35,12 +35,10 @@
|
||||
|
||||
<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"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:divider="@drawable/all_apps_divider"
|
||||
android:showDividers="beginning" />
|
||||
|
||||
</com.android.quickstep.views.TaskMenuView>
|
||||
@@ -16,9 +16,8 @@
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@style/TaskMenu.Option"
|
||||
android:layout_width="wrap_content"
|
||||
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"
|
||||
@@ -29,22 +28,19 @@
|
||||
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_marginStart="@dimen/task_menu_option_start_margin"
|
||||
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_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/popup_padding_end"
|
||||
android:layout_marginStart="@dimen/task_menu_option_start_margin"
|
||||
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>
|
||||
|
||||
@@ -15,7 +15,5 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<dimen name="task_card_menu_horizontal_padding">24dp</dimen>
|
||||
|
||||
<dimen name="overview_task_margin">8dp</dimen>
|
||||
</resources>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?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>
|
||||
@@ -67,7 +67,7 @@
|
||||
in various configurations -->
|
||||
<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="task_menu_option_start_margin">12dp</dimen>
|
||||
<!-- Copied from framework resource:
|
||||
docked_stack_divider_thickness - 2 * docked_stack_divider_insets -->
|
||||
<dimen name="multi_window_task_divider_size">10dp</dimen>
|
||||
|
||||
@@ -15,16 +15,6 @@
|
||||
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>
|
||||
|
||||
<style name="TextAppearance.GestureTutorial"
|
||||
parent="android:TextAppearance.Material.Body1" />
|
||||
|
||||
@@ -201,12 +201,13 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange
|
||||
}
|
||||
|
||||
private void addMenuOption(SystemShortcut menuOption) {
|
||||
ViewGroup menuOptionView = (ViewGroup) mActivity.getLayoutInflater().inflate(
|
||||
LinearLayout menuOptionView = (LinearLayout) mActivity.getLayoutInflater().inflate(
|
||||
R.layout.task_view_menu_option, this, false);
|
||||
menuOption.setIconAndLabelFor(
|
||||
menuOptionView.findViewById(R.id.icon), menuOptionView.findViewById(R.id.text));
|
||||
LayoutParams lp = (LayoutParams) menuOptionView.getLayoutParams();
|
||||
mTaskView.getPagedOrientationHandler().setLayoutParamsForTaskMenuOptionItem(lp);
|
||||
mTaskView.getPagedOrientationHandler().setLayoutParamsForTaskMenuOptionItem(lp,
|
||||
menuOptionView, mActivity.getDeviceProfile());
|
||||
menuOptionView.setEnabled(menuOption.isEnabled());
|
||||
menuOptionView.setAlpha(menuOption.isEnabled() ? 1 : 0.5f);
|
||||
menuOptionView.setOnClickListener(view -> {
|
||||
@@ -228,16 +229,15 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange
|
||||
mActivity.getDragLayer().getDescendantRectRelativeToSelf(taskView, sTempRect);
|
||||
Rect insets = mActivity.getDragLayer().getInsets();
|
||||
BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams();
|
||||
// TODO(b/186583656) Move the entire menu to the center/make smaller than thumbnail width
|
||||
params.width = orientationHandler.getTaskMenuWidth(taskView.getThumbnail());
|
||||
// Gravity set to Left instead of Start as sTempRect.left measures Left distance not Start
|
||||
params.gravity = Gravity.LEFT;
|
||||
setLayoutParams(params);
|
||||
setScaleX(taskView.getScaleX());
|
||||
setScaleY(taskView.getScaleY());
|
||||
boolean canActivityRotate = taskView.getRecentsView()
|
||||
.mOrientationState.isRecentsActivityRotationAllowed();
|
||||
mOptionLayout.setOrientation(orientationHandler
|
||||
.getTaskMenuLayoutOrientation(canActivityRotate, mOptionLayout));
|
||||
orientationHandler.setTaskMenuLayoutOrientation(
|
||||
mActivity.getDeviceProfile(), mOptionLayout);
|
||||
setPosition(sTempRect.left - insets.left, sTempRect.top - insets.top, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
import androidx.core.os.BuildCompat;
|
||||
@@ -752,6 +753,16 @@ public final class Utilities {
|
||||
ColorUtils.blendARGB(0, color, tintAmount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets start margin on the provided {@param view} to be {@param margin}.
|
||||
* Assumes {@param view} is a child of {@link LinearLayout}
|
||||
*/
|
||||
public static void setStartMarginForView(View view, int margin) {
|
||||
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) view.getLayoutParams();
|
||||
lp.setMarginStart(margin);
|
||||
view.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
private static class FixedSizeEmptyDrawable extends ColorDrawable {
|
||||
|
||||
private final int mSize;
|
||||
|
||||
@@ -254,16 +254,21 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTaskMenuLayoutOrientation(boolean canRecentsActivityRotate,
|
||||
public void setTaskMenuLayoutOrientation(DeviceProfile deviceProfile,
|
||||
LinearLayout taskMenuLayout) {
|
||||
return LinearLayout.HORIZONTAL;
|
||||
taskMenuLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp) {
|
||||
public void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp,
|
||||
LinearLayout viewGroup, DeviceProfile deviceProfile) {
|
||||
// Phone fake landscape
|
||||
viewGroup.setOrientation(LinearLayout.VERTICAL);
|
||||
lp.width = 0;
|
||||
lp.height = WRAP_CONTENT;
|
||||
lp.weight = 1;
|
||||
Utilities.setStartMarginForView(viewGroup.findViewById(R.id.text), 0);
|
||||
Utilities.setStartMarginForView(viewGroup.findViewById(R.id.icon), 0);
|
||||
}
|
||||
|
||||
/* ---------- The following are only used by TaskViewTouchHandler. ---------- */
|
||||
|
||||
@@ -101,8 +101,9 @@ public interface PagedOrientationHandler {
|
||||
float getTaskMenuX(float x, View thumbnailView, int overScroll);
|
||||
float getTaskMenuY(float y, View thumbnailView, int overScroll);
|
||||
int getTaskMenuWidth(View view);
|
||||
int getTaskMenuLayoutOrientation(boolean canRecentsActivityRotate, LinearLayout taskMenuLayout);
|
||||
void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp);
|
||||
void setTaskMenuLayoutOrientation(DeviceProfile deviceProfile, LinearLayout taskMenuLayout);
|
||||
void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp,
|
||||
LinearLayout viewGroup, DeviceProfile deviceProfile);
|
||||
int getDistanceToBottomOfRect(DeviceProfile dp, Rect rect);
|
||||
List<SplitPositionOption> getSplitPositionOptions(DeviceProfile dp);
|
||||
FloatProperty getSplitSelectTaskOffset(FloatProperty primary, FloatProperty secondary,
|
||||
|
||||
@@ -253,14 +253,34 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTaskMenuLayoutOrientation(boolean canRecentsActivityRotate,
|
||||
public void setTaskMenuLayoutOrientation(DeviceProfile deviceProfile,
|
||||
LinearLayout taskMenuLayout) {
|
||||
return canRecentsActivityRotate ? taskMenuLayout.getOrientation() : LinearLayout.VERTICAL;
|
||||
if (deviceProfile.isLandscape && !deviceProfile.isTablet) {
|
||||
// Phone landscape
|
||||
taskMenuLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||
} else {
|
||||
// Phone Portrait, LargeScreen Landscape/Portrait
|
||||
taskMenuLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp) {
|
||||
// no-op, defaults are fine
|
||||
public void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp,
|
||||
LinearLayout viewGroup, DeviceProfile deviceProfile) {
|
||||
if (deviceProfile.isLandscape && !deviceProfile.isTablet) {
|
||||
// Phone landscape
|
||||
viewGroup.setOrientation(LinearLayout.VERTICAL);
|
||||
lp.width = 0;
|
||||
lp.weight = 1;
|
||||
Utilities.setStartMarginForView(viewGroup.findViewById(R.id.text), 0);
|
||||
Utilities.setStartMarginForView(viewGroup.findViewById(R.id.icon), 0);
|
||||
} else {
|
||||
// Phone Portrait, LargeScreen Landscape/Portrait
|
||||
viewGroup.setOrientation(LinearLayout.HORIZONTAL);
|
||||
lp.width = LinearLayout.LayoutParams.WRAP_CONTENT;
|
||||
}
|
||||
|
||||
lp.height = LinearLayout.LayoutParams.WRAP_CONTENT;
|
||||
}
|
||||
|
||||
/* ---------- The following are only used by TaskViewTouchHandler. ---------- */
|
||||
|
||||
Reference in New Issue
Block a user