Don't make identity descriptions unique on import
Identity descriptions don't have to be unique so they shouldn't be modified when imported to make them unique. This also means that identities with no description can be imported without giving them one (e.g. "Imported", "Imported (1)", "Imported (2)").
This commit is contained in:
parent
12824ba726
commit
ab47889542
1 changed files with 4 additions and 24 deletions
|
@ -540,19 +540,6 @@ public class SettingsImporter {
|
|||
nextIdentityIndex++;
|
||||
}
|
||||
|
||||
String identityDescription = (identity.description == null) ? "Imported" : identity.description;
|
||||
if (isIdentityDescriptionUsed(identityDescription, existingIdentities)) {
|
||||
// Identity description is already in use. So generate a new one by appending
|
||||
// " (x)", where x is the first number >= 1 that results in an unused identity
|
||||
// description.
|
||||
for (int i = 1; i <= existingIdentities.size(); i++) {
|
||||
identityDescription = identity.description + " (" + i + ")";
|
||||
if (!isIdentityDescriptionUsed(identityDescription, existingIdentities)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String identitySuffix = "." + writeIdentityIndex;
|
||||
|
||||
// Write name used in identity
|
||||
|
@ -568,8 +555,10 @@ public class SettingsImporter {
|
|||
putString(editor, accountKeyPrefix + AccountPreferenceSerializer.IDENTITY_EMAIL_KEY + identitySuffix, identity.email);
|
||||
|
||||
// Write identity description
|
||||
putString(editor, accountKeyPrefix + AccountPreferenceSerializer.IDENTITY_DESCRIPTION_KEY + identitySuffix,
|
||||
identityDescription);
|
||||
if (identity.description != null) {
|
||||
putString(editor, accountKeyPrefix + AccountPreferenceSerializer.IDENTITY_DESCRIPTION_KEY + identitySuffix,
|
||||
identity.description);
|
||||
}
|
||||
|
||||
if (identity.settings != null) {
|
||||
// Validate identity settings
|
||||
|
@ -617,15 +606,6 @@ public class SettingsImporter {
|
|||
return false;
|
||||
}
|
||||
|
||||
private static boolean isIdentityDescriptionUsed(String description, List<Identity> identities) {
|
||||
for (Identity identity : identities) {
|
||||
if (identity.getDescription().equals(description)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static int findIdentity(ImportedIdentity identity, List<Identity> identities) {
|
||||
for (int i = 0; i < identities.size(); i++) {
|
||||
Identity existingIdentity = identities.get(i);
|
||||
|
|
Loading…
Reference in a new issue