Search in sources :

Example 11 with StructIGSticker

use of net.iGap.fragments.emoji.struct.StructIGSticker in project iGap-Android by KianIranian-STDG.

the class ChatSendMessageUtil method onMessageReceive.

@Override
public void onMessageReceive(long roomId, String message, ProtoGlobal.RoomMessageType messageType, ProtoGlobal.RoomMessage roomMessage, ProtoGlobal.Room.Type roomType) {
    if (onChatSendMessageResponseChat != null) {
        onChatSendMessageResponseChat.onMessageReceive(roomId, message, messageType, roomMessage, roomType);
    }
    onRoomMessageReceive(roomId, roomMessage, roomType);
    if (roomMessage.getMessageType() == STICKER && roomMessage.getAdditionalData() != null && roomMessage.getAdditionalType() == AdditionalType.GIFT_STICKER) {
        StructIGSticker sticker = new Gson().fromJson(roomMessage.getAdditionalData(), StructIGSticker.class);
        G.runOnUiThread(() -> getEventManager().postEvent(EventManager.STICKER_CHANGED, sticker.getGroupId()));
    } else if (roomMessage.getForwardFrom() != null && roomMessage.getForwardFrom().getMessageType() == STICKER && roomMessage.getForwardFrom().getAdditionalData() != null && roomMessage.getForwardFrom().getAdditionalType() == AdditionalType.GIFT_STICKER) {
        StructIGSticker sticker = new Gson().fromJson(roomMessage.getForwardFrom().getAdditionalData(), StructIGSticker.class);
        G.runOnUiThread(() -> getEventManager().postEvent(EventManager.STICKER_CHANGED, sticker.getGroupId()));
    }
}
Also used : StructIGSticker(net.iGap.fragments.emoji.struct.StructIGSticker) Gson(com.google.gson.Gson)

Example 12 with StructIGSticker

use of net.iGap.fragments.emoji.struct.StructIGSticker in project iGap-Android by KianIranian-STDG.

the class StoryDisplayFragment method getStickerByEmoji.

