mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-17 16:47:14 -04:00
- Update JavaGUILauncherActivity to use LoggerView
- Simplified view hierarchy
This commit is contained in:
parent
364509069e
commit
d44f2dc023
@ -17,14 +17,13 @@ import org.lwjgl.glfw.*;
|
|||||||
|
|
||||||
import static net.kdt.pojavlaunch.utils.MathUtils.map;
|
import static net.kdt.pojavlaunch.utils.MathUtils.map;
|
||||||
|
|
||||||
|
import com.kdt.LoggerView;
|
||||||
|
|
||||||
public class JavaGUILauncherActivity extends LoggableActivity implements View.OnTouchListener {
|
public class JavaGUILauncherActivity extends LoggableActivity implements View.OnTouchListener {
|
||||||
private static final int MSG_LEFT_MOUSE_BUTTON_CHECK = 1028;
|
private static final int MSG_LEFT_MOUSE_BUTTON_CHECK = 1028;
|
||||||
|
|
||||||
private AWTCanvasView mTextureView;
|
private AWTCanvasView mTextureView;
|
||||||
private LinearLayout contentLog;
|
private LoggerView loggerView;
|
||||||
private TextView textLog;
|
|
||||||
private ScrollView contentScroll;
|
|
||||||
private ToggleButton toggleLog;
|
|
||||||
|
|
||||||
private LinearLayout touchPad;
|
private LinearLayout touchPad;
|
||||||
private ImageView mousePointer;
|
private ImageView mousePointer;
|
||||||
@ -68,6 +67,7 @@ public class JavaGUILauncherActivity extends LoggableActivity implements View.On
|
|||||||
Tools.updateWindowSize(this);
|
Tools.updateWindowSize(this);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
loggerView = findViewById(R.id.launcherLoggerView);
|
||||||
MultiRTUtils.setRuntimeNamed(this,LauncherPreferences.PREF_DEFAULT_RUNTIME);
|
MultiRTUtils.setRuntimeNamed(this,LauncherPreferences.PREF_DEFAULT_RUNTIME);
|
||||||
gestureDetector = new GestureDetector(this, new SingleTapConfirm());
|
gestureDetector = new GestureDetector(this, new SingleTapConfirm());
|
||||||
|
|
||||||
@ -145,85 +145,58 @@ public class JavaGUILauncherActivity extends LoggableActivity implements View.On
|
|||||||
});
|
});
|
||||||
|
|
||||||
placeMouseAt(CallbackBridge.physicalWidth / 2, CallbackBridge.physicalHeight / 2);
|
placeMouseAt(CallbackBridge.physicalWidth / 2, CallbackBridge.physicalHeight / 2);
|
||||||
|
|
||||||
this.contentLog = findViewById(R.id.content_log_layout);
|
|
||||||
this.contentScroll = (ScrollView) findViewById(R.id.content_log_scroll);
|
|
||||||
this.textLog = (TextView) contentScroll.getChildAt(0);
|
|
||||||
this.toggleLog = (ToggleButton) findViewById(R.id.content_log_toggle_log);
|
|
||||||
this.toggleLog.setChecked(false);
|
|
||||||
// this.textLogBehindGL = (TextView) findViewById(R.id.main_log_behind_GL);
|
// this.textLogBehindGL = (TextView) findViewById(R.id.main_log_behind_GL);
|
||||||
// this.textLogBehindGL.setTypeface(Typeface.MONOSPACE);
|
// this.textLogBehindGL.setTypeface(Typeface.MONOSPACE);
|
||||||
this.textLog.setTypeface(Typeface.MONOSPACE);
|
|
||||||
this.toggleLog.setOnCheckedChangeListener(new ToggleButton.OnCheckedChangeListener(){
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton button, boolean isChecked) {
|
|
||||||
isLogAllow = isChecked;
|
|
||||||
Logger.getInstance().appendToLog("");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final File modFile = (File) getIntent().getExtras().getSerializable("modFile");
|
final File modFile = (File) getIntent().getExtras().getSerializable("modFile");
|
||||||
final String javaArgs = getIntent().getExtras().getString("javaArgs");
|
final String javaArgs = getIntent().getExtras().getString("javaArgs");
|
||||||
|
|
||||||
mTextureView = findViewById(R.id.installmod_surfaceview);
|
mTextureView = findViewById(R.id.installmod_surfaceview);
|
||||||
mTextureView.setOnTouchListener(new OnTouchListener(){
|
mTextureView.setOnTouchListener((v, event) -> {
|
||||||
@Override
|
float x = event.getX();
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
float y = event.getY();
|
||||||
float x = event.getX();
|
if (gestureDetector.onTouchEvent(event)) {
|
||||||
float y = event.getY();
|
sendScaledMousePosition(x, y);
|
||||||
if (gestureDetector.onTouchEvent(event)) {
|
AWTInputBridge.sendMousePress(rightOverride ? AWTInputEvent.BUTTON3_DOWN_MASK : AWTInputEvent.BUTTON1_DOWN_MASK);
|
||||||
sendScaledMousePosition(x, y);
|
|
||||||
AWTInputBridge.sendMousePress(rightOverride ? AWTInputEvent.BUTTON3_DOWN_MASK : AWTInputEvent.BUTTON1_DOWN_MASK);
|
|
||||||
} else {
|
|
||||||
switch (event.getActionMasked()) {
|
|
||||||
case MotionEvent.ACTION_UP: // 1
|
|
||||||
case MotionEvent.ACTION_CANCEL: // 3
|
|
||||||
case MotionEvent.ACTION_POINTER_UP: // 6
|
|
||||||
break;
|
|
||||||
case MotionEvent.ACTION_MOVE: // 2
|
|
||||||
sendScaledMousePosition(x, y);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (event.getActionMasked()) {
|
||||||
|
case MotionEvent.ACTION_UP: // 1
|
||||||
|
case MotionEvent.ACTION_CANCEL: // 3
|
||||||
|
case MotionEvent.ACTION_POINTER_UP: // 6
|
||||||
|
break;
|
||||||
|
case MotionEvent.ACTION_MOVE: // 2
|
||||||
|
sendScaledMousePosition(x, y);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
mSkipDetectMod = getIntent().getExtras().getBoolean("skipDetectMod", false);
|
mSkipDetectMod = getIntent().getExtras().getBoolean("skipDetectMod", false);
|
||||||
if (mSkipDetectMod) {
|
if (mSkipDetectMod) {
|
||||||
new Thread(new Runnable(){
|
new Thread(() -> launchJavaRuntime(modFile, javaArgs), "JREMainThread").start();
|
||||||
@Override
|
return;
|
||||||
public void run() {
|
|
||||||
launchJavaRuntime(modFile, javaArgs);
|
|
||||||
}
|
|
||||||
}, "JREMainThread").start();
|
|
||||||
} else {
|
|
||||||
openLogOutput(null);
|
|
||||||
new Thread(new Runnable(){
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
final int exit = doCustomInstall(modFile, javaArgs);
|
|
||||||
Logger.getInstance().appendToLog(getString(R.string.toast_optifine_success));
|
|
||||||
if (exit == 0) {
|
|
||||||
runOnUiThread(new Runnable(){
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Toast.makeText(JavaGUILauncherActivity.this, R.string.toast_optifine_success, Toast.LENGTH_SHORT).show();
|
|
||||||
MainActivity.fullyExit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} /* else {
|
|
||||||
throw new ErrnoException(getString(R.string.glo, exit);
|
|
||||||
} */
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Logger.getInstance().appendToLog("Install failed:");
|
|
||||||
Logger.getInstance().appendToLog(Log.getStackTraceString(e));
|
|
||||||
Tools.showError(JavaGUILauncherActivity.this, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, "Installer").start();
|
|
||||||
}
|
}
|
||||||
|
// No skip detection
|
||||||
|
openLogOutput(null);
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
final int exit = doCustomInstall(modFile, javaArgs);
|
||||||
|
Logger.getInstance().appendToLog(getString(R.string.toast_optifine_success));
|
||||||
|
if (exit != 0) return;
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
Toast.makeText(JavaGUILauncherActivity.this, R.string.toast_optifine_success, Toast.LENGTH_SHORT).show();
|
||||||
|
MainActivity.fullyExit();
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Logger.getInstance().appendToLog("Install failed:");
|
||||||
|
Logger.getInstance().appendToLog(Log.getStackTraceString(e));
|
||||||
|
Tools.showError(JavaGUILauncherActivity.this, e);
|
||||||
|
}
|
||||||
|
}, "Installer").start();
|
||||||
} catch (Throwable th) {
|
} catch (Throwable th) {
|
||||||
Tools.showError(this, th, true);
|
Tools.showError(this, th, true);
|
||||||
}
|
}
|
||||||
@ -278,12 +251,12 @@ public class JavaGUILauncherActivity extends LoggableActivity implements View.On
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void openLogOutput(View v) {
|
public void openLogOutput(View v) {
|
||||||
contentLog.setVisibility(View.VISIBLE);
|
loggerView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeLogOutput(View view) {
|
public void closeLogOutput(View view) {
|
||||||
if (mSkipDetectMod) {
|
if (mSkipDetectMod) {
|
||||||
contentLog.setVisibility(View.GONE);
|
loggerView.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
forceClose(null);
|
forceClose(null);
|
||||||
}
|
}
|
||||||
@ -350,16 +323,6 @@ public class JavaGUILauncherActivity extends LoggableActivity implements View.On
|
|||||||
decorView.setSystemUiVisibility(uiOptions);
|
decorView.setSystemUiVisibility(uiOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void purposefullybrokenName(final String text, boolean checkAllow) {
|
|
||||||
|
|
||||||
if (checkAllow && !isLogAllow) return;
|
|
||||||
textLog.post(() -> {
|
|
||||||
textLog.append(text);
|
|
||||||
contentScroll.fullScroll(ScrollView.FOCUS_DOWN);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] initScaleFactors(){
|
int[] initScaleFactors(){
|
||||||
return initScaleFactors(true);
|
return initScaleFactors(true);
|
||||||
}
|
}
|
||||||
|
@ -14,16 +14,16 @@
|
|||||||
android:id="@+id/installmod_surfaceview"/>
|
android:id="@+id/installmod_surfaceview"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_height="match_parent"
|
android:id="@+id/main_touchpad"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:orientation="vertical"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/main_touchpad">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_height="27dp"
|
android:id="@+id/main_mouse_pointer"
|
||||||
android:layout_width="18dp"
|
android:layout_width="18dp"
|
||||||
android:src="@drawable/mouse_pointer"
|
android:layout_height="27dp"
|
||||||
android:id="@+id/main_mouse_pointer"/>
|
android:src="@drawable/mouse_pointer" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -90,58 +90,12 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<com.kdt.LoggerView
|
||||||
android:id="@+id/content_log_layout"
|
android:id="@+id/launcherLoggerView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:orientation="vertical">
|
/>
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_height="42dp"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:background="#555555">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:text="@string/control_viewout"
|
|
||||||
android:paddingLeft="15dp"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
|
||||||
android:layout_centerVertical="true"/>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_height="42dp"
|
|
||||||
android:layout_width="42dp"
|
|
||||||
android:src="@android:drawable/ic_delete"
|
|
||||||
android:onClick="closeLogOutput"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:id="@+id/content_log_close_button"/>
|
|
||||||
|
|
||||||
<ToggleButton
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_toLeftOf="@id/content_log_close_button"
|
|
||||||
android:id="@+id/content_log_toggle_log"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:id="@+id/content_log_scroll"
|
|
||||||
android:alpha="0.8"
|
|
||||||
android:background="#000000">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:textIsSelectable="true"/>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user