Merge "Add WRITE_SYNC_SETTINGS permission to Contacts App." into ub-contactsdialer-b-dev
diff --git a/Android.mk b/Android.mk
index b0fa901..ad13292 100644
--- a/Android.mk
+++ b/Android.mk
@@ -16,6 +16,8 @@
 res_dirs := res $(contacts_common_dir)/res $(phone_common_dir)/res
 asset_dirs := $(contacts_common_dir)/assets
 
+src_dirs += src-N $(contacts_common_dir)/src-N $(phone_common_dir)/src-N
+
 LOCAL_SRC_FILES := $(call all-java-files-under, $(src_dirs))
 LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(res_dirs)) \
     $(support_library_root_dir)/v7/appcompat/res \
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 887d8ab..b3d47db 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -16,8 +16,8 @@
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.android.contacts"
-    android:versionCode="10400"
-    android:versionName="1.4.0">
+    android:versionCode="10401"
+    android:versionName="1.4.1">
 
     <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="23" />
     <original-package android:name="com.android.contacts" />
@@ -53,7 +53,7 @@
     <application
         android:name="com.android.contacts.ContactsApplication"
         android:label="@string/applicationLabel"
-        android:icon="@mipmap/ic_contacts_clr_48cv_44dp"
+        android:icon="@mipmap/ic_contacts_launcher"
         android:taskAffinity="android.task.contacts"
         android:hardwareAccelerated="true"
         android:supportsRtl="true"
@@ -63,7 +63,7 @@
         <!-- The main Contacts activity with the contact list, favorites, and groups. -->
         <activity android:name=".activities.PeopleActivity"
             android:label="@string/launcherActivityLabel"
-            android:theme="@style/PeopleTheme"
+            android:theme="@style/PeopleActivityTheme"
             android:clearTaskOnLaunch="true"
             android:launchMode="singleTop"
             android:resizeableActivity="true"
diff --git a/res/layout-land/contacts_unavailable_fragment_content.xml b/res/layout-land/contacts_unavailable_fragment_content.xml
index 4f26db6..3d5a0b0 100644
--- a/res/layout-land/contacts_unavailable_fragment_content.xml
+++ b/res/layout-land/contacts_unavailable_fragment_content.xml
@@ -69,6 +69,7 @@
             android:layout_gravity="center_horizontal">
 
             <Button
+                style="@style/ContactsUnavailableButtonStyle"
                 android:id="@+id/add_account_button"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
@@ -78,6 +79,7 @@
                 android:text="@string/contacts_unavailable_add_account" />
 
             <Button
+                style="@style/ContactsUnavailableButtonStyle"
                 android:id="@+id/import_contacts_button"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
diff --git a/res/layout-land/people_activity_toolbar.xml b/res/layout-land/people_activity_toolbar.xml
index d33a96c..c110133 100644
--- a/res/layout-land/people_activity_toolbar.xml
+++ b/res/layout-land/people_activity_toolbar.xml
@@ -28,13 +28,15 @@
     <FrameLayout
         android:id="@+id/toolbar_frame"
         android:layout_width="match_parent"
-        android:layout_height="?android:attr/actionBarSize"
+        android:layout_height="?attr/actionBarSize"
         android:background="@color/actionbar_background_color">
 
-        <Toolbar
+        <!-- the attribute padding removes the gap between this Toolbar and its parent FrameLayout on tablet -->
+        <android.support.v7.widget.Toolbar
             android:layout_width="match_parent"
-            android:layout_height="?android:attr/actionBarSize"
+            android:layout_height="?attr/actionBarSize"
             android:id="@+id/toolbar"
+            android:padding="0dp"
             style="@style/ContactsToolbarStyle" />
 
     </FrameLayout>
diff --git a/res/layout/contacts_unavailable_fragment_content.xml b/res/layout/contacts_unavailable_fragment_content.xml
index 9482273..765e453 100644
--- a/res/layout/contacts_unavailable_fragment_content.xml
+++ b/res/layout/contacts_unavailable_fragment_content.xml
@@ -58,6 +58,7 @@
         android:layout_height="wrap_content">
 
         <Button
+            style="@style/ContactsUnavailableButtonStyle"
             android:id="@+id/add_account_button"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
@@ -67,6 +68,7 @@
             android:text="@string/contacts_unavailable_add_account" />
 
         <Button
+            style="@style/ContactsUnavailableButtonStyle"
             android:id="@+id/import_contacts_button"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
diff --git a/res/layout/custom_action_bar.xml b/res/layout/custom_action_bar.xml
index 5b930ea..9604849 100644
--- a/res/layout/custom_action_bar.xml
+++ b/res/layout/custom_action_bar.xml
@@ -28,7 +28,7 @@
         android:layout_height="1px" >
         <requestFocus />
     </View>
-    <SearchView
+    <android.support.v7.widget.SearchView
         android:id="@+id/search_view"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
diff --git a/res/layout/people_activity_toolbar.xml b/res/layout/people_activity_toolbar.xml
index cbb4d91..da1dae4 100644
--- a/res/layout/people_activity_toolbar.xml
+++ b/res/layout/people_activity_toolbar.xml
@@ -24,13 +24,15 @@
     <FrameLayout
         android:id="@+id/toolbar_frame"
         android:layout_width="match_parent"
-        android:layout_height="?android:attr/actionBarSize"
+        android:layout_height="?attr/actionBarSize"
         android:background="@color/actionbar_background_color">
 
-        <Toolbar
+        <!-- the attribute padding removes the gap between this Toolbar and its parent FrameLayout on tablet -->
+        <android.support.v7.widget.Toolbar
             android:layout_width="match_parent"
-            android:layout_height="?android:attr/actionBarSize"
+            android:layout_height="?attr/actionBarSize"
             android:id="@+id/toolbar"
+            android:padding="0dp"
             style="@style/ContactsToolbarStyle" />
 
     </FrameLayout>
@@ -38,7 +40,7 @@
     <com.android.contacts.common.list.ViewPagerTabs
         android:id="@+id/lists_pager_header"
         android:layout_width="match_parent"
-        android:layout_height="?android:attr/actionBarSize"
+        android:layout_height="?attr/actionBarSize"
         android:textAllCaps="true"
         android:orientation="horizontal"
         android:layout_gravity="top"
diff --git a/res/layout/quickcontact_expand_suggestion_card.xml b/res/layout/quickcontact_expand_suggestion_card.xml
index 7b27c86..1d91f87 100644
--- a/res/layout/quickcontact_expand_suggestion_card.xml
+++ b/res/layout/quickcontact_expand_suggestion_card.xml
@@ -155,6 +155,8 @@
                 android:id="@+id/link_button"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:lines="1"
+                android:ellipsize="end"
                 android:text="@string/quickcontact_suggestion_link_button"/>
         </LinearLayout>
     </LinearLayout>
diff --git a/res/layout/selection_bar.xml b/res/layout/selection_bar.xml
index 34cdd60..f91c2b8 100644
--- a/res/layout/selection_bar.xml
+++ b/res/layout/selection_bar.xml
@@ -25,7 +25,7 @@
         android:layout_width="48dp"
         android:layout_height="48dp"
         android:src="@drawable/ic_back_arrow"
-        android:background="?android:attr/selectableItemBackgroundBorderless"
+        android:background="?attr/selectableItemBackgroundBorderless"
         android:contentDescription="@string/action_menu_back_from_search"
         android:layout_gravity="center_vertical|start"
         android:tint="@android:color/white" />
@@ -37,6 +37,6 @@
         android:layout_height="wrap_content"
         android:visibility="gone"
         android:layout_gravity="center_vertical|start"
-        style="@style/ContactsActionBarTitleText" />
+        style="@style/ContactsActionBarTitleTextAppCompat" />
 
 </FrameLayout>
diff --git a/res/menu/people_options.xml b/res/menu/people_options.xml
index 1dd4dc4..6b604c1 100644
--- a/res/menu/people_options.xml
+++ b/res/menu/people_options.xml
@@ -13,12 +13,13 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:contacts="http://schemas.android.com/apk/res-auto">
     <item
         android:id="@+id/menu_search"
         android:icon="@drawable/ic_ab_search"
         android:title="@string/menu_search"
