feat: redesign account picker sheet

This commit is contained in:
LucasGGamerM 2023-03-17 17:44:17 -03:00 committed by FineFindus
parent c73562fb75
commit e9e491c0b0
No known key found for this signature in database
GPG Key ID: 64873EE210FF8E6B
2 changed files with 49 additions and 6 deletions

View File

@ -8,6 +8,7 @@ import android.graphics.drawable.Animatable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
@ -25,6 +26,7 @@ import org.joinmastodon.android.api.session.AccountSession;
import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.fragments.onboarding.CustomWelcomeFragment;
import org.joinmastodon.android.ui.utils.UiUtils;
import org.w3c.dom.Text;
import java.util.List;
import java.util.function.Consumer;
@ -79,7 +81,8 @@ public class AccountSwitcherSheet extends BottomSheet{
AccountViewHolder holder = new AccountViewHolder();
holder.more.setVisibility(View.GONE);
holder.currentIcon.setVisibility(View.GONE);
holder.name.setText(R.string.add_account);
holder.display_name.setVisibility(View.GONE);
holder.display_add_account.setVisibility(View.VISIBLE);
holder.avatar.setScaleType(ImageView.ScaleType.CENTER);
holder.avatar.setImageResource(R.drawable.ic_fluent_add_circle_24_filled);
holder.avatar.setImageTintList(ColorStateList.valueOf(UiUtils.getThemeColor(activity, android.R.attr.textColorPrimary)));
@ -183,6 +186,8 @@ public class AccountSwitcherSheet extends BottomSheet{
private class AccountViewHolder extends BindableViewHolder<AccountSession> implements ImageLoaderViewHolder, UsableRecyclerView.Clickable{
private final TextView name;
private final TextView display_name;
private final TextView display_add_account;
private final ImageView avatar;
private final ImageButton more;
private final View currentIcon;
@ -191,6 +196,8 @@ public class AccountSwitcherSheet extends BottomSheet{
public AccountViewHolder(){
super(activity, R.layout.item_account_switcher, list);
name=findViewById(R.id.name);
display_name=findViewById(R.id.display_name);
display_add_account=findViewById(R.id.add_account);
avatar=findViewById(R.id.avatar);
more=findViewById(R.id.more);
currentIcon=findViewById(R.id.current);
@ -210,6 +217,7 @@ public class AccountSwitcherSheet extends BottomSheet{
@SuppressLint("SetTextI18n")
@Override
public void onBind(AccountSession item){
display_name.setText(item.self.displayName);
name.setText("@"+item.self.username+"@"+item.domain);
if(AccountSessionManager.getInstance().getLastActiveAccountID().equals(item.getID())){
more.setVisibility(View.GONE);

View File

@ -2,28 +2,63 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_height="52dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:gravity="center_vertical">
<ImageView
android:id="@+id/avatar"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_width="36dp"
android:layout_height="36dp"
android:importantForAccessibility="no"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/display_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="24dp"
android:textSize="16sp"
android:textColor="?android:textColorPrimary"
android:singleLine="true"
android:ellipsize="end"/>
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="24dp"
android:textSize="14sp"
android:textColor="?android:textColorSecondary"
android:singleLine="true"
android:ellipsize="end"/>
</LinearLayout>
<TextView
android:id="@+id/name"
android:id="@+id/add_account"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="24dp"
android:textSize="16sp"
android:textColor="?android:textColorPrimary"
android:text="@string/add_account"
android:singleLine="true"
android:visibility="gone"
android:ellipsize="end"/>
<Space
android:layout_width="0px"
android:layout_height="1px"
android:layout_weight="1"/>
<View
android:id="@+id/current"
android:layout_width="24dp"