Multi-line EditText background is set using a state. Step 2.

See change 86347 for Step 1.

New state_multiline state flag, handled in TextView drawable background drawables.

Change-Id: I230df16c7ddee3296da180fd80ef341a4ac17dc0
diff --git a/api/current.xml b/api/current.xml
index 3357d1e..b33111a 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -9084,6 +9084,17 @@
  visibility="public"
 >
 </field>
+<field name="state_multiline"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843595"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="state_pressed"
  type="int"
  transient="false"
@@ -252110,7 +252121,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="arg0" type="T">
+<parameter name="t" type="T">
 </parameter>
 </method>
 </interface>
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index d4515d5..ae4b193 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -4132,7 +4132,12 @@
 
     @Override
     protected int[] onCreateDrawableState(int extraSpace) {
-        final int[] drawableState = super.onCreateDrawableState(extraSpace);
+        final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
+
+        if (!mSingleLine) {
+            mergeDrawableStates(drawableState, MULTILINE_STATE_SET);
+        }
+
         if (mTextIsSelectable) {
             // Disable pressed state, which was introduced when TextView was made clickable.
             // Prevents text color change.
@@ -4148,6 +4153,7 @@
                 }
             }
         }
+
         return drawableState;
     }
 
@@ -9488,4 +9494,6 @@
     private static long sLastCutOrCopyTime;
     // Used to highlight a word when it is corrected by the IME
     private CorrectionHighlighter mCorrectionHighlighter;
+    // New state used to change background based on whether this TextView is multiline.
+    private static final int[] MULTILINE_STATE_SET = { R.attr.state_multiline };
 }
diff --git a/core/res/res/drawable/edit_text_holo_dark.xml b/core/res/res/drawable/edit_text_holo_dark.xml
index 29a5150c..d00747f 100644
--- a/core/res/res/drawable/edit_text_holo_dark.xml
+++ b/core/res/res/drawable/edit_text_holo_dark.xml
@@ -15,10 +15,19 @@
 -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:state_multiline="true" android:state_window_focused="false" android:state_enabled="true"  android:drawable="@drawable/textfield_multiline_default_holo_dark" />
+    <item android:state_multiline="true" android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/textfield_multiline_disabled_holo_dark" />
+    <item android:state_multiline="true" android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_multiline_activated_holo_dark" />
+    <item android:state_multiline="true" android:state_enabled="true" android:state_activated="true" android:drawable="@drawable/textfield_multiline_focused_holo_dark" />
+    <item android:state_multiline="true" android:state_enabled="true" android:drawable="@drawable/textfield_multiline_default_holo_dark" />
+    <item android:state_multiline="true" android:state_focused="true" android:drawable="@drawable/textfield_multiline_disabled_focused_holo_dark" />
+    <item android:state_multiline="true" android:drawable="@drawable/textfield_multiline_disabled_holo_dark" />
+
     <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/textfield_default_holo_dark" />
     <item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/textfield_disabled_holo_dark" />
     <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_activated_holo_dark" />
-    <item android:state_enabled="true" android:state_activated="true" android:drawable="@drawable/textfield_focused_holo_dark" />
+    <iten android:state_enabled="true" android:state_activated="true" android:drawable="@drawable/textfield_focused_holo_dark" />
     <item android:state_enabled="true" android:drawable="@drawable/textfield_default_holo_dark" />
     <item android:state_focused="true" android:drawable="@drawable/textfield_disabled_focused_holo_dark" />
     <item android:drawable="@drawable/textfield_disabled_holo_dark" />
diff --git a/core/res/res/drawable/edit_text_holo_light.xml b/core/res/res/drawable/edit_text_holo_light.xml
index 5426916..5bdcbd9 100644
--- a/core/res/res/drawable/edit_text_holo_light.xml
+++ b/core/res/res/drawable/edit_text_holo_light.xml
@@ -15,6 +15,15 @@
 -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:state_multiline="true" android:state_window_focused="false" android:state_enabled="true"  android:drawable="@drawable/textfield_multiline_default_holo_light" />
+    <item android:state_multiline="true" android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/textfield_multiline_disabled_holo_light" />
+    <item android:state_multiline="true" android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_multiline_activated_holo_light" />
+    <item android:state_multiline="true" android:state_enabled="true" android:state_activated="true" android:drawable="@drawable/textfield_multiline_focused_holo_light" />
+    <item android:state_multiline="true" android:state_enabled="true" android:drawable="@drawable/textfield_multiline_default_holo_light" />
+    <item android:state_multiline="true" android:state_focused="true" android:drawable="@drawable/textfield_multiline_disabled_focused_holo_light" />
+    <item android:state_multiline="true" android:drawable="@drawable/textfield_multiline_disabled_holo_light" />
+
     <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/textfield_default_holo_light" />
     <item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/textfield_disabled_holo_light" />
     <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_activated_holo_light" />
diff --git a/core/res/res/drawable/edit_text_multiline_holo_dark.xml b/core/res/res/drawable/edit_text_multiline_holo_dark.xml
deleted file mode 100644
index d20ea19..0000000
--- a/core/res/res/drawable/edit_text_multiline_holo_dark.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:state_window_focused="false" android:state_enabled="true"  android:drawable="@drawable/textfield_multiline_default_holo_dark" />
-    <item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/textfield_multiline_disabled_holo_dark" />
-    <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_multiline_activated_holo_dark" />
-    <item android:state_enabled="true" android:state_activated="true" android:drawable="@drawable/textfield_multiline_focused_holo_dark" />
-    <item android:state_enabled="true" android:drawable="@drawable/textfield_multiline_default_holo_dark" />
-    <item android:state_focused="true" android:drawable="@drawable/textfield_multiline_disabled_focused_holo_dark" />
-    <item android:drawable="@drawable/textfield_multiline_disabled_holo_dark" />
-</selector>
diff --git a/core/res/res/drawable/edit_text_multiline_holo_light.xml b/core/res/res/drawable/edit_text_multiline_holo_light.xml
deleted file mode 100644
index 41a4eab..0000000
--- a/core/res/res/drawable/edit_text_multiline_holo_light.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:state_window_focused="false" android:state_enabled="true"  android:drawable="@drawable/textfield_multiline_default_holo_light" />
-    <item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/textfield_multiline_disabled_holo_light" />
-    <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_multiline_activated_holo_light" />
-    <item android:state_enabled="true" android:state_activated="true" android:drawable="@drawable/textfield_multiline_focused_holo_light" />
-    <item android:state_enabled="true" android:drawable="@drawable/textfield_multiline_default_holo_light" />
-    <item android:state_focused="true" android:drawable="@drawable/textfield_multiline_disabled_focused_holo_light" />
-    <item android:drawable="@drawable/textfield_multiline_disabled_holo_light" />
-</selector>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 8333157..588b33b 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -3692,6 +3692,10 @@
         <!-- State identifier indicating the popup will be above the anchor. -->
         <attr name="state_above_anchor" format="boolean" />
     </declare-styleable>
+    <declare-styleable name="TextViewMultiLineBackgroundState">
+        <!-- State identifier indicating a TextView has a multi-line layout. -->
+        <attr name="state_multiline" format="boolean" />
+    </declare-styleable>
 
     <!-- ***************************************************************** -->
     <!-- Support for Searchable activities. -->
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 9f1b9a1..76a9d3b 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1425,6 +1425,7 @@
   <public type="attr" name="solidColor" />
   <public type="attr" name="spinnersShown" />
   <public type="attr" name="calendarViewShown" />
+  <public type="attr" name="state_multiline" />
 
   <public type="anim" name="animator_fade_in" />
   <public type="anim" name="animator_fade_out" />