Merge "Remove one more layer of view hierarchy."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 12e0e3b..5a645a0 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -39,6 +39,9 @@
     <uses-permission android:name="android.permission.USE_CREDENTIALS" />
     <uses-permission android:name="android.permission.VIBRATE" />
     <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
+    <uses-permission android:name="com.android.voicemail.permission.ADD_VOICEMAIL" />
+    <!-- TODO: get rid of READ_WRITE_OWN_VOICEMAIL permission when voicemail provider has been
+    modified to support ADD_VOICEMAIL -->
     <uses-permission android:name="com.android.voicemail.permission.READ_WRITE_OWN_VOICEMAIL" />
     <uses-permission android:name="com.android.voicemail.permission.READ_WRITE_ALL_VOICEMAIL" />
     <!-- allow broadcasting secret code intents that reboot the phone -->
@@ -399,6 +402,7 @@
             android:theme="@style/Theme.QuickContact"
             android:launchMode="singleTop"
             android:excludeFromRecents="true"
+            android:noHistory="true"
             android:taskAffinity="android.task.quickcontact"
             android:windowSoftInputMode="stateUnchanged">
 
diff --git a/res/drawable-hdpi/call_log_action_bar_bg.9.png b/res/drawable-hdpi/call_log_action_bar_bg.9.png
deleted file mode 100644
index 2e4d0ca..0000000
--- a/res/drawable-hdpi/call_log_action_bar_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/divider_horizontal_light.png b/res/drawable-hdpi/divider_horizontal_light.png
deleted file mode 100644
index 20d7a01..0000000
--- a/res/drawable-hdpi/divider_horizontal_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_call_log_home.png b/res/drawable-hdpi/ic_call_log_home.png
deleted file mode 100644
index c7c8f16..0000000
--- a/res/drawable-hdpi/ic_call_log_home.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_call_log_list_action_play.png b/res/drawable-hdpi/ic_call_log_list_action_play.png
deleted file mode 100644
index db19cdd..0000000
--- a/res/drawable-hdpi/ic_call_log_list_action_play.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_contacts_details.png b/res/drawable-hdpi/ic_contacts_details.png
deleted file mode 100755
index 35f8106..0000000
--- a/res/drawable-hdpi/ic_contacts_details.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/quickactions_icon_activated.9.png b/res/drawable-hdpi/quickactions_icon_activated.9.png
deleted file mode 100644
index dd68562..0000000
--- a/res/drawable-hdpi/quickactions_icon_activated.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/statusbox_landscape_holo_light.9.png b/res/drawable-hdpi/statusbox_landscape_holo_light.9.png
deleted file mode 100644
index 12001e6..0000000
--- a/res/drawable-hdpi/statusbox_landscape_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/statusbox_portrait_holo_light.9.png b/res/drawable-hdpi/statusbox_portrait_holo_light.9.png
deleted file mode 100644
index 6dcb8c0..0000000
--- a/res/drawable-hdpi/statusbox_portrait_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/call_log_action_bar_bg.9.png b/res/drawable-mdpi/call_log_action_bar_bg.9.png
deleted file mode 100644
index 2e4d0ca..0000000
--- a/res/drawable-mdpi/call_log_action_bar_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/divider_horizontal_light.png b/res/drawable-mdpi/divider_horizontal_light.png
deleted file mode 100644
index 20d7a01..0000000
--- a/res/drawable-mdpi/divider_horizontal_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_call_log_home.png b/res/drawable-mdpi/ic_call_log_home.png
deleted file mode 100644
index c7c8f16..0000000
--- a/res/drawable-mdpi/ic_call_log_home.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_call_log_list_action_play.png b/res/drawable-mdpi/ic_call_log_list_action_play.png
deleted file mode 100644
index db19cdd..0000000
--- a/res/drawable-mdpi/ic_call_log_list_action_play.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_contacts_details.png b/res/drawable-mdpi/ic_contacts_details.png
deleted file mode 100644
index 7e71b85..0000000
--- a/res/drawable-mdpi/ic_contacts_details.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/quickactions_icon_activated.9.png b/res/drawable-mdpi/quickactions_icon_activated.9.png
deleted file mode 100644
index 00479b8..0000000
--- a/res/drawable-mdpi/quickactions_icon_activated.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/statusbox_landscape_holo_light.9.png b/res/drawable-mdpi/statusbox_landscape_holo_light.9.png
deleted file mode 100644
index e274c84..0000000
--- a/res/drawable-mdpi/statusbox_landscape_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/statusbox_portrait_holo_light.9.png b/res/drawable-mdpi/statusbox_portrait_holo_light.9.png
deleted file mode 100644
index 803b866..0000000
--- a/res/drawable-mdpi/statusbox_portrait_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_contacts_details.png b/res/drawable-xhdpi/ic_contacts_details.png
deleted file mode 100644
index 8d72566..0000000
--- a/res/drawable-xhdpi/ic_contacts_details.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/statusbox_landscape_holo_light.9.png b/res/drawable-xhdpi/statusbox_landscape_holo_light.9.png
deleted file mode 100644
index 345c227..0000000
--- a/res/drawable-xhdpi/statusbox_landscape_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/statusbox_portrait_holo_light.9.png b/res/drawable-xhdpi/statusbox_portrait_holo_light.9.png
deleted file mode 100644
index 914d5e0..0000000
--- a/res/drawable-xhdpi/statusbox_portrait_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/res/layout-sw580dp/group_editor_account_header.xml b/res/layout-sw580dp/group_editor_account_header.xml
deleted file mode 100644
index a38266d..0000000
--- a/res/layout-sw580dp/group_editor_account_header.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<!-- Account info header for group editor -->
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_height="wrap_content"
-    android:layout_width="match_parent"
-    android:layout_marginBottom="10dip"
-    android:orientation="horizontal">
-
-    <TextView
-        android:id="@+id/account_type"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:textAppearance="?android:attr/textAppearanceMedium"
-        android:textColor="?android:attr/textColorPrimary"
-        android:singleLine="true"
-        android:layout_gravity="center_vertical" />
-
-    <ImageView
-        android:id="@+id/account_icon"
-        android:layout_width="30dip"
-        android:layout_height="30dip"
-        android:layout_marginLeft="7dip"
-        android:layout_marginRight="7dip"
-        android:layout_centerVertical="true"/>
-
-    <TextView
-        android:id="@+id/account_name"
-        android:layout_width="0dip"
-        android:layout_height="wrap_content"
-        android:layout_weight="1"
-        android:textAppearance="?android:attr/textAppearanceSmall"
-        android:textColor="?android:attr/textColorPrimary"
-        android:layout_gravity="center_vertical"
-        android:gravity="right"
-        android:singleLine="true" />
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout-sw580dp/simple_contact_detail_header_view_list_item.xml b/res/layout-sw580dp/simple_contact_detail_header_view_list_item.xml
deleted file mode 100644
index 5960022..0000000
--- a/res/layout-sw580dp/simple_contact_detail_header_view_list_item.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<!--
-  This view temporarily holds the extra information that used to be in the
-  original contact detail header view, but now must move into the list because
-  of the new tab carousel. TODO: Integrate this better into the list as provided
-  by the mocks.
--->
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical"
-    android:paddingTop="20dip">
-
-    <ImageView
-        android:id="@+id/photo"
-        android:scaleType="centerCrop"
-        android:layout_width="@dimen/detail_contact_photo_size"
-        android:layout_height="@dimen/detail_contact_photo_size" />
-
-    <TextView
-        android:id="@+id/name"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:textAppearance="?android:attr/textAppearanceLarge"
-        android:textSize="36sp" />
-
-    <TextView
-        android:id="@+id/company"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:textAppearance="?android:attr/textAppearanceMedium" />
-
-    <CheckBox
-        android:id="@+id/star"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="top"
-        android:contentDescription="@string/description_star"
-        style="?android:attr/starStyle" />
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout-sw580dp/total_contacts.xml b/res/layout-sw580dp/total_contacts.xml
deleted file mode 100644
index 8c05119..0000000
--- a/res/layout-sw580dp/total_contacts.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-
-<RelativeLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="47dip"
-    android:paddingLeft="5dp"
-    android:paddingRight="7dp"
-    >
-
-    <TextView
-        android:id="@+id/totalContactsText"
-        android:layout_width="wrap_content"
-        android:layout_height="match_parent"
-        android:textColor="#ff666666"
-        android:textSize="14sp"
-        android:textStyle="normal"
-        android:layout_alignParentLeft="true"
-        android:gravity="center_vertical"
-    />
-
-</RelativeLayout>
diff --git a/res/layout/edit_contact_entry_voicemail.xml b/res/layout/edit_contact_entry_voicemail.xml
deleted file mode 100644
index 73c65d9..0000000
--- a/res/layout/edit_contact_entry_voicemail.xml
+++ /dev/null
@@ -1,77 +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:id="@+id/checkable"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:paddingRight="?android:attr/scrollbarSize"
-    android:minHeight="?android:attr/listPreferredItemHeight"
-    android:background="@android:drawable/list_selector_background"
-    android:orientation="horizontal"
-    android:gravity="center_vertical"
-    android:focusable="true"
-    android:clickable="true"
-    >
-
-    <RelativeLayout
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginLeft="14dip"
-        android:layout_marginTop="6dip"
-        android:layout_marginBottom="6dip"
-        android:layout_weight="1"
-        android:duplicateParentState="true"
-        >
-
-        <TextView android:id="@+id/label"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:singleLine="true"
-            android:textAppearance="?android:attr/textAppearanceMedium"
-            android:ellipsize="marquee"
-            android:fadingEdge="horizontal"
-            android:duplicateParentState="true"
-            />
-
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_below="@+id/label"
-            android:layout_alignLeft="@+id/label"
-            android:textAppearance="?android:attr/textAppearanceSmall"
-            android:text="@string/send_to_voicemail_checkbox"
-            android:maxLines="2"
-            android:duplicateParentState="true"
-            />
-
-    </RelativeLayout>
-
-    <CheckBox android:id="@+id/checkbox"
-        android:layout_width="wrap_content"
-        android:layout_height="match_parent"
-        android:focusable="false"
-        android:clickable="false"
-        />
-
-    <!-- Need to provide a data view to make binder happy -->
-    <TextView android:id="@+id/data"
-        android:layout_width="0dip"
-        android:layout_height="0dip"
-        android:visibility="gone"
-        />
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/preference_with_more_button.xml b/res/layout/preference_with_more_button.xml
deleted file mode 100644
index e61f891..0000000
--- a/res/layout/preference_with_more_button.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 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/preference"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:paddingRight="?android:attr/scrollbarSize"
-    android:minHeight="?android:attr/listPreferredItemHeight"
-    android:background="@android:drawable/list_selector_background"
-    android:orientation="horizontal"
-    android:gravity="center_vertical"
-    >
-
-    <RelativeLayout
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginLeft="14dip"
-        android:layout_marginTop="6dip"
-        android:layout_marginBottom="6dip"
-        android:layout_weight="1"
-        android:duplicateParentState="true"
-        >
-
-        <TextView android:id="@+id/label"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:singleLine="true"
-            android:textAppearance="?android:attr/textAppearanceMedium"
-            android:ellipsize="marquee"
-            android:fadingEdge="horizontal"
-            android:duplicateParentState="true"
-            />
-
-        <TextView android:id="@+id/data"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_below="@+id/label"
-            android:layout_alignLeft="@+id/label"
-            android:textAppearance="?android:attr/textAppearanceSmall"
-            android:maxLines="2"
-            android:duplicateParentState="true"
-            />
-
-    </RelativeLayout>
-
-    <ImageView
-        android:src="@drawable/ic_menu_expander_minimized_holo_light"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        />
-
-</LinearLayout>
diff --git a/res/layout/total_contacts.xml b/res/layout/total_contacts.xml
deleted file mode 100644
index 1cac674..0000000
--- a/res/layout/total_contacts.xml
+++ /dev/null
@@ -1,37 +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.
--->
-
-<RelativeLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="28dip"
-    android:background="@drawable/infobar_dark"
-    android:paddingLeft="5dp"
-    android:paddingRight="7dp"
-    >
-
-    <TextView 
-        android:id="@+id/totalContactsText"
-        android:layout_width="wrap_content"
-        android:layout_height="match_parent"
-        android:textColor="#ffbfbfbf"
-        android:textSize="14sp"
-        android:textStyle="normal"
-        android:layout_alignParentLeft="true"
-        android:gravity="center_vertical"
-    />
-
-</RelativeLayout>
diff --git a/res/menu/call_details_options.xml b/res/menu/call_details_options.xml
index 0db32a4..634c951 100644
--- a/res/menu/call_details_options.xml
+++ b/res/menu/call_details_options.xml
@@ -18,12 +18,14 @@
         android:id="@+id/menu_share_voicemail"
         android:icon="@drawable/ic_share_holo_dark"
         android:showAsAction="ifRoom"
+        android:title="@string/recentCalls_shareVoicemail"
         android:onClick="onMenuShareVoicemail"
     />
     <item
         android:id="@+id/menu_trash"
         android:icon="@drawable/ic_trash_holo_dark"
         android:showAsAction="ifRoom"
+        android:title="@string/recentCalls_trashVoicemail"
         android:onClick="onMenuTrashVoicemail"
     />
     <item
diff --git a/res/values-sw580dp/styles.xml b/res/values-sw580dp/styles.xml
index fb4e82b..0c4c8ba 100644
--- a/res/values-sw580dp/styles.xml
+++ b/res/values-sw580dp/styles.xml
@@ -79,10 +79,6 @@
         <item name="android:layout_height">match_parent</item>
     </style>
 
-    <style name="CallDetailActivityTheme" parent="@android:Theme.Dialog">
-        <item name="android:windowContentOverlay">@null</item>
-    </style>
-
     <style name="ContactDetailActivityTheme" parent="@android:Theme.Dialog">
         <item name="android:windowContentOverlay">@null</item>
     </style>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index b1f9f6f..908e1c0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -426,6 +426,12 @@
     <!-- Menu item used to remove all calls from the call log -->
     <string name="recentCalls_deleteAll">Clear call log</string>
 
+    <!-- Menu item used to delete a voicemail. [CHAR LIMIT=30] -->
+    <string name="recentCalls_trashVoicemail">Delete voicemail</string>
+
+    <!-- Menu item used to share a voicemail. [CHAR LIMIT=30] -->
+    <string name="recentCalls_shareVoicemail">Share voicemail</string>
+
     <!-- Text displayed when the call log is empty -->
     <string name="recentCalls_empty">Call log is empty.</string>
 
