From 291e976e870d05ec9dd9d8286fb7291c0a76a523 Mon Sep 17 00:00:00 2001 From: Chiao Cheng Date: Mon, 5 Nov 2012 18:27:03 -0800 Subject: Change dial pad to show chooser onStart instead of onCreate. This fixes the problem where the chooser is not shown when the dialpad is started and pushed to recents before a call comes in. When the call comes and dial pad is selected from recents, the dialpad is shown. Instead, we should be showing the chooser so the user has the option of getting back into the call. Bug: 5761141 Change-Id: I315117c6607dbb71e5359cf98785591d20c21881 --- .../android/dialer/dialpad/DialpadFragment.java | 80 ++++++++++------------ 1 file changed, 37 insertions(+), 43 deletions(-) (limited to 'src/com/android/dialer/dialpad/DialpadFragment.java') diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index 2b77b4619..093e47d97 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -199,6 +199,8 @@ public class DialpadFragment extends Fragment */ private boolean mDigitsFilledByIntent; + private boolean mStartedFromNewIntent = false; + private static final String PREF_DIGITS_FILLED_BY_INTENT = "pref_digits_filled_by_intent"; /** @@ -334,8 +336,6 @@ public class DialpadFragment extends Fragment mDialpadChooser = (ListView) fragmentView.findViewById(R.id.dialpadChooser); mDialpadChooser.setOnItemClickListener(this); - configureScreenFromIntent(getActivity().getIntent()); - return fragmentView; } @@ -392,45 +392,11 @@ public class DialpadFragment extends Fragment } /** - * @see #showDialpadChooser(boolean) + * Determines whether an add call operation is requested. + * + * @param intent The intent. + * @return {@literal true} if add call operation was requested. {@literal false} otherwise. */ - private static boolean needToShowDialpadChooser(Intent intent, boolean isAddCallMode) { - final String action = intent.getAction(); - - boolean needToShowDialpadChooser = false; - - if (Intent.ACTION_DIAL.equals(action) || Intent.ACTION_VIEW.equals(action)) { - Uri uri = intent.getData(); - if (uri == null) { - // ACTION_DIAL or ACTION_VIEW with no data. - // This behaves basically like ACTION_MAIN: If there's - // already an active call, bring up an intermediate UI to - // make the user confirm what they really want to do. - // Be sure *not* to show the dialpad chooser if this is an - // explicit "Add call" action, though. - if (!isAddCallMode && phoneIsInUse()) { - needToShowDialpadChooser = true; - } - } - } else if (Intent.ACTION_MAIN.equals(action)) { - // The MAIN action means we're bringing up a blank dialer - // (e.g. by selecting the Home shortcut, or tabbing over from - // Contacts or Call log.) - // - // At this point, IF there's already an active call, there's a - // good chance that the user got here accidentally (but really - // wanted the in-call dialpad instead). So we bring up an - // intermediate UI to make the user confirm what they really - // want to do. - if (phoneIsInUse()) { - // Log.i(TAG, "resolveIntent(): phone is in use; showing dialpad chooser!"); - needToShowDialpadChooser = true; - } - } - - return needToShowDialpadChooser; - } - private static boolean isAddCallMode(Intent intent) { final String action = intent.getAction(); if (Intent.ACTION_DIAL.equals(action) || Intent.ACTION_VIEW.equals(action)) { @@ -445,7 +411,7 @@ public class DialpadFragment extends Fragment * Checks the given Intent and changes dialpad's UI state. For example, if the Intent requires * the screen to enter "Add Call" mode, this method will show correct UI for the mode. */ - public void configureScreenFromIntent(Intent intent) { + private void configureScreenFromIntent(Intent intent) { if (!isLayoutReady()) { // This happens typically when parent's Activity#onNewIntent() is called while // Fragment#onCreateView() isn't called yet, and thus we cannot configure Views at @@ -458,16 +424,37 @@ public class DialpadFragment extends Fragment boolean needToShowDialpadChooser = false; + // Be sure *not* to show the dialpad chooser if this is an + // explicit "Add call" action, though. final boolean isAddCallMode = isAddCallMode(intent); if (!isAddCallMode) { + + // Don't show the chooser when called via onNewIntent() and phone number is present. + // i.e. User clicks a telephone link from gmail for example. + // In this case, we want to show the dialpad with the phone number. final boolean digitsFilled = fillDigitsIfNecessary(intent); - if (!digitsFilled) { - needToShowDialpadChooser = needToShowDialpadChooser(intent, isAddCallMode); + if (!(mStartedFromNewIntent && digitsFilled)) { + + final String action = intent.getAction(); + if (Intent.ACTION_DIAL.equals(action) || Intent.ACTION_VIEW.equals(action) + || Intent.ACTION_MAIN.equals(action)) { + // If there's already an active call, bring up an intermediate UI to + // make the user confirm what they really want to do. + if (phoneIsInUse()) { + needToShowDialpadChooser = true; + } + } + } } + showDialpadChooser(needToShowDialpadChooser); } + public void setStartedFromNewIntent(boolean value) { + mStartedFromNewIntent = value; + } + /** * Sets formatted digits to digits field. */ @@ -500,6 +487,13 @@ public class DialpadFragment extends Fragment } + @Override + public void onStart() { + super.onStart(); + configureScreenFromIntent(getActivity().getIntent()); + setStartedFromNewIntent(false); + } + @Override public void onResume() { super.onResume(); -- cgit v1.2.3