Add test assist to implement motion study

This change introduces another test VoiceInteractionService, Assist,
to test the full SystemUI -> assist layer motion when invoking
assist.

The old assist test project was renamed to LegacyAssist.

Change-Id: Iddf8a36a76083625f8aa4faecef1930e9952d05b
This commit is contained in:
Jorim Jaggi
2015-04-01 13:37:39 -07:00
parent 2fdeeabe78
commit 6e9fa1a4b7
26 changed files with 581 additions and 4 deletions

10
tests/Assist/Android.mk Normal file
View File

@@ -0,0 +1,10 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := tests
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := Assist
include $(BUILD_PACKAGE)

View File

@@ -0,0 +1,39 @@
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.test.assist">
<application>
<service android:name="AssistInteractionService"
android:label="Test Assist Interaction Service"
android:permission="android.permission.BIND_VOICE_INTERACTION"
android:process=":interactor">
<meta-data android:name="android.voice_interaction"
android:resource="@xml/interaction_service" />
<intent-filter>
<action android:name="android.service.voice.VoiceInteractionService" />
</intent-filter>
<meta-data
android:name="com.android.systemui.action_assist_icon"
android:resource="@drawable/assistant" />
</service>
<service android:name="AssistInteractionSessionService"
android:permission="android.permission.BIND_VOICE_INTERACTION"
android:process=":session">
</service>
</application>
</manifest>

View File

@@ -0,0 +1,27 @@
<!--
Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48.0dp"
android:height="48.0dp"
android:viewportWidth="48.0"
android:viewportHeight="48.0">
<path
android:pathData="M0 0h48v48H0z"
android:fillColor="#00000000"/>
<path
android:fillColor="#FF000000"
android:pathData="M38.0,4.0L10.0,4.0C7.79,4.0 6.0,5.79 6.0,8.0l0.0,28.0c0.0,2.21 1.79,4.0 4.0,4.0l8.0,0.0l6.0,6.0 6.0,-6.0l8.0,0.0c2.21,0.0 4.0,-1.79 4.0,-4.0L36.0,8.0c0.0,-2.21 -1.79,-4.0 -4.0,-4.0zM27.75,25.75L24.0,34.0l-3.75,-8.25L12.0,22.0l8.25,-3.75L24.0,10.0l3.75,8.25L36.0,22.0l-8.25,3.75z"/>
</vector>

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2014 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:type="linear"
android:angle="90"
android:startColor="#33000000"
android:endColor="#00000000" />
</shape>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2014 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#e0e0e0">
<item>
<shape>
<solid android:color="#ffffff" />
<corners android:radius="2dp" />
</shape>
</item>
</ripple>

View File

@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.android.test.assist.ScrimView
android:id="@+id/scrim"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#60000000"/>
<View
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="350dp"
android:layout_gravity="bottom"
android:background="#e0e0e0"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="350dp"
android:orientation="vertical"
android:layout_gravity="bottom">
<FrameLayout
android:id="@+id/card1"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="16dp"
android:elevation="3dp"
android:background="@drawable/round_rect">
</FrameLayout>
<View
android:id="@+id/card2"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="16dp"
android:elevation="3dp"
android:background="@drawable/round_rect"/>
</LinearLayout>
<com.android.test.assist.ScrimView
android:id="@+id/navbar_scrim"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_gravity="bottom"
android:background="@drawable/navbar_scrim"/>
</FrameLayout>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<string name="start">Start</string>
<string name="confirm">Confirm</string>
<string name="abort">Abort</string>
<string name="complete">Complete</string>
<string name="abortVoice">Abort Voice</string>
<string name="completeVoice">Complete Voice</string>
<string name="pickVoice">Pick Voice</string>
<string name="cancelVoice">Cancel</string>
</resources>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<voice-interaction-service xmlns:android="http://schemas.android.com/apk/res/android"
android:sessionService="com.android.test.assist.AssistInteractionSessionService"
android:recognitionService="com.android.test.assist.AssistRecognitionService"
android:supportsAssistGesture="true"/>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<recognition-service/>

View File

@@ -0,0 +1,23 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package com.android.test.assist;
import android.service.voice.VoiceInteractionService;
public class AssistInteractionService extends VoiceInteractionService {
}

View File

