Remove SelectAccountDialogFragment for PhoneAccount on Dialer app (1/2)

One-time select will no longer be available within the dialer app so the
fragment and menu item have been removed.

Bug: 15473965
Change-Id: I13410b328f5b5ce887b8f3a9ba2c734d58008c56
diff --git a/res/menu/dialpad_options.xml b/res/menu/dialpad_options.xml
index b977ef9..49ee37d 100644
--- a/res/menu/dialpad_options.xml
+++ b/res/menu/dialpad_options.xml
@@ -19,10 +19,6 @@
         android:title="@string/add_contact"
         android:showAsAction="withText" />
     <item
-        android:id="@+id/menu_select_account"
-        android:title="@string/menu_select_account"
-        android:showAsAction="withText" />
-    <item
         android:id="@+id/menu_2s_pause"
         android:title="@string/add_2sec_pause"
         android:showAsAction="withText" />
diff --git a/res/menu/dialtacts_options.xml b/res/menu/dialtacts_options.xml
index a410b43..17f4d9f 100644
--- a/res/menu/dialtacts_options.xml
+++ b/res/menu/dialtacts_options.xml
@@ -20,9 +20,6 @@
         android:icon="@drawable/ic_menu_history_lt"
         android:title="@string/action_menu_call_history_description" />
     <item
-        android:id="@+id/menu_select_account"
-        android:title="@string/menu_select_account" />
-    <item
         android:id="@+id/menu_import_export"
         android:title="@string/menu_import_export" />
     <item
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index b40a5fc..7e14e22 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -37,7 +37,6 @@
 import android.provider.ContactsContract.Intents;
 import android.speech.RecognizerIntent;
 import android.support.v4.view.ViewPager;
-import android.telecomm.PhoneAccount;
 import android.telephony.TelephonyManager;
 import android.text.Editable;
 import android.text.TextUtils;
@@ -63,10 +62,8 @@
 import android.widget.Toast;
 
 import com.android.contacts.common.CallUtil;
-import com.android.contacts.common.PhoneAccountManager;
 import com.android.contacts.common.activity.TransactionSafeActivity;
 import com.android.contacts.common.dialog.ClearFrequentsDialog;
-import com.android.contacts.common.dialog.SelectAccountDialogFragment;
 import com.android.contacts.common.interactions.ImportExportDialogFragment;
 import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
 import com.android.contacts.common.widget.FloatingActionButtonController;
@@ -199,11 +196,6 @@
     private boolean mIsLandscape;
 
     /**
-     * Information about the currently selected account.
-     */
-    private PhoneAccountManager mAccountManager = null;
-
-    /**
      * The position of the currently selected tab in the attached {@link ListsFragment}.
      */
     private int mCurrentTabPosition = 0;
@@ -390,10 +382,6 @@
         mIsLandscape = getResources().getConfiguration().orientation
                 == Configuration.ORIENTATION_LANDSCAPE;
 
-        if (getTelephonyManager().getAccounts().size() > 1 && ENABLE_ACCOUNT_SELECT) {
-            mAccountManager = new PhoneAccountManager(getTelephonyManager());
-        }
-
         final View floatingActionButtonContainer = findViewById(
                 R.id.floating_action_button_container);
         mFloatingActionButton = (ImageButton) findViewById(R.id.floating_action_button);
@@ -601,9 +589,6 @@
             case R.id.menu_call_settings:
                 handleMenuSettings();
                 return true;
-            case R.id.menu_select_account:
-                SelectAccountDialogFragment.show(getFragmentManager(), mAccountManager);
-                return true;
         }
         return false;
     }
@@ -638,7 +623,6 @@
         }
         mIsDialpadShown = true;
         mDialpadFragment.setAnimate(animate);
-        mDialpadFragment.setAccountManager(mAccountManager);
 
         final FragmentTransaction ft = getFragmentManager().beginTransaction();
         ft.show(mDialpadFragment);
@@ -776,8 +760,6 @@
         final OptionsPopupMenu popupMenu = new OptionsPopupMenu(this, invoker);
         popupMenu.inflate(R.menu.dialtacts_options);
         final Menu menu = popupMenu.getMenu();
