Splitting Dialtacts activity into two: Dialer and Contacts
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);