diff options
Diffstat (limited to 'src/com/android/launcher3/allapps')
4 files changed, 39 insertions, 3 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index ba4fbe061..1f60fcc73 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -448,9 +448,20 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter. row = Math.abs(numTotalRows - row); } - // We manipulate the stiffness, min, and max values based on the items distance to the - // first row and the items distance to the center column to create the ^-shaped motion - // effect. + calculateSpringValues(spring, row, col); + } + + @Override + public void setDefaultValues(SpringAnimation spring) { + calculateSpringValues(spring, 0, mAppsPerRow / 2); + } + + /** + * We manipulate the stiffness, min, and max values based on the items distance to the + * first row and the items distance to the center column to create the ^-shaped motion + * effect. + */ + private void calculateSpringValues(SpringAnimation spring, int row, int col) { float rowFactor = (1 + row) * 0.5f; float colFactor = getColumnFactor(col, mAppsPerRow); diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index edfe0c15e..a1f2dd7e3 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -7,6 +7,7 @@ import android.animation.AnimatorSet; import android.animation.ArgbEvaluator; import android.animation.ObjectAnimator; import android.graphics.Color; +import android.support.animation.SpringAnimation; import android.support.v4.graphics.ColorUtils; import android.support.v4.view.animation.FastOutSlowInInterpolator; import android.view.MotionEvent; @@ -101,6 +102,7 @@ public class AllAppsTransitionController implements TouchController, SwipeDetect private AnimatorSet mDiscoBounceAnimation; private GradientView mGradientView; + private SpringAnimation mSearchSpring; private SpringAnimationHandler mSpringAnimationHandler; public AllAppsTransitionController(Launcher l) { @@ -226,6 +228,7 @@ public class AllAppsTransitionController implements TouchController, SwipeDetect } mLauncher.showAppsView(true /* animated */, false /* updatePredictedApps */); if (hasSpringAnimationHandler()) { + mSpringAnimationHandler.add(mSearchSpring, true /* setDefaultValues */); // The icons are moving upwards, so we go to 0 from 1. (y-axis 1 is below 0.) mSpringAnimationHandler.animateToFinalPosition(0 /* pos */, 1 /* startValue */); } @@ -499,6 +502,7 @@ public class AllAppsTransitionController implements TouchController, SwipeDetect public void finishPullUp() { mHotseat.setVisibility(View.INVISIBLE); if (hasSpringAnimationHandler()) { + mSpringAnimationHandler.remove(mSearchSpring); mSpringAnimationHandler.reset(); } setProgress(0f); @@ -544,6 +548,7 @@ public class AllAppsTransitionController implements TouchController, SwipeDetect mWorkspace.getPageIndicator().getCaretDrawable(), mLauncher); mAppsView.getSearchUiManager().addOnScrollRangeChangeListener(this); mSpringAnimationHandler = mAppsView.getSpringAnimationHandler(); + mSearchSpring = mAppsView.getSearchUiManager().getSpringForFling(); } private boolean hasSpringAnimationHandler() { diff --git a/src/com/android/launcher3/allapps/SearchUiManager.java b/src/com/android/launcher3/allapps/SearchUiManager.java index c0d78508f..34230e046 100644 --- a/src/com/android/launcher3/allapps/SearchUiManager.java +++ b/src/com/android/launcher3/allapps/SearchUiManager.java @@ -15,6 +15,8 @@ */ package com.android.launcher3.allapps; +import android.support.animation.SpringAnimation; +import android.support.annotation.NonNull; import android.view.KeyEvent; /** @@ -28,6 +30,11 @@ public interface SearchUiManager { void initialize(AlphabeticalAppsList appsList, AllAppsRecyclerView recyclerView); /** + * A {@link SpringAnimation} that will be used when the user flings. + */ + @NonNull SpringAnimation getSpringForFling(); + + /** * Notifies the search manager that the apps-list has changed and the search UI should be * updated accordingly. */ diff --git a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java index d50455171..ddf6e5849 100644 --- a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java +++ b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java @@ -17,6 +17,9 @@ package com.android.launcher3.allapps.search; import android.content.Context; import android.graphics.Rect; +import android.support.animation.FloatValueHolder; +import android.support.animation.SpringAnimation; +import android.support.animation.SpringForce; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.text.Selection; @@ -62,6 +65,8 @@ public class AppsSearchContainerLayout extends FrameLayout private View mDivider; private HeaderElevationController mElevationController; + private SpringAnimation mSpring; + public AppsSearchContainerLayout(Context context) { this(context, null); } @@ -81,6 +86,9 @@ public class AppsSearchContainerLayout extends FrameLayout mSearchQueryBuilder = new SpannableStringBuilder(); Selection.setSelection(mSearchQueryBuilder, 0); + + // Note: This spring does nothing. + mSpring = new SpringAnimation(new FloatValueHolder()).setSpring(new SpringForce(0)); } @Override @@ -127,6 +135,11 @@ public class AppsSearchContainerLayout extends FrameLayout } @Override + public @NonNull SpringAnimation getSpringForFling() { + return mSpring; + } + + @Override public void refreshSearchResult() { mSearchBarController.refreshSearchResult(); } |