Commit a5c6302c authored by Becky Zhou's avatar Becky Zhou Committed by Commit Bot

[Home] Animate checkmark for List UI

Adds an animation to the checkmark icon for History/Bookmark/Download.

Bug: 774673
Change-Id: I72254511a5b79026d26f0bfe7bf6b2df26b37daf
Reviewed-on: https://chromium-review.googlesource.com/801977
Commit-Queue: Becky Zhou <huayinz@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521147}
parent f2cd9430
<?xml version="1.0" encoding="utf-8"?>
<!-- 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. -->
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:aapt="http://schemas.android.com/aapt"
tools:targetApi="21">
<aapt:attr name="android:drawable">
<vector
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<!-- This path is calculated from the icon ic_check_googblue_24dp. -->
<path
android:name="ic_check"
android:pathData="M4.12,12.705 l4.88,4.88 l11.295,-11.29"
android:strokeColor="#4285F4"
android:strokeWidth="2" />
</vector>
</aapt:attr>
<target android:name="ic_check" >
<aapt:attr name="android:animation">
<set>
<objectAnimator
android:duration="200"
android:propertyName="pathData"
android:valueFrom="M4.12,12.705 l0,0 l0,0"
android:valueTo="M4.12,12.705 l4.88,4.88 l0,0"
android:valueType="pathType"/>
<objectAnimator
android:duration="200"
android:propertyName="pathData"
android:valueFrom="M4.12,12.705 l4.88,4.88 l0,0"
android:valueTo="M4.12,12.705 l4.88,4.88 l11.295,-11.29"
android:valueType="pathType"/>
</set>
</aapt:attr>
</target>
</animated-vector>
\ No newline at end of file
......@@ -272,8 +272,9 @@ public class DownloadItemView extends SelectableItemView<DownloadHistoryItemWrap
} else {
mIconView.setBackgroundColor(mIconBackgroundColorSelected);
}
mIconView.setImageResource(R.drawable.ic_check_googblue_24dp);
mIconView.setImageDrawable(mCheckDrawable);
mIconView.setTint(mCheckedIconForegroundColorList);
mCheckDrawable.start();
} else if (mThumbnailBitmap != null) {
assert !mThumbnailBitmap.isRecycled();
mIconView.setBackground(null);
......
......@@ -8,6 +8,8 @@ import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.graphics.drawable.AnimatedVectorDrawableCompat;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
......@@ -35,6 +37,7 @@ public abstract class SelectableItemView<E> extends FrameLayout implements Check
OnClickListener, OnLongClickListener, SelectionObserver<E> {
protected final int mDefaultLevel;
protected final int mSelectedLevel;
protected final AnimatedVectorDrawableCompat mCheckDrawable;
protected TintedImageView mIconView;
protected TextView mTitleView;
......@@ -55,6 +58,8 @@ public abstract class SelectableItemView<E> extends FrameLayout implements Check
ApiCompatibilityUtils.getColorStateList(getResources(), R.color.white_mode_tint);
mDefaultLevel = getResources().getInteger(R.integer.list_item_level_default);
mSelectedLevel = getResources().getInteger(R.integer.list_item_level_selected);
mCheckDrawable = AnimatedVectorDrawableCompat.create(
getContext(), R.drawable.ic_check_googblue_24dp_animated);
}
/**
......@@ -208,8 +213,9 @@ public abstract class SelectableItemView<E> extends FrameLayout implements Check
if (isChecked()) {
mIconView.getBackground().setLevel(mSelectedLevel);
mIconView.setImageResource(R.drawable.ic_check_googblue_24dp);
mIconView.setImageDrawable(mCheckDrawable);
mIconView.setTint(mIconColorList);
mCheckDrawable.start();
} else {
mIconView.getBackground().setLevel(mDefaultLevel);
mIconView.setImageDrawable(mIconDrawable);
......@@ -236,4 +242,9 @@ public abstract class SelectableItemView<E> extends FrameLayout implements Check
* that case.
*/
protected abstract void onClick();
@VisibleForTesting
public void endAnimationsForTests() {
mCheckDrawable.stop();
}
}
......@@ -331,9 +331,11 @@ public class BookmarkTest {
mRenderTestRule.render(manager.getView(), "bookmark_manager_one_folder");
ThreadUtils.runOnUiThreadBlocking(() -> {
manager.getRecyclerView()
.findViewHolderForAdapterPosition(0)
.itemView.performLongClick();
BookmarkRow itemView = (BookmarkRow) manager.getRecyclerView()
.findViewHolderForAdapterPosition(0)
.itemView;
itemView.performLongClick();
itemView.endAnimationsForTests();
manager.getToolbarForTests().endAnimationsForTesting();
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment