From 607567cd35f85c93129e995f0524b355754d20da Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 12 Nov 2017 22:50:45 -0800 Subject: [PATCH] don't allow duplicate group names If group already exists, warn rather than create another with the same name. --- .../eehouse/android/xw4/GamesListDelegate.java | 15 ++++++++++++--- .../android/app/src/main/res/values/strings.xml | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java index 06300270b..41ffeeaea 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java @@ -755,9 +755,18 @@ public class GamesListDelegate extends ListDelegateBase lstnr = new OnClickListener() { public void onClick( DialogInterface dlg, int item ) { String name = namer.getName(); - DBUtils.addGroup( m_activity, name ); - mkListAdapter(); - showNewGroupIf(); + long hasName = DBUtils.getGroup( m_activity, name ); + if ( DBUtils.GROUPID_UNSPEC == hasName ) { + DBUtils.addGroup( m_activity, name ); + mkListAdapter(); + showNewGroupIf(); + } else { + String msg = LocUtils + .getString( m_activity, + R.string.duplicate_group_name_fmt, + name ); + makeOkOnlyBuilder( msg ).show(); + } } }; lstnr2 = new OnClickListener() { diff --git a/xwords4/android/app/src/main/res/values/strings.xml b/xwords4/android/app/src/main/res/values/strings.xml index c8342bb3a..4a5a7eb29 100644 --- a/xwords4/android/app/src/main/res/values/strings.xml +++ b/xwords4/android/app/src/main/res/values/strings.xml @@ -2161,6 +2161,8 @@ Archive\u200C Archive + The group \"%1$s\" already exists. + Reconnect Square rack tiles