Search in sources :

Example 6 with StructBottomSheet

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

the class FragmentEditImage method setValueCheckBox.

private void setValueCheckBox(int position) {
    if (itemGalleryList.size() != 0) {
        if (checkBox.isChecked()) {
            checkBox.setChecked(false);
            checkBox.setUnCheckColor(G.context.getResources().getColor(R.color.transparent));
            itemGalleryList.get(position).setSelected(true);
            textImageList.remove(itemGalleryList.get(position).path);
        } else {
            checkBox.setChecked(true);
            StructBottomSheet item = new StructBottomSheet();
            item.setText(edtChat.getText().toString());
            item.setPath(itemGalleryList.get(position).path);
            item.setId(itemGalleryList.get(position).getId());
            textImageList.put(itemGalleryList.get(position).path, item);
            checkBox.setUnCheckColor(G.context.getResources().getColor(R.color.setting_items_value_color));
            itemGalleryList.get(position).setSelected(false);
        }
    }
    if (textImageList.size() > 0 && isChatPage) {
        txtCountImage.setVisibility(VISIBLE);
        txtCountImage.setText(textImageList.size() + "");
    } else {
        txtCountImage.setVisibility(View.GONE);
    }
}
Also used : StructBottomSheet(net.iGap.module.structs.StructBottomSheet)

Example 7 with StructBottomSheet

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

the class FragmentEditImage method insertItemList.

public static ArrayList<StructBottomSheet> insertItemList(String path, boolean isSelected, CompleteEditImage completeEdit) {
    if (!HelperPermission.grantedUseStorage()) {
        return itemGalleryList;
    }
    StructBottomSheet item = new StructBottomSheet();
    item.setId(itemGalleryList.size());
    item.setPath(path);
    item.setText("");
    item.isSelected = isSelected;
    itemGalleryList.add(0, item);
    textImageList.put(path, item);
    completeEditImage = completeEdit;
    return itemGalleryList;
}
Also used : StructBottomSheet(net.iGap.module.structs.StructBottomSheet)

Example 8 with StructBottomSheet

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

the class FragmentEditImage method insertItemList.

public static ArrayList<StructBottomSheet> insertItemList(String path, String message, boolean isSelected) {
    if (!HelperPermission.grantedUseStorage()) {
        return itemGalleryList;
    }
    StructBottomSheet item = new StructBottomSheet();
    item.setId(itemGalleryList.size());
    item.setPath(path);
    item.setText(message);
    item.isSelected = isSelected;
    itemGalleryList.add(0, item);
    textImageList.put(path, item);
    return itemGalleryList;
}
Also used : StructBottomSheet(net.iGap.module.structs.StructBottomSheet)

Example 9 with StructBottomSheet

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

the class FragmentEditImage method messageBox.

