From beb82cb6fda645a43ec4984f903b56caa13180bf Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Tue, 18 Dec 2012 21:09:09 +0000 Subject: [PATCH] eSpeakActivity: use the correct intent for launching the TTS settings on Android 3.x. --- .../com/reecedunn/espeak/eSpeakActivity.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/android/src/com/reecedunn/espeak/eSpeakActivity.java b/android/src/com/reecedunn/espeak/eSpeakActivity.java index 6e1b4c50..8a79cda1 100644 --- a/android/src/com/reecedunn/espeak/eSpeakActivity.java +++ b/android/src/com/reecedunn/espeak/eSpeakActivity.java @@ -26,6 +26,7 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Message; +import android.preference.PreferenceActivity; import android.speech.tts.TextToSpeech; import android.util.Log; import android.view.View; @@ -254,8 +255,7 @@ public class eSpeakActivity extends Activity { public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: - startActivityForResult( - new Intent(ACTION_TTS_SETTINGS), REQUEST_DEFAULT); + launchGeneralTtsSettings(); break; } } @@ -322,9 +322,27 @@ public class eSpeakActivity extends Activity { REQUEST_DEFAULT); break; case R.id.ttsSettings: - startActivityForResult(new Intent(ACTION_TTS_SETTINGS), REQUEST_DEFAULT); + launchGeneralTtsSettings(); break; } } }; + + private void launchGeneralTtsSettings() + { + Intent intent; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) + { + // The Text-to-Speech settings is a Fragment on 3.x: + intent = new Intent(android.provider.Settings.ACTION_SETTINGS); + intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, "com.android.settings.TextToSpeechSettings"); + intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, intent.getExtras()); + } + else + { + // The Text-to-Speech settings is an Activity on 2.x and 4.x: + intent = new Intent(ACTION_TTS_SETTINGS); + } + startActivityForResult(intent, REQUEST_DEFAULT); + } }