display roles in profile
This commit is contained in:
parent
f88b65f479
commit
defd038064
|
@ -8,11 +8,11 @@ import android.app.Activity;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.Outline;
|
import android.graphics.Outline;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.ShapeDrawable;
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.graphics.drawable.shapes.RoundRectShape;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -112,7 +112,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
|
|
||||||
private ImageView avatar;
|
private ImageView avatar;
|
||||||
private CoverImageView cover;
|
private CoverImageView cover;
|
||||||
private View avatarBorder;
|
private View avatarBorder, nameWrap;
|
||||||
private TextView name, username, bio, followersCount, followersLabel, followingCount, followingLabel, postsCount, postsLabel;
|
private TextView name, username, bio, followersCount, followersLabel, followingCount, followingLabel, postsCount, postsLabel;
|
||||||
private ProgressBarButton actionButton, notifyButton;
|
private ProgressBarButton actionButton, notifyButton;
|
||||||
private ViewPager2 pager;
|
private ViewPager2 pager;
|
||||||
|
@ -129,6 +129,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
private FrameLayout[] tabViews;
|
private FrameLayout[] tabViews;
|
||||||
private TabLayoutMediator tabLayoutMediator;
|
private TabLayoutMediator tabLayoutMediator;
|
||||||
private TextView followsYouView;
|
private TextView followsYouView;
|
||||||
|
private ViewGroup rolesView;
|
||||||
|
|
||||||
private Account account;
|
private Account account;
|
||||||
private String accountID;
|
private String accountID;
|
||||||
|
@ -200,6 +201,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
cover=content.findViewById(R.id.cover);
|
cover=content.findViewById(R.id.cover);
|
||||||
avatarBorder=content.findViewById(R.id.avatar_border);
|
avatarBorder=content.findViewById(R.id.avatar_border);
|
||||||
name=content.findViewById(R.id.name);
|
name=content.findViewById(R.id.name);
|
||||||
|
nameWrap=content.findViewById(R.id.name_wrap);
|
||||||
username=content.findViewById(R.id.username);
|
username=content.findViewById(R.id.username);
|
||||||
bio=content.findViewById(R.id.bio);
|
bio=content.findViewById(R.id.bio);
|
||||||
profileCounters=content.findViewById(R.id.profile_counters);
|
profileCounters=content.findViewById(R.id.profile_counters);
|
||||||
|
@ -225,6 +227,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
fab=content.findViewById(R.id.fab);
|
fab=content.findViewById(R.id.fab);
|
||||||
followsYouView=content.findViewById(R.id.follows_you);
|
followsYouView=content.findViewById(R.id.follows_you);
|
||||||
list=content.findViewById(R.id.metadata);
|
list=content.findViewById(R.id.metadata);
|
||||||
|
rolesView=content.findViewById(R.id.roles);
|
||||||
|
|
||||||
avatar.setOutlineProvider(new ViewOutlineProvider(){
|
avatar.setOutlineProvider(new ViewOutlineProvider(){
|
||||||
@Override
|
@Override
|
||||||
|
@ -479,6 +482,19 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
name.setText(ssb);
|
name.setText(ssb);
|
||||||
setTitle(ssb);
|
setTitle(ssb);
|
||||||
|
|
||||||
|
if (account.roles != null && !account.roles.isEmpty()) {
|
||||||
|
rolesView.setVisibility(View.VISIBLE);
|
||||||
|
rolesView.removeAllViews();
|
||||||
|
name.setPadding(0, 0, V.dp(12), 0);
|
||||||
|
for (Account.Role role : account.roles) {
|
||||||
|
TextView roleText = new TextView(getActivity(), null, 0, R.style.role_label);
|
||||||
|
roleText.setText(role.name);
|
||||||
|
GradientDrawable bg = (GradientDrawable) roleText.getBackground().mutate();
|
||||||
|
bg.setStroke(V.dp(2), Color.parseColor(role.color));
|
||||||
|
rolesView.addView(roleText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean isSelf=AccountSessionManager.getInstance().isSelf(accountID, account);
|
boolean isSelf=AccountSessionManager.getInstance().isSelf(accountID, account);
|
||||||
|
|
||||||
if(account.locked){
|
if(account.locked){
|
||||||
|
@ -738,8 +754,8 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
coverGradient.setTopOffset(scrollY);
|
coverGradient.setTopOffset(scrollY);
|
||||||
cover.invalidate();
|
cover.invalidate();
|
||||||
titleTransY=getToolbar().getHeight();
|
titleTransY=getToolbar().getHeight();
|
||||||
if(scrollY>name.getTop()-topBarsH){
|
if(scrollY>nameWrap.getTop()-topBarsH){
|
||||||
titleTransY=Math.max(0f, titleTransY-(scrollY-(name.getTop()-topBarsH)));
|
titleTransY=Math.max(0f, titleTransY-(scrollY-(nameWrap.getTop()-topBarsH)));
|
||||||
}
|
}
|
||||||
if(toolbarTitleView!=null){
|
if(toolbarTitleView!=null){
|
||||||
toolbarTitleView.setTranslationY(titleTransY);
|
toolbarTitleView.setTranslationY(titleTransY);
|
||||||
|
@ -826,6 +842,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
avatar.setForeground(overlay);
|
avatar.setForeground(overlay);
|
||||||
animators.add(ObjectAnimator.ofInt(overlay, "alpha", 0, 255));
|
animators.add(ObjectAnimator.ofInt(overlay, "alpha", 0, 255));
|
||||||
|
|
||||||
|
nameWrap.setVisibility(View.GONE);
|
||||||
nameEdit.setVisibility(View.VISIBLE);
|
nameEdit.setVisibility(View.VISIBLE);
|
||||||
nameEdit.setText(account.displayName);
|
nameEdit.setText(account.displayName);
|
||||||
RelativeLayout.LayoutParams lp=(RelativeLayout.LayoutParams) username.getLayoutParams();
|
RelativeLayout.LayoutParams lp=(RelativeLayout.LayoutParams) username.getLayoutParams();
|
||||||
|
@ -870,6 +887,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
profileCounters.setVisibility(View.VISIBLE);
|
profileCounters.setVisibility(View.VISIBLE);
|
||||||
pager.setVisibility(View.VISIBLE);
|
pager.setVisibility(View.VISIBLE);
|
||||||
tabbar.setVisibility(View.VISIBLE);
|
tabbar.setVisibility(View.VISIBLE);
|
||||||
|
V.setVisibilityAnimated(nameWrap, View.VISIBLE);
|
||||||
|
|
||||||
AnimatorSet set=new AnimatorSet();
|
AnimatorSet set=new AnimatorSet();
|
||||||
set.playTogether(animators);
|
set.playTogether(animators);
|
||||||
|
@ -882,7 +900,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
nameEdit.setVisibility(View.GONE);
|
nameEdit.setVisibility(View.GONE);
|
||||||
bioEdit.setVisibility(View.GONE);
|
bioEdit.setVisibility(View.GONE);
|
||||||
RelativeLayout.LayoutParams lp=(RelativeLayout.LayoutParams) username.getLayoutParams();
|
RelativeLayout.LayoutParams lp=(RelativeLayout.LayoutParams) username.getLayoutParams();
|
||||||
lp.addRule(RelativeLayout.BELOW, R.id.name);
|
lp.addRule(RelativeLayout.BELOW, R.id.name_wrap);
|
||||||
username.getParent().requestLayout();
|
username.getParent().requestLayout();
|
||||||
avatar.setForeground(null);
|
avatar.setForeground(null);
|
||||||
scrollToTop();
|
scrollToTop();
|
||||||
|
|
|
@ -133,6 +133,14 @@ public class Account extends BaseModel{
|
||||||
*/
|
*/
|
||||||
public Instant muteExpiresAt;
|
public Instant muteExpiresAt;
|
||||||
|
|
||||||
|
public List<Role> roles;
|
||||||
|
|
||||||
|
@Parcel
|
||||||
|
public static class Role {
|
||||||
|
public String name;
|
||||||
|
/** #rrggbb */
|
||||||
|
public String color;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postprocess() throws ObjectValidationException{
|
public void postprocess() throws ObjectValidationException{
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:dither="true"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<corners android:radius="4sp" />
|
||||||
|
<solid android:color="?colorBackgroundLight" />
|
||||||
|
<stroke android:width="2dp" android:color="#00ff00" />
|
||||||
|
</shape>
|
|
@ -135,24 +135,39 @@
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<org.joinmastodon.android.ui.views.AutoOrientationLinearLayout
|
||||||
android:id="@+id/name"
|
android:id="@+id/name_wrap"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/avatar_border"
|
android:layout_below="@id/avatar_border"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_marginHorizontal="16dp"
|
android:layout_marginHorizontal="16dp"
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp">
|
||||||
android:textAlignment="viewStart"
|
|
||||||
android:textAppearance="@style/m3_headline_small"
|
<TextView
|
||||||
tools:text="Eugen" />
|
android:id="@+id/name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
android:textAppearance="@style/m3_headline_small"
|
||||||
|
tools:text="Eugen" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/roles"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</org.joinmastodon.android.ui.views.AutoOrientationLinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/username"
|
android:id="@+id/username"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="16dp"
|
android:layout_marginHorizontal="16dp"
|
||||||
android:layout_below="@id/name"
|
android:layout_below="@id/name_wrap"
|
||||||
android:paddingTop="4dp"
|
android:paddingTop="4dp"
|
||||||
android:paddingBottom="8dp"
|
android:paddingBottom="8dp"
|
||||||
android:textAppearance="@style/m3_title_medium"
|
android:textAppearance="@style/m3_title_medium"
|
||||||
|
|
|
@ -476,6 +476,18 @@
|
||||||
<item name="android:letterSpacing">0.1</item>
|
<item name="android:letterSpacing">0.1</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="role_label">
|
||||||
|
<item name="android:fontFamily">sans-serif-medium</item>
|
||||||
|
<item name="android:textSize">14sp</item>
|
||||||
|
<item name="android:textColor">?android:textColorPrimary</item>
|
||||||
|
<item name="android:background">@drawable/bg_pill</item>
|
||||||
|
<item name="android:paddingStart">8dp</item>
|
||||||
|
<item name="android:paddingEnd">8dp</item>
|
||||||
|
<item name="android:paddingTop">6dp</item>
|
||||||
|
<item name="android:paddingBottom">6dp</item>
|
||||||
|
<item name="android:layout_marginEnd">8dp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="m3_headline_small">
|
<style name="m3_headline_small">
|
||||||
<item name="android:textSize">24sp</item>
|
<item name="android:textSize">24sp</item>
|
||||||
<item name="android:textColor">?android:textColorPrimary</item>
|
<item name="android:textColor">?android:textColorPrimary</item>
|
||||||
|
|
Loading…
Reference in New Issue