This commit is contained in:
Grishka 2023-05-30 21:32:08 +03:00
parent 31c7116a15
commit 7c6ec2e3d7
2 changed files with 18 additions and 23 deletions

View File

@ -25,6 +25,7 @@ import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.fragments.HomeFragment;
import org.joinmastodon.android.fragments.SplashFragment;
import org.joinmastodon.android.ui.utils.UiUtils;
import org.joinmastodon.android.ui.views.CheckableRelativeLayout;
import java.util.ArrayList;
import java.util.List;
@ -225,16 +226,18 @@ public class AccountSwitcherSheet extends BottomSheet{
private class AccountViewHolder extends BindableViewHolder<AccountSession> implements ImageLoaderViewHolder, UsableRecyclerView.Clickable, UsableRecyclerView.LongClickable{
private final TextView name, username;
private final ImageView avatar;
private final RadioButton radioButton;
private final CheckableRelativeLayout view;
public AccountViewHolder(){
super(activity, R.layout.item_account_switcher, list);
name=findViewById(R.id.name);
username=findViewById(R.id.username);
radioButton=findViewById(R.id.radiobtn);
View radioButton=findViewById(R.id.radiobtn);
radioButton.setBackground(new RadioButton(activity).getButtonDrawable());
avatar=findViewById(R.id.avatar);
avatar.setOutlineProvider(OutlineProviders.roundedRect(OutlineProviders.RADIUS_MEDIUM));
avatar.setClipToOutline(true);
view=(CheckableRelativeLayout) itemView;
}
@SuppressLint("SetTextI18n")
@ -242,7 +245,7 @@ public class AccountSwitcherSheet extends BottomSheet{
public void onBind(AccountSession item){
name.setText(item.self.displayName);
username.setText(item.getFullUsername());
radioButton.setChecked(AccountSessionManager.getInstance().getLastActiveAccountID().equals(item.getID()));
view.setChecked(AccountSessionManager.getInstance().getLastActiveAccountID().equals(item.getID()));
}
@Override

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<org.joinmastodon.android.ui.views.CheckableRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="72dp"
@ -13,23 +13,15 @@
android:layout_alignParentStart="true"
android:importantForAccessibility="no"/>
<FrameLayout
android:id="@+id/radiobtn_wrap"
android:layout_width="40dp"
android:layout_height="40dp"
<View
android:id="@+id/radiobtn"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="8dp">
<RadioButton
android:id="@+id/radiobtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:minWidth="0dp"
android:minHeight="0dp"/>
</FrameLayout>
android:layout_centerInParent="true"
android:layout_marginEnd="20dp"
android:layout_marginStart="12dp"
android:duplicateParentState="true"/>
<TextView
android:id="@+id/name"
@ -37,7 +29,7 @@
android:layout_height="24dp"
android:layout_marginTop="14dp"
android:layout_toEndOf="@id/avatar"
android:layout_toStartOf="@id/radiobtn_wrap"
android:layout_toStartOf="@id/radiobtn"
android:textAppearance="@style/m3_body_large"
android:textColor="?colorM3OnSurface"
android:gravity="center_vertical"
@ -50,11 +42,11 @@
android:layout_height="20dp"
android:layout_below="@id/name"
android:layout_toEndOf="@id/avatar"
android:layout_toStartOf="@id/radiobtn_wrap"
android:layout_toStartOf="@id/radiobtn"
android:textColor="?colorM3OnSurfaceVariant"
android:textAppearance="@style/m3_body_medium"
android:singleLine="true"
android:gravity="center_vertical"
android:ellipsize="end"/>
</RelativeLayout>
</org.joinmastodon.android.ui.views.CheckableRelativeLayout>