Merge "Group blocked calls separately in call log." into ub-contactsdialer-a-dev
diff --git a/res/drawable-hdpi/ic_block_24dp.png b/res/drawable-hdpi/ic_block_24dp.png
new file mode 100644
index 0000000..2ccc89d
--- /dev/null
+++ b/res/drawable-hdpi/ic_block_24dp.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_content_copy_24dp.png b/res/drawable-hdpi/ic_content_copy_24dp.png
new file mode 100644
index 0000000..70eb073
--- /dev/null
+++ b/res/drawable-hdpi/ic_content_copy_24dp.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_report_24dp.png b/res/drawable-hdpi/ic_report_24dp.png
new file mode 100644
index 0000000..dc0c995
--- /dev/null
+++ b/res/drawable-hdpi/ic_report_24dp.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_block_24dp.png b/res/drawable-mdpi/ic_block_24dp.png
new file mode 100644
index 0000000..ec1b33f
--- /dev/null
+++ b/res/drawable-mdpi/ic_block_24dp.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_content_copy_24dp.png b/res/drawable-mdpi/ic_content_copy_24dp.png
new file mode 100644
index 0000000..80c0695
--- /dev/null
+++ b/res/drawable-mdpi/ic_content_copy_24dp.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_report_24dp.png b/res/drawable-mdpi/ic_report_24dp.png
new file mode 100644
index 0000000..70b82d6
--- /dev/null
+++ b/res/drawable-mdpi/ic_report_24dp.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_block_24dp.png b/res/drawable-xhdpi/ic_block_24dp.png
new file mode 100644
index 0000000..7aba97b
--- /dev/null
+++ b/res/drawable-xhdpi/ic_block_24dp.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_content_copy_24dp.png b/res/drawable-xhdpi/ic_content_copy_24dp.png
new file mode 100644
index 0000000..537fd4e
--- /dev/null
+++ b/res/drawable-xhdpi/ic_content_copy_24dp.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_report_24dp.png b/res/drawable-xhdpi/ic_report_24dp.png
new file mode 100644
index 0000000..18e7764
--- /dev/null
+++ b/res/drawable-xhdpi/ic_report_24dp.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_block_24dp.png b/res/drawable-xxhdpi/ic_block_24dp.png
new file mode 100644
index 0000000..fddfa54
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_block_24dp.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_content_copy_24dp.png b/res/drawable-xxhdpi/ic_content_copy_24dp.png
new file mode 100644
index 0000000..9dff893
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_content_copy_24dp.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_report_24dp.png b/res/drawable-xxhdpi/ic_report_24dp.png
new file mode 100644
index 0000000..aed7668
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_report_24dp.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_block_24dp.png b/res/drawable-xxxhdpi/ic_block_24dp.png
new file mode 100644
index 0000000..0378d1b
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_block_24dp.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_content_copy_24dp.png b/res/drawable-xxxhdpi/ic_content_copy_24dp.png
new file mode 100644
index 0000000..4ddee9e
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_content_copy_24dp.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_report_24dp.png b/res/drawable-xxxhdpi/ic_report_24dp.png
new file mode 100644
index 0000000..855e590
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_report_24dp.png
Binary files differ
diff --git a/res/layout/call_detail.xml b/res/layout/call_detail.xml
index fde1de5..7d91248 100644
--- a/res/layout/call_detail.xml
+++ b/res/layout/call_detail.xml
@@ -13,90 +13,12 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/call_detail"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:orientation="vertical"
-    android:layout_alignParentStart="true"
-    android:layout_alignParentTop="true"
     android:background="@color/background_dialer_call_log" >
 
-    <!-- Caller information "card" -->
-    <LinearLayout
-        android:id="@+id/caller_information"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingStart="@dimen/call_detail_horizontal_margin"
-        android:paddingTop="@dimen/call_detail_top_margin"
-        android:paddingBottom="@dimen/call_detail_bottom_margin"
-        android:baselineAligned="false"
-        android:orientation="horizontal"
-        android:translationZ="@dimen/call_detail_translation_z"
-        android:focusable="true"
-        android:background="@color/background_dialer_white" >
-
-        <QuickContactBadge
-            android:id="@+id/quick_contact_photo"
-            android:layout_width="@dimen/contact_photo_size"
-            android:layout_height="@dimen/contact_photo_size"
-            android:layout_alignParentStart="true"
-            android:layout_gravity="top"
-            android:layout_marginTop="3dp"
-            android:focusable="true" />
-
-        <LinearLayout
-            android:layout_width="0dp"
-            android:layout_height="wrap_content"
-            android:layout_weight="1"
-            android:orientation="vertical"
-            android:gravity="center_vertical"
-            android:layout_marginStart="@dimen/call_detail_horizontal_margin">
-
-            <TextView
-                android:id="@+id/caller_name"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textColor="?attr/call_log_primary_text_color"
-                android:textSize="@dimen/call_log_primary_text_size"
-                android:includeFontPadding="false"
-                android:layout_marginBottom="5dp"
-                android:singleLine="true" />
-
-            <TextView
-                android:id="@+id/caller_number"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textColor="?attr/call_log_secondary_text_color"
-                android:textSize="@dimen/call_log_secondary_text_size"
-                android:layout_marginBottom="1dp"
-                android:singleLine="true" />
-
-            <TextView
-                android:id="@+id/phone_account_label"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textColor="?attr/call_log_secondary_text_color"
-                android:textSize="@dimen/call_log_secondary_text_size"
-                android:singleLine="true"
-                android:visibility="gone" />
-
-        </LinearLayout>
-
-        <ImageView
-            android:id="@+id/call_back_button"
-            android:layout_width="@dimen/call_log_list_item_primary_action_dimen"
-            android:layout_height="@dimen/call_log_list_item_primary_action_dimen"
-            android:layout_marginEnd="16dp"
-            android:background="?android:attr/selectableItemBackgroundBorderless"
-            android:src="@drawable/ic_call_24dp"
-            android:scaleType="center"
-            android:tint="@color/call_log_list_item_primary_action_icon_tint"
-            android:contentDescription="@string/description_call_log_call_action"
-            android:visibility="gone" />
-
-    </LinearLayout>
-
     <!--
       The list view is under everything.
       It contains a first header element which is hidden under the controls UI.
@@ -107,4 +29,4 @@
         android:layout_width="match_parent"
         android:layout_height="fill_parent" />
 