-        android:showAsAction="ifRoom" />
+        contacts:showAsAction="ifRoom" />
 
     <item
         android:id="@+id/menu_contacts_filter"
diff --git a/res/menu/search_menu.xml b/res/menu/search_menu.xml
index 355442e..c890f20 100644
--- a/res/menu/search_menu.xml
+++ b/res/menu/search_menu.xml
@@ -13,10 +13,11 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:contacts="http://schemas.android.com/apk/res-auto">
     <item
         android:id="@+id/menu_search"
         android:icon="@drawable/ic_ab_search"
         android:title="@string/menu_search"
-        android:showAsAction="always" />
+        contacts:showAsAction="always" />
 </menu>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index c3478cd..7df52c0 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -108,6 +108,15 @@
         <item name="favorites_padding_bottom">0dip</item>
     </style>
 
+    <style name="PeopleActivityTheme" parent="@style/PeopleThemeAppCompat">
+        <item name="windowActionBar">false</item>
+        <item name="windowNoTitle">true</item>
+        <item name="android:listSelector">?android:attr/listChoiceBackgroundIndicator</item>
+    </style>
+
+    <style name="ContactsUnavailableButtonStyle" parent="@style/Widget.AppCompat.Button.Colored">
+    </style>
+
     <style name="PeopleThemeAppCompat" parent="Theme.AppCompat.Light">
         <!-- Styles that require AppCompat compatibility, remember to update both sets -->
         <item name="android:actionBarStyle">@style/ContactsActionBarStyleAppCompat</item>
@@ -123,6 +132,7 @@
         <item name="homeAsUpIndicator">@drawable/ic_back_arrow</item>
         <!-- Style for the overflow button in the actionbar. -->
         <item name="android:actionOverflowButtonStyle">@style/ContactsActionBarOverflowQP</item>
+        <item name="actionOverflowButtonStyle">@style/ContactsActionBarOverflowQP</item>
         <item name="android:actionModeCloseDrawable">@drawable/ic_close_lt</item>
         <item name="android:fastScrollThumbDrawable">@drawable/fastscroll_thumb</item>
         <item name="android:fastScrollTrackDrawable">@null</item>
@@ -194,8 +204,8 @@
         <!-- Styles that require AppCompat compatibility, remember to update both sets -->
         <item name="android:background">@color/actionbar_background_color</item>
         <item name="background">@color/actionbar_background_color</item>
-        <item name="android:titleTextStyle">@style/ContactsActionBarTitleText</item>
-        <item name="titleTextStyle">@style/ContactsActionBarTitleText</item>
+        <item name="android:titleTextStyle">@style/ContactsActionBarTitleTextAppCompat</item>
+        <item name="titleTextStyle">@style/ContactsActionBarTitleTextAppCompat</item>
         <item name="android:backgroundStacked">@color/actionbar_background_color</item>
         <item name="backgroundStacked">@color/actionbar_background_color</item>
         <!-- Empty icon -->
@@ -209,20 +219,25 @@
 
     <!-- When this style was added, android:toolbarStyle was private. Therefore, this style
          must be directly applied to every toolbar -->
-    <style name="ContactsToolbarStyle" parent="@android:style/Widget.Toolbar">
-        <item name="android:titleTextAppearance">@style/ContactsActionBarTitleText</item>
+    <style name="ContactsToolbarStyle" parent="@style/Widget.AppCompat.Toolbar">
+        <!-- Styles that require AppCompat compatibility, remember to update both sets -->
+        <item name="android:titleTextAppearance">@style/ContactsActionBarTitleTextAppCompat</item>
+        <item name="titleTextAppearance">@style/ContactsActionBarTitleTextAppCompat</item>
     </style>
 
-    <style name="ContactsPickerActionBarStyle" parent="@style/ContactsActionBarStyle">
+    <style name="ContactsPickerActionBarStyle" parent="@style/ContactsActionBarStyleAppCompat">
         <!-- when first loading, don't show title or up button -->
         <item name="android:displayOptions"></item>
     </style>
 