private void messageBox(final View view) {
    if (textImageList.containsKey(itemGalleryList.get(selectPosition).path)) {
        edtChat.setText(EmojiManager.getInstance().replaceEmoji(textImageList.get(itemGalleryList.get(selectPosition).path).getText(), edtChat.getPaint().getFontMetricsInt()));
    } else {
        edtChat.setText("");
    }
    txtEditImage.setOnClickListener(v -> {
        hideKeyboard();
        if (getActivity() != null && itemGalleryList.size() > 0) {
            if (!isNicknamePage) {
                new HelperFragment(getActivity().getSupportFragmentManager(), FragmentFilterImage.newInstance(itemGalleryList.get(viewPager.getCurrentItem()).path)).setReplace(false).load();
            } else {
                FragmentFilterImage fragment = FragmentFilterImage.newInstance(itemGalleryList.get(viewPager.getCurrentItem()).path);
                getActivity().getSupportFragmentManager().beginTransaction().add(R.id.registrationFrame, fragment).setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left, R.anim.slide_exit_in_right, R.anim.slide_exit_out_left).commitAllowingStateLoss();
            }
        }
    });
    paintTv.setOnClickListener(v -> {
        hideKeyboard();
        if (getActivity() != null && itemGalleryList.size() > 0) {
            String path = itemGalleryList.get(viewPager.getCurrentItem()).path;
            if (path == null || path.isEmpty()) {
                Toast.makeText(getActivity(), R.string.error, Toast.LENGTH_SHORT).show();
                return;
            }
            if (!isNicknamePage) {
                new HelperFragment(getActivity().getSupportFragmentManager(), FragmentPaintImage.newInstance(path)).setReplace(false).load();
            } else {
                FragmentPaintImage fragment = FragmentPaintImage.newInstance(path);
                getActivity().getSupportFragmentManager().beginTransaction().add(R.id.registrationFrame, fragment).setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left, R.anim.slide_exit_in_right, R.anim.slide_exit_out_left).commitAllowingStateLoss();
            }
        }
    });
    iconOk.setOnClickListener(v -> {
        String path = itemGalleryList.get(viewPager.getCurrentItem()).getPath();
        String message = edtChat.getText().toString();
        itemGalleryList.get(viewPager.getCurrentItem()).setSelected(false);
        checkBox.setChecked(true);
        checkBox.setUnCheckColor(G.context.getResources().getColor(R.color.setting_items_value_color));
        StructBottomSheet item = new StructBottomSheet();
        item.setPath(path);
        item.setText(message);
        item.setId(itemGalleryList.get(viewPager.getCurrentItem()).getId());
        textImageList.put(path, item);
        if (textImageList.size() > 0 && isMultiItem) {
            txtCountImage.setVisibility(VISIBLE);
            txtCountImage.setText(textImageList.size() + "");
        } else {
            txtCountImage.setVisibility(View.GONE);
        }
        v.setVisibility(View.GONE);
        showPopup(-1);
    });
    isTheFirstFocus = true;
    edtChat.setOnFocusChangeListener((v, hasFocus) -> {
        if (hasFocus) {
            if (!isTheFirstFocus) {
                changeEmojiButtonImageResource(R.string.icon_emoji_smile);
                onEmojiClicked();
            } else {
                changeEmojiButtonImageResource(R.string.icon_emoji_smile);
            }
        } else {
            isTheFirstFocus = false;
            changeEmojiButtonImageResource(R.string.icon_keyboard);
        }
    });
    edtChat.requestFocus();
    edtChat.setOnClickListener(v -> {
        if (isPopupShowing()) {
            imvSmileButton.performClick();
        }
    });
    edtChat.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) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            String oldPath = "";
            if (textImageList.containsKey(itemGalleryList.get(viewPager.getCurrentItem()).path)) {
                oldPath = textImageList.get(itemGalleryList.get(viewPager.getCurrentItem()).path).getText();
            }
            if (!oldPath.equals(s.toString())) {
                iconOk.setVisibility(VISIBLE);
            } else {
                iconOk.setVisibility(View.GONE);
            }
        }
    });
    imvSmileButton.setOnClickListener(v -> onEmojiClicked());
}
Also used : StructBottomSheet(net.iGap.module.structs.StructBottomSheet) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) FragmentFilterImage(net.iGap.fragments.filterImage.FragmentFilterImage) HelperFragment(net.iGap.helper.HelperFragment) FragmentPaintImage(net.iGap.fragments.filterImage.FragmentPaintImage)

Example 10 with StructBottomSheet

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

the class ChatAttachmentPopup method initViews.

