summaryrefslogtreecommitdiffstats
path: root/tests/VoiceInteraction
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
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')
-rw-r--r--tests/VoiceInteraction/res/layout/voice_interaction_session.xml9
-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
4 files changed, 24 insertions, 5 deletions
diff --git a/tests/VoiceInteraction/res/layout/voice_interaction_session.xml b/tests/VoiceInteraction/res/layout/voice_interaction_session.xml
index 1057176..d44afb0 100644
--- a/tests/VoiceInteraction/res/layout/voice_interaction_session.xml
+++ b/tests/VoiceInteraction/res/layout/voice_interaction_session.xml
@@ -26,7 +26,7 @@
android:layout_height="match_parent"
android:fitsSystemWindows="true">
- <FrameLayout android:id="@+id/top_content"
+ <LinearLayout android:id="@+id/top_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
@@ -34,15 +34,16 @@
android:background="#ffffffff"
android:elevation="8dp"
>
-
<Button android:id="@+id/start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right"
android:text="@string/start"
/>
-
- </FrameLayout>
+ <ImageView android:id="@+id/screenshot"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+ </LinearLayout>
<LinearLayout android:id="@+id/bottom_content"
android:layout_width="match_parent"
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);