mirror of
https://github.com/xoureldeen/Vectras-VM-Android.git
synced 2026-04-29 23:09:48 +00:00
Ladyfingers
This commit is contained in:
parent
c448139d4b
commit
802e60902c
14 changed files with 167 additions and 75 deletions
|
|
@ -98,7 +98,7 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
public String previousName = "";
|
||||
public String secondVMdirectory = "";
|
||||
public boolean addromnowdone = false;
|
||||
public String vmID = VMManager.idGenerator();
|
||||
public static String vmID = VMManager.idGenerator();
|
||||
public int port = VMManager.startRandomPort();
|
||||
private boolean created = false;
|
||||
|
||||
|
|
@ -302,10 +302,10 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if (Objects.requireNonNull(drive.getText()).toString().isEmpty()) {
|
||||
File vDir = new File(com.vectras.vm.AppConfig.maindirpath + "IMG");
|
||||
if (!vDir.exists()) {
|
||||
vDir.mkdirs();
|
||||
}
|
||||
// File vDir = new File(com.vectras.vm.AppConfig.maindirpath + "IMG");
|
||||
// if (!vDir.exists()) {
|
||||
// vDir.mkdirs();
|
||||
// }
|
||||
CreateImageDialogFragment dialogFragment = new CreateImageDialogFragment();
|
||||
dialogFragment.customRom = true;
|
||||
dialogFragment.show(getSupportFragmentManager(), "CreateImageDialogFragment");
|
||||
|
|
|
|||
|
|
@ -23,10 +23,14 @@ import com.vectras.vm.R;
|
|||
import com.vectras.vm.utils.FileUtils;
|
||||
import com.vectras.vterm.Terminal;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CreateImageDialogFragment extends DialogFragment {
|
||||
|
||||
public boolean customRom = false;
|
||||
|
||||
public String folder = AppConfig.vmFolder + CustomRomActivity.vmID + "/";
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.create_vhd, container, false);
|
||||
|
|
@ -53,7 +57,7 @@ public class CreateImageDialogFragment extends DialogFragment {
|
|||
|
||||
TextView createPath = view.findViewById(R.id.createPath);
|
||||
|
||||
createPath.setText(AppConfig.maindirpath + "IMG/");
|
||||
createPath.setText(folder);
|
||||
|
||||
if (customRom)
|
||||
createPath.append(CustomRomActivity.title.getText().toString() + ".qcow2");
|
||||
|
|
@ -73,7 +77,7 @@ public class CreateImageDialogFragment extends DialogFragment {
|
|||
} else {
|
||||
createQcow2Btn.setEnabled(false);
|
||||
}
|
||||
createPath.setText(AppConfig.maindirpath + "IMG/" + imageName.getText().toString() + ".qcow2");
|
||||
createPath.setText(folder + imageName.getText().toString() + ".qcow2");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -90,11 +94,15 @@ public class CreateImageDialogFragment extends DialogFragment {
|
|||
createQcow2Btn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
File vDir = new File(folder);
|
||||
if (!vDir.exists()) {
|
||||
vDir.mkdirs();
|
||||
}
|
||||
Terminal vterm = new Terminal(getActivity());
|
||||
vterm.executeShellCommand("qemu-img create -f qcow2 \"" + AppConfig.maindirpath + "IMG/" + imageName.getText().toString() + ".qcow2\" " +
|
||||
vterm.executeShellCommand("qemu-img create -f qcow2 \"" + folder + imageName.getText().toString() + ".qcow2\" " +
|
||||
imageSize.getText().toString() + "G", true, getActivity());
|
||||
if (customRom)
|
||||
CustomRomActivity.drive.setText(AppConfig.maindirpath + "IMG/" + imageName.getText().toString() + ".qcow2");
|
||||
CustomRomActivity.drive.setText(folder + imageName.getText().toString() + ".qcow2");
|
||||
try {
|
||||
CustomRomActivity.driveLayout.setEndIconDrawable(R.drawable.more_vert_24px);
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -701,6 +701,8 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
TextView qemuVersion = findViewById(R.id.qemuVersion);
|
||||
|
||||
setupBottomAppBar();
|
||||
|
||||
String command = "qemu-system-x86_64 --version";
|
||||
new Terminal(activity).extractQemuVersion(command, false, activity, (output, errors) -> {
|
||||
if (errors.isEmpty()) {
|
||||
|
|
@ -1467,4 +1469,41 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private void setupBottomAppBar() {
|
||||
BottomAppBar bottomAppBar = findViewById(R.id.bottomAppBar);
|
||||
bottomAppBar.setOnMenuItemClickListener(new BottomAppBar.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if (item.getItemId() == R.id.shutdown) {
|
||||
alertDialog = new AlertDialog.Builder(activity, R.style.MainDialogTheme).create();
|
||||
alertDialog.setTitle(getResources().getString(R.string.do_you_want_to_kill_all_qemu_processes));
|
||||
alertDialog.setMessage(getResources().getString(R.string.all_running_vms_will_be_forcibly_shut_down));
|
||||
alertDialog.setCancelable(true);
|
||||
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.kill_all), (dialog, which) -> {
|
||||
VectrasApp.killallqemuprocesses(getApplicationContext());
|
||||
});
|
||||
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), (dialog, which) -> {
|
||||
|
||||
});
|
||||
alertDialog.show();
|
||||
} else if (item.getItemId() == R.id.backtothedisplay) {
|
||||
if (VectrasApp.isQemuRunning()) {
|
||||
if (MainSettingsManager.getVmUi(activity).equals("VNC"))
|
||||
activity.startActivity(new Intent(activity, MainVNCActivity.class));
|
||||
else if (MainSettingsManager.getVmUi(activity).equals("X11"))
|
||||
activity.startActivity(new Intent(activity, X11Activity.class));
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(), activity.getResources().getString(R.string.there_is_nothing_here_because_there_is_no_vm_running), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} else if (item.getItemId() == R.id.importrom) {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(getApplicationContext(), CustomRomActivity.class);
|
||||
intent.putExtra("importcvbinow", "");
|
||||
startActivity(intent);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import androidx.recyclerview.widget.GridLayoutManager;
|
|||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.vectras.qemu.Config;
|
||||
import com.vectras.qemu.MainSettingsManager;
|
||||
import com.vectras.vm.MainRoms.AdapterMainRoms;
|
||||
import com.vectras.vm.utils.UIUtils;
|
||||
|
|
@ -213,6 +214,7 @@ public class VMManager {
|
|||
listmapForRemoveVM = new Gson().fromJson(pendingJsonContent, new TypeToken<ArrayList<HashMap<String, Object>>>(){}.getType());
|
||||
if (listmapForRemoveVM.get(pendingPosition).containsKey("vmID")) {
|
||||
pendingVMID = Objects.requireNonNull(listmapForRemoveVM.get(pendingPosition).get("vmID")).toString();
|
||||
VectrasApp.deleteDirectory(Config.getCacheDir()+ "/" + pendingVMID);
|
||||
Log.i("VMManager", "deleteVM: ID obtained: " + pendingVMID);
|
||||
} else {
|
||||
Log.e("VMManager", "deleteVM: Cannot get ID.");
|
||||
|
|
|
|||
|
|
@ -958,7 +958,7 @@ public class VectrasApp extends Application {
|
|||
}
|
||||
|
||||
public static String createCommandForSelectedMirror(boolean _https, String _url, String _beforemain) {
|
||||
String command = "echo \"\" > /etc/apk/repositories && sed -i -e \"1ihttps://xssFjnj58Id/yttGkok69Je/edge/testing\" /etc/apk/repositories && sed -i -e \"1ihttps://xssFjnj58Id/alpine/v3.19/community\" /etc/apk/repositories && sed -i -e \"1ihttps://xssFjnj58Id/alpine/v3.19/main\" /etc/apk/repositories";
|
||||
String command = "echo \"\" > /etc/apk/repositories && sed -i -e \"1ihttps://xssFjnj58Id/yttGkok69Je/edge/testing\" /etc/apk/repositories && sed -i -e \"1ihttps://xssFjnj58Id/yttGkok69Je/v3.19/community\" /etc/apk/repositories && sed -i -e \"1ihttps://xssFjnj58Id/yttGkok69Je/v3.19/main\" /etc/apk/repositories";
|
||||
command = command.replaceAll("/yttGkok69Je", _beforemain);
|
||||
if (!_https)
|
||||
command = command.replaceAll("https://", "http://");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue