Copy "Blocked Numbers Activity" from Dialer to Contacts

1. Classes are copied and modified so that they will work in Contacts.
2. BlockedNumbersActivity.java is the main activity.
3. Most copied classes are put in the newly-created "callblocking" package.
4. What's not copied: CachedNumberLookupService, visual voicemail, and
   emergency call. The corresponding features will be implemented based on
   framework change, which is not ready yet.
5. In Dialer, BlockedListSearchFragment extends RegularSearchFragment,
   which extends SearchFragment. These three classes are combined into
   SearchFragment in Contacts.
6. In Dialer, BlockedListSearchAdapter extends RegularSearchListAdapter,
   which extends DialerPhoneNumberListAdapter. These three classes are
   combined into SearchAdapter in Contacts.
7. An intent is specified in AndroidManifest.xml to open
   BlockedNumbersActivity.java

Bug: 26453530
Change-Id: Iec07725fd9aa5a174bb6b306792fa446dcaa4e65
diff --git a/res/layout/blocked_number_fragment.xml b/res/layout/blocked_number_fragment.xml
new file mode 100644
index 0000000..e2b9403
--- /dev/null
+++ b/res/layout/blocked_number_fragment.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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/blocked_number_fragment"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:orientation="vertical"
+              android:background="@color/blocked_number_background">
+
+    <ListView android:id="@id/android:list"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:divider="@null"
+              android:headerDividersEnabled="false" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/blocked_number_header.xml b/res/layout/blocked_number_header.xml
new file mode 100644
index 0000000..13ee7ba
--- /dev/null
+++ b/res/layout/blocked_number_header.xml
@@ -0,0 +1,179 @@
+<?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"
+    xmlns:card_view="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:focusable="false"
+    android:orientation="vertical">
+
+    <LinearLayout
+        android:id="@+id/blocked_numbers_disabled_for_emergency"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingTop="27dp"
+        android:paddingBottom="29dp"
+        android:paddingStart="@dimen/blocked_number_container_padding"
+        android:paddingEnd="44dp"
+        android:background="@color/blocked_number_disabled_emergency_background_color"
+        android:focusable="true"
+        android:orientation="vertical"
+        android:visibility="gone">
+
+        <TextView
+            style="@style/BlockedNumbersDescriptionTextStyle"
+            android:textStyle="bold"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/blocked_numbers_disabled_emergency_header_label"/>
+
+        <TextView
+            style="@style/BlockedNumbersDescriptionTextStyle"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/blocked_numbers_disabled_emergency_desc"/>
+
+    </LinearLayout>
+
+    <android.support.v7.widget.CardView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        card_view:cardCornerRadius="0dp">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:background="@android:color/white"
+            android:focusable="true"
+            android:orientation="vertical">
+
+            <LinearLayout
+                android:id="@+id/header_textview"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical"
+                android:padding="@dimen/blocked_number_container_padding"
+                android:background="@android:color/white"
+                android:focusable="true">
+
+                <TextView
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:textColor="@color/blocked_number_secondary_text_color"
+                    android:textSize="@dimen/blocked_number_settings_description_text_size"
+                    android:text="@string/blocked_number_header_message"/>
+            </LinearLayout>
+
+            <RelativeLayout
+                android:id="@+id/import_settings"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:visibility="gone">
+
+                <TextView
+                    android:id="@+id/import_description"
+                    style="@style/BlockedNumbersDescriptionTextStyle"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:paddingTop="11dp"
+                    android:paddingBottom="27dp"
+                    android:paddingStart="@dimen/blocked_number_container_padding"
+                    android:paddingEnd="@dimen/blocked_number_container_padding"
+                    android:text="@string/blocked_call_settings_import_description"
+                    android:textColor="@color/blocked_number_secondary_text_color"
+                    android:textSize="@dimen/blocked_number_settings_description_text_size"/>
+
+                <Button
+                    android:id="@+id/import_button"
+                    style="@style/ContactsFlatButtonStyle"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginEnd="@dimen/blocked_number_container_padding"
+                    android:layout_alignParentEnd="true"
+                    android:layout_below="@id/import_description"
+                    android:text="@string/blocked_call_settings_import_button"/>
+
+                <Button
+                    android:id="@+id/view_numbers_button"
+                    style="@style/ContactsFlatButtonStyle"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginEnd="8dp"
+                    android:layout_below="@id/import_description"
+                    android:layout_toStartOf="@id/import_button"
+                    android:text="@string/blocked_call_settings_view_numbers_button"/>
+
+                <View
+                    android:layout_width="match_parent"
+                    android:layout_height="1dp"
+                    android:layout_marginTop="8dp"
+                    android:layout_below="@id/import_button"
+                    android:background="@color/blocked_number_divider_line_color"/>
+
+            </RelativeLayout>
+
+            <LinearLayout
+                android:id="@+id/add_number_linear_layout"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:paddingTop="@dimen/blocked_number_add_top_margin"
+                android:paddingBottom="@dimen/blocked_number_add_bottom_margin"
+                android:paddingStart="@dimen/blocked_number_horizontal_margin"
+                android:background="?android:attr/selectableItemBackground"
+                android:baselineAligned="false"
+                android:clickable="true"
+                android:contentDescription="@string/addBlockedNumber"
+                android:focusable="true"
+                android:gravity="center_vertical"
+                android:orientation="horizontal">
+
+                <ImageView
+                    android:id="@+id/add_number_icon"
+                    android:layout_width="@dimen/blocked_number_add_number_icon_size"
+                    android:layout_height="@dimen/blocked_number_add_number_icon_size"
+                    android:importantForAccessibility="no"/>
+                <LinearLayout
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:layout_marginStart="@dimen/blocked_number_horizontal_margin"
+                    android:gravity="center_vertical"
+                    android:orientation="vertical">
+
+                    <TextView
+                        android:id="@+id/add_number_textview"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:includeFontPadding="false"
+                        android:text="@string/addBlockedNumber"
+                        android:textColor="@color/blocked_number_primary_text_color"
+                        android:textSize="@dimen/blocked_number_primary_text_size"/>
+                </LinearLayout>
+
+            </LinearLayout>
+
+            <View
+                android:id="@+id/blocked_number_list_divider"
+                android:layout_width="match_parent"
+                android:layout_height="1dp"
+                android:layout_marginStart="72dp"
+                android:background="@color/blocked_number_divider_line_color"/>
+
+        </LinearLayout>
+
+    </android.support.v7.widget.CardView>
+
+</LinearLayout>
diff --git a/res/layout/blocked_number_item.xml b/res/layout/blocked_number_item.xml
new file mode 100644
index 0000000..0d8b26f
--- /dev/null
+++ b/res/layout/blocked_number_item.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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/blocked_number_horizontal_margin"
+    android:baselineAligned="false"
+    android:orientation="horizontal"
+    android:focusable="true"
+    android:gravity="center_vertical"
+    android:background="@android:color/white">
+
+    <QuickContactBadge
+        android:id="@+id/quick_contact_photo"
+        android:layout_width="@dimen/blocked_number_add_number_icon_size"
+        android:layout_height="@dimen/blocked_number_add_number_icon_size"
+        android:focusable="true"
+        android:layout_marginTop="@dimen/blocked_number_top_margin"
+        android:layout_marginBottom="@dimen/blocked_number_bottom_margin"/>
+    <LinearLayout
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:gravity="center_vertical"
+        android:layout_weight="1"
+        android:orientation="vertical"
+        android:layout_marginStart="@dimen/blocked_number_horizontal_margin">
+
+        <TextView
+            android:id="@+id/caller_name"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textColor="@color/blocked_number_primary_text_color"
+            android:textSize="@dimen/blocked_number_primary_text_size"
+            android:includeFontPadding="false"
+            android:singleLine="true"/>
+
+        <TextView
+            android:id="@+id/caller_number"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textColor="@color/blocked_number_secondary_text_color"
+            android:textSize="@dimen/blocked_number_settings_description_text_size"
+            android:singleLine="true" />
+    </LinearLayout>
+
+    <ImageView
+        android:id="@+id/delete_button"
+        android:layout_width="@dimen/blocked_number_delete_icon_size"
+        android:layout_height="@dimen/blocked_number_delete_icon_size"
+        android:layout_marginEnd="24dp"
+        android:background="?android:attr/selectableItemBackgroundBorderless"
+        android:src="@drawable/ic_remove"
+        android:scaleType="center"
+        android:tint="@color/blocked_number_icon_tint"
+        android:contentDescription="@string/description_blocked_number_list_delete" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/blocked_numbers_activity.xml b/res/layout/blocked_numbers_activity.xml
new file mode 100644
index 0000000..6451496
--- /dev/null
+++ b/res/layout/blocked_numbers_activity.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+             android:id="@+id/blocked_numbers_activity_container"
+             android:layout_width="match_parent"
+             android:layout_height="match_parent">
+</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/empty_content_view.xml b/res/layout/empty_content_view.xml
new file mode 100644
index 0000000..97ac4c7
--- /dev/null
+++ b/res/layout/empty_content_view.xml
@@ -0,0 +1,54 @@
+<?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.
+-->
+
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+    <ImageView
+        android:id="@+id/emptyListViewImage"
+        android:layout_height="wrap_content"
+        android:layout_width="match_parent"
+        android:gravity="center_horizontal" />
+
+    <TextView
+        android:id="@+id/emptyListViewMessage"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center_horizontal|top"
+        android:textSize="@dimen/empty_list_message_text_size"
+        android:textColor="@color/empty_list_text_color"
+        android:paddingRight="16dp"
+        android:paddingLeft="16dp"
+        android:paddingTop="8dp"
+        android:paddingBottom="8dp" />
+
+    <TextView
+        android:id="@+id/emptyListViewAction"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:gravity="center_horizontal"
+        android:layout_gravity="center_horizontal"
+        android:paddingRight="16dp"
+        android:paddingLeft="16dp"
+        android:paddingTop="8dp"
+        android:paddingBottom="8dp"
+        android:background="?android:attr/selectableItemBackground"
+        android:clickable="true"
+        style="@style/TextActionStyle" />
+
+    <Space
+        android:layout_width="match_parent"
+        android:layout_height="40dp" />
+
+</merge>
diff --git a/res/layout/search_edittext.xml b/res/layout/search_edittext.xml
new file mode 100644
index 0000000..2492ca9
--- /dev/null
+++ b/res/layout/search_edittext.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<view class="com.android.contacts.widget.SearchEditTextLayout"
+      xmlns:android="http://schemas.android.com/apk/res/android"
+      android:layout_width="match_parent"
+      android:layout_height="match_parent"
+      android:id="@+id/search_view_container"
+      android:orientation="horizontal"
+      android:layout_marginTop="0dp"
+      android:layout_marginBottom="0dp"
+      android:layout_marginLeft="0dp"
+      android:layout_marginRight="0dp"
+      android:background="@drawable/rounded_corner"
+      android:elevation="3dp">
+
+    <include layout="@layout/search_bar_expanded" />
+
+</view>
diff --git a/res/layout/view_numbers_to_import_fragment.xml b/res/layout/view_numbers_to_import_fragment.xml
new file mode 100644
index 0000000..8f7331f
--- /dev/null
+++ b/res/layout/view_numbers_to_import_fragment.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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"
+    xmlns:card_view="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical"
+    android:background="@color/blocked_number_background">
+
+    <ListView android:id="@id/android:list"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1"
+        android:divider="@null"
+        android:headerDividersEnabled="false" />
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_gravity="bottom"
+        android:paddingTop="8dp"
+        android:paddingBottom="8dp"
+        android:background="@android:color/white">
+
+        <Button android:id="@+id/import_button"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentEnd="true"
+            android:layout_marginEnd="@dimen/blocked_number_container_padding"
+            android:text="@string/blocked_call_settings_import_button"
+            style="@style/ContactsFlatButtonStyle" />
+
+        <Button android:id="@+id/cancel_button"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_below="@id/import_description"
+            android:layout_toLeftOf="@id/import_button"
+            android:text="@android:string/cancel"
+            style="@style/ContactsFlatButtonStyle" />
+
+    </RelativeLayout>
+
+</LinearLayout>