From beededb3fb7b3fcc9fa87f2a3ea50cac7415c794 Mon Sep 17 00:00:00 2001 From: Nancy Chen Date: Tue, 10 Jun 2014 18:30:28 -0700 Subject: Add menu items for multi-sim support The main overflow menu will display a "select SIM card" option when more than one sim is available. Bug: 15473965 Change-Id: I18175cec57158f0a8189979849f6ad761eff1aff --- src/com/android/dialer/DialtactsActivity.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src') diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 414569031..a9eb21779 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -66,6 +66,7 @@ import com.android.contacts.common.CallUtil; import com.android.contacts.common.activity.TransactionSafeActivity; import com.android.contacts.common.animation.AnimationListenerAdapter; import com.android.contacts.common.dialog.ClearFrequentsDialog; +import com.android.contacts.common.dialog.SelectSIMDialogFragment; import com.android.contacts.common.interactions.ImportExportDialogFragment; import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; import com.android.contacts.common.util.ViewUtil; @@ -106,6 +107,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O OnDragDropListener, OnPhoneNumberPickerActionListener, PopupMenu.OnMenuItemClickListener, + SelectSIMDialogFragment.OnClickOkListener, ViewPager.OnPageChangeListener, ActionBarController.ActivityUi { private static final String TAG = "DialtactsActivity"; @@ -140,6 +142,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O private static final int ACTIVITY_REQUEST_CODE_VOICE_SEARCH = 1; + /** + * Constant to indicate there is only one service provider available. + */ + private static final int NO_MULTI_SIM = -1; + private FrameLayout parentLayout; /** @@ -193,6 +200,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O */ private boolean mIsLandscape; + /** + * Information about the currently selected SIM card. + */ + private int mCurrentSimCard = NO_MULTI_SIM; + /** * The position of the currently selected tab in the attached {@link ListsFragment}. */ @@ -594,10 +606,18 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O case R.id.menu_call_settings: handleMenuSettings(); return true; + case R.id.menu_select_sim: + SelectSIMDialogFragment.show(getFragmentManager(), mCurrentSimCard); + return true; } return false; } + @Override + public void passSimUpdate(int simId) { + mCurrentSimCard = simId; + } + @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == ACTIVITY_REQUEST_CODE_VOICE_SEARCH) { @@ -764,6 +784,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O private OptionsPopupMenu buildOptionsMenu(View invoker) { final OptionsPopupMenu popupMenu = new OptionsPopupMenu(this, invoker); popupMenu.inflate(R.menu.dialtacts_options); + final Menu menu = popupMenu.getMenu(); + final MenuItem selectSim = menu.findItem(R.id.menu_select_sim); + selectSim.setVisible(mCurrentSimCard != NO_MULTI_SIM); popupMenu.setOnMenuItemClickListener(this); return popupMenu; } -- cgit v1.2.3