This commit is contained in:
Epic Studios 2024-01-26 05:05:38 +02:00
parent e724a517a8
commit a6d138dfb8
47 changed files with 1169 additions and 954 deletions

View file

@ -108,7 +108,7 @@ public class Config {
return cacheDir.toString();
}
public static final String getBasefileDir() {
return getCacheDir() + "/vectras/";
return AppConfig.basefiledir;
}
public static String machineFolder = "machines/";

View file

@ -451,13 +451,13 @@ public class MainSDLActivity extends SDLActivity {
}
private void onMouseMode() {
public void onMouseMode() {
String[] items = {"Trackpad Mouse (Phone)",
"Bluetooth/USB Mouse (Desktop mode)", //Physical mouse for Chromebook, Android x86 PC, or Bluetooth Mouse
};
final AlertDialog.Builder mBuilder = new AlertDialog.Builder(this);
mBuilder.setTitle("Mouse");
final AlertDialog.Builder mBuilder = new AlertDialog.Builder(this, R.style.MainDialogTheme);
mBuilder.setTitle("Mouse Mode");
mBuilder.setSingleChoiceItems(items, Config.mouseMode.ordinal(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int i) {
@ -531,13 +531,6 @@ public class MainSDLActivity extends SDLActivity {
final AlertDialog alertDialog;
alertDialog = new AlertDialog.Builder(activity).create();
alertDialog.setTitle("Desktop Mode");
LinearLayout mLayout = new LinearLayout(this);
mLayout.setPadding(20, 20, 20, 20);
mLayout.setOrientation(LinearLayout.VERTICAL);
TextView textView = new TextView(activity);
textView.setVisibility(View.VISIBLE);
String desktopInstructions = this.getString(R.string.desktopInstructions);
if (!checkVMResolutionFits()) {
String resolutionWarning = "Warning: MainActivity.vmexecutor resolution "
@ -547,17 +540,7 @@ public class MainSDLActivity extends SDLActivity {
"Reduce display resolution within the Guest OS for better experience.\n\n";
desktopInstructions = resolutionWarning + desktopInstructions;
}
textView.setText(desktopInstructions);
ScrollView scrollView = new ScrollView(this);
scrollView.addView(textView);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
mLayout.addView(scrollView, params);
alertDialog.setView(mLayout);
alertDialog.setMessage(desktopInstructions);
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
setUIModeDesktop();
@ -934,7 +917,6 @@ public class MainSDLActivity extends SDLActivity {
ImageButton ctrlBtn = findViewById(R.id.ctrlBtn);
ImageButton altBtn = findViewById(R.id.altBtn);
ImageButton delBtn = findViewById(R.id.delBtn);
Button ctrlAltDelBtn = findViewById(R.id.ctrlAltDelBtn);
ImageButton qmpBtn = findViewById(R.id.btnQmp);
ImageButton btnLogs = findViewById(R.id.btnLogs);
btnLogs.setOnClickListener(new View.OnClickListener() {
@ -1049,7 +1031,7 @@ public class MainSDLActivity extends SDLActivity {
delayKey(100);
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_ENTER);
delayKey(100);
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_ENTER);
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_ENTER);
}
});
ctrlBtn.setOnClickListener(new View.OnClickListener() {
@ -1091,12 +1073,6 @@ public class MainSDLActivity extends SDLActivity {
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DEL);
}
});
ctrlAltDelBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sendCtrlAltKey(KeyEvent.KEYCODE_DEL);
}
});
qmpBtn.setVisibility(View.GONE);
if (monitorMode) {
qmpBtn.setImageDrawable(getResources().getDrawable(R.drawable.round_terminal_24));
@ -1156,6 +1132,7 @@ public class MainSDLActivity extends SDLActivity {
});
}
private void createUI(int w, int h) {
mSurface = new MainSDLSurface(this);

View file

@ -755,6 +755,32 @@ public class MainSettingsManager extends AppCompatActivity
return prefs.getString("TbSize", "2048");
}
public static void setBoot(Activity activity, String boot) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
SharedPreferences.Editor edit = prefs.edit();
edit.putString("boot", boot);
edit.apply();
}
public static String getBoot(Activity activity) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
return prefs.getString("boot", "c");
}
public static void setCpu(Activity activity, String cpu) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
SharedPreferences.Editor edit = prefs.edit();
edit.putString("cpu", cpu);
edit.apply();
}
public static String getCpu(Activity activity) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
return prefs.getString("cpu", "qemu64");
}
public static void setVmUi(Activity activity, String vmUi) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
SharedPreferences.Editor edit = prefs.edit();

