Added the dial voicemail button.

Voicemail is disabled if the number cannot be accessed,
e.g no SIM card or insufficient privilege.

I left the functionality of long pressing '1' to
call the voicemail.

Bug: 2104523
diff --git a/res/drawable-finger/btn_dial_voicemail.xml b/res/drawable-finger/btn_dial_voicemail.xml
new file mode 100644
index 0000000..8669f0f
--- /dev/null
+++ b/res/drawable-finger/btn_dial_voicemail.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- Background resource for dial voicemail button for the various 12 key dialers. -->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <!-- Disabled views -->
+    <item android:state_focused="true" android:state_enabled="false"
+        android:drawable="@drawable/btn_dial_action_left_disable_focused" />
+    <item android:state_enabled="false"
+        android:drawable="@drawable/btn_dial_action_left_disable" />
+
+    <!-- Enabled views -->
+    <item android:state_pressed="true" android:state_enabled="true"
+        android:drawable="@drawable/btn_dial_action_left_pressed" />
+    <item android:state_focused="true" android:state_enabled="true"
+        android:drawable="@drawable/btn_dial_action_left_selected" />
+    <item android:state_enabled="true"
+        android:drawable="@drawable/btn_dial_action_left_normal" />
+</selector>
diff --git a/res/drawable-hdpi-finger/btn_dial_action_left_disable.9.png b/res/drawable-hdpi-finger/btn_dial_action_left_disable.9.png
new file mode 100755
index 0000000..7ba8672
--- /dev/null
+++ b/res/drawable-hdpi-finger/btn_dial_action_left_disable.9.png
Binary files differ
diff --git a/res/drawable-hdpi-finger/btn_dial_action_left_disable_focused.9.png b/res/drawable-hdpi-finger/btn_dial_action_left_disable_focused.9.png
new file mode 100755
index 0000000..b4300b6
--- /dev/null
+++ b/res/drawable-hdpi-finger/btn_dial_action_left_disable_focused.9.png
Binary files differ
diff --git a/res/drawable-hdpi-finger/btn_dial_action_left_normal.9.png b/res/drawable-hdpi-finger/btn_dial_action_left_normal.9.png
new file mode 100755
index 0000000..7ba8672
--- /dev/null
+++ b/res/drawable-hdpi-finger/btn_dial_action_left_normal.9.png
Binary files differ
diff --git a/res/drawable-hdpi-finger/btn_dial_action_left_pressed.9.png b/res/drawable-hdpi-finger/btn_dial_action_left_pressed.9.png
new file mode 100755
index 0000000..1dc40b7
--- /dev/null
+++ b/res/drawable-hdpi-finger/btn_dial_action_left_pressed.9.png
Binary files differ
diff --git a/res/drawable-hdpi-finger/btn_dial_action_left_selected.9.png b/res/drawable-hdpi-finger/btn_dial_action_left_selected.9.png
new file mode 100755
index 0000000..4f6c7cf
--- /dev/null
+++ b/res/drawable-hdpi-finger/btn_dial_action_left_selected.9.png
Binary files differ
diff --git a/res/drawable-hdpi-finger/ic_dial_action_voice_mail.png b/res/drawable-hdpi-finger/ic_dial_action_voice_mail.png
new file mode 100755
index 0000000..8a3f366
--- /dev/null
+++ b/res/drawable-hdpi-finger/ic_dial_action_voice_mail.png
Binary files differ
diff --git a/res/drawable-mdpi-finger/btn_dial_action_left_disable.9.png b/res/drawable-mdpi-finger/btn_dial_action_left_disable.9.png
new file mode 100755
index 0000000..6ab27d8
--- /dev/null
+++ b/res/drawable-mdpi-finger/btn_dial_action_left_disable.9.png
Binary files differ
diff --git a/res/drawable-mdpi-finger/btn_dial_action_left_disable_focused.9.png b/res/drawable-mdpi-finger/btn_dial_action_left_disable_focused.9.png
new file mode 100755
index 0000000..5bba3c4
--- /dev/null
+++ b/res/drawable-mdpi-finger/btn_dial_action_left_disable_focused.9.png
Binary files differ
diff --git a/res/drawable-mdpi-finger/btn_dial_action_left_normal.9.png b/res/drawable-mdpi-finger/btn_dial_action_left_normal.9.png
new file mode 100755
index 0000000..6ab27d8
--- /dev/null
+++ b/res/drawable-mdpi-finger/btn_dial_action_left_normal.9.png
Binary files differ
diff --git a/res/drawable-mdpi-finger/btn_dial_action_left_pressed.9.png b/res/drawable-mdpi-finger/btn_dial_action_left_pressed.9.png
new file mode 100755
index 0000000..542abe7
--- /dev/null
+++ b/res/drawable-mdpi-finger/btn_dial_action_left_pressed.9.png
Binary files differ
diff --git a/res/drawable-mdpi-finger/btn_dial_action_left_selected.9.png b/res/drawable-mdpi-finger/btn_dial_action_left_selected.9.png
new file mode 100755
index 0000000..34caba1
--- /dev/null
+++ b/res/drawable-mdpi-finger/btn_dial_action_left_selected.9.png
Binary files differ
diff --git a/res/drawable-mdpi-finger/ic_dial_action_voice_mail.png b/res/drawable-mdpi-finger/ic_dial_action_voice_mail.png
new file mode 100755
index 0000000..cb07d1a
--- /dev/null
+++ b/res/drawable-mdpi-finger/ic_dial_action_voice_mail.png
Binary files differ
diff --git a/res/layout-finger/twelve_key_dialer.xml b/res/layout-finger/twelve_key_dialer.xml
index b350f4f..c904deb 100644
--- a/res/layout-finger/twelve_key_dialer.xml
+++ b/res/layout-finger/twelve_key_dialer.xml
@@ -63,15 +63,24 @@
         android:layout_width="wrap_content"
         android:layout_height="fill_parent"
         android:layout_gravity="center_horizontal"
-        android:layout_marginBottom="7dip"
+        android:layout_marginBottom="6dip"
         android:orientation="horizontal">
 
+        <!-- Onscreen "Voicemail" button -->
+        <ImageButton android:id="@+id/voicemailButton"
+            android:layout_width="90dip"
+            android:layout_height="52dip"
+            android:layout_gravity="center_vertical"
+            android:state_enabled="false"
+            android:background="@drawable/btn_dial_voicemail"
+            android:src="@drawable/ic_dial_action_voice_mail" />
+
         <!-- Onscreen "Dial" button, used on all platforms by
              default. Its usage can be disabled using resources (see
              config.xml.) -->
         <ImageButton android:id="@+id/dialButton"
             android:layout_width="116dip"
-            android:layout_height="50dip"
+            android:layout_height="52dip"
             android:layout_gravity="center_vertical"
             android:state_enabled="false"
             android:background="@drawable/btn_dial_action"
diff --git a/res/layout-land-finger/twelve_key_dialer.xml b/res/layout-land-finger/twelve_key_dialer.xml
index 2978799..9547ed5 100644
--- a/res/layout-land-finger/twelve_key_dialer.xml
+++ b/res/layout-land-finger/twelve_key_dialer.xml
@@ -64,15 +64,24 @@
         android:layout_width="wrap_content"
         android:layout_height="fill_parent"
         android:layout_gravity="center_horizontal"
-        android:layout_marginBottom="7dip"
+        android:layout_marginBottom="6dip"
         android:orientation="horizontal">
 
+        <!-- Onscreen "Voicemail" button -->
+        <ImageButton android:id="@+id/voicemailButton"
+            android:layout_width="90dip"
+            android:layout_height="52dip"
+            android:layout_gravity="center_vertical"
+            android:state_enabled="false"
+            android:background="@drawable/btn_dial_voicemail"
+            android:src="@drawable/ic_dial_action_voice_mail" />
+
         <!-- Onscreen "Dial" button, used on all platforms by
              default. Its usage can be disabled using resources (see
              config.xml.) -->
         <ImageButton android:id="@+id/dialButton"
             android:layout_width="116dip"
-            android:layout_height="50dip"
+            android:layout_height="52dip"
             android:layout_gravity="center_vertical"
             android:state_enabled="false"
             android:background="@drawable/btn_dial_action"
diff --git a/src/com/android/contacts/TwelveKeyDialer.java b/src/com/android/contacts/TwelveKeyDialer.java
index 2e88d89..2be677a 100644
--- a/src/com/android/contacts/TwelveKeyDialer.java
+++ b/src/com/android/contacts/TwelveKeyDialer.java
@@ -93,8 +93,9 @@
     private Drawable mDeleteEmptyBackground;
     private View mDigitsAndBackspace;
     private View mDialpad;
-    private View mDialButton;
     private View mVoicemailDialAndBackspaceRow;
+    private View mVoicemailButton;
+    private View mDialButton;
     private ListView mDialpadChooser;
     private DialpadChooserAdapter mDialpadChooserAdapter;
     //Member variables for dialpad options
@@ -204,6 +205,8 @@
 
         mVoicemailDialAndBackspaceRow = findViewById(R.id.voicemailAndDialAndBackspace);
 
+        initVoicemailButton();
+
         // Check whether we should show the onscreen "Dial" button.
         mDialButton = mVoicemailDialAndBackspaceRow.findViewById(R.id.dialButton);
 
@@ -673,6 +676,11 @@
                 placeCall();
                 return;
             }
+            case R.id.voicemailButton: {
+                callVoicemail();
+                vibrate();
+                return;
+            }
         }
     }
 
@@ -1047,6 +1055,25 @@
     }
 
     /**
+     * Check if voicemail is enabled/accessible.
+     */
+    private void initVoicemailButton() {
+        boolean hasVoicemail = false;
+        try {
+            hasVoicemail = TelephonyManager.getDefault().getVoiceMailNumber() != null;
+        } catch (SecurityException se) {
+            // Possibly no READ_PHONE_STATE privilege.
+        }
+
+        mVoicemailButton = mVoicemailDialAndBackspaceRow.findViewById(R.id.voicemailButton);
+        if (hasVoicemail) {
+            mVoicemailButton.setOnClickListener(this);
+        } else {
+            mVoicemailButton.setEnabled(false);
+        }
+    }
+
+    /**
      * This function return true if Wait menu item can be shown
      * otherwise returns false. Assumes the passed string is non-empty
      * and the 0th index check is not required.