@@ -0,0 +1,181 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package com.android.test.assist;
import android.animation.Animator;
import android.animation.RevealAnimator;
import android.animation.ValueAnimator;
import android.app.VoiceInteractor;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.service.voice.VoiceInteractionService;
import android.service.voice.VoiceInteractionSession;
import android.util.Log;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewTreeObserver;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
/**
* Sample session to show test assist transition.
*/
public class AssistInteractionSession extends VoiceInteractionSession {
private View mScrim;
private View mBackground;
private View mNavbarScrim;
private View mCard1;
private View mCard2;
private float mDensity;
public AssistInteractionSession(Context context) {
super(context);
}
public AssistInteractionSession(Context context, Handler handler) {
super(context, handler);
}
@Override
public void onConfirm(Caller caller,
Request request, CharSequence prompt, Bundle extras) {
}
@Override
public void onPickOption(Caller caller,
Request request, CharSequence prompt,
VoiceInteractor.PickOptionRequest.Option[] options, Bundle extras) {
}
@Override
public void onCommand(Caller caller,
Request request, String command, Bundle extras) {
}
@Override
public void onCreate(Bundle args) {
super.onCreate(args);
// Simulate slowness of Assist app
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public void onCancel(Request request) {
}
@Override
public View onCreateContentView() {
View v = getLayoutInflater().inflate(R.layout.assist, null);
mScrim = v.findViewById(R.id.scrim);
mBackground = v.findViewById(R.id.background);
mDensity = mScrim.getResources().getDisplayMetrics().density;
mCard1 = v.findViewById(R.id.card1);
mCard2 = v.findViewById(R.id.card2);
mNavbarScrim = v.findViewById(R.id.navbar_scrim);
return v;
}
@Override
public void onShow(Bundle args, int showFlags) {
super.onShow(args, showFlags);
if ((showFlags & VoiceInteractionService.START_SOURCE_ASSIST_GESTURE) != 0) {
mBackground.getViewTreeObserver().addOnPreDrawListener(
new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
mBackground.getViewTreeObserver().removeOnPreDrawListener(this);
playAssistAnimation();
return true;
}
});
}
}
private void playAssistAnimation() {
Interpolator linearOutSlowIn = AnimationUtils.loadInterpolator(mBackground.getContext(),
android.R.interpolator.linear_out_slow_in);
Interpolator fastOutSlowIn = AnimationUtils.loadInterpolator(mBackground.getContext(),
android.R.interpolator.fast_out_slow_in);
mScrim.setAlpha(0f);
mScrim.animate()
.alpha(1f)
.setStartDelay(100)
.setDuration(500);
mBackground.setTranslationY(50 * mDensity);
mBackground.animate()
.translationY(0)
.setDuration(300)
.setInterpolator(linearOutSlowIn);
int centerX = mBackground.getWidth()/2;
int centerY = (int) (mBackground.getHeight()/5*3.8f);
int radius = (int) Math.sqrt(centerX*centerX + centerY*centerY) + 1;
Animator animator = ViewAnimationUtils.createCircularReveal(mBackground, centerX, centerY,
0, radius);
animator.setDuration(300);
animator.setInterpolator(fastOutSlowIn);
animator.start();
ValueAnimator colorAnim = ValueAnimator.ofArgb(Color.WHITE, 0xffe0e0e0);
colorAnim.setDuration(300);
colorAnim.setInterpolator(fastOutSlowIn);
colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mBackground.setBackgroundColor((Integer) animation.getAnimatedValue());
}
});
colorAnim.start();
mCard1.setY(mBackground.getHeight());
mCard2.setTranslationY(mCard1.getTranslationY());
mCard1.animate()
.translationY(0)
.setDuration(500)
.setInterpolator(linearOutSlowIn)
.setStartDelay(100);
mCard2.animate()
.translationY(0)
.setInterpolator(linearOutSlowIn)
.setStartDelay(150)
.setDuration(500);
mNavbarScrim.setAlpha(0f);
mNavbarScrim.animate()
.alpha(1f)
.setDuration(500)
.setStartDelay(100);
}
@Override
public void onHide() {
super.onHide();
}
}

View File

@@ -0,0 +1,28 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package com.android.test.assist;
import android.os.Bundle;
import android.service.voice.VoiceInteractionSession;
import android.service.voice.VoiceInteractionSessionService;
public class AssistInteractionSessionService extends VoiceInteractionSessionService {
@Override
public VoiceInteractionSession onNewSession(Bundle args) {
return new AssistInteractionSession(this);
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package com.android.test.assist;
import android.content.Intent;
import android.speech.RecognitionService;
/**
* Stub recognition service needed to be a complete voice interactor.
*/
public class AssistRecognitionService extends RecognitionService {
@Override
protected void onStartListening(Intent recognizerIntent, Callback listener) {
}
@Override
protected void onCancel(Callback listener) {
}
@Override
protected void onStopListening(Callback listener) {
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package com.android.test.assist;
import android.annotation.Nullable;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
public class ScrimView extends View {
public ScrimView(Context context) {
super(context);
}
public ScrimView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public ScrimView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public boolean hasOverlappingRendering() {
return false;
}
}

View File

@@ -3,7 +3,7 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := Assistant
LOCAL_PACKAGE_NAME := LegacyAssistant
LOCAL_MODULE_TAGS := tests
LOCAL_CERTIFICATE := platform

View File

@@ -15,7 +15,7 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.test.assistant">
package="com.google.android.test.legacyassistant">
<application android:label="@string/activity_title">

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@@ -14,11 +14,11 @@
* limitations under the License.
*/
package com.google.android.test.assistant;
package com.google.android.test.legacyassistant;
import android.app.Activity;
import android.os.Bundle;
import com.google.android.test.assistant.R;
import com.google.android.test.legacyassistant.R;
public class AssistActivity extends Activity {