-</LinearLayout>
+</FrameLayout>
diff --git a/res/layout/call_detail_header.xml b/res/layout/call_detail_header.xml
new file mode 100644
index 0000000..5931445
--- /dev/null
+++ b/res/layout/call_detail_header.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/caller_information"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:paddingStart="@dimen/call_detail_horizontal_margin"
+    android:paddingTop="@dimen/call_detail_top_margin"
+    android:paddingBottom="@dimen/call_detail_bottom_margin"
+    android:baselineAligned="false"
+    android:orientation="horizontal"
+    android:elevation="@dimen/call_detail_elevation"
+    android:focusable="true"
+    android:background="@color/background_dialer_white" >
+
+    <QuickContactBadge
+        android:id="@+id/quick_contact_photo"
+        android:layout_width="@dimen/contact_photo_size"
+        android:layout_height="@dimen/contact_photo_size"
+        android:layout_alignParentStart="true"
+        android:layout_gravity="top"
+        android:layout_marginTop="3dp"
+        android:focusable="true" />
+
+    <LinearLayout
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:orientation="vertical"
+        android:gravity="center_vertical"
+        android:layout_marginStart="@dimen/call_detail_horizontal_margin">
+
+        <TextView
+            android:id="@+id/caller_name"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textColor="?attr/call_log_primary_text_color"
+            android:textSize="@dimen/call_log_primary_text_size"
+            android:includeFontPadding="false"
+            android:layout_marginTop="2dp"
+            android:layout_marginBottom="3dp"
+            android:singleLine="true" />
+
+        <TextView
+            android:id="@+id/caller_number"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textColor="?attr/call_log_secondary_text_color"
+            android:textSize="@dimen/call_log_secondary_text_size"
+            android:layout_marginBottom="1dp"
+            android:singleLine="true" />
+
+        <TextView
+            android:id="@+id/phone_account_label"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textColor="?attr/call_log_secondary_text_color"
+            android:textSize="@dimen/call_log_secondary_text_size"
+            android:singleLine="true"
+            android:visibility="gone" />
+
+    </LinearLayout>
+
+    <ImageView
+        android:id="@+id/call_back_button"
+        android:layout_width="@dimen/call_log_list_item_primary_action_dimen"
+        android:layout_height="@dimen/call_log_list_item_primary_action_dimen"
+        android:layout_marginEnd="16dp"
+        android:background="?android:attr/selectableItemBackgroundBorderless"
+        android:src="@drawable/ic_call_24dp"
+        android:scaleType="center"
+        android:tint="@color/call_log_list_item_primary_action_icon_tint"
+        android:contentDescription="@string/description_call_log_call_action"
+        android:visibility="gone" />
+
+</LinearLayout>
diff --git a/res/layout/call_detail_history_header.xml b/res/layout/call_detail_history_header.xml
deleted file mode 100644
index def1fd8..0000000
--- a/res/layout/call_detail_history_header.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 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.
--->
-
-<TextView
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:ex="http://schemas.android.com/apk/res-auto"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:paddingTop="@dimen/call_detail_header_top_margin"
-    android:paddingBottom="@dimen/call_detail_header_bottom_margin"
-    android:paddingStart="@dimen/call_detail_horizontal_margin"
-    android:textColor="?attr/call_log_secondary_text_color"
-    android:textSize="@dimen/call_log_secondary_text_size"
-    android:fontFamily="sans-serif-medium"
-    android:singleLine="true"
-    android:text="@string/call_detail_list_header"
-    />
diff --git a/res/layout/call_details_voicemail_header.xml b/res/layout/call_details_voicemail_header.xml
deleted file mode 100644
index e3640fa..0000000
--- a/res/layout/call_details_voicemail_header.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical" >
-
-        <LinearLayout
-            android:id="@+id/voicemail_container"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="vertical"
-            android:paddingBottom="@dimen/call_detail_button_spacing"
-            android:visibility="gone">
-            <!-- The voicemail fragment will be put here. -->
-        </LinearLayout>
-
-</LinearLayout>
diff --git a/res/menu/call_details_options.xml b/res/menu/call_details_options.xml
index 0e9e5c9..414b671 100644
--- a/res/menu/call_details_options.xml
+++ b/res/menu/call_details_options.xml
@@ -16,16 +16,6 @@
 <menu xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/call_details_menu">
 
-    <item android:id="@+id/menu_trash"
-        android:icon="@drawable/ic_delete_24dp"
-        android:showAsAction="ifRoom"
-        android:title="@string/call_log_trash_voicemail" />
-
-    <item android:id="@+id/menu_remove_from_call_log"
-        android:icon="@drawable/ic_delete_24dp"
-        android:showAsAction="ifRoom"
-        android:title="@string/call_log_remove_from_call_log" />
-
     <item android:id="@+id/menu_edit_number_before_call"
         android:title="@string/call_log_edit_number_before_call" />
 
diff --git a/res/values/colors.xml b/res/values/colors.xml
index e80ee69..f0765ba 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -92,9 +92,10 @@
 
     <!-- Color for missed call icons. -->
     <color name="missed_call">#ff2e58</color>
-
     <!-- Color for answered or outgoing call icons. -->
     <color name="answered_call">@color/dialer_green_highlight_color</color>
+    <!-- Color for blocked call icons. -->
+    <color name="blocked_call">@color/dialtacts_secondary_text_color</color>
 
     <!-- Color for icons in the actionbar -->
     <color name="actionbar_icon_color">#ffffff</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 0a330d8..093e80f 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -39,12 +39,12 @@
     <!-- Size of contact photos in the call log and call details. -->
     <dimen name="contact_photo_size">40dp</dimen>
     <dimen name="call_detail_button_spacing">2dip</dimen>
-    <dimen name="call_detail_horizontal_margin">16dp</dimen>
-    <dimen name="call_detail_top_margin">36dp</dimen>
-    <dimen name="call_detail_bottom_margin">32dp</dimen>
+    <dimen name="call_detail_horizontal_margin">20dp</dimen>
+    <dimen name="call_detail_top_margin">16dp</dimen>
+    <dimen name="call_detail_bottom_margin">16dp</dimen>
     <dimen name="call_detail_header_top_margin">20dp</dimen>
     <dimen name="call_detail_header_bottom_margin">9dp</dimen>
-    <dimen name="call_detail_translation_z">0.5dp</dimen>
+    <dimen name="call_detail_elevation">0.5dp</dimen>
     <dimen name="transcription_top_margin">18dp</dimen>
     <dimen name="transcription_bottom_margin">18dp</dimen>
 
@@ -154,4 +154,6 @@
     <dimen name="blocked_number_secondary_text_size">12sp</dimen>
     <dimen name="blocked_number_delete_icon_size">32dp</dimen>
     <dimen name="blocked_number_search_text_size">14sp</dimen>
+
+    <dimen name="call_type_icon_size">12dp</dimen>
 </resources>
diff --git a/res/values/ids.xml b/res/values/ids.xml
index f96761a..f850327 100644
--- a/res/values/ids.xml
+++ b/res/values/ids.xml
@@ -15,6 +15,7 @@
 -->
 
 <resources>
+    <item type="id" name="call_detail_delete_menu_item" />
     <item type="id" name="context_menu_copy_to_clipboard" />
     <item type="id" name="context_menu_copy_transcript_to_clipboard" />
     <item type="id" name="context_menu_edit_before_call" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d51ff6d..c52b18b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -70,6 +70,9 @@
     <!-- Text for undo button in snackbar for blocking/unblocking number. [CHAR LIMIT=10] -->
     <string name="block_number_undo">UNDO</string>
 
+    <!-- Menu item in call details used to remove a call or voicemail from the call log. -->
+    <string name="call_details_delete">Delete</string>
+
     <!-- Menu item used to copy a number from the call log to the dialer so it can be edited before calling it -->
     <string name="call_log_edit_number_before_call">Edit number before call</string>
 
