| Index: chrome/android/java/src/org/chromium/chrome/browser/appmenu/RowHighlightDrawable.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/appmenu/RowHighlightDrawable.java b/chrome/android/java/src/org/chromium/chrome/browser/appmenu/RowHighlightDrawable.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..14d36c0471d9942c9eca3e3b6b354358d6e606df
|
| --- /dev/null
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/appmenu/RowHighlightDrawable.java
|
| @@ -0,0 +1,64 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.chrome.browser.appmenu;
|
| +
|
| +import android.animation.Animator;
|
| +import android.animation.AnimatorListenerAdapter;
|
| +import android.animation.AnimatorSet;
|
| +import android.animation.ObjectAnimator;
|
| +import android.graphics.drawable.ColorDrawable;
|
| +import android.support.annotation.ColorInt;
|
| +import android.support.v4.view.animation.FastOutSlowInInterpolator;
|
| +
|
| +/** A {@link Drawable} that pulses a color. */
|
| +public class RowHighlightDrawable extends ColorDrawable {
|
| + /** Creates a new black pulsing {@link RowHighlightDrawable}. */
|
| + public RowHighlightDrawable() {
|
| + startAnimation();
|
| + }
|
| +
|
| + /**
|
| + * Creates a new {@link RowHighlightDrawable} with the specified color.
|
| + * @param color The color to draw.
|
| + */
|
| + public RowHighlightDrawable(@ColorInt int color) {
|
| + super(color);
|
| + startAnimation();
|
| + }
|
| +
|
| + private void startAnimation() {
|
| + setAlpha(75);
|
| + ObjectAnimator fadeInAnim = ObjectAnimator.ofInt(this, "alpha", 75, 12);
|
| + fadeInAnim.setStartDelay(500);
|
| + fadeInAnim.setDuration(500);
|
| + fadeInAnim.setInterpolator(new FastOutSlowInInterpolator());
|
| +
|
| + ObjectAnimator fadeOutAnim = ObjectAnimator.ofInt(this, "alpha", 12, 75);
|
| + fadeOutAnim.setDuration(250);
|
| + fadeOutAnim.setInterpolator(new FastOutSlowInInterpolator());
|
| +
|
| + AnimatorSet set = new AnimatorSet();
|
| + set.playSequentially(fadeInAnim, fadeOutAnim);
|
| + set.addListener(new AnimatorListenerAdapter() {
|
| + private boolean mCanceled;
|
| +
|
| + @Override
|
| + public void onAnimationStart(Animator animation) {
|
| + mCanceled = false;
|
| + }
|
| +
|
| + @Override
|
| + public void onAnimationCancel(Animator animation) {
|
| + mCanceled = true;
|
| + }
|
| +
|
| + @Override
|
| + public void onAnimationEnd(Animator animation) {
|
| + if (!mCanceled) animation.start();
|
| + }
|
| + });
|
| + set.start();
|
| + }
|
| +}
|
|
|