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 ef8a420d1..25f3d2de2 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java @@ -16,7 +16,6 @@ import android.text.TextPaint; import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; -import android.view.ViewTreeObserver; import android.view.WindowInsets; import android.view.animation.TranslateAnimation; import android.widget.ImageButton; @@ -95,7 +94,6 @@ public abstract class BaseStatusListFragment exten @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); - UiUtils.loadMaxWidth(getContext()); if(GlobalUserPreferences.disableMarquee){ setTitleMarqueeEnabled(false); setSubtitleMarqueeEnabled(false); @@ -319,7 +317,7 @@ public abstract class BaseStatusListFragment exten currentPhotoViewer.offsetView(-dx, -dy); View fab = getFab(); - if (fab!=null && GlobalUserPreferences.autoHideFab) { + if (fab!=null && GlobalUserPreferences.autoHideFab && dy != UiUtils.SCROLL_TO_TOP_DELTA) { if (dy > 0 && fab.getVisibility() == View.VISIBLE) { hideFab(); } else if (dy < 0 && fab.getVisibility() != View.VISIBLE) { diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ScrollableToTop.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ScrollableToTop.java index d6a28ae6c..af675748a 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ScrollableToTop.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ScrollableToTop.java @@ -3,7 +3,8 @@ package org.joinmastodon.android.fragments; import android.view.ViewTreeObserver; import androidx.recyclerview.widget.RecyclerView; -import me.grishka.appkit.utils.V; + +import org.joinmastodon.android.ui.utils.UiUtils; public interface ScrollableToTop{ void scrollToTop(); @@ -21,7 +22,7 @@ public interface ScrollableToTop{ @Override public boolean onPreDraw(){ list.getViewTreeObserver().removeOnPreDrawListener(this); - list.scrollBy(0, V.dp(300)); + list.scrollBy(0, UiUtils.SCROLL_TO_TOP_DELTA); list.smoothScrollToPosition(0); return true; } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java index c6fbd646e..77e1b1c5a 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java @@ -65,7 +65,6 @@ public class TextStatusDisplayItem extends StatusDisplayItem{ spoilerEmojiHelper.setText(parsedSpoilerText); } session = AccountSessionManager.getInstance().getAccount(parentFragment.getAccountID()); - UiUtils.loadMaxWidth(parentFragment.getContext()); } public void setTranslationShown(boolean translationShown) { diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java index 01bc646bd..0adf08595 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java @@ -17,6 +17,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.res.ColorStateList; import android.content.res.Configuration; +import android.content.res.Resources; import android.content.res.TypedArray; import android.database.Cursor; import android.graphics.Bitmap; @@ -141,15 +142,11 @@ public class UiUtils { private static Handler mainHandler = new Handler(Looper.getMainLooper()); private static final DateTimeFormatter DATE_FORMATTER_SHORT_WITH_YEAR = DateTimeFormatter.ofPattern("d MMM uuuu"), DATE_FORMATTER_SHORT = DateTimeFormatter.ofPattern("d MMM"); public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG, FormatStyle.SHORT); - public static int MAX_WIDTH; + public static int MAX_WIDTH, SCROLL_TO_TOP_DELTA; private UiUtils() { } - public static void loadMaxWidth(Context ctx) { - if (MAX_WIDTH == 0) MAX_WIDTH = (int) ctx.getResources().getDimension(R.dimen.layout_max_width); - } - public static void launchWebBrowser(Context context, String url) { try { if (GlobalUserPreferences.useCustomTabs) { @@ -898,6 +895,10 @@ public class UiUtils { ColorPalette palette = ColorPalette.palettes.get(GlobalUserPreferences.color); if (palette != null) palette.apply(context); + + Resources res = context.getResources(); + MAX_WIDTH = (int) res.getDimension(R.dimen.layout_max_width); + SCROLL_TO_TOP_DELTA = (int) res.getDimension(R.dimen.scroll_to_top_delta); } public static boolean isDarkTheme() { diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/views/ComposeMediaLayout.java b/mastodon/src/main/java/org/joinmastodon/android/ui/views/ComposeMediaLayout.java index f435cca48..7ee640324 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/views/ComposeMediaLayout.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/views/ComposeMediaLayout.java @@ -23,7 +23,6 @@ public class ComposeMediaLayout extends ViewGroup{ public ComposeMediaLayout(Context context, AttributeSet attrs, int defStyle){ super(context, attrs, defStyle); - UiUtils.loadMaxWidth(context); } @Override diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/views/MediaGridLayout.java b/mastodon/src/main/java/org/joinmastodon/android/ui/views/MediaGridLayout.java index d4ca3e547..7d6c49624 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/views/MediaGridLayout.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/views/MediaGridLayout.java @@ -27,7 +27,6 @@ public class MediaGridLayout extends ViewGroup{ public MediaGridLayout(Context context, AttributeSet attrs, int defStyle){ super(context, attrs, defStyle); - UiUtils.loadMaxWidth(context); } @Override diff --git a/mastodon/src/main/res/values/dimens.xml b/mastodon/src/main/res/values/dimens.xml index 6b401510b..a1ebac297 100644 --- a/mastodon/src/main/res/values/dimens.xml +++ b/mastodon/src/main/res/values/dimens.xml @@ -3,4 +3,5 @@ 220dp 145dp 450dp + 300dp \ No newline at end of file