From a085744038f2f52b9d340d51275d1a4e131f885b Mon Sep 17 00:00:00 2001 From: sk Date: Fri, 10 Nov 2023 15:37:31 +0100 Subject: [PATCH] fix missing parens on start of pronouns --- .../org/joinmastodon/android/ui/utils/UiUtils.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java index 306b767c12..a33da0105e 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java @@ -1707,13 +1707,14 @@ private static String extractPronounsFromField(String localizedPronouns, Account Matcher matcher=trimPronouns.matcher(text); if(!matcher.find()) return null; String pronouns=matcher.group(1); - // crude fix to allow for pronouns like "it(/she)" - int missingClosingParens=0; + // crude fix to allow for pronouns like "it(/she)" or "(de) sie/ihr" + int missingParens=0; for(char c : pronouns.toCharArray()){ - if(c=='(') missingClosingParens++; - if(c==')') missingClosingParens--; + if(c=='(') missingParens++; + if(c==')') missingParens--; } - pronouns+=")".repeat(Math.max(0, missingClosingParens)); + if(missingParens > 0) pronouns+=")".repeat(missingParens); + else if(missingParens < 0) pronouns="(".repeat(missingParens*-1)+pronouns; // if ends with an un-closed custom emoji if(pronouns.matches("^.*\\s+:[a-zA-Z_]+$")) pronouns+=':'; return pronouns;