use of org.thoughtcrime.securesms.components.emoji.EmojiImageView in project Signal-Android by WhisperSystems.
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 WhisperSystems.
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 WhisperSystems.
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)));
}
}
}
use of org.thoughtcrime.securesms.components.emoji.EmojiImageView in project Signal-Android by WhisperSystems.
the class HelpFragment method initializeViews.
private void initializeViews(@NonNull View view) {
problem = view.findViewById(R.id.help_fragment_problem);
includeDebugLogs = view.findViewById(R.id.help_fragment_debug);
debugLogInfo = view.findViewById(R.id.help_fragment_debug_info);
faq = view.findViewById(R.id.help_fragment_faq);
next = view.findViewById(R.id.help_fragment_next);
toaster = view.findViewById(R.id.help_fragment_next_toaster);
categorySpinner = view.findViewById(R.id.help_fragment_category);
emoji = new ArrayList<>(Feeling.values().length);
for (Feeling feeling : Feeling.values()) {
EmojiImageView emojiView = view.findViewById(feeling.getViewId());
emojiView.setImageEmoji(feeling.getEmojiCode());
emoji.add(view.findViewById(feeling.getViewId()));
}
categoryAdapter = ArrayAdapter.createFromResource(requireContext(), R.array.HelpFragment__categories_3, android.R.layout.simple_spinner_item);
categoryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
categorySpinner.setAdapter(categoryAdapter);
Bundle args = getArguments();
if (args != null) {
categorySpinner.setSelection(Util.clamp(args.getInt(START_CATEGORY_INDEX, 0), 0, categorySpinner.getCount() - 1));
}
}
use of org.thoughtcrime.securesms.components.emoji.EmojiImageView in project Signal-Android by signalapp.
the class HelpFragment method initializeViews.
private void initializeViews(@NonNull View view) {
problem = view.findViewById(R.id.help_fragment_problem);
includeDebugLogs = view.findViewById(R.id.help_fragment_debug);
debugLogInfo = view.findViewById(R.id.help_fragment_debug_info);
faq = view.findViewById(R.id.help_fragment_faq);
next = view.findViewById(R.id.help_fragment_next);
toaster = view.findViewById(R.id.help_fragment_next_toaster);
categorySpinner = view.findViewById(R.id.help_fragment_category);
emoji = new ArrayList<>(Feeling.values().length);
for (Feeling feeling : Feeling.values()) {
EmojiImageView emojiView = view.findViewById(feeling.getViewId());
emojiView.setImageEmoji(feeling.getEmojiCode());
emoji.add(view.findViewById(feeling.getViewId()));
}
categoryAdapter = ArrayAdapter.createFromResource(requireContext(), R.array.HelpFragment__categories_3, android.R.layout.simple_spinner_item);
categoryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
categorySpinner.setAdapter(categoryAdapter);
Bundle args = getArguments();
if (args != null) {
categorySpinner.setSelection(Util.clamp(args.getInt(START_CATEGORY_INDEX, 0), 0, categorySpinner.getCount() - 1));
}
}
Aggregations