Follow-up to Ie62a4486

Clear the flag only when all digits are removed.

TESTED:
- Manually type "123#"
-> DOES trigger special-char-sequence handling

- Have Intent with "tel:555", remove all digits with back press, type 123#
-> DOES trigger the handling

- Have Intent with "tel:555", remove all digits with back long-press, type 123#
-> DOES trigger the handling

- Have Intent with "tel:555", dial this, hang up, and type 123#
-> DOES trigger the handling

- Have Intent with "tel:123%23"
-> Does NOT trigger the handling

- Have Intent with "tel:123", type #
-> Does NOT trigger the handling

- Have Intent with "tel:123%23%23", remove the last #
-> Does NOT trigger the handling

- Have Intent with "tel:123%23", remove the last # and type #
-> Does NOT trigger the handling

- Have Intent with "tel:123%23", change locale, relaunch the dialer
-> Does NOT trigger the handling

Also did the same with hardware keyboard.

Bug: 6726923
Change-Id: Idea7ae599e3a217ad656a304fbae26746d9f3284
diff --git a/src/com/android/contacts/dialpad/DialpadFragment.java b/src/com/android/contacts/dialpad/DialpadFragment.java
index 8548296..a853711 100644
--- a/src/com/android/contacts/dialpad/DialpadFragment.java
+++ b/src/com/android/contacts/dialpad/DialpadFragment.java
@@ -194,8 +194,7 @@
     /**
      * This field is set to true while processing an incoming DIAL intent, in order to make sure
      * that SpecialCharSequenceMgr actions can be triggered by user input but *not* by a
-     * tel: URI passed by some other app. It will be cleared once the user manually interected
-     * with the dialer.
+     * tel: URI passed by some other app.  It will be set to false when all digits are cleared.
      */
     private boolean mDigitsFilledByIntent;
 
@@ -231,6 +230,7 @@
         }
 
         if (isDigitsEmpty()) {
+            mDigitsFilledByIntent = false;
             mDigits.setCursorVisible(false);
         }
 
@@ -716,7 +716,6 @@
     }
 
     private void keyPressed(int keyCode) {
-        mDigitsFilledByIntent = false;
         switch (keyCode) {
             case KeyEvent.KEYCODE_1:
                 playTone(ToneGenerator.TONE_DTMF_1, TONE_LENGTH_INFINITE);
@@ -867,7 +866,6 @@
 
     @Override
     public void onClick(View view) {
-        mDigitsFilledByIntent = false;
         switch (view.getId()) {
             case R.id.deleteButton: {
                 keyPressed(KeyEvent.KEYCODE_DEL);
@@ -906,7 +904,6 @@
 
     @Override
     public boolean onLongClick(View view) {
-        mDigitsFilledByIntent = false;
         final Editable digits = mDigits.getText();
         final int id = view.getId();
         switch (id) {
@@ -1069,7 +1066,6 @@
      * case described above).
      */
     public void dialButtonPressed() {
-        mDigitsFilledByIntent = false;
         if (isDigitsEmpty()) { // No number entered.
             handleDialButtonClickWithEmptyDigits();
         } else {