Dialer: add onscreen "Dial" button.

Add a new "Dial" button, below the keypad (in portrait) or below the
"digits" widget (in landscape).  It does the exact same action as tapping
the digits widget, and its enabled/disabled state uses the exact same
logic that turns the digit widget green when it's OK to dial.

This is a partial fix for bug 1825144 (soft SEND/END keys in places other
than in-call),

The button has visibility GONE by default; it's enabled on a per-product
basis using a flag in config.xml.  (To enable this on devices that need
it, I'll separately check in resource overlay files in those other
projects)

For now the Dial button is just a regular button, with no special layout
or artwork. (But bug 1993282 is open to cover any future visual design
tweaks we might need.)
diff --git a/res/layout-finger/twelve_key_dialer.xml b/res/layout-finger/twelve_key_dialer.xml
index 071ca57..781f23c 100644
--- a/res/layout-finger/twelve_key_dialer.xml
+++ b/res/layout-finger/twelve_key_dialer.xml
@@ -58,6 +58,21 @@
     <!-- Keypad section -->
     <include layout="@layout/dialpad" />
 
+    <!-- Onscreen "Dial" button, used on some platforms -->
+    <Button android:id="@+id/dialButton"
+            android:text="@string/dial_button_label"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:layout_width="wrap_content"
+            android:layout_height="60dip"
+            android:gravity="center"
+            android:layout_gravity="center_horizontal"
+            android:layout_marginTop="20dip"
+            android:paddingLeft="100dip"
+            android:paddingRight="100dip"
+            android:enabled="false"
+            android:visibility="gone"
+            />
+
     <!-- "Dialpad chooser" UI, shown only when the user brings up the
          Dialer while a call is already in progress.
          When this UI is visible, the other Dialer elements
diff --git a/res/layout-land-finger/twelve_key_dialer.xml b/res/layout-land-finger/twelve_key_dialer.xml
index 2b436b8..a1849e1 100644
--- a/res/layout-land-finger/twelve_key_dialer.xml
+++ b/res/layout-land-finger/twelve_key_dialer.xml
@@ -59,6 +59,21 @@
 
     </LinearLayout>
 
+    <!-- Onscreen "Dial" button, used on some platforms -->
+    <Button android:id="@+id/dialButton"
+            android:text="@string/dial_button_label"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:layout_width="wrap_content"
+            android:layout_height="60dip"
+            android:gravity="center"
+            android:layout_gravity="center_horizontal"
+            android:layout_marginTop="20dip"
+            android:paddingLeft="100dip"
+            android:paddingRight="100dip"
+            android:enabled="false"
+            android:visibility="gone"
+            />
+
     <!-- "Dialpad chooser" UI, shown only when the user brings up the
          Dialer while a call is already in progress.
          When this UI is visible, the other Dialer elements
diff --git a/res/values/config.xml b/res/values/config.xml
index 7af1d54..32664ec 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -71,4 +71,11 @@
      exist in a target directory, 00003.vcf becomes a next file name candidate.
      Without this configuration, 00002.vcf becomes the candidate.-->
     <string name="config_export_extensions_to_consider"></string>
+
+    <!-- If true, show an onscreen "Dial" button in the dialer.
+         (In practice this is used only on platforms with no hard SEND/END
+         keys, but for maximum flexibility it's controlled by a flag here
+         (which can be overridden on a per-product basis.)) -->
+    <bool name="config_show_onscreen_dial_button">false</bool>
+
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5ad60b3..cca8b80 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -740,4 +740,8 @@
     <!-- Menu items for dialpad options as part of Pause and Wait ftr -->
     <string name="add_2sec_pause">Add 2-sec Pause</string>
     <string name="add_wait">Add Wait</string>
+
+    <!-- Label for onscreen "Dial" button -->
+    <string name="dial_button_label">Dial</string>
+
 </resources>
diff --git a/src/com/android/contacts/TwelveKeyDialer.java b/src/com/android/contacts/TwelveKeyDialer.java
index a7c1bf5..428cc8e 100644
--- a/src/com/android/contacts/TwelveKeyDialer.java
+++ b/src/com/android/contacts/TwelveKeyDialer.java
@@ -95,6 +95,7 @@
     private Drawable mDeleteEmptyBackground;
     private View mDigitsAndBackspace;
     private View mDialpad;
+    private View mDialButton;
     private ListView mDialpadChooser;
     private DialpadChooserAdapter mDialpadChooserAdapter;
     //Member variables for dialpad options
@@ -168,6 +169,11 @@
             mDigits.setBackgroundDrawable(mDigitsEmptyBackground);
             mDigits.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
         }
+
+        // Update the enabledness of the "Dial" button
+        if (mDialButton != null) {
+            mDialButton.setEnabled(mDigits.length() != 0);
+        }
     }
 
     @Override
@@ -200,6 +206,13 @@
             setupKeypad();
         }
 
+        // Check whether we should show the onscreen "Dial" button.
+        if (r.getBoolean(R.bool.config_show_onscreen_dial_button)) {
+            mDialButton = findViewById(R.id.dialButton);
+            mDialButton.setVisibility(View.VISIBLE);  // It's GONE by default
+            mDialButton.setOnClickListener(this);
+        }
+
         view = findViewById(R.id.backspace);
         view.setOnClickListener(this);
         view.setOnLongClickListener(this);
@@ -678,6 +691,7 @@
                 keyPressed(KeyEvent.KEYCODE_DEL);
                 return;
             }
+            case R.id.dialButton:
             case R.id.digits: {
                 vibrate();  // Vibrate here too, just like we do for the regular keys
                 placeCall();
@@ -813,6 +827,7 @@
             // Log.i(TAG, "Showing dialpad chooser!");
             mDigitsAndBackspace.setVisibility(View.GONE);
             if (mDialpad != null) mDialpad.setVisibility(View.GONE);
+            if (mDialButton != null) mDialButton.setVisibility(View.GONE);
             mDialpadChooser.setVisibility(View.VISIBLE);
 
             // Instantiate the DialpadChooserAdapter and hook it up to the
@@ -825,6 +840,7 @@
             // Log.i(TAG, "Displaying normal Dialer UI.");
             mDigitsAndBackspace.setVisibility(View.VISIBLE);
             if (mDialpad != null) mDialpad.setVisibility(View.VISIBLE);
+            if (mDialButton != null) mDialButton.setVisibility(View.VISIBLE);
             mDialpadChooser.setVisibility(View.GONE);
         }
     }