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()));
}
}
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);
}
}
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);
}
}
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));
}
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));
}
Aggregations