-    <style name="ContactPickerSearchTheme" parent="@style/PeopleTheme">
+    <style name="ContactPickerSearchTheme" parent="@style/PeopleThemeAppCompat">
         <item name="android:textColorPrimary">@android:color/white</item>
         <item name="android:textColorHint">?android:textColorHintInverse</item>
+        <!-- Styles that require AppCompat compatibility, remember to update both sets -->
         <item name="android:colorControlActivated">?android:textColorHintInverse</item>
+        <item name="colorControlActivated">?android:textColorHintInverse</item>
         <item name="android:colorControlNormal">@android:color/white</item>
+        <item name="colorControlNormal">@android:color/white</item>
     </style>
 
     <!-- Text in the action bar at the top of the screen -->
@@ -231,6 +246,10 @@
         <item name="android:textColor">@color/actionbar_text_color</item>
     </style>
 
+    <style name="ContactsActionBarTitleTextAppCompat" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
+        <item name="android:textColor">@color/actionbar_text_color</item>
+    </style>
+
     <!-- Styling for the tab bar; handles styling of the divider line. -->
     <style name="ContactsActionBarTabBarStyle"
            parent="@android:style/Widget.Material.ActionBar.TabBar">
@@ -249,7 +268,7 @@
 
     <!-- Action bar overflow menu icon. -->
     <style name="ContactsActionBarOverflowQP"
-           parent="@android:style/Widget.Material.Light.ActionButton.Overflow">
+           parent="Widget.AppCompat.Light.ActionButton.Overflow">
         <item name="android:src">@drawable/ic_menu_overflow_lt</item>
     </style>
 
@@ -268,8 +287,11 @@
         <item name="android:listSelector">?android:attr/listChoiceBackgroundIndicator</item>
     </style>
 
-    <style name="ContactPickerTheme" parent="@style/PeopleTheme" >
+    <style name="ContactPickerTheme" parent="@style/PeopleThemeAppCompat">
+        <!-- Styles that require AppCompat compatibility, remember to update both sets -->
         <item name="android:actionBarStyle">@style/ContactsPickerActionBarStyle</item>
+        <item name="actionBarStyle">@style/ContactsPickerActionBarStyle</item>
+        <item name="android:listSelector">?android:attr/listChoiceBackgroundIndicator</item>
     </style>
 
     <style name="ContactPickerLayout" parent="ContactPickerTheme">
