summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/Controller.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/browser/Controller.java')
-rw-r--r--src/com/android/browser/Controller.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 8a00ba3..e901d45 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -52,6 +52,7 @@ import android.provider.BrowserContract;
import android.provider.BrowserContract.Images;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Intents.Insert;
+import android.speech.RecognizerIntent;
import android.text.TextUtils;
import android.util.Log;
import android.util.Patterns;
@@ -129,6 +130,7 @@ public class Controller
final static int PREFERENCES_PAGE = 3;
final static int FILE_SELECTED = 4;
final static int AUTOFILL_SETUP = 5;
+ final static int VOICE_RESULT = 6;
private final static int WAKELOCK_TIMEOUT = 5 * 60 * 1000; // 5 minutes
@@ -216,6 +218,8 @@ public class Controller
private boolean mBlockEvents;
+ private String mVoiceResult;
+
public Controller(Activity browser) {
mActivity = browser;
mSettings = BrowserSettings.getInstance();
@@ -700,6 +704,10 @@ public class Controller
mNetworkHandler.onResume();
WebView.enablePlatformNotifications();
NfcHandler.register(mActivity, this);
+ if (mVoiceResult != null) {
+ mUi.onVoiceResult(mVoiceResult);
+ mVoiceResult = null;
+ }
}
private void releaseWakeLock() {
@@ -1190,6 +1198,15 @@ public class Controller
}
}
break;
+ case VOICE_RESULT:
+ if (resultCode == Activity.RESULT_OK && intent != null) {
+ ArrayList<String> results = intent.getStringArrayListExtra(
+ RecognizerIntent.EXTRA_RESULTS);
+ if (results.size() >= 1) {
+ mVoiceResult = results.get(0);
+ }
+ }
+ break;
default:
break;
}
@@ -2804,6 +2821,23 @@ public class Controller
}
@Override
+ public boolean supportsVoice() {
+ PackageManager pm = mActivity.getPackageManager();
+ List activities = pm.queryIntentActivities(new Intent(
+ RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
+ return activities.size() != 0;
+ }
+
+ @Override
+ public void startVoiceRecognizer() {
+ Intent voice = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
+ voice.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
+ RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
+ voice.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);
+ mActivity.startActivityForResult(voice, VOICE_RESULT);
+ }
+
+ @Override
public void setBlockEvents(boolean block) {
mBlockEvents = block;
}