check for duplicate keys in entry edit

This commit is contained in:
Philipp Crocoll 2015-09-29 01:20:25 +02:00
parent 4fb1ae996a
commit 565438a630
2 changed files with 11 additions and 1 deletions

View File

@ -1015,6 +1015,7 @@ namespace keepass2android
LinearLayout container = (LinearLayout) FindViewById(Resource.Id.advanced_container);
HashSet<string> allKeys = new HashSet<string>();
for (int i = 0; i < container.ChildCount; i++) {
View ees = container.GetChildAt(i);
@ -1026,6 +1027,14 @@ namespace keepass2android
return false;
}
if (allKeys.Contains(key))
{
Toast.MakeText(this, GetString(Resource.String.error_string_duplicate_key, new Java.Lang.Object[]{key}), ToastLength.Long).Show();
return false;
}
allKeys.Add(key);
}
return true;

View File

@ -277,6 +277,7 @@
<string name="error_invalid_expiry_date">Invalid date/time format for expiry date!</string>
<string name="error_string_key">A field name is required for each string.</string>
<string name="error_string_duplicate_key">A field name cannot be used twice (%1$s).</string>
<string name="field_name">Field Name</string>
<string name="field_value">Field value</string>
<string name="protection">Protected field</string>