summaryrefslogtreecommitdiffstats
path: root/tests/VoiceInteraction/src
diff options
context:
space:
mode:
authorBarnaby James <bjames@google.com>2014-07-07 10:51:06 -0700
committerBarnaby James <bjames@google.com>2014-07-11 10:34:50 -0700
commitd3fdb8bed8e836786253f9cd5ab640c7c5ed8501 (patch)
tree46a17309ceb85bb5d6abc0660fab799a0207924b /tests/VoiceInteraction/src
parentca249dc6342a7c6678ca3b7f1dabe0e32d3d902e (diff)
downloadframeworks_base-d3fdb8bed8e836786253f9cd5ab640c7c5ed8501.zip
frameworks_base-d3fdb8bed8e836786253f9cd5ab640c7c5ed8501.tar.gz
frameworks_base-d3fdb8bed8e836786253f9cd5ab640c7c5ed8501.tar.bz2
Add VoiceInteraction request type for successful actions.
Add CompleteVoiceRequest to VoiceInteractor to allow apps to indicate when a voice interaction was successfully completed. Change-Id: I1481cfe96e9e2495d88a7a4fb62263bdd1e03c54
Diffstat (limited to 'tests/VoiceInteraction/src')
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java19
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java18
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
index c24a088..d20906e 100644
--- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
@@ -34,6 +34,7 @@ public class MainInteractionSession extends VoiceInteractionSession
TextView mText;
Button mStartButton;
Button mConfirmButton;
+ Button mCompleteButton;
Button mAbortButton;
static final int STATE_IDLE = 0;
@@ -41,6 +42,7 @@ public class MainInteractionSession extends VoiceInteractionSession
static final int STATE_CONFIRM = 2;
static final int STATE_COMMAND = 3;
static final int STATE_ABORT_VOICE = 4;
+ static final int STATE_COMPLETE_VOICE = 5;
int mState = STATE_IDLE;
Request mPendingRequest;
@@ -64,6 +66,8 @@ public class MainInteractionSession extends VoiceInteractionSession
mStartButton.setOnClickListener(this);
mConfirmButton = (Button)mContentView.findViewById(R.id.confirm);
mConfirmButton.setOnClickListener(this);
+ mCompleteButton = (Button)mContentView.findViewById(R.id.complete);
+ mCompleteButton.setOnClickListener(this);
mAbortButton = (Button)mContentView.findViewById(R.id.abort);
mAbortButton.setOnClickListener(this);
updateState();
@@ -74,6 +78,7 @@ public class MainInteractionSession extends VoiceInteractionSession
mStartButton.setEnabled(mState == STATE_IDLE);
mConfirmButton.setEnabled(mState == STATE_CONFIRM || mState == STATE_COMMAND);
mAbortButton.setEnabled(mState == STATE_ABORT_VOICE);
+ mCompleteButton.setEnabled(mState == STATE_COMPLETE_VOICE);
}
public void onClick(View v) {
@@ -95,6 +100,11 @@ public class MainInteractionSession extends VoiceInteractionSession
mPendingRequest = null;
mState = STATE_IDLE;
updateState();
+ } else if (v== mCompleteButton) {
+ mPendingRequest.sendCompleteVoiceResult(null);
+ mPendingRequest = null;
+ mState = STATE_IDLE;
+ updateState();
}
}
@@ -114,6 +124,15 @@ public class MainInteractionSession extends VoiceInteractionSession
}
@Override
+ public void onCompleteVoice(Caller caller, Request request, CharSequence message, Bundle extras) {
+ Log.i(TAG, "onCompleteVoice: message=" + message + " extras=" + extras);
+ mText.setText(message);
+ mPendingRequest = request;
+ mState = STATE_COMPLETE_VOICE;
+ updateState();
+ }
+
+ @Override
public void onAbortVoice(Caller caller, Request request, CharSequence message, Bundle extras) {
Log.i(TAG, "onAbortVoice: message=" + message + " extras=" + extras);
mText.setText(message);
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java
index 3ae6a36..d64eefa 100644
--- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java
@@ -30,6 +30,7 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis
VoiceInteractor mInteractor;
Button mAbortButton;
+ Button mCompleteButton;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -44,6 +45,8 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis
setContentView(R.layout.test_interaction);
mAbortButton = (Button)findViewById(R.id.abort);
mAbortButton.setOnClickListener(this);
+ mCompleteButton = (Button)findViewById(R.id.complete);
+ mCompleteButton.setOnClickListener(this);
// Framework should take care of these.
getWindow().setGravity(Gravity.TOP);
@@ -90,6 +93,21 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis
}
};
mInteractor.submitRequest(req);
+ } else if (v == mCompleteButton) {
+ VoiceInteractor.CompleteVoiceRequest req = new VoiceInteractor.CompleteVoiceRequest(
+ "Woohoo, completed!", null) {
+ @Override
+ public void onCancel() {
+ Log.i(TAG, "Canceled!");
+ }
+
+ @Override
+ public void onCompleteResult(Bundle result) {
+ Log.i(TAG, "Complete result: result=" + result);
+ getActivity().finish();
+ }
+ };
+ mInteractor.submitRequest(req);
}
}