diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java index f2ce30837..c0eaa0e5c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java @@ -13,11 +13,13 @@ import android.text.Layout; import android.text.StaticLayout; import android.text.TextPaint; import android.text.TextUtils; +import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.view.WindowInsets; import android.view.animation.TranslateAnimation; import android.widget.ImageButton; +import android.widget.ImageButton; import android.widget.Toolbar; import org.joinmastodon.android.E; @@ -296,9 +298,6 @@ public abstract class BaseStatusListFragment exten currentPhotoViewer.offsetView(-dx, -dy); if (fab!=null && GlobalUserPreferences.enableFabAutoHide) { - if(dy > 0){ - scrollDiff = 0; - } if (dy > 0 && fab.getVisibility() == View.VISIBLE) { TranslateAnimation animate = new TranslateAnimation( 0, @@ -311,7 +310,7 @@ public abstract class BaseStatusListFragment exten fab.setVisibility(View.INVISIBLE); scrollDiff = 0; } else if (dy < 0 && fab.getVisibility() != View.VISIBLE) { - if (scrollDiff > 800) { + if (scrollDiff > 400) { fab.setVisibility(View.VISIBLE); TranslateAnimation animate = new TranslateAnimation( 0, @@ -327,7 +326,6 @@ public abstract class BaseStatusListFragment exten } } } - } }); list.addItemDecoration(new StatusListItemDecoration()); ((UsableRecyclerView)list).setSelectorBoundsProvider(new UsableRecyclerView.SelectorBoundsProvider(){ diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java index b6e027659..a2d607264 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -19,11 +19,13 @@ import android.os.Bundle; import android.text.SpannableStringBuilder; import android.text.TextUtils; import android.text.style.ImageSpan; +import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.ViewOutlineProvider; @@ -158,7 +160,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList private WindowInsets childInsets; private PhotoViewer currentPhotoViewer; private boolean editModeLoading; - private boolean isScrollingUp = false; + protected int scrollDiff = 0; private static final int MAX_FIELDS=4; @@ -872,6 +874,36 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList if(currentPhotoViewer!=null){ currentPhotoViewer.offsetView(0, oldScrollY-scrollY); } + + int dy = scrollY - oldScrollY; + + if (dy > 0 && fab.getVisibility() == View.VISIBLE) { + TranslateAnimation animate = new TranslateAnimation( + 0, + 0, + 0, + fab.getHeight() * 2); + animate.setDuration(300); + animate.setFillAfter(true); + fab.startAnimation(animate); + fab.setVisibility(View.INVISIBLE); + scrollDiff = 0; + } else if (dy < 0 && fab.getVisibility() != View.VISIBLE) { + if (scrollDiff > 400) { + fab.setVisibility(View.VISIBLE); + TranslateAnimation animate = new TranslateAnimation( + 0, + 0, + fab.getHeight() * 2, + 0); + animate.setDuration(300); + animate.setFillAfter(true); + fab.startAnimation(animate); + scrollDiff = 0; + } else { + scrollDiff += Math.abs(dy); + } + } } private Fragment getFragmentForPage(int page){