Search in sources :

Example 16 with ParamWithAvatarType

use of net.iGap.helper.avatar.ParamWithAvatarType in project iGap-Android by KianIranian-STDG.

the class FragmentContactsProfile method onViewCreated.

@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    initialToolbar();
    DbManager.getInstance().doRealmTask(realm -> {
        realmRoom = realm.where(RealmRoom.class).equalTo("id", viewModel.roomId).findFirst();
        if (realmRoom != null) {
            roomType = realmRoom.getType();
            action = realmRoom.getActionState();
        }
    });
    G.onSetAction = this;
    if (peerId == AccountManager.getInstance().getCurrentUser().getId()) {
        binding.toolbarTxtStatusExpanded.setText(requireContext().getResources().getString(R.string.chat_with_yourself));
    } else {
        viewModel.lastSeen.observe(getViewLifecycleOwner(), lastSeen -> {
            if (action != null && realmRoom != null)
                binding.toolbarTxtStatusExpanded.setText(action);
            else
                binding.toolbarTxtStatusExpanded.setText(HelperCalander.unicodeManage(lastSeen));
        });
    }
    userAvatarImageView = binding.toolbarAvatar;
    userAvatarImageView.setOnClickListener(v -> viewModel.onImageClick());
    binding.toolbarBack.setOnClickListener(v -> popBackStackFragment());
    binding.toolbarMore.setOnClickListener(v -> viewModel.onMoreButtonClick());
    binding.toolbarCall.setOnClickListener(v -> onCallButtonClick());
    viewModel.copyUserNameToClipBoard.observe(getViewLifecycleOwner(), userName -> {
        if (userName == null)
            return;
        ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
        ClipData clip = ClipData.newPlainText("LINK_USER", Config.IGAP_LINK_PREFIX + userName);
        clipboard.setPrimaryClip(clip);
        Toast.makeText(getActivity(), getString(R.string.username_copied), Toast.LENGTH_SHORT).show();
    });
    viewModel.getCloudVisibility().observe(getViewLifecycleOwner(), thisMyCloud -> {
        if (thisMyCloud != null) {
            if (thisMyCloud) {
                binding.report.setVisibility(View.GONE);
                binding.block.setVisibility(View.GONE);
                binding.enableNotificationLyt.setVisibility(View.GONE);
                binding.line1.setVisibility(View.GONE);
                binding.customNotification.setVisibility(View.GONE);
            } else {
                binding.report.setVisibility(View.VISIBLE);
                binding.block.setVisibility(View.VISIBLE);
                binding.line1.setVisibility(View.VISIBLE);
                binding.enableNotificationLyt.setVisibility(View.VISIBLE);
                binding.customNotification.setVisibility(View.VISIBLE);
            }
        }
    });
    viewModel.menuVisibility.observe(getViewLifecycleOwner(), visible -> {
        if (visible != null)
            binding.toolbarMore.setVisibility(visible);
    });
    viewModel.videoCallVisibility.observe(getViewLifecycleOwner(), visible -> {
        if (visible != null)
            binding.toolbarCall.setVisibility(visible);
    });
    viewModel.isMuteNotificationChangeListener.observe(getViewLifecycleOwner(), isChecked -> {
        binding.enableNotification.setChecked(isChecked);
        getRoomController().clientMuteRoom(viewModel.roomId, isChecked);
    });
    viewModel.contactName.observe(getViewLifecycleOwner(), name -> {
        if (name != null) {
            binding.toolbarTxtNameCollapsed.setText(EmojiManager.getInstance().replaceEmoji(name, binding.toolbarTxtNameCollapsed.getPaint().getFontMetricsInt()));
            binding.toolbarTxtNameExpanded.setText(EmojiManager.getInstance().replaceEmoji(name, binding.toolbarTxtNameExpanded.getPaint().getFontMetricsInt()));
            binding.toolbarTxtNameExpanded.setSelected(true);
        }
    });
    viewModel.goToChatPage.observe(getViewLifecycleOwner(), userRoomId -> {
        if (getActivity() != null && userRoomId != null) {
            if (G.twoPaneMode) {
                ((ActivityMain) getActivity()).removeAllFragment();
            } else {
                ((ActivityMain) getActivity()).removeAllFragmentFromMain();
            }
            new GoToChatActivity(userRoomId).startActivity(getActivity());
        }
    });
    viewModel.goBack.observe(getViewLifecycleOwner(), isBack -> {
        if (isBack != null && isBack) {
            popBackStackFragment();
        }
    });
    viewModel.goToShearedMediaPage.observe(getViewLifecycleOwner(), data -> {
        if (getActivity() != null && data != null) {
            new HelperFragment(getActivity().getSupportFragmentManager(), FragmentShearedMedia.newInstance(data)).setReplace(false).load();
        }
    });
    if (viewModel.phone != null && (!viewModel.phone.get().equals("0") || viewModel.showNumber.get())) {
        if (viewModel.phone.get().equals("0")) {
            binding.toolbarTxtTelExpanded.setVisibility(View.GONE);
            viewModel.menuVisibility.setValue(View.GONE);
        } else {
            binding.toolbarTxtTelExpanded.setText(viewModel.phone.get());
            binding.toolbarTxtTelExpanded.setOnClickListener(v -> viewModel.onPhoneNumberClick());
        }
    } else {
        binding.toolbarTxtTelExpanded.setVisibility(View.GONE);
    }
    /*binding.toolbarTxtUsernameExpanded.setText(viewModel.username.get());*/
    binding.toolbarFabChat.setOnClickListener(v -> {
        viewModel.onClickGoToChat();
    });
    /*binding.chiFabSetPic.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor(G.fabBottom)));
        binding.chiFabSetPic.setColorFilter(Color.WHITE);
        binding.chiFabSetPic.setOnClickListener(new View.OnClickListener() { //fab button
            @Override
            public void onClick(View view) {

                if (enterFrom.equals(ProtoGlobal.Room.Type.GROUP.toString()) || enterFrom.equals("Others")) { // Others is from FragmentMapUsers adapter

final RealmRoom realmRoom = realm.where(RealmRoom.class).equalTo("chatRoom.peer_id", userId).findFirst();

                    if (realmRoom != null) {
                        new HelperFragment().removeAll(true);
                        new GoToChatActivity(realmRoom.getId()).startActivity();
                    } else {
                        G.onChatGetRoom = new OnChatGetRoom() {
                            @Override
                            public void onChatGetRoom(final ProtoGlobal.Room room) {
                                G.handler.post(new Runnable() {
                                    @Override
                                    public void run() {
                                        new HelperFragment().removeAll(true);
                                        new GoToChatActivity(room.getId()).setPeerID(userId).startActivity();
                                        G.onChatGetRoom = null;
                                    }
                                });
                            }

                            @Override
                            public void onChatGetRoomTimeOut() {

                            }

                            @Override
                            public void onChatGetRoomError(int majorCode, int minorCode) {

                            }
                        };

                        new RequestChatGetRoom().chatGetRoom(userId);
                    }


                } else {
                    popBackStackFragment();
                }
            }
        });*/
    /*if (viewModel.showNumber.get()) {
            binding.chiLayoutNickname.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                    if (viewModel.contactName.get() == null) {
                        return;
                    }

                    final LinearLayout layoutNickname = new LinearLayout(G.fragmentActivity);
                    layoutNickname.setOrientation(LinearLayout.VERTICAL);

                    String splitNickname[] = viewModel.contactName.get().split(" ");
                    String firsName = "";
                    String lastName = "";
                    StringBuilder stringBuilder = null;
                    if (splitNickname.length > 1) {

                        lastName = splitNickname[splitNickname.length - 1];
                        stringBuilder = new StringBuilder();
                        for (int i = 0; i < splitNickname.length - 1; i++) {

                            stringBuilder.append(splitNickname[i]).append(" ");
                        }
                        firsName = stringBuilder.toString();
                    } else {
                        firsName = splitNickname[0];
                    }
                    final View viewFirstName = new View(G.fragmentActivity);
                    viewFirstName.setBackgroundColor(G.context.getResources().getColor(R.color.line_edit_text));

                    LinearLayout.LayoutParams viewParams = new AppBarLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 2);

                    TextInputLayout inputFirstName = new TextInputLayout(G.fragmentActivity);
                    final EmojiEditTextE edtFirstName = new EmojiEditTextE(G.fragmentActivity);
                    edtFirstName.setHint(R.string.first_name);
                    edtFirstName.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
                    edtFirstName.setTypeface(G.typeface_IRANSansMobile);
                    edtFirstName.setText(firsName);
                    edtFirstName.setTextSize(TypedValue.COMPLEX_UNIT_PX, G.context.getResources().getDimension(R.dimen.dp14));
                    edtFirstName.setTextColor(G.context.getResources().getColor(R.color.text_edit_text));
                    edtFirstName.setHintTextColor(G.context.getResources().getColor(R.color.hint_edit_text));
                    edtFirstName.setPadding(0, 8, 0, 8);
                    edtFirstName.setSingleLine(true);
                    inputFirstName.addView(edtFirstName);
                    inputFirstName.addView(viewFirstName, viewParams);
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                        edtFirstName.setBackground(G.context.getResources().getDrawable(android.R.color.transparent));
                    }

                    final View viewLastName = new View(G.fragmentActivity);
                    viewLastName.setBackgroundColor(G.context.getResources().getColor(R.color.line_edit_text));

                    TextInputLayout inputLastName = new TextInputLayout(G.fragmentActivity);
                    final MEditText edtLastName = new MEditText(G.fragmentActivity);
                    edtLastName.setHint(R.string.last_name);
                    edtLastName.setTypeface(G.typeface_IRANSansMobile);
                    edtLastName.setText(lastName);
                    edtLastName.setTextSize(TypedValue.COMPLEX_UNIT_PX, G.context.getResources().getDimension(R.dimen.dp14));
                    edtLastName.setTextColor(G.context.getResources().getColor(R.color.text_edit_text));
                    edtLastName.setHintTextColor(G.context.getResources().getColor(R.color.hint_edit_text));
                    edtLastName.setPadding(0, 8, 0, 8);
                    edtLastName.setSingleLine(true);
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                        edtLastName.setBackground(G.context.getResources().getDrawable(android.R.color.transparent));
                    }
                    inputLastName.addView(edtLastName);
                    inputLastName.addView(viewLastName, viewParams);

                    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                    layoutParams.setMargins(0, 0, 0, 15);
                    LinearLayout.LayoutParams lastNameLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                    lastNameLayoutParams.setMargins(0, 15, 0, 10);

                    layoutNickname.addView(inputFirstName, layoutParams);
                    layoutNickname.addView(inputLastName, lastNameLayoutParams);

                    final MaterialDialog dialog = new MaterialDialog.Builder(G.fragmentActivity).title(G.fragmentActivity.getResources().getString(R.string.pu_nikname_profileUser))
                            .positiveText(G.fragmentActivity.getResources().getString(R.string.B_ok))
                            .customView(layoutNickname, true)
                            .widgetColor(Color.parseColor(G.appBarColor))
                            .negativeText(G.fragmentActivity.getResources().getString(R.string.B_cancel))
                            .build();

                    final View positive = dialog.getActionButton(DialogAction.POSITIVE);
                    positive.setEnabled(false);

                    edtFirstName.setOnFocusChangeListener(new View.OnFocusChangeListener() {
                        @Override
                        public void onFocusChange(View view, boolean b) {
                            if (b) {
                                viewFirstName.setBackgroundColor(Color.parseColor(G.appBarColor));
                            } else {
                                viewFirstName.setBackgroundColor(G.context.getResources().getColor(R.color.line_edit_text));
                            }
                        }
                    });

                    edtLastName.setOnFocusChangeListener(new View.OnFocusChangeListener() {
                        @Override
                        public void onFocusChange(View view, boolean b) {
                            if (b) {
                                viewLastName.setBackgroundColor(Color.parseColor(G.appBarColor));
                            } else {
                                viewLastName.setBackgroundColor(G.context.getResources().getColor(R.color.line_edit_text));
                            }
                        }
                    });

                    final String finalFirsName = firsName;
                    edtFirstName.addTextChangedListener(new TextWatcher() {
                        @Override
                        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

                        }

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

                        }

                        @Override
                        public void afterTextChanged(Editable editable) {

                            if (!edtFirstName.getText().toString().equals(finalFirsName)) {
                                positive.setEnabled(true);
                            } else {
                                positive.setEnabled(false);
                            }
                        }
                    });

                    final String finalLastName = lastName;
                    edtLastName.addTextChangedListener(new TextWatcher() {
                        @Override
                        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

                        }

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

                        }

                        @Override
                        public void afterTextChanged(Editable editable) {
                            if (!edtLastName.getText().toString().equals(finalLastName)) {
                                positive.setEnabled(true);
                            } else {
                                positive.setEnabled(false);
                            }
                        }
                    });

                    positive.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            long po = Long.parseLong(viewModel.phone.get());
                            String firstName = edtFirstName.getText().toString().trim();
                            String lastName = edtLastName.getText().toString().trim();
                            new RequestUserContactsEdit().contactsEdit(userId, po, firstName, lastName);
                            dialog.dismiss();
                        }
                    });

                    dialog.show();
                }
            });
        }*/
    /*binding.chiAppbar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
            @Override
            public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
                ViewGroup viewGroup = binding.chiRootCircleImage;
                if (verticalOffset < -5) {
                    viewGroup.animate().alpha(0).setDuration(700);
                    viewGroup.setVisibility(View.GONE);
                    binding.chiTxtTitleToolbarDisplayName.setVisibility(View.VISIBLE);
                    binding.chiTxtTitleToolbarDisplayName.animate().alpha(1).setDuration(300);
                    binding.chiTxtTitleToolbarLastSeen.setVisibility(View.VISIBLE);
                    binding.chiTxtTitleToolbarLastSeen.animate().alpha(1).setDuration(300);
                } else {
                    viewGroup.setVisibility(View.VISIBLE);
                    viewGroup.animate().alpha(1).setDuration(700);
                    binding.chiTxtTitleToolbarDisplayName.setVisibility(View.GONE);
                    binding.chiTxtTitleToolbarDisplayName.animate().alpha(0).setDuration(500);
                    binding.chiTxtTitleToolbarLastSeen.setVisibility(View.GONE);
                    binding.chiTxtTitleToolbarLastSeen.animate().alpha(0).setDuration(500);
                }
            }
        });*/
    viewModel.showMenu.observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean != null && aBoolean) {
            showPopUp();
        }
    });
    viewModel.showPhoneNumberDialog.observe(getViewLifecycleOwner(), new Observer<Boolean>() {

        @Override
        public void onChanged(@Nullable Boolean aBoolean) {
            if (aBoolean != null && aBoolean) {
                try {
                    HelperPermission.getContactPermision(G.fragmentActivity, new OnGetPermission() {

                        @Override
                        public void Allow() {
                            showPopupPhoneNumber(/*t.getProfileTell()*/
                            null, viewModel.phone.get());
                        }

                        @Override
                        public void deny() {
                            showDeniedPermissionMessage(G.context.getString(R.string.permission_contact));
                        }
                    });
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    });
    /*binding.chiLayoutSharedMedia.setOnClickListener(new View.OnClickListener() {// go to the ActivityMediaChanel
            @Override
            public void onClick(View view) {
                new HelperFragment(FragmentShearedMedia.newInstance(viewModel.shearedId)).setReplace(false).load();
            }
        });*/
    viewModel.showClearChatDialog.observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean != null && aBoolean) {
            showAlertDialog(getString(R.string.clear_this_chat), getString(R.string.clear), getString(R.string.cancel));
        }
    });
    viewModel.goToCustomNotificationPage.observe(getViewLifecycleOwner(), aBoolean -> {
        if (getActivity() != null && aBoolean != null && aBoolean) {
            FragmentNotification fragmentNotification = new FragmentNotification();
            Bundle bundle = new Bundle();
            bundle.putString("PAGE", "CONTACT");
            bundle.putLong("ID", viewModel.roomId);
            fragmentNotification.setArguments(bundle);
            new HelperFragment(getActivity().getSupportFragmentManager(), fragmentNotification).setReplace(false).load();
        }
    });
    viewModel.setAvatar.observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean != null) {
            if (aBoolean) {
                avatarHandler.getAvatar(new ParamWithAvatarType(userAvatarImageView, viewModel.userId).avatarSize(R.dimen.dp100).avatarType(AvatarHandler.AvatarType.USER).showMain());
            } else {
                userAvatarImageView.setImageResource(R.drawable.ic_cloud_space_blue);
            }
        }
    });
    viewModel.showDeleteContactDialog.observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean != null && aBoolean) {
            new MaterialDialog.Builder(G.fragmentActivity).title(R.string.to_delete_contact).content(R.string.delete_text).positiveText(R.string.B_ok).onPositive(new MaterialDialog.SingleButtonCallback() {

                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    viewModel.deleteContact();
                }
            }).negativeText(R.string.B_cancel).show();
        }
    });
    viewModel.showDialogReportContact.observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean != null && aBoolean) {
            openDialogReport();
        }
    });
    viewModel.showDialogStartSecretChat.observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean != null && aBoolean) {
            Toast.makeText(getContext(), "secret chat", Toast.LENGTH_LONG).show();
        }
    });
    viewModel.goToShowAvatarPage.observe(getViewLifecycleOwner(), isCurrentUser -> {
        if (getActivity() != null && isCurrentUser != null) {
            Log.wtf(this.getClass().getName(), "goToShowAvatarPage observe");
            FragmentShowAvatars fragment;
            if (isCurrentUser) {
                fragment = FragmentShowAvatars.newInstance(viewModel.userId, FragmentShowAvatars.From.setting);
            } else {
                fragment = FragmentShowAvatars.newInstance(viewModel.userId, FragmentShowAvatars.From.chat);
            }
            new HelperFragment(getActivity().getSupportFragmentManager(), fragment).setReplace(false).load();
        }
    });
    viewModel.blockDialogListener.observe(getViewLifecycleOwner(), isBlockUser -> {
        if (isBlockUser == null)
            return;
        if (isBlockUser) {
            new MaterialDialog.Builder(getContext()).title(R.string.unblock_the_user).content(R.string.unblock_the_user_text).positiveText(R.string.ok).onPositive(new MaterialDialog.SingleButtonCallback() {

                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    new RequestUserContactsUnblock().userContactsUnblock(viewModel.userId);
                }
            }).negativeText(R.string.cancel).dismissListener(dialog -> checkViewsState()).showListener(dialog -> checkViewsState()).show();
        } else {
            new MaterialDialog.Builder(getContext()).title(R.string.block_the_user).content(R.string.block_the_user_text).positiveText(R.string.ok).onPositive(new MaterialDialog.SingleButtonCallback() {

                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    new RequestUserContactsBlock().userContactsBlock(viewModel.userId);
                }
            }).negativeText(R.string.cancel).dismissListener(dialog -> checkViewsState()).showListener(dialog -> checkViewsState()).show();
        }
    });
    viewModel.editContactListener.observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean == null)
            return;
        FragmentAddContact fragment = FragmentAddContact.newInstance(viewModel.userId, viewModel.phoneNumber, viewModel.firstName, viewModel.lastName, FragmentAddContact.ContactMode.EDIT, (name, family) -> {
            viewModel.contactName.setValue(name + " " + family);
            viewModel.firstName = name;
            viewModel.lastName = family;
            if (getActivity() != null) {
                ((ActivityMain) getActivity()).onUpdateContacts();
            }
        });
        if (getActivity() != null)
            new HelperFragment(getActivity().getSupportFragmentManager(), fragment).setReplace(false).load();
    });
}
Also used : ClipboardManager(android.content.ClipboardManager) ContentProviderOperation(android.content.ContentProviderOperation) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) FragmentContactsProfileBinding(net.iGap.databinding.FragmentContactsProfileBinding) G(net.iGap.G) ContactsContract(android.provider.ContactsContract) HelperPermission(net.iGap.helper.HelperPermission) HelperPermission.showDeniedPermissionMessage(net.iGap.helper.HelperPermission.showDeniedPermissionMessage) DialogAnimation(net.iGap.module.DialogAnimation) BottomSheetFragment(net.iGap.module.dialog.bottomsheet.BottomSheetFragment) OnSetAction(net.iGap.observers.interfaces.OnSetAction) ClipboardManager(android.content.ClipboardManager) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) ProtoUserReport(net.iGap.proto.ProtoUserReport) HelperFragment(net.iGap.helper.HelperFragment) Log(android.util.Log) DataBindingUtil(androidx.databinding.DataBindingUtil) FragmentContactsProfileViewModel(net.iGap.viewmodel.FragmentContactsProfileViewModel) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) HelperCalander(net.iGap.helper.HelperCalander) InputType(android.text.InputType) RealmRoom(net.iGap.realm.RealmRoom) ViewGroup(android.view.ViewGroup) List(java.util.List) Nullable(androidx.annotation.Nullable) HelperPreferences(net.iGap.helper.HelperPreferences) SHP_SETTING(net.iGap.module.SHP_SETTING) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) AlphaAnimation(android.view.animation.AlphaAnimation) CLIPBOARD_SERVICE(android.content.Context.CLIPBOARD_SERVICE) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) NotNull(org.jetbrains.annotations.NotNull) Snackbar(com.google.android.material.snackbar.Snackbar) EmojiManager(net.iGap.libs.emojiKeyboard.emoji.EmojiManager) Config(net.iGap.Config) StructListOfContact(net.iGap.module.structs.StructListOfContact) RequestUserReport(net.iGap.request.RequestUserReport) ActivityMain(net.iGap.activities.ActivityMain) AccountManager(net.iGap.module.accountManager.AccountManager) Intent(android.content.Intent) ArrayList(java.util.ArrayList) ClipData(android.content.ClipData) GoToChatActivity(net.iGap.helper.GoToChatActivity) Toast(android.widget.Toast) RequestUserContactsUnblock(net.iGap.request.RequestUserContactsUnblock) HelperGetAction(net.iGap.helper.HelperGetAction) Cursor(android.database.Cursor) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) RequestUserContactImport(net.iGap.request.RequestUserContactImport) LayoutInflater(android.view.LayoutInflater) DialogAction(com.afollestad.materialdialogs.DialogAction) IOException(java.io.IOException) Contacts.showLimitDialog(net.iGap.module.Contacts.showLimitDialog) TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) CircleImageView(net.iGap.module.CircleImageView) Observer(androidx.lifecycle.Observer) ProtoGlobal(net.iGap.proto.ProtoGlobal) R(net.iGap.R) DbManager(net.iGap.module.accountManager.DbManager) RequestUserContactsBlock(net.iGap.request.RequestUserContactsBlock) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) RequestUserContactsBlock(net.iGap.request.RequestUserContactsBlock) Bundle(android.os.Bundle) RequestUserContactsUnblock(net.iGap.request.RequestUserContactsUnblock) IOException(java.io.IOException) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) ActivityMain(net.iGap.activities.ActivityMain) DialogAction(com.afollestad.materialdialogs.DialogAction) GoToChatActivity(net.iGap.helper.GoToChatActivity) RealmRoom(net.iGap.realm.RealmRoom) HelperFragment(net.iGap.helper.HelperFragment) ClipData(android.content.ClipData)

