Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a761a0d5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Stop using magic constant 0.1 for switching from home to all apps" into ub-launcher3-master

parents 7b43eba7 174a330d
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -71,6 +71,9 @@ public class TestInformationProvider extends ContentProvider {
            final Context context = getContext();
            final DeviceProfile deviceProfile = InvariantDeviceProfile.INSTANCE.
                    get(context).getDeviceProfile(context);
            final LauncherAppState launcherAppState = LauncherAppState.getInstanceNoCreate();
            final Launcher launcher = launcherAppState != null ?
                    (Launcher) launcherAppState.getModel().getCallback() : null;

            switch (method) {
                case TestProtocol.REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT: {
@@ -79,18 +82,15 @@ public class TestInformationProvider extends ContentProvider {
                    response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
                    break;
                }

                case TestProtocol.REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT: {
                    final float swipeHeight =
                            LayoutUtils.getShelfTrackingDistance(context, deviceProfile);
                    response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
                    break;
                }
                case TestProtocol.REQUEST_ALL_APPS_TO_OVERVIEW_SWIPE_HEIGHT: {
                    final LauncherAppState launcherAppState =
                            LauncherAppState.getInstanceNoCreate();
                    if (launcherAppState == null) return null;

                    final Launcher launcher = (Launcher) launcherAppState.getModel().getCallback();
                case TestProtocol.REQUEST_ALL_APPS_TO_OVERVIEW_SWIPE_HEIGHT: {
                    if (launcher == null) return null;

                    final float progress = LauncherState.OVERVIEW.getVerticalProgress(launcher)
@@ -100,6 +100,17 @@ public class TestInformationProvider extends ContentProvider {
                    response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) distance);
                    break;
                }

                case TestProtocol.REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT: {
                    if (launcher == null) return null;

                    final float progress = LauncherState.NORMAL.getVerticalProgress(launcher)
                            - LauncherState.ALL_APPS.getVerticalProgress(launcher);
                    final float distance =
                            launcher.getAllAppsController().getShiftRange() * progress;
                    response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) distance);
                    break;
                }
            }
            return response;
        }
+2 −0
Original line number Diff line number Diff line
@@ -38,4 +38,6 @@ public final class TestProtocol {
            "background-to-overview-swipe-height";
    public static final String REQUEST_ALL_APPS_TO_OVERVIEW_SWIPE_HEIGHT =
            "all-apps-to-overview-swipe-height";
    public static final String REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT =
            "home-to-all-apps-swipe-height";
}
+4 −3
Original line number Diff line number Diff line
@@ -51,15 +51,16 @@ public final class Workspace extends Home {
    @NonNull
    public AllApps switchToAllApps() {
        verifyActiveContainer();
        // Swipe from the hotseat to near the top, e.g. 10% of the screen.
        final UiObject2 hotseat = mHotseat;
        final Point start = hotseat.getVisibleCenter();
        final int endY = (int) (mLauncher.getDevice().getDisplayHeight() * 0.1f);
        final int swipeHeight = mLauncher.getTestInfo(
                TestProtocol.REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT).
                getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
        mLauncher.swipe(
                start.x,
                start.y,
                start.x,
                endY,
                start.y - swipeHeight - mLauncher.getTouchSlop(),
                ALL_APPS_STATE_ORDINAL
        );