diff --git a/src/com/android/contacts/CallDetailActivity.java b/src/com/android/contacts/CallDetailActivity.java
index cd5ba14..e9424ef 100644
--- a/src/com/android/contacts/CallDetailActivity.java
+++ b/src/com/android/contacts/CallDetailActivity.java
@@ -28,17 +28,20 @@
 import android.app.ListActivity;
 import android.content.ContentResolver;
 import android.content.ContentUris;
+import android.content.ContentValues;
 import android.content.Context;
 import android.content.Intent;
 import android.content.res.Resources;
 import android.database.Cursor;
 import android.net.Uri;
+import android.os.AsyncTask;
 import android.os.Bundle;
 import android.provider.CallLog;
 import android.provider.CallLog.Calls;
 import android.provider.Contacts.Intents.Insert;
 import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.PhoneLookup;
+import android.provider.VoicemailContract.Voicemails;
 import android.telephony.PhoneNumberUtils;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
@@ -191,6 +194,7 @@
             getFragmentManager().beginTransaction()
                     .add(R.id.voicemail_container, playbackFragment).commit();
             mAsyncQueryHandler.startVoicemailStatusQuery(getVoicemailUri());
+            markVoicemailAsRead(getVoicemailUri());
         } else {
             // No voicemail uri: hide the status view.
             mStatusMessageView.setVisibility(View.GONE);
@@ -205,6 +209,18 @@
         return getIntent().getParcelableExtra(EXTRA_VOICEMAIL_URI);
     }
 
