diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 8325cb3..ddf8f1e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -57,7 +57,7 @@
         </activity>
 
         <!-- Tab container for TwelveKeyDialer and RecentCallsList -->
-        <activity android:name="DialtactsActivity"
+        <activity android:name="DialerActivity"
             android:label="@string/launcherDialer"
             android:theme="@android:style/Theme.NoTitleBar"
             android:launchMode="singleTask"
@@ -108,9 +108,32 @@
             </intent-filter>
         </activity>
 
+        <!-- An alias for compatibility -->
+        <activity-alias android:name="DialtactsActivity"
+            android:targetActivity="DialerActivity"
+        >
+        </activity-alias>
+        
+        <!-- Tab container for Activity Stream and Contacts -->
+        <activity android:name="ContactsActivity"
+            android:label="@string/strequentList"
+            android:theme="@android:style/Theme.NoTitleBar"
+            android:launchMode="singleTask"
+            android:clearTaskOnLaunch="true"
+            android:icon="@drawable/ic_launcher_contacts"
+            android:screenOrientation="nosensor"
+        >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.BROWSABLE" />
+            </intent-filter>
+        </activity>
+
         <!-- An empty activity that presents the DialtactActivity's Contacts tab -->
         <activity-alias android:name="DialtactsContactsEntryActivity"
-            android:targetActivity="DialtactsActivity"
+            android:targetActivity="ContactsActivity"
             android:label="@string/contactsList"
             android:icon="@drawable/ic_launcher_contacts"
         >
@@ -134,9 +157,7 @@
 
         <!-- An empty activity that presents the DialtactActivity's Favorites tab -->
         <activity-alias android:name="DialtactsFavoritesEntryActivity"
-            android:targetActivity="DialtactsActivity"
-            android:label="@string/strequentList"
-            android:icon="@drawable/ic_launcher_contacts"
+            android:targetActivity="ContactsActivity"
         >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
