From 3a19f8e40b20bd43734aefeb4cfbef466788f50a Mon Sep 17 00:00:00 2001 From: NoodleMage Date: Sat, 13 Feb 2016 12:08:15 +0100 Subject: [PATCH] FAB animation update --- .../ui/base/fab/ScrollAwareFABBehavior.java | 48 ++++++++++++++++-- .../ui/manga/info/MangaInfoFragment.java | 9 ---- app/src/main/res/anim/fab_hide_to_bottom.xml | 6 +++ .../main/res/anim/fab_show_from_bottom.xml | 6 +++ .../res/drawable-hdpi/ic_action_add_18dp.png | Bin 134 -> 0 bytes .../res/drawable-hdpi/ic_add_white_24dp.png | Bin 0 -> 127 bytes .../drawable-hdpi/ic_mode_edit_white_24dp.png | Bin 0 -> 219 bytes .../res/drawable-ldpi/ic_action_add_18dp.png | Bin 119 -> 0 bytes .../res/drawable-mdpi/ic_action_add_18dp.png | Bin 116 -> 0 bytes .../res/drawable-mdpi/ic_add_white_24dp.png | Bin 0 -> 88 bytes .../drawable-mdpi/ic_mode_edit_white_24dp.png | Bin 0 -> 165 bytes .../res/drawable-xhdpi/ic_action_add_18dp.png | Bin 168 -> 0 bytes .../res/drawable-xhdpi/ic_add_white_24dp.png | Bin 0 -> 97 bytes .../ic_mode_edit_white_24dp.png | Bin 0 -> 239 bytes .../drawable-xxhdpi/ic_action_add_18dp.png | Bin 242 -> 0 bytes .../res/drawable-xxhdpi/ic_add_white_24dp.png | Bin 0 -> 97 bytes .../ic_mode_edit_white_24dp.png | Bin 0 -> 302 bytes .../drawable-xxxhdpi/ic_action_add_18dp.png | Bin 500 -> 0 bytes .../drawable-xxxhdpi/ic_add_white_24dp.png | Bin 0 -> 102 bytes .../ic_mode_edit_white_24dp.png | Bin 0 -> 355 bytes .../res/layout/activity_edit_categories.xml | 9 ++-- .../main/res/layout/fragment_manga_info.xml | 43 ++++++++-------- app/src/main/res/values/dimens.xml | 1 + 23 files changed, 83 insertions(+), 39 deletions(-) create mode 100644 app/src/main/res/anim/fab_hide_to_bottom.xml create mode 100644 app/src/main/res/anim/fab_show_from_bottom.xml delete mode 100644 app/src/main/res/drawable-hdpi/ic_action_add_18dp.png create mode 100644 app/src/main/res/drawable-hdpi/ic_add_white_24dp.png create mode 100644 app/src/main/res/drawable-hdpi/ic_mode_edit_white_24dp.png delete mode 100644 app/src/main/res/drawable-ldpi/ic_action_add_18dp.png delete mode 100644 app/src/main/res/drawable-mdpi/ic_action_add_18dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_add_white_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_mode_edit_white_24dp.png delete mode 100644 app/src/main/res/drawable-xhdpi/ic_action_add_18dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_mode_edit_white_24dp.png delete mode 100644 app/src/main/res/drawable-xxhdpi/ic_action_add_18dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_mode_edit_white_24dp.png delete mode 100644 app/src/main/res/drawable-xxxhdpi/ic_action_add_18dp.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_mode_edit_white_24dp.png diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/fab/ScrollAwareFABBehavior.java b/app/src/main/java/eu/kanade/tachiyomi/ui/base/fab/ScrollAwareFABBehavior.java index 707299b80..cbcd0100c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/fab/ScrollAwareFABBehavior.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/fab/ScrollAwareFABBehavior.java @@ -19,10 +19,19 @@ import android.content.Context; import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.FloatingActionButton; import android.support.v4.view.ViewCompat; +import android.support.v4.view.animation.FastOutSlowInInterpolator; import android.util.AttributeSet; import android.view.View; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.view.animation.Interpolator; + +import eu.kanade.tachiyomi.R; public class ScrollAwareFABBehavior extends FloatingActionButton.Behavior { + private static final Interpolator INTERPOLATOR = new FastOutSlowInInterpolator(); + private boolean mIsAnimatingOut = false; + public ScrollAwareFABBehavior(Context context, AttributeSet attrs) { super(); } @@ -40,12 +49,43 @@ public class ScrollAwareFABBehavior extends FloatingActionButton.Behavior { final View target, final int dxConsumed, final int dyConsumed, final int dxUnconsumed, final int dyUnconsumed) { super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); - if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) { + if (dyConsumed > 0 && !this.mIsAnimatingOut && child.getVisibility() == View.VISIBLE) { // User scrolled down and the FAB is currently visible -> hide the FAB - child.hide(); + animateOut(child); } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) { // User scrolled up and the FAB is currently not visible -> show the FAB - child.show(); + animateIn(child); } } -} + + // Same animation that FloatingActionButton.Behavior uses to hide the FAB when the AppBarLayout exits + private void animateOut(final FloatingActionButton button) { + Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.fab_hide_to_bottom); + anim.setInterpolator(INTERPOLATOR); + anim.setDuration(200L); + anim.setAnimationListener(new Animation.AnimationListener() { + public void onAnimationStart(Animation animation) { + ScrollAwareFABBehavior.this.mIsAnimatingOut = true; + } + + public void onAnimationEnd(Animation animation) { + ScrollAwareFABBehavior.this.mIsAnimatingOut = false; + button.setVisibility(View.GONE); + } + + @Override + public void onAnimationRepeat(final Animation animation) { + } + }); + button.startAnimation(anim); + } + + // Same animation that FloatingActionButton.Behavior uses to show the FAB when the AppBarLayout enters + private void animateIn(FloatingActionButton button) { + button.setVisibility(View.VISIBLE); + Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.fab_show_from_bottom); + anim.setDuration(200L); + anim.setInterpolator(INTERPOLATOR); + button.startAnimation(anim); + } +} \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoFragment.java b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoFragment.java index 532692c6b..b4df1d8d7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoFragment.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoFragment.java @@ -65,15 +65,6 @@ public class MangaInfoFragment extends BaseRxFragment { View view = inflater.inflate(R.layout.fragment_manga_info, container, false); ButterKnife.bind(this, view); - //Create edit drawable with size 24dp (google guidelines) - IconicsDrawable edit = new IconicsDrawable(this.getContext()) - .icon(GoogleMaterial.Icon.gmd_edit) - .color(ContextCompat.getColor(this.getContext(), R.color.white)) - .sizeDp(24); - - // Update image of fab button - fabEdit.setImageDrawable(edit); - // Set listener. fabEdit.setOnClickListener(v -> selectImage()); diff --git a/app/src/main/res/anim/fab_hide_to_bottom.xml b/app/src/main/res/anim/fab_hide_to_bottom.xml new file mode 100644 index 000000000..b5f8d63bd --- /dev/null +++ b/app/src/main/res/anim/fab_hide_to_bottom.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/app/src/main/res/anim/fab_show_from_bottom.xml b/app/src/main/res/anim/fab_show_from_bottom.xml new file mode 100644 index 000000000..eea12e8c4 --- /dev/null +++ b/app/src/main/res/anim/fab_show_from_bottom.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/app/src/main/res/drawable-hdpi/ic_action_add_18dp.png b/app/src/main/res/drawable-hdpi/ic_action_add_18dp.png deleted file mode 100644 index 7800ba33d627ceed4ab719da9cd8ce23ec437f50..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 134 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTCUr!gukcwMxZ*1gbFc4sJ_#S_2 zi=+a}Kg)xR>oyqX8t-HTDguHCt{uz}7K4H82V(|pMmHWP|G^zrFstG^^W;Nye|k0wldT1B8K;o2QFoh{y5d1PRu~4CX)Hf7s8+ zA**4&;-Ni|k0wldT1B8LpB2O2`5Rc<;FKpyGWFX@9u)F)) z*;~Krtafv?I)%E_Y_K{}=&{m7?a*G%T~B-z4T5qy=?Zpsw#8tS1Xd&9k2*~>k}K1Ey;A{<}r&^GyiQbDLWRp zHtQZo@OLK!~9QxBGc=AX`N|Mrqd7MsSY794L@SiwUF=4J|?MqgvM-%Km Tlv}?Bx|YGy)z4*}Q$iB}qq10? literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-ldpi/ic_action_add_18dp.png b/app/src/main/res/drawable-ldpi/ic_action_add_18dp.png deleted file mode 100644 index 1a39b71f835d24c27ca729470a6c798039593003..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 119 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjcAhSdAr-fhfBgS%&#Y^Bcm=ET zxhBp4A7gGlhmR{*4n|ElzrUa8o?i*N5^xwE?&r!@^WUx-YfBWA` Sr8z*87(8A5T-G@yGywqEH70fd diff --git a/app/src/main/res/drawable-mdpi/ic_action_add_18dp.png b/app/src/main/res/drawable-mdpi/ic_action_add_18dp.png deleted file mode 100644 index ed40b2b21627006beb1e6fa808e20b2304b557eb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 116 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzYfl%)kcwMxuWjUHP!M1~@MeF> znmG=xQ@EGZuJibqIeRuQ1H*wwjgkxu4fTw>Kj|F+>HX8fz;N7};aHVL;lI$d7eEmP MPgg&ebxsLQ09S`3zyJUM diff --git a/app/src/main/res/drawable-mdpi/ic_add_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_add_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..3856041d702e80237afa394e0900d507f67e0a8f GIT binary patch literal 88 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1c~2L|5R22v2@_&aj!VDzSo@fq7N>%r!;1bAd`3JYD@<);T3K0RTZ}7R&$u literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_mode_edit_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_mode_edit_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..12b09f1d9b28e275323add8a5f26a40709b3550e GIT binary patch literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_+i98VX=5R22v2@+Kg_J9Ac|NpmV z;J?TA96oAc&PVGdUZ@}Y5}^>ueD%XLiQ|9%%Clen^me~?-P5>$?ao_51Xjx|Qk^y- zdBRlThZ6o?Q|jd-p2|(pELRqpvP6?TOTpK2Qrr9gcRRh0Ezy*ZVPIH1?c-DthJyV- Pdl@`k{an^LB{Ts5yXZdH literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_action_add_18dp.png b/app/src/main/res/drawable-xhdpi/ic_action_add_18dp.png deleted file mode 100644 index 185be8a769b4b5dccc8ca553f2f698fa5a801099..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 168 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=`JOJ0Ar-gY-rC5?V8Fxd_;&x6 zOYK(zopr04XFQCIA2c diff --git a/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..67bb598e52a36b6caba846efe733501479965a41 GIT binary patch literal 97 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZA`BpB)|k7xlYrjj7PU+mP(MLbxIU@tZx11_<06E_Cm;EuJEI5KzuPNK$?!{-w< zW;{Mke9afh-**!m1^<@N@NHtL5K^$DhZ|FM=P=&qvIgiFq?I{~>Up@NR&` pI{_Y_4KVpkfXgQVHXn-(+!KC0r!M+UZ~XuO002ovPDHLkV1hXhU+Vw> literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_add_18dp.png b/app/src/main/res/drawable-xxhdpi/ic_action_add_18dp.png deleted file mode 100644 index 2ab780a89de78daeb3faaf82d295a0007449cbe9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 242 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGoJ3U<-Ln>~)y>^h7!GMF=@LRmq z+y&>mxMW_69gx@ZT&eHQz~I2Zz`?-4$e_T$z{1eLz#zcDzyuQfb1j#FI8ecEPzqOh nF96QO&p@}7L530LjD$$`Hy8gfbhUB40GZ+G>gTe~DWM4f^m`)q diff --git a/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..0fdced8fce76a0f9a527388935adecebf63d0dae GIT binary patch literal 97 zcmeAS@N?(olHy`uVBq!ia0vp^9w5vJBp7O^^}Pa8OeH~n!3+##lh0ZJc~YJ(jv*C{ s$r5`OFVdQ&MBb@07vc`*Z=?k literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_mode_edit_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_mode_edit_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..02e19d04570c6f86c7885615cbc9a271a7a04873 GIT binary patch literal 302 zcmV+}0nz@6P)Nklp%{z$v^{5pMgUJ9P141uEYB)_=4RF_CjEcv6+Mn znIBAnGv0XNgxmvXi5r?~6rMQtq!!1P)XA|U^>VC8*ddh(X+J>9y^)Suv$GbGo?4@P z$3{eY=xvsabkJP%VN!{O?z@vFl@sq+=QG$(GU4=-%sAbo$vH)W(#MY3BegB1ZSKdK$X(b(iukxii#&) zXB+`2Dj&R^aRxxq;yb_>Cjp8^Kc>z&j4?L%KF;(Ssh;`jUH||907*qoM6N<$f)^cq A)Bpeg literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/ic_action_add_18dp.png b/app/src/main/res/drawable-xxxhdpi/ic_action_add_18dp.png deleted file mode 100644 index e6ca376b305d4bb78c96ec2aa1a40d4a1e0b30fb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 500 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7xzrVBGEL;uunK>+K!KtV0eW4T-IC ziobUSd{mfstJ&ksqIb4U7cSV$n3`ZD((~z4t%0<4>w`Z>)r>YrF#?T%gPJYNGLzP* zx0!3bel-95^YypiZj(G#C$YO-aD8r4A4d_}hCbGJzyF!^yf)aC7<1~ysqE!5gp2nk zTQc96-ukcBXq}-uLnZT#sr$c0ym9{+C0@)j!MfqJ2ZJ~xhXVtXKm&sS1Cs*-2Lq!5 z0}D=$ok2scD?>Eno;<;i_Uy==^4RoSYhQ}~{v2<)E%jsn z;UAKm3Uy^YJD-+6+jH#Bb77x1=jSJHNo{=pxA?o!^0_~6eVXqdu+zT2&+zHo>(jp1 zGT$m`Z~Df*BafCZDwc^5i{T978G? xlN*`>5BzUTIj7P7-(I3-fns}2dtZ?oBSS_(`pg9u0+k>GJYD@<);T3K0RZru9Krwq literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/ic_mode_edit_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_mode_edit_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..d6668a051cd53b2ef454e8e09872339348c2ee22 GIT binary patch literal 355 zcmV-p0i6DcP)o)4CwERtj4{R- zW9;vcYqq-8KB2^1t{_z z0h;{m09AfwfG$5PK$)Krpv|uhQ0Fto7-NhzVt3qk;nT+k=6L`B002ovPDHLkV1hVj BpML-V literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/activity_edit_categories.xml b/app/src/main/res/layout/activity_edit_categories.xml index c709d0773..4e8b4af20 100644 --- a/app/src/main/res/layout/activity_edit_categories.xml +++ b/app/src/main/res/layout/activity_edit_categories.xml @@ -18,11 +18,12 @@ - - @@ -254,28 +256,25 @@ + + - + + - - - - - - \ No newline at end of file + + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 970ef0afe..eea86b5e7 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -7,6 +7,7 @@ 16dp 16dp 16dp + 56dp 24dp 20dp