blob: d2ed5ffc00b12f2921106c6d3bc88319bfd785e7 [file] [log] [blame]
The Android Open Source Project10592532009-03-18 17:39:46 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Joe Onoratofd52b182010-11-10 18:00:52 -080017package com.android.systemui.statusbar.phone;
The Android Open Source Project10592532009-03-18 17:39:46 -070018
19import android.content.Context;
20import android.content.res.TypedArray;
21import android.util.AttributeSet;
Joe Onorato8a9b2202010-02-26 18:56:32 -080022import android.util.Slog;
The Android Open Source Project10592532009-03-18 17:39:46 -070023import android.view.View;
24import android.graphics.BitmapFactory;
25import android.graphics.Bitmap;
26import android.graphics.Paint;
27import android.graphics.Canvas;
28
29public class TrackingPatternView extends View {
30 private Bitmap mTexture;
31 private Paint mPaint;
32 private int mTextureWidth;
33 private int mTextureHeight;
34
35 public TrackingPatternView(Context context, AttributeSet attrs) {
36 super(context, attrs);
37
38 mTexture = BitmapFactory.decodeResource(getResources(),
39 com.android.internal.R.drawable.status_bar_background);
40 mTextureWidth = mTexture.getWidth();
41 mTextureHeight = mTexture.getHeight();
42
43 mPaint = new Paint();
44 mPaint.setDither(false);
45 }
46
47 @Override
48 public void onDraw(Canvas canvas) {
49 final Bitmap texture = mTexture;
50 final Paint paint = mPaint;
51
52 final int width = getWidth();
53 final int height = getHeight();
54
55 final int textureWidth = mTextureWidth;
56 final int textureHeight = mTextureHeight;
57
The Android Open Source Project10592532009-03-18 17:39:46 -070058 int x = 0;
59 int y;
60
61 while (x < width) {
62 y = 0;
63 while (y < height) {
64 canvas.drawBitmap(texture, x, y, paint);
65 y += textureHeight;
66 }
67 x += textureWidth;
68 }
69 }
70}