Merge "Add the search button in CallLog/Favorites"
diff --git a/res/menu/call_log_options.xml b/res/menu/call_log_options.xml
new file mode 100644
index 0000000..57d637e
--- /dev/null
+++ b/res/menu/call_log_options.xml
@@ -0,0 +1,22 @@
+<?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.
+-->
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <item
+        android:id="@+id/delete_all"
+        android:icon="@android:drawable/ic_menu_close_clear_cancel"
+        android:title="@string/recentCalls_deleteAll"
+        android:showAsAction="withText" />
+</menu>
diff --git a/res/menu/dialpad_options.xml b/res/menu/dialpad_options.xml
new file mode 100644
index 0000000..382e3d9
--- /dev/null
+++ b/res/menu/dialpad_options.xml
@@ -0,0 +1,39 @@
+<?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.
+-->
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <item
+        android:id="@+id/menu_add_contacts"
+        android:icon="@android:drawable/ic_menu_add"
+        android:title="@string/recentCalls_addToContact"
+        android:showAsAction="withText" />
+    <item
+        android:id="@+id/menu_2s_pause"
+        android:icon="@drawable/ic_menu_2sec_pause"
+        android:title="@string/add_2sec_pause"
+        android:showAsAction="withText" />
+
+    <item
+        android:id="@+id/menu_add_wait"
+        android:icon="@drawable/ic_menu_wait"
+        android:title="@string/add_wait"
+        android:showAsAction="withText" />
+
+    <!-- TODO: need asset -->
+    <item
+        android:id="@+id/menu_call_settings"
+        android:title="@string/call_settings"
+        android:showAsAction="withText" />
+</menu>
diff --git a/res/menu/dialtacts_options.xml b/res/menu/dialtacts_options.xml
new file mode 100644
index 0000000..aa3af3f
--- /dev/null
+++ b/res/menu/dialtacts_options.xml
@@ -0,0 +1,21 @@
+<?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.
+-->
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <item
+        android:id="@+id/search_on_action_bar"
+        android:icon="@android:drawable/ic_menu_search"
+        android:showAsAction="always" />
+</menu>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index d89ebcf..fbd8653 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -14,7 +14,7 @@
      limitations under the License.
 -->
 <resources>
-    <style name="DialtactsTheme" parent="android:Theme.Holo.Light">
+    <style name="DialtactsTheme" parent="android:Theme.Holo.Light.SplitActionBarWhenNarrow">
         <item name="android:windowContentOverlay">@null</item>
         <item name="activated_background">@drawable/list_item_activated_background</item>
         <item name="section_header_background">@drawable/list_title_holo</item>
diff --git a/src/com/android/contacts/activities/DialtactsActivity.java b/src/com/android/contacts/activities/DialtactsActivity.java
index a7a5410..37da553 100644
--- a/src/com/android/contacts/activities/DialtactsActivity.java
+++ b/src/com/android/contacts/activities/DialtactsActivity.java
@@ -19,12 +19,10 @@
 import com.android.contacts.R;
 import com.android.contacts.calllog.CallLogFragment;
 import com.android.contacts.dialpad.DialpadFragment;
-import com.android.contacts.interactions.ImportExportDialogFragment;
 import com.android.contacts.interactions.PhoneNumberInteraction;
 import com.android.contacts.list.OnPhoneNumberPickerActionListener;
 import com.android.contacts.list.PhoneNumberPickerFragment;
 import com.android.contacts.list.StrequentContactListFragment;
-import com.android.contacts.preference.ContactsPreferenceActivity;
 import com.android.internal.telephony.ITelephony;
 
 import android.app.ActionBar;
@@ -43,10 +41,7 @@
 import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.provider.CallLog.Calls;
-import android.provider.ContactsContract;
-import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.Intents.UI;
-import android.provider.Settings;
 import android.support.v13.app.FragmentPagerAdapter;
 import android.support.v4.view.ViewPager;
 import android.support.v4.view.ViewPager.OnPageChangeListener;
