- Fixed heads not being DPI aware

This commit is contained in:
SerpentSpirale 2021-03-26 11:29:11 +01:00
parent cf7a5ec357
commit 35b5941387
2 changed files with 19 additions and 9 deletions

View File

@ -32,6 +32,7 @@ import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
@ -651,15 +652,16 @@ public class PojavLoginActivity extends BaseActivity
View child = inflater.inflate(R.layout.simple_account_list_item, null);
TextView accountName = child.findViewById(R.id.accountitem_text_name);
ImageButton removeButton = child.findViewById(R.id.accountitem_button_remove);
ImageView imageView = child.findViewById(R.id.account_head);
String accNameStr = s.substring(0, s.length() - 5);
String skinFaceBase64 = MinecraftAccount.load(accNameStr).skinFaceBase64;
if (skinFaceBase64 != null) {
byte[] faceIconBytes = Base64.decode(skinFaceBase64, Base64.DEFAULT);
Bitmap bitmap = BitmapFactory.decodeByteArray(faceIconBytes, 0, faceIconBytes.length);
accountName.setCompoundDrawablesWithIntrinsicBounds(new BitmapDrawable(getResources(),
bitmap), null, null, null);
imageView.setImageDrawable(new BitmapDrawable(getResources(),
bitmap));
}
accountName.setText(accNameStr);

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
@ -8,20 +7,19 @@
<TextView
android:id="@+id/accountitem_text_name"
android:layout_width="240dp"
android:layout_width="185dp"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:maxHeight="?android:attr/listPreferredItemHeightSmall"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:text="Name Placeholder"
android:text="Name Placeholder"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:drawablePadding="20dp"
app:layout_constraintEnd_toStartOf="@+id/accountitem_button_remove"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
@ -37,5 +35,15 @@
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_remove" />
<ImageView
android:id="@+id/account_head"
android:layout_width="48dp"
android:layout_height="48dp"
android:maxHeight="?android:attr/listPreferredItemHeightSmall"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
app:layout_constraintEnd_toStartOf="@+id/accountitem_text_name"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />
</androidx.constraintlayout.widget.ConstraintLayout>