Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
xoureldeen committed Dec 28, 2024
1 parent 80163ba commit 4f52f63
Show file tree
Hide file tree
Showing 10 changed files with 323 additions and 0 deletions.
Binary file added 3dfx/3dfx-wrappers-2.9.5.iso
Binary file not shown.
77 changes: 77 additions & 0 deletions app/src/main/java/com/vectras/vm/core/PulseAudio.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.vectras.vm.core;

import android.content.Context;
import android.util.Log;
import com.termux.app.TermuxService;
import com.vectras.vm.logger.VectrasStatus;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;

public class PulseAudio {
private static final String TAG = "PulseAudio";
private Process pulseAudioProcess;
private Context context;
private ExecutorService executorService;
private Future<?> processFuture;

public PulseAudio(Context context) {
this.context = context;
this.executorService = Executors.newSingleThreadExecutor();
}

public void start() {
String tmpDir = TermuxService.PREFIX_PATH + "/tmp";

Runnable processRunnable = () -> {
try {
ProcessBuilder processBuilder = new ProcessBuilder(
"/system/bin/sh", "-c",
"XDG_RUNTIME_DIR=" + tmpDir + " TMPDIR=" + tmpDir + " " +
TermuxService.PREFIX_PATH + "/bin/pulseaudio --start " +
"--load=\"module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1\" " +
"--exit-idle-time=-1"
);

processBuilder.redirectErrorStream(true);
pulseAudioProcess = processBuilder.start();

BufferedReader reader = new BufferedReader(new InputStreamReader(pulseAudioProcess.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
Log.d(TAG, line);
VectrasStatus.logInfo(TAG + " > " + line);
}
} catch (IOException e) {
Log.e(TAG, "Error starting PulseAudio", e);
VectrasStatus.logInfo(TAG + " > " + e.toString());
}
};

processFuture = executorService.submit(processRunnable);
}

public void stop() {
if (pulseAudioProcess != null) {
pulseAudioProcess.destroy();
try {
pulseAudioProcess.waitFor();
Log.d(TAG, "PulseAudio stopped");
VectrasStatus.logInfo(TAG + " > PulseAudio stopped");
} catch (InterruptedException e) {
Log.e(TAG, "Error stopping PulseAudio", e);
VectrasStatus.logInfo(TAG + " > Error stopping PulseAudio: " + e.toString());
}
}

if (processFuture != null) {
processFuture.cancel(true);
}

executorService.shutdown();
}
}
150 changes: 150 additions & 0 deletions app/src/main/java/com/vectras/vm/utils/LibraryChecker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
package com.vectras.vm.utils;

import android.app.Activity;
import android.content.Context;

import androidx.appcompat.app.AlertDialog;

import com.vectras.vm.AppConfig;
import com.vectras.vm.R;
import com.vectras.vterm.Terminal;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class LibraryChecker {
private Context context;

public LibraryChecker(Context context) {
this.context = context;
}

public void checkMissingLibraries(Activity activity) {
// List of required libraries
String[] requiredLibraries = AppConfig.neededPkgs.split(" ");

// Get the list of installed packages
isPackageInstalled(null, (output, errors) -> {
// Split the installed packages output into an array and convert to a set for fast lookup
Set<String> installedPackages = new HashSet<>();
for (String installedPackage : output.split("\n")) {
installedPackages.add(installedPackage.trim());
}

// StringBuilder to collect missing libraries
StringBuilder missingLibraries = new StringBuilder();

// Loop over required libraries and check if they're installed
for (String lib : requiredLibraries) {
if (!installedPackages.contains(lib.trim())) {
missingLibraries.append(lib).append("\n");
}
}

// Show dialog if any libraries are missing
if (missingLibraries.toString().trim().length() > 0) {
showMissingLibrariesDialog(activity, missingLibraries.toString());
} else {
// show a dialog if all libraries are installed
// showAllLibrariesInstalledDialog(activity);
}
});
}

// Method to show the missing libraries dialog
private void showMissingLibrariesDialog(Activity activity, String missingLibraries) {
new AlertDialog.Builder(activity, R.style.MainDialogTheme)
.setTitle("Missing Libraries")
.setMessage("The following libraries are missing:\n\n" + missingLibraries)
.setCancelable(false)
.setPositiveButton("Install", (dialog, which) -> {
// Create the install command
String installCommand = "apk add " + missingLibraries.replace("\n", " ");
new Terminal(context).executeShellCommand(installCommand, true, activity);
})
.setNegativeButton("Cancel", (dialog, which) -> dialog.dismiss())
.show();
}

// Method to show the "All Libraries Installed" dialog
private void showAllLibrariesInstalledDialog(Activity activity) {
new AlertDialog.Builder(activity, R.style.MainDialogTheme)
.setTitle("All Libraries Installed")
.setMessage("All required libraries are already installed.")
.setPositiveButton("OK", (dialog, which) -> dialog.dismiss())
.show();
}

// Method to check if the package is installed
public void isPackageInstalled(String packageName, Terminal.CommandCallback callback) {
String command = "apk info";

Terminal terminal = new Terminal(context);
terminal.executeShellCommand(command, (Activity) context, (output, errors) -> {
if (callback != null) {
callback.onCommandCompleted(output, errors);
}
});
}

// Method to check if the package is installed
public static void isPackageInstalled2(Activity activity, String packageName, Terminal.CommandCallback callback) {
String command = "apk info";

Terminal terminal = new Terminal(activity);
terminal.executeShellCommand(command, activity, (output, errors) -> {
if (callback != null) {
callback.onCommandCompleted(output, errors);
}
});
}

public void checkAndInstallXFCE4(Activity activity) {
// XFCE4 meta-package
String xfce4Package = "xfce4";

// Check if XFCE4 is installed
isPackageInstalled(xfce4Package, (output, errors) -> {
boolean isInstalled = false;

// Check if the package exists in the installed packages output
if (output != null) {
Set<String> installedPackages = new HashSet<>();
for (String installedPackage : output.split("\n")) {
installedPackages.add(installedPackage.trim());
}

isInstalled = installedPackages.contains(xfce4Package.trim());
}

// If not installed, show a dialog to install it
if (!isInstalled) {
showInstallDialog(activity, xfce4Package);
} else {
showAlreadyInstalledDialog(activity);
}
});
}

private void showInstallDialog(Activity activity, String packageName) {
new AlertDialog.Builder(activity, R.style.MainDialogTheme)
.setTitle("Install XFCE4")
.setMessage("XFCE4 is not installed. Would you like to install it?")
.setCancelable(false)
.setPositiveButton("Install", (dialog, which) -> {
String installCommand = "apk add " + packageName;
new Terminal(context).executeShellCommand(installCommand, true, activity);
})
.setNegativeButton("Cancel", (dialog, which) -> dialog.dismiss())
.show();
}

private void showAlreadyInstalledDialog(Activity activity) {
new AlertDialog.Builder(activity, R.style.MainDialogTheme)
.setTitle("XFCE4 Installed")
.setMessage("XFCE4 is already installed on this system.")
.setPositiveButton("OK", (dialog, which) -> dialog.dismiss())
.show();
}
}
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/apps_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="M240,800Q207,800 183.5,776.5Q160,753 160,720Q160,687 183.5,663.5Q207,640 240,640Q273,640 296.5,663.5Q320,687 320,720Q320,753 296.5,776.5Q273,800 240,800ZM480,800Q447,800 423.5,776.5Q400,753 400,720Q400,687 423.5,663.5Q447,640 480,640Q513,640 536.5,663.5Q560,687 560,720Q560,753 536.5,776.5Q513,800 480,800ZM720,800Q687,800 663.5,776.5Q640,753 640,720Q640,687 663.5,663.5Q687,640 720,640Q753,640 776.5,663.5Q800,687 800,720Q800,753 776.5,776.5Q753,800 720,800ZM240,560Q207,560 183.5,536.5Q160,513 160,480Q160,447 183.5,423.5Q207,400 240,400Q273,400 296.5,423.5Q320,447 320,480Q320,513 296.5,536.5Q273,560 240,560ZM480,560Q447,560 423.5,536.5Q400,513 400,480Q400,447 423.5,423.5Q447,400 480,400Q513,400 536.5,423.5Q560,447 560,480Q560,513 536.5,536.5Q513,560 480,560ZM720,560Q687,560 663.5,536.5Q640,513 640,480Q640,447 663.5,423.5Q687,400 720,400Q753,400 776.5,423.5Q800,447 800,480Q800,513 776.5,536.5Q753,560 720,560ZM240,320Q207,320 183.5,296.5Q160,273 160,240Q160,207 183.5,183.5Q207,160 240,160Q273,160 296.5,183.5Q320,207 320,240Q320,273 296.5,296.5Q273,320 240,320ZM480,320Q447,320 423.5,296.5Q400,273 400,240Q400,207 423.5,183.5Q447,160 480,160Q513,160 536.5,183.5Q560,207 560,240Q560,273 536.5,296.5Q513,320 480,320ZM720,320Q687,320 663.5,296.5Q640,273 640,240Q640,207 663.5,183.5Q687,160 720,160Q753,160 776.5,183.5Q800,207 800,240Q800,273 776.5,296.5Q753,320 720,320Z"/>
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/deployed_code_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="M440,777L440,503L200,364L200,638Q200,638 200,638Q200,638 200,638L440,777ZM520,777L760,638Q760,638 760,638Q760,638 760,638L760,364L520,503L520,777ZM480,434L717,297L480,160Q480,160 480,160Q480,160 480,160L243,297L480,434ZM160,708Q141,697 130.5,679Q120,661 120,639L120,321Q120,299 130.5,281Q141,263 160,252L440,91Q459,80 480,80Q501,80 520,91L800,252Q819,263 829.5,281Q840,299 840,321L840,639Q840,661 829.5,679Q819,697 800,708L520,869Q501,880 480,880Q459,880 440,869L160,708ZM480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480Z"/>
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/desktop_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="M320,840L320,760L400,760L400,680L160,680Q127,680 103.5,656.5Q80,633 80,600L80,200Q80,167 103.5,143.5Q127,120 160,120L800,120Q833,120 856.5,143.5Q880,167 880,200L880,600Q880,633 856.5,656.5Q833,680 800,680L560,680L560,760L640,760L640,840L320,840ZM160,600L800,600Q800,600 800,600Q800,600 800,600L800,200Q800,200 800,200Q800,200 800,200L160,200Q160,200 160,200Q160,200 160,200L160,600Q160,600 160,600Q160,600 160,600ZM160,600Q160,600 160,600Q160,600 160,600L160,200Q160,200 160,200Q160,200 160,200L160,200Q160,200 160,200Q160,200 160,200L160,600Q160,600 160,600Q160,600 160,600Z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_discord.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:viewportHeight="256" android:viewportWidth="256" android:width="24dp">

<path android:fillColor="#5865F2" android:fillType="nonZero" android:pathData="M216.86,45.1C200.29,37.34 182.57,31.71 164.04,28.5C161.77,32.61 159.11,38.15 157.28,42.55C137.58,39.58 118.07,39.58 98.74,42.55C96.91,38.15 94.19,32.61 91.9,28.5C73.35,31.71 55.61,37.36 39.04,45.14C5.62,95.65 -3.44,144.9 1.09,193.46C23.26,210.01 44.74,220.07 65.86,226.65C71.08,219.47 75.73,211.84 79.74,203.8C72.1,200.9 64.79,197.32 57.89,193.17C59.72,191.81 61.51,190.39 63.24,188.93C105.37,208.63 151.13,208.63 192.75,188.93C194.51,190.39 196.3,191.81 198.11,193.17C191.18,197.34 183.85,200.92 176.22,203.82C180.23,211.84 184.86,219.49 190.1,226.67C211.24,220.09 232.74,210.03 254.91,193.46C260.23,137.17 245.83,88.37 216.86,45.1ZM85.47,163.59C72.83,163.59 62.46,151.79 62.46,137.41C62.46,123.04 72.61,111.21 85.47,111.21C98.34,111.21 108.71,123.02 108.49,137.41C108.51,151.79 98.34,163.59 85.47,163.59ZM170.53,163.59C157.88,163.59 147.51,151.79 147.51,137.41C147.51,123.04 157.66,111.21 170.53,111.21C183.39,111.21 193.76,123.02 193.54,137.41C193.54,151.79 183.39,163.59 170.53,163.59Z"/>

</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/manufacturing_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="M222,420Q210,415 199.5,409.5Q189,404 178,396L149,405Q136,409 123.5,404Q111,399 104,388L96,374Q89,362 91,348Q93,334 104,325L126,306Q124,293 124,280Q124,267 126,254L104,235Q93,226 91,212.5Q89,199 96,187L105,172Q112,161 124,156Q136,151 149,155L178,164Q189,156 199.5,150.5Q210,145 222,140L228,111Q231,97 241.5,88.5Q252,80 266,80L282,80Q296,80 306.5,89Q317,98 320,112L326,140Q338,145 348.5,150.5Q359,156 370,164L399,155Q412,151 424.5,156Q437,161 444,172L452,186Q459,198 457,212Q455,226 444,235L422,254Q424,267 424,280Q424,293 422,306L444,325Q455,334 457,347.5Q459,361 452,373L443,388Q436,399 424,404Q412,409 399,405L370,396Q359,404 348.5,409.5Q338,415 326,420L320,449Q317,463 306.5,471.5Q296,480 282,480L266,480Q252,480 241.5,471Q231,462 228,448L222,420ZM274,360Q307,360 330.5,336.5Q354,313 354,280Q354,247 330.5,223.5Q307,200 274,200Q241,200 217.5,223.5Q194,247 194,280Q194,313 217.5,336.5Q241,360 274,360ZM574,836Q557,830 542.5,821.5Q528,813 514,802L476,814Q458,820 440,813.5Q422,807 412,790L401,771Q391,754 394,734.5Q397,715 412,702L442,676Q440,658 440,640Q440,622 442,604L412,577Q397,564 394,545Q391,526 401,509L412,490Q422,473 440,466.5Q458,460 476,466L514,478Q528,467 542.5,458.5Q557,450 574,444L583,403Q587,384 601.5,372Q616,360 636,360L660,360Q680,360 694.5,372Q709,384 713,403L722,444Q739,450 753.5,458.5Q768,467 782,478L820,466Q838,460 856,466.5Q874,473 884,490L895,509Q905,526 902,545.5Q899,565 884,578L854,604Q856,622 856,640Q856,658 854,676L884,703Q899,716 902,735Q905,754 895,771L884,790Q874,807 856,813.5Q838,820 820,814L782,802Q768,813 753.5,821.5Q739,830 722,836L713,877Q709,896 694.5,908Q680,920 660,920L636,920Q616,920 601.5,908Q587,896 583,877L574,836ZM648,760Q698,760 733,725Q768,690 768,640Q768,590 733,555Q698,520 648,520Q598,520 563,555Q528,590 528,640Q528,690 563,725Q598,760 648,760Z"/>
</vector>
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/transparent_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/transparent"/>
<corners android:radius="10dp"/>
</shape>
47 changes: 47 additions & 0 deletions app/src/main/res/layout/dialog_programs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center"
android:padding="20dp"
android:background="@drawable/transparent_background">

<ImageButton
android:id="@+id/btnTerminal"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginRight="8dp"
android:background="@drawable/controls_button"
android:backgroundTint="?attr/colorPrimary"
android:src="@drawable/round_terminal_24"
android:scaleType="fitCenter"
android:layout_margin="4dp"
app:tint="?attr/colorPrimary" />

<ImageButton
android:id="@+id/btnGlxGears"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginRight="8dp"
android:background="@drawable/controls_button"
android:backgroundTint="?attr/colorPrimary"
android:src="@drawable/manufacturing_24px"
android:scaleType="fitCenter"
android:layout_margin="4dp"
app:tint="?attr/colorPrimary" />

<ImageButton
android:id="@+id/btnVkCube"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginRight="8dp"
android:background="@drawable/controls_button"
android:backgroundTint="?attr/colorPrimary"
android:src="@drawable/deployed_code_24px"
android:visibility="gone"
android:scaleType="fitCenter"
android:layout_margin="4dp"
app:tint="?attr/colorPrimary" />

</LinearLayout>

0 comments on commit 4f52f63

Please sign in to comment.