Make dialpad themeable

Bug: 19841919
Change-Id: Ie66d84e0027f739625c334c7a774fea8ee42b25f
diff --git a/res/layout/dialpad_key_one.xml b/res/layout/dialpad_key_one.xml
index 5a9d13f..6c6f199 100644
--- a/res/layout/dialpad_key_one.xml
+++ b/res/layout/dialpad_key_one.xml
@@ -33,7 +33,7 @@
                 android:src="@drawable/ic_dialpad_voicemail"
                 android:scaleType="fitCenter"
                 android:layout_centerInParent="true"
-                android:tint="@color/dialpad_voicemail_tint" />
+                android:tint="?attr/dialpad_voicemail_tint" />
             <!-- Place empty text view so vertical height is same as other dialpad keys. -->
             <TextView style="@style/DialpadKeyLettersStyle" />
         </RelativeLayout>
diff --git a/res/layout/dialpad_view.xml b/res/layout/dialpad_view.xml
index 67ec58f..416ae93 100644
--- a/res/layout/dialpad_view.xml
+++ b/res/layout/dialpad_view.xml
@@ -1,133 +1,22 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
+<!--
+  ~ Copyright (C) 2014 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
+  -->
 
-     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.
--->
-<view class="com.android.phone.common.dialpad.DialpadView"
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/dialpad_view"
-    android:layout_height="match_parent"
-    android:layout_width="match_parent"
-    android:layout_gravity="bottom"
-    android:orientation="vertical"
-    android:layoutDirection="ltr"
-    android:background="@color/background_dialpad"
-    android:clickable="true" >
-
-    <!-- Text field where call rate is displayed for ILD calls. -->
-    <LinearLayout
-        android:id="@+id/rate_container"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:orientation="vertical"
-        android:visibility="gone">
-
-        <LinearLayout
-            android:id="@+id/ild_container"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:orientation="horizontal"
-            android:layout_gravity="center_horizontal"
-            android:layout_marginTop="@dimen/ild_margin_height"
-            android:layout_marginBottom="@dimen/ild_margin_height">
-
-            <TextView android:id="@+id/ild_country"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content" />
-
-            <TextView android:id="@+id/ild_rate"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginStart="4dp"
-                android:textStyle="bold" />
-
-        </LinearLayout>
-
-        <View
-            android:layout_width="match_parent"
-            android:layout_height="1dp"
-            android:background="#e3e3e3" />
-
-    </LinearLayout>
-
-    <!-- Text field and possibly soft menu button above the keypad where
-     the digits are displayed. -->
-    <LinearLayout
-        android:id="@+id/digits_container"
-        android:layout_width="match_parent"
-        android:layout_height="@dimen/dialpad_digits_adjustable_height"
-        android:orientation="horizontal">
-
-        <ImageButton android:id="@+id/dialpad_overflow"
-            android:background="@drawable/btn_dialpad_key"
-            android:src="@drawable/ic_overflow_menu"
-            android:tint="@color/dialpad_icon_tint"
-            android:layout_width="wrap_content"
-            android:layout_height="match_parent"
-            android:layout_margin="@dimen/dialpad_overflow_margin"
-            android:paddingLeft="@dimen/dialpad_digits_menu_left_padding"
-            android:paddingRight="@dimen/dialpad_digits_menu_right_padding"
-            android:contentDescription="@string/description_dialpad_overflow"
-            android:gravity="center"
-            android:visibility="invisible" />
-
-        <view class="com.android.phone.common.dialpad.DigitsEditText"
-            xmlns:ex="http://schemas.android.com/apk/res-auto"
-            android:id="@+id/digits"
-            android:layout_width="0dp"
-            android:layout_height="match_parent"
-            android:scrollHorizontally="true"
-            android:singleLine="true"
-            android:layout_weight="1"
-            android:gravity="center"
-            android:background="@android:color/transparent"
-            android:maxLines="1"
-            android:textSize="@dimen/dialpad_digits_adjustable_text_size"
-            android:freezesText="true"
-            android:focusableInTouchMode="true"
-            android:cursorVisible="false"
-            android:textColor="@color/dialpad_digits_text_color"
-            android:textCursorDrawable="@null"
-            android:fontFamily="sans-serif"
-            android:textStyle="normal"
-            ex:resizing_text_min_size="@dimen/dialpad_digits_text_min_size" />
-
-        <ImageButton
-            android:id="@+id/deleteButton"
-            android:background="@drawable/btn_dialpad_key"
-            android:tint="@color/dialpad_icon_tint"
-            android:paddingLeft="@dimen/dialpad_digits_padding"
-            android:paddingRight="@dimen/dialpad_digits_padding"
-            android:layout_width="wrap_content"
-            android:layout_height="match_parent"
-            android:state_enabled="false"
-            android:contentDescription="@string/description_delete_button"
-            android:src="@drawable/ic_dialpad_delete" />
-    </LinearLayout>
-
-    <View
-        android:layout_width="match_parent"
-        android:layout_height="1dp"
-        android:background="#e3e3e3" />
-
-    <Space
-        android:layout_width="match_parent"
-        android:layout_height="@dimen/dialpad_space_above_keys" />
-
-    <include layout="@layout/dialpad" />
-
-    <Space
-        android:layout_width="match_parent"
-        android:layout_height="8dp" />
-
-</view>
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+    <include
+            layout="@layout/dialpad_view_unthemed"
+            android:theme="@style/Dialpad_Light" />
+</merge>
diff --git a/res/layout/dialpad_view_unthemed.xml b/res/layout/dialpad_view_unthemed.xml
new file mode 100644
index 0000000..74e785a
--- /dev/null
+++ b/res/layout/dialpad_view_unthemed.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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.
+-->
+<view class="com.android.phone.common.dialpad.DialpadView"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/dialpad_view"
+    android:layout_height="match_parent"
+    android:layout_width="match_parent"
+    android:layout_gravity="bottom"
+    android:orientation="vertical"
+    android:layoutDirection="ltr"
+    android:background="?attr/dialpad_background"
+    android:clickable="true">
+
+    <!-- Text field where call rate is displayed for ILD calls. -->
+    <LinearLayout
+        android:id="@+id/rate_container"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical"
+        android:visibility="gone">
+
+        <LinearLayout
+            android:id="@+id/ild_container"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal"
+            android:layout_gravity="center_horizontal"
+            android:layout_marginTop="@dimen/ild_margin_height"
+            android:layout_marginBottom="@dimen/ild_margin_height">
+
+            <TextView android:id="@+id/ild_country"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content" />
+
+            <TextView android:id="@+id/ild_rate"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginStart="4dp"
+                android:textStyle="bold" />
+
+        </LinearLayout>
+
+        <View
+            android:layout_width="match_parent"
+            android:layout_height="1dp"
+            android:background="#e3e3e3" />
+
+    </LinearLayout>
+
+    <!-- Text field and possibly soft menu button above the keypad where
+     the digits are displayed. -->
+    <LinearLayout
+        android:id="@+id/digits_container"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/dialpad_digits_adjustable_height"
+        android:orientation="horizontal">
+
+        <ImageButton android:id="@+id/dialpad_overflow"
+            android:background="@drawable/btn_dialpad_key"
+            android:src="@drawable/ic_overflow_menu"
+            android:tint="?attr/dialpad_icon_tint"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:layout_margin="@dimen/dialpad_overflow_margin"
+            android:paddingLeft="@dimen/dialpad_digits_menu_left_padding"
+            android:paddingRight="@dimen/dialpad_digits_menu_right_padding"
+            android:contentDescription="@string/description_dialpad_overflow"
+            android:gravity="center"
+            android:visibility="invisible" />
+
+        <view class="com.android.phone.common.dialpad.DigitsEditText"
+            xmlns:ex="http://schemas.android.com/apk/res-auto"
+            android:id="@+id/digits"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:scrollHorizontally="true"
+            android:singleLine="true"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:background="@android:color/transparent"
+            android:maxLines="1"
+            android:textSize="@dimen/dialpad_digits_adjustable_text_size"
+            android:freezesText="true"
+            android:focusableInTouchMode="true"
+            android:cursorVisible="false"
+            android:textColor="?attr/dialpad_text_color"
+            android:textCursorDrawable="@null"
+            android:fontFamily="sans-serif"
+            android:textStyle="normal"
+            ex:resizing_text_min_size="@dimen/dialpad_digits_text_min_size" />
+
+        <ImageButton
+            android:id="@+id/deleteButton"
+            android:background="@drawable/btn_dialpad_key"
+            android:tint="?attr/dialpad_icon_tint"
+            android:paddingLeft="@dimen/dialpad_digits_padding"
+            android:paddingRight="@dimen/dialpad_digits_padding"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:state_enabled="false"
+            android:contentDescription="@string/description_delete_button"
+            android:src="@drawable/ic_dialpad_delete" />
+    </LinearLayout>
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="1dp"
+        android:background="#e3e3e3" />
+
+    <Space
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/dialpad_space_above_keys" />
+
+    <include layout="@layout/dialpad" />
+
+    <Space
+        android:layout_width="match_parent"
+        android:layout_height="8dp" />
+
+</view>
diff --git a/res/values-land/styles.xml b/res/values-land/styles.xml
index 07f4998..24d6f27 100644
--- a/res/values-land/styles.xml
+++ b/res/values-land/styles.xml
@@ -17,7 +17,7 @@
 
 <resources>
     <style name="DialpadKeyNumberStyle">
-        <item name="android:textColor">@color/dialpad_primary_text_color</item>
+        <item name="android:textColor">?attr/dialpad_text_color_primary</item>
         <item name="android:textSize">@dimen/dialpad_key_numbers_size</item>
         <item name="android:fontFamily">sans-serif-light</item>
         <item name="android:layout_width">@dimen/dialpad_key_number_width</item>
@@ -26,7 +26,7 @@
     </style>
 
         <style name="DialpadKeyLettersStyle">
-        <item name="android:textColor">@color/dialpad_secondary_text_color</item>
+        <item name="android:textColor">?attr/dialpad_text_color_secondary</item>
         <item name="android:textSize">@dimen/dialpad_key_letters_size</item>
         <item name="android:fontFamily">sans-serif-regular</item>
         <item name="android:layout_width">wrap_content</item>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 1c94a14..c47f81b 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -22,4 +22,13 @@
     <declare-styleable name="ResizingText">
         <attr name="resizing_text_min_size" format="dimension"/>
     </declare-styleable>
+
+    <declare-styleable name="Theme.Dialpad">
+        <attr name="dialpad_text_color" format="color" />
+        <attr name="dialpad_text_color_primary" format="color" />
+        <attr name="dialpad_text_color_secondary" format="color" />
+        <attr name="dialpad_icon_tint" format="color" />
+        <attr name="dialpad_voicemail_tint" format="color" />
+        <attr name="dialpad_background" format="color" />
+    </declare-styleable>
 </resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index df649d6..b563705 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -22,7 +22,7 @@
     </style>
 
     <style name="DialpadKeyNumberStyle">
-        <item name="android:textColor">@color/dialpad_primary_text_color</item>
+        <item name="android:textColor">?attr/dialpad_text_color_primary</item>
         <item name="android:textSize">@dimen/dialpad_key_numbers_size</item>
         <item name="android:fontFamily">sans-serif-light</item>
         <item name="android:layout_width">wrap_content</item>
@@ -36,7 +36,7 @@
     </style>
 
     <style name="DialpadKeyStarStyle">
-        <item name="android:textColor">@color/dialpad_secondary_text_color</item>
+        <item name="android:textColor">?attr/dialpad_text_color_secondary</item>
         <item name="android:textSize">@dimen/dialpad_key_star_size</item>
         <item name="android:fontFamily">sans-serif-light</item>
         <item name="android:alpha">0.8</item>
@@ -47,7 +47,7 @@
     </style>
 
     <style name="DialpadKeyPoundStyle">
-        <item name="android:textColor">@color/dialpad_secondary_text_color</item>
+        <item name="android:textColor">?attr/dialpad_text_color_secondary</item>
         <item name="android:textSize">@dimen/dialpad_key_pound_size</item>
         <item name="android:fontFamily">sans-serif-light</item>
         <item name="android:alpha">0.8</item>
@@ -58,7 +58,7 @@
     </style>
 
     <style name="DialpadKeyLettersStyle">
-        <item name="android:textColor">@color/dialpad_secondary_text_color</item>
+        <item name="android:textColor">?attr/dialpad_text_color_secondary</item>
         <item name="android:textSize">@dimen/dialpad_key_letters_size</item>
         <item name="android:fontFamily">sans-serif-regular</item>
         <item name="android:layout_width">wrap_content</item>
@@ -88,4 +88,22 @@
         <item name="android:gravity">center</item>
         <item name="android:orientation">vertical</item>
     </style>
+
+    <style name="Dialpad_Light">
+        <item name="dialpad_text_color">@color/dialpad_digits_text_color</item>
+        <item name="dialpad_text_color_primary">@color/dialpad_primary_text_color</item>
+        <item name="dialpad_text_color_secondary">@color/dialpad_secondary_text_color</item>
+        <item name="dialpad_icon_tint">@color/dialpad_icon_tint</item>
+        <item name="dialpad_voicemail_tint">@color/dialpad_voicemail_tint</item>
+        <item name="dialpad_background">@color/background_dialpad</item>
+    </style>
+
+    <style name="Dialpad_Dark">
+        <item name="dialpad_text_color">@android:color/white</item>
+        <item name="dialpad_text_color_primary">@android:color/white</item>
+        <item name="dialpad_text_color_secondary">#ffd4d6d7</item>
+        <item name="dialpad_icon_tint">@android:color/white</item>
+        <item name="dialpad_voicemail_tint">?attr/dialpad_text_color_secondary</item>
+        <item name="dialpad_background">#00000000</item>
+    </style>
 </resources>