Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 1 | package com.android.launcher3.allapps; |
| 2 | |
Sunny Goyal | 0310220 | 2017-10-27 11:05:26 -0700 | [diff] [blame] | 3 | import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN; |
| 4 | import static com.android.launcher3.anim.Interpolators.LINEAR; |
Sunny Goyal | 3e3f44c | 2017-10-23 17:14:52 -0700 | [diff] [blame] | 5 | |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 6 | import android.animation.Animator; |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 7 | import android.animation.AnimatorInflater; |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 8 | import android.animation.AnimatorListenerAdapter; |
| 9 | import android.animation.AnimatorSet; |
| 10 | import android.animation.ObjectAnimator; |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 11 | import android.util.Property; |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 12 | import android.view.View; |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 13 | import android.view.animation.Interpolator; |
| 14 | |
| 15 | import com.android.launcher3.Hotseat; |
| 16 | import com.android.launcher3.Launcher; |
Sunny Goyal | f9403d9 | 2017-10-18 10:55:56 -0700 | [diff] [blame] | 17 | import com.android.launcher3.LauncherState; |
Sunny Goyal | c4fa8c3 | 2017-11-07 12:23:58 -0800 | [diff] [blame^] | 18 | import com.android.launcher3.LauncherStateManager; |
Sunny Goyal | 3e3f44c | 2017-10-23 17:14:52 -0700 | [diff] [blame] | 19 | import com.android.launcher3.LauncherStateManager.AnimationConfig; |
Hyunyoung Song | eac1dac | 2016-06-21 16:37:13 -0700 | [diff] [blame] | 20 | import com.android.launcher3.R; |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 21 | import com.android.launcher3.Utilities; |
Sunny Goyal | a92e0df | 2016-06-09 12:08:22 -0700 | [diff] [blame] | 22 | import com.android.launcher3.Workspace; |
Sunny Goyal | c4fa8c3 | 2017-11-07 12:23:58 -0800 | [diff] [blame^] | 23 | import com.android.launcher3.anim.AnimationLayerSet; |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 24 | import com.android.launcher3.anim.AnimationSuccessListener; |
Sunny Goyal | 5bc6b6f | 2017-10-26 15:36:10 -0700 | [diff] [blame] | 25 | import com.android.launcher3.anim.Interpolators; |
Mario Bertschler | 8acf8b5 | 2017-05-11 10:45:20 -0700 | [diff] [blame] | 26 | import com.android.launcher3.graphics.GradientView; |
Sunny Goyal | 8392c82 | 2017-06-20 10:03:56 -0700 | [diff] [blame] | 27 | import com.android.launcher3.util.SystemUiController; |
Sunny Goyal | 1f3f07d | 2017-02-10 16:52:16 -0800 | [diff] [blame] | 28 | import com.android.launcher3.util.Themes; |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 29 | |
| 30 | /** |
| 31 | * Handles AllApps view transition. |
| 32 | * 1) Slides all apps view using direct manipulation |
| 33 | * 2) When finger is released, animate to either top or bottom accordingly. |
Hyunyoung Song | e8a2b8e | 2016-07-14 15:09:11 -0700 | [diff] [blame] | 34 | * <p/> |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 35 | * Algorithm: |
| 36 | * If release velocity > THRES1, snap according to the direction of movement. |
| 37 | * If release velocity < THRES1, snap according to either top or bottom depending on whether it's |
Hyunyoung Song | e8a2b8e | 2016-07-14 15:09:11 -0700 | [diff] [blame] | 38 | * closer to top or closer to the page indicator. |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 39 | */ |
Sunny Goyal | c4fa8c3 | 2017-11-07 12:23:58 -0800 | [diff] [blame^] | 40 | public class AllAppsTransitionController |
| 41 | implements SearchUiManager.OnScrollRangeChangeListener, LauncherStateManager.StateHandler { |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 42 | |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 43 | private static final Property<AllAppsTransitionController, Float> PROGRESS = |
| 44 | new Property<AllAppsTransitionController, Float>(Float.class, "progress") { |
| 45 | |
| 46 | @Override |
| 47 | public Float get(AllAppsTransitionController controller) { |
| 48 | return controller.mProgress; |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public void set(AllAppsTransitionController controller, Float progress) { |
| 53 | controller.setProgress(progress); |
| 54 | } |
| 55 | }; |
| 56 | |
Sunny Goyal | 5bc6b6f | 2017-10-26 15:36:10 -0700 | [diff] [blame] | 57 | private final Interpolator mWorkspaceAccelnterpolator = Interpolators.ACCEL_2; |
| 58 | private final Interpolator mHotseatAccelInterpolator = Interpolators.ACCEL_1_5; |
Hyunyoung Song | 74b5af3 | 2016-06-08 16:29:32 -0700 | [diff] [blame] | 59 | |
Hyunyoung Song | a9a8a42 | 2016-06-15 16:45:48 -0700 | [diff] [blame] | 60 | private static final float PARALLAX_COEFFICIENT = .125f; |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 61 | |
| 62 | private AllAppsContainerView mAppsView; |
Sunny Goyal | a92e0df | 2016-06-09 12:08:22 -0700 | [diff] [blame] | 63 | private Workspace mWorkspace; |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 64 | private Hotseat mHotseat; |
Hyunyoung Song | a0c5647 | 2016-06-20 13:54:42 -0700 | [diff] [blame] | 65 | |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 66 | private final Launcher mLauncher; |
Sunny Goyal | 368ae77 | 2017-05-24 13:19:15 -0700 | [diff] [blame] | 67 | private final boolean mIsDarkTheme; |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 68 | |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 69 | // Animation in this class is controlled by a single variable {@link mProgress}. |
| 70 | // Visually, it represents top y coordinate of the all apps container if multiplied with |
| 71 | // {@link mShiftRange}. |
| 72 | |
| 73 | // When {@link mProgress} is 0, all apps container is pulled up. |
| 74 | // When {@link mProgress} is 1, all apps container is pulled down. |
Hyunyoung Song | eac1dac | 2016-06-21 16:37:13 -0700 | [diff] [blame] | 75 | private float mShiftRange; // changes depending on the orientation |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 76 | private float mProgress; // [0, 1], mShiftRange * mProgress = shiftCurrent |
Hyunyoung Song | eac1dac | 2016-06-21 16:37:13 -0700 | [diff] [blame] | 77 | |
Hyunyoung Song | 2359a68 | 2016-07-07 15:57:42 -0700 | [diff] [blame] | 78 | private static final float DEFAULT_SHIFT_RANGE = 10; |
| 79 | |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 80 | private boolean mIsTranslateWithoutWorkspace = false; |
Sunny Goyal | e18d3f5 | 2017-08-24 13:33:47 -0700 | [diff] [blame] | 81 | private Animator mDiscoBounceAnimation; |
Mario Bertschler | 8acf8b5 | 2017-05-11 10:45:20 -0700 | [diff] [blame] | 82 | private GradientView mGradientView; |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 83 | |
| 84 | public AllAppsTransitionController(Launcher l) { |
| 85 | mLauncher = l; |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 86 | mShiftRange = DEFAULT_SHIFT_RANGE; |
| 87 | mProgress = 1f; |
Peter Schiller | a30b51c | 2016-07-13 14:04:13 -0700 | [diff] [blame] | 88 | |
Mario Bertschler | a693694 | 2017-05-31 14:48:19 -0700 | [diff] [blame] | 89 | mIsDarkTheme = Themes.getAttrBoolean(mLauncher, R.attr.isMainColorDark); |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Sunny Goyal | 0310220 | 2017-10-27 11:05:26 -0700 | [diff] [blame] | 92 | public float getShiftRange() { |
| 93 | return mShiftRange; |
Hyunyoung Song | 9dcf0a3 | 2016-07-27 10:55:51 -0700 | [diff] [blame] | 94 | } |
Hyunyoung Song | e3876e8 | 2016-07-27 11:54:02 -0700 | [diff] [blame] | 95 | |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 96 | private void onProgressAnimationStart() { |
| 97 | // Initialize values that should not change until #onDragEnd |
| 98 | mHotseat.setVisibility(View.VISIBLE); |
| 99 | mAppsView.setVisibility(View.VISIBLE); |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 102 | private void updateLightStatusBar(float shift) { |
Sunny Goyal | 8392c82 | 2017-06-20 10:03:56 -0700 | [diff] [blame] | 103 | // Use a light system UI (dark icons) if all apps is behind at least half of the status bar. |
Sunny Goyal | f2dd421 | 2017-09-28 11:31:39 -0700 | [diff] [blame] | 104 | boolean forceChange = shift <= mShiftRange / 4; |
Sunny Goyal | 8392c82 | 2017-06-20 10:03:56 -0700 | [diff] [blame] | 105 | if (forceChange) { |
| 106 | mLauncher.getSystemUiController().updateUiState( |
| 107 | SystemUiController.UI_STATE_ALL_APPS, !mIsDarkTheme); |
| 108 | } else { |
| 109 | mLauncher.getSystemUiController().updateUiState( |
| 110 | SystemUiController.UI_STATE_ALL_APPS, 0); |
| 111 | } |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 112 | } |
| 113 | |
Mario Bertschler | 48198d0 | 2017-01-30 17:05:24 -0800 | [diff] [blame] | 114 | private void updateAllAppsBg(float progress) { |
| 115 | // gradient |
| 116 | if (mGradientView == null) { |
Sunny Goyal | d66e3b6 | 2017-10-02 15:26:42 -0700 | [diff] [blame] | 117 | mGradientView = mLauncher.findViewById(R.id.gradient_bg); |
Mario Bertschler | 48198d0 | 2017-01-30 17:05:24 -0800 | [diff] [blame] | 118 | } |
| 119 | mGradientView.setProgress(progress); |
Mario Bertschler | 48198d0 | 2017-01-30 17:05:24 -0800 | [diff] [blame] | 120 | } |
| 121 | |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 122 | /** |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 123 | * Note this method should not be called outside this class. This is public because it is used |
| 124 | * in xml-based animations which also handle updating the appropriate UI. |
| 125 | * |
| 126 | * @param progress value between 0 and 1, 0 shows all apps and 1 shows workspace |
| 127 | * |
Sunny Goyal | c4fa8c3 | 2017-11-07 12:23:58 -0800 | [diff] [blame^] | 128 | * @see #setState(LauncherState) |
| 129 | * @see #setStateWithAnimation(LauncherState, AnimationLayerSet, AnimatorSet, AnimationConfig) |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 130 | */ |
| 131 | public void setProgress(float progress) { |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 132 | mProgress = progress; |
| 133 | float shiftCurrent = progress * mShiftRange; |
| 134 | |
| 135 | float workspaceHotseatAlpha = Utilities.boundToRange(progress, 0f, 1f); |
| 136 | float alpha = 1 - workspaceHotseatAlpha; |
Mario Bertschler | 8acf8b5 | 2017-05-11 10:45:20 -0700 | [diff] [blame] | 137 | float workspaceAlpha = mWorkspaceAccelnterpolator.getInterpolation(workspaceHotseatAlpha); |
| 138 | float hotseatAlpha = mHotseatAccelInterpolator.getInterpolation(workspaceHotseatAlpha); |
Hyunyoung Song | 74b5af3 | 2016-06-08 16:29:32 -0700 | [diff] [blame] | 139 | |
Sunny Goyal | f2dd421 | 2017-09-28 11:31:39 -0700 | [diff] [blame] | 140 | updateAllAppsBg(alpha); |
Sunny Goyal | f1fbc3f | 2017-10-10 15:21:15 -0700 | [diff] [blame] | 141 | mAppsView.setAlpha(alpha); |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 142 | mAppsView.setTranslationY(shiftCurrent); |
| 143 | |
| 144 | if (!mLauncher.getDeviceProfile().isVerticalBarLayout()) { |
| 145 | mWorkspace.setHotseatTranslationAndAlpha(Workspace.Direction.Y, -mShiftRange + shiftCurrent, |
Mario Bertschler | 8acf8b5 | 2017-05-11 10:45:20 -0700 | [diff] [blame] | 146 | hotseatAlpha); |
Hyunyoung Song | eac1dac | 2016-06-21 16:37:13 -0700 | [diff] [blame] | 147 | } else { |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 148 | mWorkspace.setHotseatTranslationAndAlpha(Workspace.Direction.Y, |
| 149 | PARALLAX_COEFFICIENT * (-mShiftRange + shiftCurrent), |
Mario Bertschler | 8acf8b5 | 2017-05-11 10:45:20 -0700 | [diff] [blame] | 150 | hotseatAlpha); |
Hyunyoung Song | eac1dac | 2016-06-21 16:37:13 -0700 | [diff] [blame] | 151 | } |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 152 | |
| 153 | if (mIsTranslateWithoutWorkspace) { |
| 154 | return; |
| 155 | } |
| 156 | mWorkspace.setWorkspaceYTranslationAndAlpha( |
Mario Bertschler | 8acf8b5 | 2017-05-11 10:45:20 -0700 | [diff] [blame] | 157 | PARALLAX_COEFFICIENT * (-mShiftRange + shiftCurrent), workspaceAlpha); |
Hyunyoung Song | 5b64706 | 2016-08-02 13:31:22 -0700 | [diff] [blame] | 158 | |
Peter Schiller | e6fe1b5 | 2016-07-29 17:05:30 -0700 | [diff] [blame] | 159 | updateLightStatusBar(shiftCurrent); |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | public float getProgress() { |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 163 | return mProgress; |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 164 | } |
| 165 | |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 166 | /** |
Sunny Goyal | c4fa8c3 | 2017-11-07 12:23:58 -0800 | [diff] [blame^] | 167 | * Sets the vertical transition progress to {@param state} and updates all the dependent UI |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 168 | * accordingly. |
| 169 | */ |
Sunny Goyal | c4fa8c3 | 2017-11-07 12:23:58 -0800 | [diff] [blame^] | 170 | @Override |
| 171 | public void setState(LauncherState state) { |
| 172 | setProgress(state.verticalProgress); |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 173 | onProgressAnimationEnd(); |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * Creates an animation which updates the vertical transition progress and updates all the |
| 178 | * dependent UI using various animation events |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 179 | */ |
Sunny Goyal | c4fa8c3 | 2017-11-07 12:23:58 -0800 | [diff] [blame^] | 180 | @Override |
| 181 | public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews, |
| 182 | AnimatorSet animationOut, AnimationConfig config) { |
| 183 | if (Float.compare(mProgress, toState.verticalProgress) == 0) { |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 184 | // Fail fast |
| 185 | onProgressAnimationEnd(); |
Sunny Goyal | aeb1643 | 2017-10-16 11:46:41 -0700 | [diff] [blame] | 186 | return; |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 187 | } |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 188 | |
Sunny Goyal | c4fa8c3 | 2017-11-07 12:23:58 -0800 | [diff] [blame^] | 189 | Interpolator interpolator = config.userControlled ? LINEAR : FAST_OUT_SLOW_IN; |
| 190 | ObjectAnimator anim = ObjectAnimator.ofFloat( |
| 191 | this, PROGRESS, mProgress, toState.verticalProgress); |
| 192 | anim.setDuration(config.duration); |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 193 | anim.setInterpolator(interpolator); |
| 194 | anim.addListener(new AnimationSuccessListener() { |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 195 | @Override |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 196 | public void onAnimationSuccess(Animator animator) { |
| 197 | onProgressAnimationEnd(); |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 198 | } |
Hyunyoung Song | e8a2b8e | 2016-07-14 15:09:11 -0700 | [diff] [blame] | 199 | |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 200 | @Override |
Jon Miranda | 610af37 | 2017-09-05 11:32:13 -0700 | [diff] [blame] | 201 | public void onAnimationStart(Animator animation) { |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 202 | onProgressAnimationStart(); |
Hyunyoung Song | e8a2b8e | 2016-07-14 15:09:11 -0700 | [diff] [blame] | 203 | } |
| 204 | }); |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 205 | |
| 206 | animationOut.play(anim); |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 207 | } |
| 208 | |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 209 | public void showDiscoveryBounce() { |
| 210 | // cancel existing animation in case user locked and unlocked at a super human speed. |
| 211 | cancelDiscoveryAnimation(); |
| 212 | |
| 213 | // assumption is that this variable is always null |
Sunny Goyal | e18d3f5 | 2017-08-24 13:33:47 -0700 | [diff] [blame] | 214 | mDiscoBounceAnimation = AnimatorInflater.loadAnimator(mLauncher, |
| 215 | R.animator.discovery_bounce); |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 216 | mDiscoBounceAnimation.addListener(new AnimatorListenerAdapter() { |
| 217 | @Override |
| 218 | public void onAnimationStart(Animator animator) { |
| 219 | mIsTranslateWithoutWorkspace = true; |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 220 | onProgressAnimationStart(); |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | @Override |
| 224 | public void onAnimationEnd(Animator animator) { |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 225 | onProgressAnimationEnd(); |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 226 | mDiscoBounceAnimation = null; |
| 227 | mIsTranslateWithoutWorkspace = false; |
| 228 | } |
| 229 | }); |
| 230 | mDiscoBounceAnimation.setTarget(this); |
| 231 | mAppsView.post(new Runnable() { |
| 232 | @Override |
| 233 | public void run() { |
Hyunyoung Song | e688e1e | 2016-08-03 10:40:18 -0700 | [diff] [blame] | 234 | if (mDiscoBounceAnimation == null) { |
| 235 | return; |
| 236 | } |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 237 | mDiscoBounceAnimation.start(); |
| 238 | } |
| 239 | }); |
| 240 | } |
| 241 | |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 242 | public void cancelDiscoveryAnimation() { |
| 243 | if (mDiscoBounceAnimation == null) { |
| 244 | return; |
| 245 | } |
| 246 | mDiscoBounceAnimation.cancel(); |
| 247 | mDiscoBounceAnimation = null; |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 248 | } |
| 249 | |
Hyunyoung Song | a0c5647 | 2016-06-20 13:54:42 -0700 | [diff] [blame] | 250 | public void setupViews(AllAppsContainerView appsView, Hotseat hotseat, Workspace workspace) { |
| 251 | mAppsView = appsView; |
| 252 | mHotseat = hotseat; |
| 253 | mWorkspace = workspace; |
Hyunyoung Song | dd60ce4 | 2016-07-27 17:08:38 -0700 | [diff] [blame] | 254 | mHotseat.bringToFront(); |
Sunny Goyal | dc19a07 | 2017-05-12 08:17:35 -0700 | [diff] [blame] | 255 | mAppsView.getSearchUiManager().addOnScrollRangeChangeListener(this); |
Hyunyoung Song | 5215b54 | 2016-06-29 21:25:33 -0700 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | @Override |
Sunny Goyal | dc19a07 | 2017-05-12 08:17:35 -0700 | [diff] [blame] | 259 | public void onScrollRangeChanged(int scrollRange) { |
| 260 | mShiftRange = scrollRange; |
Hyunyoung Song | c001cf5 | 2016-07-21 17:32:43 -0700 | [diff] [blame] | 261 | setProgress(mProgress); |
Hyunyoung Song | a0c5647 | 2016-06-20 13:54:42 -0700 | [diff] [blame] | 262 | } |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 263 | |
| 264 | /** |
| 265 | * Set the final view states based on the progress. |
| 266 | * TODO: This logic should go in {@link LauncherState} |
| 267 | */ |
| 268 | private void onProgressAnimationEnd() { |
| 269 | if (Float.compare(mProgress, 1f) == 0) { |
| 270 | mAppsView.setVisibility(View.INVISIBLE); |
| 271 | mHotseat.setVisibility(View.VISIBLE); |
| 272 | mAppsView.reset(); |
| 273 | } else if (Float.compare(mProgress, 0f) == 0) { |
| 274 | mHotseat.setVisibility(View.INVISIBLE); |
| 275 | mAppsView.setVisibility(View.VISIBLE); |
| 276 | } |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 277 | } |
Hyunyoung Song | 645764e | 2016-06-06 14:19:02 -0700 | [diff] [blame] | 278 | } |