Update verified icon.

This commit is contained in:
Michelle Tang 2024-09-17 16:48:15 -07:00 committed by Greyson Parrelli
parent ba06efe35a
commit b74f04495e
10 changed files with 58 additions and 9 deletions

View file

@ -226,8 +226,8 @@ public abstract class MessageRecord extends DisplayRecord {
} else if (isIdentityUpdate()) {
return fromRecipient(getFromRecipient(), r -> context.getString(R.string.MessageRecord_your_safety_number_with_s_has_changed, r.getDisplayName(context)), R.drawable.ic_update_safety_number_16);
} else if (isIdentityVerified()) {
if (isOutgoing()) return fromRecipient(getToRecipient(), r -> context.getString(R.string.MessageRecord_you_marked_your_safety_number_with_s_verified, r.getDisplayName(context)), R.drawable.ic_update_verified_16);
else return fromRecipient(getFromRecipient(), r -> context.getString(R.string.MessageRecord_you_marked_your_safety_number_with_s_verified_from_another_device, r.getDisplayName(context)), R.drawable.ic_update_verified_16);
if (isOutgoing()) return fromRecipient(getToRecipient(), r -> context.getString(R.string.MessageRecord_you_marked_your_safety_number_with_s_verified, r.getDisplayName(context)), R.drawable.ic_safety_number_16);
else return fromRecipient(getFromRecipient(), r -> context.getString(R.string.MessageRecord_you_marked_your_safety_number_with_s_verified_from_another_device, r.getDisplayName(context)), R.drawable.ic_safety_number_16);
} else if (isIdentityDefault()) {
if (isOutgoing()) return fromRecipient(getToRecipient(), r -> context.getString(R.string.MessageRecord_you_marked_your_safety_number_with_s_unverified, r.getDisplayName(context)), R.drawable.ic_update_info_16);
else return fromRecipient(getFromRecipient(), r -> context.getString(R.string.MessageRecord_you_marked_your_safety_number_with_s_unverified_from_another_device, r.getDisplayName(context)), R.drawable.ic_update_info_16);

View file

@ -438,7 +438,7 @@ final class GroupMemberListAdapter extends RecyclerView.Adapter<GroupMemberListA
pendingMembers.getInviteCount(),
displayName, pendingMembers.getInviteCount());
bindImageAndText(inviter, displayText, inviter.getAbout());
bindImageAndText(inviter, displayText, inviter.getFilteredAbout());
if (pendingMembers.isCancellable() && adminActionsListener != null) {
popupMenu.setMenu(R.menu.others_invite_pending_menu,

View file

@ -1,5 +1,6 @@
package org.thoughtcrime.securesms.profiles.manage;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.Editable;
@ -15,6 +16,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.navigation.Navigation;
@ -25,11 +27,11 @@ import androidx.recyclerview.widget.RecyclerView;
import org.signal.core.util.BreakIteratorCompat;
import org.signal.core.util.EditTextUtil;
import org.signal.core.util.StringUtil;
import org.signal.core.util.concurrent.LifecycleDisposable;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.components.emoji.EmojiUtil;
import org.thoughtcrime.securesms.reactions.any.ReactWithAnyEmojiBottomSheetDialogFragment;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.signal.core.util.concurrent.LifecycleDisposable;
import org.thoughtcrime.securesms.util.ViewUtil;
import org.thoughtcrime.securesms.util.adapter.AlwaysChangedDiffUtil;
import org.thoughtcrime.securesms.util.text.AfterTextChanged;
@ -63,6 +65,7 @@ public class EditAboutFragment extends Fragment implements EditProfileActivity.E
private ImageView emojiView;
private EditText bodyView;
private TextView countView;
private TextView errorView;
private CircularProgressMaterialButton saveButton;
private EditAboutViewModel viewModel;
private LifecycleDisposable lifecycleDisposable;
@ -79,6 +82,7 @@ public class EditAboutFragment extends Fragment implements EditProfileActivity.E
this.emojiView = view.findViewById(R.id.edit_about_emoji);
this.bodyView = view.findViewById(R.id.edit_about_body);
this.countView = view.findViewById(R.id.edit_about_count);
this.errorView = view.findViewById(R.id.edit_about_error);
this.saveButton = view.findViewById(R.id.edit_about_save);
lifecycleDisposable = new LifecycleDisposable();
@ -92,6 +96,7 @@ public class EditAboutFragment extends Fragment implements EditProfileActivity.E
EditTextUtil.addGraphemeClusterLimitFilter(bodyView, ABOUT_MAX_GLYPHS);
this.bodyView.addTextChangedListener(new AfterTextChanged(editable -> {
checkValidText(editable.toString());
trimFieldToMaxByteLength(editable);
presentCount(editable.toString());
}));
@ -126,6 +131,21 @@ public class EditAboutFragment extends Fragment implements EditProfileActivity.E
ViewUtil.focusAndMoveCursorToEndAndOpenKeyboard(bodyView);
}
private void checkValidText(String text) {
boolean isInvalid = false;
for (Character emoji : StringUtil.FILTERED_EMOJIS) {
if (text.contains(Character.toString(emoji))) {
isInvalid = true;
break;
}
}
int colorRes = isInvalid ? R.color.signal_colorError : R.color.signal_colorPrimary;
bodyView.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(requireContext(), colorRes)));
errorView.setVisibility(isInvalid ? View.VISIBLE : View.GONE);
saveButton.setEnabled(!isInvalid);
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
outState.putString(KEY_SELECTED_EMOJI, selectedEmoji);

