1
0
Fork 0
mirror of https://github.com/MatomoCamp/matomocamp-companion-android.git synced 2024-09-19 16:13:46 +02:00

Improved bookmark add/remove vector animation and make it compatible with any background color

This commit is contained in:
Christophe Beyls 2017-01-07 22:34:57 +01:00
parent 01e1c25f36
commit bedab2071c
18 changed files with 99 additions and 103 deletions

View file

@ -266,10 +266,10 @@ public class EventDetailsFragment extends Fragment {
if (isBookmarked) {
actionButton.setContentDescription(getString(R.string.remove_bookmark));
actionButton.setImageResource(animate ? R.drawable.avd_fab_bookmark_add_24dp : R.drawable.ic_bookmark_white_24dp);
actionButton.setImageResource(animate ? R.drawable.avd_bookmark_add_24dp : R.drawable.ic_bookmark_white_24dp);
} else {
actionButton.setContentDescription(getString(R.string.add_bookmark));
actionButton.setImageResource(animate ? R.drawable.avd_fab_bookmark_remove_24dp : R.drawable.ic_bookmark_outline_white_24dp);
actionButton.setImageResource(animate ? R.drawable.avd_bookmark_remove_24dp : R.drawable.ic_bookmark_outline_white_24dp);
}
if (animate) {
((Animatable) actionButton.getDrawable()).start();
@ -289,10 +289,10 @@ public class EventDetailsFragment extends Fragment {
if (isBookmarked) {
bookmarkMenuItem.setTitle(R.string.remove_bookmark);
bookmarkMenuItem.setIcon(animate ? R.drawable.avd_appbar_bookmark_add_24dp : R.drawable.ic_bookmark_white_24dp);
bookmarkMenuItem.setIcon(animate ? R.drawable.avd_bookmark_add_24dp : R.drawable.ic_bookmark_white_24dp);
} else {
bookmarkMenuItem.setTitle(R.string.add_bookmark);
bookmarkMenuItem.setIcon(animate ? R.drawable.avd_appbar_bookmark_remove_24dp : R.drawable.ic_bookmark_outline_white_24dp);
bookmarkMenuItem.setIcon(animate ? R.drawable.avd_bookmark_remove_24dp : R.drawable.ic_bookmark_outline_white_24dp);
}
if (animate) {
((Animatable) bookmarkMenuItem.getIcon()).stop();

View file

@ -1,16 +1,14 @@
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="sequentially">
<objectAnimator
android:name="check"
android:duration="250"
android:propertyName="trimPathEnd"
android:valueFrom="0"
android:valueTo="0"/>
<objectAnimator
android:name="check"
android:duration="250"
android:interpolator="@android:anim/accelerate_interpolator"
android:propertyName="trimPathEnd"
android:valueFrom="0"
android:duration="200"
android:propertyName="scaleX"
android:valueFrom="1"
android:valueTo="1"/>
<objectAnimator
android:duration="300"
android:interpolator="@android:anim/accelerate_interpolator"
android:propertyName="scaleX"
android:valueFrom="1"
android:valueTo="0"/>
</set>

View file

@ -1,8 +1,7 @@
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="check"
android:duration="250"
android:duration="300"
android:interpolator="@android:anim/decelerate_interpolator"
android:propertyName="trimPathEnd"
android:valueFrom="1"
android:valueTo="0"/>
android:propertyName="scaleX"
android:valueFrom="0"
android:valueTo="1"/>

View file

@ -1,14 +1,12 @@
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="sequentially">
<objectAnimator
android:name="filler"
android:duration="250"
android:propertyName="fillAlpha"
android:valueFrom="1"
android:valueTo="1"/>
<objectAnimator
android:name="filler"
android:duration="250"
android:duration="0"
android:propertyName="fillAlpha"
android:valueFrom="1"
android:valueTo="0"/>

View file

@ -0,0 +1,13 @@
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="sequentially">
<objectAnimator
android:duration="250"
android:propertyName="fillAlpha"
android:valueFrom="0"
android:valueTo="0"/>
<objectAnimator
android:duration="0"
android:propertyName="fillAlpha"
android:valueFrom="0"
android:valueTo="1"/>
</set>

View file

@ -1,7 +1,7 @@
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="filler"
android:duration="250"
android:propertyName="fillAlpha"
android:interpolator="@android:anim/accelerate_interpolator"
android:propertyName="scaleY"
android:valueFrom="0"
android:valueTo="1"/>

View file

@ -0,0 +1,14 @@
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="sequentially">
<objectAnimator
android:duration="250"
android:propertyName="scaleY"
android:valueFrom="1"
android:valueTo="1"/>
<objectAnimator
android:duration="250"
android:interpolator="@android:anim/decelerate_interpolator"
android:propertyName="scaleY"
android:valueFrom="1"
android:valueTo="0"/>
</set>

View file

@ -1,9 +0,0 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_avd_appbar_bookmark_24dp">
<target
android:name="filler"
android:animation="@animator/bookmark_fade_in"/>
<target
android:name="check"
android:animation="@animator/bookmark_check_in"/>
</animated-vector>

View file

@ -1,9 +0,0 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_avd_appbar_bookmark_24dp">
<target
android:name="filler"
android:animation="@animator/bookmark_fade_out"/>
<target
android:name="check"
android:animation="@animator/bookmark_check_out"/>
</animated-vector>

View file

@ -0,0 +1,12 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_avd_bookmark_24dp">
<target
android:name="outline_extension"
android:animation="@animator/bookmark_toggle_in"/>
<target
android:name="zoom_group"
android:animation="@animator/bookmark_zoom_in"/>
<target
android:name="filler_group"
android:animation="@animator/bookmark_check_in"/>
</animated-vector>

View file

@ -0,0 +1,12 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_avd_bookmark_24dp">
<target
android:name="outline_extension"
android:animation="@animator/bookmark_toggle_out"/>
<target
android:name="zoom_group"
android:animation="@animator/bookmark_zoom_out"/>
<target
android:name="filler_group"
android:animation="@animator/bookmark_check_out"/>
</animated-vector>

View file

@ -1,9 +0,0 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_avd_fab_bookmark_24dp">
<target
android:name="filler"
android:animation="@animator/bookmark_fade_in"/>
<target
android:name="check"
android:animation="@animator/bookmark_check_in"/>
</animated-vector>

View file

@ -1,9 +0,0 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_avd_fab_bookmark_24dp">
<target
android:name="filler"
android:animation="@animator/bookmark_fade_out"/>
<target
android:name="check"
android:animation="@animator/bookmark_check_out"/>
</animated-vector>

View file

@ -1,19 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:name="bookmark_outline"
android:fillColor="#FFFFFFFF"
android:pathData="@string/path_ic_bookmark_outline"/>
<path
android:name="filler"
android:fillColor="#FFFFFFFF"
android:pathData="@string/path_ic_bookmark_filler"/>
<path
android:name="check"
android:pathData="@string/path_ic_bookmark_check"
android:strokeColor="?attr/colorPrimary"
android:strokeWidth="2"/>
</vector>

View file

@ -0,0 +1,27 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M18,18V5H7V18L12,15.82L17,18H18M17,3A2,2 0 0,1 19,5V21L12,18L5,21V5C5,3.89 5.9,3 7,3H17"/>
<path
android:name="outline_extension"
android:fillColor="#FFFFFFFF"
android:pathData="M11,7H13V9H15V11H13V13H11V11H9V9H11V7ZM17,4.5H18.5V18.5H17Z"/>
<group
android:name="zoom_group"
android:pivotY="18">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M5.5,4.5H18.5V18H5.5ZM11,14L17.25,7.76L15.84,6.34L11,11.18L8.41,8.59L7,10L11,14Z"/>
<group
android:name="filler_group"
android:pivotX="17.5">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M6.75,5H17.5V15H6.75Z"/>
</group>
</group>
</vector>

View file

@ -1,19 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:name="bookmark_outline"
android:fillColor="#FFFFFFFF"
android:pathData="@string/path_ic_bookmark_outline"/>
<path
android:name="filler"
android:fillColor="#FFFFFFFF"
android:pathData="@string/path_ic_bookmark_filler"/>
<path
android:name="check"
android:pathData="@string/path_ic_bookmark_check"
android:strokeColor="?attr/colorAccent"
android:strokeWidth="2"/>
</vector>

View file

@ -5,5 +5,5 @@
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="@string/path_ic_bookmark_outline"/>
android:pathData="M17,18V5H7V18L12,15.82L17,18M17,3A2,2 0 0,1 19,5V21L12,18L5,21V5C5,3.89 5.9,3 7,3H17M11,7H13V9H15V11H13V13H11V11H9V9H11V7Z"/>
</vector>

View file

@ -1,9 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="path_ic_bookmark" translatable="false">M17,3A2,2 0 0,1 19,5V21L12,18L5,21V5C5,3.89 5.9,3 7,3H17M11,14L17.25,7.76L15.84,6.34L11,11.18L8.41,8.59L7,10L11,14Z</string>
<string name="path_ic_bookmark_filler" translatable="false">M6,4h12v14h-12z</string>
<string name="path_ic_bookmark_check" translatable="false">M7.71,9.3L11,12.59L16.55,7.05</string>
<string name="path_ic_bookmark_outline" translatable="false">M17,18V5H7V18L12,15.82L17,18M17,3A2,2 0 0,1 19,5V21L12,18L5,21V5C5,3.89 5.9,3 7,3H17M11,7H13V9H15V11H13V13H11V11H9V9H11V7Z</string>
<string name="path_ic_play_circle_outline" translatable="false">M10,16.5l6,-4.5 -6,-4.5v9zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z</string>
<string name="path_shortcut_background" translatable="false">M24,24m-22,0a22,22 0,1 1,44 0a22,22 0,1 1,-44 0</string>
</resources>