diff --git a/src/com/android/contacts/ContactsActivity.java b/src/com/android/contacts/ContactsActivity.java
new file mode 100644
index 0000000..fbffc17
--- /dev/null
+++ b/src/com/android/contacts/ContactsActivity.java
@@ -0,0 +1,218 @@
+/*
+ * 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.
+ */
+
+package com.android.contacts;
+
+import android.app.Activity;
+import android.app.TabActivity;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.provider.Contacts;
+import android.provider.Contacts.Intents.UI;
+import android.view.KeyEvent;
+import android.view.Window;
+import android.widget.TabHost;
+
+/**
+ * The contacts activity that has one tab with social activity stream and
+ * another with contact list. This is the container and the tabs are embedded
+ * using intents.
+ */
+public class ContactsActivity extends TabActivity implements TabHost.OnTabChangeListener {
+    private static final String TAG = "Contacts";
+    private static final String FAVORITES_ENTRY_COMPONENT =
+            "com.android.contacts.DialtactsFavoritesEntryActivity";
+
+    private static final int TAB_INDEX_CONTACTS = 0;
+    private static final int TAB_INDEX_FAVORITES = 1;
+
+    static final String EXTRA_IGNORE_STATE = "ignore-state";
+
+    /** Name of the dialtacts shared preferences */
+    static final String PREFS_DIALTACTS = "dialtacts";
+    /** If true, when handling the contacts intent the favorites tab will be shown instead */
+    static final String PREF_FAVORITES_AS_CONTACTS = "favorites_as_contacts";
+    static final boolean PREF_FAVORITES_AS_CONTACTS_DEFAULT = false;
+
+    private TabHost mTabHost;
+    private String mFilterText;
+
+    @Override
+    protected void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+
+        final Intent intent = getIntent();
+
+        requestWindowFeature(Window.FEATURE_NO_TITLE);
+        setContentView(R.layout.dialer_activity);
+
+        mTabHost = getTabHost();
+        mTabHost.setOnTabChangedListener(this);
+
+        // Setup the tabs
+        setupContactsTab();
+        setupFavoritesTab();
+
+        setCurrentTab(intent);
+
+        if (intent.getAction().equals(Contacts.Intents.UI.FILTER_CONTACTS_ACTION)
+                && icicle == null) {
+            setupFilterText(intent);
+        }
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+
+        int currentTabIndex = mTabHost.getCurrentTab();
+        if (currentTabIndex == TAB_INDEX_CONTACTS || currentTabIndex == TAB_INDEX_FAVORITES) {
+            SharedPreferences.Editor editor = getSharedPreferences(PREFS_DIALTACTS, MODE_PRIVATE)
+                    .edit();
+            editor.putBoolean(PREF_FAVORITES_AS_CONTACTS, currentTabIndex == TAB_INDEX_FAVORITES);
+            editor.commit();
+        }
+    }
+
+    private void setupContactsTab() {
+        Intent intent = new Intent(UI.LIST_DEFAULT);
+        intent.setClass(this, ContactsListActivity.class);
+
+        mTabHost.addTab(mTabHost.newTabSpec("contacts")
+                .setIndicator(getText(R.string.contactsIconLabel),
+                        getResources().getDrawable(R.drawable.ic_tab_contacts))
+                .setContent(intent));
+    }
+
+    private void setupFavoritesTab() {
+        Intent intent = new Intent(UI.LIST_STREQUENT_ACTION);
+        intent.setClass(this, ContactsListActivity.class);
+
+        mTabHost.addTab(mTabHost.newTabSpec("favorites")
+                .setIndicator(getString(R.string.contactsFavoritesLabel),
+                        getResources().getDrawable(R.drawable.ic_tab_starred))
+                .setContent(intent));
+    }
+
+    /**
+     * Sets the current tab based on the intent's request type
+     *
+     * @param recentCallsRequest true is the recent calls tab is desired, false otherwise
+     */
+    private void setCurrentTab(Intent intent) {
+
+        // Dismiss menu provided by any children activities
+        Activity activity = getLocalActivityManager().
+                getActivity(mTabHost.getCurrentTabTag());
+        if (activity != null) {
+            activity.closeOptionsMenu();
+        }
+
+        // Tell the children activities that they should ignore any possible saved
+        // state and instead reload their state from the parent's intent
+        intent.putExtra(EXTRA_IGNORE_STATE, true);
+
+        // Choose the tab based on the inbound intent
+        String componentName = intent.getComponent().getClassName();
+        if (FAVORITES_ENTRY_COMPONENT.equals(componentName)) {
+            mTabHost.setCurrentTab(TAB_INDEX_FAVORITES);
+        } else if (Contacts.Intents.UI.FILTER_CONTACTS_ACTION.equals(intent.getAction())) {
+            mTabHost.setCurrentTab(TAB_INDEX_CONTACTS);
+        } else {
+            SharedPreferences prefs = getSharedPreferences(PREFS_DIALTACTS, MODE_PRIVATE);
+            boolean favoritesAsContacts = prefs.getBoolean(PREF_FAVORITES_AS_CONTACTS,
+                    PREF_FAVORITES_AS_CONTACTS_DEFAULT);
+            if (favoritesAsContacts) {
+                mTabHost.setCurrentTab(TAB_INDEX_FAVORITES);
+            } else {
+                mTabHost.setCurrentTab(TAB_INDEX_CONTACTS);
+            }
+        }
+
+        // Tell the children activities that they should honor their saved states
+        // instead of the state from the parent's intent
+        intent.putExtra(EXTRA_IGNORE_STATE, false);
+    }
+
+    @Override
+    public void onNewIntent(Intent newIntent) {
+        setIntent(newIntent);
+        setCurrentTab(newIntent);
+        final String action = newIntent.getAction();
+        if (action.equals(Contacts.Intents.UI.FILTER_CONTACTS_ACTION)) {
+            setupFilterText(newIntent);
+        }
+    }
+
+    /**
+     * Retrieves the filter text stored in {@link #setupFilterText(Intent)}.
+     * This text originally came from a FILTER_CONTACTS_ACTION intent received
+     * by this activity. The stored text will then be cleared after after this
+     * method returns.
+     *
+     * @return The stored filter text
+     */
+    public String getAndClearFilterText() {
+        String filterText = mFilterText;
+        mFilterText = null;
+        return filterText;
+    }
+
+    /**
+     * Stores the filter text associated with a FILTER_CONTACTS_ACTION intent.
+     * This is so child activities can check if they are supposed to display a filter.
+     *
+     * @param intent The intent received in {@link #onNewIntent(Intent)}
+     */
+    private void setupFilterText(Intent intent) {
+        // If the intent was relaunched from history, don't apply the filter text.
+        if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
+            return;
+        }
+        String filter = intent.getStringExtra(Contacts.Intents.UI.FILTER_TEXT_EXTRA_KEY);
+        if (filter != null && filter.length() > 0) {
+            mFilterText = filter;
+        }
+    }
+
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        // Handle BACK
+        if (keyCode == KeyEvent.KEYCODE_BACK && isTaskRoot()) {
+            // Instead of stopping, simply push this to the back of the stack.
+            // This is only done when running at the top of the stack;
+            // otherwise, we have been launched by someone else so need to
+            // allow the user to go back to the caller.
+            moveTaskToBack(false);
+            return true;
+        }
+
+        return super.onKeyDown(keyCode, event);
+    }
+
+    /** {@inheritDoc} */
+    public void onTabChanged(String tabId) {
+        // Because we're using Activities as our tab children, we trigger
+        // onWindowFocusChanged() to let them know when they're active.  This may
+        // seem to duplicate the purpose of onResume(), but it's needed because
+        // onResume() can't reliably check if a keyguard is active.
+        Activity activity = getLocalActivityManager().getActivity(tabId);
+        if (activity != null) {
+            activity.onWindowFocusChanged(true);
+        }
+    }
+}
diff --git a/src/com/android/contacts/ContactsListActivity.java b/src/com/android/contacts/ContactsListActivity.java
index f6718f5..fefb815 100644
--- a/src/com/android/contacts/ContactsListActivity.java
+++ b/src/com/android/contacts/ContactsListActivity.java
@@ -16,8 +16,6 @@
 
 package com.android.contacts;
 
-import static com.android.contacts.ShowOrCreateActivity.QUERY_KIND_EMAIL_OR_IM;
-
 import android.app.Activity;
 import android.app.AlertDialog;
 import android.app.ListActivity;
@@ -28,19 +26,15 @@
 import android.content.ContentValues;
 import android.content.Context;
 import android.content.DialogInterface;
-import android.content.IContentProvider;
-import android.content.ISyncAdapter;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.database.CharArrayBuffer;
 import android.database.Cursor;
-import android.database.CursorWrapper;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Parcelable;
-import android.os.RemoteException;
 import android.preference.PreferenceManager;
 import android.provider.Contacts;
 import android.provider.Contacts.ContactMethods;
@@ -87,7 +81,7 @@
 
     private static final String LIST_STATE_KEY = "liststate";
     private static final String FOCUS_KEY = "focused";
