Overview - Adds first pass at making landscape layout real.

Adds dynamic sizing to margins around task view, also creates space in the
overview actions view in landscape to make space for the proactive chips if
needed.

Bug: 182529089
Test: Local build and run on two devices
Change-Id: I447de3564a3249ede4e8e8a4d3e5d1c177f6be61
This commit is contained in:
Zak Cohen
2021-03-24 14:45:48 +00:00
committed by Alex Chau
parent 59230c3cdd
commit 334efebaba
13 changed files with 87 additions and 57 deletions
@@ -22,5 +22,4 @@
android:layout_height="wrap_content"
android:text="@string/recents_clear_all"
android:textColor="?attr/workspaceTextColor"
android:textSize="14sp"
android:translationY="@dimen/task_thumbnail_half_top_margin" />
android:textSize="14sp" />
+3 -2
View File
@@ -13,6 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- NOTE! don't add dimensions for margins / paddings / sizes that change per orientation to this
file, they need to be loaded at runtime. -->
<com.android.quickstep.views.TaskView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
@@ -24,8 +26,7 @@
<com.android.quickstep.views.TaskThumbnailView
android:id="@+id/snapshot"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/task_thumbnail_top_margin"/>
android:layout_height="match_parent"/>
<com.android.quickstep.views.IconView
android:id="@+id/icon"
+2
View File
@@ -16,4 +16,6 @@
-->
<resources>
<dimen name="task_card_menu_horizontal_padding">24dp</dimen>
<dimen name="overview_task_margin">8dp</dimen>
</resources>
-4
View File
@@ -15,11 +15,7 @@
-->
<resources>
<dimen name="task_thumbnail_top_margin">80dp</dimen>
<dimen name="task_thumbnail_half_top_margin">40dp</dimen>
<dimen name="task_thumbnail_icon_size">48dp</dimen>
<dimen name="task_icon_top_margin">16dp</dimen>
<!-- For screens without rounded corners -->
<dimen name="task_corner_radius_small">2dp</dimen>
@@ -201,14 +201,18 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
PagedOrientationHandler orientedState) {
Resources res = context.getResources();
int taskMargin = res.getDimensionPixelSize(R.dimen.overview_task_margin);
int taskIconAndMargin = res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_size)
+ res.getDimensionPixelSize(R.dimen.task_icon_top_margin);
int proactiveRowAndMargin = res.getDimensionPixelSize(R.dimen.overview_proactive_row_height)
+ res.getDimensionPixelSize(R.dimen.overview_proactive_row_bottom_margin);
int taskMargin = dp.overviewTaskMarginPx;
int proactiveRowAndMargin;
if (dp.isVerticalBarLayout()) {
// In Vertical Bar Layout the proactive row doesn't have its own space, it's inside
// the actions row.
proactiveRowAndMargin = 0;
} else {
proactiveRowAndMargin = res.getDimensionPixelSize(R.dimen.overview_proactive_row_height)
+ res.getDimensionPixelSize(R.dimen.overview_proactive_row_bottom_margin);
}
calculateTaskSizeInternal(context, dp,
taskIconAndMargin + taskMargin,
dp.overviewTaskThumbnailTopMarginPx,
proactiveRowAndMargin + getOverviewActionsHeight(context) + taskMargin,
res.getDimensionPixelSize(R.dimen.overview_minimum_next_prev_size) + taskMargin,
outRect);
@@ -267,13 +271,11 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
* Calculates the modal taskView size for the provided device configuration
*/
public final void calculateModalTaskSize(Context context, DeviceProfile dp, Rect outRect) {
Resources res = context.getResources();
calculateTaskSizeInternal(
context, dp,
res.getDimensionPixelSize(R.dimen.overview_task_margin),
getOverviewActionsHeight(context)
+ res.getDimensionPixelSize(R.dimen.overview_task_margin),
res.getDimensionPixelSize(R.dimen.overview_task_margin),
dp.overviewTaskMarginPx,
getOverviewActionsHeight(context) + dp.overviewTaskMarginPx,
dp.overviewTaskMarginPx,
outRect);
}
@@ -112,7 +112,6 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
private boolean mLayoutValid = false;
private boolean mScrollValid = false;
private int mOrientationStateId;
private final int mTaskThumbnailPadding;
private final int mRowSpacing;
public TaskViewSimulator(Context context, BaseActivityInterface sizeStrategy) {
@@ -125,7 +124,6 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
mOrientationStateId = mOrientationState.getStateId();
Resources resources = context.getResources();
mIsRecentsRtl = mOrientationState.getOrientationHandler().getRecentsRtlSetting(resources);
mTaskThumbnailPadding = (int) resources.getDimension(R.dimen.task_thumbnail_top_margin);
mRowSpacing = (int) resources.getDimension(R.dimen.overview_grid_row_spacing);
}
@@ -314,7 +312,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
final int boxLength = (int) Math.max(taskWidth, taskHeight);
float availableHeight = mGridRect.height();
float rowHeight = (availableHeight - mRowSpacing) / 2;
float gridScale = rowHeight / (boxLength + mTaskThumbnailPadding);
float gridScale = rowHeight / (boxLength + mDp.overviewTaskThumbnailTopMarginPx);
scale = Utilities.mapRange(interpolatedGridProgress, 1f, gridScale);
mMatrix.postScale(scale, scale, mIsRecentsRtl ? 0 : taskWidth, 0);
mOrientationState.getOrientationHandler().setSecondary(mMatrix, MATRIX_POST_TRANSLATE,
@@ -331,7 +329,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
taskGridHorizontalDiff = mGridRect.left - taskLeft;
}
float taskGridVerticalDiff =
mGridRect.top + mTaskThumbnailPadding * gridScale - mTaskRect.top;
mGridRect.top + mDp.overviewTaskThumbnailTopMarginPx * gridScale - mTaskRect.top;
mOrientationState.getOrientationHandler().set(mMatrix, MATRIX_POST_TRANSLATE,
Utilities.mapRange(interpolatedGridProgress, 0, taskGridHorizontalDiff));
mOrientationState.getOrientationHandler().setSecondary(mMatrix, MATRIX_POST_TRANSLATE,
@@ -21,6 +21,7 @@ import android.util.AttributeSet;
import android.util.FloatProperty;
import android.widget.Button;
import com.android.launcher3.statemanager.StatefulActivity;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.quickstep.views.RecentsView.PageCallbacks;
import com.android.quickstep.views.RecentsView.ScrollState;
@@ -40,13 +41,13 @@ public class ClearAllButton extends Button implements PageCallbacks {
}
};
private final StatefulActivity mActivity;
private float mScrollAlpha = 1;
private float mContentAlpha = 1;
private float mVisibilityAlpha = 1;
private float mGridProgress = 1;
private boolean mIsRtl;
private final float mOriginalTranslationX, mOriginalTranslationY;
private float mNormalTranslationPrimary;
private float mGridTranslationPrimary;
@@ -55,8 +56,7 @@ public class ClearAllButton extends Button implements PageCallbacks {
public ClearAllButton(Context context, AttributeSet attrs) {
super(context, attrs);
mIsRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
mOriginalTranslationX = getTranslationX();
mOriginalTranslationY = getTranslationY();
mActivity = StatefulActivity.fromContext(context);
}
@Override
@@ -114,7 +114,7 @@ public class ClearAllButton extends Button implements PageCallbacks {
mNormalTranslationPrimary = mIsRtl ? (mScrollOffset - shift) : (mScrollOffset + shift);
applyPrimaryTranslation();
orientationHandler.getSecondaryViewTranslate().set(this,
orientationHandler.getSecondaryValue(mOriginalTranslationX, mOriginalTranslationY));
orientationHandler.getSecondaryValue(0f, getOriginalTranslationY()));
mScrollAlpha = 1 - shift / orientationSize;
updateAlpha();
}
@@ -166,4 +166,11 @@ public class ClearAllButton extends Button implements PageCallbacks {
private float getGridTrans(float endTranslation) {
return mGridProgress > 0 ? endTranslation : 0;
}
/**
* Get the Y translation that is set in the original layout position, before scrolling.
*/
private float getOriginalTranslationY() {
return mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx / 2.0f;
}
}
@@ -29,6 +29,7 @@ import android.widget.FrameLayout;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
import com.android.launcher3.R;
import com.android.launcher3.util.MultiValueAlpha;
@@ -144,6 +145,7 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
public void setInsets(Rect insets) {
mInsets.set(insets);
updateVerticalMargin(SysUINavigationMode.getMode(getContext()));
updateHorizontalPadding();
}
public void updateHiddenFlags(@ActionsHiddenFlags int visibilityFlags, boolean enable) {
@@ -187,6 +189,10 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
return mMultiValueAlpha.getProperty(INDEX_FULLSCREEN_ALPHA);
}
private void updateHorizontalPadding() {
setPadding(mInsets.left, 0, mInsets.right, 0);
}
/** Updates vertical margins for different navigation mode or configuration changes. */
public void updateVerticalMargin(Mode mode) {
LayoutParams actionParams = (LayoutParams) findViewById(
@@ -196,6 +202,13 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
getBottomVerticalMargin(mode));
}
/**
* Set the device profile for this view to draw with.
*/
public void setDp(DeviceProfile dp) {
requestLayout();
}
protected int getBottomVerticalMargin(Mode mode) {
int bottomMargin;
int orientation = getResources().getConfiguration().orientation;
@@ -310,7 +310,6 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
protected final T mActivity;
private final float mFastFlingVelocity;
private final RecentsModel mModel;
private final int mTaskTopMargin;
private final int mRowSpacing;
private final ClearAllButton mClearAllButton;
private final Rect mClearAllButtonDeadZoneRect = new Rect();
@@ -529,8 +528,6 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
mIsRtl = mOrientationHandler.getRecentsRtlSetting(getResources());
setLayoutDirection(mIsRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
mTaskTopMargin = getResources()
.getDimensionPixelSize(R.dimen.task_thumbnail_top_margin);
mRowSpacing = getResources().getDimensionPixelSize(R.dimen.overview_grid_row_spacing);
mSquaredTouchSlop = squaredTouchSlop(context);
@@ -1066,7 +1063,9 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
public void setInsets(Rect insets) {
mInsets.set(insets);
resetPaddingFromTaskSize();
mLiveTileTaskViewSimulator.setDp(mActivity.getDeviceProfile());
DeviceProfile dp = mActivity.getDeviceProfile();
mLiveTileTaskViewSimulator.setDp(dp);
mActionsView.setDp(dp);
}
private void resetPaddingFromTaskSize() {
@@ -1075,7 +1074,7 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
mTaskWidth = mTempRect.width();
mTaskHeight = mTempRect.height();
mTempRect.top -= mTaskTopMargin;
mTempRect.top -= dp.overviewTaskThumbnailTopMarginPx;
setPadding(mTempRect.left - mInsets.left, mTempRect.top - mInsets.top,
dp.widthPx - mInsets.right - mTempRect.right,
dp.heightPx - mInsets.bottom - mTempRect.bottom);
@@ -1602,7 +1601,8 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
final int boxLength = Math.max(mTaskWidth, mTaskHeight);
float availableHeight = mLastComputedGridSize.height();
float rowHeight = (availableHeight - mRowSpacing) / 2;
float gridScale = rowHeight / (boxLength + mTaskTopMargin);
int taskTopMargin = mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx;
float gridScale = rowHeight / (boxLength + taskTopMargin);
int topRowWidth = 0;
int bottomRowWidth = 0;
@@ -1635,7 +1635,7 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
gridTranslations[i] -= taskGridHorizontalDiff;
taskView.setGridOffsetTranslationX(taskGridHorizontalDiff);
float taskGridVerticalDiff = mLastComputedGridSize.top + mTaskTopMargin * gridScale
float taskGridVerticalDiff = mLastComputedGridSize.top + taskTopMargin * gridScale
- mLastComputedTaskSize.top;
// Off-set gap due to task scaling.
@@ -1669,7 +1669,7 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
bottomSet.add(i);
// Move into bottom row.
float heightOffset = (boxLength + mTaskTopMargin) * gridScale + mRowSpacing;
float heightOffset = (boxLength + taskTopMargin) * gridScale + mRowSpacing;
taskView.setGridTranslationY(heightOffset + taskGridVerticalDiff);
// Move horizontally into empty space.
@@ -2485,7 +2485,7 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
if (child == mSplitHiddenTaskView) {
int left = newScroll[i] + getPaddingStart();
int topMargin = mSplitHiddenTaskView.getThumbnailTopMargin();
int topMargin = mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx;
int top = -mSplitHiddenTaskView.getHeight() - locationOnScreen[1];
mSplitHiddenTaskView.layout(left, top,
left + mSplitHiddenTaskView.getWidth(),
@@ -58,7 +58,6 @@ public class TaskMenuView extends AbstractFloatingView {
private static final int REVEAL_OPEN_DURATION = 150;
private static final int REVEAL_CLOSE_DURATION = 100;
private final float mThumbnailTopMargin;
private BaseDraggingActivity mActivity;
private TextView mTaskName;
private AnimatorSet mOpenCloseAnimator;
@@ -73,7 +72,6 @@ public class TaskMenuView extends AbstractFloatingView {
super(context, attrs, defStyleAttr);
mActivity = BaseDraggingActivity.fromContext(context);
mThumbnailTopMargin = getResources().getDimension(R.dimen.task_thumbnail_top_margin);
setClipToOutline(true);
}
@@ -123,14 +121,15 @@ public class TaskMenuView extends AbstractFloatingView {
}
public void setPosition(float x, float y, PagedOrientationHandler pagedOrientationHandler) {
float adjustedY = y + mThumbnailTopMargin;
int taskTopMargin = mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx;
float adjustedY = y + taskTopMargin;
// Changing pivot to make computations easier
// NOTE: Changing the pivots means the rotated view gets rotated about the new pivots set,
// which would render the X and Y position set here incorrect
setPivotX(0);
if (mActivity.getDeviceProfile().isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) {
// In tablet, set pivotY to original position without mThumbnailTopMargin adjustment.
setPivotY(-mThumbnailTopMargin);
setPivotY(-taskTopMargin);
} else {
setPivotY(0);
}
@@ -376,7 +376,8 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
mCurrentFullscreenParams = new FullscreenDrawParams(context);
mDigitalWellBeingToast = new DigitalWellBeingToast(mActivity, this);
mOutlineProvider = new TaskOutlineProvider(getContext(), mCurrentFullscreenParams);
mOutlineProvider = new TaskOutlineProvider(getContext(), mCurrentFullscreenParams,
mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx);
setOutlineProvider(mOutlineProvider);
}
@@ -673,16 +674,12 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
}
}
public int getThumbnailTopMargin() {
return (int) getResources().getDimension(R.dimen.task_thumbnail_top_margin);
}
public void setOrientationState(RecentsOrientedState orientationState) {
PagedOrientationHandler orientationHandler = orientationState.getOrientationHandler();
boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
LayoutParams snapshotParams = (LayoutParams) mSnapshotView.getLayoutParams();
int thumbnailPadding = (int) getResources().getDimension(R.dimen.task_thumbnail_top_margin);
int taskIconMargin = (int) getResources().getDimension(R.dimen.task_icon_top_margin);
snapshotParams.topMargin = mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx;
int taskIconMargin = mActivity.getDeviceProfile().overviewTaskMarginPx;
int taskIconHeight = (int) getResources().getDimension(R.dimen.task_thumbnail_icon_size);
LayoutParams iconParams = (LayoutParams) mIconView.getLayoutParams();
switch (orientationHandler.getRotation()) {
@@ -694,7 +691,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
break;
case ROTATION_180:
iconParams.gravity = BOTTOM | CENTER_HORIZONTAL;
iconParams.bottomMargin = -thumbnailPadding;
iconParams.bottomMargin = -snapshotParams.topMargin;
iconParams.leftMargin = iconParams.rightMargin = 0;
iconParams.topMargin = taskIconMargin;
break;
@@ -711,6 +708,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
iconParams.topMargin = taskIconMargin;
break;
}
mSnapshotView.setLayoutParams(snapshotParams);
mIconView.setLayoutParams(iconParams);
mIconView.setRotation(orientationHandler.getDegreesRotated());
@@ -1083,17 +1081,17 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
private static final class TaskOutlineProvider extends ViewOutlineProvider {
private final int mMarginTop;
private int mMarginTop;
private FullscreenDrawParams mFullscreenParams;
TaskOutlineProvider(Context context, FullscreenDrawParams fullscreenParams) {
mMarginTop = context.getResources().getDimensionPixelSize(
R.dimen.task_thumbnail_top_margin);
TaskOutlineProvider(Context context, FullscreenDrawParams fullscreenParams, int topMargin) {
mMarginTop = topMargin;
mFullscreenParams = fullscreenParams;
}
public void setFullscreenParams(FullscreenDrawParams params) {
public void updateParams(FullscreenDrawParams params, int topMargin) {
mFullscreenParams = params;
mMarginTop = topMargin;
}
@Override
@@ -1216,7 +1214,9 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
}
thumbnail.setFullscreenParams(mCurrentFullscreenParams);
mOutlineProvider.setFullscreenParams(mCurrentFullscreenParams);
mOutlineProvider.updateParams(
mCurrentFullscreenParams,
mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx);
invalidateOutline();
}
@@ -1238,8 +1238,8 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
void updateTaskSize() {
ViewGroup.LayoutParams params = getLayoutParams();
if (mActivity.getDeviceProfile().isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) {
final int thumbnailPadding = (int) getResources().getDimension(
R.dimen.task_thumbnail_top_margin);
final int thumbnailPadding =
mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx;
Rect lastComputedTaskSize = getRecentsView().getLastComputedTaskSize();
int taskWidth = lastComputedTaskSize.width();
+4
View File
@@ -286,4 +286,8 @@
<!-- Size of the maximum radius for the enforced rounded rectangles. -->
<dimen name="enforced_rounded_corner_max_radius">16dp</dimen>
<!-- Overview placeholder to compile in Launcer3 without Quickstep -->
<dimen name="task_thumbnail_icon_size">0dp</dimen>
<dimen name="overview_task_margin">0dp</dimen>
</resources>
@@ -151,6 +151,10 @@ public class DeviceProfile {
public int allAppsIconDrawablePaddingPx;
public float allAppsIconTextSizePx;
// Overview
public int overviewTaskThumbnailTopMarginPx;
public int overviewTaskMarginPx;
// Widgets
public final PointF appWidgetScale = new PointF(1.0f, 1.0f);
@@ -297,6 +301,11 @@ public class DeviceProfile {
: (hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx
+ (isScalableGrid ? 0 : hotseatExtraVerticalSize)));
overviewTaskMarginPx = res.getDimensionPixelSize(R.dimen.overview_task_margin);
overviewTaskThumbnailTopMarginPx = res.getDimensionPixelSize(
R.dimen.task_thumbnail_icon_size) + 2 * overviewTaskMarginPx;
// Calculate all of the remaining variables.
extraSpace = updateAvailableDimensions(res);
// Now that we have all of the variables calculated, we can tune certain sizes.