198029c825b9234e6b90721d910cc180885fcab1dRomain Guy/* 298029c825b9234e6b90721d910cc180885fcab1dRomain Guy * Copyright (C) 2010 The Android Open Source Project 398029c825b9234e6b90721d910cc180885fcab1dRomain Guy * 498029c825b9234e6b90721d910cc180885fcab1dRomain Guy * Licensed under the Apache License, Version 2.0 (the "License"); 598029c825b9234e6b90721d910cc180885fcab1dRomain Guy * you may not use this file except in compliance with the License. 698029c825b9234e6b90721d910cc180885fcab1dRomain Guy * You may obtain a copy of the License at 798029c825b9234e6b90721d910cc180885fcab1dRomain Guy * 898029c825b9234e6b90721d910cc180885fcab1dRomain Guy * http://www.apache.org/licenses/LICENSE-2.0 998029c825b9234e6b90721d910cc180885fcab1dRomain Guy * 1098029c825b9234e6b90721d910cc180885fcab1dRomain Guy * Unless required by applicable law or agreed to in writing, software 1198029c825b9234e6b90721d910cc180885fcab1dRomain Guy * distributed under the License is distributed on an "AS IS" BASIS, 1298029c825b9234e6b90721d910cc180885fcab1dRomain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1398029c825b9234e6b90721d910cc180885fcab1dRomain Guy * See the License for the specific language governing permissions and 1498029c825b9234e6b90721d910cc180885fcab1dRomain Guy * limitations under the License. 1598029c825b9234e6b90721d910cc180885fcab1dRomain Guy */ 1698029c825b9234e6b90721d910cc180885fcab1dRomain Guy 1798029c825b9234e6b90721d910cc180885fcab1dRomain Guypackage com.android.test.hwui; 1898029c825b9234e6b90721d910cc180885fcab1dRomain Guy 1998029c825b9234e6b90721d910cc180885fcab1dRomain Guyimport android.app.Activity; 2098029c825b9234e6b90721d910cc180885fcab1dRomain Guyimport android.content.Context; 2198029c825b9234e6b90721d910cc180885fcab1dRomain Guyimport android.graphics.Canvas; 2298029c825b9234e6b90721d910cc180885fcab1dRomain Guyimport android.graphics.Paint; 2398029c825b9234e6b90721d910cc180885fcab1dRomain Guyimport android.graphics.Path; 2498029c825b9234e6b90721d910cc180885fcab1dRomain Guyimport android.os.Bundle; 2598029c825b9234e6b90721d910cc180885fcab1dRomain Guyimport android.view.View; 2698029c825b9234e6b90721d910cc180885fcab1dRomain Guyimport android.widget.LinearLayout; 2798029c825b9234e6b90721d910cc180885fcab1dRomain Guy 2898029c825b9234e6b90721d910cc180885fcab1dRomain Guy@SuppressWarnings({"UnusedDeclaration"}) 2998029c825b9234e6b90721d910cc180885fcab1dRomain Guypublic class SmallCircleActivity extends Activity { 3098029c825b9234e6b90721d910cc180885fcab1dRomain Guy @Override 3198029c825b9234e6b90721d910cc180885fcab1dRomain Guy protected void onCreate(Bundle savedInstanceState) { 3298029c825b9234e6b90721d910cc180885fcab1dRomain Guy super.onCreate(savedInstanceState); 3398029c825b9234e6b90721d910cc180885fcab1dRomain Guy 3498029c825b9234e6b90721d910cc180885fcab1dRomain Guy final LinearLayout layout = new LinearLayout(this); 3598029c825b9234e6b90721d910cc180885fcab1dRomain Guy layout.setOrientation(LinearLayout.VERTICAL); 3698029c825b9234e6b90721d910cc180885fcab1dRomain Guy 3798029c825b9234e6b90721d910cc180885fcab1dRomain Guy View view = new PathView(this); 3898029c825b9234e6b90721d910cc180885fcab1dRomain Guy layout.addView(view, new LinearLayout.LayoutParams(PathView.SIZE, PathView.SIZE)); 3998029c825b9234e6b90721d910cc180885fcab1dRomain Guy view = new PathView(this); 4098029c825b9234e6b90721d910cc180885fcab1dRomain Guy view.setLayerType(View.LAYER_TYPE_SOFTWARE, null); 4198029c825b9234e6b90721d910cc180885fcab1dRomain Guy layout.addView(view, new LinearLayout.LayoutParams(PathView.SIZE, PathView.SIZE)); 4298029c825b9234e6b90721d910cc180885fcab1dRomain Guy 4398029c825b9234e6b90721d910cc180885fcab1dRomain Guy setContentView(layout); 4498029c825b9234e6b90721d910cc180885fcab1dRomain Guy } 4598029c825b9234e6b90721d910cc180885fcab1dRomain Guy 4698029c825b9234e6b90721d910cc180885fcab1dRomain Guy static class PathView extends View { 4798029c825b9234e6b90721d910cc180885fcab1dRomain Guy private static final int SIZE = 37; 4898029c825b9234e6b90721d910cc180885fcab1dRomain Guy private final Paint mPaint; 4998029c825b9234e6b90721d910cc180885fcab1dRomain Guy private final Path mPath; 5098029c825b9234e6b90721d910cc180885fcab1dRomain Guy 5198029c825b9234e6b90721d910cc180885fcab1dRomain Guy PathView(Context c) { 5298029c825b9234e6b90721d910cc180885fcab1dRomain Guy super(c); 5398029c825b9234e6b90721d910cc180885fcab1dRomain Guy 5498029c825b9234e6b90721d910cc180885fcab1dRomain Guy mPath = new Path(); 5598029c825b9234e6b90721d910cc180885fcab1dRomain Guy mPath.addCircle(SIZE * 0.5f, SIZE * 0.5f, SIZE * 0.275f, Path.Direction.CW); 5698029c825b9234e6b90721d910cc180885fcab1dRomain Guy mPath.addCircle(SIZE * 0.5f, SIZE * 0.5f, SIZE * 0.225f, Path.Direction.CCW); 5798029c825b9234e6b90721d910cc180885fcab1dRomain Guy 5898029c825b9234e6b90721d910cc180885fcab1dRomain Guy mPaint = new Paint(); 5998029c825b9234e6b90721d910cc180885fcab1dRomain Guy mPaint.setAntiAlias(true); 6052244fff29042926e21fa897ef5ab11148e35299John Reck mPaint.setColor(0xff00ffff); 6198029c825b9234e6b90721d910cc180885fcab1dRomain Guy } 6298029c825b9234e6b90721d910cc180885fcab1dRomain Guy 6398029c825b9234e6b90721d910cc180885fcab1dRomain Guy @Override 6498029c825b9234e6b90721d910cc180885fcab1dRomain Guy protected void onDraw(Canvas canvas) { 6598029c825b9234e6b90721d910cc180885fcab1dRomain Guy super.onDraw(canvas); 6698029c825b9234e6b90721d910cc180885fcab1dRomain Guy 6798029c825b9234e6b90721d910cc180885fcab1dRomain Guy canvas.drawPath(mPath, mPaint); 6898029c825b9234e6b90721d910cc180885fcab1dRomain Guy } 6998029c825b9234e6b90721d910cc180885fcab1dRomain Guy } 7098029c825b9234e6b90721d910cc180885fcab1dRomain Guy} 71