Chiao Cheng | 0a73660 | 2012-12-05 12:06:58 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 | */ |
Gary Mai | 69c182a | 2016-12-05 13:07:03 -0800 | [diff] [blame] | 16 | package com.android.contacts.list; |
Chiao Cheng | 0a73660 | 2012-12-05 12:06:58 -0800 | [diff] [blame] | 17 | |
| 18 | import android.content.Context; |
| 19 | import android.util.AttributeSet; |
| 20 | |
Gary Mai | 0a49afa | 2016-12-05 15:53:58 -0800 | [diff] [blame] | 21 | import com.android.contacts.ContactPhotoManager; |
| 22 | import com.android.contacts.ContactPhotoManager.DefaultImageRequest; |
| 23 | |
Chiao Cheng | 0a73660 | 2012-12-05 12:06:58 -0800 | [diff] [blame] | 24 | /** |
| 25 | * A {@link ContactTileStarredView} displays the contact's picture overlayed with their name |
| 26 | * in a square. The actual dimensions are set by |
Gary Mai | 69c182a | 2016-12-05 13:07:03 -0800 | [diff] [blame] | 27 | * {@link com.android.contacts.list.ContactTileAdapter.ContactTileRow}. |
Chiao Cheng | 0a73660 | 2012-12-05 12:06:58 -0800 | [diff] [blame] | 28 | */ |
| 29 | public class ContactTileStarredView extends ContactTileView { |
Brian Attwell | 9854e16 | 2014-08-21 20:11:13 -0700 | [diff] [blame] | 30 | |
| 31 | /** |
| 32 | * The photo manager should display the default image/letter at 80% of its normal size. |
| 33 | */ |
| 34 | private static final float DEFAULT_IMAGE_LETTER_SCALE = 0.8f; |
| 35 | |
Chiao Cheng | 0a73660 | 2012-12-05 12:06:58 -0800 | [diff] [blame] | 36 | public ContactTileStarredView(Context context, AttributeSet attrs) { |
| 37 | super(context, attrs); |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | protected boolean isDarkTheme() { |
| 42 | return false; |
| 43 | } |
| 44 | |
| 45 | @Override |
| 46 | protected int getApproximateImageSize() { |
| 47 | // The picture is the full size of the tile (minus some padding, but we can be generous) |
| 48 | return mListener.getApproximateTileWidth(); |
| 49 | } |
Brian Attwell | 9854e16 | 2014-08-21 20:11:13 -0700 | [diff] [blame] | 50 | |
| 51 | @Override |
| 52 | protected DefaultImageRequest getDefaultImageRequest(String displayName, String lookupKey) { |
| 53 | return new DefaultImageRequest(displayName, lookupKey, ContactPhotoManager.TYPE_DEFAULT, |
| 54 | DEFAULT_IMAGE_LETTER_SCALE, /* offset = */ 0, /* isCircular = */ true); |
| 55 | } |
Chiao Cheng | 0a73660 | 2012-12-05 12:06:58 -0800 | [diff] [blame] | 56 | } |