@@ -55,6 +50,7 @@
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
+import android.view.MenuItem.OnMenuItemClickListener;
 import android.view.View;
 import android.view.View.OnAttachStateChangeListener;
 import android.view.inputmethod.InputMethodManager;
@@ -92,7 +88,7 @@
      * when it becomes visible or invisible inside the ViewPager.
      */
     public interface ViewPagerVisibilityListener {
-        public void onVisibilityChange(boolean visible);
+        public void onVisibilityChanged(boolean visible);
     }
 
     public class ViewPagerAdapter extends FragmentPagerAdapter {
@@ -120,6 +116,8 @@
     }
 
     private class PageChangeListener implements OnPageChangeListener {
+        private int mPreviousPosition = -1;  // Invalid at first
+
         @Override
         public void onPageScrolled(
                 int position, float positionOffset, int positionOffsetPixels) {
@@ -128,7 +126,32 @@
         @Override
         public void onPageSelected(int position) {
             final ActionBar actionBar = getActionBar();
+            if (mPreviousPosition == position) {
+                Log.w(TAG, "Previous position and next position became same (" + position + ")");
+            }
+
+            if (mPreviousPosition >= 0) {
+                Fragment prevFragment = getFragmentAt(mPreviousPosition);
+                if (prevFragment instanceof ViewPagerVisibilityListener) {
+                    ((ViewPagerVisibilityListener) prevFragment).onVisibilityChanged(false);
+                }
+            }
+            final Fragment nextFragment = getFragmentAt(position);
+            if (nextFragment instanceof ViewPagerVisibilityListener) {
+                ((ViewPagerVisibilityListener) nextFragment).onVisibilityChanged(true);
+            }
+
             actionBar.selectTab(actionBar.getTabAt(position));
+
+            // Activity#onPrepareOptionsMenu() may not be called when Fragment has it's own
+            // options menu. We force this Activity to call it to hide/show bottom bar. Also
+            // we don't want to do so when it is unnecessary (buttons may flicker).
+            if (mPreviousPosition == TAB_INDEX_DIALER || position == TAB_INDEX_DIALER) {
+                // Force this Activity to prepare Menu again.
+                invalidateOptionsMenu();
+            }
+
+            mPreviousPosition = position;
         }
 
         @Override
@@ -149,20 +172,19 @@
      * Fragment for searching phone numbers. Unlike the other Fragments, this doesn't correspond
      * to tab but is shown by a search action.
      */
-    private PhoneNumberPickerFragment mPhoneNumberPickerFragment;
+    private PhoneNumberPickerFragment mSearchFragment;
     /**
      * True when this Activity is in its search UI (with a {@link SearchView} and
      * {@link PhoneNumberPickerFragment}).
      */
     private boolean mInSearchUi;
+    private SearchView mSearchView;
 
     /**
-     * The index of the tab that has last been manually selected (the user clicked on a tab).
+     * The index of the Fragment (or, the tab) that has last been manually selected.
      * This value does not keep track of programmatically set Tabs (e.g. Call Log after a Call)
      */
-    private int mLastManuallySelectedTab;
-
-    private SearchView mSearchView;
+    private int mLastManuallySelectedFragment;
 
     /**
      * Listener used when one of phone numbers in search UI is selected. This will initiate a
@@ -196,8 +218,8 @@
                 @Override
                 public boolean onQueryTextChange(String newText) {
                     // Show search result with non-empty text. Show a bare list otherwise.
-                    mPhoneNumberPickerFragment.setQueryString(newText, true);
-                    mPhoneNumberPickerFragment.setSearchMode(!TextUtils.isEmpty(newText));
+                    mSearchFragment.setQueryString(newText, true);
+                    mSearchFragment.setSearchMode(!TextUtils.isEmpty(newText));
                     return true;
                 }
     };
@@ -250,14 +272,14 @@
         mViewPager.setOnPageChangeListener(new PageChangeListener());
 
         // This Fragment is _not_ maintained by ViewPager.
-        mPhoneNumberPickerFragment = (PhoneNumberPickerFragment) getFragmentManager()
+        mSearchFragment = (PhoneNumberPickerFragment) getFragmentManager()
                 .findFragmentById(R.id.phone_number_picker_fragment);
-        mPhoneNumberPickerFragment.setOnPhoneNumberPickerActionListener(
+        mSearchFragment.setOnPhoneNumberPickerActionListener(
                 mPhoneNumberPickerActionListener);
-        mPhoneNumberPickerFragment.setHighlightSearchPrefix(true);
+        mSearchFragment.setHighlightSearchPrefix(true);
 
         final FragmentTransaction transaction = getFragmentManager().beginTransaction();
-        transaction.hide(mPhoneNumberPickerFragment);
+        transaction.hide(mSearchFragment);
         transaction.commit();
 
         // Setup the ActionBar tabs (the order matches the tab-index contants TAB_INDEX_*)
@@ -270,11 +292,11 @@
 
         // Load the last manually loaded tab
         final SharedPreferences prefs = getSharedPreferences(PREFS_DIALTACTS, MODE_PRIVATE);
-        mLastManuallySelectedTab = prefs.getInt(PREF_LAST_MANUALLY_SELECTED_TAB,
+        mLastManuallySelectedFragment = prefs.getInt(PREF_LAST_MANUALLY_SELECTED_TAB,
                 PREF_LAST_MANUALLY_SELECTED_TAB_DEFAULT);
-        if (mLastManuallySelectedTab >= TAB_INDEX_COUNT) {
+        if (mLastManuallySelectedFragment >= TAB_INDEX_COUNT) {
             // Stored value may have exceeded the number of current tabs. Reset it.
-            mLastManuallySelectedTab = PREF_LAST_MANUALLY_SELECTED_TAB_DEFAULT;
+            mLastManuallySelectedFragment = PREF_LAST_MANUALLY_SELECTED_TAB_DEFAULT;
         }
 
         setCurrentTab(intent);
@@ -291,7 +313,7 @@
 
         final SharedPreferences.Editor editor =
                 getSharedPreferences(PREFS_DIALTACTS, MODE_PRIVATE).edit();
-        editor.putInt(PREF_LAST_MANUALLY_SELECTED_TAB, mLastManuallySelectedTab);
+        editor.putInt(PREF_LAST_MANUALLY_SELECTED_TAB, mLastManuallySelectedFragment);
 
         editor.apply();
     }
@@ -343,7 +365,8 @@
      * @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
      */
-    private boolean isSendKeyWhileInCall(final Intent intent, final boolean recentCallsRequest) {
+    private boolean isSendKeyWhileInCall(final Intent intent,
+            final boolean recentCallsRequest) {
         // If there is a call in progress go to the call screen
         if (recentCallsRequest) {
             final boolean callKey = intent.getBooleanExtra("call_key", false);
@@ -376,7 +399,7 @@
 
         // Remember the old manually selected tab index so that it can be restored if it is
         // overwritten by one of the programmatic tab selections
-        final int savedTabIndex = mLastManuallySelectedTab;
+        final int savedTabIndex = mLastManuallySelectedFragment;
 
         final int tabIndex;
         if (DialpadFragment.phoneIsInUse() || isDialIntent(intent)) {
@@ -384,13 +407,13 @@
         } else if (recentCallsRequest) {
             tabIndex = TAB_INDEX_CALL_LOG;
         } else {
-            tabIndex = mLastManuallySelectedTab;
+            tabIndex = mLastManuallySelectedFragment;
         }
-        mViewPager.setCurrentItem(tabIndex);
+        mViewPager.setCurrentItem(tabIndex, false /* smoothScroll */);
         getActionBar().selectTab(getActionBar().getTabAt(tabIndex));
 
         // Restore to the previous manual selection
-        mLastManuallySelectedTab = savedTabIndex;
+        mLastManuallySelectedFragment = savedTabIndex;
     }
 
     @Override
@@ -404,7 +427,7 @@
         } else if (isDialIntent(newIntent)) {
             setupDialUri(newIntent);
         }
-        if (mPhoneNumberPickerFragment.isVisible()) {
+        if (mSearchFragment.isVisible()) {
             exitSearchUi();
         }
     }
@@ -511,27 +534,21 @@
 
         @Override
         public void onTabUnselected(Tab tab, FragmentTransaction ft) {
-            if (mFragment instanceof ViewPagerVisibilityListener) {
-                ((ViewPagerVisibilityListener) mFragment).onVisibilityChange(false);
-            }
         }
 
         @Override
         public void onTabSelected(Tab tab, FragmentTransaction ft) {
-            if (mFragment instanceof ViewPagerVisibilityListener) {
-                ((ViewPagerVisibilityListener) mFragment).onVisibilityChange(true);
-            }
             if (mViewPager.getCurrentItem() != tab.getPosition()) {
                 mViewPager.setCurrentItem(tab.getPosition(), false /* smoothScroll */);
             }
-            ft.hide(mPhoneNumberPickerFragment);
+            ft.hide(mSearchFragment);
 
             // During the call, we don't remember the tab position.
             if (!DialpadFragment.phoneIsInUse()) {
                 // Remember this tab index. This function is also called, if the tab is set
                 // automatically in which case the setter (setCurrentTab) has to set this to its old
                 // value afterwards
-                mLastManuallySelectedTab = tab.getPosition();
+                mLastManuallySelectedFragment = tab.getPosition();
             }
         }
 
@@ -551,62 +568,34 @@
 
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
-        // For now, create the menu in here. It would be nice to do this in the Fragment,
-        // but that Fragment is re-used in other views.
-        final ActionBar actionBar = getActionBar();
-        if (actionBar == null) return false;
-        final Tab tab = actionBar.getSelectedTab();
-        if (tab == null) return false;
-        final int tabIndex = tab.getPosition();
-        if (tabIndex != TAB_INDEX_FAVORITES) return false;
-
         MenuInflater inflater = getMenuInflater();
-        inflater.inflate(R.menu.list, menu);
+        inflater.inflate(R.menu.dialtacts_options, menu);
         return true;
     }
 
     @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        // This is currently a copy of the equivalent code of PeopleActivity (with the
-        // exception of menu_add, because we do not select items in the list).
-        // Should be consolidated
-        switch (item.getItemId()) {
-        case R.id.menu_settings: {
-            final Intent intent = new Intent(this, ContactsPreferenceActivity.class);
-            startActivity(intent);
-            return true;
-        }
-        case R.id.menu_search: {
-            onSearchRequested();
-            return true;
-        }
-        case R.id.menu_add: {
-            final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
-            startActivity(intent);
-            return true;
-        }
-        case R.id.menu_import_export: {
-            ImportExportDialogFragment.show(getFragmentManager());
-            return true;
-        }
-        case R.id.menu_accounts: {
-            final Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
-            intent.putExtra(Settings.EXTRA_AUTHORITIES, new String[] {
-                ContactsContract.AUTHORITY
+    public boolean onPrepareOptionsMenu(Menu menu) {
+        final MenuItem searchMenuItem = menu.findItem(R.id.search_on_action_bar);
+        if (mInSearchUi || getActionBar().getSelectedTab().getPosition() == TAB_INDEX_DIALER) {
+            searchMenuItem.setVisible(false);
+        } else {
+            searchMenuItem.setVisible(true);
+            searchMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+                @Override
+                public boolean onMenuItemClick(MenuItem item) {
+                    enterSearchUi();
+                    return true;
+                }
             });
-            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
-            startActivity(intent);
-            return true;
         }
-        default:
-            return super.onOptionsItemSelected(item);
-        }
+
+        return true;
     }
 
     @Override
     public void startSearch(String initialQuery, boolean selectInitialQuery,
             Bundle appSearchData, boolean globalSearch) {
-        if (mPhoneNumberPickerFragment != null && mPhoneNumberPickerFragment.isAdded()
+        if (mSearchFragment != null && mSearchFragment.isAdded()
                 && !globalSearch) {
             enterSearchUi();
         } else {
@@ -624,7 +613,7 @@
 
         // User can search during the call, but we don't want to remember the status.
         if (tab != null && !DialpadFragment.phoneIsInUse()) {
-            mLastManuallySelectedTab = tab.getPosition();
+            mLastManuallySelectedFragment = tab.getPosition();
         }
 
         // Instantiate or reset SearchView in ActionBar.
@@ -666,7 +655,7 @@
 
         // Show the search fragment and hide everything else.
         final FragmentTransaction transaction = getFragmentManager().beginTransaction();
-        transaction.show(mPhoneNumberPickerFragment);
+        transaction.show(mSearchFragment);
         transaction.commit();
         mViewPager.setVisibility(View.GONE);
 
@@ -692,7 +681,7 @@
         actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
 
         final FragmentTransaction transaction = getFragmentManager().beginTransaction();
-        transaction.hide(mPhoneNumberPickerFragment);
+        transaction.hide(mSearchFragment);
         transaction.commit();
 
         mViewPager.setVisibility(View.VISIBLE);
@@ -702,4 +691,17 @@
 
         mInSearchUi = false;
     }
+
+    private Fragment getFragmentAt(int position) {
+        switch (position) {
+            case TAB_INDEX_DIALER:
+                return mDialpadFragment;
+            case TAB_INDEX_CALL_LOG:
+                return mCallLogFragment;
+            case TAB_INDEX_FAVORITES:
+                return mStrequentFragment;
+            default:
+                throw new IllegalStateException("Unknown fragment index: " + position);
+        }
+    }
 }
diff --git a/src/com/android/contacts/calllog/CallLogFragment.java b/src/com/android/contacts/calllog/CallLogFragment.java
index 8b09e28..a9aa4b6 100644
--- a/src/com/android/contacts/calllog/CallLogFragment.java
+++ b/src/com/android/contacts/calllog/CallLogFragment.java
@@ -144,7 +144,6 @@
     private String mCurrentCountryIso;
     private boolean mScrollToTop;
 
-    private MenuItem mDeleteAllCallLogMenuItem;
     private boolean mShowMenu;
 
     public static final class ContactInfo {
@@ -905,14 +904,12 @@
     @Override
     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
         super.onCreateOptionsMenu(menu, inflater);
-        mDeleteAllCallLogMenuItem = menu.add(0, OptionsMenuItems.DELETE_ALL,
-                0, R.string.recentCalls_deleteAll)
-                .setIcon(android.R.drawable.ic_menu_close_clear_cancel);
+        inflater.inflate(R.menu.call_log_options, menu);
     }
 
     @Override
     public void onPrepareOptionsMenu(Menu menu) {
-        mDeleteAllCallLogMenuItem.setVisible(mShowMenu);
+        menu.findItem(R.id.delete_all).setVisible(mShowMenu);
     }
 
     @Override
@@ -1146,7 +1143,7 @@
     }
 
     @Override
-    public void onVisibilityChange(boolean visible) {
+    public void onVisibilityChanged(boolean visible) {
         mShowMenu = visible;
     }
 }
diff --git a/src/com/android/contacts/dialpad/DialpadFragment.java b/src/com/android/contacts/dialpad/DialpadFragment.java
index 70dd4b1..6946635 100644
--- a/src/com/android/contacts/dialpad/DialpadFragment.java
+++ b/src/com/android/contacts/dialpad/DialpadFragment.java
@@ -95,7 +95,6 @@
 
     private EditText mDigits;
     private View mDelete;
-    private MenuItem mAddToContactMenuItem;
     private ToneGenerator mToneGenerator;
     private Object mToneGeneratorLock = new Object();
     private Drawable mDigitsBackground;
@@ -110,15 +109,6 @@
     private ListView mDialpadChooser;
     private DialpadChooserAdapter mDialpadChooserAdapter;
 
-    // Member variables for dialpad options
-    private MenuItem m2SecPauseMenuItem;
-    private MenuItem mWaitMenuItem;
-    private MenuItem mCallSettingsItem;
-    private static final int MENU_ADD_CONTACTS = 1;
-    private static final int MENU_2S_PAUSE = 2;
-    private static final int MENU_WAIT = 3;
-    private static final int MENU_CALL_SETTINGS = 4;
-
     private boolean mShowMenu;
 
     private boolean mHasVoicemail = false;
@@ -513,15 +503,7 @@
     @Override
     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
         super.onCreateOptionsMenu(menu, inflater);
-
-        mAddToContactMenuItem = menu.add(0, MENU_ADD_CONTACTS, 0, R.string.recentCalls_addToContact)
-                .setIcon(android.R.drawable.ic_menu_add);
-        m2SecPauseMenuItem = menu.add(0, MENU_2S_PAUSE, 0, R.string.add_2sec_pause)
-                .setIcon(R.drawable.ic_menu_2sec_pause);
-        mWaitMenuItem = menu.add(0, MENU_WAIT, 0, R.string.add_wait)
-                .setIcon(R.drawable.ic_menu_wait);
-        // TODO: icon
-        mCallSettingsItem = menu.add(0, MENU_CALL_SETTINGS, 0, R.string.call_settings);
+        inflater.inflate(R.menu.dialpad_options, menu);
     }
 
     @Override
@@ -531,9 +513,14 @@
             return;
         }
 
+        final MenuItem addToContactMenuItem = menu.findItem(R.id.menu_add_contacts);
+        final MenuItem m2SecPauseMenuItem = menu.findItem(R.id.menu_2s_pause);
+        final MenuItem mWaitMenuItem = menu.findItem(R.id.menu_add_wait);
+        final MenuItem mCallSettingsItem = menu.findItem(R.id.menu_call_settings);
+
         if (!mShowMenu) {
             mCallSettingsItem.setVisible(false);
-            mAddToContactMenuItem.setVisible(false);
+            addToContactMenuItem.setVisible(false);
             m2SecPauseMenuItem.setVisible(false);
             mWaitMenuItem.setVisible(false);
             return;
@@ -548,7 +535,7 @@
         // seeing usual dialpads and has typed at least one digit.
         // We never show a menu if the "choose dialpad" UI is up.
         if (dialpadChooserVisible() || isDigitsEmpty()) {
-            mAddToContactMenuItem.setVisible(false);
+            addToContactMenuItem.setVisible(false);
             m2SecPauseMenuItem.setVisible(false);
             mWaitMenuItem.setVisible(false);
         } else {
@@ -558,8 +545,8 @@
             Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
             intent.putExtra(Insert.PHONE, digits);
             intent.setType(People.CONTENT_ITEM_TYPE);
-            mAddToContactMenuItem.setIntent(intent);
-            mAddToContactMenuItem.setVisible(true);
+            addToContactMenuItem.setIntent(intent);
+            addToContactMenuItem.setVisible(true);
 
             // Check out whether to show Pause & Wait option menu items
             int selectionStart;
@@ -1075,10 +1062,10 @@
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         switch (item.getItemId()) {
-            case MENU_2S_PAUSE:
+            case R.id.menu_2s_pause:
                 updateDialString(",");
                 return true;
-            case MENU_WAIT:
+            case R.id.menu_add_wait:
                 updateDialString(";");
                 return true;
         }
@@ -1234,7 +1221,7 @@
     }
 
     @Override
-    public void onVisibilityChange(boolean visible) {
+    public void onVisibilityChanged(boolean visible) {
         mShowMenu = visible;
     }
 }