From ff43216e62d2ab2b6773466a06420081dc8900e5 Mon Sep 17 00:00:00 2001 From: Christine Chen Date: Mon, 20 May 2013 16:40:17 -0700 Subject: Preserves changes in phone number on dialer. Added check on whether the intent is new to decide when to fill in the number in dialer automatically. If the intent is not new, the dialer will be filled with previously used number, preserving any edits on that number. Bug: 8484457 Change-Id: I45f02d395ce402670b380485b5ba1e7190600ec3 --- .../android/dialer/dialpad/DialpadFragment.java | 35 ++++++++++++---------- 1 file changed, 19 insertions(+), 16 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 fdcd14073..4034d9cbe 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -401,6 +401,12 @@ public class DialpadFragment extends Fragment * @return true when {@link #mDigits} is actually filled by the Intent. */ private boolean fillDigitsIfNecessary(Intent intent) { + // Only fills digits from an intent if it is a new intent. + // Otherwise falls back to the previously used number. + if (!mFirstLaunch && !mStartedFromNewIntent) { + return false; + } + final String action = intent.getAction(); if (Intent.ACTION_DIAL.equals(action) || Intent.ACTION_VIEW.equals(action)) { Uri uri = intent.getData(); @@ -439,7 +445,6 @@ public class DialpadFragment extends Fragment } } } - return false; } @@ -463,7 +468,17 @@ 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. */ - private void configureScreenFromIntent(Intent intent) { + private void configureScreenFromIntent(Activity parent) { + // If we were not invoked with a DIAL intent, + if (!(parent instanceof DialtactsActivity)) { + setStartedFromNewIntent(false); + return; + } + + // 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(); + 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 @@ -499,8 +514,8 @@ public class DialpadFragment extends Fragment } } - showDialpadChooser(needToShowDialpadChooser); + setStartedFromNewIntent(false); } public void setStartedFromNewIntent(boolean value) { @@ -539,13 +554,6 @@ public class DialpadFragment extends Fragment } - @Override - public void onStart() { - super.onStart(); - configureScreenFromIntent(getActivity().getIntent()); - setStartedFromNewIntent(false); - } - @Override public void onResume() { super.onResume(); @@ -595,12 +603,7 @@ public class DialpadFragment extends Fragment // the dialpad edittext to prevent entries from being loaded from a null cache. initializeSmartDialingState(); - Activity parent = getActivity(); - if (parent instanceof DialtactsActivity) { - // See if we were invoked with a DIAL intent. If we were, fill in the appropriate - // digits in the dialer field. - fillDigitsIfNecessary(parent.getIntent()); - } + configureScreenFromIntent(getActivity()); stopWatch.lap("fdin"); -- cgit v1.2.3