Skip to content

Commit

Permalink
Merge pull request #217 from AnBui2004/master
Browse files Browse the repository at this point in the history
Doughnut
  • Loading branch information
AnBui2004 authored Feb 9, 2025
2 parents 5604b1f + a1e7f23 commit 3231fd0
Show file tree
Hide file tree
Showing 15 changed files with 186 additions and 23 deletions.
10 changes: 5 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ plugins {

android {
namespace 'com.vectras.vm'
compileSdk compileApi
buildToolsVersion toolsVersion
compileSdk 35
buildToolsVersion '35.0.0'

defaultConfig {
applicationId "com.vectras.vm"
minSdk minApi
targetSdk targetApi
versionCode 21
versionName "v2.9.5-3dfx-churro"
versionName "v2.9.5-3dfx-doughnut"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
Expand Down Expand Up @@ -63,8 +63,8 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
}

Expand Down
14 changes: 13 additions & 1 deletion app/src/main/java/com/vectras/qemu/MainSettingsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ public static boolean getCusRam(Activity activity) {

public static boolean autoCreateDisk(Activity activity) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
return prefs.getBoolean("autoCreateDisk", true);
return prefs.getBoolean("autoCreateDisk", false);
}

public static boolean useDefaultBios(Activity activity) {
Expand Down Expand Up @@ -750,4 +750,16 @@ public static void setPromptUpdateVersion(Activity activity, boolean flag) {
// UIUtils.log("Setting First time: ");
}

public static void setsetUpWithManualSetupBefore(Context context, Boolean _boolean) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean("setUpWithManualSetupBefore", _boolean);
edit.commit();
}

public static Boolean getsetUpWithManualSetupBefore(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
return prefs.getBoolean("setUpWithManualSetupBefore", false);
}

}
54 changes: 54 additions & 0 deletions app/src/main/java/com/vectras/vm/CustomRomActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,23 @@ public void onClick(View v) {
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) {
Expand All @@ -235,6 +252,7 @@ public void onClick(View v) {
startActivityForResult(intent, 1002);
}
});

driveLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down Expand Up @@ -265,6 +283,20 @@ public void onClick(View v) {
}
});

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) {
Expand Down Expand Up @@ -330,6 +362,20 @@ public void onClick(DialogInterface dialog, int which) {
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
Expand Down Expand Up @@ -450,6 +496,14 @@ public void onClick(View v) {
}
});

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;
Expand Down
15 changes: 12 additions & 3 deletions app/src/main/java/com/vectras/vm/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1128,9 +1128,18 @@ public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
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 = "";
}
}
Expand Down
27 changes: 27 additions & 0 deletions app/src/main/java/com/vectras/vm/Minitools.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ protected void onCreate(Bundle savedInstanceState) {
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())) {
Expand Down Expand Up @@ -167,6 +168,32 @@ public void onClick(DialogInterface dialog, int which) {
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));
Expand Down
15 changes: 10 additions & 5 deletions app/src/main/java/com/vectras/vm/SetupQemuActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,16 @@ public void onResponse(String tag, String response, HashMap<String, Object> resp
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);
Expand Down Expand Up @@ -792,6 +796,7 @@ public void run() {
loading.setVisibility(View.GONE);
alertDialog.dismiss();
setupVectras();
MainSettingsManager.setsetUpWithManualSetupBefore(SetupQemuActivity.this, true);
}
};
activity.runOnUiThread(runnable);
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/java/com/vectras/vm/VMManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -636,4 +636,23 @@ public static boolean isthiscommandsafe(String _command) {
}
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;
}
}
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/delete_forever_24px.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M376,660L480,556L584,660L640,604L536,500L640,396L584,340L480,444L376,340L320,396L424,500L320,604L376,660ZM280,840Q247,840 223.5,816.5Q200,793 200,760L200,240L160,240L160,160L360,160L360,120L600,120L600,160L800,160L800,240L760,240L760,760Q760,793 736.5,816.5Q713,840 680,840L280,840ZM680,240L280,240L280,760Q280,760 280,760Q280,760 280,760L680,760Q680,760 680,760Q680,760 680,760L680,240ZM280,240L280,240L280,760Q280,760 280,760Q280,760 280,760L280,760Q280,760 280,760Q280,760 280,760L280,240Z"/>
</vector>
20 changes: 20 additions & 0 deletions app/src/main/res/layout/activity_minitools.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,26 @@
android:layout_marginLeft="8dp"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="16dp"
android:id="@+id/deleteall"
android:background="?android:attr/selectableItemBackground" >

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/delete_forever_24px"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/delete_all"
android:layout_marginLeft="8dp"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@
<string name="error_NO_SUCH_FILE_OR_DIRECTORY">حدثت مشكلة وفشل تشغيل الجهاز الظاهري لأن الملف أو الدليل الذي يحتاجه الجهاز الظاهري للتشغيل غير موجود.</string>
<string name="auto_create_new_hard_drive_when_creating_new_vm">إنشاء محرك أقراص ثابت جديد تلقائيًا عند إنشاء جهاز افتراضي جديد</string>
<string name="with_size_is_128GB">بحجم 128 جيجابايت.</string>
<string name="delete_all_content">سيتم مسح كافة البيانات باستثناء النظام.</string>

