Skip to content

Commit

Permalink
Add You to reactions you've sent in the bottom dialog fragment.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-signal committed Feb 4, 2020
1 parent 092fb40 commit ed2b049
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.thoughtcrime.securesms.reactions;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -45,13 +46,13 @@ public int getItemCount() {
return data.size();
}

final class ViewHolder extends RecyclerView.ViewHolder {
final static class ViewHolder extends RecyclerView.ViewHolder {

private final AvatarImageView avatar;
private final TextView recipient;
private final TextView emoji;

public ViewHolder(@NonNull View itemView) {
private ViewHolder(@NonNull View itemView) {
super(itemView);

avatar = itemView.findViewById(R.id.reactions_bottom_view_recipient_avatar);
Expand All @@ -60,7 +61,7 @@ public ViewHolder(@NonNull View itemView) {
}

void bind(@NonNull Reaction reaction) {
this.recipient.setText(reaction.getSender().getDisplayName(itemView.getContext()));
this.recipient.setText(getReactionSenderDisplayName(itemView.getContext(), reaction.getSender()));
this.emoji.setText(reaction.getEmoji());

if (reaction.getSender().equals(Recipient.self())) {
Expand All @@ -69,6 +70,16 @@ void bind(@NonNull Reaction reaction) {
this.avatar.setAvatar(GlideApp.with(avatar), reaction.getSender(), false);
}
}

private static @NonNull String getReactionSenderDisplayName(@NonNull Context context, @NonNull Recipient sender) {
String displayName = sender.getDisplayName(context);

if (sender.isLocalNumber()) {
return context.getString(R.string.ReactionsBottomSheetDialogFragment_you, displayName);
} else {
return displayName;
}
}
}

}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@

<!-- ReactionsBottomSheetDialogFragment -->
<string name="ReactionsBottomSheetDialogFragment_all">All %1$d</string>
<string name="ReactionsBottomSheetDialogFragment_you">%1$s (You)</string>

<!-- ReactionsConversationView -->
<string name="ReactionsConversationView_plus">+%1$d</string>
Expand Down

0 comments on commit ed2b049

Please sign in to comment.