Hide Emergency Info summary values from search.

Because the summary value displayed by the fragment is dynamically
updated, while the settings search index is statically computed from the
preference values, the two cannot presently be in sync. By renaming the
summary preference attribute, the search index omits the summary, which
prevents it from displaying an incorrect value.

Change-Id: I6598d92ea34e55bcc885050888faa8123233987b
Bug: 64654734
Fix: 64654734
Test: manual, and runtest --path packages/apps/EmergencyInfo/
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index a92b598..dd161c5 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -14,6 +14,12 @@
      limitations under the License.
 -->
 <resources>
+    <declare-styleable name="EmergencyEditTextPreference">
+        <!-- Summary text for the text preference. This is used rather than android:summary to
+        avoid indexing the text incorrectly during settings search. -->
+        <attr name="summary" />
+    </declare-styleable>
+
     <declare-styleable name="EmergencyListPreference">
         <!-- The array to find the content description when an entry from entries is selected.
         If a user clicks on the second item in entries, the second item in this array will be
@@ -25,4 +31,4 @@
         <attr name="textColorActionBar" format="reference|color" />
     </declare-styleable>
 
-</resources>
\ No newline at end of file
+</resources>
diff --git a/res/xml/edit_medical_info.xml b/res/xml/edit_medical_info.xml
index e1603fc..178cda6 100644
--- a/res/xml/edit_medical_info.xml
+++ b/res/xml/edit_medical_info.xml
@@ -13,22 +13,25 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
+
     <com.android.emergency.preferences.NameAutoCompletePreference
         android:icon="@drawable/ic_account_circle"
         android:inputType="textCapWords|textPersonName"
         android:key="name"
         android:singleLine="true"
-        android:summary="@string/unknown_name"
-        android:title="@string/name" />
+        android:title="@string/name"
+        app:summary="@string/unknown_name" />
 
     <com.android.emergency.preferences.EmergencyEditTextPreference
         android:icon="@drawable/ic_address_black_24dp"
         android:inputType="textCapWords|textPostalAddress|textMultiLine"
         android:key="address"
         android:singleLine="false"
-        android:summary="@string/unknown_address"
-        android:title="@string/address" />
+        android:title="@string/address"
+        app:summary="@string/unknown_address" />
 
     <com.android.emergency.preferences.EmergencyListPreference
         xmlns:app="http://schemas.android.com/apk/res/com.android.emergency"
@@ -39,9 +42,9 @@
         android:key="blood_type"
         android:negativeButtonText="@null"
         android:positiveButtonText="@null"
-        android:summary="@string/unknown_blood_type"
         android:title="@string/blood_type"
-        app:entryContentDescriptions="@array/blood_type_content_description" />
+        app:entryContentDescriptions="@array/blood_type_content_description"
+        app:summary="@string/unknown_blood_type" />
 
     <com.android.emergency.preferences.EmergencyEditTextPreference
         android:capitalize="sentences"
@@ -51,8 +54,8 @@
         android:inputType="textMultiLine"
         android:key="allergies"
         android:singleLine="false"
-        android:summary="@string/unknown_allergies"
-        android:title="@string/allergies" />
+        android:title="@string/allergies"
+        app:summary="@string/unknown_allergies" />
 
     <com.android.emergency.preferences.EmergencyEditTextPreference
         android:capitalize="sentences"
@@ -62,8 +65,8 @@
         android:inputType="textMultiLine"
         android:key="medications"
         android:singleLine="false"
-        android:summary="@string/unknown_medications"
-        android:title="@string/medications" />
+        android:title="@string/medications"
+        app:summary="@string/unknown_medications" />
 
     <com.android.emergency.preferences.EmergencyListPreference
         android:entries="@array/organ_donor_entries"
@@ -73,8 +76,8 @@
         android:defaultValue=""
         android:negativeButtonText="@null"
         android:positiveButtonText="@null"
-        android:summary="@string/unknown_organ_donor"
-        android:title="@string/organ_donor" />
+        android:title="@string/organ_donor"
+        app:summary="@string/unknown_organ_donor" />
 
     <com.android.emergency.preferences.EmergencyEditTextPreference
         android:capitalize="sentences"
@@ -84,6 +87,6 @@
         android:inputType="textMultiLine"
         android:key="medical_conditions"
         android:singleLine="false"
-        android:summary="@string/unknown_medical_conditions"
-        android:title="@string/medical_conditions" />
+        android:title="@string/medical_conditions"
+        app:summary="@string/unknown_medical_conditions" />
 </PreferenceScreen>
diff --git a/src/com/android/emergency/preferences/EmergencyEditTextPreference.java b/src/com/android/emergency/preferences/EmergencyEditTextPreference.java
index efb7adc..1511055 100644
--- a/src/com/android/emergency/preferences/EmergencyEditTextPreference.java
+++ b/src/com/android/emergency/preferences/EmergencyEditTextPreference.java
@@ -16,6 +16,7 @@
 package com.android.emergency.preferences;
 
 import android.content.Context;
+import android.content.res.TypedArray;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceViewHolder;
 import android.text.TextUtils;
@@ -23,6 +24,7 @@
 import android.view.View;
 import android.widget.TextView;
 
+import com.android.emergency.R;
 import com.android.emergency.ReloadablePreferenceInterface;
 import com.android.settingslib.CustomEditTextPreference;
 
@@ -36,6 +38,12 @@
 
     public EmergencyEditTextPreference(Context context, AttributeSet attrs) {
         super(context, attrs);
+        TypedArray a = context.obtainStyledAttributes(
+                attrs, R.styleable.EmergencyEditTextPreference, 0, 0);
+        if (a.hasValue(R.styleable.EmergencyEditTextPreference_summary)) {
+            setSummary(a.getString(R.styleable.EmergencyEditTextPreference_summary));
+        }
+        a.recycle();
     }
 
     @Override