diff --git a/src/com/android/contacts/AppCompatContactsActivity.java b/src/com/android/contacts/AppCompatContactsActivity.java
new file mode 100644
index 0000000..cd5a79f
--- /dev/null
+++ b/src/com/android/contacts/AppCompatContactsActivity.java
@@ -0,0 +1,130 @@
+/*
+ * 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.
+ */
+
+package com.android.contacts;
+
+import android.app.Fragment;
+import android.app.FragmentManager;
+import android.app.FragmentTransaction;
+import android.content.ContentResolver;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.view.View;
+
+import com.android.contacts.common.activity.AppCompatTransactionSafeActivity;
+import com.android.contacts.common.testing.InjectedServices;
+
+/**
+ * A common superclass for Contacts activities that handles application-wide services, copied from
+ * {@link com.android.contacts.ContactsActivity}, which will be deprecated after Kitkat backporting
+ * is done.
+ */
+public abstract class AppCompatContactsActivity extends AppCompatTransactionSafeActivity
+    implements ContactSaveService.Listener {
+
+    private ContentResolver mContentResolver;
+
+    @Override
+    public ContentResolver getContentResolver() {
+        if (mContentResolver == null) {
+            InjectedServices services = ContactsApplication.getInjectedServices();
+            if (services != null) {
+                mContentResolver = services.getContentResolver();
+            }
+            if (mContentResolver == null) {
+                mContentResolver = super.getContentResolver();
+            }
+        }
+        return mContentResolver;
+    }
+
+    @Override
+    public SharedPreferences getSharedPreferences(String name, int mode) {
+        InjectedServices services = ContactsApplication.getInjectedServices();
+        if (services != null) {
+            SharedPreferences prefs = services.getSharedPreferences();
+            if (prefs != null) {
+                return prefs;
+            }
+        }
+
+        return super.getSharedPreferences(name, mode);
+    }
+
+    @Override
+    public Object getSystemService(String name) {
+        Object service = super.getSystemService(name);
+        if (service != null) {
+            return service;
+        }
+
+        return getApplicationContext().getSystemService(name);
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        ContactSaveService.registerListener(this);
+        super.onCreate(savedInstanceState);
+    }
+
+    @Override
+    protected void onDestroy() {
+        ContactSaveService.unregisterListener(this);
+        super.onDestroy();
+    }
+
+    @Override
+    public void onServiceCompleted(Intent callbackIntent) {
+        onNewIntent(callbackIntent);
+    }
+
+    /**
+     * Convenient version of {@link FragmentManager#findFragmentById(int)}, which throws
+     * an exception if the fragment doesn't exist.
+     */
+    @SuppressWarnings("unchecked")
+    public <T extends Fragment> T getFragment(int id) {
+        T result = (T)getFragmentManager().findFragmentById(id);
+        if (result == null) {
+            throw new IllegalArgumentException("fragment 0x" + Integer.toHexString(id)
+                    + " doesn't exist");
+        }
+        return result;
+    }
+
+    /**
+     * Convenient version of {@link #findViewById(int)}, which throws
+     * an exception if the view doesn't exist.
+     */
+    @SuppressWarnings("unchecked")
+    public <T extends View> T getView(int id) {
+        T result = (T)findViewById(id);
+        if (result == null) {
+            throw new IllegalArgumentException("view 0x" + Integer.toHexString(id)
+                    + " doesn't exist");
+        }
+        return result;
+    }
+
+    protected static void showFragment(FragmentTransaction ft, Fragment f) {
+        if ((f != null) && f.isHidden()) ft.show(f);
+    }
+
+    protected static void hideFragment(FragmentTransaction ft, Fragment f) {
+        if ((f != null) && !f.isHidden()) ft.hide(f);
+    }
+}
diff --git a/src/com/android/contacts/ContactsApplication.java b/src/com/android/contacts/ContactsApplication.java
index 798614c..f0dc91b 100644
--- a/src/com/android/contacts/ContactsApplication.java
+++ b/src/com/android/contacts/ContactsApplication.java
@@ -29,16 +29,13 @@
 import android.provider.ContactsContract.Contacts;
 import android.util.Log;
 
-import com.android.contacts.common.ContactPhotoManager;
-import com.android.contacts.common.list.ContactListFilterController;
-import com.android.contacts.common.model.AccountTypeManager;
 import com.android.contacts.common.testing.InjectedServices;
 import com.android.contacts.common.util.Constants;
 import com.android.contacts.commonbind.analytics.AnalyticsUtil;
 
 import com.google.common.annotations.VisibleForTesting;
 
