diff --git a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java index abf99e4..fdd4897 100644 --- a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java +++ b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java @@ -113,6 +113,7 @@ import acr.browser.lightning.dialog.BrowserDialog; import acr.browser.lightning.dialog.LightningDialogBuilder; import acr.browser.lightning.fragment.BookmarksFragment; import acr.browser.lightning.fragment.TabsFragment; +import acr.browser.lightning.interpolator.BezierDecelerateInterpolator; import acr.browser.lightning.receiver.NetworkReceiver; import acr.browser.lightning.search.Suggestions; import acr.browser.lightning.utils.DrawableUtils; @@ -1932,7 +1933,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements } }; show.setDuration(250); - show.setInterpolator(new DecelerateInterpolator()); + show.setInterpolator(new BezierDecelerateInterpolator()); mBrowserFrame.startAnimation(show); } } @@ -1971,7 +1972,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements } }; show.setDuration(250); - show.setInterpolator(new DecelerateInterpolator()); + show.setInterpolator(new BezierDecelerateInterpolator()); mBrowserFrame.startAnimation(show); } } diff --git a/app/src/main/java/acr/browser/lightning/fragment/anim/HorizontalItemAnimator.java b/app/src/main/java/acr/browser/lightning/fragment/anim/HorizontalItemAnimator.java index 0fa4838..c16e41f 100644 --- a/app/src/main/java/acr/browser/lightning/fragment/anim/HorizontalItemAnimator.java +++ b/app/src/main/java/acr/browser/lightning/fragment/anim/HorizontalItemAnimator.java @@ -29,6 +29,8 @@ import android.view.animation.DecelerateInterpolator; import java.util.ArrayList; import java.util.List; +import acr.browser.lightning.interpolator.BezierDecelerateInterpolator; + /** * This implementation of {@link RecyclerView.ItemAnimator} provides basic * animations on remove, add, and move events that happen to the items in @@ -235,7 +237,7 @@ public class HorizontalItemAnimator extends SimpleItemAnimator { final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view); mAddAnimations.add(holder); animation.alpha(1).translationY(0) - .setInterpolator(new DecelerateInterpolator()).setDuration(getAddDuration()) + .setInterpolator(new BezierDecelerateInterpolator()).setDuration(getAddDuration()) .setListener(new VpaListenerAdapter() { @Override public void onAnimationStart(View view) { diff --git a/app/src/main/java/acr/browser/lightning/fragment/anim/VerticalItemAnimator.java b/app/src/main/java/acr/browser/lightning/fragment/anim/VerticalItemAnimator.java index b6ee56e..7352550 100644 --- a/app/src/main/java/acr/browser/lightning/fragment/anim/VerticalItemAnimator.java +++ b/app/src/main/java/acr/browser/lightning/fragment/anim/VerticalItemAnimator.java @@ -29,6 +29,8 @@ import android.view.animation.DecelerateInterpolator; import java.util.ArrayList; import java.util.List; +import acr.browser.lightning.interpolator.BezierDecelerateInterpolator; + /** * This implementation of {@link RecyclerView.ItemAnimator} provides basic * animations on remove, add, and move events that happen to the items in @@ -235,7 +237,7 @@ public class VerticalItemAnimator extends SimpleItemAnimator { final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view); mAddAnimations.add(holder); animation.alpha(1).translationX(0).setDuration(getAddDuration()) - .setInterpolator(new DecelerateInterpolator()).setListener(new VpaListenerAdapter() { + .setInterpolator(new BezierDecelerateInterpolator()).setListener(new VpaListenerAdapter() { @Override public void onAnimationStart(View view) { dispatchAddStarting(holder); diff --git a/app/src/main/java/acr/browser/lightning/interpolator/BezierDecelerateInterpolator.java b/app/src/main/java/acr/browser/lightning/interpolator/BezierDecelerateInterpolator.java new file mode 100644 index 0000000..5ee0a3e --- /dev/null +++ b/app/src/main/java/acr/browser/lightning/interpolator/BezierDecelerateInterpolator.java @@ -0,0 +1,31 @@ +package acr.browser.lightning.interpolator; + +import android.os.Build; +import android.support.annotation.NonNull; +import android.view.animation.DecelerateInterpolator; +import android.view.animation.Interpolator; +import android.view.animation.PathInterpolator; + +/** + * Bezier decelerate curve similar to iOS. + * On Kitkat and below, it reverts to a + * decelerate interpolator. + */ +public class BezierDecelerateInterpolator implements Interpolator { + + @NonNull + private static final Interpolator PATH_INTERPOLATOR; + + static { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + PATH_INTERPOLATOR = new PathInterpolator(0.25f, 0.1f, 0.25f, 1); + } else { + PATH_INTERPOLATOR = new DecelerateInterpolator(); + } + } + + @Override + public float getInterpolation(float input) { + return PATH_INTERPOLATOR.getInterpolation(input); + } +} diff --git a/app/src/main/res/anim-v21/bezier_decelerate.xml b/app/src/main/res/anim-v21/bezier_decelerate.xml new file mode 100644 index 0000000..b528d2d --- /dev/null +++ b/app/src/main/res/anim-v21/bezier_decelerate.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/app/src/main/res/anim/bezier_decelerate.xml b/app/src/main/res/anim/bezier_decelerate.xml new file mode 100644 index 0000000..63ed5f6 --- /dev/null +++ b/app/src/main/res/anim/bezier_decelerate.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/app/src/main/res/anim/fade_in_scale.xml b/app/src/main/res/anim/fade_in_scale.xml index 4021eef..c4e135b 100644 --- a/app/src/main/res/anim/fade_in_scale.xml +++ b/app/src/main/res/anim/fade_in_scale.xml @@ -4,7 +4,7 @@ android:duration="@integer/animation_time_medium" android:fromXScale="0.85" android:fromYScale="0.85" - android:interpolator="@android:interpolator/decelerate_cubic" + android:interpolator="@anim/bezier_decelerate" android:pivotX="50%p" android:pivotY="50%p" android:toXScale="1.0" diff --git a/app/src/main/res/anim/fade_out_scale.xml b/app/src/main/res/anim/fade_out_scale.xml index e65ec67..c6df9ee 100644 --- a/app/src/main/res/anim/fade_out_scale.xml +++ b/app/src/main/res/anim/fade_out_scale.xml @@ -4,7 +4,7 @@ android:duration="@integer/animation_time_medium" android:fromXScale="1.0" android:fromYScale="1.0" - android:interpolator="@android:interpolator/decelerate_cubic" + android:interpolator="@anim/bezier_decelerate" android:pivotX="50%p" android:pivotY="50%p" android:toXScale="0.85" diff --git a/app/src/main/res/anim/slide_in_from_right.xml b/app/src/main/res/anim/slide_in_from_right.xml index 5376037..540a680 100644 --- a/app/src/main/res/anim/slide_in_from_right.xml +++ b/app/src/main/res/anim/slide_in_from_right.xml @@ -3,7 +3,7 @@ diff --git a/app/src/main/res/anim/slide_out_to_right.xml b/app/src/main/res/anim/slide_out_to_right.xml index 5f27e58..a77ba4c 100644 --- a/app/src/main/res/anim/slide_out_to_right.xml +++ b/app/src/main/res/anim/slide_out_to_right.xml @@ -3,7 +3,7 @@ diff --git a/app/src/main/res/anim/slide_up_in.xml b/app/src/main/res/anim/slide_up_in.xml index 6682e82..5864e97 100644 --- a/app/src/main/res/anim/slide_up_in.xml +++ b/app/src/main/res/anim/slide_up_in.xml @@ -3,7 +3,7 @@