New Branch: Full project rewrite (Beta)

This commit is contained in:
Daniel 2025-11-15 22:58:08 +03:00
commit 188bc459b1
25 changed files with 1496 additions and 0 deletions

9
.gitattributes vendored Normal file
View file

@ -0,0 +1,9 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf
# These are Windows script files and should use crlf
*.bat text eol=crlf

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
# Ignore Gradle project-specific cache directory
.gradle
# Ignore Gradle build output directory
build

54
app/build.gradle.kts Normal file
View file

@ -0,0 +1,54 @@
plugins {
id("com.android.application")
kotlin("android")
}
android {
namespace = "com.example.vedroid"
compileSdk = 34
defaultConfig {
applicationId = "com.example.vedroid"
minSdk = 21
targetSdk = 34
versionCode = 1
versionName = "1.0"
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
buildToolsVersion = "34.0.0"
}
dependencies {
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.10.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
// SSH библиотека
implementation("com.github.mwiede:jsch:0.2.11")
// Корутины для асинхронности
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
// Для работы с терминалом
implementation("com.jcraft:jzlib:1.1.3") // Для лучшей поддержки терминала
}

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Разрешение на интернет -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Разрешение на сеть для проверки состояния -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="false"
android:icon="@drawable/ic_launcher"
android:label="Vedroid SSH Client"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
<!-- Главный экран -->
<activity
android:name=".SshActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Терминал - ДОБАВЛЯЕМ ЭТУ АКТИВНОСТЬ -->
<activity
android:name=".TerminalActivity"
android:exported="false"
android:screenOrientation="landscape" />
</application>
</manifest>

View file

@ -0,0 +1,11 @@
package com.example.vedroid
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}

View file

