diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2017-12-12 12:02:29 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2017-12-12 12:20:23 -0800 |
commit | 0c723353a6c3cd36248a71a538717da687fc3aaf (patch) | |
tree | 841486dbde434666160badb64b54cd40a4fb1176 /quickstep | |
parent | d96072e63e6eb82542f0d585b955d03b14c2adf1 (diff) | |
download | android_packages_apps_Trebuchet-0c723353a6c3cd36248a71a538717da687fc3aaf.tar.gz android_packages_apps_Trebuchet-0c723353a6c3cd36248a71a538717da687fc3aaf.tar.bz2 android_packages_apps_Trebuchet-0c723353a6c3cd36248a71a538717da687fc3aaf.zip |
Enabling swipe up from overview to all-apps
> Fixing wrong alpha interpolator when swiping down from all-apps
Change-Id: I7d4200c89797e5609fd7c4aa8681dea2ffd00bf7
Diffstat (limited to 'quickstep')
3 files changed, 79 insertions, 2 deletions
diff --git a/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java index 106449200..a4851ba96 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java @@ -17,6 +17,7 @@ package com.android.launcher3.uioverrides; import static com.android.launcher3.LauncherAnimUtils.ALL_APPS_TRANSITION_MS; import static com.android.launcher3.allapps.DiscoveryBounce.APPS_VIEW_SHOWN; +import static com.android.launcher3.anim.Interpolators.DEACCEL_2; import android.view.View; @@ -33,6 +34,13 @@ public class AllAppsState extends LauncherState { private static final int STATE_FLAGS = FLAG_DISABLE_ACCESSIBILITY; + private static final PageAlphaProvider PAGE_ALPHA_PROVIDER = new PageAlphaProvider(DEACCEL_2) { + @Override + public float getPageAlpha(int pageIndex) { + return 0; + } + }; + public AllAppsState(int id) { super(id, ContainerType.ALLAPPS, ALL_APPS_TRANSITION_MS, 0f, STATE_FLAGS); } @@ -65,6 +73,6 @@ public class AllAppsState extends LauncherState { @Override public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) { - return (i) -> 0; + return PAGE_ALPHA_PROVIDER; } } diff --git a/quickstep/src/com/android/launcher3/uioverrides/OverviewSwipeUpController.java b/quickstep/src/com/android/launcher3/uioverrides/OverviewSwipeUpController.java new file mode 100644 index 000000000..92f89f6a1 --- /dev/null +++ b/quickstep/src/com/android/launcher3/uioverrides/OverviewSwipeUpController.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.launcher3.uioverrides; + +import static com.android.launcher3.LauncherState.OVERVIEW; + +import android.view.MotionEvent; + +import com.android.launcher3.Launcher; +import com.android.launcher3.touch.SwipeDetector; +import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; +import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; +import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; +import com.android.launcher3.util.VerticalSwipeController; + +/** + * Extension of {@link VerticalSwipeController} which allows swipe up from OVERVIEW to ALL_APPS + * Note that the swipe down is handled by {@link TwoStepSwipeController}. + */ +public class OverviewSwipeUpController extends VerticalSwipeController { + + public OverviewSwipeUpController(Launcher l) { + super(l, OVERVIEW); + } + + @Override + protected boolean shouldInterceptTouch(MotionEvent ev) { + return mLauncher.isInState(OVERVIEW) && mLauncher.getDragLayer().isEventOverHotseat(ev); + } + + @Override + protected int getSwipeDirection(MotionEvent ev) { + return SwipeDetector.DIRECTION_POSITIVE; + } + + @Override + protected void onTransitionComplete(boolean wasFling, boolean stateChanged) { + if (stateChanged) { + // Transition complete. log the action + mLauncher.getUserEventDispatcher().logActionOnContainer( + wasFling ? Touch.FLING : Touch.SWIPE, + Direction.UP, + ContainerType.OVERVIEW, + mLauncher.getWorkspace().getCurrentPage()); + } + + } +} diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java index 5e280b696..9178d8ad4 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java +++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java @@ -30,7 +30,15 @@ import com.android.launcher3.widget.WidgetsFullSheet; public class UiFactory { public static TouchController[] createTouchControllers(Launcher launcher) { - return new TouchController[] {new TwoStepSwipeController(launcher)}; + + if (launcher.getDeviceProfile().isVerticalBarLayout()) { + // TODO: Allow swipe up from overview in transposed layout + return new TouchController[] {new TwoStepSwipeController(launcher)}; + } else { + return new TouchController[] { + new TwoStepSwipeController(launcher), + new OverviewSwipeUpController(launcher)}; + } } public static AccessibilityDelegate newPageIndicatorAccessibilityDelegate() { |