mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-18 17:15:40 -04:00
- Improved scaling of the select account menu for portrait/split screen mode and small scren devices.
This commit is contained in:
parent
4e227a702a
commit
2eb88ff0ba
@ -23,6 +23,7 @@ import android.util.Base64;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
@ -675,12 +676,8 @@ public class PojavLoginActivity extends BaseActivity
|
||||
|
||||
final Dialog accountDialog = new Dialog(PojavLoginActivity.this);
|
||||
|
||||
int xScreen = PojavLoginActivity.this.getResources().getDisplayMetrics().widthPixels;
|
||||
int yScreen = PojavLoginActivity.this.getResources().getDisplayMetrics().heightPixels;
|
||||
|
||||
accountDialog.setContentView(R.layout.simple_account_list_holder);
|
||||
|
||||
|
||||
LinearLayout accountListLayout = accountDialog.findViewById(R.id.accountListLayout);
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
@ -764,12 +761,14 @@ public class PojavLoginActivity extends BaseActivity
|
||||
public void onClick(DialogInterface p1, int p2) {
|
||||
new InvalidateTokenTask(PojavLoginActivity.this).execute(selectedAccName);
|
||||
accountListLayout.removeViewsInLayout(accountIndex_final, 1);
|
||||
//Resize the window
|
||||
|
||||
if (accountListLayout.getChildCount() == 0) {
|
||||
accountDialog.dismiss(); //No need to keep it, since there is no account
|
||||
return;
|
||||
}
|
||||
accountDialog.getWindow().setLayout((int)(xScreen*0.4),(int) Math.min((yScreen*0.8), (73 + accountListLayout.getChildCount()*55)*(PojavLoginActivity.this.getResources().getDisplayMetrics().densityDpi/160f) ));
|
||||
//Refreshes the layout with the same settings so it take the missing child into account.
|
||||
accountListLayout.setLayoutParams(accountListLayout.getLayoutParams());
|
||||
|
||||
}
|
||||
});
|
||||
builder2.setNegativeButton(android.R.string.cancel, null);
|
||||
@ -778,9 +777,6 @@ public class PojavLoginActivity extends BaseActivity
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//The value 73 and 56 are dp numbers, converted into px in order to resize the layout.
|
||||
accountDialog.getWindow().setLayout((int)(xScreen*0.4),(int)Math.min((yScreen*0.8), (73 + accountListLayout.getChildCount()*56)*(PojavLoginActivity.this.getResources().getDisplayMetrics().densityDpi/160f) ));
|
||||
accountDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
accountDialog.show();
|
||||
}
|
||||
|
@ -3,19 +3,21 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:background="#424242"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/TextViewTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="20dp"
|
||||
|
||||
android:paddingTop="15dp"
|
||||
android:paddingBottom="20dp"
|
||||
android:textSize="26sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@android:color/white"
|
||||
android:gravity="center"
|
||||
|
||||
android:text="@string/login_select_account"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@ -25,8 +27,10 @@
|
||||
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/accountScrollView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintHeight_max="200dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
@ -36,7 +40,8 @@
|
||||
<LinearLayout
|
||||
android:id="@+id/accountListLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="100dp"
|
||||
android:maxHeight="100dp"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/accountitem_text_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="240dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
|
Loading…
x
Reference in New Issue
Block a user