1fb13abd800cd610c7f46815848545feff83e5748Romain Guy/* 2fb13abd800cd610c7f46815848545feff83e5748Romain Guy * Copyright (C) 2011 The Android Open Source Project 3fb13abd800cd610c7f46815848545feff83e5748Romain Guy * 4fb13abd800cd610c7f46815848545feff83e5748Romain Guy * Licensed under the Apache License, Version 2.0 (the "License"); 5fb13abd800cd610c7f46815848545feff83e5748Romain Guy * you may not use this file except in compliance with the License. 6fb13abd800cd610c7f46815848545feff83e5748Romain Guy * You may obtain a copy of the License at 7fb13abd800cd610c7f46815848545feff83e5748Romain Guy * 8fb13abd800cd610c7f46815848545feff83e5748Romain Guy * http://www.apache.org/licenses/LICENSE-2.0 9fb13abd800cd610c7f46815848545feff83e5748Romain Guy * 10fb13abd800cd610c7f46815848545feff83e5748Romain Guy * Unless required by applicable law or agreed to in writing, software 11fb13abd800cd610c7f46815848545feff83e5748Romain Guy * distributed under the License is distributed on an "AS IS" BASIS, 12fb13abd800cd610c7f46815848545feff83e5748Romain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13fb13abd800cd610c7f46815848545feff83e5748Romain Guy * See the License for the specific language governing permissions and 14fb13abd800cd610c7f46815848545feff83e5748Romain Guy * limitations under the License. 15fb13abd800cd610c7f46815848545feff83e5748Romain Guy */ 16fb13abd800cd610c7f46815848545feff83e5748Romain Guy 17fb13abd800cd610c7f46815848545feff83e5748Romain Guypackage com.android.test.hwui; 18fb13abd800cd610c7f46815848545feff83e5748Romain Guy 19fb13abd800cd610c7f46815848545feff83e5748Romain Guyimport android.app.Activity; 20fb13abd800cd610c7f46815848545feff83e5748Romain Guyimport android.content.Context; 21fb13abd800cd610c7f46815848545feff83e5748Romain Guyimport android.graphics.Canvas; 22fb13abd800cd610c7f46815848545feff83e5748Romain Guyimport android.graphics.drawable.Drawable; 23fb13abd800cd610c7f46815848545feff83e5748Romain Guyimport android.os.Bundle; 24fb13abd800cd610c7f46815848545feff83e5748Romain Guyimport android.view.View; 25fb13abd800cd610c7f46815848545feff83e5748Romain Guy 26fb13abd800cd610c7f46815848545feff83e5748Romain Guy@SuppressWarnings({"UnusedDeclaration"}) 27fb13abd800cd610c7f46815848545feff83e5748Romain Guypublic class SimplePatchActivity extends Activity { 28fb13abd800cd610c7f46815848545feff83e5748Romain Guy @Override 29fb13abd800cd610c7f46815848545feff83e5748Romain Guy protected void onCreate(Bundle savedInstanceState) { 30fb13abd800cd610c7f46815848545feff83e5748Romain Guy super.onCreate(savedInstanceState); 31fb13abd800cd610c7f46815848545feff83e5748Romain Guy 32fb13abd800cd610c7f46815848545feff83e5748Romain Guy setContentView(new PatchView(this)); 33fb13abd800cd610c7f46815848545feff83e5748Romain Guy } 34fb13abd800cd610c7f46815848545feff83e5748Romain Guy 35fb13abd800cd610c7f46815848545feff83e5748Romain Guy private static class PatchView extends View { 36fb13abd800cd610c7f46815848545feff83e5748Romain Guy private final Drawable mDrawable; 37fb13abd800cd610c7f46815848545feff83e5748Romain Guy 38fb13abd800cd610c7f46815848545feff83e5748Romain Guy public PatchView(Context context) { 39fb13abd800cd610c7f46815848545feff83e5748Romain Guy super(context); 40fb13abd800cd610c7f46815848545feff83e5748Romain Guy setBackgroundColor(0xff000000); 41fb13abd800cd610c7f46815848545feff83e5748Romain Guy mDrawable = context.getResources().getDrawable(R.drawable.expander_ic_minimized); 42fb13abd800cd610c7f46815848545feff83e5748Romain Guy } 43fb13abd800cd610c7f46815848545feff83e5748Romain Guy 44fb13abd800cd610c7f46815848545feff83e5748Romain Guy @Override 45fb13abd800cd610c7f46815848545feff83e5748Romain Guy protected void onDraw(Canvas canvas) { 46fb13abd800cd610c7f46815848545feff83e5748Romain Guy super.onDraw(canvas); 47fb13abd800cd610c7f46815848545feff83e5748Romain Guy canvas.save(); 48fb13abd800cd610c7f46815848545feff83e5748Romain Guy canvas.translate(200, 200); 49fb13abd800cd610c7f46815848545feff83e5748Romain Guy mDrawable.setBounds(3, 0, 33, 64); 50fb13abd800cd610c7f46815848545feff83e5748Romain Guy mDrawable.draw(canvas); 51fb13abd800cd610c7f46815848545feff83e5748Romain Guy mDrawable.setBounds(63, 0, 94, 64); 52fb13abd800cd610c7f46815848545feff83e5748Romain Guy mDrawable.draw(canvas); 53fb13abd800cd610c7f46815848545feff83e5748Romain Guy canvas.restore(); 54fb13abd800cd610c7f46815848545feff83e5748Romain Guy } 55fb13abd800cd610c7f46815848545feff83e5748Romain Guy } 56fb13abd800cd610c7f46815848545feff83e5748Romain Guy} 57