mirror of
https://github.com/xoureldeen/Vectras-VM-Android.git
synced 2026-04-29 14:59:50 +00:00
Doughnut
This commit is contained in:
parent
5604b1fdf7
commit
a1e7f2336c
15 changed files with 186 additions and 23 deletions
|
|
@ -219,6 +219,23 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
startActivityForResult(intent, 1001);
|
||||
}
|
||||
});
|
||||
|
||||
icon.setOnLongClickListener((View.OnLongClickListener) v -> {
|
||||
if (!Objects.requireNonNull(icon.getText()).toString().isEmpty()) {
|
||||
icon.setText("");
|
||||
VectrasApp.setIconWithName(ivIcon, Objects.requireNonNull(title.getText()).toString());
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
iconLayout.setOnLongClickListener((View.OnLongClickListener) v -> {
|
||||
if (!Objects.requireNonNull(icon.getText()).toString().isEmpty()) {
|
||||
icon.setText("");
|
||||
VectrasApp.setIconWithName(ivIcon, Objects.requireNonNull(title.getText()).toString());
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
drive.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
@ -235,6 +252,7 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
startActivityForResult(intent, 1002);
|
||||
}
|
||||
});
|
||||
|
||||
driveLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
@ -265,6 +283,20 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
|
||||
drive.setOnLongClickListener((View.OnLongClickListener) v -> {
|
||||
if (!Objects.requireNonNull(drive.getText()).toString().isEmpty()) {
|
||||
drive.setText("");
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
driveLayout.setOnLongClickListener((View.OnLongClickListener) v -> {
|
||||
if (!Objects.requireNonNull(drive.getText()).toString().isEmpty()) {
|
||||
drive.setText("");
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
View.OnClickListener cdromClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
@ -330,6 +362,20 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
cdrom.setOnClickListener(cdromClickListener);
|
||||
cdromLayout.setOnClickListener(cdromClickListener);
|
||||
|
||||
cdrom.setOnLongClickListener((View.OnLongClickListener) v -> {
|
||||
if (!Objects.requireNonNull(cdrom.getText()).toString().isEmpty()) {
|
||||
cdrom.setText("");
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
cdromLayout.setOnLongClickListener((View.OnLongClickListener) v -> {
|
||||
if (!Objects.requireNonNull(cdrom.getText()).toString().isEmpty()) {
|
||||
cdrom.setText("");
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
addRomBtn = findViewById(R.id.addRomBtn);
|
||||
addRomBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
@ -450,6 +496,14 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
|
||||
ivIcon.setOnLongClickListener((View.OnLongClickListener) v -> {
|
||||
if (!Objects.requireNonNull(icon.getText()).toString().isEmpty()) {
|
||||
icon.setText("");
|
||||
VectrasApp.setIconWithName(ivIcon, title.getText().toString());
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
modify = getIntent().getBooleanExtra("MODIFY", false);
|
||||
if (modify) {
|
||||
created = true;
|
||||
|
|
|
|||
|
|
@ -1128,9 +1128,18 @@ public class MainActivity extends AppCompatActivity {
|
|||
VectrasApp.oneDialog(activity.getResources().getString(R.string.problem_has_been_detected), activity.getResources().getString(R.string.harmful_command_was_detected), true, false, activity);
|
||||
return;
|
||||
}
|
||||
StartVM.cdrompath = "";
|
||||
String env = StartVM.env(MainActivity.activity, AppConfig.pendingCommand, "", "1");
|
||||
MainActivity.startVM("Quick run", env, AppConfig.pendingCommand, "");
|
||||
if (AppConfig.pendingCommand.startsWith("qemu-img")) {
|
||||
if (!VMManager.isthiscommandsafeimg(AppConfig.pendingCommand)) {
|
||||
return;
|
||||
}
|
||||
Terminal _vterm = new Terminal(MainActivity.this);
|
||||
_vterm.executeShellCommand2(AppConfig.pendingCommand, false, MainActivity.activity);
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.done), Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
StartVM.cdrompath = "";
|
||||
String env = StartVM.env(MainActivity.activity, AppConfig.pendingCommand, "", "1");
|
||||
MainActivity.startVM("Quick run", env, AppConfig.pendingCommand, "");
|
||||
}
|
||||
AppConfig.pendingCommand = "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ public class Minitools extends AppCompatActivity {
|
|||
LinearLayout restore = findViewById(R.id.restore);
|
||||
LinearLayout deleteallvm = findViewById(R.id.deleteallvm);
|
||||
LinearLayout reinstallsystem = findViewById(R.id.reinstallsystem);
|
||||
LinearLayout deleteall = findViewById(R.id.deleteall);
|
||||
|
||||
setupsoundfortermux.setOnClickListener(v -> {
|
||||
if (VectrasApp.isAppInstalled("com.termux", getApplicationContext())) {
|
||||
|
|
@ -167,6 +168,32 @@ public class Minitools extends AppCompatActivity {
|
|||
alertDialog.show();
|
||||
});
|
||||
|
||||
deleteall.setOnClickListener(v -> {
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(Minitools.this, R.style.MainDialogTheme).create();
|
||||
alertDialog.setTitle(getResources().getString(R.string.delete_all));
|
||||
alertDialog.setMessage(getResources().getString(R.string.delete_all_content));
|
||||
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.delete_all), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
VectrasApp.killallqemuprocesses(getApplicationContext());
|
||||
VectrasApp.deleteDirectory(AppConfig.maindirpath);
|
||||
File vDir = new File(AppConfig.maindirpath);
|
||||
vDir.mkdirs();
|
||||
VectrasApp.writeToFile(AppConfig.maindirpath, "roms-data.json", "[]");
|
||||
cleanup.setVisibility(GONE);
|
||||
restore.setVisibility(GONE);
|
||||
deleteallvm.setVisibility(GONE);
|
||||
deleteall.setVisibility(GONE);
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.done), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
});
|
||||
|
||||
reinstallsystem.setOnClickListener(v -> {
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(Minitools.this, R.style.MainDialogTheme).create();
|
||||
alertDialog.setTitle(getResources().getString(R.string.reinstall_system));
|
||||
|
|
|
|||
|
|
@ -146,12 +146,16 @@ public class SetupQemuActivity extends AppCompatActivity implements View.OnClick
|
|||
linearcannotconnecttoserver.setVisibility(View.GONE);
|
||||
}
|
||||
if (AppConfig.needreinstallsystem) {
|
||||
if (AppConfig.getSetupFiles().contains("arm64-v8a") || AppConfig.getSetupFiles().contains("x86_64")) {
|
||||
setupVectras64();
|
||||
} else {
|
||||
setupVectras32();
|
||||
AppConfig.needreinstallsystem = false;
|
||||
if (!MainSettingsManager.getsetUpWithManualSetupBefore(SetupQemuActivity.this)) {
|
||||
if (AppConfig.getSetupFiles().contains("arm64-v8a") || AppConfig.getSetupFiles().contains("x86_64")) {
|
||||
setupVectras64();
|
||||
} else {
|
||||
setupVectras32();
|
||||
}
|
||||
textviewsettingup.setText(getResources().getString(R.string.reinstalling));
|
||||
simpleSetupUIControler(1);
|
||||
}
|
||||
textviewsettingup.setText(getResources().getString(R.string.reinstalling));
|
||||
}
|
||||
} else {
|
||||
linearload.setVisibility(View.GONE);
|
||||
|
|
@ -792,6 +796,7 @@ public class SetupQemuActivity extends AppCompatActivity implements View.OnClick
|
|||
loading.setVisibility(View.GONE);
|
||||
alertDialog.dismiss();
|
||||
setupVectras();
|
||||
MainSettingsManager.setsetUpWithManualSetupBefore(SetupQemuActivity.this, true);
|
||||
}
|
||||
};
|
||||
activity.runOnUiThread(runnable);
|
||||
|
|
|
|||
|
|
@ -636,4 +636,23 @@ public class VMManager {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isthiscommandsafeimg(String _command) {
|
||||
if (!_command.contains("-f qcow2")) {
|
||||
String _getsize = _command.substring(_command.lastIndexOf(" ") + 1);
|
||||
if (_getsize.toLowerCase().endsWith("t") || _getsize.toLowerCase().endsWith("p") || _getsize.toLowerCase().endsWith("e")) {
|
||||
return false;
|
||||
}
|
||||
if (_getsize.toLowerCase().endsWith("g")) {
|
||||
return _getsize.length() <= 2;
|
||||
}
|
||||
if (_getsize.toLowerCase().endsWith("m")) {
|
||||
return _getsize.length() <= 4;
|
||||
}
|
||||
if (_getsize.toLowerCase().endsWith("k")) {
|
||||
return _getsize.length() <= 8;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue