Search in sources :

Example 6 with StructIGSticker

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);
    }
}
Also used : ThumbnailUtils(android.media.ThumbnailUtils) Bundle(android.os.Bundle) HelperNotification(net.iGap.helper.HelperNotification) StructBottomSheetForward(net.iGap.module.structs.StructBottomSheetForward) ProgressBar(android.widget.ProgressBar) NonNull(androidx.annotation.NonNull) FileLog(net.iGap.helper.FileLog) UploadObject(net.iGap.module.upload.UploadObject) IMAGE_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.IMAGE_VALUE) ToolbarItem(net.iGap.messenger.ui.toolBar.ToolbarItem) AppCompatCheckBox(androidx.appcompat.widget.AppCompatCheckBox) NewChatItemHolder(net.iGap.adapter.items.chat.NewChatItemHolder) GroupChatRole(net.iGap.module.enums.GroupChatRole) HelperSetAction(net.iGap.helper.HelperSetAction) OnBotClick(net.iGap.observers.interfaces.OnBotClick) Handler(android.os.Handler) MediaStore(android.provider.MediaStore) Map(java.util.Map) OnChatSendMessageResponse(net.iGap.observers.interfaces.OnChatSendMessageResponse) ClipboardManager(android.content.ClipboardManager) CallActivity(net.iGap.activities.CallActivity) HelperError(net.iGap.helper.HelperError) DOWN(net.iGap.proto.ProtoClientGetRoomHistory.ClientGetRoomHistory.Direction.DOWN) GIF_TEXT(net.iGap.proto.ProtoGlobal.RoomMessageType.GIF_TEXT) RequestClientSubscribeToRoom(net.iGap.request.RequestClientSubscribeToRoom) ContextCompat(androidx.core.content.ContextCompat) HelperFragment(net.iGap.helper.HelperFragment) Log(android.util.Log) R.id.ac_ll_parent(net.iGap.R.id.ac_ll_parent) Realm(io.realm.Realm) HelperCalander(net.iGap.helper.HelperCalander) NumberTextView(net.iGap.messenger.ui.toolBar.NumberTextView) RealmObjectChangeListener(io.realm.RealmObjectChangeListener) RealmRoom(net.iGap.realm.RealmRoom) CHAT(net.iGap.proto.ProtoGlobal.Room.Type.CHAT) VIDEO(net.iGap.proto.ProtoGlobal.RoomMessageType.VIDEO) CHANNEL(net.iGap.proto.ProtoGlobal.Room.Type.CHANNEL) SoundPool(android.media.SoundPool) CountDownLatch(java.util.concurrent.CountDownLatch) RequestChatUpdateDraft(net.iGap.request.RequestChatUpdateDraft) OnHelperSetAction(net.iGap.observers.interfaces.OnHelperSetAction) AttachFile.getFilePathFromUri(net.iGap.module.AttachFile.getFilePathFromUri) CLIPBOARD_SERVICE(android.content.Context.CLIPBOARD_SERVICE) RequestChatGetRoom(net.iGap.request.RequestChatGetRoom) RealmCallConfig(net.iGap.realm.RealmCallConfig) SuggestedStickerAdapter(net.iGap.fragments.emoji.SuggestedStickerAdapter) ActivityMain(net.iGap.activities.ActivityMain) BottomSheetBehavior(com.google.android.material.bottomsheet.BottomSheetBehavior) HelperUrl(net.iGap.helper.HelperUrl) AccountManager(net.iGap.module.accountManager.AccountManager) ChatAttachmentPopup(net.iGap.module.dialog.ChatAttachmentPopup) RealmContacts(net.iGap.realm.RealmContacts) ParamWithInitBitmap(net.iGap.helper.avatar.ParamWithInitBitmap) Calendar(java.util.Calendar) WebSettings(android.webkit.WebSettings) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) Toast(android.widget.Toast) ImageLoadingServiceInjector(net.iGap.module.imageLoaderService.ImageLoadingServiceInjector) IMAGE_TEXT(net.iGap.proto.ProtoGlobal.RoomMessageType.IMAGE_TEXT) AudioItem(net.iGap.adapter.items.chat.AudioItem) RealmRoomAccess(net.iGap.realm.RealmRoomAccess) MessageObject(net.iGap.structs.MessageObject) VideoWithTextItem(net.iGap.adapter.items.chat.VideoWithTextItem) G.twoPaneMode(net.iGap.G.twoPaneMode) AppCompatDelegate(androidx.appcompat.app.AppCompatDelegate) AttachFile.request_code_VIDEO_CAPTURED(net.iGap.module.AttachFile.request_code_VIDEO_CAPTURED) IOException(java.io.IOException) FragmentMediaContainer(net.iGap.messenger.ui.components.FragmentMediaContainer) IResendMessage(net.iGap.observers.interfaces.IResendMessage) EventEditText(net.iGap.module.customView.EventEditText) SharedPreferences(android.content.SharedPreferences) AUDIO_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.AUDIO_VALUE) HelperMimeType(net.iGap.helper.HelperMimeType) RoomObject(net.iGap.helper.RoomObject) NotifyFrameLayout(net.iGap.libs.emojiKeyboard.NotifyFrameLayout) EditText(android.widget.EditText) FileListerDialog(net.iGap.module.FileListerDialog.FileListerDialog) RequestUserContactsBlock(net.iGap.request.RequestUserContactsBlock) ISendPosition(net.iGap.observers.interfaces.ISendPosition) BottomSheetDialog(com.google.android.material.bottomsheet.BottomSheetDialog) JsonObject(com.google.gson.JsonObject) LinearLayout(android.widget.LinearLayout) RequestClientUnsubscribeFromRoom(net.iGap.request.RequestClientUnsubscribeFromRoom) AppUtils(net.iGap.module.AppUtils) PackageManager(android.content.pm.PackageManager) WindowManager(android.view.WindowManager) StickerDialogFragment(net.iGap.fragments.emoji.add.StickerDialogFragment) Animator(android.animation.Animator) Theme(net.iGap.module.Theme) GIF_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.GIF_VALUE) G(net.iGap.G) StatusTextFragment(net.iGap.story.StatusTextFragment) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) RequestClientGetRoomHistory(net.iGap.request.RequestClientGetRoomHistory) IntentRequests(net.iGap.module.IntentRequests) RealmUserInfo(net.iGap.realm.RealmUserInfo) ACTION_STATE_SWIPE(androidx.recyclerview.widget.ItemTouchHelper.ACTION_STATE_SWIPE) ContentResolver(android.content.ContentResolver) UnreadMessage(net.iGap.adapter.items.chat.UnreadMessage) HelperPermission(net.iGap.helper.HelperPermission) IMessageItem(net.iGap.observers.interfaces.IMessageItem) Gson(com.google.gson.Gson) KeyboardView(net.iGap.libs.emojiKeyboard.KeyboardView) RecyclerView(androidx.recyclerview.widget.RecyclerView) RealmString(net.iGap.realm.RealmString) HelperImageBackColor(net.iGap.helper.HelperImageBackColor) VIDEO_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.VIDEO_VALUE) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) UP(net.iGap.proto.ProtoClientGetRoomHistory.ClientGetRoomHistory.Direction.UP) ProgressWaiting(net.iGap.adapter.items.chat.ProgressWaiting) VIDEO_TEXT(net.iGap.proto.ProtoGlobal.RoomMessageType.VIDEO_TEXT) MessageController(net.iGap.controllers.MessageController) Status(net.iGap.module.downloader.Status) ProtoChannelGetMessagesStats(net.iGap.proto.ProtoChannelGetMessagesStats) ItemBottomSheetForward(net.iGap.adapter.items.ItemBottomSheetForward) DisplayMetrics(android.util.DisplayMetrics) GIF_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.GIF_TEXT_VALUE) STORY_REPLY_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.STORY_REPLY_VALUE) OnClientGetRoomMessage(net.iGap.observers.interfaces.OnClientGetRoomMessage) Disposable(io.reactivex.disposables.Disposable) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) MusicPlayer(net.iGap.module.MusicPlayer) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) StickerRepository(net.iGap.repository.StickerRepository) ActivityTrimVideo(net.iGap.activities.ActivityTrimVideo) LocationManager(android.location.LocationManager) EditorInfo(android.view.inputmethod.EditorInfo) IOnBackPressed(net.iGap.observers.interfaces.IOnBackPressed) RealmRoomMessageLocation(net.iGap.realm.RealmRoomMessageLocation) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) ActivityManager(android.app.ActivityManager) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) CallManager(net.iGap.viewmodel.controllers.CallManager) HelperGetMessageState(net.iGap.helper.HelperGetMessageState) OnVoiceRecord(net.iGap.observers.interfaces.OnVoiceRecord) RealmList(io.realm.RealmList) RequestClientGetFavoriteMenu(net.iGap.request.RequestClientGetFavoriteMenu) RealmRoomMessage.makeUnreadMessage(net.iGap.realm.RealmRoomMessage.makeUnreadMessage) TimeUtils(net.iGap.module.TimeUtils) AudioManager(android.media.AudioManager) InputMethodManager(android.view.inputmethod.InputMethodManager) FragmentActivity(androidx.fragment.app.FragmentActivity) AnimationUtils(android.view.animation.AnimationUtils) HelperCalander.convertToUnicodeFarsiNumber(net.iGap.helper.HelperCalander.convertToUnicodeFarsiNumber) RequestUserContactsUnblock(net.iGap.request.RequestUserContactsUnblock) MODE_PRIVATE(android.content.Context.MODE_PRIVATE) Build(android.os.Build) RequestUserInfo(net.iGap.request.RequestUserInfo) EmojiView(net.iGap.libs.emojiKeyboard.EmojiView) RequestChannelUpdateDraft(net.iGap.request.RequestChannelUpdateDraft) RealmAdditional(net.iGap.realm.RealmAdditional) JsonSyntaxException(com.google.gson.JsonSyntaxException) LayoutInflater(android.view.LayoutInflater) BadgeView(net.iGap.adapter.items.chat.BadgeView) RealmResults(io.realm.RealmResults) DialogAction(com.afollestad.materialdialogs.DialogAction) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) IDispatchTochEvent(net.iGap.observers.interfaces.IDispatchTochEvent) Color(android.graphics.Color) CountDownTimer(android.os.CountDownTimer) FileItem(net.iGap.adapter.items.chat.FileItem) StructMessageOption(net.iGap.module.structs.StructMessageOption) Bitmap(android.graphics.Bitmap) HelperSaveFile(net.iGap.helper.HelperSaveFile) STICKER_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.STICKER_VALUE) ViewTreeObserver(android.view.ViewTreeObserver) VIDEO_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.VIDEO_TEXT_VALUE) VOICE_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.VOICE_VALUE) R(net.iGap.R) OnConnectionChangeStateChat(net.iGap.observers.interfaces.OnConnectionChangeStateChat) ProtoClientGetRoomHistory(net.iGap.proto.ProtoClientGetRoomHistory) StickerItem(net.iGap.adapter.items.chat.StickerItem) SHOW(net.iGap.module.enums.ProgressState.SHOW) Vibrator(android.os.Vibrator) Activity(android.app.Activity) FastItemAdapter(com.mikepenz.fastadapter.commons.adapters.FastItemAdapter) Arrays(java.util.Arrays) MyLinearLayoutManager(net.iGap.module.MyLinearLayoutManager) RequestClientJoinByUsername(net.iGap.request.RequestClientJoinByUsername) VoiceRecord(net.iGap.module.VoiceRecord) ProtoFileDownload(net.iGap.proto.ProtoFileDownload) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) LastSeenTimeUtil(net.iGap.module.LastSeenTimeUtil) Drawable(android.graphics.drawable.Drawable) Manifest(android.Manifest) ProtoClientRoomReport(net.iGap.proto.ProtoClientRoomReport) AdditionalType(net.iGap.module.additionalData.AdditionalType) HelperPermission.showDeniedPermissionMessage(net.iGap.helper.HelperPermission.showDeniedPermissionMessage) Looper(android.os.Looper) DialogAnimation(net.iGap.module.DialogAnimation) Fragment(androidx.fragment.app.Fragment) OnSetAction(net.iGap.observers.interfaces.OnSetAction) Canvas(android.graphics.Canvas) ProgressState(net.iGap.module.enums.ProgressState) RealmConstants(net.iGap.realm.RealmConstants) CardView(androidx.cardview.widget.CardView) OnDeleteChatFinishActivity(net.iGap.observers.interfaces.OnDeleteChatFinishActivity) HelperTracker(net.iGap.helper.HelperTracker) RequestGroupUpdateDraft(net.iGap.request.RequestGroupUpdateDraft) OnLastSeenUpdateTiming(net.iGap.observers.interfaces.OnLastSeenUpdateTiming) OnComplete(net.iGap.observers.interfaces.OnComplete) RealmRoomDraft(net.iGap.realm.RealmRoomDraft) WALLET_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.WALLET_VALUE) Set(java.util.Set) ChatSendMessageUtil(net.iGap.module.ChatSendMessageUtil) ChatMoreItem(net.iGap.model.ChatMoreItem) BotInit(net.iGap.module.BotInit) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) RealmGroupRoom(net.iGap.realm.RealmGroupRoom) Uploader(net.iGap.module.upload.Uploader) StringRes(androidx.annotation.StringRes) JsonArray(com.google.gson.JsonArray) FontIconTextView(net.iGap.module.FontIconTextView) Nullable(androidx.annotation.Nullable) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) HIDE(net.iGap.module.enums.ProgressState.HIDE) Tuple(net.iGap.libs.Tuple) OnGroupAvatarResponse(net.iGap.observers.interfaces.OnGroupAvatarResponse) SHP_SETTING(net.iGap.module.SHP_SETTING) Sort(io.realm.Sort) MyWebViewClient(net.iGap.libs.MyWebViewClient) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) VoiceItem(net.iGap.adapter.items.chat.VoiceItem) InputFilter(android.text.InputFilter) EventManager(net.iGap.observers.eventbus.EventManager) DownloadObject(net.iGap.module.downloader.DownloadObject) TextWatcher(android.text.TextWatcher) OnMessageReceive(net.iGap.observers.interfaces.OnMessageReceive) EmojiManager(net.iGap.libs.emojiKeyboard.emoji.EmojiManager) Config(net.iGap.Config) AttachmentObject(net.iGap.structs.AttachmentObject) StoryViewFragment(net.iGap.story.viewPager.StoryViewFragment) AttachFile.request_code_pic_audi(net.iGap.module.AttachFile.request_code_pic_audi) ImageSpan(android.text.style.ImageSpan) Environment(android.os.Environment) RequestClientGetRoomMessage(net.iGap.request.RequestClientGetRoomMessage) OnChatMessageRemove(net.iGap.observers.interfaces.OnChatMessageRemove) Editable(android.text.Editable) LOCATION_SERVICE(android.content.Context.LOCATION_SERVICE) ArrayList(java.util.ArrayList) VibrationEffect(android.os.VibrationEffect) LOCATION_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.LOCATION_VALUE) RealmChannelExtra(net.iGap.realm.RealmChannelExtra) ConnectionState(net.iGap.module.enums.ConnectionState) HelperGetAction(net.iGap.helper.HelperGetAction) LayoutCreator(net.iGap.helper.LayoutCreator) IMAGE_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.IMAGE_TEXT_VALUE) WebChromeClient(android.webkit.WebChromeClient) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar) LogWallet(net.iGap.adapter.items.chat.LogWallet) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) RESULT_CANCELED(android.app.Activity.RESULT_CANCELED) StructWebView(net.iGap.module.structs.StructWebView) StickerSettingFragment(net.iGap.fragments.emoji.remove.StickerSettingFragment) AnimatedStickerItem(net.iGap.adapter.items.chat.AnimatedStickerItem) OnChatEditMessageResponse(net.iGap.observers.interfaces.OnChatEditMessageResponse) File(java.io.File) IItemAdapter(com.mikepenz.fastadapter.IItemAdapter) Gravity(android.view.Gravity) StructIGSticker(net.iGap.fragments.emoji.struct.StructIGSticker) Configuration(android.content.res.Configuration) LocationListener(net.iGap.observers.interfaces.LocationListener) LocationItem(net.iGap.adapter.items.chat.LocationItem) DbManager(net.iGap.module.accountManager.DbManager) CardToCardItem(net.iGap.adapter.items.chat.CardToCardItem) ValueAnimator(android.animation.ValueAnimator) FILE_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.FILE_TEXT_VALUE) ImageHelper(net.iGap.helper.ImageHelper) AttachFile.request_code_pic_file(net.iGap.module.AttachFile.request_code_pic_file) IMAGE(net.iGap.proto.ProtoGlobal.RoomMessageType.IMAGE) RealmRoomMessage.makeSeenAllMessageOfRoom(net.iGap.realm.RealmRoomMessage.makeSeenAllMessageOfRoom) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) ResendMessage(net.iGap.module.ResendMessage) AttachFile(net.iGap.module.AttachFile) LOG_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.LOG_VALUE) LogWalletCardToCard(net.iGap.adapter.items.chat.LogWalletCardToCard) OnGetFavoriteMenu(net.iGap.observers.interfaces.OnGetFavoriteMenu) RealmChannelRoom(net.iGap.realm.RealmChannelRoom) AUDIO_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.AUDIO_TEXT_VALUE) ContactItem(net.iGap.adapter.items.chat.ContactItem) LISTENED_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageStatus.LISTENED_VALUE) BottomSheetFragment(net.iGap.module.dialog.bottomsheet.BottomSheetFragment) View(android.view.View) Animation(android.view.animation.Animation) WebView(android.webkit.WebView) OnChatMessageSelectionChanged(net.iGap.observers.interfaces.OnChatMessageSelectionChanged) RealmRoomMessageContact(net.iGap.realm.RealmRoomMessageContact) StoryPagerFragment(net.iGap.story.StoryPagerFragment) ContactUtils(net.iGap.module.ContactUtils) ParentChatMoneyTransferFragment(net.iGap.fragments.chatMoneyTransfer.ParentChatMoneyTransferFragment) MessagesAdapter(net.iGap.adapter.MessagesAdapter) FILE_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.FILE_VALUE) AdapterDrBot(net.iGap.adapter.AdapterDrBot) OnUpdateUserOrRoomInfo(net.iGap.observers.interfaces.OnUpdateUserOrRoomInfo) RequestClientRoomReport(net.iGap.request.RequestClientRoomReport) HelperGetDataFromOtherApp(net.iGap.helper.HelperGetDataFromOtherApp) ObjectAnimator(android.animation.ObjectAnimator) PassCode(net.iGap.model.PassCode) StructMessageInfo(net.iGap.module.structs.StructMessageInfo) InputType(android.text.InputType) StructIGStickerGroup(net.iGap.fragments.emoji.struct.StructIGStickerGroup) ViewStubCompat(androidx.appcompat.widget.ViewStubCompat) Additional(net.iGap.module.enums.Additional) TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.TEXT_VALUE) LogWalletTopup(net.iGap.adapter.items.chat.LogWalletTopup) ViewGroup(android.view.ViewGroup) OnForwardBottomSheet(net.iGap.observers.interfaces.OnForwardBottomSheet) OnUserUpdateStatus(net.iGap.observers.interfaces.OnUserUpdateStatus) HelperLog(net.iGap.helper.HelperLog) OnChatSendMessage(net.iGap.observers.interfaces.OnChatSendMessage) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) TextView(android.widget.TextView) FragmentSettingAddStickers(net.iGap.fragments.emoji.add.FragmentSettingAddStickers) CONTACT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.CONTACT_VALUE) RequestQueue(net.iGap.request.RequestQueue) RelativeLayout(android.widget.RelativeLayout) TextItem(net.iGap.adapter.items.chat.TextItem) IUpdateLogItem(net.iGap.observers.interfaces.IUpdateLogItem) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) NotNull(org.jetbrains.annotations.NotNull) OpenBottomSheetItem(net.iGap.observers.interfaces.OpenBottomSheetItem) Context(android.content.Context) AndroidUtils(net.iGap.module.AndroidUtils) SEEN_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageStatus.SEEN_VALUE) KeyEvent(android.view.KeyEvent) ResourcesCompat(androidx.core.content.res.ResourcesCompat) GifWithTextItem(net.iGap.adapter.items.chat.GifWithTextItem) RequestSignalingGetConfiguration(net.iGap.request.RequestSignalingGetConfiguration) OnChatDelete(net.iGap.observers.interfaces.OnChatDelete) Intent(android.content.Intent) HashMap(java.util.HashMap) RealmStickerItem(net.iGap.realm.RealmStickerItem) SUID(net.iGap.module.SUID) ClipData(android.content.ClipData) OnUserInfoResponse(net.iGap.observers.interfaces.OnUserInfoResponse) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) AnimatorSet(android.animation.AnimatorSet) TimeItem(net.iGap.adapter.items.chat.TimeItem) RealmRoomMessage(net.iGap.realm.RealmRoomMessage) Cursor(android.database.Cursor) LogWalletBill(net.iGap.adapter.items.chat.LogWalletBill) ACTIVITY_SERVICE(android.content.Context.ACTIVITY_SERVICE) CONTACT(net.iGap.proto.ProtoGlobal.RoomMessageType.CONTACT) ToolbarItems(net.iGap.messenger.ui.toolBar.ToolbarItems) FileWriter(java.io.FileWriter) ProtoResponse(net.iGap.proto.ProtoResponse) MessageLoader(net.iGap.module.MessageLoader) LogItem(net.iGap.adapter.items.chat.LogItem) HelperString(net.iGap.helper.HelperString) ViewMaker(net.iGap.adapter.items.chat.ViewMaker) StructBottomSheet(net.iGap.module.structs.StructBottomSheet) OnFileSelectedListener(net.iGap.module.FileListerDialog.OnFileSelectedListener) ProtoGlobal(net.iGap.proto.ProtoGlobal) ImageWithTextItem(net.iGap.adapter.items.chat.ImageWithTextItem) ChannelChatRole(net.iGap.module.enums.ChannelChatRole) GROUP(net.iGap.proto.ProtoGlobal.Room.Type.GROUP) Collections(java.util.Collections) MimeTypeMap(android.webkit.MimeTypeMap) AbstractMessage(net.iGap.adapter.items.chat.AbstractMessage) RealmAttachment(net.iGap.realm.RealmAttachment) RealmQuery(io.realm.RealmQuery) NotifyFrameLayout(net.iGap.libs.emojiKeyboard.NotifyFrameLayout) FrameLayout(android.widget.FrameLayout) RecyclerView(androidx.recyclerview.widget.RecyclerView) SuggestedStickerAdapter(net.iGap.fragments.emoji.SuggestedStickerAdapter) MyLinearLayoutManager(net.iGap.module.MyLinearLayoutManager) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) CompositeDisposable(io.reactivex.disposables.CompositeDisposable)

