From 48cce92eeaf16280b48987da4e020d1e09f96289 Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Thu, 14 Sep 2017 14:28:46 -0700 Subject: Dialpad chooser now properly shows when in a call. Bug: 65212837 Test: DialpadFragmentTest PiperOrigin-RevId: 168745371 Change-Id: I62da45cdac58e3387343589b952e5d6bce7a4ee2 --- java/com/android/dialer/app/DialtactsActivity.java | 8 +- .../dialer/dialpadview/DialpadFragment.java | 92 +++++++++++----------- 2 files changed, 49 insertions(+), 51 deletions(-) (limited to 'java/com') diff --git a/java/com/android/dialer/app/DialtactsActivity.java b/java/com/android/dialer/app/DialtactsActivity.java index ec67f5498..0b2f37505 100644 --- a/java/com/android/dialer/app/DialtactsActivity.java +++ b/java/com/android/dialer/app/DialtactsActivity.java @@ -1074,12 +1074,14 @@ public class DialtactsActivity extends TransactionSafeActivity && phoneIsInUse() && !DialpadFragment.isAddCallMode(intent); boolean isDialIntent = intent.getData() != null && isDialIntent(intent); - if (showDialpadChooser || isDialIntent) { + boolean isAddCallIntent = DialpadFragment.isAddCallMode(intent); + if (showDialpadChooser || isDialIntent || isAddCallIntent) { LogUtil.i( "DialtactsActivity.displayFragment", - "showing dialpad fragment (showDialpadChooser: %b, isDialIntent: %b)", + "show dialpad fragment (showDialpadChooser: %b, isDialIntent: %b, isAddCallIntent: %b)", showDialpadChooser, - isDialIntent); + isDialIntent, + isAddCallIntent); showDialpadFragment(false); mDialpadFragment.setStartedFromNewIntent(true); if (showDialpadChooser && !mDialpadFragment.isVisible()) { diff --git a/java/com/android/dialer/dialpadview/DialpadFragment.java b/java/com/android/dialer/dialpadview/DialpadFragment.java index 837c3af90..7dd557863 100644 --- a/java/com/android/dialer/dialpadview/DialpadFragment.java +++ b/java/com/android/dialer/dialpadview/DialpadFragment.java @@ -39,6 +39,7 @@ import android.provider.Contacts.People; import android.provider.Contacts.Phones; import android.provider.Contacts.PhonesColumns; import android.provider.Settings; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.design.widget.FloatingActionButton; @@ -485,24 +486,27 @@ 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. + * Checks the given Intent and changes dialpad's UI state. + * + *

There are three modes: + * + *

+ * + * For example, if the user... + * + * */ - private void configureScreenFromIntent(Activity parent) { - LogUtil.enterBlock("DialpadFragment.configureScreenFromIntent"); - - // If we were not invoked with a DIAL intent - if (!Intent.ACTION_DIAL.equals(parent.getIntent().getAction())) { - setStartedFromNewIntent(false); - return; - } - - LogUtil.i("DialpadFragment.configureScreenFromIntent", "dial intent"); - - // See if we were invoked with a DIAL intent. If we were, fill in the appropriate - // digits in the dialer field. - Intent intent = parent.getIntent(); - + private void configureScreenFromIntent(@NonNull Intent intent) { + LogUtil.i("DialpadFragment.configureScreenFromIntent", "action: %s", intent.getAction()); 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 @@ -514,37 +518,29 @@ public class DialpadFragment extends Fragment return; } - 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 (!(mStartedFromNewIntent && digitsFilled)) { - - final String action = intent.getAction(); - LogUtil.i("DialpadFragment.configureScreenFromIntent", "action: %s", action); - 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 (isPhoneInUse()) { - needToShowDialpadChooser = true; - } - } - } + // If "Add call" was selected, show the dialpad instead of the dialpad chooser prompt + if (isAddCallMode(intent)) { + LogUtil.i("DialpadFragment.configureScreenFromIntent", "Add call mode"); + showDialpadChooser(false); + setStartedFromNewIntent(true); + return; } - LogUtil.i( - "DialpadFragment.configureScreenFromIntent", - "needToShowDialpadChooser? %b", - needToShowDialpadChooser); - showDialpadChooser(needToShowDialpadChooser); + + // 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. + boolean digitsFilled = fillDigitsIfNecessary(intent); + if (!(mStartedFromNewIntent && digitsFilled) && isPhoneInUse()) { + // If there's already an active call, bring up an intermediate UI to + // make the user confirm what they really want to do. + LogUtil.i("DialpadFragment.configureScreenFromIntent", "Dialpad chooser mode"); + showDialpadChooser(true); + setStartedFromNewIntent(false); + return; + } + + LogUtil.i("DialpadFragment.configureScreenFromIntent", "Nothing to show"); + showDialpadChooser(false); setStartedFromNewIntent(false); } @@ -669,7 +665,7 @@ public class DialpadFragment extends Fragment mPressedDialpadKeys.clear(); - configureScreenFromIntent(getActivity()); + configureScreenFromIntent(getActivity().getIntent()); stopWatch.lap("fdin"); -- cgit v1.2.3