/* * 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.voiceinteraction; import android.annotation.Nullable; import android.app.AssistData; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Rect; import android.util.AttributeSet; import android.util.Log; import android.view.View; import java.util.ArrayList; public class AssistVisualizer extends View { static final String TAG = "AssistVisualizer"; AssistData mAssistData; final Paint mFramePaint = new Paint(); final ArrayList mTextRects = new ArrayList<>(); final int[] mTmpLocation = new int[2]; public AssistVisualizer(Context context, @Nullable AttributeSet attrs) { super(context, attrs); setWillNotDraw(false); mFramePaint.setColor(0xffff0000); mFramePaint.setStyle(Paint.Style.STROKE); mFramePaint.setStrokeWidth(0); } public void setAssistData(AssistData ad) { mAssistData = ad; mTextRects.clear(); final int N = ad.getWindowCount(); if (N > 0) { AssistData.ViewNode window = new AssistData.ViewNode(); for (int i=0; i 0) { left -= root.getScrollX(); top -= root.getScrollY(); AssistData.ViewNode child = new AssistData.ViewNode(); for (int i=0; i