View file

@ -93,6 +93,7 @@ public class MainVNCActivity extends VncCanvasActivity {
public boolean ctrlClicked = false;
public boolean altClicked = false;
private ImageButton qmpBtn;
public static MainVNCActivity activity;
@Override
public void onCreate(Bundle b) {
@ -102,6 +103,7 @@ public class MainVNCActivity extends VncCanvasActivity {
WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(b);
activity = this;
this.vncCanvas.setFocusableInTouchMode(true);
@ -132,7 +134,6 @@ public class MainVNCActivity extends VncCanvasActivity {
ImageButton altBtn = findViewById(R.id.altBtn);
ImageButton delBtn = findViewById(R.id.delBtn);
ImageButton btnLogs = findViewById(R.id.btnLogs);
Button ctrlAltDelBtn = findViewById(R.id.ctrlAltDelBtn);
qmpBtn = findViewById(R.id.btnQmp);
btnLogs.setOnClickListener(new View.OnClickListener() {
@Override
@ -279,12 +280,6 @@ public class MainVNCActivity extends VncCanvasActivity {
keyDownUp(KeyEvent.KEYCODE_DEL);
}
});
ctrlAltDelBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sendCtrlAtlDelKey();
}
});
qmpBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -630,7 +625,7 @@ public class MainVNCActivity extends VncCanvasActivity {
return true;
}
private void onMouseMode() {
public void onMouseMode() {
String[] items = {"Trackpad Mouse (Phone)",
"Bluetooth/USB Mouse (Desktop mode)", //Physical mouse for Chromebook, Android x86 PC, or Bluetooth Mouse
@ -732,32 +727,16 @@ public class MainVNCActivity extends VncCanvasActivity {
final AlertDialog alertDialog;
alertDialog = new AlertDialog.Builder(activity, R.style.MainDialogTheme).create();
alertDialog.setTitle("Desktop mode");
LinearLayout mLayout = new LinearLayout(this);
mLayout.setPadding(20, 20, 20, 20);
mLayout.setOrientation(LinearLayout.VERTICAL);
TextView textView = new TextView(activity);
textView.setVisibility(View.VISIBLE);
String desktopInstructions = this.getString(R.string.desktopInstructions);
if (!checkVMResolutionFits()) {
String resolutionWarning = "Warning: Machine resolution "
String resolutionWarning = "Warning: MainActivity.vmexecutor resolution "
+ vncCanvas.rfb.framebufferWidth + "x" + vncCanvas.rfb.framebufferHeight +
" is too high for Desktop Mode. " +
"Scaling will be used and Mouse Alignment will not be accurate. " +
"Reduce display resolution for better experience\n\n";
"Reduce display resolution within the Guest OS for better experience.\n\n";
desktopInstructions = resolutionWarning + desktopInstructions;
}
textView.setText(desktopInstructions);
LinearLayout.LayoutParams textViewParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
ScrollView scrollView = new ScrollView(this);
scrollView.addView(textView);
mLayout.addView(scrollView, textViewParams);
alertDialog.setView(mLayout);
alertDialog.setMessage(desktopInstructions);
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {

View file

@ -155,8 +155,9 @@ public class StartVM {
this.libqemu = FileUtils.getNativeLibDir(context) + "/libqemu-system-x86_64.so";
this.arch = "x86_64";
this.machine_type = "pc";
this.cpu = "qemu64";
this.cpu = MainSettingsManager.getCpu(MainActivity.activity);
}
bootdevice = MainSettingsManager.getBoot(MainActivity.activity);
this.sound_card = MainSettingsManager.getSoundCard(MainActivity.activity);
this.cpuNum = MainSettingsManager.getCpuNum(MainActivity.activity);