Example 17 with ParamWithAvatarType

use of net.iGap.helper.avatar.ParamWithAvatarType in project iGap-Android by KianIranian-STDG.

the class EditChannelFragment method receivedEvent.

@Override
public void receivedEvent(int id, int account, Object... args) {
    if (id == EventManager.AVATAR_UPDATE) {
        G.runOnUiThread(() -> {
            viewModel.getShowUploadProgressLiveData().postValue(View.GONE);
            long roomId = (long) args[0];
            if (roomId == this.roomId) {
                avatarHandler.getAvatar(new ParamWithAvatarType(binding.channelAvatar, viewModel.roomId).avatarType(AvatarHandler.AvatarType.ROOM).showMain());
            }
        }, 500);
    } else if (id == EventManager.FILE_UPLOAD_FAILED) {
        String fileId = (String) args[0];
        if (uploadAvatarId != null && uploadAvatarId.equals(fileId)) {
            G.runOnUiThread(() -> viewModel.getShowUploadProgressLiveData().postValue(View.GONE));
        }
    }
}
Also used : HelperString(net.iGap.helper.HelperString) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType)

Example 18 with ParamWithAvatarType

use of net.iGap.helper.avatar.ParamWithAvatarType in project iGap-Android by KianIranian-STDG.

the class FragmentGroupProfile method initComponent.

