diff options
author | Tony <twickham@google.com> | 2019-06-14 20:26:12 -0700 |
---|---|---|
committer | Tony Wickham <twickham@google.com> | 2019-06-18 13:41:08 -0700 |
commit | 32cb616fab1ad495968d1eadd503a61b8bf3db35 (patch) | |
tree | c34099791eaea36a725233b55d054e8f5b0efe8f | |
parent | e1abaa64c25fdc9841f5cbeff2647ff4f95ac255 (diff) | |
download | packages_apps_Trebuchet-32cb616fab1ad495968d1eadd503a61b8bf3db35.tar.gz packages_apps_Trebuchet-32cb616fab1ad495968d1eadd503a61b8bf3db35.tar.bz2 packages_apps_Trebuchet-32cb616fab1ad495968d1eadd503a61b8bf3db35.zip |
Fix bugs with hotseat in overview
- Allow touches to go through recents to the hotseat.
- Translate the hotseat with the all apps shelf when swiping
up in background app state.
Bug: 135222111
Change-Id: Ib887fc25ccfeb406a44074198c11f7b1d245443c
7 files changed, 65 insertions, 6 deletions
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java index 1c6696858..d14de70c5 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java @@ -83,4 +83,16 @@ public class BackgroundAppState extends OverviewState { public int getVisibleElements(Launcher launcher) { return super.getVisibleElements(launcher) & ~RECENTS_CLEAR_ALL_BUTTON; } + + @Override + public ScaleAndTranslation getHotseatScaleAndTranslation(Launcher launcher) { + if ((getVisibleElements(launcher) & HOTSEAT_ICONS) != 0) { + // Translate hotseat offscreen if we show it in overview. + ScaleAndTranslation scaleAndTranslation = super.getHotseatScaleAndTranslation(launcher); + scaleAndTranslation.translationY = LayoutUtils.getShelfTrackingDistance(launcher, + launcher.getDeviceProfile()); + return scaleAndTranslation; + } + return super.getHotseatScaleAndTranslation(launcher); + } } diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java index 9a99c1552..5c9b20096 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java @@ -127,6 +127,10 @@ public class OverviewState extends LauncherState { // We have no all apps content, so we're still at the fully down progress. return super.getVerticalProgress(launcher); } + return getDefaultVerticalProgress(launcher); + } + + public static float getDefaultVerticalProgress(Launcher launcher) { return 1 - (getDefaultSwipeHeight(launcher) / launcher.getAllAppsController().getShiftRange()); } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java index 0d06c19ab..e7d085ca1 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java @@ -16,7 +16,6 @@ package com.android.quickstep; import static android.view.View.TRANSLATION_Y; - import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.LauncherState.BACKGROUND_APP; import static com.android.launcher3.LauncherState.NORMAL; @@ -62,6 +61,7 @@ import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.AnimatorSetBuilder; import com.android.launcher3.anim.SpringObjectAnimator; import com.android.launcher3.testing.TestProtocol; +import com.android.launcher3.uioverrides.states.OverviewState; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.views.FloatingIconView; import com.android.quickstep.SysUINavigationMode.Mode; @@ -260,8 +260,11 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe } float shelfHiddenProgress = BACKGROUND_APP.getVerticalProgress(activity); float shelfOverviewProgress = OVERVIEW.getVerticalProgress(activity); + // Peek based on default overview progress so we can see hotseat if we're showing + // that instead of predictions in overview. + float defaultOverviewProgress = OverviewState.getDefaultVerticalProgress(activity); float shelfPeekingProgress = shelfHiddenProgress - - (shelfHiddenProgress - shelfOverviewProgress) * 0.25f; + - (shelfHiddenProgress - defaultOverviewProgress) * 0.25f; float toProgress = mShelfState == ShelfAnimState.HIDE ? shelfHiddenProgress : mShelfState == ShelfAnimState.PEEK diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java index 5b2e27e53..03441c87e 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java @@ -33,9 +33,11 @@ import android.graphics.Canvas; import android.graphics.Rect; import android.os.Build; import android.util.AttributeSet; +import android.view.MotionEvent; import android.view.View; import com.android.launcher3.DeviceProfile; +import com.android.launcher3.Hotseat; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.LauncherStateManager.StateListener; @@ -250,4 +252,16 @@ public class LauncherRecentsView extends RecentsView<Launcher> implements StateL setDisallowScrollToClearAll(!hasClearAllButton); } } + + @Override + protected boolean shouldStealTouchFromSiblingsBelow(MotionEvent ev) { + if (ev.getAction() == MotionEvent.ACTION_DOWN) { + // Allow touches to go through to the hotseat. + Hotseat hotseat = mActivity.getHotseat(); + boolean touchingHotseat = hotseat.isShown() + && mActivity.getDragLayer().isEventOverView(hotseat, ev, this); + return !touchingHotseat; + } + return super.shouldStealTouchFromSiblingsBelow(ev); + } } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java index 9058e7eda..a8987a3d4 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java @@ -521,6 +521,10 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl // Do not let touch escape to siblings below this view. + return isHandlingTouch() || shouldStealTouchFromSiblingsBelow(ev); + } + + protected boolean shouldStealTouchFromSiblingsBelow(MotionEvent ev) { return true; } diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index c62fc3d8f..a351b9ae1 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -2,6 +2,8 @@ package com.android.launcher3.allapps; import static com.android.launcher3.LauncherState.ALL_APPS_CONTENT; import static com.android.launcher3.LauncherState.ALL_APPS_HEADER_EXTRA; +import static com.android.launcher3.LauncherState.BACKGROUND_APP; +import static com.android.launcher3.LauncherState.HOTSEAT_ICONS; import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.LauncherState.VERTICAL_SWIPE_INDICATOR; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_ALL_APPS_FADE; @@ -28,15 +30,12 @@ import com.android.launcher3.ProgressInterface; import com.android.launcher3.R; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorSetBuilder; -import com.android.launcher3.anim.SpringObjectAnimator; import com.android.launcher3.anim.PropertySetter; +import com.android.launcher3.anim.SpringObjectAnimator; import com.android.launcher3.testing.TestProtocol; -import com.android.launcher3.util.MultiValueAlpha; import com.android.launcher3.util.Themes; import com.android.launcher3.views.ScrimView; -import androidx.dynamicanimation.animation.FloatPropertyCompat; - /** * Handles AllApps view transition. * 1) Slides all apps view using direct manipulation @@ -139,6 +138,15 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil } else { mLauncher.getSystemUiController().updateUiState(UI_STATE_ALL_APPS, 0); } + + if ((OVERVIEW.getVisibleElements(mLauncher) & HOTSEAT_ICONS) != 0) { + // Translate hotseat with the shelf until reaching overview. + float overviewProgress = OVERVIEW.getVerticalProgress(mLauncher); + if (progress >= overviewProgress || mLauncher.isInState(BACKGROUND_APP)) { + float hotseatShift = (progress - overviewProgress) * mShiftRange; + mLauncher.getHotseat().setTranslationY(hotseatShift); + } + } } @Override diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java index ac152dbff..51c7022bd 100644 --- a/src/com/android/launcher3/views/BaseDragLayer.java +++ b/src/com/android/launcher3/views/BaseDragLayer.java @@ -116,11 +116,25 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext> mMultiValueAlpha = new MultiValueAlpha(this, alphaChannelCount); } + /** + * Same as {@link #isEventOverView(View, MotionEvent, View)} where evView == this drag layer. + */ public boolean isEventOverView(View view, MotionEvent ev) { getDescendantRectRelativeToSelf(view, mHitRect); return mHitRect.contains((int) ev.getX(), (int) ev.getY()); } + /** + * Given a motion event in evView's coordinates, return whether the event is within another + * view's bounds. + */ + public boolean isEventOverView(View view, MotionEvent ev, View evView) { + int[] xy = new int[] {(int) ev.getX(), (int) ev.getY()}; + getDescendantCoordRelativeToSelf(evView, xy); + getDescendantRectRelativeToSelf(view, mHitRect); + return mHitRect.contains(xy[0], xy[1]); + } + @Override public boolean onInterceptTouchEvent(MotionEvent ev) { int action = ev.getAction(); |