PhoneFavoriteRegularRowView.java revision 791082e22b50db98de6749bb5ef878d3ec483e28
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 */
16package com.android.dialer.list;
17
18import android.content.Context;
19import android.content.res.Resources;
20import android.util.AttributeSet;
21import android.view.View;
22
23import com.android.contacts.common.util.ViewUtil;
24import com.android.dialer.R;
25
26public class PhoneFavoriteRegularRowView extends PhoneFavoriteTileView {
27    private static final String TAG = PhoneFavoriteRegularRowView.class.getSimpleName();
28    private static final boolean DEBUG = false;
29
30    public PhoneFavoriteRegularRowView(Context context, AttributeSet attrs) {
31        super(context, attrs);
32    }
33
34    @Override
35    protected void onFinishInflate() {
36        super.onFinishInflate();
37
38        final View favoriteContactCard = findViewById(R.id.contact_favorite_card);
39
40        final int rowPaddingStart;
41        final int rowPaddingEnd;
42        final int rowPaddingTop;
43        final int rowPaddingBottom;
44
45        final Resources resources = getResources();
46        rowPaddingStart = resources.getDimensionPixelSize(
47                R.dimen.favorites_row_start_padding);
48        rowPaddingEnd = resources.getDimensionPixelSize(
49                R.dimen.favorites_row_end_padding);
50        rowPaddingTop = resources.getDimensionPixelSize(
51                R.dimen.favorites_row_top_padding);
52        rowPaddingBottom = resources.getDimensionPixelSize(
53                R.dimen.favorites_row_bottom_padding);
54
55        favoriteContactCard.setBackgroundResource(R.drawable.contact_list_item_background);
56
57        favoriteContactCard.setPaddingRelative(rowPaddingStart, rowPaddingTop, rowPaddingEnd,
58                rowPaddingBottom);
59
60        final View quickContactBadge = findViewById(R.id.contact_tile_quick);
61        quickContactBadge.setOnLongClickListener(new OnLongClickListener() {
62            @Override
63            public boolean onLongClick(View v) {
64                return PhoneFavoriteRegularRowView.this.performLongClick();
65            }
66        });
67    }
68
69    @Override
70    protected int getApproximateImageSize() {
71        return ViewUtil.getConstantPreLayoutWidth(getQuickContact());
72    }
73}
74