Winson Chung | b3347bb | 2010-08-19 14:51:28 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.launcher2; |
| 18 | |
Winson Chung | cd4bc49 | 2010-12-09 18:52:32 -0800 | [diff] [blame] | 19 | import android.animation.ObjectAnimator; |
Winson Chung | b3347bb | 2010-08-19 14:51:28 -0700 | [diff] [blame] | 20 | import android.content.Context; |
Winson Chung | 59e1f9a | 2010-12-21 11:31:54 -0800 | [diff] [blame] | 21 | import android.content.res.Resources; |
Winson Chung | b3347bb | 2010-08-19 14:51:28 -0700 | [diff] [blame] | 22 | import android.graphics.Bitmap; |
Winson Chung | b3347bb | 2010-08-19 14:51:28 -0700 | [diff] [blame] | 23 | import android.graphics.Canvas; |
Winson Chung | b3347bb | 2010-08-19 14:51:28 -0700 | [diff] [blame] | 24 | import android.graphics.Paint; |
Winson Chung | b3347bb | 2010-08-19 14:51:28 -0700 | [diff] [blame] | 25 | import android.util.AttributeSet; |
Michael Jurka | 4c4c001 | 2011-11-15 13:59:13 -0800 | [diff] [blame] | 26 | import android.widget.TextView; |
Winson Chung | c84001e | 2010-11-09 12:20:57 -0800 | [diff] [blame] | 27 | |
Winson Chung | 63257c1 | 2011-05-05 17:06:13 -0700 | [diff] [blame] | 28 | import com.android.launcher.R; |
Winson Chung | 241c3b4 | 2010-08-25 16:53:03 -0700 | [diff] [blame] | 29 | |
Winson Chung | b3347bb | 2010-08-19 14:51:28 -0700 | [diff] [blame] | 30 | /** |
| 31 | * An icon on a PagedView, specifically for items in the launcher's paged view (with compound |
| 32 | * drawables on the top). |
| 33 | */ |
Michael Jurka | 82369a1 | 2012-01-12 08:08:38 -0800 | [diff] [blame^] | 34 | public class PagedViewIcon extends TextView { |
Winson Chung | b3347bb | 2010-08-19 14:51:28 -0700 | [diff] [blame] | 35 | private static final String TAG = "PagedViewIcon"; |
| 36 | |
Michael Jurka | 0620bec | 2010-10-25 17:50:09 -0700 | [diff] [blame] | 37 | private Bitmap mIcon; |
Winson Chung | b3347bb | 2010-08-19 14:51:28 -0700 | [diff] [blame] | 38 | |
Winson Chung | b3347bb | 2010-08-19 14:51:28 -0700 | [diff] [blame] | 39 | public PagedViewIcon(Context context) { |
| 40 | this(context, null); |
| 41 | } |
| 42 | |
| 43 | public PagedViewIcon(Context context, AttributeSet attrs) { |
| 44 | this(context, attrs, 0); |
| 45 | } |
| 46 | |
| 47 | public PagedViewIcon(Context context, AttributeSet attrs, int defStyle) { |
| 48 | super(context, attrs, defStyle); |
Michael Jurka | 8245a86 | 2011-02-01 17:53:59 -0800 | [diff] [blame] | 49 | } |
| 50 | |
Michael Jurka | 82369a1 | 2012-01-12 08:08:38 -0800 | [diff] [blame^] | 51 | public void applyFromApplicationInfo(ApplicationInfo info, boolean scaleUp) { |
Michael Jurka | c9a9619 | 2010-11-01 11:52:08 -0700 | [diff] [blame] | 52 | mIcon = info.iconBitmap; |
Michael Jurka | 0620bec | 2010-10-25 17:50:09 -0700 | [diff] [blame] | 53 | setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null); |
Winson Chung | 241c3b4 | 2010-08-25 16:53:03 -0700 | [diff] [blame] | 54 | setText(info.title); |
| 55 | setTag(info); |
| 56 | } |
Winson Chung | b3347bb | 2010-08-19 14:51:28 -0700 | [diff] [blame] | 57 | } |