Merge "Excluding corner radius from quick switch gesture." into sc-dev

This commit is contained in:
TreeHugger Robot
2021-06-14 23:27:48 +00:00
committed by Android (Google) Code Review
3 changed files with 41 additions and 41 deletions
@@ -163,8 +163,8 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
@NonNull
private void quickSwitch(boolean toRight) {
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to quick switch to the previous app")) {
LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to quick switch to the previous app")) {
verifyActiveContainer();
final boolean launcherWasVisible = mLauncher.isLauncherVisible();
boolean transposeInLandscape = false;
@@ -177,33 +177,34 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
final int startY;
final int endX;
final int endY;
final int cornerRadius = (int) Math.ceil(mLauncher.getWindowCornerRadius());
if (toRight) {
if (mLauncher.getDevice().isNaturalOrientation() || !transposeInLandscape) {
// Swipe from the bottom left to the bottom right of the screen.
startX = 0;
startX = cornerRadius;
startY = getSwipeStartY();
endX = mLauncher.getDevice().getDisplayWidth();
endX = mLauncher.getDevice().getDisplayWidth() - cornerRadius;
endY = startY;
} else {
// Swipe from the bottom right to the top right of the screen.
startX = getSwipeStartX();
startY = mLauncher.getRealDisplaySize().y - 1;
startY = mLauncher.getRealDisplaySize().y - 1 - cornerRadius;
endX = startX;
endY = 0;
endY = cornerRadius;
}
} else {
if (mLauncher.getDevice().isNaturalOrientation() || !transposeInLandscape) {
// Swipe from the bottom right to the bottom left of the screen.
startX = mLauncher.getDevice().getDisplayWidth();
startX = mLauncher.getDevice().getDisplayWidth() - cornerRadius;
startY = getSwipeStartY();
endX = 0;
endX = cornerRadius;
endY = startY;
} else {
// Swipe from the bottom left to the top left of the screen.
startX = getSwipeStartX();
startY = 0;
startY = cornerRadius;
endX = startX;
endY = mLauncher.getRealDisplaySize().y - 1;
endY = mLauncher.getRealDisplaySize().y - 1 - cornerRadius;
}
}
@@ -1450,4 +1450,33 @@ public final class LauncherInstrumentation {
return null;
}
}
float getWindowCornerRadius() {
final Resources resources = getResources();
if (!supportsRoundedCornersOnWindows(resources)) {
return 0f;
}
// Radius that should be used in case top or bottom aren't defined.
float defaultRadius = ResourceUtils.getDimenByName("rounded_corner_radius", resources, 0);
float topRadius = ResourceUtils.getDimenByName("rounded_corner_radius_top", resources, 0);
if (topRadius == 0f) {
topRadius = defaultRadius;
}
float bottomRadius = ResourceUtils.getDimenByName(
"rounded_corner_radius_bottom", resources, 0);
if (bottomRadius == 0f) {
bottomRadius = defaultRadius;
}
// Always use the smallest radius to make sure the rounded corners will
// completely cover the display.
return Math.min(topRadius, bottomRadius);
}
private static boolean supportsRoundedCornersOnWindows(Resources resources) {
return ResourceUtils.getBoolByName(
"config_supportsRoundedCornersOnWindows", resources, false);
}
}
@@ -22,7 +22,6 @@ import static com.android.launcher3.testing.TestProtocol.SPRING_LOADED_STATE_ORD
import static junit.framework.TestCase.assertTrue;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.SystemClock;
@@ -61,34 +60,6 @@ public final class Workspace extends Home {
mHotseat = launcher.waitForLauncherObject("hotseat");
}
private static boolean supportsRoundedCornersOnWindows(Resources resources) {
return ResourceUtils.getBoolByName(
"config_supportsRoundedCornersOnWindows", resources, false);
}
private static float getWindowCornerRadius(Resources resources) {
if (!supportsRoundedCornersOnWindows(resources)) {
return 0f;
}
// Radius that should be used in case top or bottom aren't defined.
float defaultRadius = ResourceUtils.getDimenByName("rounded_corner_radius", resources, 0);
float topRadius = ResourceUtils.getDimenByName("rounded_corner_radius_top", resources, 0);
if (topRadius == 0f) {
topRadius = defaultRadius;
}
float bottomRadius = ResourceUtils.getDimenByName(
"rounded_corner_radius_bottom", resources, 0);
if (bottomRadius == 0f) {
bottomRadius = defaultRadius;
}
// Always use the smallest radius to make sure the rounded corners will
// completely cover the display.
return Math.min(topRadius, bottomRadius);
}
/**
* Swipes up to All Apps.
*
@@ -103,8 +74,7 @@ public final class Workspace extends Home {
final int deviceHeight = mLauncher.getDevice().getDisplayHeight();
final int bottomGestureMargin = ResourceUtils.getNavbarSize(
ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mLauncher.getResources());
final int windowCornerRadius = (int) Math.ceil(getWindowCornerRadius(
mLauncher.getResources()));
final int windowCornerRadius = (int) Math.ceil(mLauncher.getWindowCornerRadius());
final int startY = deviceHeight - Math.max(bottomGestureMargin, windowCornerRadius) - 1;
final int swipeHeight = mLauncher.getTestInfo(
TestProtocol.REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT).