1d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng/*
2d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng * Copyright (C) 2011 The Android Open Source Project
3d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng *
4d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng * Licensed under the Apache License, Version 2.0 (the "License");
5d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng * you may not use this file except in compliance with the License.
6d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng * You may obtain a copy of the License at
7d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng *
8d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng *      http://www.apache.org/licenses/LICENSE-2.0
9d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng *
10d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng * Unless required by applicable law or agreed to in writing, software
11d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng * distributed under the License is distributed on an "AS IS" BASIS,
12d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng * See the License for the specific language governing permissions and
14d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng * limitations under the License.
15d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng */
16d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Chengpackage com.android.contacts.common.list;
17d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng
182fd9bf9b5cef661118131464c8692f63b7e97510Brian Attwellimport com.android.contacts.common.ContactPhotoManager;
192fd9bf9b5cef661118131464c8692f63b7e97510Brian Attwellimport com.android.contacts.common.ContactPhotoManager.DefaultImageRequest;
202fd9bf9b5cef661118131464c8692f63b7e97510Brian Attwell
21d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Chengimport android.content.Context;
22d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Chengimport android.util.AttributeSet;
23d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng
24d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng/**
25d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng * A {@link ContactTileStarredView} displays the contact's picture overlayed with their name
26d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng * in a square. The actual dimensions are set by
27d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng * {@link com.android.contacts.common.list.ContactTileAdapter.ContactTileRow}.
28d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng */
29d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Chengpublic class ContactTileStarredView extends ContactTileView {
302fd9bf9b5cef661118131464c8692f63b7e97510Brian Attwell
312fd9bf9b5cef661118131464c8692f63b7e97510Brian Attwell    /**
322fd9bf9b5cef661118131464c8692f63b7e97510Brian Attwell     * The photo manager should display the default image/letter at 80% of its normal size.
332fd9bf9b5cef661118131464c8692f63b7e97510Brian Attwell     */
342fd9bf9b5cef661118131464c8692f63b7e97510Brian Attwell    private static final float DEFAULT_IMAGE_LETTER_SCALE = 0.8f;
352fd9bf9b5cef661118131464c8692f63b7e97510Brian Attwell
36d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng    public ContactTileStarredView(Context context, AttributeSet attrs) {
37d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng        super(context, attrs);
38d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng    }
39d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng
40d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng    @Override
41d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng    protected boolean isDarkTheme() {
42d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng        return false;
43d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng    }
44d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng
45d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng    @Override
46d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng    protected int getApproximateImageSize() {
47d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng        // The picture is the full size of the tile (minus some padding, but we can be generous)
48d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng        return mListener.getApproximateTileWidth();
49d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng    }
502fd9bf9b5cef661118131464c8692f63b7e97510Brian Attwell
512fd9bf9b5cef661118131464c8692f63b7e97510Brian Attwell    @Override
522fd9bf9b5cef661118131464c8692f63b7e97510Brian Attwell    protected DefaultImageRequest getDefaultImageRequest(String displayName, String lookupKey) {
532fd9bf9b5cef661118131464c8692f63b7e97510Brian Attwell        return new DefaultImageRequest(displayName, lookupKey, ContactPhotoManager.TYPE_DEFAULT,
542fd9bf9b5cef661118131464c8692f63b7e97510Brian Attwell                DEFAULT_IMAGE_LETTER_SCALE, /* offset = */ 0, /* isCircular = */ true);
552fd9bf9b5cef661118131464c8692f63b7e97510Brian Attwell    }
56d0c8da65af3b67ba551a220ca40be31f644dfed6Chiao Cheng}
57