Search in sources :

Example 1 with MediaKeyboardMode

use of org.thoughtcrime.securesms.util.TextSecurePreferences.MediaKeyboardMode 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)

Aggregations

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