@ -0,0 +1,333 @@
package com.example.vedroid
import android.content.SharedPreferences
import android.content.Intent // ✅ Добавляем этот импорт
import android.os.Bundle
import android.widget.*
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import com.jcraft.jsch.ChannelExec
import com.jcraft.jsch.JSch
import org.json.JSONArray
import org.json.JSONObject
import com.example.vedroid.model.SshProfile
class SshActivity : AppCompatActivity() {
private lateinit var hostInput: EditText
private lateinit var portInput: EditText
private lateinit var usernameInput: EditText
private lateinit var passwordInput: EditText
private lateinit var connectButton: Button
private lateinit var executeButton: Button
private lateinit var outputText: TextView
private lateinit var profilesSpinner: Spinner
private lateinit var saveProfileButton: Button
private lateinit var deleteProfileButton: Button
private lateinit var terminalButton: Button // ✅ Добавляем terminalButton
private val jsch = JSch()
private lateinit var prefs: SharedPreferences
private val profiles = mutableListOf<SshProfile>()
private lateinit var adapter: ArrayAdapter<String>
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_ssh)
prefs = getSharedPreferences("ssh_profiles", MODE_PRIVATE)
initViews()
loadProfiles()
setupClickListeners()
}
private fun initViews() {
hostInput = findViewById(R.id.hostInput)
portInput = findViewById(R.id.portInput)
usernameInput = findViewById(R.id.usernameInput)
passwordInput = findViewById(R.id.passwordInput)
connectButton = findViewById(R.id.connectButton)
executeButton = findViewById(R.id.executeButton)
outputText = findViewById(R.id.outputText)
profilesSpinner = findViewById(R.id.profilesSpinner)
saveProfileButton = findViewById(R.id.saveProfileButton)
deleteProfileButton = findViewById(R.id.deleteProfileButton)
terminalButton = findViewById(R.id.terminalButton) // ✅ Инициализируем terminalButton
executeButton.isEnabled = false
// Настройка спиннера профилей
adapter = ArrayAdapter(this, android.R.layout.simple_spinner_item, mutableListOf<String>())
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
profilesSpinner.adapter = adapter
}
private fun openTerminal(profile: SshProfile) {
val intent = Intent(this, TerminalActivity::class.java).apply {
// Передаем отдельные поля вместо всего объекта
putExtra("profile_name", profile.name)
putExtra("host", profile.host)
putExtra("port", profile.port)
putExtra("username", profile.username)
putExtra("password", profile.password)
}
startActivity(intent)
}
private fun setupClickListeners() {
connectButton.setOnClickListener {
connectSsh()
}
executeButton.setOnClickListener {
executeCommand("ls -la")
}
saveProfileButton.setOnClickListener {
showSaveProfileDialog()
}
deleteProfileButton.setOnClickListener {
deleteCurrentProfile()
}
terminalButton.setOnClickListener { // ✅ Добавляем обработчик для terminalButton
val position = profilesSpinner.selectedItemPosition
if (position > 0) {
val profile = profiles[position - 1]
openTerminal(profile)
} else {
// Создаем временный профиль из текущих данных
val tempProfile = SshProfile(
name = "Temp Terminal",
host = hostInput.text.toString(),
port = portInput.text.toString().toIntOrNull() ?: 22,
username = usernameInput.text.toString(),
password = passwordInput.text.toString()
)
openTerminal(tempProfile)
}
}
profilesSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>?, view: android.view.View?, position: Int, id: Long) {
if (position > 0) { // position 0 is "New Profile"
loadProfile(profiles[position - 1])
}
}
override fun onNothingSelected(parent: AdapterView<*>?) {}
}
}
private fun loadProfiles() {
val profilesJson = prefs.getString("profiles", "[]") ?: "[]"
val jsonArray = JSONArray(profilesJson)
profiles.clear()
val profileNames = mutableListOf("New Profile")
for (i in 0 until jsonArray.length()) {
val json = jsonArray.getJSONObject(i)
val profile = SshProfile(
name = json.getString("name"),
host = json.getString("host"),
port = json.getInt("port"),
username = json.getString("username"),
password = json.getString("password")
)
profiles.add(profile)
profileNames.add(profile.name)
}
adapter.clear()
adapter.addAll(profileNames)
}
private fun saveProfiles() {
val jsonArray = JSONArray()
profiles.forEach { profile ->
val json = JSONObject().apply {
put("name", profile.name)
put("host", profile.host)
put("port", profile.port)
put("username", profile.username)
put("password", profile.password)
}
jsonArray.put(json)
}
prefs.edit().putString("profiles", jsonArray.toString()).apply()
loadProfiles() // Reload to update spinner
}
private fun showSaveProfileDialog() {
val dialogView = layoutInflater.inflate(R.layout.dialog_save_profile, null)
val nameInput = dialogView.findViewById<EditText>(R.id.profileNameInput)
// Pre-fill with current connection details
nameInput.setText("${usernameInput.text}@${hostInput.text}")
AlertDialog.Builder(this)
.setTitle("Save Profile")
.setView(dialogView)
.setPositiveButton("Save") { _, _ ->
val profileName = nameInput.text.toString()
if (profileName.isNotEmpty()) {
saveProfile(profileName)
}
}
.setNegativeButton("Cancel", null)
.show()
}
private fun saveProfile(name: String) {
val profile = SshProfile(
name = name,
host = hostInput.text.toString(),
port = portInput.text.toString().toIntOrNull() ?: 22,
username = usernameInput.text.toString(),
password = passwordInput.text.toString()
)
profiles.removeAll { it.name == name } // Remove existing with same name
profiles.add(profile)
saveProfiles()
// Select the newly saved profile
profilesSpinner.setSelection(adapter.getPosition(name))
appendOutput("✅ Profile '$name' saved")
}
private fun deleteCurrentProfile() {
val position = profilesSpinner.selectedItemPosition
if (position > 0) {
val profile = profiles[position - 1]
AlertDialog.Builder(this)
.setTitle("Delete Profile")
.setMessage("Delete profile '${profile.name}'?")
.setPositiveButton("Delete") { _, _ ->
profiles.removeAt(position - 1)
saveProfiles()
profilesSpinner.setSelection(0) // Select "New Profile"
appendOutput("🗑️ Profile '${profile.name}' deleted")
}
.setNegativeButton("Cancel", null)
.show()
}
}
private fun loadProfile(profile: SshProfile) {
hostInput.setText(profile.host)
portInput.setText(profile.port.toString())
usernameInput.setText(profile.username)
passwordInput.setText(profile.password)
appendOutput("📁 Loaded profile: ${profile.name}")
}
private fun connectSsh() {
val host = hostInput.text.toString()
val port = portInput.text.toString().toIntOrNull() ?: 22
val username = usernameInput.text.toString()
val password = passwordInput.text.toString()
if (host.isEmpty() || username.isEmpty() || password.isEmpty()) {
appendOutput("❌ Please fill all fields")
return
}
GlobalScope.launch(Dispatchers.IO) {
try {
appendOutput("🔌 Connecting to $host:$port...")
val session = jsch.getSession(username, host, port).apply {
setPassword(password)
setConfig("StrictHostKeyChecking", "no") // ⚠️ Only for testing!
connect(30000) // 30 second timeout
}
appendOutput("✅ Connected successfully!")
runOnUiThread {
executeButton.isEnabled = true
}
} catch (e: Exception) {
appendOutput("❌ Connection failed: ${e.message}")
e.printStackTrace()
}
}
}
private fun executeCommand(command: String) {
val host = hostInput.text.toString()
val port = portInput.text.toString().toIntOrNull() ?: 22
val username = usernameInput.text.toString()
val password = passwordInput.text.toString()
if (host.isEmpty() || username.isEmpty() || password.isEmpty()) {
appendOutput("❌ Please fill all fields")
return
}
GlobalScope.launch(Dispatchers.IO) {
try {
appendOutput("💻 Executing: $command")
val session = jsch.getSession(username, host, port).apply {
setPassword(password)
setConfig("StrictHostKeyChecking", "no")
connect(30000)
}
val channel = session.openChannel("exec") as ChannelExec
channel.setCommand(command)
val inputStream = channel.inputStream
val errorStream = channel.errStream
channel.connect()
val output = inputStream.bufferedReader().readText()
val error = errorStream.bufferedReader().readText()
channel.disconnect()
session.disconnect()
runOnUiThread {
if (output.isNotEmpty()) {
appendOutput("📄 Output:\n$output")
}
if (error.isNotEmpty()) {
appendOutput("⚠️ Error:\n$error")
}
appendOutput("🔚 Command completed")
}
} catch (e: Exception) {
appendOutput("❌ SSH operation failed: ${e.message}")
e.printStackTrace()
}
}
}
private fun appendOutput(text: String) {
runOnUiThread {
val current = outputText.text.toString()
outputText.text = if (current.isEmpty()) text else "$current\n$text"
}
}
}
// Простой data class для профилей
data class SshProfile(
val name: String,
val host: String,
val port: Int,
val username: String,
val password: String
)