private void getStickerByEmoji(String unicode) {
    if (lastChar == null) {
        lastChar = unicode;
        if (suggestedLayout == null && getContext() != null) {
            stickerRepository = StickerRepository.getInstance();
            suggestedAdapter = new SuggestedStickerAdapter();
            compositeDisposable = new CompositeDisposable();
            suggestedLayout = new FrameLayout(getContext());
            suggestedRecyclerView = new RecyclerView(getContext());
            suggestedRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.HORIZONTAL, false));
            suggestedRecyclerView.setAdapter(suggestedAdapter);
            suggestedRecyclerView.setClipToPadding(false);
            suggestedRecyclerView.setPadding(LayoutCreator.dp(2), LayoutCreator.dp(3), LayoutCreator.dp(8), LayoutCreator.dp(2));
            suggestedAdapter.setListener(structIGSticker -> {
                lastChar = null;
                suggestedLayout.setVisibility(View.GONE);
                suggestedAdapter.clearData();
                suggestedRecyclerView.scrollToPosition(0);
                if (disposable != null && !disposable.isDisposed())
                    disposable.dispose();
                replyEditText.setText("");
                sendStickerAsMessage(structIGSticker);
            });
            suggestedLayout.addView(suggestedRecyclerView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER));
        // rootLayout.addView(suggestedLayout, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, (G.isAppRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM, 6, 8, 6, keyboardViewVisible ? LayoutCreator.pxToDp(keyboardHeight) + 60 : 60));
        }
        suggestedRecyclerView.setBackground(Theme.getInstance().tintDrawable(getResources().getDrawable(R.drawable.shape_suggested_sticker), getContext(), R.attr.iGapEditTxtColor));
        disposable = stickerRepository.getStickerByEmoji(lastChar).filter(structIGStickers -> structIGStickers.size() > 0 && lastChar != null).subscribe(structIGStickers -> {
            suggestedAdapter.setIgStickers(structIGStickers);
            suggestedLayout.setVisibility(View.VISIBLE);
        });
        compositeDisposable.add(disposable);
    }
}
Also used : AnticipateInterpolator(android.view.animation.AnticipateInterpolator) Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) NonNull(androidx.annotation.NonNull) ProtoFileDownload(net.iGap.proto.ProtoFileDownload) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) LastSeenTimeUtil(net.iGap.module.LastSeenTimeUtil) Drawable(android.graphics.drawable.Drawable) AdditionalType(net.iGap.module.additionalData.AdditionalType) HelperFragment(net.iGap.helper.HelperFragment) HelperCalander(net.iGap.helper.HelperCalander) ScrollingMovementMethod(android.text.method.ScrollingMovementMethod) ChatSendMessageUtil(net.iGap.module.ChatSendMessageUtil) RealmRoom(net.iGap.realm.RealmRoom) BaseFragment(net.iGap.fragments.BaseFragment) Downloader(net.iGap.module.downloader.Downloader) StringRes(androidx.annotation.StringRes) FontIconTextView(net.iGap.module.FontIconTextView) Nullable(androidx.annotation.Nullable) SHP_SETTING(net.iGap.module.SHP_SETTING) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) EventManager(net.iGap.observers.eventbus.EventManager) AbstractObject(net.iGap.network.AbstractObject) DownloadObject(net.iGap.module.downloader.DownloadObject) SuggestedStickerAdapter(net.iGap.fragments.emoji.SuggestedStickerAdapter) EmojiManager(net.iGap.libs.emojiKeyboard.emoji.EmojiManager) LayerDrawable(android.graphics.drawable.LayerDrawable) AttachmentObject(net.iGap.structs.AttachmentObject) ViewMaker.setTextSize(net.iGap.adapter.items.chat.ViewMaker.setTextSize) Environment(android.os.Environment) AccountManager(net.iGap.module.accountManager.AccountManager) BitmapFactory(android.graphics.BitmapFactory) PlayerView(com.google.android.exoplayer2.ui.PlayerView) ViewUserDialogFragment(net.iGap.story.ViewUserDialogFragment) GradientDrawable(android.graphics.drawable.GradientDrawable) Toast(android.widget.Toast) LayoutCreator(net.iGap.helper.LayoutCreator) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) StickerSettingFragment(net.iGap.fragments.emoji.remove.StickerSettingFragment) MessageObject(net.iGap.structs.MessageObject) TextUtils(android.text.TextUtils) RecyclerListView(net.iGap.module.customView.RecyclerListView) File(java.io.File) Gravity(android.view.Gravity) StructIGSticker(net.iGap.fragments.emoji.struct.StructIGSticker) EventEditText(net.iGap.module.customView.EventEditText) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) NotifyFrameLayout(net.iGap.libs.emojiKeyboard.NotifyFrameLayout) DbManager(net.iGap.module.accountManager.DbManager) EditText(android.widget.EditText) Rect(android.graphics.Rect) LinearLayout(android.widget.LinearLayout) AppUtils(net.iGap.module.AppUtils) StoryCell(net.iGap.story.storyviews.StoryCell) Animator(android.animation.Animator) Theme(net.iGap.module.Theme) G(net.iGap.G) RealmUserInfo(net.iGap.realm.RealmUserInfo) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Gson(com.google.gson.Gson) ActivityInfo(android.content.pm.ActivityInfo) View(android.view.View) KeyboardView(net.iGap.libs.emojiKeyboard.KeyboardView) RecyclerView(androidx.recyclerview.widget.RecyclerView) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) Status(net.iGap.module.downloader.Status) ObjectAnimator(android.animation.ObjectAnimator) RealmStory(net.iGap.realm.RealmStory) DisplayMetrics(android.util.DisplayMetrics) ViewGroup(android.view.ViewGroup) Objects(java.util.Objects) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) TextView(android.widget.TextView) FragmentSettingAddStickers(net.iGap.fragments.emoji.add.FragmentSettingAddStickers) HttpRequest(net.iGap.module.downloader.HttpRequest) StickerRepository(net.iGap.repository.StickerRepository) Typeface(android.graphics.Typeface) Context(android.content.Context) AndroidUtils(net.iGap.module.AndroidUtils) KeyEvent(android.view.KeyEvent) ResourcesCompat(androidx.core.content.res.ResourcesCompat) TimeUtils(net.iGap.module.TimeUtils) RealmStickerItem(net.iGap.realm.RealmStickerItem) MotionEvent(android.view.MotionEvent) ExpandableTextView(net.iGap.story.ExpandableTextView) MODE_PRIVATE(android.content.Context.MODE_PRIVATE) AnimatorSet(android.animation.AnimatorSet) RealmRoomMessage(net.iGap.realm.RealmRoomMessage) EmojiView(net.iGap.libs.emojiKeyboard.EmojiView) IG_RPC(net.iGap.network.IG_RPC) ImageLoadingView(net.iGap.story.liststories.ImageLoadingView) RealmAdditional(net.iGap.realm.RealmAdditional) InsetDrawable(android.graphics.drawable.InsetDrawable) CircleImageView(net.iGap.module.CircleImageView) Color(android.graphics.Color) Glide(com.bumptech.glide.Glide) Bitmap(android.graphics.Bitmap) ProtoGlobal(net.iGap.proto.ProtoGlobal) R(net.iGap.R) RealmAttachment(net.iGap.realm.RealmAttachment) FrameLayout(android.widget.FrameLayout) NotifyFrameLayout(net.iGap.libs.emojiKeyboard.NotifyFrameLayout) RecyclerView(androidx.recyclerview.widget.RecyclerView) SuggestedStickerAdapter(net.iGap.fragments.emoji.SuggestedStickerAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) CompositeDisposable(io.reactivex.disposables.CompositeDisposable)