Example 7 with StructIGSticker

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");
                }
            }
        }
    }
}
Also used : InputFilter(android.text.InputFilter) StructIGSticker(net.iGap.fragments.emoji.struct.StructIGSticker) Bundle(android.os.Bundle) ParentChatMoneyTransferFragment(net.iGap.fragments.chatMoneyTransfer.ParentChatMoneyTransferFragment) RealmRoom(net.iGap.realm.RealmRoom) RealmString(net.iGap.realm.RealmString) HelperString(net.iGap.helper.HelperString)

Example 8 with StructIGSticker

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);
    }
}
Also used : KeyEvent(android.view.KeyEvent) RealmObjectChangeListener(io.realm.RealmObjectChangeListener) LocationListener(net.iGap.observers.interfaces.LocationListener) OnFileSelectedListener(net.iGap.module.FileListerDialog.OnFileSelectedListener) StructIGSticker(net.iGap.fragments.emoji.struct.StructIGSticker) StickerSettingFragment(net.iGap.fragments.emoji.remove.StickerSettingFragment) RealmString(net.iGap.realm.RealmString) HelperString(net.iGap.helper.HelperString) KeyboardView(net.iGap.libs.emojiKeyboard.KeyboardView) HelperFragment(net.iGap.helper.HelperFragment) SuppressLint(android.annotation.SuppressLint) IOException(java.io.IOException) JsonSyntaxException(com.google.gson.JsonSyntaxException)

