diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..e81c242 Binary files /dev/null and b/.DS_Store differ diff --git a/app/.DS_Store b/app/.DS_Store new file mode 100644 index 0000000..9a874b5 Binary files /dev/null and b/app/.DS_Store differ diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..0e383e6 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,52 @@ +plugins { + alias(libs.plugins.android.application) +} + +android { + namespace = "com.example.jarvis_stts" + compileSdk { + version = release(36) { + minorApiLevel = 1 + } + } + + defaultConfig { + applicationId = "com.example.jarvis_stts" + minSdk = 24 + targetSdk = 36 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } +} + +dependencies { + // OkHttp für Netzwerkanfragen an Telegram + implementation("com.squareup.okhttp3:okhttp:4.12.0") + + // Coroutinen für Hintergrund-Prozesse (Polling) + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3") + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.appcompat) + implementation(libs.material) + implementation(libs.androidx.activity) + implementation(libs.androidx.constraintlayout) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.androidx.espresso.core) +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/.DS_Store b/app/src/.DS_Store new file mode 100644 index 0000000..e1029c6 Binary files /dev/null and b/app/src/.DS_Store differ diff --git a/app/src/androidTest/java/com/example/jarvis_stts/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/example/jarvis_stts/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..c74b088 --- /dev/null +++ b/app/src/androidTest/java/com/example/jarvis_stts/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.jarvis_stts + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.example.jarvis_stts", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/.DS_Store b/app/src/main/.DS_Store new file mode 100644 index 0000000..55c1fcb Binary files /dev/null and b/app/src/main/.DS_Store differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..36a3dc3 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/.DS_Store b/app/src/main/java/.DS_Store new file mode 100644 index 0000000..35a54bf Binary files /dev/null and b/app/src/main/java/.DS_Store differ diff --git a/app/src/main/java/com/.DS_Store b/app/src/main/java/com/.DS_Store new file mode 100644 index 0000000..57a5553 Binary files /dev/null and b/app/src/main/java/com/.DS_Store differ diff --git a/app/src/main/java/com/example/.DS_Store b/app/src/main/java/com/example/.DS_Store new file mode 100644 index 0000000..3ad1e86 Binary files /dev/null and b/app/src/main/java/com/example/.DS_Store differ diff --git a/app/src/main/java/com/example/jarvis_stts/MainActivity.kt b/app/src/main/java/com/example/jarvis_stts/MainActivity.kt new file mode 100644 index 0000000..e28ce80 --- /dev/null +++ b/app/src/main/java/com/example/jarvis_stts/MainActivity.kt @@ -0,0 +1,161 @@ +package com.example.jarvis_stts + +import android.Manifest +import android.content.Intent +import android.content.pm.PackageManager +import android.os.Bundle +import android.speech.RecognizerIntent +import android.speech.tts.TextToSpeech +import android.speech.tts.Voice +import android.util.Log +import android.view.View +import android.widget.* +import androidx.activity.result.contract.ActivityResultContracts +import androidx.appcompat.app.AppCompatActivity +import androidx.core.app.ActivityCompat +import androidx.core.content.ContextCompat +import okhttp3.* +import java.util.Locale + +class MainActivity : AppCompatActivity(), TextToSpeech.OnInitListener { + + private lateinit var tts: TextToSpeech + private lateinit var tvStatus: TextView + private lateinit var etUrl: EditText + private lateinit var spinnerVoices: Spinner + + private val client = OkHttpClient() + private var webSocket: WebSocket? = null + + // Liste für die Stimmen-Objekte und deren Namen + private var availableVoices = mutableListOf() + private var voiceNames = mutableListOf() + + private val speechRecognizerLauncher = registerForActivityResult( + ActivityResultContracts.StartActivityForResult() + ) { result -> + if (result.resultCode == RESULT_OK && result.data != null) { + val spokenText = result.data!!.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)?.get(0) ?: "" + tvStatus.text = "Ich: $spokenText" + webSocket?.send(spokenText) + } + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + // 1. UI-Elemente initialisieren + tvStatus = findViewById(R.id.tvStatus) + etUrl = findViewById(R.id.etUrl) + spinnerVoices = findViewById(R.id.spinnerVoices) + + // Hier fehlten wahrscheinlich diese Definitionen: + val btnConnect = findViewById