/**
 * ************************************** methods **************************************
 */
private void initComponent() {
    AppUtils.setProgresColler(binding.loading);
    FragmentShowAvatars.onComplete = new OnComplete() {

        @Override
        public void complete(boolean result, String messageOne, String MessageTwo) {
            long mAvatarId = 0;
            if (messageOne != null && !messageOne.equals("")) {
                mAvatarId = Long.parseLong(messageOne);
            }
            avatarHandler.avatarDelete(new ParamWithAvatarType(imvGroupAvatar, viewModel.roomId).avatarType(AvatarHandler.AvatarType.ROOM), mAvatarId);
        }
    };
    showAvatar();
}
Also used : OnComplete(net.iGap.observers.interfaces.OnComplete) HelperString(net.iGap.helper.HelperString) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType)

Example 19 with ParamWithAvatarType

use of net.iGap.helper.avatar.ParamWithAvatarType in project iGap-Android by KianIranian-STDG.

the class FragmentUserProfile 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);
    }
    viewModel.getCloseKeyboard().observe(getViewLifecycleOwner(), aBoolean -> {
        closeKeyboard((binding.getRoot()));
    });
    viewModel.openAccountsDialog.observe(getViewLifecycleOwner(), show -> {
        if (show == null)
            return;
        if (show) {
            openAccountsDialog();
        }
    });
    viewModel.setCurrentFragment.observe(getViewLifecycleOwner(), isEdit -> {
        if (isEdit != null) {
            if (isEdit) {
                getChildFragmentManager().beginTransaction().setReorderingAllowed(true).add(R.id.frame_edit, FragmentEditProfile.class, null).addToBackStack(FragmentEditProfile.class.getName()).commit();
            } else {
                getChildFragmentManager().beginTransaction().setReorderingAllowed(true).replace(R.id.frame_edit, FragmentProfile.class, null).addToBackStack(FragmentProfile.class.getName()).commit();
            }
        }
    });
    viewModel.changeUserProfileWallpaperPath.observe(getViewLifecycleOwner(), path -> {
        if (path != null && new File(path).exists()) {
            ImageLoadingServiceInjector.inject().loadImage(binding.fupBgAvatar, path);
        } else {
            binding.fupBgAvatar.setImageResource(R.drawable.test_bg);
        }
    });
    viewModel.goToShowAvatarPage.observe(getViewLifecycleOwner(), userId -> {
        if (getActivity() != null && userId != null) {
            FragmentShowAvatars fragment = FragmentShowAvatars.newInstance(userId, FragmentShowAvatars.From.setting);
            new HelperFragment(getActivity().getSupportFragmentManager(), fragment).setReplace(false).load();
        }
    });
    viewModel.setUserAvatar.observe(getViewLifecycleOwner(), userId -> {
        if (userId != null) {
            avatarHandler.getAvatar(new ParamWithAvatarType(binding.fupUserImage, userId).avatarType(AvatarHandler.AvatarType.USER).showMain());
        }
    });
    viewModel.deleteAvatar.observe(getViewLifecycleOwner(), deleteAvatarModel -> {
        if (deleteAvatarModel != null) {
            avatarHandler.avatarDelete(new ParamWithAvatarType(binding.fupUserImage, deleteAvatarModel.getUserId()).avatarType(AvatarHandler.AvatarType.USER), deleteAvatarModel.getAvatarId());
        }
    });
    viewModel.setUserAvatarPath.observe(getViewLifecycleOwner(), changeImageModel -> {
        if (changeImageModel != null) {
            if (changeImageModel.getImagePath() == null || !new File(changeImageModel.getImagePath()).exists()) {
                binding.fupUserImage.setImageBitmap(HelperImageBackColor.drawAlphabetOnPicture((int) binding.fupUserImage.getContext().getResources().getDimension(R.dimen.dp100), changeImageModel.getInitials(), changeImageModel.getColor()));
            } else {
                G.imageLoader.displayImage(AndroidUtils.suitablePath(changeImageModel.getImagePath()), binding.fupUserImage);
            }
        }
    });
    viewModel.showDialogChooseImage.observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean != null && aBoolean) {
            startDialog();
        }
    });
    viewModel.showError.observe(getViewLifecycleOwner(), message -> {
        if (message != null) {
            Toast.makeText(getContext(), message, Toast.LENGTH_SHORT).show();
        }
    });
    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.getPopBackStack().observe(getViewLifecycleOwner(), isPopBackStack -> {
        if (isPopBackStack != null && isPopBackStack) {
            getChildFragmentManager().popBackStack();
        }
    });
    viewModel.getCheckClick().observe(getViewLifecycleOwner(), isClick -> {
        if (isClick) {
            viewModel.getToastId().observe(getViewLifecycleOwner(), toastId -> {
                if (toastId != R.string.empty_error_message) {
                    Toast.makeText(getContext(), getResources().getString(toastId), Toast.LENGTH_SHORT).show();
                    viewModel.getToastId().setValue(R.string.empty_error_message);
                }
            });
        }
    });
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) Theme(net.iGap.module.Theme) HelperFragment(net.iGap.helper.HelperFragment) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) AttachFile(net.iGap.module.AttachFile) File(java.io.File) Fragment(androidx.fragment.app.Fragment) HelperFragment(net.iGap.helper.HelperFragment)

