Move bidi methods to BidiUtil.

This commit is contained in:
Greyson Parrelli
2025-02-27 13:58:22 -05:00
parent 791e95c645
commit e9e62b98f3
15 changed files with 201 additions and 186 deletions

View File

@@ -6,7 +6,7 @@
package org.thoughtcrime.securesms.database.model
import okio.ByteString
import org.signal.core.util.StringUtil
import org.signal.core.util.BidiUtil
import org.signal.core.util.isNullOrEmpty
import org.signal.storageservice.protos.groups.AccessControl
import org.signal.storageservice.protos.groups.AccessControl.AccessRequired
@@ -340,7 +340,7 @@ object GroupsV2UpdateMessageConverter {
fun translateNewTitle(change: DecryptedGroupChange, editorUnknown: Boolean, updates: MutableList<GroupChangeChatUpdate.Update>) {
if (change.newTitle != null) {
val editorAci = if (editorUnknown) null else change.editorServiceIdBytes
val newTitle = StringUtil.isolateBidi(change.newTitle?.value_)
val newTitle = BidiUtil.isolateBidi(change.newTitle?.value_)
updates.add(
GroupChangeChatUpdate.Update(
groupNameUpdate = GroupNameUpdate(

View File

@@ -12,6 +12,7 @@ import androidx.annotation.StringRes;
import androidx.annotation.VisibleForTesting;
import androidx.core.content.ContextCompat;
import org.signal.core.util.BidiUtil;
import org.signal.core.util.StringUtil;
import org.signal.storageservice.protos.groups.AccessControl;
import org.signal.storageservice.protos.groups.Member;
@@ -551,9 +552,9 @@ final class GroupsV2UpdateMessageProducer {
private void describeGroupNameUpdate(@NonNull GroupNameUpdate update, @NonNull List<UpdateDescription> updates) {
if (update.updaterAci == null) {
updates.add(updateDescription(context.getString(R.string.MessageRecord_the_group_name_has_changed_to_s, StringUtil.isolateBidi(update.newGroupName)), R.drawable.ic_update_group_name_16));
updates.add(updateDescription(context.getString(R.string.MessageRecord_the_group_name_has_changed_to_s, BidiUtil.isolateBidi(update.newGroupName)), R.drawable.ic_update_group_name_16));
} else {
String newTitle = StringUtil.isolateBidi(update.newGroupName);
String newTitle = BidiUtil.isolateBidi(update.newGroupName);
if (selfIds.matches(update.updaterAci)) {
updates.add(updateDescription(context.getString(R.string.MessageRecord_you_changed_the_group_name_to_s, newTitle), R.drawable.ic_update_group_name_16));
} else {
@@ -1081,7 +1082,7 @@ final class GroupsV2UpdateMessageProducer {
boolean editorIsYou = selfIds.matches(change.editorServiceIdBytes);
if (change.newTitle != null) {
String newTitle = StringUtil.isolateBidi(change.newTitle.value_);
String newTitle = BidiUtil.isolateBidi(change.newTitle.value_);
if (editorIsYou) {
updates.add(updateDescription(context.getString(R.string.MessageRecord_you_changed_the_group_name_to_s, newTitle), R.drawable.ic_update_group_name_16));
} else {
@@ -1104,7 +1105,7 @@ final class GroupsV2UpdateMessageProducer {
private void describeUnknownEditorNewTitle(@NonNull DecryptedGroupChange change, @NonNull List<UpdateDescription> updates) {
if (change.newTitle != null) {
updates.add(updateDescription(context.getString(R.string.MessageRecord_the_group_name_has_changed_to_s, StringUtil.isolateBidi(change.newTitle.value_)), R.drawable.ic_update_group_name_16));
updates.add(updateDescription(context.getString(R.string.MessageRecord_the_group_name_has_changed_to_s, BidiUtil.isolateBidi(change.newTitle.value_)), R.drawable.ic_update_group_name_16));
}
}
@@ -1118,7 +1119,7 @@ final class GroupsV2UpdateMessageProducer {
updates.add(updateDescription(R.string.MessageRecord_s_changed_the_group_description, groupDescriptionUpdate.updaterAci, R.drawable.ic_update_group_name_16));
}
} else {
updates.add(updateDescription(context.getString(R.string.MessageRecord_the_group_name_has_changed_to_s, StringUtil.isolateBidi(groupDescriptionUpdate.newDescription)), R.drawable.ic_update_group_name_16));
updates.add(updateDescription(context.getString(R.string.MessageRecord_the_group_name_has_changed_to_s, BidiUtil.isolateBidi(groupDescriptionUpdate.newDescription)), R.drawable.ic_update_group_name_16));
}
}

View File

@@ -34,6 +34,7 @@ import androidx.core.content.ContextCompat;
import com.annimon.stream.Stream;
import org.signal.core.util.Base64;
import org.signal.core.util.BidiUtil;
import org.signal.core.util.StringUtil;
import org.signal.core.util.logging.Log;
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
@@ -470,8 +471,8 @@ public abstract class MessageRecord extends DisplayRecord {
if (profileChangeDetails != null) {
if (profileChangeDetails.profileNameChange != null) {
String displayName = getFromRecipient().getDisplayName(context);
String newName = StringUtil.isolateBidi(ProfileName.fromSerialized(profileChangeDetails.profileNameChange.newValue).toString());
String previousName = StringUtil.isolateBidi(ProfileName.fromSerialized(profileChangeDetails.profileNameChange.previous).toString());
String newName = BidiUtil.isolateBidi(ProfileName.fromSerialized(profileChangeDetails.profileNameChange.newValue).toString());
String previousName = BidiUtil.isolateBidi(ProfileName.fromSerialized(profileChangeDetails.profileNameChange.previous).toString());
String updateMessage;
if (getFromRecipient().isSystemContact()) {