Search in sources :

Example 1 with ProfileChangeDetails

use of org.thoughtcrime.securesms.database.model.databaseprotos.ProfileChangeDetails in project Signal-Android by WhisperSystems.

the class MessageRecord method getProfileChangeDescription.

@NonNull
private String getProfileChangeDescription(@NonNull Context context) {
    try {
        byte[] decoded = Base64.decode(getBody());
        ProfileChangeDetails profileChangeDetails = ProfileChangeDetails.parseFrom(decoded);
        if (profileChangeDetails.hasProfileNameChange()) {
            String displayName = getIndividualRecipient().getDisplayName(context);
            String newName = StringUtil.isolateBidi(ProfileName.fromSerialized(profileChangeDetails.getProfileNameChange().getNew()).toString());
            String previousName = StringUtil.isolateBidi(ProfileName.fromSerialized(profileChangeDetails.getProfileNameChange().getPrevious()).toString());
            if (getIndividualRecipient().isSystemContact()) {
                return context.getString(R.string.MessageRecord_changed_their_profile_name_from_to, displayName, previousName, newName);
            } else {
                return context.getString(R.string.MessageRecord_changed_their_profile_name_to, previousName, newName);
            }
        }
    } catch (IOException e) {
        Log.w(TAG, "Profile name change details could not be read", e);
    }
    return context.getString(R.string.MessageRecord_changed_their_profile, getIndividualRecipient().getDisplayName(context));
}
Also used : SpannableString(android.text.SpannableString) IOException(java.io.IOException) ProfileChangeDetails(org.thoughtcrime.securesms.database.model.databaseprotos.ProfileChangeDetails) NonNull(androidx.annotation.NonNull)

Example 2 with ProfileChangeDetails

use of org.thoughtcrime.securesms.database.model.databaseprotos.ProfileChangeDetails in project Signal-Android by signalapp.

the class MessageRecord method getProfileChangeDescription.

@NonNull
private String getProfileChangeDescription(@NonNull Context context) {
    try {
        byte[] decoded = Base64.decode(getBody());
        ProfileChangeDetails profileChangeDetails = ProfileChangeDetails.parseFrom(decoded);
        if (profileChangeDetails.hasProfileNameChange()) {
            String displayName = getIndividualRecipient().getDisplayName(context);
            String newName = StringUtil.isolateBidi(ProfileName.fromSerialized(profileChangeDetails.getProfileNameChange().getNew()).toString());
            String previousName = StringUtil.isolateBidi(ProfileName.fromSerialized(profileChangeDetails.getProfileNameChange().getPrevious()).toString());
            if (getIndividualRecipient().isSystemContact()) {
                return context.getString(R.string.MessageRecord_changed_their_profile_name_from_to, displayName, previousName, newName);
            } else {
                return context.getString(R.string.MessageRecord_changed_their_profile_name_to, previousName, newName);
            }
        }
    } catch (IOException e) {
        Log.w(TAG, "Profile name change details could not be read", e);
    }
    return context.getString(R.string.MessageRecord_changed_their_profile, getIndividualRecipient().getDisplayName(context));
}
Also used : SpannableString(android.text.SpannableString) IOException(java.io.IOException) ProfileChangeDetails(org.thoughtcrime.securesms.database.model.databaseprotos.ProfileChangeDetails) NonNull(androidx.annotation.NonNull)

Aggregations

SpannableString (android.text.SpannableString)2 NonNull (androidx.annotation.NonNull)2 IOException (java.io.IOException)2 ProfileChangeDetails (org.thoughtcrime.securesms.database.model.databaseprotos.ProfileChangeDetails)2