<!--======================TERMUX STRINGS====================-->
<string name="shared_user_label">مستخدم Vterm</string>
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<string name="app_name">Vectras VM</string>

<!--======================VECTRAS STRINGS====================-->
<string name="app_version" translatable="false">v2.9.5 (3dfx - Churro)</string>
<string name="app_version" translatable="false">v2.9.5 (3dfx - Doughnut)</string>
<string name="qemu_version" translatable="false">Stable</string>
<string name="str_home">Home</string>
<string name="str_logger">Logger</string>
Expand Down Expand Up @@ -394,6 +394,7 @@
<string name="error_NO_SUCH_FILE_OR_DIRECTORY">A problem occurred and the virtual machine failed to run because a file or directory that the virtual machine needs to run does not exist.</string>
<string name="auto_create_new_hard_drive_when_creating_new_vm">Automatically create new hard drive when creating new virtual machine</string>
<string name="with_size_is_128GB">With size is 128GB.</string>
<string name="delete_all_content">All data will be erased except the system.</string>


<!--======================TERMUX STRINGS====================-->
Expand Down Expand Up @@ -509,7 +510,7 @@
<string name="don_t_forget_to_tell_us_on_github_issues_or_telegram_bot_br"><![CDATA[don\'t forget to tell us on github issues or telegram bot<br>]]></string>
<string name="a_href_https_t_me_vectras_protect_bot_telegram_report_bot_a_br"><![CDATA[<a href=\"https://t.me/vectras_protect_bot\">telegram report bot</a><br>]]></string>
<string name="a_href_https_github_com_epicstudios856_vectras_vm_android_issues_github_issues_page_a_br"><![CDATA[<a href=\"https://github.com/epicstudios856/Vectras-VM-Android/issues\">github issues page</a><br>]]></string>
<string name="getting_ready_for_you_please_don_t_disconnect_the_network">1G etting ready for you… Please don\'t disconnect the network.</string>
<string name="getting_ready_for_you_please_don_t_disconnect_the_network">Getting ready for you…\nPlease don\'t disconnect the network.</string>
<string name="it_won_t_take_long">It won\'t take long…</string>
<string name="completed_10_it_won_t_take_long">Completed 10%\nIt won\'t take long…</string>
<string name="completed_20_it_won_t_take_long">Completed 20%\nIt won\'t take long…</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/qemu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
android:id="@+id/autocreatedisk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:defaultValue="true"
android:defaultValue="false"
android:key="autoCreateDisk"
android:summary="@string/with_size_is_128GB"
android:title="@string/auto_create_new_hard_drive_when_creating_new_vm"
Expand Down
11 changes: 8 additions & 3 deletions shell-loader/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
//file:noinspection UnnecessaryQualifiedReference, GrDeprecatedAPIUsage
apply plugin: 'com.android.application'

android {

buildToolsVersion '35.0.0'
compileSdk 35
}

android.namespace 'com.vectras.vm'
android.defaultConfig.minSdkVersion 21
android.compileSdkVersion 34
android.buildTypes.debug.signingConfig null
android.buildFeatures.buildConfig true
android.compileOptions.sourceCompatibility JavaVersion.VERSION_1_8
android.compileOptions.targetCompatibility JavaVersion.VERSION_1_8
android.compileOptions.sourceCompatibility SDK_VERSION
android.compileOptions.targetCompatibility SDK_VERSION
dependencies.compileOnly project(':shell-loader:stub')
android.applicationVariants.configureEach { outputs.configureEach { outputFileName = "loader.apk" } }

Expand Down
4 changes: 2 additions & 2 deletions shell-loader/stub/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ plugins {

android {
namespace 'com.termux.x11.stub'
buildToolsVersion "34.0.0"
compileSdkVersion 34
buildToolsVersion "35.0.0"
compileSdkVersion 35
defaultConfig {
minSdkVersion 24
//noinspection ExpiredTargetSdkVersion
Expand Down
2 changes: 1 addition & 1 deletion web/data/UpdateConfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"versionCode":"21",
"versionName":"v2.9.5-3dfx,v2.9.5-3dfx-almondcake,v2.9.5-3dfx-bread,v2.9.5-3dfx-churro",
"versionName":"v2.9.5-3dfx,v2.9.5-3dfx-almondcake,v2.9.5-3dfx-bread,v2.9.5-3dfx-churro,v2.9.5-3dfx-doughnut",
"size": "46 MB",
"url": "https://github.com/xoureldeen/Vectras-VM-Android/releases/v2.9.5",
"Message": "<h2>v2.9.5-3dfx</h2><ul><li>Bring back 3dfx support.</li><li>Enhance app execution.</li><li>Added some linux programs in x11 display.</li><li>Added alpine linux (x11).</li><li>Russian language by <a href=\"https://github.com/OFGING\" target=\"_blank\">@OFGING</a></li></ul><br><br>New updates are live!",
Expand Down

0 comments on commit 3231fd0

Please sign in to comment.