View file

@ -0,0 +1,312 @@
package com.example.vedroid
import android.os.Bundle
import android.text.method.ScrollingMovementMethod
import android.view.KeyEvent
import android.view.inputmethod.EditorInfo
import android.widget.*
import androidx.appcompat.app.AppCompatActivity
import com.jcraft.jsch.ChannelShell
import com.jcraft.jsch.JSch
import kotlinx.coroutines.*
import java.io.InputStream
import java.io.OutputStream
import java.nio.charset.StandardCharsets
class TerminalActivity : AppCompatActivity() {
private lateinit var terminalView: TextView
private lateinit var inputEditText: EditText
private lateinit var terminalScrollView: ScrollView
private lateinit var ctrlCButton: Button
private lateinit var ctrlDButton: Button
private lateinit var clearButton: Button
private lateinit var sendButton: Button
private val jsch = JSch()
private var channel: ChannelShell? = null
private var inputStream: InputStream? = null
private var outputStream: OutputStream? = null
private var isConnected = false
private val terminalScope = CoroutineScope(Dispatchers.Main + Job())
private val commandHistory = mutableListOf<String>()
private var historyIndex = -1
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_terminal)
val host = intent.getStringExtra("host") ?: ""
val port = intent.getIntExtra("port", 22)
val username = intent.getStringExtra("username") ?: ""
val password = intent.getStringExtra("password") ?: ""
if (host.isEmpty() || username.isEmpty() || password.isEmpty()) {
showError("Invalid connection data")
finish()
return
}
initViews()
setupClickListeners()
connectToTerminal(host, port, username, password)
}
private fun initViews() {
terminalView = findViewById(R.id.terminalView)
inputEditText = findViewById(R.id.inputEditText)
terminalScrollView = findViewById(R.id.terminalScrollView)
ctrlCButton = findViewById(R.id.ctrlCButton)
ctrlDButton = findViewById(R.id.ctrlDButton)
clearButton = findViewById(R.id.clearButton)
sendButton = findViewById(R.id.sendButton)
terminalView.movementMethod = ScrollingMovementMethod()
terminalView.text = ""
// Настройка истории команд
inputEditText.setOnKeyListener { _, keyCode, event ->
if (event.action == KeyEvent.ACTION_DOWN) {
when (keyCode) {
KeyEvent.KEYCODE_DPAD_UP -> {
showPreviousCommand()
return@setOnKeyListener true
}
KeyEvent.KEYCODE_DPAD_DOWN -> {
showNextCommand()
return@setOnKeyListener true
}
}
}
false
}
}
private fun setupClickListeners() {
sendButton.setOnClickListener {
sendCommand()
}
inputEditText.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE) {
sendCommand()
true
} else {
false
}
}
ctrlCButton.setOnClickListener {
sendControlC()
}
ctrlDButton.setOnClickListener {
sendControlD()
}
clearButton.setOnClickListener {
clearTerminal()
}
}
private fun connectToTerminal(host: String, port: Int, username: String, password: String) {
terminalScope.launch(Dispatchers.IO) {
try {
appendToTerminal("🔌 Connecting to $host:$port...\n")
val session = jsch.getSession(username, host, port).apply {
setPassword(password)
setConfig("StrictHostKeyChecking", "no")
setConfig("PreferredAuthentications", "password")
// Важные настройки для терминала
setConfig("compression.s2c", "none")
setConfig("compression.c2s", "none")
setConfig("StrictHostKeyChecking", "no")
connect(30000)
}
channel = session.openChannel("shell") as ChannelShell
channel?.apply {
// Упрощенные настройки терминала
setPtyType("vt100") // Простой терминал вместо xterm
setPtySize(80, 24, 0, 0)
// Минимальные настройки окружения
setEnv("TERM", "vt100")
setEnv("LANG", "C") // Простая локаль
connect(5000)
}
inputStream = channel?.inputStream
outputStream = channel?.outputStream
isConnected = true
appendToTerminal("✅ Connected to SSH terminal\n")
appendToTerminal("💡 Type commands in the input field below\n\n")
// Запускаем чтение вывода
launch(Dispatchers.IO) {
readTerminalOutput()
}
} catch (e: Exception) {
appendToTerminal("❌ Connection failed: ${e.message}\n")
}
}
}
private fun readTerminalOutput() {
val buffer = ByteArray(1024)
try {
while (isConnected && channel?.isConnected == true) {
val length = inputStream?.read(buffer) ?: -1
if (length > 0) {
val output = String(buffer, 0, length, StandardCharsets.UTF_8)
val cleanedOutput = cleanTerminalOutput(output)
appendToTerminal(cleanedOutput)
} else if (length < 0) {
break
}
}
} catch (e: Exception) {
if (isConnected) {
appendToTerminal("\n❌ Connection lost\n")
}
} finally {
disconnect()
}
}
private fun cleanTerminalOutput(output: String): String {
return output
.replace("\u001B\\[[?]?[0-9;]*[A-Za-z]".toRegex(), "") // ANSI escape sequences
.replace("\u001B\\].*?\u0007".toRegex(), "") // OSC sequences
.replace("\u0007", "") // Bell character
.replace("\u0008", "") // Backspace
.replace("\r\n", "\n") // Normalize line endings
.replace("\r", "\n")
}
private fun sendCommand() {
val command = inputEditText.text.toString().trim()
if (command.isNotEmpty() && isConnected) {
// Добавляем в историю
if (commandHistory.isEmpty() || commandHistory.last() != command) {
commandHistory.add(command)
if (commandHistory.size > 50) {
commandHistory.removeAt(0)
}
}
historyIndex = commandHistory.size
// Показываем команду в терминале
appendToTerminal("$ ${command}\n")
// Отправляем команду
terminalScope.launch(Dispatchers.IO) {
try {
outputStream?.write("$command\n".toByteArray(StandardCharsets.UTF_8))
outputStream?.flush()
} catch (e: Exception) {
appendToTerminal("❌ Error sending command\n")
}
}
inputEditText.text.clear()
}
}
private fun showPreviousCommand() {
if (commandHistory.isNotEmpty()) {
if (historyIndex > 0) historyIndex--
if (historyIndex in commandHistory.indices) {
inputEditText.setText(commandHistory[historyIndex])
inputEditText.setSelection(inputEditText.text.length)
}
}
}
private fun showNextCommand() {
if (commandHistory.isNotEmpty()) {
if (historyIndex < commandHistory.size - 1) {
historyIndex++
inputEditText.setText(commandHistory[historyIndex])
inputEditText.setSelection(inputEditText.text.length)
} else {
historyIndex = commandHistory.size
inputEditText.text.clear()
}
}
}
private fun sendControlC() {
if (isConnected) {
terminalScope.launch(Dispatchers.IO) {
try {
outputStream?.write(3) // Ctrl+C
outputStream?.flush()
appendToTerminal("^C\n")
} catch (e: Exception) {
appendToTerminal("❌ Error sending Ctrl+C\n")
}
}
}
}
private fun sendControlD() {
if (isConnected) {
terminalScope.launch(Dispatchers.IO) {
try {
outputStream?.write(4) // Ctrl+D
outputStream?.flush()
appendToTerminal("^D\n")
} catch (e: Exception) {
appendToTerminal("❌ Error sending Ctrl+D\n")
}
}
}
}
private fun appendToTerminal(text: String) {
runOnUiThread {
val current = terminalView.text.toString()
terminalView.text = current + text
terminalScrollView.post {
terminalScrollView.fullScroll(android.view.View.FOCUS_DOWN)
}
}
}
private fun clearTerminal() {
runOnUiThread {
terminalView.text = ""
appendToTerminal("Terminal cleared\n")
}
}
private fun showError(message: String) {
Toast.makeText(this, message, Toast.LENGTH_LONG).show()
}
private fun disconnect() {
isConnected = false
try {
channel?.disconnect()
} catch (e: Exception) {
// Ignore
}
appendToTerminal("\n🔌 Disconnected\n")
}
override fun onDestroy() {
super.onDestroy()
disconnect()
terminalScope.cancel()
}
}

