diff options
author | Nancy Chen <nancychen@google.com> | 2014-06-18 17:16:10 -0700 |
---|---|---|
committer | Nancy Chen <nancychen@google.com> | 2014-06-19 16:54:38 -0700 |
commit | 8e0662990043a3b430a96d8e94b9d773f5a4deff (patch) | |
tree | 94afbefc9dc36d17f3ae5a82baf590e611f7480a | |
parent | da9fe01f539ca50251003d5c783aec434be23d3c (diff) |
Add reference to TelephonyManager, renaming, remove checkbox (1/2)
Incorporating API calls to TelephonyManager.getSubscriptions.
Added new SubscriptionManager class to wrap data about subscriptions for
the purpose of passing between Dialer and its fragments.
* This particular CL deals with the renaming of the menu strings and the
* passing of data between the Dialer and its fragments.
Bug: 15473965
Change-Id: Id52b925c618952bd77970c157fa63e665203b04c
-rw-r--r-- | res/menu/dialpad_options.xml | 4 | ||||
-rw-r--r-- | res/menu/dialtacts_options.xml | 4 | ||||
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 41 | ||||
-rw-r--r-- | src/com/android/dialer/dialpad/DialpadFragment.java | 25 |
5 files changed, 32 insertions, 44 deletions
diff --git a/res/menu/dialpad_options.xml b/res/menu/dialpad_options.xml index c1f25153f..311a5eee6 100644 --- a/res/menu/dialpad_options.xml +++ b/res/menu/dialpad_options.xml @@ -19,8 +19,8 @@ android:title="@string/add_contact" android:showAsAction="withText" /> <item - android:id="@+id/menu_select_sim" - android:title="@string/menu_select_sim" + android:id="@+id/menu_select_subscription" + android:title="@string/menu_select_subscription" android:showAsAction="withText" /> <item android:id="@+id/menu_2s_pause" diff --git a/res/menu/dialtacts_options.xml b/res/menu/dialtacts_options.xml index d1c885409..558cbd856 100644 --- a/res/menu/dialtacts_options.xml +++ b/res/menu/dialtacts_options.xml @@ -20,8 +20,8 @@ android:icon="@drawable/ic_menu_history_lt" android:title="@string/action_menu_call_history_description" /> <item - android:id="@+id/menu_select_sim" - android:title="@string/menu_select_sim" /> + android:id="@+id/menu_select_subscription" + android:title="@string/menu_select_subscription" /> <item android:id="@+id/menu_import_export" android:title="@string/menu_import_export" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index 7513b5008..a6aecc113 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -327,7 +327,7 @@ <string name="add_wait">Add wait</string> <!-- Menu item to select SIM card [CHAR LIMIT=30] --> - <string name="menu_select_sim">Select SIM card</string> + <string name="menu_select_subscription">Select Subscription</string> <!-- Menu item label for call settings [CHAR LIMIT=30] --> <string name="call_settings">Settings</string> diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index d48b28e72..5c2e17e29 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -37,6 +37,7 @@ import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Intents; import android.speech.RecognizerIntent; import android.support.v4.view.ViewPager; +import android.telecomm.Subscription; import android.telephony.TelephonyManager; import android.text.Editable; import android.text.TextUtils; @@ -62,10 +63,11 @@ import android.widget.PopupMenu; import android.widget.Toast; import com.android.contacts.common.CallUtil; +import com.android.contacts.common.SubscriptionManager; 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.dialog.SelectSubscriptionDialogFragment; import com.android.contacts.common.interactions.ImportExportDialogFragment; import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; import com.android.contacts.common.widget.FloatingActionButtonController; @@ -105,13 +107,15 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O OnDragDropListener, OnPhoneNumberPickerActionListener, PopupMenu.OnMenuItemClickListener, - SelectSIMDialogFragment.OnClickOkListener, ViewPager.OnPageChangeListener, ActionBarController.ActivityUi { private static final String TAG = "DialtactsActivity"; public static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); + /** Temporary flag for disabling subscription selection menu */ + public static final boolean ENABLE_SUBSCRIPTION_SELECT = false; + public static final String SHARED_PREFS_NAME = "com.android.dialer_preferences"; /** Used to open Call Setting */ @@ -140,11 +144,6 @@ 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; /** @@ -199,9 +198,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O private boolean mIsLandscape; /** - * Information about the currently selected SIM card. + * Information about the currently selected subscription. */ - private int mCurrentSimCard = NO_MULTI_SIM; + private SubscriptionManager mSubscriptionManager = null; /** * The position of the currently selected tab in the attached {@link ListsFragment}. @@ -369,7 +368,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O mActionBarController = new ActionBarController(this, (SearchEditTextLayout) actionBar.getCustomView()); - SearchEditTextLayout searchEditTextLayout = (SearchEditTextLayout) actionBar.getCustomView(); searchEditTextLayout.setPreImeKeyListener(mSearchEditTextLayoutListener); @@ -390,6 +388,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O mIsLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; + + if (getTelephonyManager().getSubscriptions().size() > 1 && ENABLE_SUBSCRIPTION_SELECT) { + mSubscriptionManager = new SubscriptionManager(getTelephonyManager()); + } + final View floatingActionButtonContainer = findViewById( R.id.floating_action_button_container); mFloatingActionButton = (ImageButton) findViewById(R.id.floating_action_button); @@ -597,22 +600,14 @@ 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); + case R.id.menu_select_subscription: + SelectSubscriptionDialogFragment.show(getFragmentManager(), mSubscriptionManager); return true; } return false; } @Override - public void passSimUpdate(int simId) { - mCurrentSimCard = simId; - if (mIsDialpadShown) { - mDialpadFragment.setSimCard(simId); - } - } - - @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == ACTIVITY_REQUEST_CODE_VOICE_SEARCH) { if (resultCode == RESULT_OK) { @@ -642,7 +637,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O } mIsDialpadShown = true; mDialpadFragment.setAnimate(animate); - mDialpadFragment.setSimCard(mCurrentSimCard); + mDialpadFragment.setSubscriptionManager(mSubscriptionManager); final FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.show(mDialpadFragment); @@ -780,8 +775,8 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O 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); + final MenuItem selectSubscription = menu.findItem(R.id.menu_select_subscription); + selectSubscription.setVisible(mSubscriptionManager != null); popupMenu.setOnMenuItemClickListener(this); return popupMenu; } diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index bb5880295..e7ae7ccad 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -71,7 +71,8 @@ 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.SubscriptionManager; +import com.android.contacts.common.dialog.SelectSubscriptionDialogFragment; import com.android.contacts.common.dialpad.DialpadKeyButton; import com.android.contacts.common.dialpad.DialpadView; import com.android.contacts.common.util.PhoneNumberFormatter; @@ -99,15 +100,7 @@ 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; + private static SubscriptionManager mSubscriptionManager; /** * This interface allows the DialpadFragment to tell its hosting Activity when and when not @@ -861,9 +854,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 selectSubscription = menu.findItem(R.id.menu_select_subscription); final MenuItem sendMessage = menu.findItem(R.id.menu_send_message); - selectSim.setVisible(mCurrentSimCard != NO_MULTI_SIM); + selectSubscription.setVisible(mSubscriptionManager != null); sendMessage.setVisible(mSmsPackageComponentName != null); boolean enable = !isDigitsEmpty(); @@ -1448,8 +1441,8 @@ public class DialpadFragment extends Fragment smsIntent.setComponent(mSmsPackageComponentName); DialerUtils.startActivityWithErrorToast(getActivity(), smsIntent); } - case R.id.menu_select_sim: - SelectSIMDialogFragment.show(getFragmentManager(), mCurrentSimCard); + case R.id.menu_select_subscription: + SelectSubscriptionDialogFragment.show(getFragmentManager(), mSubscriptionManager); return true; default: @@ -1621,8 +1614,8 @@ public class DialpadFragment extends Fragment return mAnimate; } - public void setSimCard(int simId) { - mCurrentSimCard = simId; + public void setSubscriptionManager(SubscriptionManager subscriptionManager) { + mSubscriptionManager = subscriptionManager; } public void setYFraction(float yFraction) { |