From 704acc087ce359295475a46695c2821c55778344 Mon Sep 17 00:00:00 2001 From: Chiao Cheng Date: Mon, 9 Sep 2013 18:34:41 -0700 Subject: Add enable reverse number lookup link to call card. Bug: 10525344 Change-Id: I6f01110e76222a2558374426675e285cfca5801b --- src/com/android/dialer/calllog/CallLogAdapter.java | 33 ++++++++--------- .../android/dialer/calllog/CallLogFragment.java | 10 ++---- .../dialer/calllog/CallLogListItemViews.java | 11 ++---- .../android/dialer/calllog/ContactInfoHelper.java | 7 ++-- .../android/dialer/list/PhoneFavoriteFragment.java | 10 ++---- .../android/dialer/list/RegularSearchFragment.java | 4 +-- src/com/android/dialerbind/ObjectFactory.java | 42 ++++++++++++++++++++++ src/com/android/dialerbind/ServiceFactory.java | 30 ---------------- 8 files changed, 70 insertions(+), 77 deletions(-) create mode 100644 src/com/android/dialerbind/ObjectFactory.java delete mode 100644 src/com/android/dialerbind/ServiceFactory.java (limited to 'src') diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 89e8be519..c0054ba79 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -90,7 +90,7 @@ public class CallLogAdapter extends GroupingListAdapter /** The size of the cache of contact info. */ private static final int CONTACT_INFO_CACHE_SIZE = 100; - private final Context mContext; + protected final Context mContext; private final ContactInfoHelper mContactInfoHelper; private final CallFetcher mCallFetcher; private ViewTreeObserver mViewTreeObserver = null; @@ -448,39 +448,30 @@ public class CallLogAdapter extends GroupingListAdapter @Override protected View newStandAloneView(Context context, ViewGroup parent) { - LayoutInflater inflater = - (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View view = inflater.inflate(R.layout.call_log_list_item, parent, false); - findAndCacheViews(view); - return view; + return newChildView(context, parent); } @Override - protected void bindStandAloneView(View view, Context context, Cursor cursor) { - bindView(view, cursor, 1); + protected View newGroupView(Context context, ViewGroup parent) { + return newChildView(context, parent); } @Override protected View newChildView(Context context, ViewGroup parent) { - LayoutInflater inflater = - (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.call_log_list_item, parent, false); findAndCacheViews(view); return view; } @Override - protected void bindChildView(View view, Context context, Cursor cursor) { + protected void bindStandAloneView(View view, Context context, Cursor cursor) { bindView(view, cursor, 1); } @Override - protected View newGroupView(Context context, ViewGroup parent) { - LayoutInflater inflater = - (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View view = inflater.inflate(R.layout.call_log_list_item, parent, false); - findAndCacheViews(view); - return view; + protected void bindChildView(View view, Context context, Cursor cursor) { + bindView(view, cursor, 1); } @Override @@ -509,7 +500,6 @@ public class CallLogAdapter extends GroupingListAdapter // Default case: an item in the call log. views.primaryActionView.setVisibility(View.VISIBLE); - views.bottomDivider.setVisibility(View.VISIBLE); views.listHeaderTextView.setVisibility(View.GONE); final String number = c.getString(CallLogQuery.NUMBER); @@ -593,6 +583,7 @@ public class CallLogAdapter extends GroupingListAdapter final int[] callTypes = getCallTypes(c, count); final String geocode = c.getString(CallLogQuery.GEOCODED_LOCATION); final PhoneCallDetails details; + if (TextUtils.isEmpty(name)) { details = new PhoneCallDetails(number, numberPresentation, formattedNumber, countryIso, geocode, callTypes, date, @@ -623,6 +614,12 @@ public class CallLogAdapter extends GroupingListAdapter mViewTreeObserver = view.getViewTreeObserver(); mViewTreeObserver.addOnPreDrawListener(this); } + + postBindView(views, info); + } + + protected void postBindView(CallLogListItemViews views, ContactInfo info) { + // no-op } /** Checks whether the contact info from the call log matches the one from the contacts db. */ diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index 9808d073b..d0d34d897 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -30,13 +30,9 @@ import android.provider.CallLog; import android.provider.CallLog.Calls; import android.provider.ContactsContract; import android.telephony.PhoneNumberUtils; -import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.util.Log; import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; @@ -50,8 +46,8 @@ import com.android.dialer.util.EmptyLoader; import com.android.dialer.voicemail.VoicemailStatusHelper; import com.android.dialer.voicemail.VoicemailStatusHelper.StatusMessage; import com.android.dialer.voicemail.VoicemailStatusHelperImpl; +import com.android.dialerbind.ObjectFactory; import com.android.internal.telephony.ITelephony; -import com.google.common.annotations.VisibleForTesting; import java.util.List; @@ -234,8 +230,8 @@ public class CallLogFragment extends ListFragment super.onViewCreated(view, savedInstanceState); updateEmptyMessage(mCallTypeFilter); String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity()); - mAdapter = new CallLogAdapter(getActivity(), this, - new ContactInfoHelper(getActivity(), currentCountryIso), false); + mAdapter = ObjectFactory.newCallLogAdapter(getActivity(), this, new ContactInfoHelper( + getActivity(), currentCountryIso), false, true); setListAdapter(mAdapter); getListView().setItemsCanFocus(true); } diff --git a/src/com/android/dialer/calllog/CallLogListItemViews.java b/src/com/android/dialer/calllog/CallLogListItemViews.java index 0dd4f6344..ed6218f86 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViews.java +++ b/src/com/android/dialer/calllog/CallLogListItemViews.java @@ -40,18 +40,15 @@ public final class CallLogListItemViews { public final PhoneCallDetailsViews phoneCallDetailsViews; /** The text of the header of a section. */ public final TextView listHeaderTextView; - /** The divider to be shown below items. */ - public final View bottomDivider; private CallLogListItemViews(QuickContactBadge quickContactView, View primaryActionView, ImageView secondaryActionView, PhoneCallDetailsViews phoneCallDetailsViews, - TextView listHeaderTextView, View bottomDivider) { + TextView listHeaderTextView) { this.quickContactView = quickContactView; this.primaryActionView = primaryActionView; this.secondaryActionView = secondaryActionView; this.phoneCallDetailsViews = phoneCallDetailsViews; this.listHeaderTextView = listHeaderTextView; - this.bottomDivider = bottomDivider; } public static CallLogListItemViews fromView(View view) { @@ -60,8 +57,7 @@ public final class CallLogListItemViews { view.findViewById(R.id.primary_action_view), (ImageView) view.findViewById(R.id.secondary_action_icon), PhoneCallDetailsViews.fromView(view), - (TextView) view.findViewById(R.id.call_log_header), - view.findViewById(R.id.call_log_divider)); + (TextView) view.findViewById(R.id.call_log_header)); } @NeededForTesting @@ -71,7 +67,6 @@ public final class CallLogListItemViews { new View(context), new ImageView(context), PhoneCallDetailsViews.createForTest(context), - new TextView(context), - new View(context)); + new TextView(context)); } } diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java index 5d7aa1bef..64484cbed 100644 --- a/src/com/android/dialer/calllog/ContactInfoHelper.java +++ b/src/com/android/dialer/calllog/ContactInfoHelper.java @@ -22,18 +22,15 @@ import android.net.Uri; import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.Contacts; -import android.provider.ContactsContract.Directory; import android.provider.ContactsContract.DisplayNameSources; import android.provider.ContactsContract.PhoneLookup; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; -import android.util.Log; import com.android.contacts.common.util.Constants; import com.android.contacts.common.util.UriUtils; import com.android.dialer.service.CachedNumberLookupService; -import com.android.dialer.service.CachedNumberLookupService.CachedContactInfo; -import com.android.dialerbind.ServiceFactory; +import com.android.dialerbind.ObjectFactory; import org.json.JSONException; import org.json.JSONObject; @@ -46,7 +43,7 @@ public class ContactInfoHelper { private final String mCurrentCountryIso; private static final CachedNumberLookupService mCachedNumberLookupService = - ServiceFactory.newCachedNumberLookupService(); + ObjectFactory.newCachedNumberLookupService(); public ContactInfoHelper(Context context, String currentCountryIso) { mContext = context; diff --git a/src/com/android/dialer/list/PhoneFavoriteFragment.java b/src/com/android/dialer/list/PhoneFavoriteFragment.java index 4ffb0303b..0aae8aada 100644 --- a/src/com/android/dialer/list/PhoneFavoriteFragment.java +++ b/src/com/android/dialer/list/PhoneFavoriteFragment.java @@ -19,7 +19,6 @@ import android.app.Activity; import android.app.Fragment; import android.app.LoaderManager; import android.content.CursorLoader; -import android.content.Intent; import android.content.Loader; import android.database.Cursor; import android.graphics.Rect; @@ -27,7 +26,6 @@ import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; -import android.view.MotionEvent; import android.view.View; import android.view.ViewTreeObserver; import android.view.View.OnClickListener; @@ -35,7 +33,6 @@ import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; -import android.widget.FrameLayout; import android.widget.ListView; import android.widget.TextView; @@ -44,13 +41,12 @@ import com.android.contacts.common.ContactTileLoaderFactory; import com.android.contacts.common.GeoUtil; import com.android.contacts.common.list.ContactEntry; import com.android.contacts.common.list.ContactTileView; -import com.android.contacts.common.list.PhoneNumberListAdapter; -import com.android.dialer.DialtactsActivity; import com.android.dialer.R; import com.android.dialer.calllog.ContactInfoHelper; import com.android.dialer.calllog.CallLogAdapter; import com.android.dialer.calllog.CallLogQueryHandler; import com.android.dialer.list.PhoneFavoritesTileAdapter.ContactTileRow; +import com.android.dialerbind.ObjectFactory; import java.util.ArrayList; import java.util.HashMap; @@ -191,8 +187,8 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen mCallLogQueryHandler = new CallLogQueryHandler(getActivity().getContentResolver(), this, 1); final String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity()); - mCallLogAdapter = new CallLogAdapter(getActivity(), this, - new ContactInfoHelper(getActivity(), currentCountryIso), true); + mCallLogAdapter = ObjectFactory.newCallLogAdapter(getActivity(), this, + new ContactInfoHelper(getActivity(), currentCountryIso), true, false); setHasOptionsMenu(true); } diff --git a/src/com/android/dialer/list/RegularSearchFragment.java b/src/com/android/dialer/list/RegularSearchFragment.java index ccbd3d0dc..2a80b3ebd 100644 --- a/src/com/android/dialer/list/RegularSearchFragment.java +++ b/src/com/android/dialer/list/RegularSearchFragment.java @@ -16,7 +16,7 @@ package com.android.dialer.list; import com.android.contacts.common.list.ContactEntryListAdapter; -import com.android.dialerbind.ServiceFactory; +import com.android.dialerbind.ObjectFactory; import com.android.dialer.service.CachedNumberLookupService; public class RegularSearchFragment extends SearchFragment { @@ -24,7 +24,7 @@ public class RegularSearchFragment extends SearchFragment { private static final int SEARCH_DIRECTORY_RESULT_LIMIT = 5; private static final CachedNumberLookupService mCachedNumberLookupService = - ServiceFactory.newCachedNumberLookupService(); + ObjectFactory.newCachedNumberLookupService(); public RegularSearchFragment() { configureDirectorySearch(); diff --git a/src/com/android/dialerbind/ObjectFactory.java b/src/com/android/dialerbind/ObjectFactory.java new file mode 100644 index 000000000..6286c05ba --- /dev/null +++ b/src/com/android/dialerbind/ObjectFactory.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.dialerbind; + +import static com.android.dialer.calllog.CallLogAdapter.CallFetcher; + +import android.content.Context; + +import com.android.dialer.calllog.CallLogAdapter; +import com.android.dialer.calllog.ContactInfoHelper; +import com.android.dialer.service.CachedNumberLookupService; + +/** + * Default static binding for various objects. + */ +public class ObjectFactory { + + public static CachedNumberLookupService newCachedNumberLookupService() { + // no-op + return null; + } + + public static CallLogAdapter newCallLogAdapter(Context context, CallFetcher callFetcher, + ContactInfoHelper contactInfoHelper, boolean useCallAsPrimaryAction, + boolean isCallLog) { + return new CallLogAdapter(context, callFetcher, contactInfoHelper, useCallAsPrimaryAction); + } +} diff --git a/src/com/android/dialerbind/ServiceFactory.java b/src/com/android/dialerbind/ServiceFactory.java deleted file mode 100644 index e53d2e82a..000000000 --- a/src/com/android/dialerbind/ServiceFactory.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.dialerbind; - -import com.android.dialer.service.CachedNumberLookupService; - -/** - * Default static binder for services. - */ -public class ServiceFactory { - - public static CachedNumberLookupService newCachedNumberLookupService() { - // no-op - return null; - } -} -- cgit v1.2.3