Dialog for emergency info

Bug:27621394
Change-Id: I894f5526d05c84eec81e9fe87a105f466195073d
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4992d6b..53b0c92 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5388,6 +5388,10 @@
     <string name="user_exit_guest_confirm_message">All apps and data in this session will be deleted.</string>
     <!-- Label for button in confirmation dialog when exiting guest session [CHAR LIMIT=35] -->
     <string name="user_exit_guest_dialog_remove">Remove</string>
+    <!-- Message of dialog to user to confirm that he understands that emergency information is shown in emergency dialer [CHAR LIMIT=none] -->
+    <string name="user_emergency_info_consent">Information you enter here can help first responders in an emergency. It is stored on your device only, but anyone can read it from the emergency dialer without unlocking your phone.</string>
+    <!-- Label for button in confirmation dialog when the user clicks on emergency information [CHAR LIMIT=35] -->
+    <string name="emergency_info_continue">Continue</string>
 
     <!-- Title of preference to enable calling[CHAR LIMIT=40] -->
     <string name="user_enable_calling">Turn on phone calls</string>
@@ -5405,8 +5409,6 @@
     <string name="user_enable_calling_and_sms_confirm_message">Call and SMS history will be shared with this user.</string>
     <!-- Title for the emergency info preference [CHAR LIMIT=40] -->
     <string name="emergency_info_title">Emergency information</string>
-    <!-- Description of the emergency info preference [CHAR LIMIT=none] -->
-    <string name="emergency_info_subtitle">Accessible by anyone from the emergency dialer without unlocking your phone</string>
 
     <!-- Application Restrictions screen title [CHAR LIMIT=45] -->
     <string name="application_restrictions">Allow apps and content</string>
diff --git a/res/xml/user_settings.xml b/res/xml/user_settings.xml
index 8d20f31..b89f766 100644
--- a/res/xml/user_settings.xml
+++ b/res/xml/user_settings.xml
@@ -38,6 +38,5 @@
     </PreferenceCategory>
     <Preference
         android:key="emergency_info"
-        android:title="@string/emergency_info_title"
-        android:summary="@string/emergency_info_subtitle"/>
+        android:title="@string/emergency_info_title" />
 </PreferenceScreen>
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 4b060a0..8e3dccf 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -115,6 +115,7 @@
     private static final int DIALOG_NEED_LOCKSCREEN = 7;
     private static final int DIALOG_CONFIRM_EXIT_GUEST = 8;
     private static final int DIALOG_USER_PROFILE_EDITOR = 9;
+    private static final int DIALOG_EMERGENCY_INFO_CONSENT = 10;
 
     private static final int MESSAGE_UPDATE_LIST = 1;
     private static final int MESSAGE_SETUP_USER = 2;
@@ -608,6 +609,22 @@
                         android.os.Process.myUserHandle());
                 return dlg;
             }
+            case DIALOG_EMERGENCY_INFO_CONSENT : {
+                Dialog dlg = new AlertDialog.Builder(context)
+                        .setTitle(R.string.emergency_info_title)
+                        .setMessage(R.string.user_emergency_info_consent)
+                        .setPositiveButton(R.string.emergency_info_continue,
+                                new DialogInterface.OnClickListener() {
+                                    @Override
+                                    public void onClick(DialogInterface dialog, int which) {
+                                        Intent intent = new Intent(ACTION_EDIT_EMERGENCY_INFO);
+                                        startActivity(intent);
+                                    }
+                                })
+                        .setNegativeButton(android.R.string.cancel, null)
+                        .create();
+                return dlg;
+            }
             default:
                 return null;
         }
@@ -946,8 +963,7 @@
                 onAddUserClicked(USER_TYPE_USER);
             }
         } else if (pref == mEmergencyInfoPreference) {
-            Intent intent = new Intent(ACTION_EDIT_EMERGENCY_INFO);
-            startActivity(intent);
+            showDialog(DIALOG_EMERGENCY_INFO_CONSENT);
         }
         return false;
     }