From e5f129841ac6527b3685b948b50956f32f83c71e Mon Sep 17 00:00:00 2001 From: Danny Baumann Date: Fri, 16 Aug 2013 07:59:34 +0200 Subject: Hide 'set default' checkbox if it's not going to be looked at next time anyway. Change-Id: I2eb5559c3c0b61481d4f526b2198fd0372163d65 --- .../dialer/interactions/PhoneNumberInteraction.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/com/android/dialer/interactions/PhoneNumberInteraction.java b/src/com/android/dialer/interactions/PhoneNumberInteraction.java index 5321bc285..ba6d73cb0 100644 --- a/src/com/android/dialer/interactions/PhoneNumberInteraction.java +++ b/src/com/android/dialer/interactions/PhoneNumberInteraction.java @@ -187,6 +187,7 @@ public class PhoneNumberInteraction implements OnLoadCompleteListener { private static final String ARG_PHONE_LIST = "phoneList"; private static final String ARG_INTERACTION_TYPE = "interactionType"; private static final String ARG_CALL_ORIGIN = "callOrigin"; + private static final String ARG_CAN_SAVE_PRIMARY = "canSavePrimary"; private int mInteractionType; private ListAdapter mPhonesAdapter; @@ -195,12 +196,13 @@ public class PhoneNumberInteraction implements OnLoadCompleteListener { public static void show(FragmentManager fragmentManager, ArrayList phoneList, int interactionType, - String callOrigin) { + String callOrigin, boolean canSavePrimary) { PhoneDisambiguationDialogFragment fragment = new PhoneDisambiguationDialogFragment(); Bundle bundle = new Bundle(); bundle.putParcelableArrayList(ARG_PHONE_LIST, phoneList); bundle.putSerializable(ARG_INTERACTION_TYPE, interactionType); bundle.putString(ARG_CALL_ORIGIN, callOrigin); + bundle.putBoolean(ARG_CAN_SAVE_PRIMARY, canSavePrimary); fragment.setArguments(bundle); fragment.show(fragmentManager, TAG); } @@ -213,8 +215,13 @@ public class PhoneNumberInteraction implements OnLoadCompleteListener { mCallOrigin = getArguments().getString(ARG_CALL_ORIGIN); mPhonesAdapter = new PhoneItemAdapter(activity, mPhoneList, mInteractionType); - final LayoutInflater inflater = activity.getLayoutInflater(); - final View setPrimaryView = inflater.inflate(R.layout.set_primary_checkbox, null); + + View setPrimaryView = null; + if (getArguments().getBoolean(ARG_CAN_SAVE_PRIMARY)) { + final LayoutInflater inflater = activity.getLayoutInflater(); + setPrimaryView = inflater.inflate(R.layout.set_primary_checkbox, null); + } + return new AlertDialog.Builder(activity) .setAdapter(mPhonesAdapter, this) .setTitle(mInteractionType == ContactDisplayUtils.INTERACTION_SMS @@ -231,7 +238,7 @@ public class PhoneNumberInteraction implements OnLoadCompleteListener { if (mPhoneList.size() > which && which >= 0) { final PhoneItem phoneItem = mPhoneList.get(which); final CheckBox checkBox = (CheckBox)alertDialog.findViewById(R.id.setPrimary); - if (checkBox.isChecked()) { + if (checkBox != null && checkBox.isChecked()) { // Request to mark the data as primary in the background. final Intent serviceIntent = ContactUpdateService.createSetSuperPrimaryIntent( activity, phoneItem.id); @@ -500,6 +507,6 @@ public class PhoneNumberInteraction implements OnLoadCompleteListener { @VisibleForTesting /* package */ void showDisambiguationDialog(ArrayList phoneList) { PhoneDisambiguationDialogFragment.show(((Activity)mContext).getFragmentManager(), - phoneList, mInteractionType, mCallOrigin); + phoneList, mInteractionType, mCallOrigin, mUseDefault); } } -- cgit v1.2.3