blob: bd1dd6f9e0134ea1169416ab466367894d1d3f9b [file] [log] [blame]
Anne Ronge78b54c2015-09-28 11:18:42 -07001/*
2 * Copyright (C) 2015 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.util.Log;
19
20import com.android.contacts.common.list.ContactEntryListAdapter;
21import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
22
23public class BlockedListSearchFragment extends RegularSearchFragment {
24 private static final String TAG = BlockedListSearchFragment.class.getSimpleName();
25
26 @Override
27 protected ContactEntryListAdapter createListAdapter() {
28 BlockedListSearchAdapter adapter = new BlockedListSearchAdapter(getActivity());
29 adapter.setDisplayPhotos(true);
30 adapter.setUseCallableUri(usesCallableUri());
31 return adapter;
32 }
33
34 @Override
35 protected void onItemClick(int position, long id) {
36 final DialerPhoneNumberListAdapter adapter = (DialerPhoneNumberListAdapter) getAdapter();
37 final int shortcutType = adapter.getShortcutTypeFromPosition(position);
38 final OnPhoneNumberPickerActionListener listener = getOnPhoneNumberPickerListener();
39 final String number;
40
41 if (listener == null) {
42 Log.d(TAG, "getOnPhoneNumberPickerListener() returned null in onItemClick.");
43 return;
44 }
45
46 switch (shortcutType) {
47 case DialerPhoneNumberListAdapter.SHORTCUT_INVALID:
48 // Handles click on a search result, either contact or nearby places result.
49 number = adapter.getPhoneNumber(position);
50 listener.onCallNumberDirectly(number, false, getCallInitiationType(false));
51 break;
52 case DialerPhoneNumberListAdapter.SHORTCUT_BLOCK_NUMBER:
53 // Handles click on 'Block number' shortcut to add the user query as a number.
54 number = adapter.getQueryString();
55 listener.onCallNumberDirectly(number, false, getCallInitiationType(false));
56 break;
57 default:
58 Log.w(TAG, "Ignoring unsupported shortcut type: " + shortcutType);
59 break;
60 }
61 }
62}