Search in sources :

Example 16 with Theme

use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.

the class TopSheetDialog method wrapInTopSheet.

private View wrapInTopSheet() {
    final CoordinatorLayout coordinator = (CoordinatorLayout) View.inflate(getContext(), R.layout.top_sheet_dialog, null);
    FrameLayout topSheet = coordinator.findViewById(R.id.design_top_sheet);
    TopSheetBehavior<FrameLayout> topSheetBehavior = TopSheetBehavior.from(topSheet);
    topSheetBehavior.setTopSheetCallback(mTopSheetCallback);
    RecyclerView recyclerView = topSheet.findViewById(R.id.bottomSheetList);
    recyclerView.setAdapter(new BottomSheetListAdapter(range, itemListInt, position -> {
        dismiss();
        bottomSheetItemClickCallback.onClick(position);
    }));
    // We treat the CoordinatorLayout as outside the dialog though it is technically inside
    coordinator.findViewById(R.id.top_sheet_touch_outside).setOnClickListener(view -> {
        if (isShowing()) {
            cancel();
        }
    });
    ((GradientDrawable) coordinator.findViewById(R.id.design_top_sheet).getBackground()).setColor(new Theme().getRootColor(getContext()));
    return coordinator;
}
Also used : CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) Context(android.content.Context) Bundle(android.os.Bundle) CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) BottomSheetBehavior(com.google.android.material.bottomsheet.BottomSheetBehavior) NonNull(androidx.annotation.NonNull) FrameLayout(android.widget.FrameLayout) Theme(net.iGap.module.Theme) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) StyleRes(androidx.annotation.StyleRes) List(java.util.List) Nullable(androidx.annotation.Nullable) TypedValue(android.util.TypedValue) BottomSheetListAdapter(net.iGap.module.dialog.BottomSheetListAdapter) GradientDrawable(android.graphics.drawable.GradientDrawable) View(android.view.View) R(net.iGap.R) AppCompatDialog(androidx.appcompat.app.AppCompatDialog) RecyclerView(androidx.recyclerview.widget.RecyclerView) Window(android.view.Window) BottomSheetItemClickCallback(net.iGap.module.dialog.BottomSheetItemClickCallback) DialogInterface(android.content.DialogInterface) LayoutRes(androidx.annotation.LayoutRes) BottomSheetListAdapter(net.iGap.module.dialog.BottomSheetListAdapter) FrameLayout(android.widget.FrameLayout) Theme(net.iGap.module.Theme) RecyclerView(androidx.recyclerview.widget.RecyclerView) GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 17 with Theme

use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.

the class FragmentChat method initAttachForward.

/**
 * initialize bottomSheet for use in attachment for forward
 */
private void initAttachForward(boolean isMessage) {
    canClearForwardList = true;
    multiForwardList = new ArrayList<>();
    viewBottomSheetForward = getActivity().getLayoutInflater().inflate(R.layout.bottom_sheet_forward, null);
    fastItemAdapterForward = new FastItemAdapter();
    EditText edtSearch = viewBottomSheetForward.findViewById(R.id.edtSearch);
    edtSearch.setImeOptions(EditorInfo.IME_ACTION_SEARCH | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    edtSearch.setOnEditorActionListener((v, actionId, event) -> {
        if (actionId == EditorInfo.IME_ACTION_SEARCH)
            hideKeyboard();
        return true;
    });
    edtSearch.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
    final AppCompatTextView textSend = viewBottomSheetForward.findViewById(R.id.txtSend);
    textSend.setVisibility(View.GONE);
    final RecyclerView rcvItem = viewBottomSheetForward.findViewById(R.id.rcvBottomSheetForward);
    rcvItem.setLayoutManager(new GridLayoutManager(rcvItem.getContext(), 4, GridLayoutManager.VERTICAL, false));
    rcvItem.setItemViewCacheSize(100);
    rcvItem.setAdapter(fastItemAdapterForward);
    edtSearch.setBackground(new Theme().tintDrawable(edtSearch.getBackground(), getContext(), R.attr.iGapDividerLine));
    bottomSheetDialogForward = new BottomSheetDialog(getActivity(), R.style.BaseBottomSheetDialog);
    bottomSheetDialogForward.setContentView(viewBottomSheetForward);
    final BottomSheetBehavior mBehavior = BottomSheetBehavior.from((View) viewBottomSheetForward.getParent());
    mBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
    fastItemAdapterForward.getItemFilter().withFilterPredicate((IItemAdapter.Predicate<ItemBottomSheetForward>) (item, constraint) -> item.structBottomSheetForward.getDisplayName().toLowerCase().contains(String.valueOf(constraint)));
    edtSearch.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            fastItemAdapterForward.filter(s.toString().toLowerCase());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    viewBottomSheetForward.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                mBehavior.setPeekHeight(viewBottomSheetForward.getHeight());
                viewBottomSheetForward.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
        }
    });
    // height is ready
    textSend.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            canClearForwardList = false;
            forwardToChatRoom(mListForwardNotExict, isMessage);
            prgWaiting.setVisibility(View.VISIBLE);
            viewBottomSheetForward.setEnabled(false);
        }
    });
    onForwardBottomSheet = structBottomSheetForward -> {
        if (structBottomSheetForward.isNotExistRoom()) {
            if (structBottomSheetForward.isChecked()) {
                mListForwardNotExict.add(structBottomSheetForward);
            } else {
                mListForwardNotExict.remove(structBottomSheetForward);
            }
        } else {
            if (structBottomSheetForward.isChecked()) {
                multiForwardList.add(structBottomSheetForward.getId());
            } else {
                multiForwardList.remove(structBottomSheetForward.getId());
            }
        }
        if (mListForwardNotExict.size() + multiForwardList.size() > 0) {
            textSend.setVisibility(View.VISIBLE);
        } else {
            textSend.setVisibility(View.GONE);
        }
    };
    bottomSheetDialogForward.show();
    bottomSheetDialogForward.setOnDismissListener(dialog -> {
        if (canClearForwardList) {
            removeForwardModeFromRoomList();
            mForwardMessages = null;
        }
    });
}
Also used : EventEditText(net.iGap.module.customView.EventEditText) EditText(android.widget.EditText) 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) FastItemAdapter(com.mikepenz.fastadapter.commons.adapters.FastItemAdapter) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) NumberTextView(net.iGap.messenger.ui.toolBar.NumberTextView) KeyboardView(net.iGap.libs.emojiKeyboard.KeyboardView) RecyclerView(androidx.recyclerview.widget.RecyclerView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) EmojiView(net.iGap.libs.emojiKeyboard.EmojiView) BadgeView(net.iGap.adapter.items.chat.BadgeView) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) ImageView(android.widget.ImageView) CardView(androidx.cardview.widget.CardView) FontIconTextView(net.iGap.module.FontIconTextView) StructWebView(net.iGap.module.structs.StructWebView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) BottomSheetDialog(com.google.android.material.bottomsheet.BottomSheetDialog) BottomSheetBehavior(com.google.android.material.bottomsheet.BottomSheetBehavior) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) ItemBottomSheetForward(net.iGap.adapter.items.ItemBottomSheetForward) IItemAdapter(com.mikepenz.fastadapter.IItemAdapter) Theme(net.iGap.module.Theme) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) RecyclerView(androidx.recyclerview.widget.RecyclerView) ViewTreeObserver(android.view.ViewTreeObserver)

Example 18 with Theme

use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.

the class FragmentChannelProfile method onViewCreated.

@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    if (currentRoomAccess != null) {
        checkRoomAccess(currentRoomAccess);
        roomAccessChangeListener = (realmRoomAccess, changeSet) -> checkRoomAccess(realmRoomAccess);
        currentRoomAccess.addChangeListener(roomAccessChangeListener);
    }
    imvChannelAvatar = binding.toolbarAvatar;
    imvChannelAvatar.setOnClickListener(v -> viewModel.onClickCircleImage());
    binding.toolbarBack.setOnClickListener(v -> popBackStackFragment());
    binding.toolbarMore.setOnClickListener(v -> showPopUp());
    binding.toolbarEdit.setOnClickListener(v -> {
        if (getActivity() != null && viewModel.checkIsEditableAndReturnState()) {
            new HelperFragment(getActivity().getSupportFragmentManager(), EditChannelFragment.newInstance(viewModel.roomId)).setReplace(false).load();
        }
    });
    viewModel.channelName.observe(getViewLifecycleOwner(), s -> {
        binding.toolbarTxtNameCollapsed.setText(EmojiManager.getInstance().replaceEmoji(s, binding.toolbarTxtNameCollapsed.getPaint().getFontMetricsInt()));
        binding.toolbarTxtNameExpanded.setText(EmojiManager.getInstance().replaceEmoji(s, binding.toolbarTxtNameExpanded.getPaint().getFontMetricsInt()));
    });
    viewModel.channelSecondsTitle.observe(getViewLifecycleOwner(), s -> binding.toolbarTxtStatusExpanded.setText(s));
    viewModel.menuPopupVisibility.observe(getViewLifecycleOwner(), integer -> {
        if (integer != null) {
            binding.toolbarMore.setVisibility(integer);
        }
    });
    viewModel.channelDescription.observe(getViewLifecycleOwner(), description -> {
        if (getActivity() != null && description != null) {
            binding.description.setText(HelperUrl.setUrlLink(getActivity(), description, true, false, null, true));
        }
    });
    viewModel.goBack.observe(getViewLifecycleOwner(), goBack -> {
        if (goBack != null && goBack) {
            popBackStackFragment();
        }
    });
    viewModel.muteNotifListener.observe(getViewLifecycleOwner(), isMute -> {
        getRoomController().clientMuteRoom(viewModel.roomId, isMute);
        binding.enableNotification.setChecked(isMute);
    });
    viewModel.goToRoomListPage.observe(getViewLifecycleOwner(), isGo -> {
        if (getActivity() instanceof ActivityMain && isGo != null && isGo) {
            ((ActivityMain) getActivity()).removeAllFragmentFromMain();
        /*new HelperFragment(getActivity().getSupportFragmentManager()).popBackStack(2);*/
        }
    });
    viewModel.goToShowMemberList.observe(getViewLifecycleOwner(), data -> {
        if (getActivity() != null && data != null) {
            new HelperFragment(getActivity().getSupportFragmentManager(), FragmentShowMember.newInstance2(this, data.getRoomId(), data.getRole(), data.getUserId(), data.getSelectedRole(), data.isNeedGetMemberList(), false)).setReplace(false).load();
        }
    });
    viewModel.showDialogCopyLink.observe(getViewLifecycleOwner(), link -> {
        if (getActivity() != null && link != null) {
            LinearLayout layoutChannelLink = new LinearLayout(getActivity());
            layoutChannelLink.setOrientation(LinearLayout.VERTICAL);
            View viewRevoke = new View(getActivity());
            LinearLayout.LayoutParams viewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1);
            TextInputLayout inputChannelLink = new TextInputLayout(getActivity());
            MEditText edtLink = new MEditText(getActivity());
            edtLink.setHint(R.string.channel_public_hint_revoke);
            edtLink.setTypeface(ResourcesCompat.getFont(edtLink.getContext(), R.font.main_font));
            edtLink.setText(link);
            edtLink.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.dp14));
            edtLink.setTextColor(new Theme().getTitleTextColor(getActivity()));
            edtLink.setHintTextColor(getResources().getColor(R.color.hint_edit_text));
            edtLink.setPadding(0, 8, 0, 8);
            edtLink.setEnabled(false);
            edtLink.setSingleLine(true);
            inputChannelLink.addView(edtLink);
            inputChannelLink.addView(viewRevoke, viewParams);
            TextView txtLink = new AppCompatTextView(getActivity());
            txtLink.setText(link);
            txtLink.setTextColor(new Theme().getTitleTextColor(getActivity()));
            viewRevoke.setBackgroundColor(getResources().getColor(R.color.line_edit_text));
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                edtLink.setBackground(getResources().getDrawable(android.R.color.transparent));
            }
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            layoutChannelLink.addView(inputChannelLink, layoutParams);
            layoutChannelLink.addView(txtLink, layoutParams);
            if (getActivity() != null) {
                ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
                ClipData clip = ClipData.newPlainText("LINK_GROUP", link);
                clipboard.setPrimaryClip(clip);
                Toast.makeText(getActivity(), R.string.copied, Toast.LENGTH_SHORT).show();
            }
        }
    });
    viewModel.goToSharedMediaPage.observe(getViewLifecycleOwner(), typeModel -> {
        if (getActivity() != null && typeModel != null) {
            new HelperFragment(getActivity().getSupportFragmentManager(), FragmentShearedMedia.newInstance(typeModel)).setReplace(false).load();
        }
    });
    viewModel.goToShowAvatarPage.observe(getViewLifecycleOwner(), roomId -> {
        if (getActivity() != null && roomId != null) {
            new HelperFragment(getActivity().getSupportFragmentManager(), FragmentShowAvatars.newInstance(roomId, FragmentShowAvatars.From.channel)).setReplace(false).load();
        }
    });
    viewModel.showDialogLeaveChannel.observe(getViewLifecycleOwner(), isShow -> showDialogLeaveChannel());
    viewModel.goToChatRoom.observe(getViewLifecycleOwner(), isGo -> {
        if (getActivity() != null && isGo != null && isGo) {
            ((ActivityMain) getActivity()).removeAllFragmentFromMain();
        }
    });
    viewModel.showErrorMessage.observe(getViewLifecycleOwner(), errorMessageResId -> {
        if (errorMessageResId != null) {
            HelperError.showSnackMessage(getString(errorMessageResId), false);
        }
    });
    BetterLinkMovementMethod.linkify(Linkify.ALL, binding.description).setOnLinkClickListener((tv, url) -> {
        return false;
    }).setOnLinkLongClickListener((tv, url) -> {
        if (HelperUrl.isTextLink(url)) {
            G.isLinkClicked = true;
            HelperUrl.openLinkDialog(getActivity(), url);
        }
        return true;
    });
    // binding.description.setMovementMethod(LinkMovementMethod.getInstance());
    AppUtils.setProgresColler(binding.loading);
    FragmentShowAvatars.onComplete = (result, messageOne, MessageTow) -> {
        long mAvatarId = 0;
        if (messageOne != null && !messageOne.equals("")) {
            mAvatarId = Long.parseLong(messageOne);
        }
        avatarHandler.avatarDelete(new ParamWithAvatarType(imvChannelAvatar, viewModel.roomId).avatarType(AvatarHandler.AvatarType.ROOM), mAvatarId);
    };
    setAvatar();
    initialToolbar();
}
Also used : ClipboardManager(android.content.ClipboardManager) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) AppUtils(net.iGap.module.AppUtils) NonNull(androidx.annotation.NonNull) ViewModel(androidx.lifecycle.ViewModel) Theme(net.iGap.module.Theme) G(net.iGap.G) ClipboardManager(android.content.ClipboardManager) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) HelperError(net.iGap.helper.HelperError) HelperFragment(net.iGap.helper.HelperFragment) DataBindingUtil(androidx.databinding.DataBindingUtil) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) MEditText(net.iGap.module.MEditText) RealmObjectChangeListener(io.realm.RealmObjectChangeListener) RequestChannelKickAdmin(net.iGap.request.RequestChannelKickAdmin) ViewGroup(android.view.ViewGroup) FragmentChannelProfileViewModel(net.iGap.viewmodel.FragmentChannelProfileViewModel) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) AlphaAnimation(android.view.animation.AlphaAnimation) CLIPBOARD_SERVICE(android.content.Context.CLIPBOARD_SERVICE) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) EventManager(net.iGap.observers.eventbus.EventManager) NotNull(org.jetbrains.annotations.NotNull) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) EmojiManager(net.iGap.libs.emojiKeyboard.emoji.EmojiManager) ResourcesCompat(androidx.core.content.res.ResourcesCompat) ActivityMain(net.iGap.activities.ActivityMain) HelperUrl(net.iGap.helper.HelperUrl) TextInputLayout(com.google.android.material.textfield.TextInputLayout) AccountManager(net.iGap.module.accountManager.AccountManager) Linkify(android.text.util.Linkify) ArrayList(java.util.ArrayList) ClipData(android.content.ClipData) Toast(android.widget.Toast) ActivityProfileChannelBinding(net.iGap.databinding.ActivityProfileChannelBinding) Build(android.os.Build) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) RealmRoomAccess(net.iGap.realm.RealmRoomAccess) ViewModelProvider(androidx.lifecycle.ViewModelProvider) LayoutInflater(android.view.LayoutInflater) RequestChannelKickModerator(net.iGap.request.RequestChannelKickModerator) TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) CircleImageView(net.iGap.module.CircleImageView) OnChannelAvatarDelete(net.iGap.observers.interfaces.OnChannelAvatarDelete) TypedValue(android.util.TypedValue) R(net.iGap.R) BetterLinkMovementMethod(me.saket.bettermovementmethod.BetterLinkMovementMethod) DbManager(net.iGap.module.accountManager.DbManager) RequestChannelKickMember(net.iGap.request.RequestChannelKickMember) MEditText(net.iGap.module.MEditText) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) View(android.view.View) TextView(android.widget.TextView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) CircleImageView(net.iGap.module.CircleImageView) ActivityMain(net.iGap.activities.ActivityMain) Theme(net.iGap.module.Theme) TextView(android.widget.TextView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) HelperFragment(net.iGap.helper.HelperFragment) TextInputLayout(com.google.android.material.textfield.TextInputLayout) ClipData(android.content.ClipData) LinearLayout(android.widget.LinearLayout)

