blob: 7123e2a450e1c91c2277a26435e5c1bb4c22bf51 [file] [log] [blame]
Michael Jurka8245a862011-02-01 17:53:59 -08001/*
2 * Copyright (C) 2010 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
17package com.android.launcher2;
18
19import android.content.Context;
20import android.graphics.Bitmap;
21import android.graphics.Canvas;
22import android.graphics.Paint;
23import android.widget.TextView;
24
25
26
27/**
28 * An icon on a PagedView, specifically for items in the launcher's paged view (with compound
29 * drawables on the top).
30 */
31public class HolographicPagedViewIcon extends TextView {
32 PagedViewIcon mOriginalIcon;
33 Paint mPaint;
34
35 public HolographicPagedViewIcon(Context context, PagedViewIcon original) {
36 super(context);
37 mOriginalIcon = original;
38 mPaint = new Paint();
39 }
40
41 @Override
42 protected void onDraw(Canvas canvas) {
43 Bitmap overlay = mOriginalIcon.getHolographicOutline();
Michael Jurka8245a862011-02-01 17:53:59 -080044 if (overlay != null) {
45 final int offset = getScrollX();
46 final int compoundPaddingLeft = getCompoundPaddingLeft();
47 final int compoundPaddingRight = getCompoundPaddingRight();
48 int hspace = getWidth() - compoundPaddingRight - compoundPaddingLeft;
49 canvas.drawBitmap(overlay,
50 offset + compoundPaddingLeft + (hspace - overlay.getWidth()) / 2,
51 mPaddingTop,
52 mPaint);
53 }
54 }
55}