Example 9 with StructIGSticker

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));
}
Also used : KeyEvent(android.view.KeyEvent) StructIGSticker(net.iGap.fragments.emoji.struct.StructIGSticker) EmojiView(net.iGap.libs.emojiKeyboard.EmojiView)

Example 10 with StructIGSticker

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);
        }
    }
}
Also used : STICKER(net.iGap.proto.ProtoGlobal.RoomMessageType.STICKER) MessageObject(net.iGap.structs.MessageObject) FileLog(net.iGap.helper.FileLog) AccountManager(net.iGap.module.accountManager.AccountManager) Story(net.iGap.story.viewPager.Story) RealmRoom(net.iGap.realm.RealmRoom) RequestChannelSendMessage(net.iGap.request.RequestChannelSendMessage) BaseController(net.iGap.controllers.BaseController) RequestManager(net.iGap.network.RequestManager) G(net.iGap.G) RequestChatSendMessage(net.iGap.request.RequestChatSendMessage) StructIGSticker(net.iGap.fragments.emoji.struct.StructIGSticker) AdditionalType(net.iGap.module.additionalData.AdditionalType) AdditionalObject(net.iGap.structs.AdditionalObject) Gson(com.google.gson.Gson) OnChatSendMessageResponse(net.iGap.observers.interfaces.OnChatSendMessageResponse) ProtoGlobal(net.iGap.proto.ProtoGlobal) RealmRoomMessage(net.iGap.realm.RealmRoomMessage) StickerRepository(net.iGap.repository.StickerRepository) EventManager(net.iGap.observers.eventbus.EventManager) DbManager(net.iGap.module.accountManager.DbManager) RequestGroupSendMessage(net.iGap.request.RequestGroupSendMessage) StructIGSticker(net.iGap.fragments.emoji.struct.StructIGSticker) Gson(com.google.gson.Gson) RealmRoom(net.iGap.realm.RealmRoom)

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