From ff163d83dafa0b6b02fc9702ca17de38ac23389f Mon Sep 17 00:00:00 2001 From: Grishka Date: Sat, 12 Feb 2022 02:10:30 +0300 Subject: [PATCH] More fixes --- .../fragments/BaseStatusListFragment.java | 32 +++++++++++++++++++ .../android/fragments/ProfileFragment.java | 4 +++ .../displayitems/FooterStatusDisplayItem.java | 8 ++--- .../main/res/layout/display_item_footer.xml | 21 ++++++------ 4 files changed, 52 insertions(+), 13 deletions(-) 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 38353861..d9551292 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java @@ -1,6 +1,7 @@ package org.joinmastodon.android.fragments; import android.app.Activity; +import android.content.res.Configuration; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Rect; @@ -9,7 +10,9 @@ import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.ViewGroup; +import android.view.ViewTreeObserver; import android.widget.ImageView; +import android.widget.Toolbar; import org.joinmastodon.android.R; import org.joinmastodon.android.model.Account; @@ -264,6 +267,7 @@ public abstract class BaseStatusListFragment exten } } }); + updateToolbar(); } @Override @@ -289,6 +293,34 @@ public abstract class BaseStatusListFragment exten return lm; } + @Override + public void onConfigurationChanged(Configuration newConfig){ + super.onConfigurationChanged(newConfig); + updateToolbar(); + } + + private void updateToolbar(){ + Toolbar toolbar=getToolbar(); + if(toolbar==null) + return; + toolbar.setOnClickListener(v->{ + if(list.getChildCount()>0 && list.getChildAdapterPosition(list.getChildAt(0))>10){ + list.scrollToPosition(0); + list.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener(){ + @Override + public boolean onPreDraw(){ + list.getViewTreeObserver().removeOnPreDrawListener(this); + list.scrollBy(0, V.dp(300)); + list.smoothScrollToPosition(0); + return true; + } + }); + }else{ + list.smoothScrollToPosition(0); + } + }); + } + protected int getMainAdapterOffset(){ return 0; } 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 ab0ec7b5..83200554 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -325,6 +325,10 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList toolbarTitleView.setTranslationY(titleTransY); toolbarSubtitleView.setTranslationY(titleTransY); } + getToolbar().setOnClickListener(v->{ + getScrollableRecyclerView().scrollToPosition(0); + scrollView.smoothScrollTo(0, 0); + }); } @Override diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java index fd33810e..68ed889f 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java @@ -54,10 +54,10 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{ UiUtils.fixCompoundDrawableTintOnAndroid6(boost, R.color.boost_icon); UiUtils.fixCompoundDrawableTintOnAndroid6(favorite, R.color.favorite_icon); } - reply.setOnClickListener(this::onReplyClick); - boost.setOnClickListener(this::onBoostClick); - favorite.setOnClickListener(this::onFavoriteClick); - share.setOnClickListener(this::onShareClick); + findViewById(R.id.reply_btn).setOnClickListener(this::onReplyClick); + findViewById(R.id.boost_btn).setOnClickListener(this::onBoostClick); + findViewById(R.id.favorite_btn).setOnClickListener(this::onFavoriteClick); + findViewById(R.id.share_btn).setOnClickListener(this::onShareClick); } @Override diff --git a/mastodon/src/main/res/layout/display_item_footer.xml b/mastodon/src/main/res/layout/display_item_footer.xml index d50da55b..140e71ae 100644 --- a/mastodon/src/main/res/layout/display_item_footer.xml +++ b/mastodon/src/main/res/layout/display_item_footer.xml @@ -4,19 +4,19 @@ android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="48dp" - android:paddingTop="12dp" android:paddingLeft="20dp" android:paddingRight="20dp">