Several unused codes cleanup; in-game change control (unfinished!)

This commit is contained in:
khanhduytran0 2021-02-24 09:51:37 +07:00
parent 5fba7e7170
commit 3820760b61
4 changed files with 40 additions and 35 deletions

View file

@ -164,6 +164,8 @@ public class BaseMainActivity extends LoggableActivity {
break; break;
case R.id.nav_mousespd: adjustMouseSpeedLive(); case R.id.nav_mousespd: adjustMouseSpeedLive();
break; break;
case R.id.nav_customctrl: openCustomControls();
break;
} }
//Toast.makeText(MainActivity.this, menuItem.getTitle() + ":" + menuItem.getItemId(), Toast.LENGTH_SHORT).show(); //Toast.makeText(MainActivity.this, menuItem.getTitle() + ":" + menuItem.getItemId(), Toast.LENGTH_SHORT).show();
@ -231,6 +233,7 @@ public class BaseMainActivity extends LoggableActivity {
public void run() public void run()
{ {
while (!isExited) { while (!isExited) {
if (lastGrab != CallbackBridge.isGrabbing())
mousePointer.post(new Runnable(){ mousePointer.post(new Runnable(){
@Override @Override
@ -263,9 +266,9 @@ public class BaseMainActivity extends LoggableActivity {
} }
}); });
try { // try {
Thread.sleep(100); // Thread.sleep(100);
} catch (Throwable th) {} // } catch (Throwable th) {}
} }
} }
}).start(); }).start();
@ -705,7 +708,7 @@ public class BaseMainActivity extends LoggableActivity {
Tools.showError(BaseMainActivity.this, e, true); Tools.showError(BaseMainActivity.this, e, true);
} }
} }
}).start(); }, "JVM Main thread").start();
} }
} }
@ -846,16 +849,6 @@ public class BaseMainActivity extends LoggableActivity {
decorView.setSystemUiVisibility(uiOptions); decorView.setSystemUiVisibility(uiOptions);
} }
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
/*
if (hasFocus && minecraftGLView.getVisibility() == View.GONE) {
minecraftGLView.setVisibility(View.VISIBLE);
}
*/
}
@Override @Override
protected void onPause() protected void onPause()
{ {
@ -870,24 +863,6 @@ public class BaseMainActivity extends LoggableActivity {
android.os.Process.killProcess(android.os.Process.myPid()); android.os.Process.killProcess(android.os.Process.myPid());
} }
public void forceUserHome(String s) throws Exception {
Properties props = System.getProperties();
Class clazz = props.getClass();
Field f = null;
while (clazz != null) {
try {
f = clazz.getDeclaredField("defaults");
break;
} catch (Exception e) {
clazz = clazz.getSuperclass();
}
}
if (f != null) {
f.setAccessible(true);
((Properties) f.get(props)).put("user.home", s);
}
}
public static boolean isAndroid8OrHigher() { public static boolean isAndroid8OrHigher() {
return Build.VERSION.SDK_INT >= 26; return Build.VERSION.SDK_INT >= 26;
} }
@ -931,7 +906,7 @@ public class BaseMainActivity extends LoggableActivity {
private void checkJavaArgsIsLaunchable(String jreVersion) throws Throwable { private void checkJavaArgsIsLaunchable(String jreVersion) throws Throwable {
appendlnToLog("Info: Custom Java arguments: \"" + LauncherPreferences.PREF_CUSTOM_JAVA_ARGS + "\""); appendlnToLog("Info: Custom Java arguments: \"" + LauncherPreferences.PREF_CUSTOM_JAVA_ARGS + "\"");
if (jreVersion.equals("1.9.0")) return; if (jreVersion.equals("1.8.0")) return;
/* /*
// Test java // Test java
@ -1011,6 +986,11 @@ public class BaseMainActivity extends LoggableActivity {
dialog.show(); dialog.show();
} }
private void openCustomControls() {
Intent intent = new Intent(this, CustomControlsActivity.class);
startActivity(intent);
}
private void openLogOutput() { private void openLogOutput() {
contentLog.setVisibility(View.VISIBLE); contentLog.setVisibility(View.VISIBLE);
mIsResuming = false; mIsResuming = false;

View file

@ -33,6 +33,12 @@ public class CustomControlsActivity extends BaseActivity
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (getIntent().getExtras().getBoolean("fromMainActivity", false)) {
// TODO translucent!
// setTheme(androidx.appcompat.R.style.Theme_AppCompat_Translucent);
}
setContentView(R.layout.control_mapping); setContentView(R.layout.control_mapping);
mPref = PreferenceManager.getDefaultSharedPreferences(this); mPref = PreferenceManager.getDefaultSharedPreferences(this);

View file

@ -40,8 +40,24 @@ public class ControlLayout extends FrameLayout
public void loadLayout(CustomControls controlLayout) { public void loadLayout(CustomControls controlLayout) {
if (mModifiable) { if (mModifiable) {
hideAllHandleViews(); hideAllHandleViews();
}
if (getChildAt(0) instanceof MinecraftGLView) {
View viewGL = getChildAt(0);
View viewTouchpad = getChildAt(1);
removeAllViews();
addView(viewGL);
addView(viewTouchpad);
} else {
removeAllViews(); removeAllViews();
} }
if (mLayout != null) {
mLayout.mControlDataList = null;
mLayout = null;
}
System.gc();
// Cleanup buttons only when input layout is null
if (controlLayout == null) return;
mLayout = controlLayout; mLayout = controlLayout;

View file

@ -15,4 +15,7 @@
<item <item
android:id="@+id/nav_mousespd" android:id="@+id/nav_mousespd"
android:title="@string/mcl_setting_title_mousespeed" /> android:title="@string/mcl_setting_title_mousespeed" />
<item
android:id="@+id/nav_customctrl"
android:title="@string/mcl_setting_title_mousespeed" />
</menu> </menu>