mirror of
https://github.com/xoureldeen/Vectras-VM-Android.git
synced 2026-07-09 17:28:54 +00:00
3.9.6
- Bugs fixed.
This commit is contained in:
parent
49b801686d
commit
0425f957d5
11 changed files with 97 additions and 62 deletions
|
|
@ -12,8 +12,8 @@ android {
|
|||
applicationId "com.vectras.vm"
|
||||
minSdk minApi
|
||||
targetSdk targetApi
|
||||
versionCode 99
|
||||
versionName "3.9.5"
|
||||
versionCode 100
|
||||
versionName "3.9.6"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,13 @@ public class RamInfo {
|
|||
int freeRamInt = safeLongToInt(freeMem);
|
||||
int totalRamInt = safeLongToInt(totalMem);
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
|
||||
try {
|
||||
String temp = prefs.getString("memory", "256");
|
||||
} catch (ClassCastException e) {
|
||||
prefs.edit().putString("memory", String.valueOf(prefs.getInt("memory", 256))).apply();
|
||||
}
|
||||
|
||||
if (prefs.getBoolean("customMemory", false) && TextUtils.isNumberOnly(prefs.getString("memory", "256"))) {
|
||||
if (Long.parseLong(prefs.getString("memory", "256")) > totalMem) {
|
||||
prefs.edit().putString("memory", String.valueOf(totalRamInt / 2)).apply();
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ public class AppConfig {
|
|||
public static String vmFolder = maindirpath + "roms/";
|
||||
public static String importedDriveFolder = maindirpath + "drive/";
|
||||
public static String cvbiFolder = maindirpath + "cvbi/";
|
||||
public static String pendingCommand = "";
|
||||
public static String lastCrashLogPath = internalDataDirPath + "logs/lastcrash.txt";
|
||||
|
||||
public static String neededPkgs() {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import androidx.core.app.ActivityCompat;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.vectras.vm.main.MainActivity;
|
||||
import com.vectras.vm.main.core.PendingCommand;
|
||||
import com.vectras.vm.utils.FileUtils;
|
||||
import com.vectras.vm.utils.JSONUtils;
|
||||
import com.vectras.vm.utils.PermissionUtils;
|
||||
|
|
@ -24,6 +25,8 @@ import java.util.HashMap;
|
|||
import java.util.Objects;
|
||||
|
||||
public class CqcmActivity extends AppCompatActivity {
|
||||
private final String TAG = "CqcmActivity";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
@ -133,7 +136,9 @@ public class CqcmActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
private void runCommand(String _command) {
|
||||
AppConfig.pendingCommand = _command;
|
||||
Log.i(TAG, "runCommand: " + _command);
|
||||
|
||||
PendingCommand.command = _command;
|
||||
|
||||
if (!MainActivity.isActivate) {
|
||||
startActivity(new Intent(this, SplashActivity.class));
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
|
|
|||
|
|
@ -243,7 +243,8 @@ public class VMCreatorActivity extends AppCompatActivity {
|
|||
binding.cbvShowbootmenu.setOnCheckedChangeListener((v, isChecked) -> isShowBootMenu = isChecked);
|
||||
|
||||
binding.cbvUseuefi.setOnCheckedChangeListener((v, isChecked) -> isUseUefi = isChecked);
|
||||
if (!MainSettingsManager.getArch(this).equals("X86_64")) binding.cbvUseuefi.setVisibility(View.GONE);
|
||||
if (!MainSettingsManager.getArch(this).equals("X86_64"))
|
||||
binding.cbvUseuefi.setVisibility(View.GONE);
|
||||
|
||||
binding.sbvBootfrom.setOnClickListener(v -> VMCreatorSelector.bootFrom(this, bootFrom, ((position, name, value) -> {
|
||||
bootFrom = position;
|
||||
|
|
@ -363,7 +364,7 @@ public class VMCreatorActivity extends AppCompatActivity {
|
|||
if (isProcessingFile) return;
|
||||
|
||||
if (!created && !modify) {
|
||||
new Thread(() -> FileUtils.delete(new File (AppConfig.vmFolder + vmID))).start();
|
||||
new Thread(() -> FileUtils.delete(new File(AppConfig.vmFolder + vmID))).start();
|
||||
}
|
||||
modify = false;
|
||||
finish();
|
||||
|
|
@ -431,32 +432,36 @@ public class VMCreatorActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
} else {
|
||||
if (!FileUtils.isValidFilePath(this, FileUtils.getPath(this, uri), false)) {
|
||||
DialogUtils.oneDialog(this,
|
||||
getString(R.string.problem_has_been_detected),
|
||||
getString(R.string.invalid_file_path_content),
|
||||
getString(R.string.ok),
|
||||
true,
|
||||
R.drawable.warning_48px,
|
||||
true,
|
||||
null,
|
||||
null);
|
||||
return;
|
||||
}
|
||||
File selectedFilePath = new File(getPath(uri));
|
||||
if (selectedFilePath.getName().endsWith(".iso")) {
|
||||
binding.cdrom.setText(selectedFilePath.getPath());
|
||||
} else {
|
||||
DialogUtils.oneDialog(this,
|
||||
getString(R.string.problem_has_been_detected),
|
||||
getString(R.string.invalid_iso_file_path_content),
|
||||
getString(R.string.ok),
|
||||
true,
|
||||
R.drawable.warning_48px,
|
||||
true,
|
||||
null,
|
||||
null);
|
||||
}
|
||||
executor.execute(() -> {
|
||||
if (!FileUtils.isValidFilePath(this, FileUtils.getPath(this, uri), false)) {
|
||||
runOnUiThread(() -> DialogUtils.oneDialog(this,
|
||||
getString(R.string.problem_has_been_detected),
|
||||
getString(R.string.invalid_file_path_content),
|
||||
getString(R.string.ok),
|
||||
true,
|
||||
R.drawable.warning_48px,
|
||||
true,
|
||||
null,
|
||||
null)
|
||||
);
|
||||
return;
|
||||
}
|
||||
File selectedFilePath = new File(getPath(uri));
|
||||
if (selectedFilePath.getName().endsWith(".iso")) {
|
||||
runOnUiThread(() -> binding.cdrom.setText(selectedFilePath.getPath()));
|
||||
} else {
|
||||
runOnUiThread(() -> DialogUtils.oneDialog(this,
|
||||
getString(R.string.problem_has_been_detected),
|
||||
getString(R.string.invalid_iso_file_path_content),
|
||||
getString(R.string.ok),
|
||||
true,
|
||||
R.drawable.warning_48px,
|
||||
true,
|
||||
null,
|
||||
null)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -778,7 +783,7 @@ public class VMCreatorActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
} else {
|
||||
runOnUiThread(() ->startProcessingHardDriveFile(_content_describer, _addtodrive));
|
||||
runOnUiThread(() -> startProcessingHardDriveFile(_content_describer, _addtodrive));
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
|
@ -1026,7 +1031,8 @@ public class VMCreatorActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
//It can be deleted because there are few users of the old version.
|
||||
if (!_filename.replace(".cvbi", "").isEmpty()) FileUtils.move(AppConfig.vmFolder + _filename.replace(".cvbi", ""), AppConfig.vmFolder + vmID);
|
||||
if (!_filename.replace(".cvbi", "").isEmpty())
|
||||
FileUtils.move(AppConfig.vmFolder + _filename.replace(".cvbi", ""), AppConfig.vmFolder + vmID);
|
||||
|
||||
if (!jObj.has("drive") && !jObj.has("cdrom") && !jObj.has("qemu")) {
|
||||
DialogUtils.oneDialog(this, getResources().getString(R.string.problem_has_been_detected), getResources().getString(R.string.this_rom_is_missing_too_much_information), R.drawable.warning_24px);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.StrictMode;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
|
|
@ -110,7 +109,12 @@ public class MainActivity extends AppCompatActivity implements RomStoreFragment.
|
|||
private SoftwareStoreHomeAdapter adapterSoftwareStore;
|
||||
private final List<DataRoms> listSearchData = new ArrayList<>();
|
||||
private LinearLayoutManager layoutManager;
|
||||
private final VmsFragment vmsFragment = new VmsFragment();
|
||||
private VmsFragment vmsFragment() {
|
||||
VmsFragment fragment = (VmsFragment) getSupportFragmentManager()
|
||||
.findFragmentByTag(TAG_VMS_FRAGMENT);
|
||||
if (fragment == null) fragment = new VmsFragment();
|
||||
return fragment;
|
||||
}
|
||||
private Fragment currentFragment;
|
||||
private boolean isInVmsFragment = true;
|
||||
|
||||
|
|
@ -176,7 +180,8 @@ public class MainActivity extends AppCompatActivity implements RomStoreFragment.
|
|||
|
||||
if (savedInstanceState == null) {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(bindingContent.containerView.getId(), vmsFragment, TAG_VMS_FRAGMENT)
|
||||
.replace(bindingContent.containerView.getId(),
|
||||
new VmsFragment(), TAG_VMS_FRAGMENT)
|
||||
.commit();
|
||||
}
|
||||
|
||||
|
|
@ -201,6 +206,7 @@ public class MainActivity extends AppCompatActivity implements RomStoreFragment.
|
|||
bindingContent.bottomNavigation.setOnItemSelectedListener(item -> {
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
||||
VmsFragment vms = vmsFragment();
|
||||
String selectedTag;
|
||||
|
||||
int id = item.getItemId();
|
||||
|
|
@ -213,11 +219,11 @@ public class MainActivity extends AppCompatActivity implements RomStoreFragment.
|
|||
}
|
||||
|
||||
if (id == R.id.item_home) {
|
||||
if (!vmsFragment.isAdded()) {
|
||||
fragmentTransaction.add(bindingContent.containerView.getId(), vmsFragment, TAG_VMS_FRAGMENT);
|
||||
if (!vms.isAdded()) {
|
||||
fragmentTransaction.add(bindingContent.containerView.getId(), vms, TAG_VMS_FRAGMENT);
|
||||
}
|
||||
|
||||
fragmentTransaction.show(vmsFragment);
|
||||
fragmentTransaction.show(vms);
|
||||
if (!isInVmsFragment && currentFragment != null) {
|
||||
fragmentTransaction.remove(currentFragment);
|
||||
}
|
||||
|
|
@ -226,7 +232,7 @@ public class MainActivity extends AppCompatActivity implements RomStoreFragment.
|
|||
bindingContent.searchbar.setHint(getText(R.string.home));
|
||||
bindingContent.searchbar.setEnabled(false);
|
||||
} else {
|
||||
fragmentTransaction.hide(vmsFragment);
|
||||
fragmentTransaction.hide(vms);
|
||||
Fragment selectedFragment;
|
||||
|
||||
if (id == R.id.item_romstore) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.vectras.vm.main.core;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.vectras.qemu.Config;
|
||||
|
|
@ -12,10 +13,15 @@ import com.vectras.vm.utils.DialogUtils;
|
|||
import com.vectras.vterm.Terminal;
|
||||
|
||||
public class PendingCommand {
|
||||
private static final String TAG = "PendingCommand";
|
||||
public static String command = "";
|
||||
|
||||
public static void runNow(Activity activity) {
|
||||
if (!AppConfig.pendingCommand.isEmpty()) {
|
||||
if (!VMManager.isthiscommandsafe(AppConfig.pendingCommand, activity)) {
|
||||
AppConfig.pendingCommand = "";
|
||||
Log.i(TAG, command);
|
||||
|
||||
if (!command.isEmpty()) {
|
||||
if (!VMManager.isthiscommandsafe(command, activity)) {
|
||||
command = "";
|
||||
DialogUtils.oneDialog(
|
||||
activity,
|
||||
activity.getString(R.string.problem_has_been_detected),
|
||||
|
|
@ -28,8 +34,8 @@ public class PendingCommand {
|
|||
null
|
||||
);
|
||||
} else {
|
||||
if (AppConfig.pendingCommand.startsWith("qemu-img")) {
|
||||
if (!VMManager.isthiscommandsafeimg(AppConfig.pendingCommand, activity)) {
|
||||
if (command.startsWith("qemu-img")) {
|
||||
if (!VMManager.isthiscommandsafeimg(command, activity)) {
|
||||
DialogUtils.oneDialog(activity,
|
||||
activity.getString(R.string.problem_has_been_detected),
|
||||
activity.getString(R.string.size_too_large_try_qcow2_format),
|
||||
|
|
@ -42,22 +48,26 @@ public class PendingCommand {
|
|||
);
|
||||
} else {
|
||||
Terminal _vterm = new Terminal(activity);
|
||||
_vterm.executeShellCommand2(AppConfig.pendingCommand, false, activity);
|
||||
_vterm.executeShellCommand2(command, false, activity);
|
||||
Toast.makeText(activity, activity.getResources().getString(R.string.done), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
command = "";
|
||||
} else {
|
||||
Log.i(TAG, "Run VM...");
|
||||
|
||||
com.vectras.vm.StartVM.cdrompath = "";
|
||||
Config.vmID = VMManager.idGenerator();
|
||||
new Thread(() -> {
|
||||
String env = StartVM.env(activity, AppConfig.pendingCommand, "", true);
|
||||
String env = StartVM.env(activity, command, "", true);
|
||||
activity.runOnUiThread(() -> {
|
||||
MainStartVM.startNow(activity, "Quick run", env, Config.vmID, null);
|
||||
VMManager.lastQemuCommand = AppConfig.pendingCommand;
|
||||
VMManager.lastQemuCommand = command;
|
||||
command = "";
|
||||
});
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
AppConfig.pendingCommand = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue