More fixes

This commit is contained in:
Grishka 2022-02-12 02:10:30 +03:00
parent ebba838606
commit ff163d83da
4 changed files with 52 additions and 13 deletions

View File

@ -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<T extends DisplayItemsParent> exten
}
}
});
updateToolbar();
}
@Override
@ -289,6 +293,34 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> 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;
}

View File

@ -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

View File

@ -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

View File

@ -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">
<FrameLayout
android:id="@+id/reply_btn"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:layout_height="match_parent"
android:minWidth="56dp">
<TextView
android:id="@+id/reply"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:layout_gravity="center_horizontal"
android:layout_gravity="center"
android:drawableStart="@drawable/ic_fluent_chat_multiple_24_regular"
android:drawablePadding="8dp"
android:drawableTint="@color/text_secondary"
@ -31,14 +31,15 @@
android:layout_weight="1"/>
<FrameLayout
android:id="@+id/boost_btn"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:layout_height="match_parent"
android:minWidth="56dp">
<TextView
android:id="@+id/boost"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:layout_gravity="center_horizontal"
android:layout_gravity="center"
android:drawableStart="@drawable/ic_boost"
android:drawablePadding="8dp"
android:drawableTint="@color/boost_icon"
@ -54,14 +55,15 @@
android:layout_weight="1"/>
<FrameLayout
android:id="@+id/favorite_btn"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:layout_height="match_parent"
android:minWidth="56dp">
<TextView
android:id="@+id/favorite"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:layout_gravity="center_horizontal"
android:layout_gravity="center"
android:drawableStart="@drawable/ic_fluent_star_24_selector"
android:drawablePadding="8dp"
android:drawableTint="@color/favorite_icon"
@ -77,14 +79,15 @@
android:layout_weight="1"/>
<FrameLayout
android:id="@+id/share_btn"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:layout_height="match_parent"
android:minWidth="56dp">
<ImageView
android:id="@+id/share"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:layout_gravity="center_horizontal"
android:layout_gravity="center"
android:src="@drawable/ic_fluent_share_24_regular"
android:tint="@color/text_secondary"
android:gravity="center_vertical"/>