View file

@ -0,0 +1,10 @@
package com.example.vedroid.model
// Теперь не нужно Serializable
data class SshProfile(
val name: String,
val host: String,
val port: Int,
val username: String,
val password: String
)

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#3F51B5"
android:pathData="M12,2L2,7L12,12L22,7L12,2Z" />
</vector>

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -0,0 +1,118 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SSH Client with Profiles"
android:textSize="24sp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="20dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="16dp">
<Spinner
android:id="@+id/profilesSpinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:layout_marginEnd="8dp" />
<Button
android:id="@+id/saveProfileButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="💾"
android:layout_marginEnd="4dp" />
<Button
android:id="@+id/deleteProfileButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="🗑️"
android:layout_marginStart="4dp" />
</LinearLayout>
<EditText
android:id="@+id/hostInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Host (e.g., 192.168.1.1)"
android:layout_marginBottom="8dp" />
<EditText
android:id="@+id/portInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Port (default: 22)"
android:inputType="number"
android:text="22"
android:layout_marginBottom="8dp" />
<EditText
android:id="@+id/usernameInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"
android:layout_marginBottom="8dp" />
<EditText
android:id="@+id/passwordInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
android:layout_marginBottom="16dp" />
<Button
android:id="@+id/connectButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Connect SSH"
android:layout_marginBottom="16dp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:id="@+id/outputText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SSH output will appear here..."
android:background="#f5f5f5"
android:padding="8dp"
android:textIsSelectable="true"
android:fontFamily="monospace" />
</ScrollView>
<Button
android:id="@+id/executeButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Execute: ls -la"
android:layout_marginTop="8dp" />
<!-- Добавляем после executeButton -->
<Button
android:id="@+id/terminalButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="🖥️ Open Interactive Terminal"
android:layout_marginBottom="8dp"
android:backgroundTint="#4CAF50" />
</LinearLayout>

