mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2026-05-18 23:14:40 -04:00
Try to autoscale
This commit is contained in:
@@ -151,8 +151,8 @@ public class MCLauncherActivity extends BaseLauncherActivity
|
||||
protected float updateWidthHeight() {
|
||||
float leftRightWidth = (float) CallbackBridge.windowWidth / 100f * 32f;
|
||||
float mPlayButtonWidth = CallbackBridge.windowWidth - leftRightWidth * 2f;
|
||||
LinearLayout.LayoutParams leftRightParams = new LinearLayout.LayoutParams((int) leftRightWidth, (int) Tools.dpToPx(this, CallbackBridge.windowHeight / 9));
|
||||
LinearLayout.LayoutParams mPlayButtonParams = new LinearLayout.LayoutParams((int) mPlayButtonWidth, (int) Tools.dpToPx(this, CallbackBridge.windowHeight / 9));
|
||||
LinearLayout.LayoutParams leftRightParams = new LinearLayout.LayoutParams((int) leftRightWidth, (int) Tools.dpToPx(CallbackBridge.windowHeight / 9));
|
||||
LinearLayout.LayoutParams mPlayButtonParams = new LinearLayout.LayoutParams((int) mPlayButtonWidth, (int) Tools.dpToPx(CallbackBridge.windowHeight / 9));
|
||||
leftView.setLayoutParams(leftRightParams);
|
||||
rightView.setLayoutParams(leftRightParams);
|
||||
mPlayButton.setLayoutParams(mPlayButtonParams);
|
||||
|
||||
@@ -185,8 +185,8 @@ public class PojavLauncherActivity extends BaseLauncherActivity
|
||||
protected float updateWidthHeight() {
|
||||
float leftRightWidth = (float) CallbackBridge.windowWidth / 100f * 32f;
|
||||
float mPlayButtonWidth = CallbackBridge.windowWidth - leftRightWidth * 2f;
|
||||
LinearLayout.LayoutParams leftRightParams = new LinearLayout.LayoutParams((int) leftRightWidth, (int) Tools.dpToPx(this, CallbackBridge.windowHeight / 9));
|
||||
LinearLayout.LayoutParams mPlayButtonParams = new LinearLayout.LayoutParams((int) mPlayButtonWidth, (int) Tools.dpToPx(this, CallbackBridge.windowHeight / 9));
|
||||
LinearLayout.LayoutParams leftRightParams = new LinearLayout.LayoutParams((int) leftRightWidth, (int) Tools.dpToPx(CallbackBridge.windowHeight / 9));
|
||||
LinearLayout.LayoutParams mPlayButtonParams = new LinearLayout.LayoutParams((int) mPlayButtonWidth, (int) Tools.dpToPx(CallbackBridge.windowHeight / 9));
|
||||
leftView.setLayoutParams(leftRightParams);
|
||||
rightView.setLayoutParams(leftRightParams);
|
||||
mPlayButton.setLayoutParams(mPlayButtonParams);
|
||||
|
||||
@@ -56,10 +56,10 @@ public class PojavLoginActivity extends BaseActivity
|
||||
|
||||
Tools.updateWindowSize(this);
|
||||
|
||||
ControlData.pixelOf2dp = (int) Tools.dpToPx(this, 2);
|
||||
ControlData.pixelOf30dp = (int) Tools.dpToPx(this, 30);
|
||||
ControlData.pixelOf50dp = (int) Tools.dpToPx(this, 50);
|
||||
ControlData.pixelOf80dp = (int) Tools.dpToPx(this, 80);
|
||||
ControlData.pixelOf2dp = (int) Tools.dpToPx(2);
|
||||
ControlData.pixelOf30dp = (int) Tools.dpToPx(30);
|
||||
ControlData.pixelOf50dp = (int) Tools.dpToPx(50);
|
||||
ControlData.pixelOf80dp = (int) Tools.dpToPx(80);
|
||||
ControlData[] specialButtons = ControlData.getSpecialButtons();
|
||||
specialButtons[0].name = getString(R.string.control_keyboard);
|
||||
specialButtons[1].name = getString(R.string.control_toggle);
|
||||
|
||||
@@ -341,15 +341,11 @@ public final class Tools
|
||||
CallbackBridge.windowHeight = currentDisplayMetrics.heightPixels;
|
||||
}
|
||||
|
||||
public static float pxToDp(Context ctx, float px) {
|
||||
return (px / ctx.getResources().getDisplayMetrics().density);
|
||||
}
|
||||
|
||||
public static float dpToPx(Context ctx, float dp) {
|
||||
public static float dpToPx(float dp) {
|
||||
// 921600 = 1280 * 720, default scale
|
||||
// TODO better way to scaling
|
||||
// float scaledDp = dp / 921600 * CallbackBridge.windowWidth * CallbackBridge.windowHeight;
|
||||
return (dp /* scaledDp */ * ctx.getResources().getDisplayMetrics().density);
|
||||
float scaledDp = dp / DisplayMetrics.DENSITY_XHIGH * currentDisplayMetrics.densityDpi;
|
||||
return (scaledDp * currentDisplayMetrics.density);
|
||||
}
|
||||
|
||||
public static void copyAssetFile(Context ctx, String fileName, String output, boolean overwrite) throws Exception
|
||||
|
||||
Reference in New Issue
Block a user