Skip to content

Commit

Permalink
[core/connection] Change logic of getXmlLang method.
Browse files Browse the repository at this point in the history
  • Loading branch information
vkolesnikov-intermedia authored and TrueWarg committed Dec 20, 2023
1 parent 7cb13b4 commit 163e224
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -598,13 +598,18 @@ public Locale getLanguage() {
* @return the stream language to use when connecting to the server.
*/
public String getXmlLang() {
// TODO: Change to Locale.toLanguageTag() once Smack's minimum Android API level is 21 or higher.
// This will need a workaround for new Locale("").getLanguageTag() returning "und". Expected
// behavior of this function:
// - returns null if language is null
// - returns "" if language.getLanguage() returns the empty string
// - returns language.toLanguageTag() otherwise
return language != null ? language.toString().replace("_", "-") : null;
if (language == null) return null;
if (language.getLanguage().isEmpty()) return "";
String result = language.getLanguage();
String country = language.getCountry();
if (!result.isEmpty()) {
if (!country.isEmpty()) {
result = result + "-" + country;
}
} else {
result = country;
}
return result;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.4.4-intermedia-1.3.0
4.4.4-intermedia-1.3.1

0 comments on commit 163e224

Please sign in to comment.