mirror of
https://github.com/xoureldeen/Vectras-VM-Android.git
synced 2026-05-03 00:30:28 +00:00
fix3
This commit is contained in:
parent
9b367f73ca
commit
e1bda50165
9 changed files with 153 additions and 100 deletions
|
|
@ -191,7 +191,7 @@ public class AboutActivity extends AppCompatActivity implements View.OnClickList
|
|||
g.setData(Uri.parse(gt));
|
||||
startActivity(g);
|
||||
} else if (id == IG) {
|
||||
String ig = "https://www.instagram.com/vectrasvm";
|
||||
String ig = "https://www.instagram.com/beatsbydabsh";
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse(ig));
|
||||
startActivity(i);
|
||||
|
|
|
|||
|
|
@ -432,7 +432,7 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (isFilled(title) && isFilled(icon) && isFilled(drive))
|
||||
if (isFilled(title))
|
||||
addRomBtn.setEnabled(true);
|
||||
else
|
||||
addRomBtn.setEnabled(false);
|
||||
|
|
|
|||
|
|
@ -99,7 +99,8 @@ public class AdapterMainRoms extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
myHolder.textName.setText(current.itemName);
|
||||
myHolder.textArch.setText(current.itemArch);
|
||||
Bitmap bmImg = BitmapFactory.decodeFile(current.itemIcon);
|
||||
myHolder.ivIcon.setImageBitmap(bmImg);
|
||||
if (!current.itemIcon.isEmpty())
|
||||
myHolder.ivIcon.setImageBitmap(bmImg);
|
||||
myHolder.optionsBtn.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(MainActivity.activity);
|
||||
|
|
@ -107,98 +108,92 @@ public class AdapterMainRoms extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
bottomSheetDialog.setContentView(v);
|
||||
|
||||
Button modifyRomBtn = v.findViewById(R.id.modifyRomBtn);
|
||||
modifyRomBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
com.vectras.vm.CustomRomActivity.current = data.get(position);
|
||||
MainActivity.activity.startActivity(new Intent(MainActivity.activity, CustomRomActivity.class).putExtra("POS", position).putExtra("MODIFY", true));
|
||||
bottomSheetDialog.cancel();
|
||||
}
|
||||
modifyRomBtn.setOnClickListener(v1 -> {
|
||||
CustomRomActivity.current = data.get(position);
|
||||
MainActivity.activity.startActivity(new Intent(MainActivity.activity, CustomRomActivity.class).putExtra("POS", position).putExtra("MODIFY", true));
|
||||
bottomSheetDialog.cancel();
|
||||
});
|
||||
Button exportRomBtn = v.findViewById(R.id.exportRomBtn);
|
||||
exportRomBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final File jsonFile = new File(MainActivity.activity.getExternalFilesDir("data") + "/rom-data.json");
|
||||
AlertDialog ad;
|
||||
ad = new AlertDialog.Builder(MainActivity.activity).create();
|
||||
ad.setTitle(MainActivity.activity.getString(R.string.export_rom));
|
||||
ad.setMessage(MainActivity.activity.getString(R.string.are_you_sure));
|
||||
final TextInputLayout Description = new TextInputLayout(MainActivity.activity);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
Description.setHint(R.string.description_html_supported);
|
||||
Description.setLayoutParams(lp);
|
||||
Description.setPadding(10, 10, 10, 10);
|
||||
final TextInputEditText DescriptionET = new TextInputEditText(MainActivity.activity);
|
||||
LinearLayout.LayoutParams lp2 = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
DescriptionET.setLayoutParams(lp2);
|
||||
Description.addView(DescriptionET);
|
||||
DescriptionET.setText("");
|
||||
DescriptionET.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
DescriptionET.setSelectAllOnFocus(true);
|
||||
ad.setView(Description);
|
||||
ad.setButton(Dialog.BUTTON_POSITIVE, "EXPORT", (dialog, which) -> {
|
||||
RomJson obj = new RomJson();//TODO:UPDATE AUTHOR NAME
|
||||
JSONObject jsonObject = obj.makeJSONObject(current.itemName, current.itemArch, "UNKNOWN", DescriptionET.getText().toString(), new File(current.itemIcon).getName(), new File(current.itemPath).getName(), current.itemExtra);
|
||||
exportRomBtn.setOnClickListener(v12 -> {
|
||||
final File jsonFile = new File(MainActivity.activity.getExternalFilesDir("data") + "/rom-data.json");
|
||||
AlertDialog ad;
|
||||
ad = new AlertDialog.Builder(MainActivity.activity).create();
|
||||
ad.setTitle(MainActivity.activity.getString(R.string.export_rom));
|
||||
ad.setMessage(MainActivity.activity.getString(R.string.are_you_sure));
|
||||
final TextInputLayout Description = new TextInputLayout(MainActivity.activity);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
Description.setHint(R.string.description_html_supported);
|
||||
Description.setLayoutParams(lp);
|
||||
Description.setPadding(10, 10, 10, 10);
|
||||
final TextInputEditText DescriptionET = new TextInputEditText(MainActivity.activity);
|
||||
LinearLayout.LayoutParams lp2 = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
DescriptionET.setLayoutParams(lp2);
|
||||
Description.addView(DescriptionET);
|
||||
DescriptionET.setText("");
|
||||
DescriptionET.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
DescriptionET.setSelectAllOnFocus(true);
|
||||
ad.setView(Description);
|
||||
ad.setButton(Dialog.BUTTON_POSITIVE, "EXPORT", (dialog, which) -> {
|
||||
RomJson obj = new RomJson();//TODO:UPDATE AUTHOR NAME
|
||||
JSONObject jsonObject = obj.makeJSONObject(current.itemName, current.itemArch, "UNKNOWN", DescriptionET.getText().toString(), new File(current.itemIcon).getName(), new File(current.itemPath).getName(), current.itemExtra);
|
||||
|
||||
try {
|
||||
Writer output = null;
|
||||
output = new BufferedWriter(new FileWriter(jsonFile));
|
||||
output.write(jsonObject.toString().replace("\\", "").replace("//", "/"));
|
||||
output.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
SharedPreferences credentials = MainActivity.activity.getSharedPreferences(CREDENTIAL_SHARED_PREF, Context.MODE_PRIVATE);
|
||||
try {
|
||||
Writer output = null;
|
||||
output = new BufferedWriter(new FileWriter(jsonFile));
|
||||
output.write(jsonObject.toString().replace("\\", "").replace("//", "/"));
|
||||
output.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
SharedPreferences credentials = MainActivity.activity.getSharedPreferences(CREDENTIAL_SHARED_PREF, Context.MODE_PRIVATE);
|
||||
|
||||
ProgressDialog progressDialog = new ProgressDialog(MainActivity.activity);
|
||||
progressDialog.setTitle(MainActivity.activity.getString(R.string.compressing_cvbi));
|
||||
progressDialog.setMessage(MainActivity.activity.getString(R.string.please_wait_dialog));
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show(); // Showing Progress Dialog
|
||||
Thread t = new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
ZipEntrySource[] addedEntries = new ZipEntrySource[]{
|
||||
new FileSource("/" + new File(current.itemPath).getName(), new File(current.itemPath)),
|
||||
new FileSource("/" + new File(current.itemIcon).getName(), new File(current.itemIcon)),
|
||||
new FileSource("/" + new File(MainActivity.activity.getExternalFilesDir("data") + "/rom-data.json").getName(), new File(MainActivity.activity.getExternalFilesDir("data") + "/rom-data.json"))
|
||||
};
|
||||
ZipUtil.pack(addedEntries, new File(FileUtils.getExternalFilesDirectory(MainActivity.activity).getPath() + "/cvbi/" + current.itemName + ".cvbi"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
progressDialog.cancel(); // cancelling Dialog.
|
||||
UIUtils.UIAlert(MainActivity.activity, MainActivity.activity.getString(R.string.error), e.toString());
|
||||
}
|
||||
};
|
||||
MainActivity.activity.runOnUiThread(runnable);
|
||||
} finally {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
progressDialog.cancel(); // cancelling Dialog.}
|
||||
UIUtils.UIAlert(MainActivity.activity, MainActivity.activity.getString(R.string.done), FileUtils.getExternalFilesDirectory(MainActivity.activity).getPath() + "/cvbi/" + current.itemName + ".cvbi");
|
||||
}
|
||||
};
|
||||
MainActivity.activity.runOnUiThread(runnable);
|
||||
}
|
||||
ProgressDialog progressDialog = new ProgressDialog(MainActivity.activity);
|
||||
progressDialog.setTitle(MainActivity.activity.getString(R.string.compressing_cvbi));
|
||||
progressDialog.setMessage(MainActivity.activity.getString(R.string.please_wait_dialog));
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show(); // Showing Progress Dialog
|
||||
Thread t = new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
ZipEntrySource[] addedEntries = new ZipEntrySource[]{
|
||||
new FileSource("/" + new File(current.itemPath).getName(), new File(current.itemPath)),
|
||||
new FileSource("/" + new File(current.itemIcon).getName(), new File(current.itemIcon)),
|
||||
new FileSource("/" + new File(MainActivity.activity.getExternalFilesDir("data") + "/rom-data.json").getName(), new File(MainActivity.activity.getExternalFilesDir("data") + "/rom-data.json"))
|
||||
};
|
||||
ZipUtil.pack(addedEntries, new File(FileUtils.getExternalFilesDirectory(MainActivity.activity).getPath() + "/cvbi/" + current.itemName + ".cvbi"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
progressDialog.cancel(); // cancelling Dialog.
|
||||
UIUtils.UIAlert(MainActivity.activity, MainActivity.activity.getString(R.string.error), e.toString());
|
||||
}
|
||||
};
|
||||
MainActivity.activity.runOnUiThread(runnable);
|
||||
} finally {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
progressDialog.cancel(); // cancelling Dialog.}
|
||||
UIUtils.UIAlert(MainActivity.activity, MainActivity.activity.getString(R.string.done), FileUtils.getExternalFilesDirectory(MainActivity.activity).getPath() + "/cvbi/" + current.itemName + ".cvbi");
|
||||
}
|
||||
};
|
||||
MainActivity.activity.runOnUiThread(runnable);
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
return;
|
||||
});
|
||||
ad.setButton(Dialog.BUTTON_NEGATIVE, MainActivity.activity.getString(R.string.close), (dialog, which) -> {
|
||||
return;
|
||||
});
|
||||
ad.show();
|
||||
bottomSheetDialog.cancel();
|
||||
}
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
return;
|
||||
});
|
||||
ad.setButton(Dialog.BUTTON_NEGATIVE, MainActivity.activity.getString(R.string.close), (dialog, which) -> {
|
||||
return;
|
||||
});
|
||||
ad.show();
|
||||
bottomSheetDialog.cancel();
|
||||
});
|
||||
bottomSheetDialog.show();
|
||||
}
|
||||
|
|
@ -215,7 +210,7 @@ public class AdapterMainRoms extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
public boolean onLongClick(View v) {
|
||||
AlertDialog ad;
|
||||
ad = new AlertDialog.Builder(MainActivity.activity, R.style.MainDialogTheme).create();
|
||||
ad.setTitle(MainActivity.activity.getString(R.string.remove)+ " " + current.itemName);
|
||||
ad.setTitle(MainActivity.activity.getString(R.string.remove) + " " + current.itemName);
|
||||
ad.setMessage(MainActivity.activity.getString(R.string.are_you_sure));
|
||||
ad.setButton(Dialog.BUTTON_NEGATIVE, MainActivity.activity.getString(R.string.remove) + " " + current.itemName, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
|
@ -231,7 +226,7 @@ public class AdapterMainRoms extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
|
||||
try {
|
||||
boolean deleted = cdrom.delete();
|
||||
if(!deleted) {
|
||||
if (!deleted) {
|
||||
// The file wasn't successfully deleted.
|
||||
// Handle this case, maybe the file didn't exist or was read only.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ public class SetupQemuActivity extends AppCompatActivity implements View.OnClick
|
|||
" apk update;" +
|
||||
" apk add tar libslirp libslirp-dev pulseaudio-dev glib-dev pixman-dev zlib-dev spice-dev" +
|
||||
" libusbredirparser usbredir-dev libiscsi-dev sdl2 sdl2-dev libepoxy-dev virglrenderer-dev rdma-core" +
|
||||
" libusb ncurses-libs curl libnfs sdl2 gtk+3.0 fuse libpulse libseccomp jack pipewire liburing;" +
|
||||
" libusb ncurses-libs curl libnfs sdl2 gtk+3.0 fuse libpulse libseccomp jack pipewire liburing xkeyboard-config;" +
|
||||
" tar -xzvf " + tarPath + " -C /;" +
|
||||
" rm " + tarPath + ";" +
|
||||
" mkdir -p ~/.vnc && echo -e \"555555\\n555555\" | vncpasswd -f > ~/.vnc/passwd && chmod 0600 ~/.vnc/passwd;" +
|
||||
|
|
|
|||
63
app/src/main/java/com/vectras/vm/core/TermuxX11.java
Normal file
63
app/src/main/java/com/vectras/vm/core/TermuxX11.java
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
package com.vectras.vm.core;
|
||||
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.system.ErrnoException;
|
||||
import android.system.Os;
|
||||
import android.util.Log;
|
||||
|
||||
import com.vectras.vm.VectrasApp;
|
||||
|
||||
import dalvik.system.PathClassLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class TermuxX11 {
|
||||
private static final String TAG = "boxvidra.TermuxX11";
|
||||
private static final String TARGET_APP_ID = "com.termux.x11";
|
||||
private static final String TARGET_CLASS_ID = "com.termux.x11.CmdEntryPoint";
|
||||
|
||||
public static void main(String[] args) throws ErrnoException {
|
||||
String filesDir = VectrasApp.vectrasapp.getFilesDir().getAbsolutePath();
|
||||
File xkbConfigRoot = new File(filesDir + "/distro/share/X11/xkb");
|
||||
if (!xkbConfigRoot.exists())
|
||||
throw new RuntimeException("XKB_CONFIG_ROOT not found: " + xkbConfigRoot);
|
||||
Os.setenv("XKB_CONFIG_ROOT", xkbConfigRoot.getAbsolutePath(), true);
|
||||
|
||||
File tmpDir = new File(VectrasApp.vectrasapp.getFilesDir(), "tmp");
|
||||
deleteRecursively(tmpDir);
|
||||
tmpDir.mkdirs();
|
||||
Os.setenv("TMPDIR", tmpDir.toString(), true);
|
||||
|
||||
try {
|
||||
PackageInfo targetInfo = VectrasApp.vectrasapp.getPackageManager().getPackageInfo(TARGET_APP_ID, 0);
|
||||
if (targetInfo == null) throw new RuntimeException("Termux:X11 not installed");
|
||||
Log.i(TAG, "Running " + targetInfo.applicationInfo.sourceDir + "::" + TARGET_CLASS_ID + "::main of " + TARGET_APP_ID + " application");
|
||||
Class<?> targetClass = Class.forName(
|
||||
TARGET_CLASS_ID, true,
|
||||
new PathClassLoader(targetInfo.applicationInfo.sourceDir, null, ClassLoader.getSystemClassLoader())
|
||||
);
|
||||
targetClass.getMethod("main", String[].class).invoke(null, (Object) args);
|
||||
} catch (AssertionError e) {
|
||||
System.err.println(e.getMessage());
|
||||
} catch (InvocationTargetException e) {
|
||||
if (e.getCause() != null) e.getCause().printStackTrace(System.err);
|
||||
} catch (Throwable e) {
|
||||
Log.e(TAG, "Termux:X11 error", e);
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
|
||||
// Assuming a custom method similar to Kotlin's deleteRecursively
|
||||
private static void deleteRecursively(File file) {
|
||||
if (file.isDirectory()) {
|
||||
File[] children = file.listFiles();
|
||||
if (children != null) {
|
||||
for (File child : children) {
|
||||
deleteRecursively(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
|
@ -94,10 +94,6 @@ public class Terminal {
|
|||
processBuilder.environment().put("TMPDIR", tmpDir.getAbsolutePath());
|
||||
processBuilder.environment().put("SHELL", "/bin/sh");
|
||||
processBuilder.environment().put("DISPLAY", DISPLAY);
|
||||
processBuilder.environment().put("PULSE_SERVER", "/run/pulse/native");
|
||||
processBuilder.environment().put("XDG_RUNTIME_DIR", "/run");
|
||||
processBuilder.environment().put("QEMU_AUDIO_DRV", "sdl");
|
||||
processBuilder.environment().put("SDL_VIDEODRIVER", "x11");
|
||||
|
||||
String[] prootCommand = {
|
||||
nativeLibDir + "/libproot.so", // PRoot binary path
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue