diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-06-24 10:07:22 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-06-24 10:07:22 +0200 |
commit | 7adb0ca6b889aac5f306d2e0efdda277d6ae614b (patch) | |
tree | b53c1c894460f089119bbdb430099ecacb1b5d19 /src | |
parent | 472d7a8f0186ef1474c1e480e4d58db3ad7fab7a (diff) |
don't use version part of identity name in presence selection
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/pixart/messenger/entities/Presences.java | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Presences.java b/src/main/java/de/pixart/messenger/entities/Presences.java index d57515392..c82e733e9 100644 --- a/src/main/java/de/pixart/messenger/entities/Presences.java +++ b/src/main/java/de/pixart/messenger/entities/Presences.java @@ -139,11 +139,31 @@ public class Presences { typeMap.put(resource, type); } if (name != null) { - nameMap.put(resource, name); + nameMap.put(resource, nameWithoutVersion(name)); } } } } return new Pair<>(typeMap, nameMap); } + + private static String nameWithoutVersion(String name) { + String[] parts = name.split(" "); + if (parts.length <= 1) { + return name; + } else { + if (Character.isDigit(parts[parts.length - 1].charAt(0))) { + StringBuilder output = new StringBuilder(); + for (int i = 0; i < parts.length - 1; ++i) { + if (output.length() != 0) { + output.append(' '); + } + output.append(parts[i]); + } + return output.toString(); + } else { + return name; + } + } + } } |