AllContactsFragment.java revision 0a4327e6bfeedc23ddefb4df9f6e8041ebc87b59
18dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee/*
28dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee * Copyright (C) 2013 The Android Open Source Project
38dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee *
48dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee * Licensed under the Apache License, Version 2.0 (the "License");
58dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee * you may not use this file except in compliance with the License.
68dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee * You may obtain a copy of the License at
78dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee *
88dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee *      http://www.apache.org/licenses/LICENSE-2.0
98dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee *
108dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee * Unless required by applicable law or agreed to in writing, software
118dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee * distributed under the License is distributed on an "AS IS" BASIS,
128dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
138dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee * See the License for the specific language governing permissions and
148dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee * limitations under the License.
158dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee */
168dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee
178dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Leepackage com.android.dialer.list;
188dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee
196144d027255568a76adf8c36b96af8e283460622Yorke Leeimport android.database.Cursor;
206144d027255568a76adf8c36b96af8e283460622Yorke Leeimport android.net.Uri;
216144d027255568a76adf8c36b96af8e283460622Yorke Leeimport android.provider.ContactsContract.QuickContact;
228dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Leeimport android.view.LayoutInflater;
238dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Leeimport android.view.View;
248dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Leeimport android.view.ViewGroup;
25931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Leeimport android.widget.AdapterView;
268dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee
27931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Leeimport com.android.contacts.common.list.ContactEntryListAdapter;
28931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Leeimport com.android.contacts.common.list.ContactEntryListFragment;
29931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Leeimport com.android.contacts.common.list.ContactListFilter;
30931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Leeimport com.android.contacts.common.list.DefaultContactListAdapter;
31781ee24f91f6eb6a1687d803971196f2bf71c02bYorke Leeimport com.android.contacts.common.util.ViewUtil;
328dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Leeimport com.android.dialer.R;
330a4327e6bfeedc23ddefb4df9f6e8041ebc87b59Andrew Leeimport com.android.dialer.util.DialerUtils;
348dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee
358dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee/**
368dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee * Fragments to show all contacts with phone numbers.
378dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee */
38931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Leepublic class AllContactsFragment extends ContactEntryListFragment<ContactEntryListAdapter> {
398dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee
40931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee    public AllContactsFragment() {
416144d027255568a76adf8c36b96af8e283460622Yorke Lee        setQuickContactEnabled(false);
42331f457e9ac7b41fc8c43000ed989a3c09d68f62Andrew Lee        setAdjustSelectionBoundsEnabled(true);
43931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee        setPhotoLoaderEnabled(true);
44931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee        setSectionHeaderDisplayEnabled(true);
458dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee        setDarkTheme(false);
4653845dc94a78d3efe4f8ea76a5e9a60dbc79aa16Yorke Lee        setVisibleScrollbarEnabled(true);
47931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee    }
48931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee
49931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee    @Override
50781ee24f91f6eb6a1687d803971196f2bf71c02bYorke Lee    public void onViewCreated(View view, android.os.Bundle savedInstanceState) {
51781ee24f91f6eb6a1687d803971196f2bf71c02bYorke Lee        super.onViewCreated(view, savedInstanceState);
520a4327e6bfeedc23ddefb4df9f6e8041ebc87b59Andrew Lee
530a4327e6bfeedc23ddefb4df9f6e8041ebc87b59Andrew Lee        View emptyListView = view.findViewById(R.id.empty_list_view);
540a4327e6bfeedc23ddefb4df9f6e8041ebc87b59Andrew Lee        DialerUtils.configureEmptyListView(emptyListView, R.drawable.empty_contacts,
550a4327e6bfeedc23ddefb4df9f6e8041ebc87b59Andrew Lee                R.string.listFoundAllContactsZero, getResources());
560a4327e6bfeedc23ddefb4df9f6e8041ebc87b59Andrew Lee        getListView().setEmptyView(emptyListView);
570a4327e6bfeedc23ddefb4df9f6e8041ebc87b59Andrew Lee
58781ee24f91f6eb6a1687d803971196f2bf71c02bYorke Lee        ViewUtil.addBottomPaddingToListViewForFab(getListView(), getResources());
59781ee24f91f6eb6a1687d803971196f2bf71c02bYorke Lee    }
60781ee24f91f6eb6a1687d803971196f2bf71c02bYorke Lee
61781ee24f91f6eb6a1687d803971196f2bf71c02bYorke Lee    @Override
62931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee    protected ContactEntryListAdapter createListAdapter() {
636144d027255568a76adf8c36b96af8e283460622Yorke Lee        final DefaultContactListAdapter adapter = new DefaultContactListAdapter(getActivity()) {
646144d027255568a76adf8c36b96af8e283460622Yorke Lee            @Override
656144d027255568a76adf8c36b96af8e283460622Yorke Lee            protected void bindView(View itemView, int partition, Cursor cursor, int position) {
666144d027255568a76adf8c36b96af8e283460622Yorke Lee                super.bindView(itemView, partition, cursor, position);
676144d027255568a76adf8c36b96af8e283460622Yorke Lee                itemView.setTag(this.getContactUri(partition, cursor));
686144d027255568a76adf8c36b96af8e283460622Yorke Lee            }
696144d027255568a76adf8c36b96af8e283460622Yorke Lee        };
70931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee        adapter.setDisplayPhotos(true);
71931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee        adapter.setFilter(ContactListFilter.createFilterWithType(
72931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee                ContactListFilter.FILTER_TYPE_WITH_PHONE_NUMBERS_ONLY));
73931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee        adapter.setSectionHeaderDisplayEnabled(isSectionHeaderDisplayEnabled());
74931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee        return adapter;
758dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee    }
768dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee
778dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee    @Override
788dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee    protected View inflateView(LayoutInflater inflater, ViewGroup container) {
798dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee        return inflater.inflate(R.layout.show_all_contacts_fragment, null);
808dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee    }
81931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee
82931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee    @Override
83931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
846144d027255568a76adf8c36b96af8e283460622Yorke Lee        final Uri uri = (Uri) view.getTag();
856144d027255568a76adf8c36b96af8e283460622Yorke Lee        if (uri != null) {
866144d027255568a76adf8c36b96af8e283460622Yorke Lee            QuickContact.showQuickContact(getActivity(), view, uri, QuickContact.MODE_LARGE, null);
876144d027255568a76adf8c36b96af8e283460622Yorke Lee        }
88931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee    }
89931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee
90931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee    @Override
91931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee    protected void onItemClick(int position, long id) {
92931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee        // Do nothing. Implemented to satisfy ContactEntryListFragment.
93931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee    }
948dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee}
95