Gestures for zero-button mode
Change-Id: If17ba764ede132694ccf0c56269df1a4117ec0f6
This commit is contained in:
parent
c6d9ddfddb
commit
679b09d6bd
|
@ -44,6 +44,7 @@ import com.android.launcher3.anim.AnimationSuccessListener;
|
|||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.anim.AnimatorSetBuilder;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.compat.AccessibilityManagerCompat;
|
||||
import com.android.launcher3.touch.SwipeDetector;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Command;
|
||||
|
@ -212,6 +213,7 @@ public class NavBarToHomeTouchController implements TouchController, SwipeDetect
|
|||
private void onSwipeInteractionCompleted(LauncherState targetState) {
|
||||
clearState();
|
||||
mLauncher.getStateManager().goToState(targetState, false /* animated */);
|
||||
AccessibilityManagerCompat.sendStateEventToTest(mLauncher, targetState.ordinal);
|
||||
}
|
||||
|
||||
private void logStateChange(int startContainerType, int logAction) {
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package com.android.launcher3.tapl;
|
||||
|
||||
import static com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel.ZERO_BUTTON;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.test.uiautomator.BySelector;
|
||||
import androidx.test.uiautomator.Direction;
|
||||
|
@ -47,6 +49,7 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer {
|
|||
private boolean hasClickableIcon(UiObject2 allAppsContainer, BySelector appIconSelector) {
|
||||
final UiObject2 icon = allAppsContainer.findObject(appIconSelector);
|
||||
if (icon == null) return false;
|
||||
if (mLauncher.getNavigationModel() == ZERO_BUTTON) return true;
|
||||
final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame");
|
||||
return icon.getVisibleBounds().bottom < navBar.getVisibleBounds().top;
|
||||
}
|
||||
|
@ -63,8 +66,10 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer {
|
|||
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
||||
"want to get app icon on all apps")) {
|
||||
final UiObject2 allAppsContainer = verifyActiveContainer();
|
||||
final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame");
|
||||
allAppsContainer.setGestureMargins(0, 0, 0, navBar.getVisibleBounds().height() + 1);
|
||||
if (mLauncher.getNavigationModel() != ZERO_BUTTON) {
|
||||
final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame");
|
||||
allAppsContainer.setGestureMargins(0, 0, 0, navBar.getVisibleBounds().height() + 1);
|
||||
}
|
||||
final BySelector appIconSelector = AppIcon.getAppIconSelector(appName, mLauncher);
|
||||
if (!hasClickableIcon(allAppsContainer, appIconSelector)) {
|
||||
scrollBackToBeginning();
|
||||
|
|
|
@ -109,6 +109,6 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
|
|||
}
|
||||
|
||||
protected int getSwipeStartY() {
|
||||
return mLauncher.waitForSystemUiObject("navigation_bar_frame").getVisibleBounds().centerY();
|
||||
return mLauncher.getRealDisplaySize().y - 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import android.view.InputDevice;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.Surface;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.WindowManager;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -350,36 +351,17 @@ public final class LauncherInstrumentation {
|
|||
final String action;
|
||||
if (getNavigationModel() == NavigationModel.ZERO_BUTTON) {
|
||||
if (hasLauncherObject(WORKSPACE_RES_ID)) {
|
||||
log(action = "0-button: already in workspace");
|
||||
} else if (hasLauncherObject(OVERVIEW_RES_ID)) {
|
||||
log(action = "0-button: from overview");
|
||||
final UiObject2 navBar = waitForSystemUiObject("navigation_bar_frame");
|
||||
|
||||
swipe(
|
||||
navBar.getVisibleBounds().centerX(), navBar.getVisibleBounds().centerY(),
|
||||
navBar.getVisibleBounds().centerX(), 0,
|
||||
NORMAL_STATE_ORDINAL, ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME);
|
||||
} else if (hasLauncherObject(WIDGETS_RES_ID)) {
|
||||
log(action = "0-button: from widgets");
|
||||
mDevice.pressHome();
|
||||
} else if (hasLauncherObject(APPS_RES_ID)) {
|
||||
log(action = "0-button: from all apps");
|
||||
final UiObject2 navBar = waitForSystemUiObject("navigation_bar_frame");
|
||||
|
||||
swipe(
|
||||
navBar.getVisibleBounds().centerX(), navBar.getVisibleBounds().centerY(),
|
||||
navBar.getVisibleBounds().centerX(), 0,
|
||||
NORMAL_STATE_ORDINAL, ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME);
|
||||
log(action = "already at home");
|
||||
} else {
|
||||
log(action = "0-button: from another app");
|
||||
assertTrue("Launcher is visible, don't know how to go home",
|
||||
!mDevice.hasObject(By.pkg(getLauncherPackageName())));
|
||||
final UiObject2 navBar = waitForSystemUiObject("navigation_bar_frame");
|
||||
log(action = "swiping up to home");
|
||||
final int finalState = mDevice.hasObject(By.pkg(getLauncherPackageName()))
|
||||
? NORMAL_STATE_ORDINAL : BACKGROUND_APP_STATE_ORDINAL;
|
||||
final Point displaySize = getRealDisplaySize();
|
||||
|
||||
swipe(
|
||||
navBar.getVisibleBounds().centerX(), navBar.getVisibleBounds().centerY(),
|
||||
navBar.getVisibleBounds().centerX(), 0,
|
||||
BACKGROUND_APP_STATE_ORDINAL, ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME);
|
||||
displaySize.x / 2, displaySize.y - 1,
|
||||
displaySize.x / 2, 0,
|
||||
finalState, ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME);
|
||||
}
|
||||
} else {
|
||||
log(action = "clicking home button");
|
||||
|
@ -690,4 +672,10 @@ public final class LauncherInstrumentation {
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Point getRealDisplaySize() {
|
||||
final Point size = new Point();
|
||||
getContext().getSystemService(WindowManager.class).getDefaultDisplay().getRealSize(size);
|
||||
return size;
|
||||
}
|
||||
}
|
|
@ -49,11 +49,13 @@ public final class Overview extends BaseOverview {
|
|||
"want to switch from overview to all apps")) {
|
||||
verifyActiveContainer();
|
||||
|
||||
// Swipe from navbar to the top.
|
||||
final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame");
|
||||
// Swipe from the prediction row to the top.
|
||||
LauncherInstrumentation.log("Overview.switchToAllApps before swipe");
|
||||
final int x = navBar.getVisibleCenter().x;
|
||||
mLauncher.swipe(x, navBar.getVisibleBounds().top - 1, x, 0, ALL_APPS_STATE_ORDINAL);
|
||||
final UiObject2 predictionRow = mLauncher.waitForLauncherObject("prediction_row");
|
||||
mLauncher.swipe(mLauncher.getDevice().getDisplayWidth() / 2,
|
||||
predictionRow.getVisibleBounds().centerY(),
|
||||
mLauncher.getDevice().getDisplayWidth() / 2,
|
||||
0, ALL_APPS_STATE_ORDINAL);
|
||||
|
||||
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
|
||||
"swiped all way up from overview")) {
|
||||
|
|
Loading…
Reference in New Issue