Example 13 with StructIGSticker

use of net.iGap.fragments.emoji.struct.StructIGSticker in project iGap-Android by KianIranian-STDG.

the class StoryDisplayFragment method createKeyboardView.

private void createKeyboardView() {
    if (getContext() != null) {
        keyboardView = new KeyboardView(getContext(), new KeyboardView.Listener() {

            @Override
            public void onViewCreated(int mode) {
            }

            @Override
            public void onStickerSettingClicked() {
                if (getActivity() != null) {
                    showPopup(-1);
                    new HelperFragment(getActivity().getSupportFragmentManager(), new StickerSettingFragment()).setReplace(false).load();
                }
            }

            @Override
            public void onBackSpace() {
                if (replyEditText.length() == 0) {
                    return;
                }
                replyEditText.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
            }

            @Override
            public void onSendStickerAsMessage(StructIGSticker structIGSticker) {
                sendStickerAsMessage(structIGSticker);
            }

            @Override
            public void onAddStickerClicked() {
                if (getActivity() != null) {
                    showPopup(-1);
                    new HelperFragment(getActivity().getSupportFragmentManager(), FragmentSettingAddStickers.newInstance("ALL")).setReplace(false).load();
                }
            }

            @Override
            public void onEmojiSelected(String unicode) {
                int i = replyEditText.getSelectionEnd();
                if (i < 0)
                    i = 0;
                try {
                    CharSequence sequence = EmojiManager.getInstance().replaceEmoji(unicode, replyEditText.getPaint().getFontMetricsInt(), LayoutCreator.dp(22), false);
                    if (replyEditText.getText() != null)
                        replyEditText.setText(replyEditText.getText().insert(i, sequence));
                    int j = i + sequence.length();
                    replyEditText.setSelection(j, j);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (EmojiManager.getInstance().isValidEmoji(unicode) && replyEditText.getText().toString().equals(unicode)) {
                    getStickerByEmoji(unicode);
                } else if (replyEditText.getText() != null && !replyEditText.getText().toString().equals("")) {
                    if (suggestedLayout != null && suggestedLayout.getVisibility() == View.VISIBLE) {
                        suggestedLayout.setVisibility(View.GONE);
                        lastChar = null;
                    }
                }
            }
        }, KeyboardView.MODE_KEYBOARD, false);
        keyboardView.setVisibility(View.GONE);
        // if (mustCheckPermission())
        // keyboardView.setStickerPermission(currentRoomAccess != null && currentRoomAccess.getRealmPostMessageRights() != null && currentRoomAccess.getRealmPostMessageRights().isCanSendSticker());
        keyboardContainer.addView(keyboardView);
    }
}
Also used : KeyEvent(android.view.KeyEvent) StructIGSticker(net.iGap.fragments.emoji.struct.StructIGSticker) StickerSettingFragment(net.iGap.fragments.emoji.remove.StickerSettingFragment) KeyboardView(net.iGap.libs.emojiKeyboard.KeyboardView) HelperFragment(net.iGap.helper.HelperFragment)

Example 14 with StructIGSticker

use of net.iGap.fragments.emoji.struct.StructIGSticker in project iGap-Android by KianIranian-STDG.

the class PhotoViewer method createEmojiView.

private void createEmojiView() {
    if (emojiView == null) {
        emojiView = new EmojiView(context, false, true);
        emojiView.setVisibility(View.GONE);
        emojiView.setContentView(EmojiView.EMOJI);
        emojiView.setListener(new EmojiView.Listener() {

            @Override
            public void onBackSpace() {
                if (captionEditText.length() == 0) {
                    return;
                }
                captionEditText.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
            }

            @Override
            public void onStickerClick(StructIGSticker structIGSticker) {
            }

            @Override
            public void onStickerSettingClick() {
            }

            @Override
            public void onAddStickerClicked() {
            }

            @Override
            public void onEmojiSelected(String unicode) {
                int i = captionEditText.getSelectionEnd();
                if (i < 0)
                    i = 0;
                try {
                    CharSequence sequence = EmojiManager.getInstance().replaceEmoji(unicode, captionEditText.getPaint().getFontMetricsInt(), LayoutCreator.dp(22), false);
                    if (captionEditText.getText() != null)
                        captionEditText.setText(captionEditText.getText().insert(i, sequence));
                    int j = i + sequence.length();
                    captionEditText.setSelection(j, j);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
    chatKeyBoardContainer.addView(emojiView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT, Gravity.BOTTOM));
}
Also used : KeyEvent(android.view.KeyEvent) StructIGSticker(net.iGap.fragments.emoji.struct.StructIGSticker) EmojiView(net.iGap.libs.emojiKeyboard.EmojiView) IOException(java.io.IOException)

Example 15 with StructIGSticker

use of net.iGap.fragments.emoji.struct.StructIGSticker in project iGap-Android by KianIranian-STDG.

the class StatusTextFragment method createEmojiView.

private void createEmojiView() {
    if (emojiView == null) {
        emojiView = new EmojiView(rootView.getContext(), false, true);
        emojiView.setVisibility(View.GONE);
        emojiView.setContentView(EmojiView.EMOJI);
        emojiView.setListener(new EmojiView.Listener() {

            @Override
            public void onBackSpace() {
                if (addTextEditTExt.length() == 0) {
                    return;
                }
                addTextEditTExt.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
            }

            @Override
            public void onStickerClick(StructIGSticker structIGSticker) {
            }

            @Override
            public void onStickerSettingClick() {
            }

            @Override
            public void onAddStickerClicked() {
            }

            @Override
            public void onEmojiSelected(String unicode) {
                int i = addTextEditTExt.getSelectionEnd();
                if (i < 0)
                    i = 0;
                try {
                    if (addTextEditTExt.getText() != null) {
                        editTextSize = 27;
                        addTextEditTExt.setTextSize(editTextSize);
                        CharSequence sequence = EmojiManager.getInstance().replaceEmoji(unicode, addTextEditTExt.getPaint().getFontMetricsInt(), LayoutCreator.dp(22), false);
                        addTextEditTExt.setText(addTextEditTExt.getText().insert(i, sequence));
                        int j = i + sequence.length();
                        addTextEditTExt.setSelection(j, j);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
    chatKeyBoardContainer.addView(emojiView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT, Gravity.BOTTOM));
}
Also used : KeyEvent(android.view.KeyEvent) StructIGSticker(net.iGap.fragments.emoji.struct.StructIGSticker) EmojiView(net.iGap.libs.emojiKeyboard.EmojiView)

Aggregations

StructIGSticker (net.iGap.fragments.emoji.struct.StructIGSticker)15 KeyEvent (android.view.KeyEvent)6 Gson (com.google.gson.Gson)6 ArrayList (java.util.ArrayList)5 G (net.iGap.G)5 DbManager (net.iGap.module.accountManager.DbManager)5 Animator (android.animation.Animator)4 EmojiView (net.iGap.libs.emojiKeyboard.EmojiView)4 RealmStickerItem (net.iGap.realm.RealmStickerItem)4 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)3 AnimatorSet (android.animation.AnimatorSet)3 ObjectAnimator (android.animation.ObjectAnimator)3 SuppressLint (android.annotation.SuppressLint)3 Context (android.content.Context)3 MODE_PRIVATE (android.content.Context.MODE_PRIVATE)3 SharedPreferences (android.content.SharedPreferences)3 RecyclerView (androidx.recyclerview.widget.RecyclerView)3 JsonObject (com.google.gson.JsonObject)3 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)3 Disposable (io.reactivex.disposables.Disposable)3