Merge "Show bottom action bar throughout dialer" into klp-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 37b78c0..6f37841 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -67,7 +67,7 @@
             android:launchMode="singleTask"
             android:clearTaskOnLaunch="true"
             android:icon="@mipmap/ic_launcher_phone"
-            android:screenOrientation="nosensor"
+            android:screenOrientation="portrait"
             android:enabled="@*android:bool/config_voice_capable"
             android:windowSoftInputMode="stateAlwaysHidden|adjustNothing">
             <intent-filter>
diff --git a/res/layout/phone_disambig_item.xml b/res/layout/phone_disambig_item.xml
index 02d596b..a097ce7 100755
--- a/res/layout/phone_disambig_item.xml
+++ b/res/layout/phone_disambig_item.xml
@@ -30,11 +30,13 @@
         android:textStyle="bold"
         android:textAppearance="?android:attr/textAppearanceMedium" />
 
+    <!-- Phone number should be displayed ltr -->
     <TextView
         android:id="@android:id/text2"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginTop="-4dip"
-        android:textAppearance="?android:attr/textAppearanceSmall" />
+        android:textAppearance="?android:attr/textAppearanceSmall"
+        android:textDirection="ltr" />
 
 </LinearLayout>
diff --git a/res/values-ka-rGE/strings.xml b/res/values-ka-rGE/strings.xml
index 4d6f74e..e6ba2aa 100644
--- a/res/values-ka-rGE/strings.xml
+++ b/res/values-ka-rGE/strings.xml
@@ -118,7 +118,7 @@
     <string name="menu_callNumber" msgid="997146291983360266">"დარეკვა <xliff:g id="NUMBER">%s</xliff:g>-ზე"</string>
     <string name="unknown" msgid="740067747858270469">"უცნობი"</string>
     <string name="voicemail" msgid="3851469869202611441">"ხმოვანი ფოსტა"</string>
-    <string name="private_num" msgid="6374339738119166953">"კერძო ნომერი"</string>
+    <string name="private_num" msgid="6374339738119166953">"დაფარული ნომერი"</string>
     <string name="payphone" msgid="4864313342828942922">"საზოგადოებრივი ტელეფონი"</string>
     <string name="dialerKeyboardHintText" msgid="5401660096579787344">"კლავიატურის გამოყენება დასარეკად"</string>
     <string name="dialerDialpadHintText" msgid="5824490365898349041">"დარეკეთ ზარის დასამატებლად"</string>
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index da29bbd..9ac7bea 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -598,10 +598,9 @@
                     formattedNumber, countryIso, geocode, callTypes, date,
                     duration);
         } else {
-            // We do not pass a photo id since we do not need the high-res picture.
             details = new PhoneCallDetails(number, numberPresentation,
                     formattedNumber, countryIso, geocode, callTypes, date,
-                    duration, name, ntype, label, lookupUri, null);
+                    duration, name, ntype, label, lookupUri, photoUri);
         }
 
         final boolean isNew = c.getInt(CallLogQuery.IS_READ) == 0;
diff --git a/src/com/android/dialer/calllog/ContactInfo.java b/src/com/android/dialer/calllog/ContactInfo.java
index 08633f8..ac858df 100644
--- a/src/com/android/dialer/calllog/ContactInfo.java
+++ b/src/com/android/dialer/calllog/ContactInfo.java
@@ -24,7 +24,7 @@
 /**
  * Information for a contact as needed by the Call Log.
  */
-public final class ContactInfo {
+public class ContactInfo {
     public Uri lookupUri;
     public String name;
     public int type;
diff --git a/src/com/android/dialer/list/RegularSearchFragment.java b/src/com/android/dialer/list/RegularSearchFragment.java
index 47dd075..ccbd3d0 100644
--- a/src/com/android/dialer/list/RegularSearchFragment.java
+++ b/src/com/android/dialer/list/RegularSearchFragment.java
@@ -15,10 +15,17 @@
  */
 package com.android.dialer.list;
 
+import com.android.contacts.common.list.ContactEntryListAdapter;
+import com.android.dialerbind.ServiceFactory;
+import com.android.dialer.service.CachedNumberLookupService;
+
 public class RegularSearchFragment extends SearchFragment {
 
     private static final int SEARCH_DIRECTORY_RESULT_LIMIT = 5;
 
+    private static final CachedNumberLookupService mCachedNumberLookupService =
+        ServiceFactory.newCachedNumberLookupService();
+
     public RegularSearchFragment() {
         configureDirectorySearch();
     }
@@ -27,4 +34,22 @@
         setDirectorySearchEnabled(true);
         setDirectoryResultLimit(SEARCH_DIRECTORY_RESULT_LIMIT);
     }
+
+    @Override
+    protected ContactEntryListAdapter createListAdapter() {
+        RegularSearchListAdapter adapter = new RegularSearchListAdapter(getActivity());
+        adapter.setDisplayPhotos(true);
+        adapter.setUseCallableUri(usesCallableUri());
+        return adapter;
+    }
+
+    @Override
+    protected void cacheContactInfo(int position) {
+        if (mCachedNumberLookupService != null) {
+            final RegularSearchListAdapter adapter =
+                (RegularSearchListAdapter) getAdapter();
+            mCachedNumberLookupService.addContact(getContext(),
+                    adapter.getContactInfo(position));
+        }
+    }
 }
diff --git a/src/com/android/dialer/list/RegularSearchListAdapter.java b/src/com/android/dialer/list/RegularSearchListAdapter.java
new file mode 100644
index 0000000..390dbb5
--- /dev/null
+++ b/src/com/android/dialer/list/RegularSearchListAdapter.java
@@ -0,0 +1,62 @@
+/*
+ * 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.dialer.list;
+
+import android.content.Context;
+import android.database.Cursor;
+import android.net.Uri;
+import android.provider.ContactsContract;
+
+import com.android.contacts.common.list.DirectoryPartition;
+import com.android.contacts.common.list.PhoneNumberListAdapter;
+import com.android.dialer.service.CachedNumberLookupService.CachedContactInfo;
+
+/**
+ * List adapter to display regular search results.
+ */
+public class RegularSearchListAdapter extends PhoneNumberListAdapter {
+
+    public RegularSearchListAdapter(Context context) {
+        super(context);
+    }
+
+    public CachedContactInfo getContactInfo(int position) {
+        CachedContactInfo info = new CachedContactInfo();
+        final Cursor item = (Cursor) getItem(position);
+        if (item != null) {
+            info.name = item.getString(PhoneQuery.DISPLAY_NAME);
+            info.type = item.getInt(PhoneQuery.PHONE_TYPE);
+            info.label = item.getString(PhoneQuery.PHONE_LABEL);
+            info.number = item.getString(PhoneQuery.PHONE_NUMBER);
+            final String photoUriStr = item.getString(PhoneQuery.PHOTO_URI);
+            info.photoUri = photoUriStr == null ? null : Uri.parse(photoUriStr);
+            info.lookupKey = item.getString(PhoneQuery.LOOKUP_KEY);
+
+            final int partitionIndex = getPartitionForPosition(position);
+            final DirectoryPartition partition =
+                (DirectoryPartition) getPartition(partitionIndex);
+            final long directoryId = partition.getDirectoryId();
+            if (isExtendedDirectory(directoryId)) {
+               info.sourceType = CachedContactInfo.SOURCE_TYPE_EXTENDED;
+                // TODO source_id for extended directory?
+            } else {
+                info.sourceType = CachedContactInfo.SOURCE_TYPE_DIRECTORY;
+                info.sourceId = (int) directoryId;
+            }
+        }
+        return info;
+    }
+}
diff --git a/src/com/android/dialer/service/CachedNumberLookupService.java b/src/com/android/dialer/service/CachedNumberLookupService.java
index a08c285..27bf589 100644
--- a/src/com/android/dialer/service/CachedNumberLookupService.java
+++ b/src/com/android/dialer/service/CachedNumberLookupService.java
@@ -1,10 +1,23 @@
 package com.android.dialer.service;
 
+import android.content.ContentValues;
 import android.content.Context;
 
 import com.android.dialer.calllog.ContactInfo;
 
 public interface CachedNumberLookupService {
+
+    public class CachedContactInfo extends ContactInfo {
+        public static final int SOURCE_TYPE_DIRECTORY = 1;
+        public static final int SOURCE_TYPE_EXTENDED = 2;
+        public static final int SOURCE_TYPE_PLACES = 3;
+        public static final int SOURCE_TYPE_PROFILE = 4;
+
+        public int    sourceType;
+        public int    sourceId;
+        public String lookupKey;
+    }
+
     /**
      * Perform a lookup using the cached number lookup service to return contact
      * information stored in the cache that corresponds to the given number.
@@ -16,4 +29,6 @@
      * not found in the cache, and null if there was an error when querying the cache.
      */
     public ContactInfo lookupCachedContactFromNumber(Context context, String number);
+
+    public void addContact(Context context, CachedContactInfo info);
 }