From 4c92456688e34683c2879d89b6011b741b33a379 Mon Sep 17 00:00:00 2001 From: Nancy Chen Date: Wed, 11 Jun 2014 15:31:16 -0700 Subject: Add select sim dialog for dialpad menu Also handles passing sim card information set in dialer menu to the dialpad fragment. Bug: 15473965 Change-Id: I075bf727402ba315c035eb741c563aafe67d60f6 --- src/com/android/dialer/DialtactsActivity.java | 4 ++++ src/com/android/dialer/dialpad/DialpadFragment.java | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'src/com') diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index f5a2d3ed5..6144bb5af 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -609,6 +609,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O @Override public void passSimUpdate(int simId) { mCurrentSimCard = simId; + if (mIsDialpadShown) { + mDialpadFragment.setSimCard(simId); + } } @Override @@ -641,6 +644,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O } mIsDialpadShown = true; mDialpadFragment.setAnimate(animate); + mDialpadFragment.setSimCard(mCurrentSimCard); final FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.show(mDialpadFragment); diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index 134c2a7f4..bb5880295 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -71,6 +71,7 @@ import android.widget.TextView; import com.android.contacts.common.CallUtil; import com.android.contacts.common.GeoUtil; +import com.android.contacts.common.dialog.SelectSIMDialogFragment; import com.android.contacts.common.dialpad.DialpadKeyButton; import com.android.contacts.common.dialpad.DialpadView; import com.android.contacts.common.util.PhoneNumberFormatter; @@ -98,6 +99,16 @@ public class DialpadFragment extends Fragment DialpadKeyButton.OnPressedListener { private static final String TAG = DialpadFragment.class.getSimpleName(); + /** + * Constant to indicate there is only a single service provider available + */ + private static final int NO_MULTI_SIM = -1; + + /** + * Information about the currently selected SIM card. + */ + private int mCurrentSimCard = NO_MULTI_SIM; + /** * 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 @@ -850,7 +861,9 @@ public class DialpadFragment extends Fragment @Override public void show() { final Menu menu = getMenu(); + final MenuItem selectSim = menu.findItem(R.id.menu_select_sim); final MenuItem sendMessage = menu.findItem(R.id.menu_send_message); + selectSim.setVisible(mCurrentSimCard != NO_MULTI_SIM); sendMessage.setVisible(mSmsPackageComponentName != null); boolean enable = !isDigitsEmpty(); @@ -1435,6 +1448,10 @@ public class DialpadFragment extends Fragment smsIntent.setComponent(mSmsPackageComponentName); DialerUtils.startActivityWithErrorToast(getActivity(), smsIntent); } + case R.id.menu_select_sim: + SelectSIMDialogFragment.show(getFragmentManager(), mCurrentSimCard); + return true; + default: return false; } @@ -1604,6 +1621,10 @@ public class DialpadFragment extends Fragment return mAnimate; } + public void setSimCard(int simId) { + mCurrentSimCard = simId; + } + public void setYFraction(float yFraction) { ((DialpadSlidingLinearLayout) getView()).setYFraction(yFraction); } -- cgit v1.2.3