@@ -873,48 +876,51 @@
     <!-- DO NOT TRANSLATE. Internal key for DTMF tone length preference. -->
     <string name="dtmf_tone_length_preference_key" translatable="false">button_dtmf_settings</string>
 
-    <!-- The label of the button used to turn on a single permission -->
+    <!-- The label of the button used to turn on a single permission [CHAR LIMIT=30]-->
     <string name="permission_single_turn_on">Turn on</string>
 
-    <!--  The label of the button used to turn on multiple permissions -->
+    <!--  The label of the button used to turn on multiple permissions [CHAR LIMIT=30]-->
     <string name="permission_multiple_turn_on">Set permissions</string>
 
-    <!-- Shown as a prompt to turn on the contacts permission to enable speed dial -->
-    <string name="permission_no_speeddial">To enable speed dial,\n turn on the Contacts permission.</string>
+    <!-- Shown as a prompt to turn on the contacts permission to enable speed dial [CHAR LIMIT=NONE]-->
+    <string name="permission_no_speeddial">To enable speed dial, turn on the Contacts permission.</string>
 
-    <!-- Shown as a prompt to turn on the phone permission to enable the call log -->
-    <string name="permission_no_calllog">To see your call log,\n turn on the Phone permission.</string>
+    <!-- Shown as a prompt to turn on the phone permission to enable the call log [CHAR LIMIT=NONE]-->
+    <string name="permission_no_calllog">To see your call log, turn on the Phone permission.</string>
 
-    <!-- Shown as a prompt to turn on the contacts permission to show all contacts -->
-    <string name="permission_no_contacts">To see your contacts,\n turn on the Contacts permission.</string>
+    <!-- Shown as a prompt to turn on the contacts permission to show all contacts [CHAR LIMIT=NONE]-->
+    <string name="permission_no_contacts">To see your contacts, turn on the Contacts permission.</string>
 
-    <!-- Shown as a prompt to turn on the phone permission to show voicemails -->
-    <string name="permission_no_voicemail">To access your voicemail,\n turn on the Phone permission.</string>
+    <!-- Shown as a prompt to turn on the phone permission to show voicemails [CHAR LIMIT=NONE]-->
+    <string name="permission_no_voicemail">To access your voicemail, turn on the Phone permission.</string>
 
-    <!-- Shown as a prompt to turn on contacts permissions to allow contact search -->
+    <!-- Shown as a prompt to turn on contacts permissions to allow contact search [CHAR LIMIT=NONE]-->
     <string name="permission_no_search">To search your contacts, turn on the Contacts permissions.</string>
 
-    <!-- Shown as a prompt to turn on the phone permission to allow a call to be placed -->
-    <string name="permission_place_call">To place a call,\n turn on the Phone permission.</string>
+    <!-- Shown as a prompt to turn on location permissions and/or enable location to allow nearby places search [CHAR LIMIT=NONE]-->
+    <string name="permission_no_location_for_search">To search nearby locations, allow Phone to access your location.</string>
 
-    <!-- Shown as a message that notifies the user that the Phone app cannot write to system settings, which is why the system settings app is being launched directly instead.-->
+    <!-- Shown as a prompt to turn on the phone permission to allow a call to be placed [CHAR LIMIT=NONE]-->
+    <string name="permission_place_call">To place a call, turn on the Phone permission.</string>
+
+    <!-- Shown as a message that notifies the user that the Phone app cannot write to system settings, which is why the system settings app is being launched directly instead. [CHAR LIMIT=NONE]-->
     <string name="toast_cannot_write_system_settings">Phone app does not have permission to write to system settings.</string>
 
-    <!-- Title of the onboarding screen that asks the user to make Phone the default Phone app -->
+    <!-- Title of the onboarding screen that asks the user to make Phone the default Phone app [CHAR LIMIT=NONE]-->
     <string name="request_default_dialer_screen_title">A better way of calling is calling</string>
 
-    <!-- Content of the onboarding screen that asks the user to make Phone the default Phone app -->
+    <!-- Content of the onboarding screen that asks the user to make Phone the default Phone app [CHAR LIMIT=NONE]-->
     <string name="request_default_dialer_screen_content">Make Phone your default phone app to be able to do things like see who\'s calling you, even when they\'re not in your contacts.</string>
 
-    <!-- Title of the onboarding screen that asks the user to grant us the Contacts and Phone permissions -->
+    <!-- Title of the onboarding screen that asks the user to grant us the Contacts and Phone permissions [CHAR LIMIT=NONE]-->
     <string name="request_permissions_screen_title">Get talking to your friends and family</string>
 
-    <!-- Content of the onboarding screen that asks the user to grant us the Contacts and Phone permissions -->
+    <!-- Content of the onboarding screen that asks the user to grant us the Contacts and Phone permissions [CHAR LIMIT=NONE]-->
     <string name="request_permissions_screen_content">Phone will need to access your phone and contacts to make calls to people in your contacts.</string>
 
-    <!-- The label of the button used to skip a screen in the onboarding flow -->
+    <!-- The label of the button used to skip a screen in the onboarding flow [CHAR LIMIT=30]-->
     <string name="onboarding_skip_button">Skip</string>
 
-    <!-- The label of the button used to go to the next screen in the onboarding flow -->
+    <!-- The label of the button used to go to the next screen in the onboarding flow [CHAR LIMIT=30]-->
     <string name="onboarding_next_button">Next</string>
 </resources>
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java
index d95b55e..12849f4 100644
--- a/src/com/android/dialer/CallDetailActivity.java
+++ b/src/com/android/dialer/CallDetailActivity.java
@@ -38,14 +38,16 @@
 import android.widget.TextView;
 import android.widget.Toast;
 
-import com.android.contacts.common.ContactPhotoManager;
-import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest;
-import com.android.contacts.common.interactions.TouchPointManager;
-import com.android.contacts.common.GeoUtil;
 import com.android.contacts.common.CallUtil;
+import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest;
+import com.android.contacts.common.ContactPhotoManager;
+import com.android.contacts.common.GeoUtil;
+import com.android.contacts.common.interactions.TouchPointManager;
+import com.android.contacts.common.testing.NeededForTesting;
 import com.android.contacts.common.util.UriUtils;
 import com.android.dialer.calllog.CallDetailHistoryAdapter;
 import com.android.dialer.calllog.CallLogAsyncTaskUtil.CallLogAsyncTaskListener;
+import com.android.dialer.onboard.OnboardingActivity;
 import com.android.dialer.calllog.CallLogAsyncTaskUtil;
 import com.android.dialer.calllog.CallTypeHelper;
 import com.android.dialer.calllog.ContactInfoHelper;
@@ -219,6 +221,11 @@
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
 
+        if (OnboardingActivity.shouldStartOnboardingActivity(this)) {
+            OnboardingActivity.startOnboardingActivity(this);
+            finish();
+        }
+
         mContext = this;
 
         setContentView(R.layout.call_detail);
@@ -230,6 +237,9 @@
 
         mVoicemailUri = getIntent().getParcelableExtra(EXTRA_VOICEMAIL_URI);
 
