Snap for 7901872 from 31bd663332 to sc-v2-release

Change-Id: I3334d3adbf5151bfd775a85230693501b8037a0f
This commit is contained in:
Android Build Coastguard Worker
2021-11-11 00:08:17 +00:00
7 changed files with 55 additions and 15 deletions
@@ -145,9 +145,10 @@ public class FallbackRecentsView extends RecentsView<RecentsActivity, RecentsSta
RunningTaskInfo runningTaskInfo = runningTaskInfos[0];
if (mHomeTaskInfo != null && runningTaskInfo != null &&
mHomeTaskInfo.taskId == runningTaskInfo.taskId
&& getTaskViewCount() == 0) {
&& getTaskViewCount() == 0 && mLoadPlanEverApplied) {
// Do not add a stub task if we are running over home with empty recents, so that we
// show the empty recents message instead of showing a stub task and later removing it.
// Ignore empty task signal if applyLoadPlan has never run.
return false;
}
return super.shouldAddStubTaskView(runningTaskInfos);
@@ -573,6 +573,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
// Keeps track of task id whose visual state should not be reset
private int mIgnoreResetTaskId = -1;
protected boolean mLoadPlanEverApplied;
// Variables for empty state
private final Drawable mEmptyIcon;
@@ -1451,6 +1452,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
resetTaskVisuals();
onTaskStackUpdated();
updateEnabledOverlays();
mLoadPlanEverApplied = true;
}
private boolean isModal() {
+23 -11
View File
@@ -141,6 +141,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
private final CheckLongPressHelper mLongPressHelper;
private final boolean mLayoutHorizontal;
private final boolean mIsRtl;
private final int mIconSize;
@ViewDebug.ExportedProperty(category = "launcher")
@@ -185,6 +186,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.BubbleTextView, defStyle, 0);
mLayoutHorizontal = a.getBoolean(R.styleable.BubbleTextView_layoutHorizontal, false);
mIsRtl = (getResources().getConfiguration().getLayoutDirection()
== View.LAYOUT_DIRECTION_RTL);
DeviceProfile grid = mActivity.getDeviceProfile();
mDisplay = a.getInteger(R.styleable.BubbleTextView_iconDisplay, DISPLAY_WORKSPACE);
@@ -581,19 +584,29 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
return mDotInfo != null;
}
/**
* Get the icon bounds on the view depending on the layout type.
*/
public void getIconBounds(Rect outBounds) {
getIconBounds(this, outBounds, mIconSize);
getIconBounds(mIconSize, outBounds);
}
public static void getIconBounds(View iconView, Rect outBounds, int iconSize) {
int top = iconView.getPaddingTop();
int left = (iconView.getWidth() - iconSize) / 2;
int right = left + iconSize;
int bottom = top + iconSize;
outBounds.set(left, top, right, bottom);
/**
* Get the icon bounds on the view depending on the layout type.
*/
public void getIconBounds(int iconSize, Rect outBounds) {
Utilities.setRectToViewCenter(this, iconSize, outBounds);
if (mLayoutHorizontal) {
if (mIsRtl) {
outBounds.offsetTo(getWidth() - iconSize - getPaddingRight(), outBounds.top);
} else {
outBounds.offsetTo(getPaddingLeft(), outBounds.top);
}
} else {
outBounds.offsetTo(outBounds.left, getPaddingTop());
}
}
/**
* Sets whether to vertically center the content.
*/
@@ -980,8 +993,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
@Override
public void getWorkspaceVisualDragBounds(Rect bounds) {
DeviceProfile grid = mActivity.getDeviceProfile();
BubbleTextView.getIconBounds(this, bounds, grid.iconSizePx);
getIconBounds(mIconSize, bounds);
}
private int getIconSizeForDisplay(int display) {
@@ -998,7 +1010,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
}
public void getSourceVisualDragBounds(Rect bounds) {
BubbleTextView.getIconBounds(this, bounds, getIconSizeForDisplay(mDisplay));
getIconBounds(mIconSize, bounds);
}
@Override
+12
View File
@@ -526,6 +526,18 @@ public final class Utilities {
return defaultValue;
}
/**
* Using the view's bounds and icon size, calculate where the icon bounds will
* be if it was positioned at the center of the view.
*/
public static void setRectToViewCenter(View iconView, int iconSize, Rect outBounds) {
int top = (iconView.getHeight() - iconSize) / 2;
int left = (iconView.getWidth() - iconSize) / 2;
int right = left + iconSize;
int bottom = top + iconSize;
outBounds.set(left, top, right, bottom);
}
/**
* Ensures that a value is within given bounds. Specifically:
* If value is less than lowerBound, return lowerBound; else if value is greater than upperBound,
@@ -628,7 +628,10 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
public void drawDot(Canvas canvas) {
if (!mForceHideDot && ((mDotInfo != null && mDotInfo.hasDot()) || mDotScale > 0)) {
Rect iconBounds = mDotParams.iconBounds;
BubbleTextView.getIconBounds(this, iconBounds, mActivity.getDeviceProfile().iconSizePx);
Utilities.setRectToViewCenter(this, mActivity.getDeviceProfile().iconSizePx,
iconBounds);
iconBounds.offsetTo(iconBounds.left, getPaddingTop());
float iconScale = (float) mBackground.previewSize / iconBounds.width();
Utilities.scaleRectAboutCenter(iconBounds, iconScale);
@@ -352,6 +352,14 @@ public abstract class AbstractLauncherUiTest {
launcher -> launcher.getStateManager().getCurrentStableState() == state.get());
}
// Cannot be used in TaplTests between a Tapl call injecting a gesture and a tapl call
// expecting the results of that gesture because the wait can hide flakeness.
protected void waitForStateTransitionToEnd(String message, Supplier<LauncherState> state) {
waitForLauncherCondition(message,
launcher -> launcher.getStateManager().isInStableState(state.get())
&& !launcher.getStateManager().isInTransition());
}
protected void waitForResumed(String message) {
waitForLauncherCondition(message, launcher -> launcher.hasBeenResumed());
}
@@ -62,10 +62,12 @@ public class WorkProfileTest extends AbstractLauncherUiTest {
mDevice.pressHome();
waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
waitForState("Launcher internal state didn't switch to Normal", () -> NORMAL);
waitForStateTransitionToEnd("Launcher internal state didn't switch to Normal",
() -> NORMAL);
waitForResumed("Launcher internal state is still Background");
executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
waitForState("Launcher internal state didn't switch to All Apps", () -> ALL_APPS);
waitForStateTransitionToEnd("Launcher internal state didn't switch to All Apps",
() -> ALL_APPS);
}
@After