summaryrefslogtreecommitdiffstats
path: root/tests/VoiceInteraction/src
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2015-03-16 17:15:53 -0700
committerDianne Hackborn <hackbod@google.com>2015-03-17 16:45:51 -0700
commit27eac1d58fe0b7ca3a2e27f5ed64eff232745f45 (patch)
treec1f0dc2a368ab1c7db1be81dc02b020eea0d1628 /tests/VoiceInteraction/src
parent7438f814f16ff1ced53d93a2fe9e3973490f3843 (diff)
downloadframeworks_base-27eac1d58fe0b7ca3a2e27f5ed64eff232745f45.zip
frameworks_base-27eac1d58fe0b7ca3a2e27f5ed64eff232745f45.tar.gz
frameworks_base-27eac1d58fe0b7ca3a2e27f5ed64eff232745f45.tar.bz2
Add ability to get a screenshot for assist.
New flag you pass in to startSession() to say you want it, new callback on VoiceInteractionSession to receive it. Change-Id: I61fdcfdee41a60d46036a2ef16681a9b4181115a
Diffstat (limited to 'tests/VoiceInteraction/src')
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java1
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java2
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java17
3 files changed, 19 insertions, 1 deletions
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java
index bae19a6..2ad23ed 100644
--- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java
@@ -55,6 +55,7 @@ public class AssistVisualizer extends View {
buildTextRects(window, 0, 0);
}
}
+ invalidate();
}
public void clearAssistData() {
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java
index 722b0de..15196b4 100644
--- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java
@@ -79,7 +79,7 @@ public class MainInteractionService extends VoiceInteractionService {
Bundle args = new Bundle();
args.putParcelable("intent", new Intent(this, TestInteractionActivity.class));
args.putBundle("assist", intent.getExtras());
- startSession(args, START_WITH_ASSIST);
+ startSession(args, START_WITH_ASSIST|START_WITH_SCREENSHOT);
} else {
Log.w(TAG, "Not starting -- not current voice interaction service");
}
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
index ad339be..bc18ca9 100644
--- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
@@ -21,11 +21,13 @@ import android.app.AssistStructure;
import android.app.VoiceInteractor;
import android.content.Context;
import android.content.Intent;
+import android.graphics.Bitmap;
import android.os.Bundle;
import android.service.voice.VoiceInteractionSession;
import android.util.Log;
import android.view.View;
import android.widget.Button;
+import android.widget.ImageView;
import android.widget.TextView;
public class MainInteractionSession extends VoiceInteractionSession
@@ -39,6 +41,7 @@ public class MainInteractionSession extends VoiceInteractionSession
View mBottomContent;
TextView mText;
Button mStartButton;
+ ImageView mScreenshot;
Button mConfirmButton;
Button mCompleteButton;
Button mAbortButton;
@@ -76,6 +79,7 @@ public class MainInteractionSession extends VoiceInteractionSession
if (mAssistVisualizer != null) {
mAssistVisualizer.clearAssistData();
}
+ onHandleScreenshot(null);
updateState();
}
@@ -101,6 +105,7 @@ public class MainInteractionSession extends VoiceInteractionSession
mText = (TextView)mContentView.findViewById(R.id.text);
mStartButton = (Button)mContentView.findViewById(R.id.start);
mStartButton.setOnClickListener(this);
+ mScreenshot = (ImageView)mContentView.findViewById(R.id.screenshot);
mConfirmButton = (Button)mContentView.findViewById(R.id.confirm);
mConfirmButton.setOnClickListener(this);
mCompleteButton = (Button)mContentView.findViewById(R.id.complete);
@@ -119,6 +124,18 @@ public class MainInteractionSession extends VoiceInteractionSession
}
}
+ @Override
+ public void onHandleScreenshot(Bitmap screenshot) {
+ if (screenshot != null) {
+ mScreenshot.setImageBitmap(screenshot);
+ mScreenshot.setAdjustViewBounds(true);
+ mScreenshot.setMaxWidth(screenshot.getWidth()/3);
+ mScreenshot.setMaxHeight(screenshot.getHeight()/3);
+ } else {
+ mScreenshot.setImageDrawable(null);
+ }
+ }
+
void parseAssistData(Bundle assistBundle) {
if (assistBundle != null) {
Bundle assistContext = assistBundle.getBundle(Intent.EXTRA_ASSIST_CONTEXT);