View file

@ -367,8 +367,11 @@ class Recipient(
/** The badge to feature on a recipient's avatar, if any. */
val featuredBadge: Badge? = badges.firstOrNull()
/** A string filtering out banned emojis from the about text */
val filteredAbout: String? by lazy { about?.filterNot { StringUtil.FILTERED_EMOJIS.contains(it) } }
/** A string combining the about emoji + text for displaying various places. */
val combinedAboutAndEmoji: String? by lazy { listOf(aboutEmoji, about).filter { it.isNotNullOrBlank() }.joinToString(separator = " ").nullIfBlank() }
val combinedAboutAndEmoji: String? by lazy { listOf(aboutEmoji, filteredAbout).filter { it.isNotNullOrBlank() }.joinToString(separator = " ").nullIfBlank() }
/** Whether or not we should blur the recipient's avatar when showing it in the chat list and other locations. */
val shouldBlurAvatar: Boolean

View file

@ -96,7 +96,7 @@ class AboutSheet : ComposeBottomSheetDialogFragment() {
displayName = recipient.get().getDisplayName(requireContext()),
shortName = recipient.get().getShortDisplayName(requireContext()),
profileName = recipient.get().profileName.toString(),
about = recipient.get().about,
about = recipient.get().filteredAbout,
verified = verified,
hasAvatar = recipient.get().profileAvatarFileDetails.hasFile(),
recipientForAvatar = recipient.get(),
@ -220,7 +220,7 @@ private fun Content(
if (!model.isSelf && model.verified) {
AboutRow(
startIcon = painterResource(id = R.drawable.check),
startIcon = painterResource(id = R.drawable.symbol_safety_number_24),
text = stringResource(id = R.string.AboutSheet__verified),
modifier = Modifier.align(alignment = Alignment.Start),
onClick = onClickSignalConnections

View file

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:fillColor="#FF000000"
android:pathData="M11.04 5.35c0.2-0.3 0.12-0.7-0.19-0.9-0.3-0.2-0.7-0.1-0.9 0.2L7.2 8.88 6.01 7.35C5.8 7.07 5.38 7.02 5.11 7.24c-0.3 0.22-0.34 0.63-0.12 0.9l1.75 2.26c0.13 0.17 0.33 0.26 0.54 0.25 0.2-0.01 0.4-0.12 0.51-0.3l3.25-5Z"/>
<path
android:fillColor="#FF000000"
android:pathData="M6.64 14.74c0.8 0.64 1.93 0.64 2.72 0l2.42-1.97c1.4-1.13 2.27-2.78 2.43-4.56l0.33-3.63c0.09-1-0.51-1.92-1.46-2.24l-3.61-1.2c-0.95-0.32-1.99-0.32-2.94 0l-3.6 1.2C1.96 2.66 1.36 3.58 1.45 4.58L1.79 8.2c0.16 1.78 1.04 3.43 2.43 4.56l2.42 1.97Zm1.9-1.01c-0.32 0.25-0.76 0.25-1.08 0l-2.42-1.97c-1.12-0.91-1.82-2.23-1.96-3.67L2.75 4.46c-0.03-0.4 0.2-0.76 0.58-0.89l3.61-1.2c0.69-0.23 1.43-0.23 2.12 0l3.6 1.2c0.38 0.13 0.62 0.5 0.59 0.89L12.9 8.09c-0.13 1.44-0.83 2.76-1.95 3.67l-2.42 1.97Z"/>
</vector>

View file

@ -85,7 +85,7 @@
android:layout_marginEnd="3dp"
android:tint="@color/signal_inverse_transparent_80"
android:visibility="gone"
app:srcCompat="@drawable/ic_check_24"
app:srcCompat="@drawable/symbol_safety_number_24"
tools:visibility="visible" />
<TextView

View file

@ -59,6 +59,17 @@
app:layout_constraintTop_toTopOf="@id/edit_about_body"
app:layout_constraintBottom_toBottomOf="@id/edit_about_body"/>
<TextView
android:id="@+id/edit_about_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
style="@style/Signal.Text.Caption"
android:textColor="@color/signal_colorError"
app:layout_constraintTop_toBottomOf="@id/edit_about_body"
app:layout_constraintStart_toStartOf="@id/edit_about_body"
android:text="@string/EditAboutFragment_one_or_more_characters" />
<TextView
android:id="@+id/edit_about_count"
android:layout_width="wrap_content"

View file

@ -3308,6 +3308,8 @@
<string name="EditAboutFragment_free_to_chat">Free to chat</string>
<string name="EditAboutFragment_taking_a_break">Taking a break</string>
<string name="EditAboutFragment_working_on_something_new">Working on something new</string>
<!-- Error text shown when the About text contains an invalid character -->
<string name="EditAboutFragment_one_or_more_characters">One or more characters is invalid.</string>
<!-- EditProfileFragment -->
<string name="EditProfileFragment__edit_group">Edit group</string>

View file

@ -1,6 +1,5 @@
package org.signal.core.util;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
@ -11,6 +10,7 @@ import androidx.core.text.BidiFormatter;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
@ -22,6 +22,7 @@ public final class StringUtil {
'\u200B', // zero-width space
'\u2800'); // braille blank
public static final List<Character> FILTERED_EMOJIS = List.of('\u2713', '\u2714', '\u2611', '\u221A', '\u26C9', '\u26CA', '\u26DB');
private static final Pattern ALL_ASCII_PATTERN = Pattern.compile("^[\\x00-\\x7F]*$");