Snap for 8276267 from 59df9e8f27 to udc-release

Change-Id: Iab2021b0754514baafec7517a3dba4b8c25e0bbf
This commit is contained in:
Android Build Coastguard Worker committed 2022-03-09 04:09:29 +00:00
commit 9cf79cfb87
23 files changed
+224 -77

No files matched your search

+3
View File
@@ -31,6 +31,7 @@ android_library {
"androidx.test.uiautomator_uiautomator",
"androidx.preference_preference",
"SystemUISharedLib",
"SystemUIAnimationLib",
],
srcs: [
"tests/tapl/**/*.java",
@@ -196,6 +197,7 @@ android_library {
"lottie",
"SystemUISharedLib",
"SystemUI-statsd",
"SystemUIAnimationLib",
],
manifest: "quickstep/AndroidManifest.xml",
min_sdk_version: "current",
@@ -302,6 +304,7 @@ android_library {
"SystemUISharedLib",
"Launcher3CommonDepsLib",
"QuickstepResLib",
"SystemUIAnimationLib",
],
manifest: "quickstep/AndroidManifest.xml",
platform_apis: true,
@@ -579,8 +579,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
}
}
// Pause page indicator animations as they lead to layer trashing.
mLauncher.getWorkspace().getPageIndicator().pauseAnimations();
// Pause expensive view updates as they can lead to layer thrashing and skipped frames.
mLauncher.pauseExpensiveViewUpdates();
endListener = () -> {
viewsToAnimate.forEach(view -> {
@@ -590,7 +590,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
if (scrimEnabled) {
mLauncher.getScrimView().setBackgroundColor(Color.TRANSPARENT);
}
mLauncher.getWorkspace().getPageIndicator().skipAnimationsToEnd();
mLauncher.resumeExpensiveViewUpdates();
};
}
@@ -29,6 +29,7 @@ import androidx.annotation.NonNull;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherState;
import com.android.launcher3.statemanager.StateManager;
import com.android.launcher3.util.MultiValueAlpha;
@@ -36,6 +37,7 @@ import com.android.quickstep.AnimatedFloat;
import com.android.quickstep.RecentsAnimationCallbacks;
import com.android.quickstep.RecentsAnimationController;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.animation.ViewRootSync;
import com.android.systemui.shared.recents.model.ThumbnailData;
import java.util.HashMap;
@@ -76,6 +78,9 @@ import java.util.function.Supplier;
private boolean mShouldDelayLauncherStateAnim;
// We skip any view synchronizations during init/destroy.
private boolean mCanSyncViews;
private final StateManager.StateListener<LauncherState> mStateListener =
new StateManager.StateListener<LauncherState>() {
@@ -102,6 +107,8 @@ import java.util.function.Supplier;
};
public void init(TaskbarControllers controllers, BaseQuickstepLauncher launcher) {
mCanSyncViews = false;
mControllers = controllers;
mLauncher = launcher;
@@ -121,9 +128,13 @@ import java.util.function.Supplier;
updateStateForFlag(FLAG_RESUMED, launcher.hasBeenResumed());
mLauncherState = launcher.getStateManager().getState();
applyState(0);
mCanSyncViews = true;
}
public void onDestroy() {
mCanSyncViews = false;
mIconAlignmentForResumedState.finishAnimation();
mIconAlignmentForGestureState.finishAnimation();
mIconAlignmentForLauncherState.finishAnimation();
@@ -131,6 +142,8 @@ import java.util.function.Supplier;
mIconAlphaForHome.setConsumer(null);
mLauncher.getHotseat().setIconsAlpha(1f);
mLauncher.getStateManager().removeStateListener(mStateListener);
mCanSyncViews = true;
}
public Animator createAnimToLauncher(@NonNull LauncherState toState,
@@ -380,6 +393,27 @@ import java.util.function.Supplier;
return;
}
float alignment = alignmentSupplier.get();
float currentValue = mIconAlphaForHome.getValue();
boolean taskbarWillBeVisible = alignment < 1;
boolean firstFrameVisChanged = (taskbarWillBeVisible && Float.compare(currentValue, 1) != 0)
|| (!taskbarWillBeVisible && Float.compare(currentValue, 0) != 0);
// Sync the first frame where we swap taskbar and hotseat.
if (firstFrameVisChanged && mCanSyncViews) {
DeviceProfile dp = mLauncher.getDeviceProfile();
// Do all the heavy work before the sync.
mControllers.taskbarViewController.createIconAlignmentControllerIfNotExists(dp);
ViewRootSync.synchronizeNextDraw(mLauncher.getHotseat(),
mControllers.taskbarActivityContext.getDragLayer(),
() -> updateIconAlignment(alignment));
} else {
updateIconAlignment(alignment);
}
}
private void updateIconAlignment(float alignment) {
mControllers.taskbarViewController.setLauncherIconAlignment(
alignment, mLauncher.getDeviceProfile());
@@ -191,6 +191,16 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
+ mTaskbarIconTranslationYForStash.value);
}
/**
* Creates the icon alignment controller if it does not already exist.
* @param launcherDp Launcher device profile.
*/
public void createIconAlignmentControllerIfNotExists(DeviceProfile launcherDp) {
if (mIconAlignControllerLazy == null) {
mIconAlignControllerLazy = createIconAlignmentController(launcherDp);
}
}
/**
* Sets the taskbar icon alignment relative to Launcher hotseat icons
* @param alignmentRatio [0, 1]
@@ -198,9 +208,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
* 1 => fully aligned
*/
public void setLauncherIconAlignment(float alignmentRatio, DeviceProfile launcherDp) {
if (mIconAlignControllerLazy == null) {
mIconAlignControllerLazy = createIconAlignmentController(launcherDp);
}
createIconAlignmentControllerIfNotExists(launcherDp);
mIconAlignControllerLazy.setPlayFraction(alignmentRatio);
if (alignmentRatio <= 0 || alignmentRatio >= 1) {
// Cleanup lazy controller so that it is created again in next animation
@@ -49,9 +49,9 @@ import java.util.HashMap;
public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAnimationListener {
public static final boolean ENABLE_SHELL_TRANSITIONS =
SystemProperties.getBoolean("persist.debug.shell_transit", false);
SystemProperties.getBoolean("persist.wm.debug.shell_transit", false);
public static final boolean SHELL_TRANSITIONS_ROTATION = ENABLE_SHELL_TRANSITIONS
&& SystemProperties.getBoolean("persist.debug.shell_transit_rotate", false);
&& SystemProperties.getBoolean("persist.wm.debug.shell_transit_rotate", false);
private RecentsAnimationController mController;
private RecentsAnimationCallbacks mCallbacks;
@@ -336,8 +336,7 @@ abstract class SwipeUpGestureTutorialController extends TutorialController {
1f - SHAPE_PROGRESS_DURATION /* shapeProgressStart */,
radius, 255,
false, /* isOpening */
mFakeIconView, mDp,
false /* isVerticalBarLayout */);
mFakeIconView, mDp);
mFakeIconView.setAlpha(1);
mFakeTaskView.setAlpha(getWindowAlpha(progress));
mFakePreviousTaskView.setAlpha(getWindowAlpha(progress));
@@ -442,6 +442,7 @@ public class StatsLogCompatManager extends StatsLogManager {
private final Optional<ActivityContext> mActivityContext;
private InstanceId mInstanceId = DEFAULT_INSTANCE_ID;
private LatencyType mType = LatencyType.UNKNOWN;
private int mPackageId = 0;
private long mLatencyInMillis;
StatsCompatLatencyLogger(Context context, ActivityContext activityContext) {
@@ -461,6 +462,12 @@ public class StatsLogCompatManager extends StatsLogManager {
return this;
}
@Override
public StatsLatencyLogger withPackageId(int packageId) {
this.mPackageId = packageId;
return this;
}
@Override
public StatsLatencyLogger withLatency(long latencyInMillis) {
this.mLatencyInMillis = latencyInMillis;
@@ -482,7 +489,7 @@ public class StatsLogCompatManager extends StatsLogManager {
SysUiStatsLog.write(SysUiStatsLog.LAUNCHER_LATENCY,
event.getId(), // event_id
mInstanceId.getId(), // instance_id
0, // package_id
mPackageId, // package_id
mLatencyInMillis, // latency_in_millis
mType.getId() //type
);
@@ -48,10 +48,10 @@ import androidx.annotation.WorkerThread;
import androidx.core.content.FileProvider;
import com.android.internal.app.ChooserActivity;
import com.android.internal.util.ScreenshotHelper;
import com.android.launcher3.BuildConfig;
import com.android.quickstep.SystemUiProxy;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.utilities.BitmapUtil;
import java.io.File;
import java.io.FileOutputStream;
@@ -77,7 +77,8 @@ public class ImageActionUtils {
public static void saveScreenshot(SystemUiProxy systemUiProxy, Bitmap screenshot,
Rect screenshotBounds,
Insets visibleInsets, Task.TaskKey task) {
systemUiProxy.handleImageBundleAsScreenshot(BitmapUtil.hardwareBitmapToBundle(screenshot),
systemUiProxy.handleImageBundleAsScreenshot(
ScreenshotHelper.HardwareBitmapBundler.hardwareBitmapToBundle(screenshot),
screenshotBounds, visibleInsets, task);
}
@@ -36,7 +36,7 @@ import org.junit.rules.TestRule;
*/
public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest {
static final boolean ENABLE_SHELL_TRANSITIONS =
SystemProperties.getBoolean("persist.debug.shell_transit", false);
SystemProperties.getBoolean("persist.wm.debug.shell_transit", false);
@Override
protected TestRule getRulesInsideActivityMonitor() {
return RuleChain.
@@ -42,7 +42,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.RemoteException;
import android.platform.test.rule.CrashDetector;
import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
@@ -106,8 +105,7 @@ public class FallbackRecentsTest {
}
mOrderSensitiveRules = RuleChain
.outerRule(new CrashDetector("com.android.systemui"))
.around(new NavigationModeSwitchRule(mLauncher))
.outerRule(new NavigationModeSwitchRule(mLauncher))
.around(new FailureWatcher(mDevice, mLauncher));
mOtherLauncherActivity = context.getPackageManager().queryIntentActivities(
+3
View File
@@ -152,6 +152,9 @@
<!-- numHotseatIcons defaults to numColumns, if not specified -->
<attr name="numHotseatIcons" format="integer" />
<!-- Number of icons to use when shrinking the hotseat size,
defaults to numHotseatIcons / 2 -->
<attr name="numShrunkenHotseatIcons" format="integer" />
<!-- Number of icons to use when extending the hotseat size,
defaults to 2 * numHotseatIcons -->
<attr name="numExtendedHotseatIcons" format="integer" />
+29 -8
View File
@@ -34,7 +34,6 @@ import android.view.Surface;
import com.android.launcher3.CellLayout.ContainerType;
import com.android.launcher3.DevicePaddings.DevicePadding;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.icons.DotRenderer;
import com.android.launcher3.icons.GraphicsUtils;
import com.android.launcher3.icons.IconNormalizer;
@@ -59,6 +58,7 @@ public class DeviceProfile {
// Device properties
public final boolean isTablet;
public final boolean isLargeTablet;
public final boolean isPhone;
public final boolean transposeLayoutWithOrientation;
public final boolean isTwoPanels;
@@ -67,6 +67,7 @@ public class DeviceProfile {
// Device properties in current orientation
public final boolean isLandscape;
public final boolean isMultiWindowMode;
public final boolean isGestureMode;
public final int windowX;
public final int windowY;
@@ -229,12 +230,13 @@ public class DeviceProfile {
/** TODO: Once we fully migrate to staged split, remove "isMultiWindowMode" */
DeviceProfile(Context context, InvariantDeviceProfile inv, Info info, WindowBounds windowBounds,
boolean isMultiWindowMode, boolean transposeLayoutWithOrientation,
boolean useTwoPanels) {
boolean useTwoPanels, boolean isGestureMode) {
this.inv = inv;
this.isLandscape = windowBounds.isLandscape();
this.isMultiWindowMode = isMultiWindowMode;
this.transposeLayoutWithOrientation = transposeLayoutWithOrientation;
this.isGestureMode = isGestureMode;
windowX = windowBounds.bounds.left;
windowY = windowBounds.bounds.top;
@@ -243,6 +245,7 @@ public class DeviceProfile {
// Determine device posture.
mInfo = info;
isTablet = info.isTablet(windowBounds);
isLargeTablet = info.isLargeTablet(windowBounds);
isPhone = !isTablet;
isTwoPanels = isTablet && useTwoPanels;
isTaskbarPresent = isTablet && ApiWrapper.TASKBAR_DRAWN_IN_PROCESS;
@@ -343,9 +346,15 @@ public class DeviceProfile {
workspaceCellPaddingXPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_padding_x);
hotseatQsbHeight = res.getDimensionPixelSize(R.dimen.qsb_widget_height);
isQsbInline = isTablet && isLandscape && !isTwoPanels && hotseatQsbHeight > 0;
numShownHotseatIcons =
isTwoPanels ? inv.numDatabaseHotseatIcons : inv.numShownHotseatIcons;
isQsbInline = isLargeTablet && isLandscape && hotseatQsbHeight > 0;
if (isTaskbarPresent && !isGestureMode && isQsbInline) {
numShownHotseatIcons = inv.numShrunkenHotseatIcons;
} else {
numShownHotseatIcons =
isTwoPanels ? inv.numDatabaseHotseatIcons : inv.numShownHotseatIcons;
}
numShownAllAppsColumns =
isTwoPanels ? inv.numDatabaseAllAppsColumns : inv.numAllAppsColumns;
hotseatBarSizeExtraSpacePx = 0;
@@ -540,7 +549,8 @@ public class DeviceProfile {
return new Builder(context, inv, mInfo)
.setWindowBounds(bounds)
.setUseTwoPanels(isTwoPanels)
.setMultiWindowMode(isMultiWindowMode);
.setMultiWindowMode(isMultiWindowMode)
.setGestureMode(isGestureMode);
}
public DeviceProfile copy(Context context) {
@@ -1081,9 +1091,11 @@ public class DeviceProfile {
writer.println(prefix + "\t1 dp = " + mMetrics.density + " px");
writer.println(prefix + "\tisTablet:" + isTablet);
writer.println(prefix + "\tisLargeTablet:" + isLargeTablet);
writer.println(prefix + "\tisPhone:" + isPhone);
writer.println(prefix + "\ttransposeLayoutWithOrientation:"
+ transposeLayoutWithOrientation);
writer.println(prefix + "\tisGestureMode:" + isGestureMode);
writer.println(prefix + "\tisLandscape:" + isLandscape);
writer.println(prefix + "\tisMultiWindowMode:" + isMultiWindowMode);
@@ -1266,6 +1278,7 @@ public class DeviceProfile {
private boolean mIsMultiWindowMode = false;
private Boolean mTransposeLayoutWithOrientation;
private Boolean mIsGestureMode;
public Builder(Context context, InvariantDeviceProfile inv, Info info) {
mContext = context;
@@ -1294,6 +1307,11 @@ public class DeviceProfile {
return this;
}
public Builder setGestureMode(boolean isGestureMode) {
mIsGestureMode = isGestureMode;
return this;
}
public DeviceProfile build() {
if (mWindowBounds == null) {
throw new IllegalArgumentException("Window bounds not set");
@@ -1301,8 +1319,11 @@ public class DeviceProfile {
if (mTransposeLayoutWithOrientation == null) {
mTransposeLayoutWithOrientation = !mInfo.isTablet(mWindowBounds);
}
return new DeviceProfile(mContext, mInv, mInfo, mWindowBounds,
mIsMultiWindowMode, mTransposeLayoutWithOrientation, mUseTwoPanels);
if (mIsGestureMode == null) {
mIsGestureMode = DisplayController.getNavigationMode(mContext).hasGestures;
}
return new DeviceProfile(mContext, mInv, mInfo, mWindowBounds, mIsMultiWindowMode,
mTransposeLayoutWithOrientation, mUseTwoPanels, mIsGestureMode);
}
}
@@ -19,6 +19,7 @@ package com.android.launcher3;
import static com.android.launcher3.Utilities.dpiFromPx;
import static com.android.launcher3.config.FeatureFlags.ENABLE_TWO_PANEL_HOME;
import static com.android.launcher3.util.DisplayController.CHANGE_DENSITY;
import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
import static com.android.launcher3.util.DisplayController.CHANGE_SUPPORTED_BOUNDS;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
@@ -137,6 +138,11 @@ public class InvariantDeviceProfile {
*/
public int numShownHotseatIcons;
/**
* Number of icons inside the hotseat area when using 3 buttons navigation.
*/
public int numShrunkenHotseatIcons;
/**
* Number of icons inside the hotseat area that is stored in the database. This is greater than
* or equal to numnShownHotseatIcons, allowing for a seamless transition between two hotseat
@@ -188,7 +194,8 @@ public class InvariantDeviceProfile {
DisplayController.INSTANCE.get(context).setPriorityListener(
(displayContext, info, flags) -> {
if ((flags & (CHANGE_DENSITY | CHANGE_SUPPORTED_BOUNDS)) != 0) {
if ((flags & (CHANGE_DENSITY | CHANGE_SUPPORTED_BOUNDS
| CHANGE_NAVIGATION_MODE)) != 0) {
onConfigChanged(displayContext);
}
});
@@ -336,6 +343,7 @@ public class InvariantDeviceProfile {
horizontalMargin = displayOption.horizontalMargin;
numShownHotseatIcons = closestProfile.numHotseatIcons;
numShrunkenHotseatIcons = closestProfile.numShrunkenHotseatIcons;
numDatabaseHotseatIcons = deviceType == TYPE_MULTI_DISPLAY
? closestProfile.numDatabaseHotseatIcons : closestProfile.numHotseatIcons;
hotseatBorderSpaces = displayOption.hotseatBorderSpaces;
@@ -365,7 +373,8 @@ public class InvariantDeviceProfile {
for (WindowBounds bounds : displayInfo.supportedBounds) {
localSupportedProfiles.add(new DeviceProfile.Builder(context, this, displayInfo)
.setUseTwoPanels(deviceType == TYPE_MULTI_DISPLAY)
.setWindowBounds(bounds).build());
.setWindowBounds(bounds)
.build());
// Wallpaper size should be the maximum of the all possible sizes Launcher expects
int displayWidth = bounds.bounds.width();
@@ -691,6 +700,7 @@ public class InvariantDeviceProfile {
private final int numAllAppsColumns;
private final int numDatabaseAllAppsColumns;
private final int numHotseatIcons;
private final int numShrunkenHotseatIcons;
private final int numDatabaseHotseatIcons;
private final String dbFile;
@@ -727,6 +737,8 @@ public class InvariantDeviceProfile {
numHotseatIcons = a.getInt(
R.styleable.GridDisplayOption_numHotseatIcons, numColumns);
numShrunkenHotseatIcons = a.getInt(
R.styleable.GridDisplayOption_numShrunkenHotseatIcons, numHotseatIcons / 2);
numDatabaseHotseatIcons = a.getInt(
R.styleable.GridDisplayOption_numExtendedHotseatIcons, 2 * numHotseatIcons);
+11
View File
@@ -3184,4 +3184,15 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
public ArrowPopup<?> getOptionsPopup() {
return findViewById(R.id.popup_container);
}
/** Pauses view updates that should not be run during the app launch animation. */
public void pauseExpensiveViewUpdates() {
// Pause page indicator animations as they lead to layer trashing.
getWorkspace().getPageIndicator().pauseAnimations();
}
/** Resumes view updates at the end of the app launch animation. */
public void resumeExpensiveViewUpdates() {
getWorkspace().getPageIndicator().skipAnimationsToEnd();
}
}
@@ -705,6 +705,12 @@ public class StatsLogManager implements ResourceBasedOverride {
return this;
}
/**
* Sets packageId of log message.
*/
default StatsLatencyLogger withPackageId(int packageId) {
return this;
}
/**
* Builds the final message and logs it as {@link EventEnum}.
@@ -26,6 +26,7 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_NAVIGATION_MODE_GESTURE_BUTTON;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.PackageManagerHelper.getPackageFilter;
import static com.android.launcher3.util.WindowManagerCompat.MIN_LARGE_TABLET_WIDTH;
import static com.android.launcher3.util.WindowManagerCompat.MIN_TABLET_WIDTH;
import static java.util.Collections.emptyMap;
@@ -369,12 +370,20 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
}
/**
* Returns true if the bounds represent a tablet
* Returns {@code true} if the bounds represent a tablet.
*/
public boolean isTablet(WindowBounds bounds) {
return dpiFromPx(Math.min(bounds.bounds.width(), bounds.bounds.height()),
densityDpi) >= MIN_TABLET_WIDTH;
}
/**
* Returns {@code true} if the bounds represent a large tablet.
*/
public boolean isLargeTablet(WindowBounds bounds) {
return dpiFromPx(Math.min(bounds.bounds.width(), bounds.bounds.height()),
densityDpi) >= MIN_LARGE_TABLET_WIDTH;
}
}
/**
@@ -45,6 +45,7 @@ import java.util.Set;
public class WindowManagerCompat {
public static final int MIN_TABLET_WIDTH = 600;
public static final int MIN_LARGE_TABLET_WIDTH = 720;
/**
* Returns a set of supported render sizes for a internal display.
@@ -22,7 +22,7 @@ import com.android.launcher3.model.data.ItemInfoWithIcon;
/**
* Views that contain {@link BubbleTextView} should implement this interface.
*/
public interface BubbleTextHolder {
public interface BubbleTextHolder extends IconLabelDotView {
BubbleTextView getBubbleText();
/**
@@ -32,4 +32,14 @@ public interface BubbleTextHolder {
*/
default void onItemInfoUpdated(ItemInfoWithIcon itemInfo) {
}
@Override
default void setIconVisible(boolean visible) {
getBubbleText().setIconVisible(visible);
}
@Override
default void setForceHideDot(boolean hide) {
getBubbleText().setForceHideDot(hide);
}
}
@@ -147,8 +147,7 @@ public class ClipIconView extends View implements ClipPathView {
* Update the icon UI to match the provided parameters during an animation frame
*/
public void update(RectF rect, float progress, float shapeProgressStart, float cornerRadius,
int fgIconAlpha, boolean isOpening, View container, DeviceProfile dp,
boolean isVerticalBarLayout) {
int fgIconAlpha, boolean isOpening, View container, DeviceProfile dp) {
MarginLayoutParams lp = (MarginLayoutParams) container.getLayoutParams();
float dX = mIsRtl
@@ -169,7 +168,7 @@ public class ClipIconView extends View implements ClipPathView {
}
update(rect, progress, shapeProgressStart, cornerRadius, fgIconAlpha, isOpening, scale,
minSize, lp, isVerticalBarLayout, dp);
minSize, lp, dp);
container.setPivotX(0);
container.setPivotY(0);
@@ -181,7 +180,7 @@ public class ClipIconView extends View implements ClipPathView {
private void update(RectF rect, float progress, float shapeProgressStart, float cornerRadius,
int fgIconAlpha, boolean isOpening, float scale, float minSize,
MarginLayoutParams parentLp, boolean isVerticalBarLayout, DeviceProfile dp) {
MarginLayoutParams parentLp, DeviceProfile dp) {
float dX = mIsRtl
? rect.left - (dp.widthPx - parentLp.getMarginStart() - parentLp.width)
: rect.left - parentLp.getMarginStart();
@@ -193,7 +192,7 @@ public class ClipIconView extends View implements ClipPathView {
float shapeRevealProgress = boundToRange(mapToRange(max(shapeProgressStart, progress),
shapeProgressStart, 1f, 0, toMax, LINEAR), 0, 1);
if (isVerticalBarLayout) {
if (dp.isLandscape) {
mOutline.right = (int) (rect.width() / scale);
} else {
mOutline.bottom = (int) (rect.height() / scale);
@@ -218,16 +217,16 @@ public class ClipIconView extends View implements ClipPathView {
mRevealAnimator.setCurrentFraction(shapeRevealProgress);
}
float drawableScale = (isVerticalBarLayout ? mOutline.width() : mOutline.height())
float drawableScale = (dp.isLandscape ? mOutline.width() : mOutline.height())
/ minSize;
setBackgroundDrawableBounds(drawableScale, isVerticalBarLayout);
setBackgroundDrawableBounds(drawableScale, dp.isLandscape);
if (isOpening) {
// Center align foreground
int height = mFinalDrawableBounds.height();
int width = mFinalDrawableBounds.width();
int diffY = isVerticalBarLayout ? 0
int diffY = dp.isLandscape ? 0
: (int) (((height * drawableScale) - height) / 2);
int diffX = isVerticalBarLayout ? (int) (((width * drawableScale) - width) / 2)
int diffX = dp.isLandscape ? (int) (((width * drawableScale) - width) / 2)
: 0;
sTmpRect.set(mFinalDrawableBounds);
sTmpRect.offset(diffX, diffY);
@@ -247,11 +246,11 @@ public class ClipIconView extends View implements ClipPathView {
invalidateOutline();
}
private void setBackgroundDrawableBounds(float scale, boolean isVerticalBarLayout) {
private void setBackgroundDrawableBounds(float scale, boolean isLandscape) {
sTmpRect.set(mFinalDrawableBounds);
Utilities.scaleRectAboutCenter(sTmpRect, scale);
// Since the drawable is at the top of the view, we need to offset to keep it centered.
if (isVerticalBarLayout) {
if (isLandscape) {
sTmpRect.offsetTo((int) (mFinalDrawableBounds.left * scale), sTmpRect.top);
} else {
sTmpRect.offsetTo(sTmpRect.left, (int) (mFinalDrawableBounds.top * scale));
@@ -269,7 +268,7 @@ public class ClipIconView extends View implements ClipPathView {
* Sets the icon for this view as part of initial setup
*/
public void setIcon(@Nullable Drawable drawable, int iconOffset, MarginLayoutParams lp,
boolean isOpening, boolean isVerticalBarLayout, DeviceProfile dp) {
boolean isOpening, DeviceProfile dp) {
mIsAdaptiveIcon = drawable instanceof AdaptiveIconDrawable;
if (mIsAdaptiveIcon) {
boolean isFolderIcon = drawable instanceof FolderAdaptiveIcon;
@@ -304,7 +303,7 @@ public class ClipIconView extends View implements ClipPathView {
Utilities.scaleRectAboutCenter(mStartRevealRect, IconShape.getNormalizationScale());
}
if (isVerticalBarLayout) {
if (dp.isLandscape) {
lp.width = (int) Math.max(lp.width, lp.height * dp.aspectRatio);
} else {
lp.height = (int) Math.max(lp.height, lp.width * dp.aspectRatio);
@@ -325,7 +324,7 @@ public class ClipIconView extends View implements ClipPathView {
bgDrawableStartScale = scale;
mOutline.set(0, 0, lp.width, lp.height);
}
setBackgroundDrawableBounds(bgDrawableStartScale, isVerticalBarLayout);
setBackgroundDrawableBounds(bgDrawableStartScale, dp.isLandscape);
mEndRevealRect.set(0, 0, lp.width, lp.height);
setOutlineProvider(new ViewOutlineProvider() {
@Override
@@ -43,6 +43,7 @@ import androidx.annotation.UiThread;
import androidx.annotation.WorkerThread;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
@@ -82,7 +83,6 @@ public class FloatingIconView extends FrameLayout implements
private final Launcher mLauncher;
private final boolean mIsRtl;
private boolean mIsVerticalBarLayout = false;
private boolean mIsOpening;
private IconLoadResult mIconLoadResult;
@@ -150,7 +150,7 @@ public class FloatingIconView extends FrameLayout implements
float shapeProgressStart, float cornerRadius, boolean isOpening) {
setAlpha(alpha);
mClipIconView.update(rect, progress, shapeProgressStart, cornerRadius, fgIconAlpha,
isOpening, this, mLauncher.getDeviceProfile(), mIsVerticalBarLayout);
isOpening, this, mLauncher.getDeviceProfile());
}
@Override
@@ -320,11 +320,11 @@ public class FloatingIconView extends FrameLayout implements
@UiThread
private void setIcon(@Nullable Drawable drawable, @Nullable Drawable badge,
@Nullable Drawable btvIcon, int iconOffset) {
final DeviceProfile dp = mLauncher.getDeviceProfile();
final InsettableFrameLayout.LayoutParams lp =
(InsettableFrameLayout.LayoutParams) getLayoutParams();
mBadge = badge;
mClipIconView.setIcon(drawable, iconOffset, lp, mIsOpening, mIsVerticalBarLayout,
mLauncher.getDeviceProfile());
mClipIconView.setIcon(drawable, iconOffset, lp, mIsOpening, dp);
if (drawable instanceof AdaptiveIconDrawable) {
final int originalHeight = lp.height;
final int originalWidth = lp.width;
@@ -332,7 +332,7 @@ public class FloatingIconView extends FrameLayout implements
mFinalDrawableBounds.set(0, 0, originalWidth, originalHeight);
float aspectRatio = mLauncher.getDeviceProfile().aspectRatio;
if (mIsVerticalBarLayout) {
if (dp.isLandscape) {
lp.width = (int) Math.max(lp.width, lp.height * aspectRatio);
} else {
lp.height = (int) Math.max(lp.height, lp.width * aspectRatio);
@@ -565,7 +565,6 @@ public class FloatingIconView extends FrameLayout implements
view.recycle();
// Init properties before getting the drawable.
view.mIsVerticalBarLayout = launcher.getDeviceProfile().isVerticalBarLayout();
view.mIsOpening = isOpening;
view.mOriginalIcon = originalView;
view.mPositionOut = positionOut;
@@ -587,7 +586,7 @@ public class FloatingIconView extends FrameLayout implements
view.matchPositionOf(launcher, originalView, isOpening, positionOut);
// We need to add it to the overlay, but keep it invisible until animation starts..
view.setVisibility(INVISIBLE);
setIconAndDotVisible(view, false);
parent.addView(view);
dragLayer.addView(view.mListenerView);
view.mListenerView.setListener(view::fastFinish);
@@ -596,16 +595,8 @@ public class FloatingIconView extends FrameLayout implements
view.mEndRunnable = null;
if (hideOriginal) {
if (isOpening) {
setIconAndDotVisible(originalView, true);
view.finish(dragLayer);
} else {
originalView.setVisibility(VISIBLE);
if (originalView instanceof IconLabelDotView) {
setIconAndDotVisible(originalView, true);
}
view.finish(dragLayer);
}
setIconAndDotVisible(originalView, true);
view.finish(dragLayer);
} else {
view.finish(dragLayer);
}
@@ -31,6 +31,7 @@ import android.content.res.Resources;
import android.graphics.Rect;
import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.AttributeSet;
import android.util.Pair;
import android.util.SparseArray;
@@ -55,7 +56,9 @@ import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.model.UserManagerState;
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.pm.UserCache;
import com.android.launcher3.views.ArrowTipView;
import com.android.launcher3.views.RecyclerViewFastScroller;
import com.android.launcher3.views.SpringRelativeLayout;
@@ -94,13 +97,17 @@ public class WidgetsFullSheet extends BaseWidgetSheet
"launcher.widgets_education_dialog_seen";
private final Rect mInsets = new Rect();
private final UserManagerState mUserManagerState = new UserManagerState();
private final boolean mHasWorkProfile;
private final SparseArray<AdapterHolder> mAdapters = new SparseArray();
private final UserHandle mCurrentUser = Process.myUserHandle();
private final Predicate<WidgetsListBaseEntry> mPrimaryWidgetsFilter =
entry -> mCurrentUser.equals(entry.mPkgItem.user);
private final Predicate<WidgetsListBaseEntry> mWorkWidgetsFilter =
mPrimaryWidgetsFilter.negate();
entry -> !mCurrentUser.equals(entry.mPkgItem.user)
&& !mUserManagerState.isUserQuiet(entry.mPkgItem.user);
@Nullable private ArrowTipView mLatestEducationalTip;
private final OnLayoutChangeListener mLayoutChangeListenerToShowTips =
new OnLayoutChangeListener() {
@@ -171,6 +178,9 @@ public class WidgetsFullSheet extends BaseWidgetSheet
: 0;
mWidgetSheetContentHorizontalPadding = 2 * resources.getDimensionPixelSize(
R.dimen.widget_cell_horizontal_padding);
mUserManagerState.init(UserCache.INSTANCE.get(context),
context.getSystemService(UserManager.class));
}
public WidgetsFullSheet(Context context, AttributeSet attrs) {
@@ -259,10 +269,15 @@ public class WidgetsFullSheet extends BaseWidgetSheet
boolean isWidgetAvailable = adapterHolder.mWidgetsListAdapter.hasVisibleEntries();
adapterHolder.mWidgetsRecyclerView.setVisibility(isWidgetAvailable ? VISIBLE : GONE);
mNoWidgetsView.setText(
adapterHolder.mAdapterType == AdapterHolder.SEARCH
? R.string.no_search_results
: R.string.no_widgets_available);
if (adapterHolder.mAdapterType == AdapterHolder.SEARCH) {
mNoWidgetsView.setText(R.string.no_search_results);
} else if (adapterHolder.mAdapterType == AdapterHolder.WORK
&& mUserManagerState.isAnyProfileQuietModeEnabled()
&& mActivityContext.getStringCache() != null) {
mNoWidgetsView.setText(mActivityContext.getStringCache().workProfilePausedTitle);
} else {
mNoWidgetsView.setText(R.string.no_widgets_available);
}
mNoWidgetsView.setVisibility(isWidgetAvailable ? GONE : VISIBLE);
}
@@ -39,6 +39,7 @@ class DeviceProfileTest {
private var isMultiWindowMode: Boolean = false
private var transposeLayoutWithOrientation: Boolean = false
private var useTwoPanels: Boolean = false
private var isGestureMode: Boolean = true
@Before
fun setUp() {
@@ -58,7 +59,8 @@ class DeviceProfileTest {
windowBounds,
isMultiWindowMode,
transposeLayoutWithOrientation,
useTwoPanels
useTwoPanels,
isGestureMode
)
assertThat(dp.isQsbInline).isFalse()
@@ -67,7 +69,7 @@ class DeviceProfileTest {
@Test
fun qsbWidth_is_match_parent_for_tablet_portrait() {
initializeVarsForTablet()
initializeVarsForLargeTablet()
val dp = DeviceProfile(
context,
@@ -76,7 +78,8 @@ class DeviceProfileTest {
windowBounds,
isMultiWindowMode,
transposeLayoutWithOrientation,
useTwoPanels
useTwoPanels,
isGestureMode
)
assertThat(dp.isQsbInline).isFalse()
@@ -84,8 +87,8 @@ class DeviceProfileTest {
}
@Test
fun qsbWidth_has_size_for_tablet_landscape() {
initializeVarsForTablet(true)
fun qsbWidth_has_size_for_large_tablet_landscape() {
initializeVarsForLargeTablet(true)
val dp = DeviceProfile(
context,
@@ -94,7 +97,8 @@ class DeviceProfileTest {
windowBounds,
isMultiWindowMode,
transposeLayoutWithOrientation,
useTwoPanels
useTwoPanels,
isGestureMode
)
if (dp.hotseatQsbHeight > 0) {
@@ -110,8 +114,8 @@ class DeviceProfileTest {
* This test is to make sure that two panels don't inline the QSB as tablets do
*/
@Test
fun qsbWidth_is_match_parent_for_two_panel_landscape() {
initializeVarsForTablet(true)
fun qsbWidth_is_match_parent_for_small_two_panel_landscape() {
initializeVarsForSmallTablet(true)
useTwoPanels = true
val dp = DeviceProfile(
@@ -121,7 +125,8 @@ class DeviceProfileTest {
windowBounds,
isMultiWindowMode,
transposeLayoutWithOrientation,
useTwoPanels
useTwoPanels,
isGestureMode
)
assertThat(dp.isQsbInline).isFalse()
@@ -137,11 +142,12 @@ class DeviceProfileTest {
windowBounds = WindowBounds(x, y, x, y - 100)
`when`(info.isTablet(any())).thenReturn(false)
`when`(info.isLargeTablet(any())).thenReturn(false)
scalableInvariantDeviceProfile()
}
private fun initializeVarsForTablet(isLandscape: Boolean = false) {
private fun initializeVarsForSmallTablet(isLandscape: Boolean = false) {
val (x, y) = if (isLandscape)
Pair(2560, 1600)
else
@@ -150,6 +156,21 @@ class DeviceProfileTest {
windowBounds = WindowBounds(x, y, x, y - 100)
`when`(info.isTablet(any())).thenReturn(true)
`when`(info.isLargeTablet(any())).thenReturn(false)
scalableInvariantDeviceProfile()
}
private fun initializeVarsForLargeTablet(isLandscape: Boolean = false) {
val (x, y) = if (isLandscape)
Pair(2560, 1600)
else
Pair(1600, 2560)
windowBounds = WindowBounds(x, y, x, y - 100)
`when`(info.isTablet(any())).thenReturn(true)
`when`(info.isLargeTablet(any())).thenReturn(true)
scalableInvariantDeviceProfile()
}
@@ -39,7 +39,6 @@ import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.platform.test.rule.CrashDetector;
import android.system.OsConstants;
import android.util.Log;
@@ -229,7 +228,6 @@ public abstract class AbstractLauncherUiTest {
@Rule
public TestRule mOrderSensitiveRules = RuleChain
.outerRule(new TestStabilityRule())
.around(new CrashDetector("com.android.systemui"))
.around(mActivityMonitor)
.around(getRulesInsideActivityMonitor());