Prevent user from creating duplicate labels.

This isn't enforced at the data layer just in the UI's that
allow editting of the group name.

Bug 28718604
Change-Id: I969b0298bd895fdbdd7f8609da05f2b801707c0a
diff --git a/res/layout/floating_action_button.xml b/res/layout/floating_action_button.xml
index 95c76ae..2dc8955 100644
--- a/res/layout/floating_action_button.xml
+++ b/res/layout/floating_action_button.xml
@@ -14,24 +14,26 @@
      limitations under the License.
 -->
 
-<!-- This expects to be included inside a RelativeLayout -->
+<!-- This expects to be included inside a RelativeLayout or a CoordinatorLayout -->
 <FrameLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/floating_action_button_container"
     android:layout_width="@dimen/floating_action_button_width"
     android:layout_height="@dimen/floating_action_button_height"
-    android:layout_marginEnd="@dimen/floating_action_button_margin_right"
-    android:layout_marginBottom="@dimen/floating_action_button_margin_bottom"
-    android:background="@drawable/fab_blue"
+    android:layout_alignParentBottom="true"
     android:layout_alignParentEnd="true"
-    android:layout_alignParentBottom="true">
+    android:layout_gravity="bottom|end"
+    android:layout_marginBottom="@dimen/floating_action_button_margin_bottom"
+    android:layout_marginEnd="@dimen/floating_action_button_margin_right"
+    android:background="@drawable/fab_blue"
+    android:elevation="@dimen/design_fab_elevation">
 
     <ImageButton
         android:id="@+id/floating_action_button"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:background="@drawable/floating_action_button"
-        android:tint="@color/floating_action_button_icon_color"
         android:contentDescription="@string/action_menu_add_new_contact_button"
-        android:src="@drawable/ic_add"/>
+        android:src="@drawable/ic_add"
+        android:tint="@color/floating_action_button_icon_color"/>
 </FrameLayout>
\ No newline at end of file
diff --git a/res/layout/group_name_dialog.xml b/res/layout/group_name_dialog.xml
deleted file mode 100644
index f19df86..0000000
--- a/res/layout/group_name_dialog.xml
+++ /dev/null
@@ -1,32 +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.
--->
-
-<FrameLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:paddingLeft="25dip"
-    android:paddingRight="25dip"
-    android:paddingStart="25dip"
-    android:paddingEnd="25dip"
-    android:paddingTop="25dip"
-    android:paddingBottom="25dip">
-    <EditText
-        android:id="@+id/group_label"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:minHeight="@dimen/group_name_edit_text_min_height"/>
-</FrameLayout>
diff --git a/res/layout/group_name_edit_dialog.xml b/res/layout/group_name_edit_dialog.xml
index 9a8c69f..5df8c9d 100644
--- a/res/layout/group_name_edit_dialog.xml
+++ b/res/layout/group_name_edit_dialog.xml
@@ -14,24 +14,28 @@
      limitations under the License.
 -->
 
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<android.support.design.widget.TextInputLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/text_input_layout"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:orientation="vertical"
-    android:paddingBottom="24dp"
+    android:paddingEnd="24dp"
     android:paddingStart="24dp"
-    android:paddingEnd="24dp">
+    app:errorEnabled="true"
+    app:hintEnabled="false">
 
-    <EditText android:id="@android:id/text1"
-        xmlns:android="http://schemas.android.com/apk/res/android"
+    <android.support.design.widget.TextInputEditText
+        android:id="@android:id/text1"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:minHeight="@dimen/group_name_edit_text_min_height"
         android:layout_marginBottom="4dp"
         android:layout_marginRight="4dp"
         android:layout_marginTop="16dp"
         android:hint="@string/group_name_dialog_hint"
         android:inputType="text"
-        android:singleLine="true"
-        android:maxLength="@integer/group_name_max_length"/>
-</LinearLayout>
\ No newline at end of file
+        android:maxLength="@integer/group_name_max_length"
+        android:minHeight="@dimen/group_name_edit_text_min_height"
+        android:singleLine="true"/>
+</android.support.design.widget.TextInputLayout>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 7a81940..132064c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -369,6 +369,9 @@
     <!-- Toast displayed when saving a label failed [CHAR LIMIT=70] -->
     <string name="groupSavedErrorToast">Couldn\'t save label changes.</string>
 
+    <!-- Message displayed when creating a group with the same name as an existing group -->
+    <string name="groupExistsErrorMessage">That label already exists</string>
+
     <!-- Displayed at the top of the contacts showing the total number of contacts visible when "Only contacts with phones" is selected -->
     <plurals name="listTotalPhoneContacts">
         <item quantity="one">1 contact with phone number</item>
@@ -632,9 +635,6 @@
     Initiates a contact import dialog [CHAR LIMIT=128] -->
     <string name="contacts_unavailable_import_contacts">Import</string>
 
-    <!-- Title of the dialog that allows creation of a contact label [CHAR LIMIT=50] -->
-    <string name="create_group_dialog_title">Create new label</string>
-
     <!-- An item in the popup list of labels that triggers creation of a contact label [CHAR LIMIT=128] -->
     <string name="create_group_item_label">Create new&#8230;</string>