Add enable reverse number lookup link to call card.

Bug: 10525344
Change-Id: I6f01110e76222a2558374426675e285cfca5801b
diff --git a/res/layout/call_log_list_item.xml b/res/layout/call_log_list_item.xml
index 46e503c..c49b4b0 100644
--- a/res/layout/call_log_list_item.xml
+++ b/res/layout/call_log_list_item.xml
@@ -17,9 +17,9 @@
 <view
     xmlns:android="http://schemas.android.com/apk/res/android"
     class="com.android.dialer.calllog.CallLogListItemView"
-    android:id="@+id/call_log_list_item"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
+    android:id="@+id/call_log_list_item"
     android:orientation="vertical"
     android:background="@drawable/bottom_border_background"
 >
@@ -140,12 +140,4 @@
         android:paddingTop="@dimen/call_log_inner_margin"
         android:paddingBottom="@dimen/call_log_inner_margin" />
 
-    <View
-        android:id="@+id/call_log_divider"
-        android:layout_width="match_parent"
-        android:layout_height="1px"
-        android:layout_marginStart="@dimen/call_log_outer_margin"
-        android:layout_marginEnd="@dimen/call_log_outer_margin"
-        android:background="#55ffffff"
-    />
 </view>
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index 89e8be5..c0054ba 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -90,7 +90,7 @@
     /** 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,8 +448,17 @@
 
     @Override
     protected View newStandAloneView(Context context, ViewGroup parent) {
-        LayoutInflater inflater =
-                (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+        return newChildView(context, parent);
+    }
+
+    @Override
+    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);
         View view = inflater.inflate(R.layout.call_log_list_item, parent, false);
         findAndCacheViews(view);
         return view;
@@ -461,29 +470,11 @@
     }
 
     @Override
-    protected View newChildView(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;
-    }
-
-    @Override
     protected void bindChildView(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;
-    }
-
-    @Override
     protected void bindGroupView(View view, Context context, Cursor cursor, int groupSize,
             boolean expanded) {
         bindView(view, cursor, groupSize);
@@ -509,7 +500,6 @@
 
         // 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 @@
         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 @@
             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 9808d07..d0d34d8 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.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.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 @@
         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 0dd4f63..ed6218f 100644
--- a/src/com/android/dialer/calllog/CallLogListItemViews.java
+++ b/src/com/android/dialer/calllog/CallLogListItemViews.java
@@ -40,18 +40,15 @@
     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 @@
                 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 @@
                 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 5d7aa1b..64484cb 100644
--- a/src/com/android/dialer/calllog/ContactInfoHelper.java
+++ b/src/com/android/dialer/calllog/ContactInfoHelper.java
@@ -22,18 +22,15 @@
 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 @@
     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 4ffb030..0aae8aa 100644
--- a/src/com/android/dialer/list/PhoneFavoriteFragment.java
+++ b/src/com/android/dialer/list/PhoneFavoriteFragment.java
@@ -19,7 +19,6 @@
 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.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.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.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 @@
         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 ccbd3d0..2a80b3e 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 @@
     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 0000000..6286c05
--- /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 e53d2e8..0000000
--- 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;
-    }
-}