use of net.iGap.fragments.emoji.struct.StructIGSticker in project iGap-Android by KianIranian-STDG.
the class FragmentChat 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();
edtChat.setText("");
sendStickerAsMessage(structIGSticker);
});
suggestedLayout.addView(suggestedRecyclerView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER));
rootView.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), rootView.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 FragmentChat method showSelectItem.
private void showSelectItem() {
RealmRoom realmRoom = getRoom();
if (realmRoom != null) {
chatType = realmRoom.getType();
if (chatType == CHAT) {
chatPeerId = realmRoom.getChatRoom().getPeerId();
if (mToolbar.getTitleTextView().getText() != null) {
if (getActivity() != null) {
ParentChatMoneyTransferFragment fragment = new ParentChatMoneyTransferFragment();
Bundle bundle = new Bundle();
bundle.putString("userName", mToolbar.getTitleTextView().getText().toString());
bundle.putLong("roomId", mRoomId);
bundle.putLong("peerId", chatPeerId);
bundle.putString("phoneNumber", phoneNumber);
fragment.setArguments(bundle);
fragment.setDelegate(new ParentChatMoneyTransferFragment.Delegate() {
@Override
public void onGiftStickerGetStartPayment(StructIGSticker structIGSticker, String paymentToken) {
if (paymentToken == null) {
Toast.makeText(getContext(), getString(R.string.wallet_error_server), Toast.LENGTH_LONG).show();
return;
}
}
@Override
public void cardToCardClicked(String cardNum, String amountNum, String descriptionTv) {
sendNewMessageCardToCard(amountNum, cardNum, descriptionTv);
ll_attach_text.setVisibility(View.GONE);
edtChat.setFilters(new InputFilter[] {});
edtChat.setText("");
clearReplyView();
}
});
fragment.show(getActivity().getSupportFragmentManager(), "PaymentFragment");
}
}
}
}
}
use of net.iGap.fragments.emoji.struct.StructIGSticker in project iGap-Android by KianIranian-STDG.
the class FragmentChat 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 (edtChat.length() == 0) {
return;
}
edtChat.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 = edtChat.getSelectionEnd();
if (i < 0)
i = 0;
try {
CharSequence sequence = EmojiManager.getInstance().replaceEmoji(unicode, edtChat.getPaint().getFontMetricsInt(), LayoutCreator.dp(22), false);
if (edtChat.getText() != null)
edtChat.setText(edtChat.getText().insert(i, sequence));
int j = i + sequence.length();
edtChat.setSelection(j, j);
} catch (Exception e) {
e.printStackTrace();
}
if (EmojiManager.getInstance().isValidEmoji(unicode) && edtChat.getText().toString().equals(unicode)) {
getStickerByEmoji(unicode);
} else if (edtChat.getText() != null && !edtChat.getText().toString().equals("")) {
if (suggestedLayout != null && suggestedLayout.getVisibility() == View.VISIBLE) {
suggestedLayout.setVisibility(View.GONE);
lastChar = null;
}
}
}
}, KeyboardView.MODE_KEYBOARD, true);
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 FragmentEditImage 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 (edtChat.length() == 0) {
return;
}
edtChat.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 = edtChat.getSelectionEnd();
if (i < 0)
i = 0;
try {
CharSequence sequence = EmojiManager.getInstance().replaceEmoji(unicode, edtChat.getPaint().getFontMetricsInt(), LayoutCreator.dp(22), false);
if (edtChat.getText() != null)
edtChat.setText(edtChat.getText().insert(i, sequence));
int j = i + sequence.length();
edtChat.setSelection(j, j);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
keyboardContainer.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 ChatSendMessageUtil method onMessageUpdate.
@Override
public void onMessageUpdate(long roomId, long messageId, ProtoGlobal.RoomMessageStatus status, String identity, ProtoGlobal.RoomMessage roomMessage) {
if (onChatSendMessageResponseChat != null) {
onChatSendMessageResponseChat.onMessageUpdate(roomId, messageId, status, identity, roomMessage);
}
if (roomMessage.getMessageType() == STICKER && roomMessage.getAdditionalData() != null && roomMessage.getAdditionalType() == AdditionalType.GIFT_STICKER) {
StructIGSticker sticker = new Gson().fromJson(roomMessage.getAdditionalData(), StructIGSticker.class);
String userId = DbManager.getInstance().doRealmTask(realm -> {
RealmRoom realmRoom = realm.where(RealmRoom.class).equalTo("id", roomId).findFirst();
if (realmRoom != null && realmRoom.getChatRoom() != null) {
return String.valueOf(realmRoom.getChatRoom().getPeerId());
}
return null;
});
if (sticker != null && userId != null) {
StickerRepository.getInstance().forwardSticker(sticker.getGiftId(), userId);
}
} 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);
boolean roomIsMyCloud = DbManager.getInstance().doRealmTask(realm -> {
RealmRoom realmRoom = realm.where(RealmRoom.class).equalTo("id", roomId).findFirst();
if (realmRoom != null && realmRoom.getChatRoom() != null)
return realmRoom.getChatRoom().getPeerId() > 0 && realmRoom.getChatRoom().getPeerId() == AccountManager.getInstance().getCurrentUser().getId();
else
return false;
});
String userId = DbManager.getInstance().doRealmTask(realm -> {
RealmRoom realmRoom = realm.where(RealmRoom.class).equalTo("id", roomId).findFirst();
if (realmRoom != null && realmRoom.getChatRoom() != null) {
return String.valueOf(realmRoom.getChatRoom().getPeerId());
}
return null;
});
if (sticker != null && userId != null && !roomIsMyCloud) {
StickerRepository.getInstance().forwardSticker(sticker.getGiftId(), userId);
}
}
}
Aggregations