-        final MenuItem selectAccount = menu.findItem(R.id.menu_select_account);
-        selectAccount.setVisible(mAccountManager != null);
         popupMenu.setOnMenuItemClickListener(this);
         return popupMenu;
     }
@@ -1112,11 +1094,9 @@
 
     @Override
     public void onCallNumberDirectly(String phoneNumber, boolean isVideoCall) {
-        final PhoneAccount account = mAccountManager != null ?
-                mAccountManager.getCurrentAccount() : null;
         Intent intent = isVideoCall ?
-                CallUtil.getVideoCallIntent(phoneNumber, getCallOrigin(), account) :
-                CallUtil.getCallIntent(phoneNumber, getCallOrigin(), account);
+                CallUtil.getVideoCallIntent(phoneNumber, getCallOrigin()) :
+                CallUtil.getCallIntent(phoneNumber, getCallOrigin());
         DialerUtils.startActivityWithErrorToast(this, intent);
         mClearSearchOnPause = true;
     }
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index 0c1450a..450b9af 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -39,7 +39,6 @@
 import android.provider.Contacts.Phones;
 import android.provider.Contacts.PhonesColumns;
 import android.provider.Settings;
-import android.telecomm.PhoneAccount;
 import android.telephony.PhoneNumberUtils;
 import android.telephony.PhoneStateListener;
 import android.telephony.TelephonyManager;
@@ -68,9 +67,6 @@
 
 import com.android.contacts.common.CallUtil;
 import com.android.contacts.common.GeoUtil;
-
-import com.android.contacts.common.PhoneAccountManager;
-import com.android.contacts.common.dialog.SelectAccountDialogFragment;
 import com.android.contacts.common.util.PhoneNumberFormatter;
 import com.android.contacts.common.util.StopWatch;
 import com.android.dialer.DialtactsActivity;
@@ -97,8 +93,6 @@
         DialpadKeyButton.OnPressedListener {
     private static final String TAG = DialpadFragment.class.getSimpleName();
 
-    private static PhoneAccountManager mAccountManager;
-
     /**
      * This interface allows the DialpadFragment to tell its hosting Activity when and when not
      * to display the "dial" button. While this is logically part of the DialpadFragment, the
@@ -852,9 +846,7 @@
             @Override
             public void show() {
                 final Menu menu = getMenu();
-                final MenuItem selectAccount = menu.findItem(R.id.menu_select_account);
                 final MenuItem sendMessage = menu.findItem(R.id.menu_send_message);
-                selectAccount.setVisible(mAccountManager != null);
                 sendMessage.setVisible(mSmsPackageComponentName != null);
 
                 boolean enable = !isDigitsEmpty();
@@ -1073,15 +1065,9 @@
                 // Clear the digits just in case.
                 clearDialpad();
             } else {
-                final PhoneAccount account = mAccountManager != null?
-                        mAccountManager.getCurrentAccount() : null;
-
-
                 final Intent intent = CallUtil.getCallIntent(number,
                         (getActivity() instanceof DialtactsActivity ?
-                                ((DialtactsActivity) getActivity()).getCallOrigin() : null),
-                        account
-                );
+                                ((DialtactsActivity) getActivity()).getCallOrigin() : null));
                 DialerUtils.startActivityWithErrorToast(getActivity(), intent);
                 hideAndClearDialpad(false);
             }
@@ -1441,10 +1427,6 @@
                 DialerUtils.startActivityWithErrorToast(getActivity(), smsIntent);
                 return true;
             }
-            case R.id.menu_select_account:
-              SelectAccountDialogFragment.show(getFragmentManager(), mAccountManager);
-              return true;
-
             default:
                 return false;
         }
@@ -1614,10 +1596,6 @@
         return mAnimate;
     }
 
-    public void setAccountManager(PhoneAccountManager accountManager) {
-        mAccountManager = accountManager;
-    }
-
     public void setYFraction(float yFraction) {
         ((DialpadSlidingLinearLayout) getView()).setYFraction(yFraction);
     }