-    
+
     static final int MENU_ITEM_VIEW_CONTACT = 1;
     static final int MENU_ITEM_CALL = 2;
     static final int MENU_ITEM_EDIT_BEFORE_CALL = 3;
@@ -103,7 +97,7 @@
     public static final int MENU_DISPLAY_GROUP = 11;
 
     private static final int SUBACTIVITY_NEW_CONTACT = 1;
-    
+
     /** Mask for picker mode */
     static final int MODE_MASK_PICKER = 0x80000000;
     /** Mask for no presence mode */
@@ -148,7 +142,7 @@
     static final int DEFAULT_MODE = MODE_ALL_CONTACTS;
 
     /**
-     * The type of data to display in the main contacts list. 
+     * The type of data to display in the main contacts list.
      */
     static final String PREF_DISPLAY_TYPE = "display_system_group";
 
@@ -168,13 +162,13 @@
      * is {@link #DISPLAY_TYPE_SYSTEM_GROUP} then this will be the system id.
      * If {@link #PREF_DISPLAY_TYPE} is {@link #DISPLAY_TYPE_USER_GROUP} then this will
      * be the group name.
-     */ 
+     */
     static final String PREF_DISPLAY_INFO = "display_group";
 
-    
+
     static final String NAME_COLUMN = People.DISPLAY_NAME;
     static final String SORT_STRING = People.SORT_STRING;
-    
+
     static final String[] CONTACTS_PROJECTION = new String[] {
         People._ID, // 0
         NAME_COLUMN, // 1
@@ -187,7 +181,7 @@
         People.PRESENCE_STATUS, // 8
         SORT_STRING, // 9
     };
-    
+
     static final String[] SIMPLE_CONTACTS_PROJECTION = new String[] {
         People._ID, // 0
         NAME_COLUMN, // 1
@@ -242,7 +236,7 @@
 
     static final int PHONES_PERSON_ID_INDEX = 6;
     static final int SIMPLE_CONTACTS_PERSON_ID_INDEX = 0;
-    
+
     static final int DISPLAY_GROUP_INDEX_ALL_CONTACTS = 0;
     static final int DISPLAY_GROUP_INDEX_ALL_CONTACTS_WITH_PHONES = 1;
     static final int DISPLAY_GROUP_INDEX_MY_CONTACTS = 2;
@@ -255,7 +249,7 @@
     };
     static final int GROUPS_COLUMN_INDEX_SYSTEM_ID = 0;
     static final int GROUPS_COLUMN_INDEX_NAME = 1;
-    
+
     static final String GROUP_WITH_PHONES = "android_smartgroup_phone";
 
     ContactItemListAdapter mAdapter;
@@ -271,7 +265,7 @@
 
     private int mDisplayGroupOriginalSelection;
     private int mDisplayGroupCurrentSelection;
-    
+
     private QueryHandler mQueryHandler;
     private String mQuery;
     private Uri mGroupFilterUri;
@@ -294,7 +288,7 @@
 
     private boolean mCreateShortcut;
     private boolean mDefaultMode = false;
-    
+
     /**
      * Internal query type when in mode {@link #MODE_QUERY_PICK_TO_VIEW}.
      */
@@ -303,13 +297,13 @@
     private static final int QUERY_MODE_NONE = -1;
     private static final int QUERY_MODE_MAILTO = 1;
     private static final int QUERY_MODE_TEL = 2;
-    
+
     /**
      * Data to use when in mode {@link #MODE_QUERY_PICK_TO_VIEW}. Usually
      * provided by scheme-specific part of incoming {@link Intent#getData()}.
      */
     private String mQueryData;
-    
+
     private class DeleteClickListener implements DialogInterface.OnClickListener {
         private Uri mUri;
 
@@ -321,7 +315,7 @@
             getContentResolver().delete(mUri, null, null);
         }
     }
-    
+
     @Override
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
@@ -334,10 +328,10 @@
         if (title != null) {
             setTitle(title);
         }
-        
+
         final String action = intent.getAction();
         mMode = MODE_UNKNOWN;
-        
+
         setContentView(R.layout.contacts_list_content);
 
         if (UI.LIST_DEFAULT.equals(action)) {
@@ -399,7 +393,7 @@
                 finish();
                 return;
             }
-            
+
             // See if search request has extras to specify query
             if (intent.hasExtra(Insert.EMAIL)) {
                 mMode = MODE_QUERY_PICK_TO_VIEW;
@@ -465,7 +459,7 @@
 
         // Set the proper empty string
         setEmptyText();
-        
+
         mAdapter = new ContactItemListAdapter(this);
         setListAdapter(mAdapter);
 
@@ -533,7 +527,7 @@
 
     /**
      * Builds the URIs to query when displaying a user group
-     * 
+     *
      * @param groupName the group being displayed
      */
     private void buildUserGroupUris(String groupName) {
@@ -544,8 +538,8 @@
 
     /**
      * Builds the URIs to query when displaying a system group
-     * 
-     * @param systemId the system group's ID 
+     *
+     * @param systemId the system group's ID
      */
     private void buildSystemGroupUris(String systemId) {
         mGroupFilterUri = Uri.parse("content://contacts/groups/system_id/" + systemId
@@ -559,7 +553,7 @@
     private void setDefaultMode() {
         // Load the preferences
         SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
-        
+
         // Lookup the group to display
         mDisplayType = prefs.getInt(PREF_DISPLAY_TYPE, DISPLAY_TYPE_UNKNOWN);
         switch (mDisplayType) {
@@ -629,7 +623,7 @@
 
         boolean runQuery = true;
         Activity parent = getParent();
-        
+
         // Do this before setting the filter. The filter thread relies
         // on some state that is initialized in setDefaultMode
         if (mDefaultMode) {
@@ -637,10 +631,10 @@
             // in the preferences activity while we weren't running
             setDefaultMode();
         }
-        
+
         // See if we were invoked with a filter
-        if (parent != null && parent instanceof DialtactsActivity) {
-            String filterText = ((DialtactsActivity) parent).getAndClearFilterText();
+        if (parent != null && parent instanceof ContactsActivity) {
+            String filterText = ((ContactsActivity) parent).getAndClearFilterText();
             if (filterText != null && filterText.length() > 0) {
                 getListView().setFilterText(filterText);
                 // Don't start a new query since it will conflict with the filter
@@ -657,7 +651,7 @@
         }
         mJustCreated = false;
     }
-    
+
     @Override
     protected void onRestart() {
         super.onRestart();
@@ -672,7 +666,7 @@
             ((ContactItemListAdapter) getListAdapter()).onContentChanged();
         }
     }
-    
+
     private void updateGroup() {
         if (mDefaultMode) {
             setDefaultMode();
@@ -747,7 +741,7 @@
                     .setIcon(com.android.internal.R.drawable.ic_menu_refresh)
                     .setIntent(syncIntent);
         }
-        
+
         // SIM import
         Intent importIntent = new Intent(Intent.ACTION_VIEW);
         importIntent.setType("vnd.android.cursor.item/sim-contact");
@@ -800,7 +794,7 @@
             mDisplayGroupCurrentSelection = which;
         }
     }
-    
+
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         switch (item.getItemId()) {
@@ -809,9 +803,9 @@
                     .setTitle(R.string.select_group_title)
                     .setPositiveButton(android.R.string.ok, this)
                     .setNegativeButton(android.R.string.cancel, null);
-                
+
                 setGroupEntries(builder);
-                
+
                 builder.show();
                 return true;
 
@@ -1011,7 +1005,7 @@
                         ContentUris.withAppendedId(People.CONTENT_URI, personId));
                 startActivity(intent);
                 finish();
-            } else if (mMode == MODE_PICK_CONTACT 
+            } else if (mMode == MODE_PICK_CONTACT
                     || mMode == MODE_PICK_OR_CREATE_CONTACT) {
                 Uri uri = ContentUris.withAppendedId(People.CONTENT_URI, id);
                 if (mCreateShortcut) {
@@ -1042,7 +1036,7 @@
 
     private void returnPickerResult(String name, Uri uri) {
         final Intent intent = new Intent();
-    
+
         if (mCreateShortcut) {
             Intent shortcutIntent = new Intent(Intent.ACTION_VIEW, uri);
             shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
@@ -1104,10 +1098,10 @@
             return NAME_COLUMN + " COLLATE LOCALIZED ASC";
         }
     }
-    
+
     void startQuery() {
         mAdapter.setLoading(true);
-        
+
         // Cancel any pending queries
         mQueryHandler.cancelOperation(QUERY_TOKEN);
 
@@ -1140,7 +1134,7 @@
                         getSortOrder(CONTACTS_PROJECTION));
                 break;
             }
-            
+
             case MODE_QUERY_PICK_TO_VIEW: {
                 if (mQueryMode == QUERY_MODE_MAILTO) {
                     // Find all contacts with the given search string as either
@@ -1151,7 +1145,7 @@
                     mQueryHandler.startQuery(QUERY_TOKEN, null,
                             uri, SIMPLE_CONTACTS_PROJECTION, null, null,
                             getSortOrder(CONTACTS_PROJECTION));
-                    
+
                 } else if (mQueryMode == QUERY_MODE_TEL) {
                     mQueryPersonIdIndex = PHONES_PERSON_ID_INDEX;
                     mQueryHandler.startQuery(QUERY_TOKEN, null,
@@ -1161,7 +1155,7 @@
                 }
                 break;
             }
-            
+
             case MODE_STARRED:
                 mQueryHandler.startQuery(QUERY_TOKEN, null, People.CONTENT_URI,
                         CONTACTS_PROJECTION,
@@ -1197,7 +1191,7 @@
 
     /**
      * Called from a background thread to do the filter and return the resulting cursor.
-     * 
+     *
      * @param filter the text that was entered to filter on
      * @return a cursor with the results of the filter
      */
@@ -1239,7 +1233,7 @@
                 return resolver.query(getPeopleFilterUri(filter), CONTACTS_PROJECTION,
                         People.TIMES_CONTACTED + " > 0", null,
                         People.TIMES_CONTACTED + " DESC, " + getSortOrder(CONTACTS_PROJECTION));
-                
+
             }
 
             case MODE_STREQUENT: {
@@ -1339,12 +1333,12 @@
             // Add All Contacts
             groups.add(DISPLAY_GROUP_INDEX_ALL_CONTACTS, getString(R.string.showAllGroups));
             prefStrings.add("");
-            
+
             // Add Contacts with phones
             groups.add(DISPLAY_GROUP_INDEX_ALL_CONTACTS_WITH_PHONES,
                     getString(R.string.groupNameWithPhones));
             prefStrings.add(GROUP_WITH_PHONES);
-            
+
             int currentIndex = DISPLAY_GROUP_INDEX_ALL_CONTACTS;
             while (cursor.moveToNext()) {
                 String systemId = cursor.getString(GROUPS_COLUMN_INDEX_SYSTEM_ID);
@@ -1398,9 +1392,9 @@
             final ContactsListActivity activity = mActivity.get();
             if (activity != null && !activity.isFinishing()) {
                 activity.mAdapter.setLoading(false);
-                activity.getListView().clearTextFilter();                
+                activity.getListView().clearTextFilter();
                 activity.mAdapter.changeCursor(cursor);
-                
+
                 // Now that the cursor is populated again, it's possible to restore the list state
                 if (activity.mListState != null) {
                     activity.mList.onRestoreInstanceState(activity.mListState);
@@ -1427,7 +1421,7 @@
         public ImageView photoView;
     }
 
-    private final class ContactItemListAdapter extends ResourceCursorAdapter 
+    private final class ContactItemListAdapter extends ResourceCursorAdapter
             implements SectionIndexer {
         private SectionIndexer mIndexer;
         private String mAlphabet;
@@ -1440,9 +1434,9 @@
 
         public ContactItemListAdapter(Context context) {
             super(context, R.layout.contacts_list_item, null, false);
-            
+
             mAlphabet = context.getString(com.android.internal.R.string.fast_scroll_alphabet);
-            
+
             mUnknownNameText = context.getText(android.R.string.unknownName);
             switch (mMode) {
                 case MODE_PICK_POSTAL:
@@ -1454,7 +1448,7 @@
                             Contacts.KIND_PHONE);
                     break;
             }
-            
+
             if ((mMode & MODE_MASK_SHOW_PHOTOS) == MODE_MASK_SHOW_PHOTOS) {
                 mDisplayPhotos = true;
                 setViewResource(R.layout.contacts_list_item_photo);
@@ -1469,11 +1463,11 @@
                 return new AlphabetIndexer(cursor, NAME_COLUMN_INDEX, mAlphabet);
             }
         }
-        
+
         /**
          * Callback on the UI thread when the content observer on the backing cursor fires.
          * Instead of calling requery we need to do an async query so that the requery doesn't
-         * block the UI thread for a long time. 
+         * block the UI thread for a long time.
          */
         @Override
         protected void onContentChanged() {
@@ -1487,7 +1481,7 @@
                 startQuery();
             }
         }
-        
+
         public void setLoading(boolean loading) {
             mLoading = loading;
         }
@@ -1527,7 +1521,7 @@
             // Handle the separator specially
             if (position == mFrequentSeparatorPos) {
                 LayoutInflater inflater =
-                        (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
+                        (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                 TextView view = (TextView) inflater.inflate(R.layout.list_separator, parent, false);
                 view.setText(R.string.favoritesFrquentSeparator);
                 return view;
@@ -1536,7 +1530,7 @@
             if (!mCursor.moveToPosition(getRealPosition(position))) {
                 throw new IllegalStateException("couldn't move cursor to position " + position);
             }
-            
+
             View v;
             if (convertView == null) {
                 v = newView(mContext, mCursor, parent);
@@ -1565,8 +1559,8 @@
         @Override
         public void bindView(View view, Context context, Cursor cursor) {
             final ContactListItemCache cache = (ContactListItemCache) view.getTag();
-            
-            // Set the name           
+
+            // Set the name
             cursor.copyStringToBuffer(NAME_COLUMN_INDEX, cache.nameBuffer);
             int size = cache.nameBuffer.sizeCopied;
             if (size != 0) {
@@ -1574,7 +1568,7 @@
             } else {
                 cache.nameView.setText(mUnknownNameText);
             }
-            
+
             // Bail out early if using a specific SEARCH query mode, usually for
             // matching a specific E-mail or phone number. Any contact details
             // shown would be identical, and columns might not even be present
@@ -1585,7 +1579,7 @@
                 cache.presenceView.setVisibility(View.GONE);
                 return;
             }
-            
+
             // Set the phone number
             TextView numberView = cache.numberView;
             TextView labelView = cache.labelView;
@@ -1699,7 +1693,7 @@
                 mBitmapCache.clear();
             }
         }
-        
+
         private void updateIndexer(Cursor cursor) {
             if (mIndexer == null) {
                 mIndexer = getNewIndexer(cursor);
@@ -1719,7 +1713,7 @@
                 }
             }
         }
-        
+
         /**
          * Run the query on a helper thread. Beware that this code does not run
          * on the main UI thread!
@@ -1728,7 +1722,7 @@
         public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
             return doFilter(constraint.toString());
         }
-        
+
         public Object [] getSections() {
             if (mMode == MODE_STREQUENT) {
                 return new String[] { " " };
@@ -1779,7 +1773,7 @@
                 return super.getCount();
             }
         }
-        
+
         private int getRealPosition(int pos) {
             if (mFrequentSeparatorPos == ListView.INVALID_POSITION) {
                 // No separator, identity map
@@ -1791,17 +1785,17 @@
                 // After the separator, remove 1 from the pos to get the real underlying pos
                 return pos - 1;
             }
-            
+
         }
-        
+
         @Override
         public Object getItem(int pos) {
             return super.getItem(getRealPosition(pos));
         }
-        
+
         @Override
         public long getItemId(int pos) {
-            return super.getItemId(getRealPosition(pos)); 
+            return super.getItemId(getRealPosition(pos));
         }
     }
 }
diff --git a/src/com/android/contacts/DialtactsActivity.java b/src/com/android/contacts/DialerActivity.java
similarity index 65%
rename from src/com/android/contacts/DialtactsActivity.java
rename to src/com/android/contacts/DialerActivity.java
index 8f933b8..f86a78a 100644
--- a/src/com/android/contacts/DialtactsActivity.java
+++ b/src/com/android/contacts/DialerActivity.java
@@ -19,20 +19,16 @@
 import android.app.Activity;
 import android.app.TabActivity;
 import android.content.Intent;
-import android.content.SharedPreferences;
-import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.RemoteException;
 import android.os.ServiceManager;
-import android.provider.CallLog;
-import android.provider.Contacts;
 import android.provider.CallLog.Calls;
-import android.provider.Contacts.Intents.UI;
 import android.util.Log;
 import android.view.KeyEvent;
 import android.view.Window;
 import android.widget.TabHost;
+
 import com.android.internal.telephony.ITelephony;
 
 /**
@@ -40,26 +36,15 @@
  * and another tab with recent calls in it. This is the container and the tabs
  * are embedded using intents.
  */
-public class DialtactsActivity extends TabActivity implements TabHost.OnTabChangeListener {
-    private static final String TAG = "Dailtacts";
-    private static final String FAVORITES_ENTRY_COMPONENT =
-            "com.android.contacts.DialtactsFavoritesEntryActivity";
+public class DialerActivity extends TabActivity implements TabHost.OnTabChangeListener {
+    private static final String TAG = "Dialer";
 
     private static final int TAB_INDEX_DIALER = 0;
     private static final int TAB_INDEX_CALL_LOG = 1;
-    private static final int TAB_INDEX_CONTACTS = 2;
-    private static final int TAB_INDEX_FAVORITES = 3;
-    
+
     static final String EXTRA_IGNORE_STATE = "ignore-state";
 
-    /** Name of the dialtacts shared preferences */
-    static final String PREFS_DIALTACTS = "dialtacts";
-    /** If true, when handling the contacts intent the favorites tab will be shown instead */
-    static final String PREF_FAVORITES_AS_CONTACTS = "favorites_as_contacts";
-    static final boolean PREF_FAVORITES_AS_CONTACTS_DEFAULT = false;
-
     private TabHost mTabHost;
-    private String mFilterText;    
     private Uri mDialUri;
 
     @Override
@@ -68,7 +53,7 @@
 
         final Intent intent = getIntent();
         fixIntent(intent);
-        
+
         requestWindowFeature(Window.FEATURE_NO_TITLE);
         setContentView(R.layout.dialer_activity);
 
@@ -78,30 +63,10 @@
         // Setup the tabs
         setupDialerTab();
         setupCallLogTab();
-        setupContactsTab();
-        setupFavoritesTab();
 
         setCurrentTab(intent);
-
-        if (intent.getAction().equals(Contacts.Intents.UI.FILTER_CONTACTS_ACTION)
-                && icicle == null) {
-            setupFilterText(intent);
-        }
     }
 
-    @Override
-    protected void onPause() {
-        super.onPause();
-        
-        int currentTabIndex = mTabHost.getCurrentTab();
-        if (currentTabIndex == TAB_INDEX_CONTACTS || currentTabIndex == TAB_INDEX_FAVORITES) {
-            SharedPreferences.Editor editor = getSharedPreferences(PREFS_DIALTACTS, MODE_PRIVATE)
-                    .edit();
-            editor.putBoolean(PREF_FAVORITES_AS_CONTACTS, currentTabIndex == TAB_INDEX_FAVORITES);
-            editor.commit();
-        }
-    }
-    
     private void fixIntent(Intent intent) {
         // This should be cleaned up: the call key used to send an Intent
         // that just said to go to the recent calls list.  It now sends this
@@ -112,7 +77,7 @@
             setIntent(intent);
         }
     }
-    
+
     private void setupCallLogTab() {
         // Force the class since overriding tab entries doesn't work
         Intent intent = new Intent("com.android.phone.action.RECENT_CALLS");
@@ -134,32 +99,12 @@
                 .setContent(intent));
     }
 
-    private void setupContactsTab() {
-        Intent intent = new Intent(UI.LIST_DEFAULT);
-        intent.setClass(this, ContactsListActivity.class);
-
-        mTabHost.addTab(mTabHost.newTabSpec("contacts")
-                .setIndicator(getText(R.string.contactsIconLabel),
-                        getResources().getDrawable(R.drawable.ic_tab_contacts))
-                .setContent(intent));
-    }
-
-    private void setupFavoritesTab() {
-        Intent intent = new Intent(UI.LIST_STREQUENT_ACTION);
-        intent.setClass(this, ContactsListActivity.class);
-
-        mTabHost.addTab(mTabHost.newTabSpec("favorites")
-                .setIndicator(getString(R.string.contactsFavoritesLabel),
-                        getResources().getDrawable(R.drawable.ic_tab_starred))
-                .setContent(intent));
-    }
-
     /**
      * Returns true if the intent is due to hitting the green send key while in a call.
-     * 
+     *
      * @param intent the intent that launched this activity
      * @param recentCallsRequest true if the intent is requesting to view recent calls
-     * @return true if the intent is due to hitting the green send key while in a call 
+     * @return true if the intent is due to hitting the green send key while in a call
      */
     private boolean isSendKeyWhileInCall(final Intent intent, final boolean recentCallsRequest) {
         // If there is a call in progress go to the call screen
@@ -181,7 +126,7 @@
 
     /**
      * Sets the current tab based on the intent's request type
-     * 
+     *
      * @param recentCallsRequest true is the recent calls tab is desired, false otherwise
      */
     private void setCurrentTab(Intent intent) {
@@ -191,7 +136,7 @@
             finish();
             return;
         }
-        
+
         // Dismiss menu provided by any children activities
         Activity activity = getLocalActivityManager().
                 getActivity(mTabHost.getCurrentTabTag());
@@ -211,19 +156,6 @@
             } else {
                 mTabHost.setCurrentTab(TAB_INDEX_DIALER);
             }
-        } else if (FAVORITES_ENTRY_COMPONENT.equals(componentName)) {
-            mTabHost.setCurrentTab(TAB_INDEX_FAVORITES);
-        } else if (Contacts.Intents.UI.FILTER_CONTACTS_ACTION.equals(intent.getAction())) {
-            mTabHost.setCurrentTab(TAB_INDEX_CONTACTS);
-        } else {
-            SharedPreferences prefs = getSharedPreferences(PREFS_DIALTACTS, MODE_PRIVATE);
-            boolean favoritesAsContacts = prefs.getBoolean(PREF_FAVORITES_AS_CONTACTS,
-                    PREF_FAVORITES_AS_CONTACTS_DEFAULT);
-            if (favoritesAsContacts) {
-                mTabHost.setCurrentTab(TAB_INDEX_FAVORITES);
-            } else {
-                mTabHost.setCurrentTab(TAB_INDEX_CONTACTS);
-            }
         }
 
         // Tell the children activities that they should honor their saved states
@@ -236,10 +168,7 @@
         setIntent(newIntent);
         fixIntent(newIntent);
         setCurrentTab(newIntent);
-        final String action = newIntent.getAction();
-        if (action.equals(Contacts.Intents.UI.FILTER_CONTACTS_ACTION)) {
-            setupFilterText(newIntent);
-        } else if (isDialIntent(newIntent)) {
+        if (isDialIntent(newIntent)) {
             setupDialUri(newIntent);
         }
     }
@@ -258,43 +187,12 @@
         }
         return false;
     }
-    
-    /**
-     * Retrieves the filter text stored in {@link #setupFilterText(Intent)}.
-     * This text originally came from a FILTER_CONTACTS_ACTION intent received
-     * by this activity. The stored text will then be cleared after after this
-     * method returns.
-     * 
-     * @return The stored filter text
-     */
-    public String getAndClearFilterText() {
-        String filterText = mFilterText;
-        mFilterText = null;
-        return filterText;
-    }
-
-    /**
-     * Stores the filter text associated with a FILTER_CONTACTS_ACTION intent.
-     * This is so child activities can check if they are supposed to display a filter.
-     * 
-     * @param intent The intent received in {@link #onNewIntent(Intent)}
-     */
-    private void setupFilterText(Intent intent) {
-        // If the intent was relaunched from history, don't apply the filter text.
-        if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
-            return;
-        }
-        String filter = intent.getStringExtra(Contacts.Intents.UI.FILTER_TEXT_EXTRA_KEY);
-        if (filter != null && filter.length() > 0) {
-            mFilterText = filter;
-        }
-    }
 
     /**
      * Retrieves the uri stored in {@link #setupDialUri(Intent)}. This uri
      * originally came from a dial intent received by this activity. The stored
      * uri will then be cleared after after this method returns.
-     * 
+     *
      * @return The stored uri
      */
     public Uri getAndClearDialUri() {
@@ -306,7 +204,7 @@
     /**
      * Stores the uri associated with a dial intent. This is so child activities can
      * check if they are supposed to display new dial info.
-     * 
+     *
      * @param intent The intent received in {@link #onNewIntent(Intent)}
      */
     private void setupDialUri(Intent intent) {
@@ -328,7 +226,7 @@
             moveTaskToBack(false);
             return true;
         }
-        
+
         return super.onKeyDown(keyCode, event);
     }
 
diff --git a/src/com/android/contacts/TwelveKeyDialer.java b/src/com/android/contacts/TwelveKeyDialer.java
index ea157fc..e3d0065 100644
--- a/src/com/android/contacts/TwelveKeyDialer.java
+++ b/src/com/android/contacts/TwelveKeyDialer.java
@@ -73,12 +73,12 @@
         AdapterView.OnItemClickListener, TextWatcher {
 
     private static final String TAG = "TwelveKeyDialer";
-    
+
     private static final int STOP_TONE = 1;
 
     /** The length of DTMF tones in milliseconds */
     private static final int TONE_LENGTH_MS = 150;
-    
+
     /** The DTMF tone volume relative to other sounds in the stream */
     private static final int TONE_RELATIVE_VOLUME = 50;
 
@@ -98,7 +98,7 @@
 
     // determines if we want to playback local DTMF tones.
     private boolean mDTMFToneEnabled;
-    
+
     /** Identifier for the "Add Call" intent extra. */
     static final String ADD_CALL_MODE_KEY = "add_call_mode";
     /** Indicates if we are opening this dialer to add a call from the InCallScreen. */
@@ -133,7 +133,7 @@
 
     public void onTextChanged(CharSequence input, int start, int before, int changeCount) {
         // Do nothing
-        // DTMF Tones do not need to be played here any longer - 
+        // DTMF Tones do not need to be played here any longer -
         // the DTMF dialer handles that functionality now.
     }
 
@@ -191,8 +191,8 @@
         view.setOnLongClickListener(this);
         mDelete = view;
 
-        mDigitsAndBackspace = (View) findViewById(R.id.digitsAndBackspace);
-        mDialpad = (View) findViewById(R.id.dialpad);  // This is null in landscape mode
+        mDigitsAndBackspace = findViewById(R.id.digitsAndBackspace);
+        mDialpad = findViewById(R.id.dialpad);  // This is null in landscape mode
 
         // Set up the "dialpad chooser" UI; see showDialpadChooser().
         mDialpadChooser = (ListView) findViewById(R.id.dialpadChooser);
@@ -207,7 +207,7 @@
         synchronized (mToneGeneratorLock) {
             if (mToneGenerator == null) {
                 try {
-                    mToneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 
+                    mToneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL,
                             TONE_RELATIVE_VOLUME);
                 } catch (RuntimeException e) {
                     Log.w(TAG, "Exception caught while creating local tone generator: " + e);
@@ -233,13 +233,13 @@
     protected void onRestoreInstanceState(Bundle icicle) {
         // Do nothing, state is restored in onCreate() if needed
     }
-    
+
     protected void maybeAddNumberFormatting() {
         mDigits.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
     }
-    
+
     /**
-     * Overridden by subclasses to control the resource used by the content view. 
+     * Overridden by subclasses to control the resource used by the content view.
      */
     protected int getContentViewResource() {
         return R.layout.twelve_key_dialer;
@@ -252,7 +252,7 @@
         final Intent intent;
         if (isChild()) {
             intent = getParent().getIntent();
-            ignoreState = intent.getBooleanExtra(DialtactsActivity.EXTRA_IGNORE_STATE, false);
+            ignoreState = intent.getBooleanExtra(DialerActivity.EXTRA_IGNORE_STATE, false);
         } else {
             intent = getIntent();
         }
@@ -333,7 +333,7 @@
         setIntent(newIntent);
         resolveIntent();
     }
-    
+
     @Override
     protected void onPostCreate(Bundle savedInstanceState) {
         super.onPostCreate(savedInstanceState);
@@ -344,7 +344,7 @@
         // will always happen after onRestoreSavedInstanceState().
         mDigits.addTextChangedListener(this);
     }
-    
+
     private void setupKeypad() {
         // Setup the listeners for the buttons
         View view = findViewById(R.id.one);
@@ -371,17 +371,17 @@
     @Override
     protected void onResume() {
         super.onResume();
-        
+
         // retrieve the DTMF tone play back setting.
         mDTMFToneEnabled = Settings.System.getInt(getContentResolver(),
                 Settings.System.DTMF_TONE_WHEN_DIALING, 1) == 1;
 
-        // if the mToneGenerator creation fails, just continue without it.  It is 
+        // if the mToneGenerator creation fails, just continue without it.  It is
         // a local audio signal, and is not as important as the dtmf tone itself.
         synchronized(mToneGeneratorLock) {
             if (mToneGenerator == null) {
                 try {
-                    mToneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 
+                    mToneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL,
                             TONE_RELATIVE_VOLUME);
                 } catch (RuntimeException e) {
                     Log.w(TAG, "Exception caught while creating local tone generator: " + e);
@@ -389,12 +389,12 @@
                 }
             }
         }
-        
+
         Activity parent = getParent();
         // See if we were invoked with a DIAL intent. If we were, fill in the appropriate
         // digits in the dialer field.
-        if (parent != null && parent instanceof DialtactsActivity) {
-            Uri dialUri = ((DialtactsActivity) parent).getAndClearDialUri();
+        if (parent != null && parent instanceof DialerActivity) {
+            Uri dialUri = ((DialerActivity) parent).getAndClearDialUri();
             if (dialUri != null) {
                 resolveIntent();
             }
@@ -436,7 +436,7 @@
             // have a window token yet in onCreate / onNewIntent
             InputMethodManager inputMethodManager = (InputMethodManager)
                     getSystemService(Context.INPUT_METHOD_SERVICE);
-            inputMethodManager.hideSoftInputFromWindow(mDigits.getWindowToken(), 0);            
+            inputMethodManager.hideSoftInputFromWindow(mDigits.getWindowToken(), 0);
         }
     }
 
@@ -503,7 +503,7 @@
                 return true;
             }
             case KeyEvent.KEYCODE_1: {
-                long timeDiff = SystemClock.uptimeMillis() - event.getDownTime(); 
+                long timeDiff = SystemClock.uptimeMillis() - event.getDownTime();
                 if (timeDiff >= ViewConfiguration.getLongPressTimeout()) {
                     // Long press detected, call voice mail
                     callVoicemail();
@@ -532,7 +532,7 @@
         }
         return super.onKeyUp(keyCode, event);
     }
-    
+
     private void keyPressed(int keyCode) {
         KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
         mDigits.onKeyDown(keyCode, event);
@@ -689,7 +689,7 @@
 
     /**
      * Play a tone for TONE_LENGTH_MS milliseconds.
-     * 
+     *
      * @param tone a tone code from {@link ToneGenerator}
      */
     void playTone(int tone) {
@@ -697,16 +697,16 @@
         if (!mDTMFToneEnabled) {
             return;
         }
- 
+
         synchronized(mToneGeneratorLock) {
             if (mToneGenerator == null) {
                 Log.w(TAG, "playTone: mToneGenerator == null, tone: "+tone);
                 return;
             }
-            
+
             // Remove pending STOP_TONE messages
             mToneStopper.removeMessages(STOP_TONE);
-    
+
             // Start the new tone (will stop any playing tone)
             mToneGenerator.startTone(tone);
             mToneStopper.sendEmptyMessageDelayed(STOP_TONE, TONE_LENGTH_MS);
