Enable opening TTS settings from MainActivity

This commit is contained in:
2020-05-07 22:35:06 +02:00
parent 53ebaee880
commit 4458bf66c2
2 changed files with 5 additions and 0 deletions

View File

@@ -4,6 +4,8 @@ import android.content.Intent
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.provider.Settings
import android.provider.Settings.*
import android.view.View
import io.bartek.service.ForegroundService
@@ -20,6 +22,8 @@ class MainActivity : AppCompatActivity() {
fun stopServer(view: View) = actionOnService(ForegroundService.STOP)
fun openTTSSettings(view: View) = startActivity(Intent("com.android.settings.TTS_SETTINGS"))
private fun actionOnService(action: String) {
Intent(this, ForegroundService::class.java).also {
it.action = action

View File

@@ -44,5 +44,6 @@
android:id="@+id/ttsSettings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="openTTSSettings"
android:text="@string/main_activity_tts_settings" />
</LinearLayout>