View file

@ -0,0 +1,121 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="8dp"
android:background="#000000">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SSH Terminal"
android:textSize="18sp"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:gravity="center"
android:layout_marginBottom="8dp"
android:background="#333333"
android:padding="8dp" />
<ScrollView
android:id="@+id/terminalScrollView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#000000"
android:padding="4dp">
<TextView
android:id="@+id/terminalView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#00FF00"
android:textSize="14sp"
android:fontFamily="monospace"
android:background="#000000"
android:textIsSelectable="true" />
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="8dp">
<EditText
android:id="@+id/inputEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Type command here..."
android:textColor="#FFFFFF"
android:textSize="14sp"
android:background="#333333"
android:imeOptions="actionDone"
android:maxLines="1"
android:layout_marginEnd="8dp" />
<Button
android:id="@+id/sendButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send"
android:textColor="#FFFFFF"
android:backgroundTint="#4CAF50" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="8dp"
android:background="#333333"
android:padding="8dp">
<Button
android:id="@+id/ctrlCButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Ctrl+C"
android:textColor="#FFFFFF"
android:backgroundTint="#FF5722"
android:layout_marginEnd="4dp" />
<Button
android:id="@+id/ctrlDButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Ctrl+D"
android:textColor="#FFFFFF"
android:backgroundTint="#FF9800"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp" />
<Button
android:id="@+id/clearButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Clear"
android:textColor="#FFFFFF"
android:backgroundTint="#2196F3"
android:layout_marginStart="4dp" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="💡 Use ↑↓ for command history"
android:textSize="12sp"
android:textColor="#AAAAAA"
android:gravity="center"
android:layout_marginTop="8dp"
android:padding="4dp" />
</LinearLayout>

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Enter profile name:"
android:layout_marginBottom="8dp" />
<EditText
android:id="@+id/profileNameInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="My Server"
android:inputType="text" />
</LinearLayout>