private void initViews(View view) {
    View camera, photo, video, music, file, contact, location;
    View root;
    camera = view.findViewById(R.id.camera);
    photo = view.findViewById(R.id.picture);
    video = view.findViewById(R.id.video);
    music = view.findViewById(R.id.music);
    file = view.findViewById(R.id.file);
    location = view.findViewById(R.id.location);
    contact = view.findViewById(R.id.contact);
    btnSend = view.findViewById(R.id.close);
    icoSend = view.findViewById(R.id.txtSend);
    lblSend = view.findViewById(R.id.txtNumberItem);
    root = view.findViewById(R.id.root);
    root.setOnClickListener(v -> {
        dismiss();
    });
    btnSend.setOnClickListener(v -> {
        if (animation != null)
            animation.cancel();
        if (FragmentEditImage.textImageList.size() > 0) {
            dismiss();
            clearRecyclerAdapter();
            lblSend.setText(mFrgActivity.getString(R.string.icon_close));
            lblSend.setText(mFrgActivity.getString(R.string.navigation_drawer_close));
            mPopupListener.onAttachPopupSendSelected();
        } else {
            dismiss();
        }
    });
    camera.setOnClickListener(v -> {
        dismiss();
        attachFile.showDialogOpenCamera(v, null, mFragment);
    });
    photo.setOnClickListener(v -> {
        dismiss();
        openPhotoGallery();
    });
    video.setOnClickListener(v -> {
        dismiss();
        openVideoGallery();
    });
    music.setOnClickListener(v -> {
        dismiss();
        openMusicGallery();
    });
    file.setOnClickListener(v -> {
        dismiss();
        try {
            attachFile.requestPickFile((selectedPathList, caption) -> {
                mPopupListener.onAttachPopupFilePicked(selectedPathList, caption);
            });
        } catch (IOException e) {
            e.printStackTrace();
        }
    });
    contact.setOnClickListener(v -> {
        dismiss();
        try {
            attachFile.requestPickContact(mFragment);
        } catch (IOException e) {
            e.printStackTrace();
        }
    });
    location.setOnClickListener(v -> {
        dismiss();
        try {
            attachFile.requestGetPosition((result, messageOne, MessageTow) -> {
                mPopupListener.onAttachPopupLocation(messageOne);
            }, mFragment);
        } catch (IOException e) {
            e.printStackTrace();
        }
    });
    // init local pictures
    fastItemAdapter = new FastItemAdapter();
    onClickCamera = () -> {
        try {
            dismiss();
            new AttachFile(mFrgActivity).requestTakePicture(mFragment);
        } catch (IOException e) {
            e.printStackTrace();
        }
    };
    onPathAdapterBottomSheet = (path, isCheck, isEdit, mList, id) -> {
        if (isEdit) {
            dismiss();
            new HelperFragment(mFrgActivity.getSupportFragmentManager(), FragmentEditImage.newInstance(null, true, false, id)).setReplace(false).load();
        } else {
            if (isCheck) {
                StructBottomSheet item = new StructBottomSheet();
                item.setPath(path);
                item.setText("");
                item.setId(id);
                FragmentEditImage.textImageList.put(path, item);
            } else {
                FragmentEditImage.textImageList.remove(path);
            }
            if (FragmentEditImage.textImageList.size() > 0) {
                icoSend.setText(mFrgActivity.getString(R.string.icon_send));
                lblSend.setText("" + FragmentEditImage.textImageList.size() + " " + mFrgActivity.getString(item));
            } else {
                icoSend.setText(mFrgActivity.getString(R.string.icon_close));
                lblSend.setText(mFrgActivity.getString(R.string.navigation_drawer_close));
            }
        }
    };
    mNoCameraPermission = view.findViewById(R.id.no_camera_permission);
    rcvBottomSheet = view.findViewById(R.id.rcvContent);
    rcvBottomSheet.setLayoutManager(new GridLayoutManager(mFrgActivity, 1, GridLayoutManager.HORIZONTAL, false));
    rcvBottomSheet.setAdapter(fastItemAdapter);
    mNoCameraPermission.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                HelperPermission.getCameraPermission(G.fragmentActivity, new OnGetPermission() {

                    @Override
                    public void Allow() throws IOException {
                        mNoCameraPermission.setVisibility(View.GONE);
                        rcvBottomSheet.setVisibility(View.VISIBLE);
                    }

                    @Override
                    public void deny() {
                        HelperPermission.showDeniedPermissionMessage(G.context.getString(R.string.permission_camera));
                    }
                });
            } catch (IOException ioException) {
                ioException.printStackTrace();
            }
        }
    });
    // disable and enable camera when user scroll on recycler view
    rcvBottomSheet.addOnChildAttachStateChangeListener(new RecyclerView.OnChildAttachStateChangeListener() {

        @Override
        public void onChildViewAttachedToWindow(final View view) {
            if (isPermissionCamera) {
                if (rcvBottomSheet.getChildAdapterPosition(view) == 0) {
                    isCameraAttached = true;
                }
                if (isCameraAttached) {
                    enableCamera();
                }
            }
        }

        @Override
        public void onChildViewDetachedFromWindow(final View view) {
            if (isPermissionCamera) {
                if (rcvBottomSheet.getChildAdapterPosition(view) == 0) {
                    isCameraAttached = false;
                }
                if (!isCameraAttached) {
                    disableCamera();
                }
            }
        }
    });
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) FastItemAdapter(com.mikepenz.fastadapter.commons.adapters.FastItemAdapter) AttachFile(net.iGap.module.AttachFile) StructBottomSheet(net.iGap.module.structs.StructBottomSheet) RecyclerView(androidx.recyclerview.widget.RecyclerView) IOException(java.io.IOException) HelperFragment(net.iGap.helper.HelperFragment) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission)

Aggregations

StructBottomSheet (net.iGap.module.structs.StructBottomSheet)19 ArrayList (java.util.ArrayList)8 SuppressLint (android.annotation.SuppressLint)6 HelperFragment (net.iGap.helper.HelperFragment)6 Uri (android.net.Uri)4 View (android.view.View)4 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 IOException (java.io.IOException)4 Cursor (android.database.Cursor)3 Editable (android.text.Editable)3 TextWatcher (android.text.TextWatcher)3 TextView (android.widget.TextView)3 HelperString (net.iGap.helper.HelperString)3 AttachFile (net.iGap.module.AttachFile)3 Canvas (android.graphics.Canvas)2 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)2 File (java.io.File)2 FragmentFilterImage (net.iGap.fragments.filterImage.FragmentFilterImage)2 OnGetPermission (net.iGap.observers.interfaces.OnGetPermission)2 RealmString (net.iGap.realm.RealmString)2