Example 20 with ParamWithAvatarType

use of net.iGap.helper.avatar.ParamWithAvatarType in project iGap-Android by KianIranian-STDG.

the class AbstractMessage method bindView.

@Override
@CallSuper
public void bindView(final VH holder, List<Object> payloads) {
    super.bindView(holder, payloads);
    if (messageObject == null) {
        return;
    }
    NewChatItemHolder mHolder;
    if (holder instanceof NewChatItemHolder) {
        mHolder = (NewChatItemHolder) holder;
    } else if (holder instanceof LogItem.ViewHolder || holder instanceof LogWalletCardToCard.ViewHolder || holder instanceof LogWalletBill.ViewHolder || holder instanceof LogWalletTopup.ViewHolder || holder instanceof LogWallet.ViewHolder) {
        messageClickListener.onItemShowingMessageId(messageObject);
        return;
    } else {
        return;
    }
    this.holder = holder;
    if (messageObject.forwardedMessage == null && messageObject.isSenderMe() && attachment != null && messageObject.status == MessageObject.STATUS_SENDING) {
        EventManager.getInstance(currentAccount).addObserver(EventManager.ON_UPLOAD_PROGRESS, this);
        EventManager.getInstance(currentAccount).addObserver(EventManager.ON_UPLOAD_COMPRESS, this);
        if (!Uploader.getInstance().isCompressingOrUploading(messageObject.id + "")) {
            // TODO: 12/29/20 MESSAGE_REFACTOR
            UploadObject fileObject = UploadObject.createForMessage(messageObject, type);
            if (fileObject != null) {
                Uploader.getInstance().upload(fileObject);
            }
        } else {
            MessageProgress messageProgress = ((IProgress) holder).getProgress();
            int progress = Uploader.getInstance().getUploadProgress(messageObject.id + "");
            messageProgress.withProgress(progress);
            receivedEvent(EventManager.ON_UPLOAD_PROGRESS, AccountManager.selectedAccount, String.valueOf(messageObject.id), progress);
        }
    } else {
        EventManager.getInstance(currentAccount).removeObserver(EventManager.ON_UPLOAD_PROGRESS, this);
        EventManager.getInstance(currentAccount).removeObserver(EventManager.ON_UPLOAD_COMPRESS, this);
    }
    if (attachment != null) {
        EventManager.getInstance(currentAccount).addObserver(EventManager.ON_UPLOAD_COMPRESS, this);
        EventManager.getInstance(currentAccount).addObserver(EventManager.ON_UPLOAD_COMPLETED, this);
        EventManager.getInstance(currentAccount).addObserver(EventManager.ON_FILE_DOWNLOAD_COMPLETED, this);
    }
    // TODO: 12/29/20 MESSAGE_REFACTOR
    mHolder.getItemContainer().setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            OnClickRow(mHolder, view);
        }
    });
    holder.itemView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            OnClickRow(mHolder, view);
        }
    });
    if (holder instanceof CardToCardItem.ViewHolder) {
        CardToCardItem.ViewHolder cardToCardHolder = (CardToCardItem.ViewHolder) holder;
        cardToCardHolder.getRootView().setMinWidth(G.maxChatBox - i_Dp(R.dimen.dp100));
        cardToCardHolder.getInnerLayout().setMinimumWidth(G.maxChatBox - i_Dp(R.dimen.dp100));
        if (messageObject.forwardedMessage == null && messageObject.additionalData != null && messageObject.additionalType == AdditionalType.CARD_TO_CARD_MESSAGE) {
            CardToCardValue value = new CardToCardValue();
            try {
                JSONArray rootJsonArray = new JSONArray(messageObject.additionalData);
                for (int i = 0; i < rootJsonArray.length(); i++) {
                    JSONArray valuJsonArray = rootJsonArray.getJSONArray(i);
                    for (int j = 0; j < valuJsonArray.length(); j++) {
                        JSONObject rootJsonObject = new JSONObject(valuJsonArray.getJSONObject(i).toString());
                        JSONObject valueObject = rootJsonObject.getJSONObject("value");
                        String cardNumber = valueObject.getString("cardNumber");
                        int amount = valueObject.getInt("amount");
                        long userId = valueObject.getLong("userId");
                        value.setAmount(amount);
                        value.setCardNumber(cardNumber);
                        value.setUserId(userId);
                    }
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
            cardToCardHolder.setValue(value);
        }
        cardToCardHolder.setOnCardToCard(cardToCard -> {
            CardToCardHelper.NewCallCardToCard(G.currentActivity, cardToCard.getUserId(), cardToCard.getAmount(), cardToCard.getCardNumber());
        });
    }
    if (holder instanceof ChatItemWithTextHolder) {
        ChatItemWithTextHolder withTextHolder = (ChatItemWithTextHolder) holder;
        // withTextHolder.messageView.setHasEmoji(structMessage.hasEmojiInText());
        int maxsize = 0;
        withTextHolder.removeButtonLayout();
        if ((type == ProtoGlobal.Room.Type.CHANNEL) || (type == ProtoGlobal.Room.Type.CHAT) && messageObject.forwardedMessage != null) {
            maxsize = G.maxChatBox - 16;
        }
        if (maxsize > 0)
            withTextHolder.messageView.setMaxWidth(maxsize);
        if (messageObject.hasLink) {
            try {
                BetterLinkMovementMethod.linkify(Linkify.ALL, withTextHolder.messageView).setOnLinkClickListener((tv, url) -> {
                    return FragmentChat.isInSelectionMode;
                }).setOnLinkLongClickListener((tv, url) -> {
                    if (!FragmentChat.isInSelectionMode) {
                        if (HelperUrl.isTextLink(url)) {
                            G.isLinkClicked = true;
                            messageClickListener.onOpenLinkDialog(url);
                        }
                    }
                    return true;
                });
            } catch (AndroidRuntimeException runtimeException) {
                /**
                 *this try-catch added to fixing bug following bug:
                 * this bug happens because the "Android System WebView" started being
                 * installed as its own application from Android 5.0 and greater and this
                 * code happens to be running while "Android System WebView" is being updated.
                 * While its being updated the package doesn't exist so it causes this exception
                 */
                Toast.makeText(context, R.string.please_try_again, Toast.LENGTH_LONG).show();
            }
        } else {
        // remove BetterLinkMovementMethod
        }
        try {
            if (messageObject.forwardedMessage == null && messageObject.additionalData != null && messageObject.additionalType == AdditionalType.UNDER_MESSAGE_BUTTON) {
                HashMap<Integer, JSONArray> buttonList = MakeButtons.parseData(messageObject.additionalData);
                int rowSize = buttonList.size();
                for (int i = 0; i < rowSize; i++) {
                    int columSize = buttonList.get(i).length();
                    LinearLayout childLayout = MakeButtons.createLayout(((ChatItemWithTextHolder) holder).getContext());
                    for (int j = 0; j < columSize; j++) {
                        ButtonEntity buttonEntity = new Gson().fromJson(buttonList.get(i).get(j).toString(), ButtonEntity.class);
                        buttonEntity.setJsonObject(buttonList.get(i).get(j).toString());
                        childLayout = MakeButtons.addButtons(theme, buttonEntity, buttonList.get(i).length(), 1f, childLayout, (view, btnEntity) -> {
                            if (FragmentChat.isInSelectionMode) {
                                holder.itemView.performLongClick();
                                return;
                            }
                            mAdapter.onBotButtonClicked(() -> onBotBtnClick(view, btnEntity));
                        });
                    }
                    withTextHolder.addButtonLayout(childLayout);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        ((LinearLayout.LayoutParams) ((LinearLayout) withTextHolder.messageView.getParent()).getLayoutParams()).gravity = AndroidUtils.isTextRtl(messageObject.forwardedMessage != null ? messageObject.forwardedMessage.message : messageObject.message) ? Gravity.RIGHT : Gravity.LEFT;
    }
    /**
     * for return message that start showing to view
     */
    messageClickListener.onItemShowingMessageId(messageObject);
    if (isSelected() || messageObject.isSelected) {
        ((FrameLayout) holder.itemView).setForeground(new ColorDrawable(G.context.getResources().getColor(R.color.colorChatMessageSelectableItemBg)));
    } else {
        ((FrameLayout) holder.itemView).setForeground(new ColorDrawable(Color.TRANSPARENT));
    }
    /**
     * only will be called when message layout is directional-base (e.g. single chat)
     */
    if (directionalBased) {
        if (!messageObject.isSenderMe() || type == ProtoGlobal.Room.Type.CHANNEL) {
            updateLayoutForReceive(holder);
        } else if (messageObject.isSenderMe()) {
            updateLayoutForSend(holder);
        }
    }
    if (!messageObject.isTimeOrLogMessage()) {
        /**
         * check failed state ,because if is failed we want show to user even is in channel
         */
        if (mAdapter.getRealmRoom() != null && mAdapter.getRealmRoom().isValid() && mAdapter.getRealmRoom().getType() == ProtoGlobal.Room.Type.CHANNEL && ProtoGlobal.RoomMessageStatus.FAILED != ProtoGlobal.RoomMessageStatus.valueOf(messageObject.status)) {
            mHolder.getMessageStatusTv().setVisibility(View.GONE);
        } else {
            mHolder.getMessageStatusTv().setVisibility(View.VISIBLE);
            AppUtils.rightMessageStatus(mHolder.getMessageStatusTv(), ProtoGlobal.RoomMessageStatus.forNumber(messageObject.status), ProtoGlobal.RoomMessageType.forNumber(messageObject.forwardedMessage != null ? messageObject.forwardedMessage.messageType : messageObject.messageType), messageObject.isSenderMe());
        }
    }
    if (// TODO: 12/29/20 MESSAGE_REFACTOR
    messageObject.edited)
        if (messageObject.channelExtra != null && messageObject.channelExtra.getSignature() != null && messageObject.forwardedMessage.channelExtra.getSignature().length() > 0)
            mHolder.getSignatureTv().setText(mHolder.getResources().getString(R.string.edited) + " " + messageObject.forwardedMessage.channelExtra.getSignature());
        else {
            mHolder.getSignatureTv().setText(mHolder.getResources().getString(R.string.edited));
        }
    else
        mHolder.getSignatureTv().setText("");
    /**
     * display user avatar only if chat type is GROUP
     */
    View messageSenderAvatar = mHolder.getItemContainer().findViewById(R.id.messageSenderAvatar);
    if (messageSenderAvatar != null) {
        messageSenderAvatar.setVisibility(View.GONE);
    }
    replyMessageIfNeeded(holder);
    forwardMessageIfNeeded(holder);
    View messageSenderName = mHolder.getContentBloke().findViewById(R.id.messageSenderName);
    if (messageSenderName != null) {
        messageSenderName.setVisibility(View.GONE);
    }
    if (type == ProtoGlobal.Room.Type.GROUP) {
        if (!messageObject.isSenderMe()) {
            addSenderNameToGroupIfNeed(mHolder);
            if (messageSenderAvatar == null) {
                messageSenderAvatar = ViewMaker.makeCircleImageView();
                mHolder.getItemContainer().addView(messageSenderAvatar, 0);
            }
            messageSenderAvatar.setVisibility(View.VISIBLE);
            messageSenderAvatar.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (FragmentChat.isInSelectionMode) {
                        holder.itemView.performLongClick();
                        return;
                    }
                    messageClickListener.onSenderAvatarClick(v, messageObject, holder.getAdapterPosition());
                }
            });
            messageSenderAvatar.setOnLongClickListener(getLongClickPerform(holder));
            final ImageView copyMessageSenderAvatar = (ImageView) messageSenderAvatar;
            mAdapter.avatarHandler.getAvatar(new ParamWithAvatarType(copyMessageSenderAvatar, messageObject.userId).avatarType(AvatarHandler.AvatarType.USER));
        }
    } else {
        FrameLayout forwardContainer = mHolder.getItemContainer().findViewById(R.id.messageForwardContainer);
        ContextThemeWrapper wrapper = new ContextThemeWrapper(holder.itemView.getContext(), Theme.getInstance().getTheme(holder.itemView.getContext()));
        if (forwardContainer == null) {
            forwardContainer = new FrameLayout(holder.itemView.getContext());
            forwardContainer.setId(R.id.messageForwardContainer);
            if (mAdapter.getRealmRoom() != null && mAdapter.getRealmRoom().getChatRoom() != null && mAdapter.getRealmRoom().getChatRoom().getPeerId() == AccountManager.getInstance().getCurrentUser().getId()) {
                mHolder.getItemContainer().addView(forwardContainer, 0, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.MATCH_PARENT, Gravity.BOTTOM));
            } else {
                mHolder.getItemContainer().addView(forwardContainer, 1, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.MATCH_PARENT, Gravity.BOTTOM));
            }
            forwardContainer.addView(mHolder.getChannelForwardIv(), LayoutCreator.createFrame(26, 26, Gravity.BOTTOM, 4, 4, 8, 4));
            forwardContainer.setVisibility(View.GONE);
        }
        if (type == ProtoGlobal.Room.Type.CHANNEL) {
            mHolder.getChannelForwardIv().setImageDrawable(VectorDrawableCompat.create(holder.itemView.getContext().getResources(), R.drawable.ic_channel_forward_light, wrapper.getTheme()));
            forwardContainer.setVisibility(View.VISIBLE);
            mHolder.getChannelForwardIv().setOnClickListener(v -> {
                if (isAllowToForward(messageObject))
                    messageClickListener.onForwardClick(messageObject);
            });
        }
        if (type == ProtoGlobal.Room.Type.CHAT && mAdapter.getRealmRoom().getChatRoom() != null && mAdapter.getRealmRoom().getChatRoom().getPeerId() == AccountManager.getInstance().getCurrentUser().getId() && !messageObject.isGiftSticker()) {
            mHolder.getChannelForwardIv().setImageDrawable(VectorDrawableCompat.create(holder.itemView.getContext().getResources(), R.drawable.ic_cloud_forward, wrapper.getTheme()));
            forwardContainer.setVisibility(View.VISIBLE);
            mHolder.getChannelForwardIv().setOnClickListener(v -> {
                if (isAllowToForward(messageObject))
                    messageClickListener.onForwardFromCloudClick(messageObject);
            });
        }
    }
    /**
     * set message time
     */
    String time = HelperCalander.getClocktime(messageObject.createTime, false);
    if (HelperCalander.isPersianUnicode) {
        mHolder.getMessageTimeTv().setText(HelperCalander.convertToUnicodeFarsiNumber(time));
    } else {
        mHolder.getMessageTimeTv().setText(time);
    }
    prepareAttachmentIfNeeded(holder, messageObject.forwardedMessage != null ? messageObject.forwardedMessage.messageType : messageObject.messageType);
    /**
     * show vote layout for channel otherwise hide layout also get message state for channel
     */
    mHolder.getVoteContainer().setVisibility(View.GONE);
    mHolder.getViewContainer().setVisibility(View.GONE);
    if (!(holder instanceof StickerItem.ViewHolder)) {
        if ((type == ProtoGlobal.Room.Type.CHANNEL)) {
            showSeenContainer(holder);
        }
    }
    // TODO: 12/29/20 MESSAGE_REFACTOR
    if (messageObject.channelExtra != null && messageObject.channelExtra.getSignature() != null && messageObject.channelExtra.getSignature().length() > 0) {
        mHolder.getContentBloke().setMinimumWidth(LayoutCreator.dp(200));
    } else if (messageObject.edited) {
        mHolder.getContentBloke().setMinimumWidth(LayoutCreator.dp(100));
    }
}
Also used : NonNull(androidx.annotation.NonNull) FileLog(net.iGap.helper.FileLog) UploadObject(net.iGap.module.upload.UploadObject) ProtoFileDownload(net.iGap.proto.ProtoFileDownload) IMAGE_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.IMAGE_VALUE) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) VectorDrawableCompat(androidx.vectordrawable.graphics.drawable.VectorDrawableCompat) ReserveSpaceRoundedImageView(net.iGap.module.ReserveSpaceRoundedImageView) JSONException(org.json.JSONException) AdditionalType(net.iGap.module.additionalData.AdditionalType) HelperError(net.iGap.helper.HelperError) HelperFragment(net.iGap.helper.HelperFragment) Log(android.util.Log) ArrayMap(androidx.collection.ArrayMap) Realm(io.realm.Realm) HelperCalander(net.iGap.helper.HelperCalander) ChatSendMessageUtil(net.iGap.module.ChatSendMessageUtil) RealmRoom(net.iGap.realm.RealmRoom) Downloader(net.iGap.module.downloader.Downloader) Uploader(net.iGap.module.upload.Uploader) ViewMaker.i_Dp(net.iGap.adapter.items.chat.ViewMaker.i_Dp) Tuple(net.iGap.libs.Tuple) SHP_SETTING(net.iGap.module.SHP_SETTING) G.context(net.iGap.G.context) OnProgressUpdate(net.iGap.observers.interfaces.OnProgressUpdate) ReserveSpaceGifImageView(net.iGap.module.ReserveSpaceGifImageView) EventManager(net.iGap.observers.eventbus.EventManager) DownloadObject(net.iGap.module.downloader.DownloadObject) EmojiManager(net.iGap.libs.emojiKeyboard.emoji.EmojiManager) AttachmentObject(net.iGap.structs.AttachmentObject) HelperUrl(net.iGap.helper.HelperUrl) AbstractItem(com.mikepenz.fastadapter.items.AbstractItem) AccountManager(net.iGap.module.accountManager.AccountManager) ArrayList(java.util.ArrayList) OnMessageProgressClick(net.iGap.messageprogress.OnMessageProgressClick) ButtonActionType(net.iGap.module.additionalData.ButtonActionType) Toast(android.widget.Toast) LayoutCreator(net.iGap.helper.LayoutCreator) IMAGE_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.IMAGE_TEXT_VALUE) HelperCheckInternetConnection(net.iGap.helper.HelperCheckInternetConnection) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) AUDIO(net.iGap.proto.ProtoGlobal.RoomMessageType.AUDIO) SpannableString(android.text.SpannableString) MessageObject(net.iGap.structs.MessageObject) StyleSpan(android.text.style.StyleSpan) TextUtils(android.text.TextUtils) CallSuper(androidx.annotation.CallSuper) File(java.io.File) ContextThemeWrapper(androidx.appcompat.view.ContextThemeWrapper) CardToCardHelper(net.iGap.helper.CardToCardHelper) Gravity(android.view.Gravity) SharedPreferences(android.content.SharedPreferences) AUDIO_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.AUDIO_VALUE) BetterLinkMovementMethod(me.saket.bettermovementmethod.BetterLinkMovementMethod) DbManager(net.iGap.module.accountManager.DbManager) FILE_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.FILE_TEXT_VALUE) LinearLayout(android.widget.LinearLayout) AppUtils(net.iGap.module.AppUtils) Spannable(android.text.Spannable) Theme(net.iGap.module.Theme) MessageProgress(net.iGap.messageprogress.MessageProgress) GIF_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.GIF_VALUE) G(net.iGap.G) LocalFileType(net.iGap.module.enums.LocalFileType) AndroidRuntimeException(android.util.AndroidRuntimeException) RealmUserInfo(net.iGap.realm.RealmUserInfo) JSONObject(org.json.JSONObject) AUDIO_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.AUDIO_TEXT_VALUE) IMessageItem(net.iGap.observers.interfaces.IMessageItem) Gson(com.google.gson.Gson) Locale(java.util.Locale) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) VIDEO_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.VIDEO_VALUE) MessagesAdapter(net.iGap.adapter.MessagesAdapter) FILE_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.FILE_VALUE) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) OnProgress(net.iGap.messageprogress.OnProgress) ViewGroup(android.view.ViewGroup) GIF_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.GIF_TEXT_VALUE) List(java.util.List) TextView(android.widget.TextView) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) MusicPlayer(net.iGap.module.MusicPlayer) G.isLocationFromBot(net.iGap.G.isLocationFromBot) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Typeface(android.graphics.Typeface) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) Context(android.content.Context) AndroidUtils(net.iGap.module.AndroidUtils) ResourcesCompat(androidx.core.content.res.ResourcesCompat) HelperGetMessageState(net.iGap.helper.HelperGetMessageState) MakeButtons(net.iGap.module.MakeButtons) HashMap(java.util.HashMap) Linkify(android.text.util.Linkify) TimeUtils(net.iGap.module.TimeUtils) AdditionalObject(net.iGap.structs.AdditionalObject) FragmentChat(net.iGap.fragments.FragmentChat) MODE_PRIVATE(android.content.Context.MODE_PRIVATE) RealmRoomMessage(net.iGap.realm.RealmRoomMessage) RealmAdditional(net.iGap.realm.RealmAdditional) HelperDownloadFile(net.iGap.helper.HelperDownloadFile) CardToCardValue(net.iGap.model.CardToCardValue) VOICE(net.iGap.proto.ProtoGlobal.RoomMessageType.VOICE) AUDIO_TEXT(net.iGap.proto.ProtoGlobal.RoomMessageType.AUDIO_TEXT) DialogAction(com.afollestad.materialdialogs.DialogAction) FragmentPaymentBill(net.iGap.fragments.FragmentPaymentBill) RequestManager(net.iGap.network.RequestManager) Color(android.graphics.Color) CountDownTimer(android.os.CountDownTimer) ButtonEntity(net.iGap.module.additionalData.ButtonEntity) ProtoGlobal(net.iGap.proto.ProtoGlobal) VIDEO_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.VIDEO_TEXT_VALUE) VOICE_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.VOICE_VALUE) R(net.iGap.R) JSONArray(org.json.JSONArray) Gson(com.google.gson.Gson) SpannableString(android.text.SpannableString) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) CardToCardValue(net.iGap.model.CardToCardValue) AndroidRuntimeException(android.util.AndroidRuntimeException) UploadObject(net.iGap.module.upload.UploadObject) ImageView(android.widget.ImageView) ReserveSpaceRoundedImageView(net.iGap.module.ReserveSpaceRoundedImageView) ReserveSpaceGifImageView(net.iGap.module.ReserveSpaceGifImageView) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) ImageView(android.widget.ImageView) ReserveSpaceRoundedImageView(net.iGap.module.ReserveSpaceRoundedImageView) ReserveSpaceGifImageView(net.iGap.module.ReserveSpaceGifImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) JSONException(org.json.JSONException) AndroidRuntimeException(android.util.AndroidRuntimeException) JSONObject(org.json.JSONObject) ColorDrawable(android.graphics.drawable.ColorDrawable) ContextThemeWrapper(androidx.appcompat.view.ContextThemeWrapper) FrameLayout(android.widget.FrameLayout) ButtonEntity(net.iGap.module.additionalData.ButtonEntity) LinearLayout(android.widget.LinearLayout) MessageProgress(net.iGap.messageprogress.MessageProgress) CallSuper(androidx.annotation.CallSuper)

Aggregations

ParamWithAvatarType (net.iGap.helper.avatar.ParamWithAvatarType)23 AvatarHandler (net.iGap.helper.avatar.AvatarHandler)10 View (android.view.View)9 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)8 HelperFragment (net.iGap.helper.HelperFragment)8 Theme (net.iGap.module.Theme)8 TextView (android.widget.TextView)7 NonNull (androidx.annotation.NonNull)7 Bundle (android.os.Bundle)6 Nullable (androidx.annotation.Nullable)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 G (net.iGap.G)6 R (net.iGap.R)6 CircleImageView (net.iGap.module.CircleImageView)6 DbManager (net.iGap.module.accountManager.DbManager)6 Gravity (android.view.Gravity)5 ViewGroup (android.view.ViewGroup)5 FrameLayout (android.widget.FrameLayout)5 Toast (android.widget.Toast)5