Search in sources :

Example 1 with StickerSearchRepository

use of org.thoughtcrime.securesms.stickers.StickerSearchRepository in project Signal-Android by WhisperSystems.

the class ConversationParentFragment method initializeStickerObserver.

private void initializeStickerObserver() {
    StickerSearchRepository repository = new StickerSearchRepository(requireContext());
    stickerViewModel = new ViewModelProvider(this, new ConversationStickerViewModel.Factory(requireActivity().getApplication(), repository)).get(ConversationStickerViewModel.class);
    stickerViewModel.getStickerResults().observe(getViewLifecycleOwner(), stickers -> {
        if (stickers == null)
            return;
        inputPanel.setStickerSuggestions(stickers);
    });
    stickerViewModel.getStickersAvailability().observe(getViewLifecycleOwner(), stickersAvailable -> {
        if (stickersAvailable == null)
            return;
        boolean isSystemEmojiPreferred = SignalStore.settings().isPreferSystemEmoji();
        MediaKeyboardMode keyboardMode = TextSecurePreferences.getMediaKeyboardMode(requireContext());
        boolean stickerIntro = !TextSecurePreferences.hasSeenStickerIntroTooltip(requireContext());
        if (stickersAvailable) {
            inputPanel.showMediaKeyboardToggle(true);
            switch(keyboardMode) {
                case EMOJI:
                    inputPanel.setMediaKeyboardToggleMode(isSystemEmojiPreferred ? KeyboardPage.STICKER : KeyboardPage.EMOJI);
                    break;
                case STICKER:
                    inputPanel.setMediaKeyboardToggleMode(KeyboardPage.STICKER);
                    break;
                case GIF:
                    inputPanel.setMediaKeyboardToggleMode(KeyboardPage.GIF);
                    break;
            }
            if (stickerIntro)
                showStickerIntroductionTooltip();
        }
        if (emojiDrawerStub.resolved()) {
            initializeMediaKeyboardProviders();
        }
    });
}
Also used : StickerSearchRepository(org.thoughtcrime.securesms.stickers.StickerSearchRepository) MediaKeyboardMode(org.thoughtcrime.securesms.util.TextSecurePreferences.MediaKeyboardMode) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Example 2 with StickerSearchRepository

use of org.thoughtcrime.securesms.stickers.StickerSearchRepository in project Signal-Android by signalapp.

the class ConversationParentFragment method initializeStickerObserver.

private void initializeStickerObserver() {
    StickerSearchRepository repository = new StickerSearchRepository(requireContext());
    stickerViewModel = new ViewModelProvider(this, new ConversationStickerViewModel.Factory(requireActivity().getApplication(), repository)).get(ConversationStickerViewModel.class);
    stickerViewModel.getStickerResults().observe(getViewLifecycleOwner(), stickers -> {
        if (stickers == null)
            return;
        inputPanel.setStickerSuggestions(stickers);
    });
    stickerViewModel.getStickersAvailability().observe(getViewLifecycleOwner(), stickersAvailable -> {
        if (stickersAvailable == null)
            return;
        boolean isSystemEmojiPreferred = SignalStore.settings().isPreferSystemEmoji();
        MediaKeyboardMode keyboardMode = TextSecurePreferences.getMediaKeyboardMode(requireContext());
        boolean stickerIntro = !TextSecurePreferences.hasSeenStickerIntroTooltip(requireContext());
        if (stickersAvailable) {
            inputPanel.showMediaKeyboardToggle(true);
            switch(keyboardMode) {
                case EMOJI:
                    inputPanel.setMediaKeyboardToggleMode(isSystemEmojiPreferred ? KeyboardPage.STICKER : KeyboardPage.EMOJI);
                    break;
                case STICKER:
                    inputPanel.setMediaKeyboardToggleMode(KeyboardPage.STICKER);
                    break;
                case GIF:
                    inputPanel.setMediaKeyboardToggleMode(KeyboardPage.GIF);
                    break;
            }
            if (stickerIntro)
                showStickerIntroductionTooltip();
        }
        if (emojiDrawerStub.resolved()) {
            initializeMediaKeyboardProviders();
        }
    });
}
Also used : StickerSearchRepository(org.thoughtcrime.securesms.stickers.StickerSearchRepository) MediaKeyboardMode(org.thoughtcrime.securesms.util.TextSecurePreferences.MediaKeyboardMode) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Aggregations

ViewModelProvider (androidx.lifecycle.ViewModelProvider)2 StickerSearchRepository (org.thoughtcrime.securesms.stickers.StickerSearchRepository)2 MediaKeyboardMode (org.thoughtcrime.securesms.util.TextSecurePreferences.MediaKeyboardMode)2