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);
}
}
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;
}
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;
}
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());
}
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();
}
}
}
});
}
Aggregations