Example 19 with Theme

use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.

the class FragmentChatSettings method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    if (getContext() != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        StatusBarUtil.setColor(getActivity(), new Theme().getPrimaryDarkColor(getContext()), 50);
    }
    chatSettingsToolbar = new Toolbar(getContext());
    chatSettingsToolbar.setBackIcon(new BackDrawable(false));
    chatSettingsToolbar.setTitle(getString(R.string.chat_setting));
    chatSettingsToolbar.setListener(i -> {
        switch(i) {
            case -1:
                popBackStackFragment();
                break;
        }
    });
    binding.fcsLayoutToolbar.addView(chatSettingsToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
    binding.themeColorList.setLayoutManager(new LinearLayoutManager(binding.themeColorList.getContext(), RecyclerView.HORIZONTAL, G.isAppRtl));
    binding.themeColorList.hasFixedSize();
    binding.themeColorList.setNestedScrollingEnabled(false);
    binding.themeColorList.setAdapter(adapter);
    viewModel.getChatBackground();
    setChatReceivedChatBubble(new Theme().getReceivedChatBubbleColor(getContext()));
    setChatSendBubble(new Theme().getSendChatBubbleColor(getContext()));
    if (getContext() != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        StatusBarUtil.setColor(getActivity(), new Theme().getPrimaryDarkColor(getContext()), 50);
    }
    viewModel.getGoToChatBackgroundPage().observe(getViewLifecycleOwner(), go -> {
        if (getActivity() != null && go != null && go) {
            new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentChatBackground()).setReplace(false).load();
        }
    });
    viewModel.getGoToDateFragment().observe(getViewLifecycleOwner(), go -> {
        if (getActivity() != null && go != null && go)
            new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentData()).setReplace(false).load();
    });
    viewModel.getThemeList().observe(getViewLifecycleOwner(), themeList -> {
        if (themeList != null && binding.themeColorList.getAdapter() instanceof ThemeColorListAdapter) {
            ((ThemeColorListAdapter) binding.themeColorList.getAdapter()).setData(themeList);
        }
    });
    viewModel.getSelectedThemePosition().observe(getViewLifecycleOwner(), selectedPosition -> {
        if (selectedPosition != null && binding.themeColorList.getAdapter() instanceof ThemeColorListAdapter) {
            ((ThemeColorListAdapter) binding.themeColorList.getAdapter()).setSelectedTheme(selectedPosition);
        }
    });
    viewModel.getUpdateNewTheme().observe(getViewLifecycleOwner(), isUpdate -> {
        if (getActivity() != null && isUpdate != null && isUpdate) {
            /*if (Theme.isUnderLollipop()) {
                    if (getActivity() instanceof ActivityEnhanced) {
                        ((ActivityEnhanced) getActivity()).onRefreshActivity(true, "");
                    }
                } else {*/
            Fragment frg;
            frg = getActivity().getSupportFragmentManager().findFragmentByTag(FragmentChatSettings.class.getName());
            FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
            ft.detach(frg);
            ft.attach(frg);
            ft.commit();
        /*}*/
        }
    });
    viewModel.getUpdateTwoPaneView().observe(getViewLifecycleOwner(), isUpdate -> {
        if (getActivity() != null && isUpdate != null && isUpdate) {
            Fragment frg;
            frg = getActivity().getSupportFragmentManager().findFragmentById(R.id.mainFrame);
            FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
            ft.detach(frg);
            ft.attach(frg);
            ft.commit();
        }
    });
    viewModel.getUpdateTextSizeSampleView().observe(getViewLifecycleOwner(), textSize -> {
        if (textSize != null) {
            binding.message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize);
            binding.senderMessage.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize);
        }
    });
    viewModel.getSetChatBackground().observe(getViewLifecycleOwner(), backgroundPath -> {
        if (getActivity() != null && backgroundPath != null) {
            File f = new File(backgroundPath);
            if (f.exists()) {
                try {
                    Log.wtf(this.getClass().getName(), "set image");
                    Drawable d = Drawable.createFromPath(f.getAbsolutePath());
                    binding.chatBackgroundImage.setImageDrawable(d);
                } catch (OutOfMemoryError e) {
                    ActivityManager activityManager = (ActivityManager) getActivity().getSystemService(ACTIVITY_SERVICE);
                    ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
                    activityManager.getMemoryInfo(memoryInfo);
                }
            } else {
                try {
                    binding.chatBackgroundImage.setImageResource(0);
                    binding.chatBackgroundImage.setBackgroundColor(Color.parseColor(backgroundPath));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    });
    viewModel.getSetChatBackgroundDefault().observe(getViewLifecycleOwner(), drawableRes -> {
        if (drawableRes != null) {
            binding.chatBackgroundImage.setImageResource(R.drawable.chat_default_background_pattern);
        }
    });
}
Also used : Drawable(android.graphics.drawable.Drawable) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ActivityManager(android.app.ActivityManager) Fragment(androidx.fragment.app.Fragment) HelperFragment(net.iGap.helper.HelperFragment) ThemeColorListAdapter(net.iGap.adapter.ThemeColorListAdapter) FragmentTransaction(androidx.fragment.app.FragmentTransaction) Theme(net.iGap.module.Theme) HelperFragment(net.iGap.helper.HelperFragment) File(java.io.File) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar)

Example 20 with Theme

use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.

the class FragmentChat method initComponent.

@SuppressLint("ClickableViewAccessibility")
private void initComponent() {
    final RealmRoom realmRoom = getRoom();
    ll_attach_text = rootView.findViewById(R.id.ac_ll_attach_text);
    txtFileNameForSend = rootView.findViewById(R.id.ac_txt_file_neme_for_sending);
    btnCancelSendingFile = rootView.findViewById(R.id.ac_btn_cancel_sending_file);
    btnCancelSendingFile.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            ll_attach_text.setVisibility(View.GONE);
            edtChat.setFilters(new InputFilter[] {});
            edtChat.setText(EmojiManager.getInstance().replaceEmoji(edtChat.getText(), edtChat.getPaint().getFontMetricsInt(), LayoutCreator.dp(22), false));
            edtChat.setSelection(edtChat.getText().length());
            if (edtChat.getText().length() == 0) {
                sendButtonVisibility(false);
            }
        }
    });
    // final int screenWidth = (int) (getResources().getDisplayMetrics().widthPixels / 1.2);
    imvSmileButton = rootView.findViewById(R.id.tv_chatRoom_emoji);
    edtChat.requestFocus();
    edtChat.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (isEmojiSHow) {
                imvSmileButton.performClick();
            }
            if (botInit != null)
                botInit.close();
        }
    });
    if (viewAttachFile != null) {
    // LinearLayout linearLayout = (LinearLayout) viewAttachFile;
    // voiceHintTextView = new HintView(G.context, 9);
    }
    imvAttachFileButton = rootView.findViewById(R.id.vtn_chatRoom_attach);
    layoutAttachBottom = rootView.findViewById(R.id.ll_chatRoom_send);
    imvMicButton = rootView.findViewById(R.id.btn_chatRoom_mic);
    imvAddStoryButton = rootView.findViewById(R.id.btn_chatRoom_add_story);
    actionButtonsRootView = rootView.findViewById(R.id.chat_action_buttons_root_view);
    customStatusActionLayout = rootView.findViewById(R.id.custom_status_action_root);
    floatActionLayout = rootView.findViewById(R.id.add_story_action_root);
    customStatusActionLayout.setBackground(Theme.createSimpleSelectorCircleDrawable(LayoutCreator.dp(56), Theme.getInstance().getToolbarBackgroundColor(context), Theme.getInstance().getAccentColor(context)));
    floatActionLayout.setBackground(Theme.createSimpleSelectorCircleDrawable(LayoutCreator.dp(56), Theme.getInstance().getToolbarBackgroundColor(context), Theme.getInstance().getAccentColor(context)));
    hideFloatingButton(true);
    if (isBot) {
        botInit = new BotInit(rootView, false);
        sendButtonVisibility(false);
        RealmRoomMessage rm = null;
        String lastMessage = "";
        boolean backToMenu = true;
        RealmResults<RealmRoomMessage> result = DbManager.getInstance().doRealmTask(realm -> {
            return realm.where(RealmRoomMessage.class).equalTo("roomId", mRoomId).notEqualTo("authorHash", RealmUserInfo.getCurrentUserAuthorHash()).findAll();
        });
        if (result.size() > 0) {
            rm = result.last();
            if (rm.getMessage() != null) {
                lastMessage = rm.getMessage();
            }
        }
        try {
            if (rm.getRealmAdditional() != null && rm.getRealmAdditional().getAdditionalType() == AdditionalType.UNDER_KEYBOARD_BUTTON) {
                botInit.updateCommandList(false, lastMessage, getActivity(), backToMenu, rm, rm.getRoomId());
            }
        } catch (Exception e) {
        }
    }
    mAdapter = new MessagesAdapter<>(managedRoom, this, this, this, avatarHandler, compositeDisposable, isCloudRoom);
    mAdapter.getItemFilter().withFilterPredicate(new IItemAdapter.Predicate<AbstractMessage>() {

        @Override
        public boolean filter(AbstractMessage item, CharSequence constraint) {
            return !item.messageObject.message.toLowerCase().contains(constraint.toString().toLowerCase());
        }
    });
    // FragmentMain.PreCachingLayoutManager layoutManager = new FragmentMain.PreCachingLayoutManager(ActivityChat.this, 7500);
    MyLinearLayoutManager layoutManager = new MyLinearLayoutManager(G.fragmentActivity);
    layoutManager.setStackFromEnd(true);
    if (recyclerView == null) {
        recyclerView = rootView.findViewById(R.id.chl_recycler_view_chat);
    }
    recyclerView.setItemAnimator(null);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(mAdapter);
    recyclerView.setItemViewCacheSize(20);
    if (realmRoom != null && !realmRoom.getReadOnly()) {
        ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) {

            @Override
            public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
                return true;
            }

            @Override
            public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
                super.clearView(recyclerView, viewHolder);
                try {
                    // TODO: 12/28/20  MESSAGE_REFACTOR
                    MessageObject message_ = (mAdapter.getItem(viewHolder.getAdapterPosition())).messageObject;
                    if (message_ != null && message_.status != ProtoGlobal.RoomMessageStatus.SENDING_VALUE && message_.status != ProtoGlobal.RoomMessageStatus.FAILED_VALUE) {
                        if (isReply)
                            reply((mAdapter.getItem(viewHolder.getAdapterPosition())).messageObject, false);
                    }
                } catch (Exception ignored) {
                    ignored.printStackTrace();
                }
                isReply = false;
            }

            @Override
            public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
            }

            @Override
            public void onChildDraw(@NotNull Canvas c, @NotNull RecyclerView recyclerView, @NotNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
                if (actionState == ACTION_STATE_SWIPE && isCurrentlyActive) {
                    setTouchListener(recyclerView, dX);
                }
                dX = dX + ViewMaker.dpToPixel(25);
                if (dX > 0)
                    dX = 0;
                if (dX < -ViewMaker.dpToPixel(150)) {
                    dX = -ViewMaker.dpToPixel(150);
                }
                super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
            }

            @Override
            public float getSwipeThreshold(@NonNull RecyclerView.ViewHolder viewHolder) {
                return super.getSwipeThreshold(viewHolder);
            }

            @Override
            public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
                // TODO: 12/28/20 MESSAGE_REFACTOR
                MessageObject message_ = null;
                try {
                    message_ = (mAdapter.getItem(viewHolder.getAdapterPosition())).messageObject;
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (message_ != null && (message_.status == ProtoGlobal.RoomMessageStatus.SENDING_VALUE || message_.status == ProtoGlobal.RoomMessageStatus.FAILED_VALUE)) {
                    return 0;
                } else if (viewHolder instanceof VoiceItem.ViewHolder) {
                    return 0;
                } else if (viewHolder instanceof AudioItem.ViewHolder) {
                    return 0;
                } else if (viewHolder instanceof NewChatItemHolder) {
                    return super.getSwipeDirs(recyclerView, viewHolder);
                }
                // we disable swipe with returning Zero
                return 0;
            }

            @Override
            public int convertToAbsoluteDirection(int flags, int layoutDirection) {
                if (swipeBack) {
                    swipeBack = false;
                    return 0;
                }
                return super.convertToAbsoluteDirection(flags, layoutDirection);
            }

            @Override
            public boolean isItemViewSwipeEnabled() {
                return !FragmentChat.isInSelectionMode;
            }
        };
        ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
        itemTouchHelper.attachToRecyclerView(recyclerView);
    }
    /**
     * load message , use handler for load async
     */
    visibilityTextEmptyMessages();
    mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {

        @Override
        public void onItemRangeInserted(int positionStart, int itemCount) {
            super.onItemRangeInserted(positionStart, itemCount);
            visibilityTextEmptyMessages();
        }

        @Override
        public void onItemRangeRemoved(int positionStart, int itemCount) {
            super.onItemRangeRemoved(positionStart, itemCount);
            visibilityTextEmptyMessages();
        }
    });
    // added run time -> counter of un read messages
    llScrollNavigate = rootView.findViewById(R.id.ac_ll_scrool_navigate);
    txtNewUnreadMessage = new BadgeView(getContext());
    txtNewUnreadMessage.getTextView().setTypeface(ResourcesCompat.getFont(txtNewUnreadMessage.getContext(), R.font.main_font));
    txtNewUnreadMessage.getTextView().setSingleLine();
    // set max length
    txtNewUnreadMessage.getTextView().setFilters(new InputFilter[] { new InputFilter.LengthFilter(5) });
    txtNewUnreadMessage.setBadgeColor(new Theme().getPrimaryDarkColor(txtNewUnreadMessage.getContext()));
    llScrollNavigate.addView(txtNewUnreadMessage, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER | Gravity.TOP));
    G.handler.post(() -> {
        AndroidUtils.globalQueue.postRunnable(this::getMessages);
        manageForwardedMessage(false);
    });
    MaterialDesignTextView txtNavigationLayout = rootView.findViewById(R.id.ac_txt_down_navigation);
    llScrollNavigate.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            cancelAllRequestFetchHistory();
            // Todo : also needed: block future Request
            latestButtonClickTime = System.currentTimeMillis();
            /**
             * have unread
             */
            if (countNewMessage > 0 && getFirstUnreadMessage() != null) {
                if (!getFirstUnreadMessage().isValid() || getFirstUnreadMessage().isDeleted()) {
                    resetAndGetFromEnd();
                    return;
                }
                int position = mAdapter.findPositionByMessageId(getFirstUnreadMessage().getMessageId());
                String m = getFirstUnreadMessage().getMessage();
                if (position > 0) {
                    mAdapter.add(position, new UnreadMessage(mAdapter, FragmentChat.this).setMessage(MessageObject.create(makeUnreadMessage(countNewMessage))).withIdentifier(SUID.id().get()));
                    isShowLayoutUnreadMessage = true;
                    LinearLayoutManager linearLayout = (LinearLayoutManager) recyclerView.getLayoutManager();
                    linearLayout.scrollToPositionWithOffset(position, 0);
                } else {
                    resetMessagingValue();
                    unreadCount = countNewMessage;
                    getMessages();
                    if (getFirstUnreadMessage() == null) {
                        resetAndGetFromEnd();
                        return;
                    }
                    int position1 = mAdapter.findPositionByMessageId(getFirstUnreadMessage().getMessageId());
                    if (position1 > 0) {
                        LinearLayoutManager linearLayout = (LinearLayoutManager) recyclerView.getLayoutManager();
                        linearLayout.scrollToPositionWithOffset(position1 - 1, 0);
                    }
                }
                setCountNewMessageZero();
            } else {
                if (!addToView) {
                    resetMessagingValue();
                    getMessages();
                } else {
                    scrollToEnd();
                }
            }
        }
    });
    recyclerView.setOnFlingListener(new RecyclerView.OnFlingListener() {

        @Override
        public boolean onFling(int velocityX, int velocityY) {
            return false;
        }
    });
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                G.imageLoader.resume();
            } else if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
                G.imageLoader.pause();
            }
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            int visibleItemCount = recyclerView.getLayoutManager().getChildCount();
            int totalItemCount = recyclerView.getLayoutManager().getItemCount();
            int pastVisibleItems = ((LinearLayoutManager) recyclerView.getLayoutManager()).findLastVisibleItemPosition();
            cardFloatingTime.setVisibility(View.VISIBLE);
            long item = mAdapter.getItemByPosition(layoutManager.findFirstVisibleItemPosition());
            Calendar calendar = Calendar.getInstance();
            calendar.setTimeInMillis(item);
            if (item != 0L) {
                txtFloatingTime.setText(TimeUtils.getChatSettingsTimeAgo(G.fragmentActivity, calendar.getTime()));
            }
            gongingHandler.removeCallbacks(gongingRunnable);
            gongingHandler.postDelayed(gongingRunnable, 1000);
            if (totalItemCount - pastVisibleItems <= 2 && !isAnimateStart) {
                isAnimateStart = true;
                isAnimateStart = false;
                setDownBtnGone();
            // llScrollNavigate.animate()
            // .alpha(0.0f)
            // .translationY(llScrollNavigate.getHeight() / 2)
            // .setDuration(200)
            // .setListener(new AnimatorListenerAdapter() {
            // @Override
            // public void onAnimationEnd(Animator animation) {
            // super.onAnimationEnd(animation);
            // }
            // });
            } else if (!isScrollEnd && !isAnimateStart) {
                isAnimateStart = true;
                setDownBtnVisible();
                isAnimateStart = false;
                // llScrollNavigate.animate()
                // .alpha(1.0f)
                // .translationY(0)
                // .setDuration(200)
                // .setListener(new AnimatorListenerAdapter() {
                // @Override
                // public void onAnimationEnd(Animator animation) {
                // super.onAnimationEnd(animation);
                // }
                // });
                txtNewUnreadMessage.getTextView().setText(countNewMessage + "");
                if (countNewMessage == 0) {
                    txtNewUnreadMessage.setVisibility(View.GONE);
                } else {
                    txtNewUnreadMessage.setVisibility(View.VISIBLE);
                }
            }
        }
    });
    /*       if (event.getAction() == MotionEvent.ACTION_CANCEL) {
            card.setCardBackgroundColor(Color.parseColor("#ffffff"));
        } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
            //    event.addBatch(0,0,0,0,0,0);
            //            card.setCardBackgroundColor(Color.parseColor("#ffffff"));
        } else if (event.getAction() == android.view.MotionEvent.ACTION_DOWN) {

            card.setCardBackgroundColor(Color.parseColor("#20000000"));

        } else if (event.getAction() == android.view.MotionEvent.ACTION_UP) {
            */
    /* Reset Color */
    /*
            card.setCardBackgroundColor(Color.parseColor("#ffffff"));
            //  card.setOnClickListener(clickListener);

        }
        return false;
*/
    recyclerView.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return false;
        }
    });
    imvSendButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            lastChar = null;
            if (!addToView) {
                resetAndGetFromEnd();
            }
            if (suggestedLayout != null) {
                if (suggestedLayout.getVisibility() == View.VISIBLE)
                    suggestedLayout.setVisibility(View.GONE);
                lastChar = null;
            }
            if (isShowLayoutUnreadMessage) {
                removeLayoutUnreadMessage();
            }
            HelperSetAction.setCancel(mRoomId);
            clearDraftRequest();
            if (hasForward) {
                manageForwardedMessage(false);
                if (edtChat.getText().length() == 0) {
                    return;
                }
            }
            if (ll_attach_text.getVisibility() == View.VISIBLE) {
                if (listPathString.size() == 0) {
                    return;
                }
                sendMessage(latestRequestCode, listPathString.get(0));
                listPathString.clear();
                ll_attach_text.setVisibility(View.GONE);
                edtChat.setFilters(new InputFilter[] {});
                edtChat.setText("");
                clearReplyView();
                return;
            }
            if (edtChat.getTag() != null && edtChat.getTag() instanceof MessageObject) {
                final MessageObject messageInfo = (MessageObject) edtChat.getTag();
                final String message = getWrittenMessage();
                if (!message.equals(messageInfo.message) && edtChat.getText().toString().trim().length() > 0) {
                    if (G.connectionState == ConnectionState.WAITING_FOR_NETWORK) {
                        Toast.makeText(getContext(), getResources().getString(R.string.please_check_your_connenction), Toast.LENGTH_SHORT).show();
                        return;
                    }
                    chatRoom_send_container.setVisibility(View.VISIBLE);
                    imvSendButton.setVisibility(View.GONE);
                    editTextProgress.setVisibility(View.VISIBLE);
                    getMessageController().editMessage(messageInfo.id, messageInfo.documentId, mRoomId, message, chatType.getNumber());
                } else {
                    removeEditedMessage();
                }
            } else {
                // new message has written
                sendNewMessage(getWrittenMessage());
                scrollToEnd();
            }
            oldMessageLentghCounter = 0;
            messageLentghCounter = 0;
        }
    });
    G.openBottomSheetItem = new OpenBottomSheetItem() {

        @Override
        public void openBottomSheet(boolean isNew) {
            if (mAttachmentPopup != null)
                mAttachmentPopup.setIsNewDialog(isNew);
            imvAttachFileButton.performClick();
            if (mAttachmentPopup != null)
                mAttachmentPopup.notifyRecyclerView();
        }
    };
    FragmentEditImage.completeEditImage = new FragmentEditImage.CompleteEditImage() {

        @Override
        public void result(String path, String message, HashMap<String, StructBottomSheet> textImageList) {
            listPathString = null;
            listPathString = new ArrayList<>();
            if (textImageList.size() == 0) {
                return;
            }
            ArrayList<StructBottomSheet> itemList = new ArrayList<StructBottomSheet>();
            for (Map.Entry<String, StructBottomSheet> items : textImageList.entrySet()) {
                itemList.add(items.getValue());
            }
            Collections.sort(itemList);
            for (StructBottomSheet item : itemList) {
                edtChat.setText(EmojiManager.getInstance().replaceEmoji(item.getText(), edtChat.getPaint().getFontMetricsInt(), LayoutCreator.dp(22), false));
                listPathString.add(item.getPath());
                latestRequestCode = AttachFile.requestOpenGalleryForImageMultipleSelect;
                ll_attach_text.setVisibility(View.VISIBLE);
                imvSendButton.performClick();
            }
        }
    };
    imvAttachFileButton.setOnClickListener(view -> {
        if (getActivity() == null)
            return;
        if (mAttachmentPopup == null)
            initPopupAttachment();
        mAttachmentPopup.setMessagesLayoutHeight(recyclerView.getMeasuredHeight());
        hideKeyboard();
        mAttachmentPopup.show();
    });
    sendMoney.setOnClickListener(view -> {
        if ((chatType == CHAT) && !isCloudRoom && !isBot) {
            showSelectItem();
        } else {
            showCardToCard();
        }
        if (keyboardViewVisible) {
            hideKeyboard();
        }
    });
    customStatusActionLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (getActivity() != null) {
                hideFloatingButton(true);
                new HelperFragment(getActivity().getSupportFragmentManager(), new StatusTextFragment(true, mRoomId, 0, title)).setReplace(false).load();
            }
        }
    });
    floatActionLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (getActivity() != null) {
                hideFloatingButton(true);
                new HelperFragment(getActivity().getSupportFragmentManager(), new StoryPagerFragment(true, mRoomId, 0, title)).setReplace(false).load();
            }
        }
    });
    imvAddStoryButton.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View view) {
            if (keyboardViewVisible) {
                hideKeyboard();
            }
            if (!MessageController.isSendingRoomStory && !MessageController.isSendingStory) {
                hideFloatingButton(false);
            }
            return true;
        }
    });
    imvAddStoryButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            hideFloatingButton(true);
            micAndAddStoryAnimateVisible(false);
        }
    });
    imvMicButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (chatType == CHANNEL) {
                if (channelRole == ChannelChatRole.OWNER && !isRecording) {
                    micAndAddStoryAnimateVisible(true);
                }
            }
        }
    });
    Runnable recordVoiceRunnable = new Runnable() {

        @Override
        public void run() {
            isLongPress = true;
            if (isLongPress) {
                Vibrator vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
                vibrator.vibrate(100);
                if (mustCheckPermission()) {
                    if (currentRoomAccess != null && !currentRoomAccess.getRealmPostMessageRights().isCanSendMedia()) {
                        Toast.makeText(getContext(), getResources().getString(R.string.restrictions_on_sending_multimedia_messages), Toast.LENGTH_SHORT).show();
                        isLongPress = false;
                    }
                }
                if (keyboardViewVisible)
                    hideKeyboard();
                if (ContextCompat.checkSelfPermission(G.fragmentActivity, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
                    try {
                        HelperPermission.getMicroPhonePermission(G.fragmentActivity, null);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                } else {
                    isRecording = true;
                    voiceRecord.setItemTag("ivVoice");
                    viewMicRecorder.setVisibility(View.VISIBLE);
                    AppUtils.setVibrator(50);
                    voiceRecord.startVoiceRecord();
                }
            }
        }
    };
    imvMicButton.setOnTouchListener((v, event) -> {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            G.runOnUiThread(recordVoiceRunnable, longClickDuration);
        } else if (event.getAction() == MotionEvent.ACTION_UP) {
            G.cancelRunOnUiThread(recordVoiceRunnable);
            isLongPress = false;
        }
        return isLongPress;
    });
    imvSmileButton.setOnClickListener(v -> onEmojiButtonClick());
    edtChat.addTextChangedListener(new TextWatcher() {

        boolean processChange = false;

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence text, int start, int before, int count) {
            if (text.length() > 0) {
                HelperSetAction.setActionTyping(mRoomId, chatType);
            }
            // if in the seeting page send by enter is on message send by enter key
            if (text.toString().endsWith(System.getProperty("line.separator"))) {
                if (sendByEnter)
                    imvSendButton.performClick();
            }
            messageLentghCounter = ((int) Math.ceil((float) text.length() / (float) Config.MAX_TEXT_LENGTH));
            if (messageLentghCounter > 1 && messageLentghCounter != oldMessageLentghCounter && getContext() != null) {
                oldMessageLentghCounter = messageLentghCounter;
                Toast.makeText(getContext(), getString(R.string.message_is_long) + " " + messageLentghCounter + " " + getString(R.string.message), Toast.LENGTH_SHORT).show();
            }
            if ((count - before) > 1) {
                processChange = true;
            }
        }

        @Override
        public void afterTextChanged(Editable editable) {
            if (ll_attach_text.getVisibility() == View.GONE && !hasForward) {
                if (edtChat.getText() != null && edtChat.getText().length() > 0) {
                    sendButtonVisibility(true);
                } else {
                    if (!isEditMessage) {
                        sendButtonVisibility(false);
                    }
                }
                if (processChange) {
                    ImageSpan[] spans = editable.getSpans(0, editable.length(), ImageSpan.class);
                    for (ImageSpan span : spans) {
                        editable.removeSpan(span);
                    }
                    EmojiManager.getInstance().replaceEmoji(editable, edtChat.getPaint().getFontMetricsInt(), LayoutCreator.dp(20), false);
                    processChange = false;
                }
            }
            if (edtChat.getText() != null && !EmojiManager.getInstance().isValidEmoji(edtChat.getText()) && suggestedLayout != null && suggestedLayout.getVisibility() == View.VISIBLE) {
                suggestedLayout.setVisibility(View.GONE);
                lastChar = null;
            } else if (lastChar != null) {
                lastChar = null;
            }
        }
    });
}
Also used : ArrayList(java.util.ArrayList) RealmString(net.iGap.realm.RealmString) HelperString(net.iGap.helper.HelperString) MyLinearLayoutManager(net.iGap.module.MyLinearLayoutManager) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) UnreadMessage(net.iGap.adapter.items.chat.UnreadMessage) RealmRoomMessage.makeUnreadMessage(net.iGap.realm.RealmRoomMessage.makeUnreadMessage) NonNull(androidx.annotation.NonNull) IItemAdapter(com.mikepenz.fastadapter.IItemAdapter) RealmRoom(net.iGap.realm.RealmRoom) BotInit(net.iGap.module.BotInit) StoryPagerFragment(net.iGap.story.StoryPagerFragment) InputFilter(android.text.InputFilter) AbstractMessage(net.iGap.adapter.items.chat.AbstractMessage) Canvas(android.graphics.Canvas) BadgeView(net.iGap.adapter.items.chat.BadgeView) NewChatItemHolder(net.iGap.adapter.items.chat.NewChatItemHolder) RealmRoomMessage(net.iGap.realm.RealmRoomMessage) HelperFragment(net.iGap.helper.HelperFragment) ImageSpan(android.text.style.ImageSpan) MyLinearLayoutManager(net.iGap.module.MyLinearLayoutManager) NotNull(org.jetbrains.annotations.NotNull) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) OpenBottomSheetItem(net.iGap.observers.interfaces.OpenBottomSheetItem) Calendar(java.util.Calendar) StructBottomSheet(net.iGap.module.structs.StructBottomSheet) IOException(java.io.IOException) NumberTextView(net.iGap.messenger.ui.toolBar.NumberTextView) KeyboardView(net.iGap.libs.emojiKeyboard.KeyboardView) RecyclerView(androidx.recyclerview.widget.RecyclerView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) EmojiView(net.iGap.libs.emojiKeyboard.EmojiView) BadgeView(net.iGap.adapter.items.chat.BadgeView) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) ImageView(android.widget.ImageView) CardView(androidx.cardview.widget.CardView) FontIconTextView(net.iGap.module.FontIconTextView) StructWebView(net.iGap.module.structs.StructWebView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) IOException(java.io.IOException) JsonSyntaxException(com.google.gson.JsonSyntaxException) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) StatusTextFragment(net.iGap.story.StatusTextFragment) VoiceItem(net.iGap.adapter.items.chat.VoiceItem) Theme(net.iGap.module.Theme) RecyclerView(androidx.recyclerview.widget.RecyclerView) Vibrator(android.os.Vibrator) MessageObject(net.iGap.structs.MessageObject) SuppressLint(android.annotation.SuppressLint)

Aggregations

Theme (net.iGap.module.Theme)41 View (android.view.View)22 TextView (android.widget.TextView)21 HelperFragment (net.iGap.helper.HelperFragment)17 LinearLayout (android.widget.LinearLayout)15 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)13 Bundle (android.os.Bundle)12 ViewGroup (android.view.ViewGroup)12 Nullable (androidx.annotation.Nullable)12 RecyclerView (androidx.recyclerview.widget.RecyclerView)12 ArrayList (java.util.ArrayList)12 R (net.iGap.R)11 NonNull (androidx.annotation.NonNull)10 LayoutInflater (android.view.LayoutInflater)9 HelperError (net.iGap.helper.HelperError)9 ParamWithAvatarType (net.iGap.helper.avatar.ParamWithAvatarType)9 Drawable (android.graphics.drawable.Drawable)8 FrameLayout (android.widget.FrameLayout)8 ProgressBar (android.widget.ProgressBar)8 Fragment (androidx.fragment.app.Fragment)8