XmppUri code cleanup

This commit is contained in:
Daniel Gultsch 2018-05-04 22:07:00 +02:00
parent f9e26d7887
commit 8cd222b046
1 changed files with 9 additions and 16 deletions

View File

@ -16,13 +16,13 @@ public class XmppUri {
protected Uri uri; protected Uri uri;
protected String jid; protected String jid;
protected List<Fingerprint> fingerprints = new ArrayList<>(); private List<Fingerprint> fingerprints = new ArrayList<>();
private String body; private String body;
private String name; private String name;
private String action; private String action;
protected boolean safeSource = true; private boolean safeSource = true;
public static final String OMEMO_URI_PARAM = "omemo-sid-"; private static final String OMEMO_URI_PARAM = "omemo-sid-";
public static final String ACTION_JOIN = "join"; public static final String ACTION_JOIN = "join";
public static final String ACTION_MESSAGE = "message"; public static final String ACTION_MESSAGE = "message";
@ -121,11 +121,11 @@ public class XmppUri {
return ""; return "";
} }
protected List<Fingerprint> parseFingerprints(String query) { private List<Fingerprint> parseFingerprints(String query) {
return parseFingerprints(query, ';'); return parseFingerprints(query, ';');
} }
protected List<Fingerprint> parseFingerprints(String query, char seperator) { private List<Fingerprint> parseFingerprints(String query, char seperator) {
List<Fingerprint> fingerprints = new ArrayList<>(); List<Fingerprint> fingerprints = new ArrayList<>();
String[] pairs = query == null ? new String[0] : query.split(String.valueOf(seperator)); String[] pairs = query == null ? new String[0] : query.split(String.valueOf(seperator));
for (String pair : pairs) { for (String pair : pairs) {
@ -146,7 +146,7 @@ public class XmppUri {
return fingerprints; return fingerprints;
} }
protected String parseParameter(String key, String query) { private String parseParameter(String key, String query) {
for (String pair : query == null ? new String[0] : query.split(";")) { for (String pair : query == null ? new String[0] : query.split(";")) {
final String[] parts = pair.split("=", 2); final String[] parts = pair.split("=", 2);
if (parts.length == 2 && key.equals(parts[0].toLowerCase(Locale.US))) { if (parts.length == 2 && key.equals(parts[0].toLowerCase(Locale.US))) {
@ -171,11 +171,8 @@ public class XmppUri {
} }
public boolean isAction(final String action) { public boolean isAction(final String action) {
if (this.action == null) { return this.action != null && this.action.equals(action);
return false;
}
return this.action.equals(action);
} }
public Jid getJid() { public Jid getJid() {
@ -239,11 +236,7 @@ public class XmppUri {
public static class Fingerprint { public static class Fingerprint {
public final FingerprintType type; public final FingerprintType type;
public final String fingerprint; public final String fingerprint;
public final int deviceId; final int deviceId;
public Fingerprint(FingerprintType type, String fingerprint) {
this(type, fingerprint, 0);
}
public Fingerprint(FingerprintType type, String fingerprint, int deviceId) { public Fingerprint(FingerprintType type, String fingerprint, int deviceId) {
this.type = type; this.type = type;
@ -257,7 +250,7 @@ public class XmppUri {
} }
} }
public static String lameUrlDecode(String url) { private static String lameUrlDecode(String url) {
return url.replace("%23", "#").replace("%25", "%"); return url.replace("%23", "#").replace("%25", "%");
} }