+        ListView historyList = (ListView) findViewById(R.id.history);
+        historyList.addHeaderView(mInflater.inflate(R.layout.call_detail_header, null));
+
         mQuickContactBadge = (QuickContactBadge) findViewById(R.id.quick_contact_photo);
         mQuickContactBadge.setOverlay(null);
         mQuickContactBadge.setPrioritizedMimeType(Phone.CONTENT_ITEM_TYPE);
@@ -276,7 +286,8 @@
         CallLogAsyncTaskUtil.getCallDetails(this, getCallLogEntryUris(), mCallLogAsyncTaskListener);
     }
 
-    private boolean hasVoicemail() {
+    @NeededForTesting
+    public boolean hasVoicemail() {
         return mVoicemailUri != null;
     }
 
@@ -321,23 +332,24 @@
 
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
+        final MenuItem deleteMenuItem = menu.add(
+                Menu.NONE,
+                R.id.call_detail_delete_menu_item,
+                Menu.NONE,
+                R.string.call_details_delete);
+        deleteMenuItem.setIcon(R.drawable.ic_delete_24dp);
+        deleteMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+        deleteMenuItem.setOnMenuItemClickListener(this);
+
         getMenuInflater().inflate(R.menu.call_details_options, menu);
         return super.onCreateOptionsMenu(menu);
     }
 
     @Override
     public boolean onPrepareOptionsMenu(Menu menu) {
-        // This action deletes all elements in the group from the call log.
-        // We don't have this action for voicemails, because you can just use the trash button.
-        menu.findItem(R.id.menu_remove_from_call_log)
-                .setVisible(!hasVoicemail())
-                .setOnMenuItemClickListener(this);
         menu.findItem(R.id.menu_edit_number_before_call)
                 .setVisible(mHasEditNumberBeforeCallOption)
                 .setOnMenuItemClickListener(this);
-        menu.findItem(R.id.menu_trash)
-                .setVisible(hasVoicemail())
-                .setOnMenuItemClickListener(this);
         menu.findItem(R.id.menu_report)
                 .setVisible(mHasReportMenuOption)
                 .setOnMenuItemClickListener(this);
@@ -347,24 +359,25 @@
     @Override
     public boolean onMenuItemClick(MenuItem item) {
         switch (item.getItemId()) {
-            case R.id.menu_remove_from_call_log:
-                final StringBuilder callIds = new StringBuilder();
-                for (Uri callUri : getCallLogEntryUris()) {
-                    if (callIds.length() != 0) {
-                        callIds.append(",");
+            case R.id.call_detail_delete_menu_item:
+                if (hasVoicemail()) {
+                    CallLogAsyncTaskUtil.deleteVoicemail(
+                            this, mVoicemailUri, mCallLogAsyncTaskListener);
+                } else {
+                    final StringBuilder callIds = new StringBuilder();
+                    for (Uri callUri : getCallLogEntryUris()) {
+                        if (callIds.length() != 0) {
+                            callIds.append(",");
+                        }
+                        callIds.append(ContentUris.parseId(callUri));
                     }
-                    callIds.append(ContentUris.parseId(callUri));
+                    CallLogAsyncTaskUtil.deleteCalls(
+                            this, callIds.toString(), mCallLogAsyncTaskListener);
                 }
-                CallLogAsyncTaskUtil.deleteCalls(
-                        this, callIds.toString(), mCallLogAsyncTaskListener);
                 break;
             case R.id.menu_edit_number_before_call:
                 startActivity(new Intent(Intent.ACTION_DIAL, CallUtil.getCallUri(mNumber)));
                 break;
-            case R.id.menu_trash:
-                CallLogAsyncTaskUtil.deleteVoicemail(
-                        this, mVoicemailUri, mCallLogAsyncTaskListener);
-                break;
         }
         return true;
     }
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 9978bbe..4bfd565 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -80,6 +80,7 @@
 import com.android.dialer.list.SearchFragment;
 import com.android.dialer.list.SmartDialSearchFragment;
 import com.android.dialer.list.SpeedDialFragment;
+import com.android.dialer.onboard.OnboardingActivity;
 import com.android.dialer.settings.DialerSettingsActivity;
 import com.android.dialer.util.IntentUtil;
 import com.android.dialer.util.TelecomUtil;
@@ -109,6 +110,7 @@
         ListsFragment.HostInterface,
         SpeedDialFragment.HostInterface,
         SearchFragment.HostInterface,
+        RegularSearchFragment.HostInterface,
         OnDragDropListener,
         OnPhoneNumberPickerActionListener,
         PopupMenu.OnMenuItemClickListener,
@@ -374,6 +376,11 @@
         Trace.beginSection(TAG + " onCreate");
         super.onCreate(savedInstanceState);
 
+        if (OnboardingActivity.shouldStartOnboardingActivity(this)) {
+            OnboardingActivity.startOnboardingActivity(this);
+            finish();
+        }
+
         mFirstLaunch = true;
 
         final Resources resources = getResources();
@@ -864,6 +871,11 @@
         }
     }
 
+    @Override
+    public boolean isNearbyPlacesSearchEnabled() {
+        return false;
+    }
+
     protected int getSearchBoxHint () {
         return R.string.dialer_hint_find_contact;
     }
diff --git a/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java b/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java
index 3b488a8..ac56332 100644
--- a/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java
+++ b/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java
@@ -38,8 +38,6 @@
  * Adapter for a ListView containing history items from the details of a call.
  */
 public class CallDetailHistoryAdapter extends BaseAdapter {
-    /** The top element is a blank header, which is hidden under the rest of the UI. */
-    private static final int VIEW_TYPE_HEADER = 0;
     /** Each history item shows the detail of a call. */
     private static final int VIEW_TYPE_HISTORY_ITEM = 1;
 
@@ -69,53 +67,37 @@
 
     @Override
     public int getCount() {
-        return mPhoneCallDetails.length + 1;
+        return mPhoneCallDetails.length;
     }
 
     @Override
     public Object getItem(int position) {
-        if (position == 0) {
-            return null;
-        }
-        return mPhoneCallDetails[position - 1];
+        return mPhoneCallDetails[position];
     }
 
     @Override
     public long getItemId(int position) {
-        if (position == 0) {
-            return -1;
-        }
-        return position - 1;
+        return position;
     }
 
     @Override
     public int getViewTypeCount() {
-        return 2;
+        return 1;
     }
 
     @Override
     public int getItemViewType(int position) {
-        if (position == 0) {
-            return VIEW_TYPE_HEADER;
-        }
         return VIEW_TYPE_HISTORY_ITEM;
     }
 
     @Override
     public View getView(int position, View convertView, ViewGroup parent) {
-        if (position == 0) {
-            final View header = convertView == null
-                    ? mLayoutInflater.inflate(R.layout.call_detail_history_header, parent, false)
-                    : convertView;
-            return header;
-        }
-
         // Make sure we have a valid convertView to start with
         final View result  = convertView == null
                 ? mLayoutInflater.inflate(R.layout.call_detail_history_item, parent, false)
                 : convertView;
 
-        PhoneCallDetails details = mPhoneCallDetails[position - 1];
+        PhoneCallDetails details = mPhoneCallDetails[position];
         CallTypeIconsView callTypeIconView =
                 (CallTypeIconsView) result.findViewById(R.id.call_type_icon);
         TextView callTypeTextView = (TextView) result.findViewById(R.id.call_type_text);
diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
index b90d285..30aaee0 100644
--- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
+++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
@@ -316,7 +316,6 @@
                 FilterNumberDialogFragment newFragment =
                         FilterNumberDialogFragment.newInstance(blockId, info.normalizedNumber,
                                 number, countryIso, displayNumber);
-                newFragment.setQueryHandler(mFilteredNumberAsyncQueryHandler);
                 newFragment.setParentView(
                         ((Activity) mContext).findViewById(R.id.floating_action_button_container));
                 newFragment.show(((Activity) mContext).getFragmentManager(),
diff --git a/src/com/android/dialer/calllog/CallTypeIconsView.java b/src/com/android/dialer/calllog/CallTypeIconsView.java
index d680cfe..cfd8f97 100644
--- a/src/com/android/dialer/calllog/CallTypeIconsView.java
+++ b/src/com/android/dialer/calllog/CallTypeIconsView.java
@@ -114,6 +114,8 @@
                 return mResources.missed;
             case AppCompatConstants.CALLS_VOICEMAIL_TYPE:
                 return mResources.voicemail;
+            case AppCompatConstants.CALLS_BLOCKED_TYPE:
+                return mResources.blocked;
             default:
                 // It is possible for users to end up with calls with unknown call types in their
                 // call history, possibly due to 3rd party call log implementations (e.g. to
@@ -150,29 +152,22 @@
 
     private static class Resources {
 
-        /**
-         * Drawable representing an incoming answered call.
-         */
+        // Drawable representing an incoming answered call.
         public final Drawable incoming;
 
-        /**
-         * Drawable respresenting an outgoing call.
-         */
+        // Drawable respresenting an outgoing call.
         public final Drawable outgoing;
 
-        /**
-         * Drawable representing an incoming missed call.
-         */
+        // Drawable representing an incoming missed call.
         public final Drawable missed;
 
-        /**
-         * Drawable representing a voicemail.
-         */
+        // Drawable representing a voicemail.
         public final Drawable voicemail;
 
-        /**
-         * Drawable repesenting a video call.
-         */
+        // Drawable representing a blocked call.
+        public final Drawable blocked;
+
+        //  Drawable repesenting a video call.
         public final Drawable videoCall;
 
         /**
@@ -204,21 +199,26 @@
 
             voicemail = r.getDrawable(R.drawable.ic_call_voicemail_holo_dark);
 
-            // Get the video call icon, scaled to match the height of the call arrows.
-            // We want the video call icon to be the same height as the call arrows, while keeping
-            // the same width aspect ratio.
-            Bitmap videoIcon = BitmapFactory.decodeResource(context.getResources(),
-                    R.drawable.ic_videocam_24dp);
-            int scaledHeight = missed.getIntrinsicHeight();
-            int scaledWidth = (int) ((float) videoIcon.getWidth() *
-                    ((float) missed.getIntrinsicHeight() /
-                            (float) videoIcon.getHeight()));
-            Bitmap scaled = Bitmap.createScaledBitmap(videoIcon, scaledWidth, scaledHeight, false);
-            videoCall = new BitmapDrawable(context.getResources(), scaled);
+            blocked = getScaledBitmap(context, R.drawable.ic_block_24dp);
+            blocked.setColorFilter(r.getColor(R.color.blocked_call), PorterDuff.Mode.MULTIPLY);
+
+            videoCall = getScaledBitmap(context, R.drawable.ic_videocam_24dp);
             videoCall.setColorFilter(r.getColor(R.color.dialtacts_secondary_text_color),
                     PorterDuff.Mode.MULTIPLY);
 
             iconMargin = r.getDimensionPixelSize(R.dimen.call_log_icon_margin);
         }
+
+        // Gets the icon, scaled to the height of the call type icons. This helps display all the
+        // icons to be the same height, while preserving their width aspect ratio.
+        private Drawable getScaledBitmap(Context context, int resourceId) {
+            Bitmap icon = BitmapFactory.decodeResource(context.getResources(), resourceId);
+            int scaledHeight =
+                    context.getResources().getDimensionPixelSize(R.dimen.call_type_icon_size);
+            int scaledWidth = (int) ((float) icon.getWidth()
+                    * ((float) scaledHeight / (float) icon.getHeight()));
+            Bitmap scaledIcon = Bitmap.createScaledBitmap(icon, scaledWidth, scaledHeight, false);
+            return new BitmapDrawable(context.getResources(), scaledIcon);
+        }
     }
 }
diff --git a/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java b/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java
index 9da9cc1..c5d2f6f 100644
--- a/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java
+++ b/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java
@@ -247,4 +247,4 @@
             }
         }, uri, null, null, null, null);
     }
-}
\ No newline at end of file
+}
diff --git a/src/com/android/dialer/filterednumber/BlockedNumberAdapter.java b/src/com/android/dialer/filterednumber/BlockedNumberAdapter.java
index 5041ed8..ad61a32 100644
--- a/src/com/android/dialer/filterednumber/BlockedNumberAdapter.java
+++ b/src/com/android/dialer/filterednumber/BlockedNumberAdapter.java
@@ -35,7 +35,6 @@
 import com.android.dialer.R;
 import com.android.dialer.calllog.ContactInfo;
 import com.android.dialer.calllog.ContactInfoHelper;
-import com.android.dialer.database.FilteredNumberAsyncQueryHandler;
 import com.android.dialer.database.FilteredNumberContract.FilteredNumberColumns;
 import com.android.dialer.util.PhoneNumberUtil;
 
@@ -46,16 +45,13 @@
     private Resources mResources;
     private BidiFormatter mBidiFormatter = BidiFormatter.getInstance();
     private ContactPhotoManager mContactPhotoManager;
-    private FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler;
 
-    public BlockedNumberAdapter(Context context,
-                                FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler) {
+    public BlockedNumberAdapter(Context context) {
         super(context, R.layout.blocked_number_item, null, new String[]{}, new int[]{}, 0);
         mContext = context;
         mContactInfoHelper = new ContactInfoHelper(context, GeoUtil.getCurrentCountryIso(context));
         mContactPhotoManager = ContactPhotoManager.getInstance(context);
         mResources = context.getResources();
-        mFilteredNumberAsyncQueryHandler = filteredNumberAsyncQueryHandler;
     }
 
     @Override
@@ -88,7 +84,6 @@
                 FilterNumberDialogFragment newFragment =
                         FilterNumberDialogFragment.newInstance(id, normalizedNumber, number,
                                 countryIso, displayNumber);
-                newFragment.setQueryHandler(mFilteredNumberAsyncQueryHandler);
                 newFragment.setParentView(
                         ((Activity) mContext).findViewById(R.id.blocked_number_fragment));
                 newFragment.show(((Activity) mContext).getFragmentManager(),
diff --git a/src/com/android/dialer/filterednumber/BlockedNumberFragment.java b/src/com/android/dialer/filterednumber/BlockedNumberFragment.java
index de32fd6..79e5861 100644
--- a/src/com/android/dialer/filterednumber/BlockedNumberFragment.java
+++ b/src/com/android/dialer/filterednumber/BlockedNumberFragment.java
@@ -34,17 +34,14 @@
         LoaderManager.LoaderCallbacks<Cursor>, View.OnClickListener {
 
     private BlockedNumberAdapter mAdapter;
-    private FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler;
 
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
         LayoutInflater inflater = LayoutInflater.from(getContext());
         getListView().addHeaderView(inflater.inflate(R.layout.blocked_number_header, null));
-        mFilteredNumberAsyncQueryHandler =
-                new FilteredNumberAsyncQueryHandler(getActivity().getContentResolver());
         if (mAdapter == null) {
-            mAdapter = new BlockedNumberAdapter(getContext(), mFilteredNumberAsyncQueryHandler);
+            mAdapter = new BlockedNumberAdapter(getContext());
         }
         setListAdapter(mAdapter);
         getActivity().findViewById(R.id.add_number_button).setOnClickListener(this);
@@ -100,4 +97,4 @@
     public void onClick(final View v) {
         startActivity(new Intent(getActivity(), BlockedNumberSearchActivity.class));
     }
-}
\ No newline at end of file
+}
diff --git a/src/com/android/dialer/filterednumber/BlockedNumberSearchActivity.java b/src/com/android/dialer/filterednumber/BlockedNumberSearchActivity.java
index 11c0ac4..cfa404f 100644
--- a/src/com/android/dialer/filterednumber/BlockedNumberSearchActivity.java
+++ b/src/com/android/dialer/filterednumber/BlockedNumberSearchActivity.java
@@ -126,7 +126,6 @@
         fragment.setHasOptionsMenu(false);
         fragment.setShowEmptyListForNullQuery(true);
         fragment.setDirectorySearchEnabled(false);
-        fragment.setFilteredNumberAsyncQueryHandler(mFilteredNumberAsyncQueryHandler);
         transaction.commit();
     }
 
@@ -161,4 +160,4 @@
     public int getActionBarHeight() {
         return getResources().getDimensionPixelSize(R.dimen.action_bar_height_large);
     }
-}
\ No newline at end of file
+}
diff --git a/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java b/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java
index 1b95387..69039c8 100644
--- a/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java
+++ b/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java
@@ -61,10 +61,6 @@
         public void onUndoBlockComplete();
     }
 
-    public void setQueryHandler (FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler) {
-        mHandler = filteredNumberAsyncQueryHandler;
-    }
-
     public void setParentView(View view) {
         mParentView = view;
     }
@@ -98,6 +94,8 @@
         final boolean isBlocked = getArguments().containsKey(ARG_BLOCK_ID);
         final String displayNumber = getArguments().getString(ARG_DISPLAY_NUMBER);
 
+        mHandler = new FilteredNumberAsyncQueryHandler(getContext().getContentResolver());
+
         String message;
         String okText;
         if (isBlocked) {
@@ -123,6 +121,12 @@
         return builder.create();
     }
 
+    @Override
+    public void onDestroy() {
+        this.dismissAllowingStateLoss();
+        super.onDestroy();
+    }
+
     private String getBlockedMessage(String displayNumber) {
         return getString(R.string.snackbar_number_blocked, displayNumber);
     }
@@ -194,4 +198,4 @@
                     }
                 }, getArguments().getInt(ARG_BLOCK_ID));
     }
-}
\ No newline at end of file
+}
diff --git a/src/com/android/dialer/list/BlockedListSearchAdapter.java b/src/com/android/dialer/list/BlockedListSearchAdapter.java
index 7ae24e4..8f7971f 100644
--- a/src/com/android/dialer/list/BlockedListSearchAdapter.java
+++ b/src/com/android/dialer/list/BlockedListSearchAdapter.java
@@ -39,10 +39,9 @@
         mResources = context.getResources();
         disableAllShortcuts();
         setShortcutEnabled(SHORTCUT_BLOCK_NUMBER, true);
-    }
 
-    public void setFilteredNumberAsyncQueryHandler(FilteredNumberAsyncQueryHandler handler) {
-        mFilteredNumberAsyncQueryHandler = handler;
+        mFilteredNumberAsyncQueryHandler =
+                new FilteredNumberAsyncQueryHandler(context.getContentResolver());
     }
 
     @Override
@@ -86,4 +85,4 @@
         mFilteredNumberAsyncQueryHandler.startBlockedQuery(
                 onCheckListener, normalizedNumber, number, countryIso);
     }
-}
\ No newline at end of file
+}
diff --git a/src/com/android/dialer/list/BlockedListSearchFragment.java b/src/com/android/dialer/list/BlockedListSearchFragment.java
index 7494372..6750812 100644
--- a/src/com/android/dialer/list/BlockedListSearchFragment.java
+++ b/src/com/android/dialer/list/BlockedListSearchFragment.java
@@ -18,6 +18,7 @@
 import android.content.ContentUris;
 import android.content.ContentValues;
 import android.net.Uri;
+import android.os.Bundle;
 import android.util.Log;
 import android.view.View;
 import android.widget.AdapterView;
@@ -37,16 +38,19 @@
 
     private FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler;
 
-    public void setFilteredNumberAsyncQueryHandler(FilteredNumberAsyncQueryHandler handler) {
-        mFilteredNumberAsyncQueryHandler = handler;
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mFilteredNumberAsyncQueryHandler = new FilteredNumberAsyncQueryHandler(
+                getContext().getContentResolver());
     }
 
+
     @Override
     protected ContactEntryListAdapter createListAdapter() {
         BlockedListSearchAdapter adapter = new BlockedListSearchAdapter(getActivity());
         adapter.setDisplayPhotos(true);
         adapter.setUseCallableUri(usesCallableUri());
-        adapter.setFilteredNumberAsyncQueryHandler(mFilteredNumberAsyncQueryHandler);
         return adapter;
     }
 
@@ -100,7 +104,6 @@
                 if (id == null) {
                     final FilterNumberDialogFragment newFragment = FilterNumberDialogFragment
                             .newInstance(id, normalizedNumber, number, countryIso, number);
-                    newFragment.setQueryHandler(mFilteredNumberAsyncQueryHandler);
                     newFragment.setParentView(
                             getActivity().findViewById(R.id.search_activity_container));
                     newFragment.show(
@@ -133,7 +136,6 @@
         }
         final FilterNumberDialogFragment newFragment = FilterNumberDialogFragment
                 .newInstance(blockId, normalizedNumber, number, countryIso, number);
-        newFragment.setQueryHandler(mFilteredNumberAsyncQueryHandler);
         newFragment.setParentView(getActivity().findViewById(R.id.search_activity_container));
         newFragment.setOnUndoBlockListener(new FilterNumberDialogFragment.OnUndoBlockListener() {
             @Override
diff --git a/src/com/android/dialer/list/RegularSearchFragment.java b/src/com/android/dialer/list/RegularSearchFragment.java
index ec771e8..0b87033 100644
--- a/src/com/android/dialer/list/RegularSearchFragment.java
+++ b/src/com/android/dialer/list/RegularSearchFragment.java
@@ -16,6 +16,7 @@
 package com.android.dialer.list;
 
 import static android.Manifest.permission.READ_CONTACTS;
+import static android.Manifest.permission.ACCESS_FINE_LOCATION;
 
 import android.app.Activity;
 import android.content.pm.PackageManager;
@@ -36,13 +37,19 @@
 public class RegularSearchFragment extends SearchFragment
         implements OnEmptyViewActionButtonClickedListener {
 
-    private static final int READ_CONTACTS_PERMISSION_REQUEST_CODE = 1;
+    private static final int PERMISSION_REQUEST_CODE = 1;
 
     private static final int SEARCH_DIRECTORY_RESULT_LIMIT = 5;
 
     private static final CachedNumberLookupService mCachedNumberLookupService =
         ObjectFactory.newCachedNumberLookupService();
 
+    public interface HostInterface {
+        public boolean isNearbyPlacesSearchEnabled();
+    }
+
+    private String mPermissionToRequest;
+
     public RegularSearchFragment() {
         configureDirectorySearch();
     }
@@ -64,6 +71,7 @@
         ((PinnedHeaderListView) getListView()).setScrollToSectionOnHeaderTouch(true);
     }
 
+    @Override
     protected ContactEntryListAdapter createListAdapter() {
         RegularSearchListAdapter adapter = new RegularSearchListAdapter(getActivity());
         adapter.setDisplayPhotos(true);
@@ -84,15 +92,36 @@
     @Override
     protected void setupEmptyView() {
         if (mEmptyView != null && getActivity() != null) {
+            final int imageResource;
+            final int actionLabelResource;
+            final int descriptionResource;
+            final OnEmptyViewActionButtonClickedListener listener;
             if (!PermissionsUtil.hasPermission(getActivity(), READ_CONTACTS)) {
-                mEmptyView.setImage(R.drawable.empty_contacts);
-                mEmptyView.setActionLabel(R.string.permission_single_turn_on);
-                mEmptyView.setDescription(R.string.permission_no_search);
-                mEmptyView.setActionClickedListener(this);
+                imageResource = R.drawable.empty_contacts;
+                actionLabelResource = R.string.permission_single_turn_on;
+                descriptionResource = R.string.permission_no_search;
+                listener = this;
+                mPermissionToRequest = READ_CONTACTS;
+            } else if (((HostInterface) getActivity()).isNearbyPlacesSearchEnabled()
+                    && !PermissionsUtil.hasPermission(getActivity(), ACCESS_FINE_LOCATION)) {
+                imageResource = R.drawable.empty_contacts;
+                actionLabelResource = R.string.permission_single_turn_on;
+                descriptionResource = R.string.permission_no_location_for_search;
+                listener = this;
+                mPermissionToRequest = ACCESS_FINE_LOCATION;
             } else {
-                mEmptyView.setImage(EmptyContentView.NO_IMAGE);
-                mEmptyView.setActionLabel(EmptyContentView.NO_LABEL);
-                mEmptyView.setDescription(EmptyContentView.NO_LABEL);
+                imageResource = EmptyContentView.NO_IMAGE;
+                actionLabelResource = EmptyContentView.NO_LABEL;
+                descriptionResource = EmptyContentView.NO_LABEL;
+                listener = null;
+                mPermissionToRequest = null;
+            }
+
+            mEmptyView.setImage(imageResource);
+            mEmptyView.setActionLabel(actionLabelResource);
+            mEmptyView.setDescription(descriptionResource);
+            if (listener != null) {
+                mEmptyView.setActionClickedListener(listener);
             }
         }
     }
@@ -104,17 +133,20 @@
             return;
         }
 
-        requestPermissions(new String[] {READ_CONTACTS}, READ_CONTACTS_PERMISSION_REQUEST_CODE);
+        if (READ_CONTACTS.equals(mPermissionToRequest)
+                || ACCESS_FINE_LOCATION.equals(mPermissionToRequest)) {
+            requestPermissions(new String[] {mPermissionToRequest}, PERMISSION_REQUEST_CODE);
+        }
     }
 
     @Override
     public void onRequestPermissionsResult(int requestCode, String[] permissions,
             int[] grantResults) {
-        if (requestCode == READ_CONTACTS_PERMISSION_REQUEST_CODE) {
+        if (requestCode == PERMISSION_REQUEST_CODE) {
             setupEmptyView();
             if (grantResults != null && grantResults.length == 1
                     && PackageManager.PERMISSION_GRANTED == grantResults[0]) {
-                PermissionsUtil.notifyPermissionGranted(getActivity(), READ_CONTACTS);
+                PermissionsUtil.notifyPermissionGranted(getActivity(), mPermissionToRequest);
             }
         }
     }
diff --git a/src/com/android/dialer/onboard/OnboardingActivity.java b/src/com/android/dialer/onboard/OnboardingActivity.java
index 75378e9..144e6d4 100644
--- a/src/com/android/dialer/onboard/OnboardingActivity.java
+++ b/src/com/android/dialer/onboard/OnboardingActivity.java
@@ -19,9 +19,11 @@
 import static android.Manifest.permission.CALL_PHONE;
 import static android.Manifest.permission.READ_CONTACTS;
 
+import android.Manifest;
 import android.app.Activity;
 import android.app.Fragment;
 import android.app.FragmentTransaction;
+import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.SharedPreferences.Editor;
@@ -45,6 +47,8 @@
         PermissionsChecker, OnboardingFragment.HostInterface {
     public static final String KEY_ALREADY_REQUESTED_DEFAULT_DIALER =
             "key_already_requested_default_dialer";
+    public static final String KEY_CALLING_ACTIVITY_INTENT =
+            "key_calling_activity_intent";
 
     public static final int SCREEN_DEFAULT_DIALER = 0;
     public static final int SCREEN_PERMISSIONS = 1;
@@ -95,6 +99,16 @@
     public void completeOnboardingFlow() {
         final Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
         editor.putBoolean(KEY_ALREADY_REQUESTED_DEFAULT_DIALER, true).apply();
+
+        // Once we have completed the onboarding flow, relaunch the activity that called us, so
+        // that we return the user to the intended activity.
+        if (getIntent() != null && getIntent().getExtras() != null) {
+            final Intent previousActivityIntent =
+                    getIntent().getExtras().getParcelable(KEY_CALLING_ACTIVITY_INTENT);
+            if (previousActivityIntent != null) {
+                startActivity(previousActivityIntent);
+            }
+        }
         finish();
     }
 
@@ -114,12 +128,61 @@
     }
 
     @Override
-    public boolean previouslyRequestedDefaultDialer() {
-        final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
+    public boolean hasAlreadyRequestedDefaultDialer() {
+        return getAlreadyRequestedDefaultDialerFromPreferences(this);
+    }
+
+    private static boolean getAlreadyRequestedDefaultDialerFromPreferences(Context context) {
+        final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
         return preferences.getBoolean(KEY_ALREADY_REQUESTED_DEFAULT_DIALER, false);
     }
 
     /**
+     * Checks the current permissions/application state to determine if the
+     * {@link OnboardingActivity} should be displayed. The onboarding flow should be launched if
+     * the current application is NOT the system dialer AND any of these criteria are true.
+     *
+     * 1) The phone application is not currently the default dialer AND we have not
+     * previously displayed a prompt to ask the user to set our app as the default dialer.
+     * 2) The phone application does not have the Phone permission.
+     * 3) The phone application does not have the Contacts permission.
+     *
+     * The exception if the current application is the system dialer applies because:
+     *
+     * 1) The system dialer must always provide immediate access to the dialpad to allow
+     * emergency calls to be made.
+     * 2) In order for the system dialer to require the onboarding flow, the user must have
+     * intentionally removed certain permissions/selected a different dialer. This assumes the
+     * that the user understands the implications of the actions previously taken. For example,
+     * removing the Phone permission from the system dialer displays a dialog that warns the
+     * user that this might break certain core phone functionality. Furthermore, various elements in
+     * the Dialer will prompt the user to grant permissions as needed.
+     *
+     * @param context A valid context object.
+     * @return {@code true} if the onboarding flow should be launched to request for the
+     *         necessary permissions or prompt the user to make us the default dialer, {@code false}
+     *         otherwise.
+     */
+    public static boolean shouldStartOnboardingActivity(Context context) {
+        // Since there is no official TelecomManager API to check for the system dialer,
+        // check to see if we have the system-only MODIFY_PHONE_STATE permission.
+        if (PermissionsUtil.hasPermission(context, Manifest.permission.MODIFY_PHONE_STATE)) {
+            return false;
+        }
+
+        return (!getAlreadyRequestedDefaultDialerFromPreferences(context)
+                && !TelecomUtil.isDefaultDialer(context))
+                        || !PermissionsUtil.hasPhonePermissions(context)
+                        || !PermissionsUtil.hasContactsPermissions(context);
+    }
+
+    public static void startOnboardingActivity(Activity callingActivity) {
+        final Intent intent = new Intent(callingActivity, OnboardingActivity.class);
+        intent.putExtra(KEY_CALLING_ACTIVITY_INTENT, callingActivity.getIntent());
+        callingActivity.startActivity(intent);
+    }
+
+    /**
      * Triggers the screen-specific logic that should occur when the next button is clicked.
      */
     @Override
@@ -180,7 +243,7 @@
 
         @Override
         public boolean shouldShowScreen() {
-            return !mPermissionsChecker.previouslyRequestedDefaultDialer()
+            return !mPermissionsChecker.hasAlreadyRequestedDefaultDialer()
                     && !mPermissionsChecker.isDefaultOrSystemDialer();
         }
 
diff --git a/src/com/android/dialer/onboard/PermissionsChecker.java b/src/com/android/dialer/onboard/PermissionsChecker.java
index 78d175e..c6b0bbf 100644
--- a/src/com/android/dialer/onboard/PermissionsChecker.java
+++ b/src/com/android/dialer/onboard/PermissionsChecker.java
@@ -23,5 +23,5 @@
     public boolean hasPhonePermissions();
     public boolean hasContactsPermissions();
     public boolean isDefaultOrSystemDialer();
-    public boolean previouslyRequestedDefaultDialer();
+    public boolean hasAlreadyRequestedDefaultDialer();
 }
diff --git a/tests/src/com/android/dialer/CallDetailActivityTest.java b/tests/src/com/android/dialer/CallDetailActivityTest.java
index 27fbc30..eda7474 100644
--- a/tests/src/com/android/dialer/CallDetailActivityTest.java
+++ b/tests/src/com/android/dialer/CallDetailActivityTest.java
@@ -84,11 +84,9 @@
     }
 
     /**
-     * Test for bug where voicemails should not have remove-from-call-log entry.
-     * <p>
-     * See http://b/5054103.
+     * Verifies the trash menu item is present and a voicemail URI is set.
      */
-    public void testVoicemailDoesNotHaveRemoveFromCallLog() throws Throwable {
+    public void testVoicemailDeleteButton() throws Throwable {
         setActivityIntentForTestVoicemailEntry();
         startActivityUnderTest();
         mFakeAsyncTaskExecutor.runTask(GET_CALL_DETAILS);
@@ -96,12 +94,13 @@
         Menu optionsMenu = (new PopupMenu(mActivityUnderTest, null)).getMenu();
         mActivityUnderTest.onCreateOptionsMenu(optionsMenu);
         mActivityUnderTest.onPrepareOptionsMenu(optionsMenu);
-        assertFalse(optionsMenu.findItem(R.id.menu_remove_from_call_log).isVisible());
-        assertTrue(optionsMenu.findItem(R.id.menu_trash).isVisible());
+
+        assertTrue(optionsMenu.findItem(R.id.call_detail_delete_menu_item).isVisible());
+        assertTrue(mActivityUnderTest.hasVoicemail());
     }
 
     /**
-     * Test to check that I haven't broken the remove-from-call-log entry from regular calls.
+     * Verifies the trash menu item is present and a voicemail URI is not set.
      */
     public void testRegularCallDoesHaveRemoveFromCallLog() throws Throwable {
         setActivityIntentForTestCallEntry();
@@ -111,8 +110,9 @@
         Menu optionsMenu = (new PopupMenu(mActivityUnderTest, null)).getMenu();
         mActivityUnderTest.onCreateOptionsMenu(optionsMenu);
         mActivityUnderTest.onPrepareOptionsMenu(optionsMenu);
-        assertTrue(optionsMenu.findItem(R.id.menu_remove_from_call_log).isVisible());
-        assertFalse(optionsMenu.findItem(R.id.menu_trash).isVisible());
+
+        assertTrue(optionsMenu.findItem(R.id.call_detail_delete_menu_item).isVisible());
+        assertFalse(mActivityUnderTest.hasVoicemail());
     }
 
     private void setActivityIntentForTestCallEntry() {
diff --git a/tests/src/com/android/dialer/onboard/DefaultDialerOnboardScreenTest.java b/tests/src/com/android/dialer/onboard/DefaultDialerOnboardScreenTest.java
index f9724c1..26e513f 100644
--- a/tests/src/com/android/dialer/onboard/DefaultDialerOnboardScreenTest.java
+++ b/tests/src/com/android/dialer/onboard/DefaultDialerOnboardScreenTest.java
@@ -36,17 +36,17 @@
     }
 
     public void testNeverRequestedForDefaultDialer_shouldShowScreen() {
-        when(mPermissionsChecker.previouslyRequestedDefaultDialer()).thenReturn(false);
+        when(mPermissionsChecker.hasAlreadyRequestedDefaultDialer()).thenReturn(false);
         assertTrue(mScreen.shouldShowScreen());
     }
 
     public void testAlreadyAskedForDefaultDialer_shouldNotShowScreen() {
-        when(mPermissionsChecker.previouslyRequestedDefaultDialer()).thenReturn(true);
+        when(mPermissionsChecker.hasAlreadyRequestedDefaultDialer()).thenReturn(true);
         assertFalse(mScreen.shouldShowScreen());
     }
 
     public void testAlreadySetAsDefaultDialer_shouldNotShowScreen() {
-        when(mPermissionsChecker.previouslyRequestedDefaultDialer()).thenReturn(false);
+        when(mPermissionsChecker.hasAlreadyRequestedDefaultDialer()).thenReturn(false);
         when(mPermissionsChecker.isDefaultOrSystemDialer()).thenReturn(true);
         assertFalse(mScreen.shouldShowScreen());
     }