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;
case R.id.nav_mousespd: adjustMouseSpeedLive();
break;
case R.id.nav_customctrl: openCustomControls();
break;
}
//Toast.makeText(MainActivity.this, menuItem.getTitle() + ":" + menuItem.getItemId(), Toast.LENGTH_SHORT).show();
@ -231,6 +233,7 @@ public class BaseMainActivity extends LoggableActivity {
public void run()
{
while (!isExited) {
if (lastGrab != CallbackBridge.isGrabbing())
mousePointer.post(new Runnable(){
@Override
@ -263,9 +266,9 @@ public class BaseMainActivity extends LoggableActivity {
}
});
try {
Thread.sleep(100);
} catch (Throwable th) {}
// try {
// Thread.sleep(100);
// } catch (Throwable th) {}
}
}
}).start();
@ -705,7 +708,7 @@ public class BaseMainActivity extends LoggableActivity {
Tools.showError(BaseMainActivity.this, e, true);
}
}
}).start();
}, "JVM Main thread").start();
}
}
@ -846,16 +849,6 @@ public class BaseMainActivity extends LoggableActivity {
decorView.setSystemUiVisibility(uiOptions);
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
/*
if (hasFocus && minecraftGLView.getVisibility() == View.GONE) {
minecraftGLView.setVisibility(View.VISIBLE);
}
*/
}
@Override
protected void onPause()
{
@ -870,24 +863,6 @@ public class BaseMainActivity extends LoggableActivity {
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() {
return Build.VERSION.SDK_INT >= 26;
}
@ -931,7 +906,7 @@ public class BaseMainActivity extends LoggableActivity {
private void checkJavaArgsIsLaunchable(String jreVersion) throws Throwable {
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
@ -1011,6 +986,11 @@ public class BaseMainActivity extends LoggableActivity {
dialog.show();
}
private void openCustomControls() {
Intent intent = new Intent(this, CustomControlsActivity.class);
startActivity(intent);
}
private void openLogOutput() {
contentLog.setVisibility(View.VISIBLE);
mIsResuming = false;

View file

@ -33,6 +33,12 @@ public class CustomControlsActivity extends BaseActivity
@Override
protected void onCreate(Bundle 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);
mPref = PreferenceManager.getDefaultSharedPreferences(this);

View file

@ -40,8 +40,24 @@ public class ControlLayout extends FrameLayout
public void loadLayout(CustomControls controlLayout) {
if (mModifiable) {
hideAllHandleViews();
}
if (getChildAt(0) instanceof MinecraftGLView) {
View viewGL = getChildAt(0);
View viewTouchpad = getChildAt(1);
removeAllViews();
addView(viewGL);
addView(viewTouchpad);
} else {
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;

View file

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