diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 58d72ec..981213f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -12,8 +12,8 @@ android { minSdk = 24 //noinspection OldTargetApi targetSdk = 34 - versionCode = 2 - versionName = "1.1" + versionCode = 3 + versionName = "1.2" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/com/the0cp/objection/MainActivity.kt b/app/src/main/java/com/the0cp/objection/MainActivity.kt index 0c26d23..c2466b8 100644 --- a/app/src/main/java/com/the0cp/objection/MainActivity.kt +++ b/app/src/main/java/com/the0cp/objection/MainActivity.kt @@ -18,12 +18,15 @@ import android.util.Log import android.view.View import android.widget.ImageButton import android.widget.ImageView +import android.widget.Switch import androidx.activity.enableEdgeToEdge import androidx.appcompat.app.AppCompatActivity import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat import androidx.preference.PreferenceManager +import androidx.preference.SwitchPreference +import kotlin.properties.Delegates class AccelerationDetector(private val sensorManager: SensorManager, private var threshold: Float, private val onAccelerationDetected: () -> Boolean) : SensorEventListener { @@ -93,6 +96,8 @@ class MainActivity : AppCompatActivity(){ private lateinit var voicePath: String + private var voiceSwitch by Delegates.notNull() + private fun playAudio(context: Context, filePath: String){ /* @@ -209,7 +214,9 @@ class MainActivity : AppCompatActivity(){ val selectedCharacter = preferences.getString("character", "wright") val selectedVoice = preferences.getString("voice", "igiari") - voicePath = "lines/$selectedCharacter/$selectedVoice.mp3" // concat strings + voicePath = "lines/$selectedCharacter/$selectedVoice.mp3" /* concat strings */ + + voiceSwitch = preferences.getBoolean("is_voice", true) /* get switch state */ /* * set splash @@ -224,10 +231,14 @@ class MainActivity : AppCompatActivity(){ println(imagePath) + + accelerationDetector = AccelerationDetector(sensorManager, threshold) { accelerationDetector.stopListening() println(voicePath) - playAudio(this, voicePath) + if(voiceSwitch){ + playAudio(this, voicePath) + } imageView.visibility = View.VISIBLE handler.postDelayed({ imageView.visibility = View.INVISIBLE @@ -277,6 +288,8 @@ class MainActivity : AppCompatActivity(){ val selectedVoice = preferences.getString("voice", "igiari") voicePath = "lines/$selectedCharacter/$selectedVoice.mp3" // concat strings + voiceSwitch = preferences.getBoolean("is_voice", true) /* get switch state */ + /* * set splash * */ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index aa80d27..f56a229 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -11,5 +11,5 @@ Voice Character - Play Music + Play Voice \ No newline at end of file diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index 1829875..3a42450 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -19,13 +19,17 @@ android:key="voice" android:title="@string/voice" app:useSimpleSummaryProvider="true" /> + @@ -34,9 +38,8 @@ - + android:summary="Author: the0cp\nVersion: v1.2" + android:title="Objection!">