Merge branch 'v3_openjdk' of https://github.com/PojavLauncherTeam/PojavLauncher into v3_openjdk

This commit is contained in:
khanhduytran0 2020-11-20 14:25:24 +07:00
commit 9f73f983cb
6 changed files with 64 additions and 27 deletions

View file

@ -42,11 +42,44 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
} }
private int getInternalId(String type, String name) { private int getInternalId(String type, String name) {
/*
int id = Resources.getSystem().getIdentifier(name, type, "com.android.internal"); int id = Resources.getSystem().getIdentifier(name, type, "com.android.internal");
if (id == 0) { if (id == 0) {
mHandleView.getContext().getResources().getIdentifier(name, type, "android"); mHandleView.getContext().getResources().getIdentifier(name, type, "android");
} }
return id; return id;
*/
try {
for (Class perType : Class.forName("com.android.internal.R").getDeclaredClasses()) {
if (perType.getSimpleName().equals(type)) {
try {
Field f = perType.getDeclaredField(name);
f.setAccessible(true);
return (int) f.get(null);
} catch (Throwable th) {
th.printStackTrace();
}
}
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
// If unable to find in com.android.internal.R, go find in android.R
for (Class perType : android.R.class.getDeclaredClasses()) {
if (perType.getSimpleName().equals(type)) {
try {
Field f = perType.getDeclaredField(name);
f.setAccessible(true);
return (int) f.get(null);
} catch (Throwable th) {
th.printStackTrace();
}
}
}
return -1;
} }
@Override @Override

View file

@ -107,9 +107,11 @@ public class BaseMainActivity extends LoggableActivity {
// private static Collection<? extends Provider.Service> rsaPkcs1List; // private static Collection<? extends Provider.Service> rsaPkcs1List;
// @Override // @Override
public void onCreate(Bundle savedInstanceState, int resId) public void onCreate(Bundle savedInstanceState) {
{
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
}
protected void initLayout(int resId) {
setContentView(resId); setContentView(resId);
try { try {

View file

@ -14,7 +14,8 @@ public class CustomCtrlMainActivity extends BaseMainActivity implements OnClickL
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState, R.layout.main_with_customctrl); super.onCreate(savedInstanceState);
initLayout(R.layout.main_with_customctrl);
ControlData[] specialButtons = ControlData.getSpecialButtons(); ControlData[] specialButtons = ControlData.getSpecialButtons();
for (ControlData specialButton : specialButtons) { for (ControlData specialButton : specialButtons) {

View file

@ -23,7 +23,8 @@ public class MainActivity extends BaseMainActivity implements OnClickListener, O
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState, R.layout.main); super.onCreate(savedInstanceState);
initLayout(R.layout.main);
this.upButton = findButton(R.id.control_up); this.upButton = findButton(R.id.control_up);
this.downButton = findButton(R.id.control_down); this.downButton = findButton(R.id.control_down);

View file

@ -348,8 +348,8 @@ public final class Tools
public static float dpToPx(Context ctx, float dp) { public static float dpToPx(Context ctx, float dp) {
// 921600 = 1280 * 720, default scale // 921600 = 1280 * 720, default scale
// TODO better way to scaling // TODO better way to scaling
float scaledDp = dp / 921600 * CallbackBridge.windowWidth * CallbackBridge.windowHeight; // float scaledDp = dp / 921600 * CallbackBridge.windowWidth * CallbackBridge.windowHeight;
return (scaledDp * ctx.getResources().getDisplayMetrics().density); return (dp /* scaledDp */ * ctx.getResources().getDisplayMetrics().density);
} }
public static void copyAssetFile(Context ctx, String fileName, String output, boolean overwrite) throws Exception public static void copyAssetFile(Context ctx, String fileName, String output, boolean overwrite) throws Exception

View file

@ -13,11 +13,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<net.kdt.pojavlaunch.customcontrols.ControlLayout
android:id="@+id/main_control_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<net.kdt.pojavlaunch.MinecraftGLView <net.kdt.pojavlaunch.MinecraftGLView
android:id="@+id/main_game_render_view" android:id="@+id/main_game_render_view"
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -38,6 +33,11 @@
</LinearLayout> </LinearLayout>
<net.kdt.pojavlaunch.customcontrols.ControlLayout
android:id="@+id/main_control_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
</net.kdt.pojavlaunch.customcontrols.ControlLayout> </net.kdt.pojavlaunch.customcontrols.ControlLayout>
<LinearLayout <LinearLayout