use of org.thoughtcrime.securesms.components.emoji.EmojiImageView in project Signal-Android by signalapp.
the class ReactionsConversationView method buildPill.
private static View buildPill(@NonNull Context context, @NonNull ViewGroup parent, @NonNull Reaction reaction) {
View root = LayoutInflater.from(context).inflate(R.layout.reactions_pill, parent, false);
EmojiImageView emojiView = root.findViewById(R.id.reactions_pill_emoji);
TextView countView = root.findViewById(R.id.reactions_pill_count);
View spacer = root.findViewById(R.id.reactions_pill_spacer);
if (reaction.displayEmoji != null) {
emojiView.setImageEmoji(reaction.displayEmoji);
if (reaction.count > 1) {
countView.setText(String.valueOf(reaction.count));
} else {
countView.setVisibility(GONE);
spacer.setVisibility(GONE);
}
} else {
emojiView.setVisibility(GONE);
spacer.setVisibility(GONE);
countView.setText(context.getString(R.string.ReactionsConversationView_plus, reaction.count));
}
if (reaction.userWasSender) {
root.setBackground(ContextCompat.getDrawable(context, R.drawable.reaction_pill_background_selected));
countView.setTextColor(ContextCompat.getColor(context, R.color.reactions_pill_selected_text_color));
} else {
root.setBackground(ContextCompat.getDrawable(context, R.drawable.reaction_pill_background));
}
return root;
}
use of org.thoughtcrime.securesms.components.emoji.EmojiImageView in project Signal-Android by signalapp.
the class ReactionsBottomSheetDialogFragment method setUpTabMediator.
private void setUpTabMediator(@Nullable Bundle savedInstanceState) {
if (savedInstanceState == null) {
FrameLayout container = requireDialog().findViewById(R.id.container);
LayoutInflater layoutInflater = LayoutInflater.from(requireContext());
View statusBarShader = layoutInflater.inflate(R.layout.react_with_any_emoji_status_fade, container, false);
TabLayout emojiTabs = (TabLayout) layoutInflater.inflate(R.layout.reactions_bottom_sheet_dialog_fragment_tabs, container, false);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewUtil.getStatusBarHeight(container));
statusBarShader.setLayoutParams(params);
container.addView(statusBarShader, 0);
container.addView(emojiTabs);
ViewCompat.setOnApplyWindowInsetsListener(container, (v, insets) -> insets.consumeSystemWindowInsets());
new TabLayoutMediator(emojiTabs, recipientPagerView, (tab, position) -> {
tab.setCustomView(R.layout.reactions_bottom_sheet_dialog_fragment_emoji_item);
View customView = Objects.requireNonNull(tab.getCustomView());
EmojiImageView emoji = customView.findViewById(R.id.reactions_bottom_view_emoji_item_emoji);
TextView text = customView.findViewById(R.id.reactions_bottom_view_emoji_item_text);
EmojiCount emojiCount = recipientsAdapter.getEmojiCount(position);
if (position != 0) {
emoji.setVisibility(View.VISIBLE);
emoji.setImageEmoji(emojiCount.getDisplayEmoji());
text.setText(String.valueOf(emojiCount.getCount()));
} else {
emoji.setVisibility(View.GONE);
text.setText(customView.getContext().getString(R.string.ReactionsBottomSheetDialogFragment_all, emojiCount.getCount()));
}
}).attach();
}
}
use of org.thoughtcrime.securesms.components.emoji.EmojiImageView in project Signal-Android by signalapp.
the class ConversationReactionOverlay method setupSelectedEmoji.
private void setupSelectedEmoji() {
final List<String> emojis = SignalStore.emojiValues().getReactions();
final String oldEmoji = getOldEmoji(messageRecord);
if (oldEmoji == null) {
selectedView.setVisibility(View.GONE);
}
boolean foundSelected = false;
for (int i = 0; i < emojiViews.length; i++) {
final EmojiImageView view = emojiViews[i];
view.setScaleX(1.0f);
view.setScaleY(1.0f);
view.setTranslationY(0);
boolean isAtCustomIndex = i == customEmojiIndex;
boolean isNotAtCustomIndexAndOldEmojiMatches = !isAtCustomIndex && oldEmoji != null && emojis.get(i).equals(EmojiUtil.getCanonicalRepresentation(oldEmoji));
boolean isAtCustomIndexAndOldEmojiExists = isAtCustomIndex && oldEmoji != null;
if (!foundSelected && (isNotAtCustomIndexAndOldEmojiMatches || isAtCustomIndexAndOldEmojiExists)) {
foundSelected = true;
selectedView.setVisibility(View.VISIBLE);
ConstraintSet constraintSet = new ConstraintSet();
constraintSet.clone(foregroundView);
constraintSet.clear(selectedView.getId(), ConstraintSet.LEFT);
constraintSet.clear(selectedView.getId(), ConstraintSet.RIGHT);
constraintSet.connect(selectedView.getId(), ConstraintSet.LEFT, view.getId(), ConstraintSet.LEFT);
constraintSet.connect(selectedView.getId(), ConstraintSet.RIGHT, view.getId(), ConstraintSet.RIGHT);
constraintSet.applyTo(foregroundView);
if (isAtCustomIndex) {
view.setImageEmoji(oldEmoji);
view.setTag(oldEmoji);
} else {
view.setImageEmoji(SignalStore.emojiValues().getPreferredVariation(emojis.get(i)));
}
} else if (isAtCustomIndex) {
view.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_any_emoji_32));
view.setTag(null);
} else {
view.setImageEmoji(SignalStore.emojiValues().getPreferredVariation(emojis.get(i)));
}
}
}
Aggregations