Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8d62cd2c authored by Marcus Hagerott's avatar Marcus Hagerott
Browse files

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
parent ff00150a
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -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_alignParentBottom="true"
    android:layout_alignParentEnd="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:layout_alignParentEnd="true"
    android:layout_alignParentBottom="true">
    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

res/layout/group_name_dialog.xml

deleted100644 → 0
+0 −32
Original line number Diff line number Diff line
<?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>
+13 −9
Original line number Diff line number Diff line
@@ -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
+3 −3
Original line number Diff line number Diff line
@@ -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>

+3 −19
Original line number Diff line number Diff line
@@ -88,8 +88,7 @@ public abstract class ContactsDrawerActivity extends AppCompatContactsActivity i
        AccountFiltersListener,
        GroupsListener,
        NavigationView.OnNavigationItemSelectedListener,
        SelectAccountDialogFragment.Listener,
        GroupNameEditDialogFragment.Listener {
        SelectAccountDialogFragment.Listener {

    protected static String TAG = "ContactsDrawerActivity";

@@ -650,26 +649,11 @@ public abstract class ContactsDrawerActivity extends AppCompatContactsActivity i
    @Override
    public void onAccountChosen(AccountWithDataSet account, Bundle extraArgs) {
        mNewGroupAccount = account;
        GroupNameEditDialogFragment.showInsertDialog(
                getFragmentManager(), TAG_GROUP_NAME_EDIT_DIALOG);
        GroupNameEditDialogFragment.newInstanceForCreation(mNewGroupAccount, ACTION_CREATE_GROUP)
                .show(getFragmentManager(), TAG_GROUP_NAME_EDIT_DIALOG);
    }

    @Override
    public void onAccountSelectorCancelled() {
    }

    @Override
    public void onGroupNameEdit(String groupName, boolean isInsert) {
        if (mNewGroupAccount == null) {
            Toast.makeText(this, R.string.groupCreateFailedToast, Toast.LENGTH_SHORT).show();
            return;
        }
        startService(ContactSaveService.createNewGroupIntent(this,
                mNewGroupAccount, groupName, /* rawContactsToAdd */ null, getClass(),
                ACTION_CREATE_GROUP));
    }

    @Override
    public void onGroupNameEditCancelled() {
    }
}
Loading