diff --git a/res/layout/conversations.xml b/res/layout/conversations.xml
index ce7bd1a..a1c61f8 100644
--- a/res/layout/conversations.xml
+++ b/res/layout/conversations.xml
@@ -75,6 +75,7 @@ along with Yaaic. If not, see .
android:id="@+id/speech"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:drawableLeft="@android:drawable/ic_btn_speak_now" />
+ android:drawableLeft="@android:drawable/ic_btn_speak_now"
+ android:visibility="gone" />
\ No newline at end of file
diff --git a/res/values/settings.xml b/res/values/settings.xml
index 6cf9bf2..5c3581d 100644
--- a/res/values/settings.xml
+++ b/res/values/settings.xml
@@ -20,4 +20,7 @@
fontsize
11
+
+ voice_recognition
+ true
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index bb52312..7127e37 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -162,11 +162,13 @@
24 hour format
Use 24 hour format for timestamps
Misc
- Misc
+ Quit message
Message to show when you disconnect
Quit message
Message to show when you disconnect:
Font size
Set the global font size
Font size
+ Voice Recognition
+ Show button for voice recognition
\ No newline at end of file
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index 8bd502c..4d44daf 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -63,6 +63,11 @@ along with Yaaic. If not, see .
+
activities = pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
- if (activities.size() != 0) {
- ((Button) findViewById(R.id.speech)).setOnClickListener(new SpeechClickListener(this));
- } else {
- speechButton.setVisibility(View.GONE);
- }
// Optimization : cache field lookups
Collection mConversations = server.getConversations();
@@ -182,6 +174,17 @@ public class ConversationActivity extends Activity implements ServiceConnection,
super.onResume();
+ // Check if speech recognition is enabled and available
+ if (new Settings(this).isVoiceRecognitionEnabled()) {
+ PackageManager pm = getPackageManager();
+ Button speechButton = (Button) findViewById(R.id.speech);
+ List activities = pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
+ if (activities.size() != 0) {
+ ((Button) findViewById(R.id.speech)).setOnClickListener(new SpeechClickListener(this));
+ speechButton.setVisibility(View.VISIBLE);
+ }
+ }
+
((ImageView) findViewById(R.id.status)).setImageResource(server.getStatusIcon());
// Start service
diff --git a/src/org/yaaic/model/Settings.java b/src/org/yaaic/model/Settings.java
index 274b9d0..59409e5 100644
--- a/src/org/yaaic/model/Settings.java
+++ b/src/org/yaaic/model/Settings.java
@@ -143,4 +143,17 @@ public class Settings
resources.getString(R.string.default_fontsize)
));
}
+
+ /**
+ * Is voice recognition enabled?
+ *
+ * @return True if voice recognition is enabled, false otherwise
+ */
+ public boolean isVoiceRecognitionEnabled()
+ {
+ return preferences.getBoolean(
+ resources.getString(R.string.key_voice_recognition),
+ Boolean.parseBoolean(resources.getString(R.string.default_voice_recognition))
+ );
+ }
}