View file

@ -0,0 +1,9 @@
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>

View file

@ -0,0 +1,4 @@
<resources>
<string name="app_name">Vedroid</string>
<string name="hello_world">Hello World!</string>
</resources>

View file

@ -0,0 +1,18 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Vedroid" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#3F51B5</item>
<item name="colorPrimaryVariant">#303F9F</item>
<item name="colorOnPrimary">#FFFFFF</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#FF4081</item>
<item name="colorSecondaryVariant">#FF4081</item>
<item name="colorOnSecondary">#FFFFFF</item>
</style>
<style name="Theme.AppCompat.DayNight.NoActionBar" parent="Theme.AppCompat.DayNight">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<include domain="sharedpref" path="."/>
<include domain="database" path="."/>
<include domain="file" path="."/>
</full-backup-content>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<data-extraction-rules>
<cloud-backup>
<include domain="sharedpref" path="."/>
<include domain="database" path="."/>
<include domain="file" path="."/>
</cloud-backup>
</data-extraction-rules>

15
build.gradle.kts Normal file
View file

@ -0,0 +1,15 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* Learn more about Gradle by exploring our samples at https://docs.gradle.org/7.6.6/samples
*/
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.1.2" apply false
id("org.jetbrains.kotlin.android") version "1.8.22" apply false // Понижаем версию Kotlin
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}

10
gradle.properties Normal file
View file

@ -0,0 +1,10 @@
# Project-wide Gradle settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true
android.enableJetifier=true
android.nonTransitiveRClass=true
# SDK configuration
android.sdk.dir=/home/daniel/.android/sdk
sdk.dir=/home/daniel/.android/sdk
android.builder.sdkDownload=false

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View file

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

244
gradlew vendored Executable file
View file

@ -0,0 +1,244 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

92
gradlew.bat vendored Normal file
View file

@ -0,0 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

28
settings.gradle.kts Normal file
View file

@ -0,0 +1,28 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/7.6.6/userguide/multi_project_builds.html
*/
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url = uri("https://dl.bintray.com/termux/termux-packages/") }
maven { url = uri("https://grimler.se/termux-packages/") }
}
}
rootProject.name = "vedroid"
include(":app")