AllContactsFragment.java revision 74eb4ecc5df272f681b427760d46deafce8ed0b2
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; 2174eb4ecc5df272f681b427760d46deafce8ed0b2Brian Attwellimport android.provider.ContactsContract.CommonDataKinds.Phone; 226144d027255568a76adf8c36b96af8e283460622Yorke Leeimport android.provider.ContactsContract.QuickContact; 238dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Leeimport android.view.LayoutInflater; 248dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Leeimport android.view.View; 258dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Leeimport android.view.ViewGroup; 26931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Leeimport android.widget.AdapterView; 278dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee 28931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Leeimport com.android.contacts.common.list.ContactEntryListAdapter; 29931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Leeimport com.android.contacts.common.list.ContactEntryListFragment; 30931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Leeimport com.android.contacts.common.list.ContactListFilter; 31931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Leeimport com.android.contacts.common.list.DefaultContactListAdapter; 32781ee24f91f6eb6a1687d803971196f2bf71c02bYorke Leeimport com.android.contacts.common.util.ViewUtil; 338dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Leeimport com.android.dialer.R; 340a4327e6bfeedc23ddefb4df9f6e8041ebc87b59Andrew Leeimport com.android.dialer.util.DialerUtils; 358dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee 368dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee/** 378dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee * Fragments to show all contacts with phone numbers. 388dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee */ 39931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Leepublic class AllContactsFragment extends ContactEntryListFragment<ContactEntryListAdapter> { 408dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee 41931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee public AllContactsFragment() { 426144d027255568a76adf8c36b96af8e283460622Yorke Lee setQuickContactEnabled(false); 43331f457e9ac7b41fc8c43000ed989a3c09d68f62Andrew Lee setAdjustSelectionBoundsEnabled(true); 44931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee setPhotoLoaderEnabled(true); 45931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee setSectionHeaderDisplayEnabled(true); 468dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee setDarkTheme(false); 4753845dc94a78d3efe4f8ea76a5e9a60dbc79aa16Yorke Lee setVisibleScrollbarEnabled(true); 48931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee } 49931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee 50931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee @Override 51781ee24f91f6eb6a1687d803971196f2bf71c02bYorke Lee public void onViewCreated(View view, android.os.Bundle savedInstanceState) { 52781ee24f91f6eb6a1687d803971196f2bf71c02bYorke Lee super.onViewCreated(view, savedInstanceState); 530a4327e6bfeedc23ddefb4df9f6e8041ebc87b59Andrew Lee 540a4327e6bfeedc23ddefb4df9f6e8041ebc87b59Andrew Lee View emptyListView = view.findViewById(R.id.empty_list_view); 550a4327e6bfeedc23ddefb4df9f6e8041ebc87b59Andrew Lee DialerUtils.configureEmptyListView(emptyListView, R.drawable.empty_contacts, 5639f773e8a64ec1b770b2679871b7c44cac7243d2Andrew Lee R.string.all_contacts_empty, getResources()); 570a4327e6bfeedc23ddefb4df9f6e8041ebc87b59Andrew Lee getListView().setEmptyView(emptyListView); 580a4327e6bfeedc23ddefb4df9f6e8041ebc87b59Andrew Lee 59781ee24f91f6eb6a1687d803971196f2bf71c02bYorke Lee ViewUtil.addBottomPaddingToListViewForFab(getListView(), getResources()); 60781ee24f91f6eb6a1687d803971196f2bf71c02bYorke Lee } 61781ee24f91f6eb6a1687d803971196f2bf71c02bYorke Lee 62781ee24f91f6eb6a1687d803971196f2bf71c02bYorke Lee @Override 63931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee protected ContactEntryListAdapter createListAdapter() { 646144d027255568a76adf8c36b96af8e283460622Yorke Lee final DefaultContactListAdapter adapter = new DefaultContactListAdapter(getActivity()) { 656144d027255568a76adf8c36b96af8e283460622Yorke Lee @Override 666144d027255568a76adf8c36b96af8e283460622Yorke Lee protected void bindView(View itemView, int partition, Cursor cursor, int position) { 676144d027255568a76adf8c36b96af8e283460622Yorke Lee super.bindView(itemView, partition, cursor, position); 686144d027255568a76adf8c36b96af8e283460622Yorke Lee itemView.setTag(this.getContactUri(partition, cursor)); 696144d027255568a76adf8c36b96af8e283460622Yorke Lee } 706144d027255568a76adf8c36b96af8e283460622Yorke Lee }; 71931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee adapter.setDisplayPhotos(true); 72931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee adapter.setFilter(ContactListFilter.createFilterWithType( 733c5b0289eaf92e0b7345321993de12e89d01b8dbYorke Lee ContactListFilter.FILTER_TYPE_DEFAULT)); 74931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee adapter.setSectionHeaderDisplayEnabled(isSectionHeaderDisplayEnabled()); 75931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee return adapter; 768dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee } 778dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee 788dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee @Override 798dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee protected View inflateView(LayoutInflater inflater, ViewGroup container) { 808dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee return inflater.inflate(R.layout.show_all_contacts_fragment, null); 818dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee } 82931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee 83931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee @Override 84931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 856144d027255568a76adf8c36b96af8e283460622Yorke Lee final Uri uri = (Uri) view.getTag(); 866144d027255568a76adf8c36b96af8e283460622Yorke Lee if (uri != null) { 8774eb4ecc5df272f681b427760d46deafce8ed0b2Brian Attwell QuickContact.showQuickContact(getContext(), view, uri, null, 8874eb4ecc5df272f681b427760d46deafce8ed0b2Brian Attwell Phone.CONTENT_ITEM_TYPE); 896144d027255568a76adf8c36b96af8e283460622Yorke Lee } 90931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee } 91931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee 92931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee @Override 93931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee protected void onItemClick(int position, long id) { 94931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee // Do nothing. Implemented to satisfy ContactEntryListFragment. 95931075eab957d7ecd7a9e880c0650012e29f05c2Andrew Lee } 968dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee} 97