]> git.ktnx.net Git - mobile-ledger.git/commitdiff
more animations when collapsing profile list and when starting/editting list edit
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 19 Apr 2019 15:45:26 +0000 (18:45 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 19 Apr 2019 20:56:43 +0000 (23:56 +0300)
app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfilesRecyclerViewAdapter.java
app/src/main/res/anim/fade_in.xml
app/src/main/res/anim/fade_out.xml [new file with mode: 0644]

index 1eb8f45832269edd5f34f31a45aff13f44163a21..aad6b50649bd8075a5a172b44a63f41a66402eb9 100644 (file)
@@ -271,15 +271,25 @@ public class MainActivity extends ProfileThemedActivity {
                     profileListHeadArrow.clearAnimation();
                     profileListHeadArrow.setVisibility(View.GONE);
                     profileListHeadMore.setVisibility(View.GONE);
+                    profileListHeadMore
+                            .startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_out));
                     profileListHeadCancel.setVisibility(View.VISIBLE);
+                    profileListHeadCancel
+                            .startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in));
                 }
                 else {
                     profileListHeadArrow.setRotation(180f);
                     profileListHeadArrow.setVisibility(View.VISIBLE);
                     profileListHeadCancel.setVisibility(View.GONE);
+                    profileListHeadCancel
+                            .startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_out));
                     profileListHeadMore.setVisibility(View.GONE);
-                    profileListHeadMore
-                            .setVisibility(profileListExpanded ? View.VISIBLE : View.GONE);
+                    if (profileListExpanded) {
+                        profileListHeadMore.setVisibility(View.VISIBLE);
+                        profileListHeadMore
+                                .startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in));
+                    }
+                    else profileListHeadMore.setVisibility(View.GONE);
                 }
             };
             mProfileListAdapter.addEditingProfilesObserver(editingProfilesObserver);
@@ -699,7 +709,18 @@ public class MainActivity extends ProfileThemedActivity {
         profileListHeadArrow.setRotation(0f);
         profileListHeadArrow
                 .startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate_180_back));
-        profileListHeadMore.setVisibility(View.GONE);
+        final Animation moreAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_out);
+        moreAnimation.setAnimationListener(new Animation.AnimationListener() {
+            @Override
+            public void onAnimationStart(Animation animation) {}
+            @Override
+            public void onAnimationEnd(Animation animation) {
+                profileListHeadMore.setVisibility(View.GONE);
+            }
+            @Override
+            public void onAnimationRepeat(Animation animation) {}
+        });
+        profileListHeadMore.startAnimation(moreAnimation);
     }
     public void onAccountSummaryRowViewClicked(View view) {
         ViewGroup row;
index d1ee5fd723f60c8c269fff13b5be8bede2f54f13..8ee0dd96c696c5a299a52cdfe38a4b034f7b3a40 100644 (file)
@@ -23,6 +23,8 @@ import android.graphics.drawable.ColorDrawable;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
@@ -68,7 +70,8 @@ public class ProfilesRecyclerViewAdapter
                                   @NonNull RecyclerView.ViewHolder target) {
                 Data.profiles.blockNotifications();
                 try {
-                    Collections.swap(Data.profiles, viewHolder.getAdapterPosition(), target.getAdapterPosition());
+                    Collections.swap(Data.profiles, viewHolder.getAdapterPosition(),
+                            target.getAdapterPosition());
                     MobileLedgerProfile.storeProfilesOrder();
                     notifyItemMoved(viewHolder.getAdapterPosition(), target.getAdapterPosition());
                 }
@@ -193,12 +196,26 @@ public class ProfilesRecyclerViewAdapter
         holder.itemView
                 .setBackground(sameProfile ? new ColorDrawable(Colors.tableRowDarkBG) : null);
         if (editingProfiles.get()) {
+            boolean wasHidden = holder.mEditButton.getVisibility() == View.GONE;
             holder.mRearrangeHandle.setVisibility(View.VISIBLE);
             holder.mEditButton.setVisibility(View.VISIBLE);
+            if (wasHidden) {
+                Animation a = AnimationUtils
+                        .loadAnimation(holder.mRearrangeHandle.getContext(), R.anim.fade_in);
+                holder.mRearrangeHandle.startAnimation(a);
+                holder.mEditButton.startAnimation(a);
+            }
         }
         else {
+            boolean wasShown = holder.mEditButton.getVisibility() == View.VISIBLE;
             holder.mRearrangeHandle.setVisibility(View.INVISIBLE);
             holder.mEditButton.setVisibility(View.GONE);
+            if (wasShown) {
+                Animation a = AnimationUtils
+                        .loadAnimation(holder.mRearrangeHandle.getContext(), R.anim.fade_out);
+                holder.mRearrangeHandle.startAnimation(a);
+                holder.mEditButton.startAnimation(a);
+            }
         }
     }
     @Override
index 9e2c56ce29ff5b109a266df794021cd170b1f67b..047f26c1a891a3c31f6d675ca30ef45316e43775 100644 (file)
@@ -16,8 +16,7 @@
   -->
 
 <set xmlns:android="http://schemas.android.com/apk/res/android"
-    android:duration="@android:integer/config_mediumAnimTime"
-    android:startOffset="@android:integer/config_shortAnimTime">
+    android:duration="@android:integer/config_mediumAnimTime">
     <alpha
         android:fromAlpha="0.0"
         android:toAlpha="1.0" />
diff --git a/app/src/main/res/anim/fade_out.xml b/app/src/main/res/anim/fade_out.xml
new file mode 100644 (file)
index 0000000..32b42a8
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright © 2019 Damyan Ivanov.
+  ~ This file is part of MoLe.
+  ~ MoLe is free software: you can distribute it and/or modify it
+  ~ under the term of the GNU General Public License as published by
+  ~ the Free Software Foundation, either version 3 of the License, or
+  ~ (at your opinion), any later version.
+  ~
+  ~ MoLe is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+  ~ GNU General Public License terms for details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+  -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+    android:duration="@android:integer/config_mediumAnimTime">
+    <alpha
+        android:fromAlpha="1.0"
+        android:toAlpha="0.0" />
+</set>
\ No newline at end of file