-public final class ContactsApplication extends Application {
+public class ContactsApplication extends Application {
     private static final boolean ENABLE_LOADER_LOG = false; // Don't submit with true
     private static final boolean ENABLE_FRAGMENT_LOG = false; // Don't submit with true
 
@@ -48,8 +45,6 @@
      * To enable: adb shell setprop log.tag.ContactsStrictMode DEBUG
      */
     public static final String STRICT_MODE_TAG = "ContactsStrictMode";
-    private ContactPhotoManager mContactPhotoManager;
-    private ContactListFilterController mContactListFilterController;
 
     /**
      * Overrides the system services with mocks for testing.
diff --git a/src/com/android/contacts/activities/ActionBarAdapter.java b/src/com/android/contacts/activities/ActionBarAdapter.java
index e47f60c..0f1dbbb 100644
--- a/src/com/android/contacts/activities/ActionBarAdapter.java
+++ b/src/com/android/contacts/activities/ActionBarAdapter.java
@@ -17,7 +17,6 @@
 package com.android.contacts.activities;
 
 import android.animation.ValueAnimator;
-import android.app.ActionBar;
 import android.app.Activity;
 import android.content.Context;
 import android.content.SharedPreferences;
@@ -25,6 +24,8 @@
 import android.os.Bundle;
 import android.preference.PreferenceManager;
 import android.support.v4.content.ContextCompat;
+import android.support.v7.app.ActionBar;
+import android.support.v7.widget.Toolbar;
 import android.text.Editable;
 import android.text.TextUtils;
 import android.text.TextWatcher;
@@ -39,7 +40,6 @@
 import android.view.View.OnClickListener;
 import android.widget.EditText;
 import android.widget.TextView;
-import android.widget.Toolbar;
 
 import com.android.contacts.R;
 import com.android.contacts.activities.ActionBarAdapter.Listener.Action;
diff --git a/src/com/android/contacts/activities/ContactSelectionActivity.java b/src/com/android/contacts/activities/ContactSelectionActivity.java
index 13228e4..33c3f38 100644
--- a/src/com/android/contacts/activities/ContactSelectionActivity.java
+++ b/src/com/android/contacts/activities/ContactSelectionActivity.java
@@ -16,8 +16,6 @@
 
 package com.android.contacts.activities;
 
-import android.app.ActionBar;
-import android.app.ActionBar.LayoutParams;
 import android.app.Activity;
 import android.app.Fragment;
 import android.content.ActivityNotFoundException;
@@ -27,6 +25,8 @@
 import android.os.Bundle;
 import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.Intents.Insert;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.ActionBar.LayoutParams;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.LayoutInflater;
@@ -37,12 +37,12 @@
 import android.view.View.OnClickListener;
 import android.view.View.OnFocusChangeListener;
 import android.view.inputmethod.InputMethodManager;
-import android.widget.SearchView;
-import android.widget.SearchView.OnCloseListener;
-import android.widget.SearchView.OnQueryTextListener;
+import android.support.v7.widget.SearchView;
+import android.support.v7.widget.SearchView.OnCloseListener;
+import android.support.v7.widget.SearchView.OnQueryTextListener;
 import android.widget.Toast;
 
-import com.android.contacts.ContactsActivity;
+import com.android.contacts.AppCompatContactsActivity;
 import com.android.contacts.R;
 import com.android.contacts.common.activity.RequestPermissionsActivity;
 import com.android.contacts.common.list.ContactEntryListFragment;
@@ -70,7 +70,7 @@
  * Displays a list of contacts (or phone numbers or postal addresses) for the
  * purposes of selecting one.
  */
-public class ContactSelectionActivity extends ContactsActivity
+public class ContactSelectionActivity extends AppCompatContactsActivity
         implements View.OnCreateContextMenuListener, OnQueryTextListener, OnClickListener,
                 OnCloseListener, OnFocusChangeListener {
     private static final String TAG = "ContactSelectionActivity";
@@ -138,7 +138,7 @@
     }
 
     private void prepareSearchViewAndActionBar() {
-        final ActionBar actionBar = getActionBar();
+        final ActionBar actionBar = getSupportActionBar();
         mSearchViewContainer = LayoutInflater.from(actionBar.getThemedContext())
                 .inflate(R.layout.custom_action_bar, null);
         mSearchView = (SearchView) mSearchViewContainer.findViewById(R.id.search_view);
@@ -181,7 +181,7 @@
     }
 
     private void configureSearchMode() {
-        final ActionBar actionBar = getActionBar();
+        final ActionBar actionBar = getSupportActionBar();
         if (mIsSearchMode) {
             actionBar.setDisplayShowTitleEnabled(false);
             mSearchViewContainer.setVisibility(View.VISIBLE);
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index 14849e1..7f06629 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -40,6 +40,7 @@
 import android.support.v13.app.FragmentPagerAdapter;
 import android.support.v4.view.PagerAdapter;
 import android.support.v4.view.ViewPager;
+import android.support.v7.widget.Toolbar;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.KeyCharacterMap;
@@ -52,9 +53,8 @@
 import android.view.Window;
 import android.widget.ImageButton;
 import android.widget.Toast;
-import android.widget.Toolbar;
 
-import com.android.contacts.ContactsActivity;
+import com.android.contacts.AppCompatContactsActivity;
 import com.android.contacts.R;
 import com.android.contacts.activities.ActionBarAdapter.TabState;
 import com.android.contacts.common.ContactsUtils;
@@ -102,7 +102,7 @@
 /**
  * Displays a list to browse contacts.
  */
-public class PeopleActivity extends ContactsActivity implements
+public class PeopleActivity extends AppCompatContactsActivity implements
         View.OnCreateContextMenuListener,
         View.OnClickListener,
         ActionBarAdapter.Listener,
@@ -300,10 +300,6 @@
     }
 
     private void createViewsAndFragments(Bundle savedState) {
-        // Disable the ActionBar so that we can use a Toolbar. This needs to be called before
-        // setContentView().
-        getWindow().requestFeature(Window.FEATURE_NO_TITLE);
-
         setContentView(R.layout.people_activity);
 
         final FragmentManager fragmentManager = getFragmentManager();
@@ -319,9 +315,9 @@
         mTabPager.setAdapter(mTabPagerAdapter);
         mTabPager.setOnPageChangeListener(mTabPagerListener);
 
-        // Configure toolbar and toolbar tabs. If in landscape mode, we  configure tabs differntly.
+        // Configure toolbar and toolbar tabs. If in landscape mode, we configure tabs differently.
         final Toolbar toolbar = getView(R.id.toolbar);
-        setActionBar(toolbar);
+        setSupportActionBar(toolbar);
         final ViewPagerTabs portraitViewPagerTabs
                 = (ViewPagerTabs) findViewById(R.id.lists_pager_header);
         ViewPagerTabs landscapeViewPagerTabs = null;
@@ -372,7 +368,7 @@
         // Setting Properties after fragment is created
         mFavoritesFragment.setDisplayType(DisplayType.STREQUENT);
 
-        mActionBarAdapter = new ActionBarAdapter(this, this, getActionBar(),
+        mActionBarAdapter = new ActionBarAdapter(this, this, getSupportActionBar(),
                 portraitViewPagerTabs, landscapeViewPagerTabs, toolbar);
         mActionBarAdapter.initialize(savedState, mRequest);
 
diff --git a/src/com/android/contacts/logging/Logger.java b/src/com/android/contacts/logging/Logger.java
new file mode 100644
index 0000000..a290d80
--- /dev/null
+++ b/src/com/android/contacts/logging/Logger.java
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+package com.android.contacts.logging;
+
+import android.app.Activity;
+import android.app.Application;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.contacts.commonbind.analytics.AnalyticsUtil;
+
+/**
+ * Logs analytics events.
+ */
+public abstract class Logger {
+    public static final String TAG = "Logger";
+
+    public static Logger getInstance() {
+        return null;
+    }
+
+    /**
+     * Logs an event indicating that a screen was displayed.
+     *
+     * @param screenType integer identifier of the displayed screen
+     * @param activity Parent activity of the displayed screen.
+     */
+    public static void logScreenView(int screenType, Activity activity) {
+        final Logger logger = getInstance();
+        if (logger != null) {
+            logger.logScreenViewImpl(screenType);
+        }
+
+        final String screenName = ScreenEvent.getScreenName(screenType);
+        if (TextUtils.isEmpty(screenName)) {
+            Log.w(TAG, "Unknown screenType: " + screenType);
+        } else {
+            AnalyticsUtil.sendScreenView(screenName, activity, /* tag */ null);
+        }
+    }
+
+    public abstract void logScreenViewImpl(int screenType);
+}
diff --git a/src/com/android/contacts/logging/ScreenEvent.java b/src/com/android/contacts/logging/ScreenEvent.java
new file mode 100644
index 0000000..5b1b6bb
--- /dev/null
+++ b/src/com/android/contacts/logging/ScreenEvent.java
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+package com.android.contacts.logging;
+
+import android.text.TextUtils;
+
+import com.android.contacts.activities.PeopleActivity;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Stores constants identifying individual screens/dialogs/fragments in the application, and also
+ * provides a mapping of integer id -> screen name mappings for analytics purposes.
+ */
+public class ScreenEvent {
+    private static final Map<Integer, String> sScreenNameMap = new HashMap<>();
+
+    private static final String FRAGMENT_TAG_SEPARATOR = "#";
+
+    public static final int UNKNOWN = 0;
+
+    public static final int SEARCH = 1;
+
+    static {
+        sScreenNameMap.put(SEARCH, getScreenNameWithTag(
+                PeopleActivity.class.getSimpleName(), "Search"));
+    }
+
+    /**
+     * For a given screen type, returns the actual screen name that is used for logging/analytics
+     * purposes.
+     *
+     * @param screenType unique ID of a type of screen
+     *
+     * @return the tagged version of the screen name corresponding to the provided screenType,
+     *         or {@null} if the provided screenType is unknown.
+     */
+    public static String getScreenName(int screenType) {
+        return sScreenNameMap.get(screenType);
+    }
+
+    /**
+     * Build a tagged version of the provided screenName if the tag is non-empty.
+     *
+     * @param screenName Name of the screen.
+     * @param tag Optional tag describing the screen.
+     * @return the unchanged screenName if the tag is {@code null} or empty, the tagged version of
+     *         the screenName otherwise.
+     */
+    public static String getScreenNameWithTag(String screenName, String tag) {
+        if (TextUtils.isEmpty(tag)) {
+            return screenName;
+        }
+        return screenName + FRAGMENT_TAG_SEPARATOR + tag;
+    }
+}
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index cf95386..734eb73 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -31,6 +31,7 @@
 import android.content.Loader;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
+import android.content.res.ColorStateList;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
@@ -610,6 +611,12 @@
         }
 
         final CheckBox checkbox = (CheckBox) suggestionView.findViewById(R.id.suggestion_checkbox);
+        final int[][] stateSet = new int[][] {
+                new int[] { android.R.attr.state_checked },
+                new int[] { -android.R.attr.state_checked }
+        };
+        final int[] colors = new int[] { mColorFilterColor, mColorFilterColor };
+        checkbox.setButtonTintList(new ColorStateList(stateSet, colors));
         checkbox.setChecked(mSuggestionsShouldAutoSelected ||
                 mSelectedAggregationIds.contains(suggestion.contactId));
         if (checkbox.isChecked()) {
@@ -644,9 +651,7 @@
 
     private void enableLinkButton() {
         mSuggestionsLinkButton.setClickable(true);
-        mSuggestionsLinkButton.getBackground().setColorFilter(
-                ContextCompat.getColor(this, R.color.primary_color),
-                PorterDuff.Mode.SRC_ATOP);
+        mSuggestionsLinkButton.getBackground().setColorFilter(mColorFilter);
         mSuggestionsLinkButton.setTextColor(
                 ContextCompat.getColor(this, android.R.color.white));
         mSuggestionsLinkButton.setOnClickListener(new OnClickListener() {
@@ -2319,6 +2324,7 @@
         mContactCard.setColorAndFilter(mColorFilterColor, mColorFilter);
         mRecentCard.setColorAndFilter(mColorFilterColor, mColorFilter);
         mAboutCard.setColorAndFilter(mColorFilterColor, mColorFilter);
+        mSuggestionsCancelButton.setTextColor(mColorFilterColor);
     }
 
     private void updateStatusBarColor() {
diff --git a/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java b/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java
index fcd3e8b..6514d23 100644
--- a/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java
+++ b/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java
@@ -47,7 +47,7 @@
 
 import com.android.contacts.tests.R;
 
-import com.google.common.collect.Lists;
+import java.util.ArrayList;
 
 /**
  * An activity that provides access to various modes of the contacts application.
@@ -631,6 +631,10 @@
         row2.put(Email.LABEL, "Green Bot");
         row2.put(Email.ADDRESS, "android@android.com");
 
-        intent.putParcelableArrayListExtra(Insert.DATA, Lists.newArrayList(row1, row2));
+        final ArrayList<ContentValues> rows = new ArrayList<>();
+        rows.add(row1);
+        rows.add(row2);
+
+        intent.putParcelableArrayListExtra(Insert.DATA, rows);
     }
 }