Search in sources :

Example 6 with EmojiImageView

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;
}
Also used : TextView(android.widget.TextView) EmojiImageView(org.thoughtcrime.securesms.components.emoji.EmojiImageView) TextView(android.widget.TextView) View(android.view.View) EmojiImageView(org.thoughtcrime.securesms.components.emoji.EmojiImageView)

Example 7 with EmojiImageView

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();
    }
}
Also used : ViewCompat(androidx.core.view.ViewCompat) Context(android.content.Context) Bundle(android.os.Bundle) MessageId(org.thoughtcrime.securesms.database.model.MessageId) ViewModelProvider(androidx.lifecycle.ViewModelProvider) TabLayout(com.google.android.material.tabs.TabLayout) LayoutInflater(android.view.LayoutInflater) NonNull(androidx.annotation.NonNull) LifecycleDisposable(org.thoughtcrime.securesms.util.LifecycleDisposable) FrameLayout(android.widget.FrameLayout) ViewPager2(androidx.viewpager2.widget.ViewPager2) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) EmojiImageView(org.thoughtcrime.securesms.components.emoji.EmojiImageView) R(org.thoughtcrime.securesms.R) ViewGroup(android.view.ViewGroup) Objects(java.util.Objects) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) ThemeUtil(org.thoughtcrime.securesms.util.ThemeUtil) BottomSheetDialogFragment(com.google.android.material.bottomsheet.BottomSheetDialogFragment) View(android.view.View) TabLayoutMediator(com.google.android.material.tabs.TabLayoutMediator) DialogInterface(android.content.DialogInterface) DialogFragment(androidx.fragment.app.DialogFragment) TabLayout(com.google.android.material.tabs.TabLayout) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) LayoutInflater(android.view.LayoutInflater) TabLayoutMediator(com.google.android.material.tabs.TabLayoutMediator) TextView(android.widget.TextView) EmojiImageView(org.thoughtcrime.securesms.components.emoji.EmojiImageView) TextView(android.widget.TextView) View(android.view.View) EmojiImageView(org.thoughtcrime.securesms.components.emoji.EmojiImageView)

Example 8 with EmojiImageView

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)));
        }
    }
}
Also used : ConstraintSet(androidx.constraintlayout.widget.ConstraintSet) EmojiImageView(org.thoughtcrime.securesms.components.emoji.EmojiImageView)

Aggregations

EmojiImageView (org.thoughtcrime.securesms.components.emoji.EmojiImageView)8 Bundle (android.os.Bundle)4 View (android.view.View)4 TextView (android.widget.TextView)4 Context (android.content.Context)2 DialogInterface (android.content.DialogInterface)2 LayoutInflater (android.view.LayoutInflater)2 ViewGroup (android.view.ViewGroup)2 FrameLayout (android.widget.FrameLayout)2 NonNull (androidx.annotation.NonNull)2 Nullable (androidx.annotation.Nullable)2 ConstraintSet (androidx.constraintlayout.widget.ConstraintSet)2 ViewCompat (androidx.core.view.ViewCompat)2 DialogFragment (androidx.fragment.app.DialogFragment)2 ViewModelProvider (androidx.lifecycle.ViewModelProvider)2 ViewPager2 (androidx.viewpager2.widget.ViewPager2)2 BottomSheetDialogFragment (com.google.android.material.bottomsheet.BottomSheetDialogFragment)2 TabLayout (com.google.android.material.tabs.TabLayout)2 TabLayoutMediator (com.google.android.material.tabs.TabLayoutMediator)2 Objects (java.util.Objects)2