+    private void markVoicemailAsRead(final Uri voicemailUri) {
+        new AsyncTask<Void, Void, Void>() {
+            @Override
+            protected Void doInBackground(Void... params) {
+                ContentValues values = new ContentValues();
+                values.put(Voicemails.IS_READ, true);
+                getContentResolver().update(voicemailUri, values, null, null);
+                return null;
+            }
+        }.execute();
+    }
+
     /**
      * Returns the list of URIs to show.
      * <p>
diff --git a/src/com/android/contacts/activities/DialtactsActivity.java b/src/com/android/contacts/activities/DialtactsActivity.java
index 2040f8d..9daa9af 100644
--- a/src/com/android/contacts/activities/DialtactsActivity.java
+++ b/src/com/android/contacts/activities/DialtactsActivity.java
@@ -703,6 +703,10 @@
     private void exitSearchUi() {
         final ActionBar actionBar = getActionBar();
 
+        final FragmentTransaction transaction = getFragmentManager().beginTransaction();
+        transaction.hide(mSearchFragment);
+        transaction.commit();
+
         // We want to hide SearchView and show Tabs. Also focus on previously selected one.
         actionBar.setDisplayShowCustomEnabled(false);
         actionBar.setDisplayShowHomeEnabled(false);
@@ -710,10 +714,6 @@
 
         sendFragmentVisibilityChange(mViewPager.getCurrentItem(), true);
 
-        final FragmentTransaction transaction = getFragmentManager().beginTransaction();
-        transaction.hide(mSearchFragment);
-        transaction.commit();
-
         mViewPager.setVisibility(View.VISIBLE);
 
         hideInputMethod(getCurrentFocus());
diff --git a/src/com/android/contacts/model/AccountTypeManager.java b/src/com/android/contacts/model/AccountTypeManager.java
index 7232a26..eccf44b 100644
--- a/src/com/android/contacts/model/AccountTypeManager.java
+++ b/src/com/android/contacts/model/AccountTypeManager.java
@@ -309,6 +309,10 @@
                     Log.d(TAG, "Registering external account type=" + type
                             + ", packageName=" + auth.packageName);
                     accountType = new ExternalAccountType(mContext, auth.packageName);
+                    if (!((ExternalAccountType) accountType).isInitialized()) {
+                        // Skip external account types that couldn't be initialized.
+                        continue;
+                    }
                     accountType.readOnly = !sync.supportsUploading();
                 }
 
@@ -329,6 +333,10 @@
                 for (String extensionPackage : extensionPackages) {
                     ExternalAccountType accountType =
                             new ExternalAccountType(mContext, extensionPackage);
+                    if (!accountType.isInitialized()) {
+                        // Skip external account types that couldn't be initialized.
+                        continue;
+                    }
                     Log.d(TAG, "Registering extension package account type="
                             + accountType.accountType + ", dataSet=" + accountType.dataSet
                             + ", packageName=" + extensionPackage);