diff options
Diffstat (limited to 'src/com/android/dialer/dialpad/DialpadFragment.java')
-rw-r--r-- | src/com/android/dialer/dialpad/DialpadFragment.java | 172 |
1 files changed, 23 insertions, 149 deletions
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index 82d4b8df9..5ebbb4976 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -87,7 +87,6 @@ import com.android.dialer.SpeedDialListActivity; import com.android.dialer.SpeedDialUtils; import com.android.dialer.util.DialerUtils; import com.android.internal.telephony.PhoneConstants; -import com.android.internal.telephony.TelephonyProperties; import com.android.dialer.calllog.PhoneAccountUtils; import com.android.dialer.util.DialerUtils; import com.android.phone.common.CallLogAsync; @@ -116,21 +115,6 @@ public class DialpadFragment extends Fragment private Context mContext; /** - * 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 - * need to have a particular kind of slick animation puts the "dial" button in the parent. - * - * The parent calls dialButtonPressed() and optionsMenuInvoked() on the dialpad fragment - * when appropriate. - * - * TODO: Refactor the app so this interchange is a bit cleaner. - */ - public interface HostInterface { - void setConferenceDialButtonVisibility(boolean enabled); - void setConferenceDialButtonImage(boolean setAddParticipantButton); - } - - /** * LinearLayout with getter and setter methods for the translationY property using floats, * for animation purposes. */ @@ -188,9 +172,6 @@ public class DialpadFragment extends Fragment private DialpadView mDialpadView; private EditText mDigits; - private EditText mRecipients; - private View mDigitsContainer; - private View mDialpad; private int mDialpadSlideInDuration; /** Remembers if we need to clear digits field when the screen is completely gone. */ @@ -277,12 +258,6 @@ public class DialpadFragment extends Fragment // onscreen, but useless...) showDialpadChooser(false); } - if (TextUtils.equals(state, TelephonyManager.EXTRA_STATE_IDLE)) { - final Activity activity = getActivity(); - if (activity != null) { - ((HostInterface) activity).setConferenceDialButtonVisibility(true); - } - } } } @@ -393,13 +368,6 @@ public class DialpadFragment extends Fragment mDialpadView = (DialpadView) fragmentView.findViewById(R.id.dialpad_view); mDialpadView.setCanDigitsBeEdited(true); mDigits = mDialpadView.getDigits(); - mRecipients = (EditText) fragmentView.findViewById(R.id.recipients); - mDigitsContainer = fragmentView.findViewById(R.id.digits_container); - mDialpad = fragmentView.findViewById(R.id.dialpad); - if (mRecipients != null) { - mRecipients.setVisibility(View.GONE); - mRecipients.addTextChangedListener(this); - } mDigits.setKeyListener(UnicodeDialerKeyListener.INSTANCE); mDigits.setOnClickListener(this); mDigits.setOnKeyListener(this); @@ -572,9 +540,6 @@ public class DialpadFragment extends Fragment } } - } else { - mAddParticipant = intent.getBooleanExtra(ADD_PARTICIPANT_KEY, false); - ((HostInterface) getActivity()).setConferenceDialButtonVisibility(true); } showDialpadChooser(needToShowDialpadChooser); setStartedFromNewIntent(false); @@ -976,70 +941,6 @@ public class DialpadFragment extends Fragment handleDialButtonPressed(); } - public void dialConferenceButtonPressed() { - // show dial conference screen if it is not shown - // If it is already shown, show normal dial screen - boolean show = (mRecipients != null) && !mRecipients.isShown(); - Log.d(TAG, "dialConferenceButtonPressed show " + show); - if (show) { - showDialConference(show); - } else { - handleDialButtonPressed(); - showDialConference(!show); - } - } - - public void showDialConference(boolean enabled) { - // Check if onCreateView() is already called by checking one of View - // objects. - if (!isLayoutReady()) { - return; - } - Log.d(TAG, "showDialConference " + enabled); - /* - * if enabled is true then pick child views that should be - * visible/invisible when dialpad is choosen from conference dial button - * if enabled is false then pick child views that should be - * visible/invisible when dialpad is choosen from other buttons - */ - - // viewable when choosen through conference button - int conferenceButtonVisibility = (enabled ? View.VISIBLE : View.GONE); - // not viewable when choosen through conference button - int nonConferenceButtonVisibility = (enabled ? View.GONE : View.VISIBLE); - - // change the image visibility of the button - if (mRecipients != null) - mRecipients.setVisibility(conferenceButtonVisibility); - if (mDigits != null) - mDigits.setVisibility(nonConferenceButtonVisibility); - if (mDelete != null) - mDelete.setVisibility(nonConferenceButtonVisibility); - if (mDialpad != null) - mDialpad.setVisibility(enabled ? View.INVISIBLE : View.VISIBLE); - - if (enabled && (HostInterface)getActivity() != null) { - ((HostInterface)getActivity()).setConferenceDialButtonImage(enabled); - } - } - - public void hideAndClearDialConference() { - // hide the image visibility of the button - if (mRecipients != null) - mRecipients.setVisibility(View.GONE); - if (mDigits != null) - mDigits.setVisibility(View.GONE); - if (mDelete != null) - mDelete.setVisibility(View.GONE); - if (mDialpad != null) - mDialpad.setVisibility(View.GONE); - ((DialtactsActivity) getActivity()).commitDialpadFragmentHide(); - } - - public boolean isRecipientsShown() { - return mRecipients != null && mRecipients.isShown(); - } - @Override public void onClick(View view) { switch (view.getId()) { @@ -1310,52 +1211,32 @@ public class DialpadFragment extends Fragment * case described above). */ private void handleDialButtonPressed() { - if (isDigitsEmpty() && (mRecipients == null || !mRecipients.isShown())) { - // No number entered. + if (isDigitsEmpty()) { // No number entered. handleDialButtonClickWithEmptyDigits(); } else { - boolean isDigitsShown = mDigits.isShown(); - final String number = isDigitsShown ? mDigits.getText().toString() : - mRecipients.getText().toString().trim(); - if (isDigitsShown && isDigitsEmpty()) { - handleDialButtonClickWithEmptyDigits(); - } else if (mAddParticipant && isDigitsEmpty() && mRecipients.isShown() - && isRecipientEmpty()) { - // mRecipients must be empty - // TODO add support for conference URI in last number dialed - // use ErrorDialogFragment instead? also see - // android.app.AlertDialog - android.widget.Toast.makeText(getActivity(), - "Error: Cannot dial. Please provide conference recipients.", - android.widget.Toast.LENGTH_SHORT).show(); - } else { - // "persist.radio.otaspdial" is a temporary hack needed for one carrier's automated - // test equipment. - // TODO: clean it up. - if (number != null - && !TextUtils.isEmpty(mProhibitedPhoneNumberRegexp) - && number.matches(mProhibitedPhoneNumberRegexp)) { - Log.i(TAG, "The phone number is prohibited explicitly by a rule."); - if (getActivity() != null) { - DialogFragment dialogFragment = ErrorDialogFragment.newInstance( - R.string.dialog_phone_call_prohibited_message); - dialogFragment.show(getFragmentManager(), "phone_prohibited_dialog"); - } - - // Clear the digits just in case. - clearDialpad(); - } else { - final Intent intent = CallUtil.getCallIntent(number, - (getActivity() instanceof DialtactsActivity ? - ((DialtactsActivity) getActivity()).getCallOrigin() : null)); - if (!isDigitsShown) { - // must be dial conference add extra - intent.putExtra(TelephonyProperties.EXTRA_DIAL_CONFERENCE_URI, true); - } - intent.putExtra(ADD_PARTICIPANT_KEY, mAddParticipant); - DialerUtils.startActivityWithErrorToast(getActivity(), intent); - hideAndClearDialpad(false); + final String number = mDigits.getText().toString(); + + // "persist.radio.otaspdial" is a temporary hack needed for one carrier's automated + // test equipment. + // TODO: clean it up. + if (number != null + && !TextUtils.isEmpty(mProhibitedPhoneNumberRegexp) + && number.matches(mProhibitedPhoneNumberRegexp)) { + Log.i(TAG, "The phone number is prohibited explicitly by a rule."); + if (getActivity() != null) { + DialogFragment dialogFragment = ErrorDialogFragment.newInstance( + R.string.dialog_phone_call_prohibited_message); + dialogFragment.show(getFragmentManager(), "phone_prohibited_dialog"); } + + // Clear the digits just in case. + clearDialpad(); + } else { + final Intent intent = CallUtil.getCallIntent(number, + (getActivity() instanceof DialtactsActivity ? + ((DialtactsActivity) getActivity()).getCallOrigin() : null)); + DialerUtils.startActivityWithErrorToast(getActivity(), intent); + hideAndClearDialpad(false); } } } @@ -1884,13 +1765,6 @@ public class DialpadFragment extends Fragment } /** - * @return true if the widget with the mRecipients is empty. - */ - private boolean isRecipientEmpty() { - return (mRecipients == null) || (mRecipients.length() == 0); - } - - /** * Starts the asyn query to get the last dialed/outgoing * number. When the background query finishes, mLastNumberDialed * is set to the last dialed number or an empty string if none |