use of net.iGap.module.structs.StructBottomSheet in project iGap-Android by KianIranian-STDG.
the class CameraStoryFragment method showCamera.
private void showCamera() {
AttachFile.getAllShownImagesPath(getActivity(), 1, new ChatAttachmentPopup.OnImagesGalleryPrepared() {
@Override
public void imagesList(ArrayList<StructBottomSheet> listOfAllImages) {
G.runOnUiThread(new Runnable() {
@Override
public void run() {
if (listOfAllImages != null && listOfAllImages.size() > 0) {
Glide.with(getContext()).asDrawable().load(new File(listOfAllImages.get(0).getPath())).centerCrop().into(galleryIcon);
}
// ImageLoadingServiceInjector.inject().loadImage(galleryIcon, listOfAllImages.get(0).getPath(), true);
}
});
}
});
if (cameraView == null) {
cameraView = new CameraView(getActivity(), true);
}
cameraView.setDelegate(new CameraView.CameraViewDelegate() {
@Override
public void onCameraCreated(Camera camera) {
Log.e("dfdfsdfgds", "onCameraCreated: ");
}
@Override
public void onCameraInit() {
checkFlashMode();
Log.e("dfdfsdfgds", "onCameraCreated: ");
}
});
cameraView.initCamera();
cameraView.setFocusable(true);
}
use of net.iGap.module.structs.StructBottomSheet in project iGap-Android by KianIranian-STDG.
the class PhotoViewer method serFilterImage.
private void serFilterImage(String path) {
int po = (viewPager.getCurrentItem());
if (textImageList.containsKey(itemGalleryList.get(po).getPath())) {
String message = textImageList.get(itemGalleryList.get(po).getPath()).getText();
int id = textImageList.get(itemGalleryList.get(po).getPath()).getId();
textImageList.remove(itemGalleryList.get(po).getPath());
StructBottomSheet item = new StructBottomSheet();
item.setPath(path);
item.setText(message);
item.setId(id);
textImageList.put(path, item);
}
itemGalleryList.get(po).setPath(path);
}
use of net.iGap.module.structs.StructBottomSheet in project iGap-Android by KianIranian-STDG.
the class PhotoViewer method setCreatedFinalBitmap.
private void setCreatedFinalBitmap(String path) {
if (counter < itemGalleryList.size() && textImageList.containsKey(itemGalleryList.get(counter).getPath())) {
String message = textImageList.get(itemGalleryList.get(counter).getPath()).getText();
int id = textImageList.get(itemGalleryList.get(counter).getPath()).getId();
textImageList.remove(itemGalleryList.get(counter).getPath());
StructBottomSheet item = new StructBottomSheet();
item.setPath(path);
item.setText(message);
item.setId(id);
textImageList.put(path, item);
}
itemGalleryList.get(counter).setPath(path);
finalBitmapsPaths.add(path);
counter++;
if (counter == itemGalleryList.size()) {
if (isForRoom && listMode == 0) {
new HelperFragment(getActivity().getSupportFragmentManager(), PhotoViewer.this).popBackStack(2);
new HelperFragment(getActivity().getSupportFragmentManager(), new MyStatusStoryListFragment(finalBitmapsPaths, itemGalleryList, roomId, 0, roomTitle)).setReplace(false).load();
} else if (isForRoom && listMode == 1) {
new HelperFragment(getActivity().getSupportFragmentManager(), PhotoViewer.this).popBackStack(2);
EventManager.getInstance(AccountManager.selectedAccount).postEvent(EventManager.STORY_ROOM_IMAGE_UPLOAD, finalBitmapsPaths, itemGalleryList, roomId, 1, roomTitle);
} else {
EventManager.getInstance(AccountManager.selectedAccount).postEvent(EventManager.STORY_UPLOAD, finalBitmapsPaths, itemGalleryList, isForRoom, roomId, listMode, roomTitle);
new HelperFragment(getActivity().getSupportFragmentManager(), PhotoViewer.this).popBackStack(2);
}
}
}
use of net.iGap.module.structs.StructBottomSheet in project iGap-Android by KianIranian-STDG.
the class PhotoViewer method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
addedViews = new HashMap<>();
modes = new HashMap<>();
redoViews = new ArrayList<>();
path = getArguments().getString(PATH);
this.isForRoom = getArguments().getBoolean(IS_ROOM, false);
this.roomId = getArguments().getLong(ROOM_ID, 0);
this.listMode = getArguments().getInt(LIST_MODE, 0);
this.roomTitle = getArguments().getString(ROOM_TITLE, "");
selectedPhotos = (List<GalleryItemModel>) getArguments().getSerializable(SELECTED_PHOTOS);
brushConfigDialog = new BrushConfigDialog();
brushConfigDialog.setPropertiesChangeListener(this);
mode = StoryModes.NONE;
modes.put(viewHolderPostion, StoryModes.NONE);
if (!HelperPermission.grantedUseStorage()) {
try {
HelperPermission.getStoragePermission(getContext(), new OnGetPermission() {
@Override
public void Allow() throws IOException {
openPhotoForEdit(path, null, false);
}
@Override
public void deny() {
showDeniedPermissionMessage(G.context.getString(R.string.permission_storage));
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
if (getActivity() != null) {
emojiSharedPreferences = getActivity().getSharedPreferences(SHP_SETTING.EMOJI, MODE_PRIVATE);
}
if (path != null) {
openPhotoForEdit(path, null, false);
} else {
openPhotoForEdit(selectedPhotos, null, false);
for (int i = 0; i < itemGalleryList.size(); i++) {
modes.put(i, StoryModes.NONE);
}
}
captionEditText.setListener(new EventEditText.Listener() {
@Override
public void onInternalTouchEvent(MotionEvent event) {
if (!isPopupShowing() && event.getAction() == MotionEvent.ACTION_DOWN) {
showPopUPView(KeyboardView.MODE_KEYBOARD);
}
}
});
addTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showPopUPView(-1);
viewPager.setPagingEnabled(true);
paintTextView.setBackground(null);
textStickersParentView = viewHolders.get(viewHolderPostion).findViewById(R.id.textstickerView);
if (mode == StoryModes.PAINT || mode == StoryModes.ADD_TEXT || mode == StoryModes.EMOJI || mode == StoryModes.FILTER || mode == StoryModes.CROP) {
textStickersParentView.setPaintMode(false, "");
} else {
textStickersParentView.setPaintMode(false, "");
autoScaleImageToFitBounds();
}
mode = StoryModes.ADD_TEXT;
modes.put(viewHolderPostion, StoryModes.ADD_TEXT);
TextEditorDialogFragment textEditorDialogFragment = TextEditorDialogFragment.newInstance(requireActivity());
textEditorDialogFragment.setOnTextEditorListener((inputText, colorCode, width) -> {
FrameLayout rootView = new FrameLayout(context);
stickerBorder = new FrameLayout(context);
stickerBorder.setPadding(10, 10, 10, 10);
rootView.addView(stickerBorder, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT, Gravity.CENTER, 8, 8, 8, 8));
textTv = new TextView(context);
textTv.setId(R.id.story_added_text);
textTv.setTextColor(colorCode);
textTv.setText(inputText);
textTv.setGravity(Gravity.CENTER);
textTv.setTypeface(ResourcesCompat.getFont(context, R.font.main_font_bold));
textTv.setTextSize(30);
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(textTv, 22, 30, 1, TypedValue.COMPLEX_UNIT_DIP);
stickerBorder.addView(textTv, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER, 14, 14, 14, 14));
onEditActions.addText(rootView, inputText, colorCode);
});
}
});
paintTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showPopUPView(-1);
viewPager.setPagingEnabled(false);
textStickersParentView = viewHolders.get(viewHolderPostion).findViewById(R.id.textstickerView);
if (mode == StoryModes.PAINT || mode == StoryModes.ADD_TEXT || mode == StoryModes.EMOJI || mode == StoryModes.FILTER || mode == StoryModes.CROP) {
textStickersParentView.setPaintMode(true, "");
} else {
textStickersParentView.setPaintMode(true, "");
}
mode = StoryModes.PAINT;
modes.put(viewHolderPostion, StoryModes.PAINT);
textStickersParentView.getmBrushDrawingView().setBrushViewChangeListener(PhotoViewer.this);
String tag = brushConfigDialog.getTag();
// Avoid IllegalStateException "Fragment already added"
if (brushConfigDialog.isAdded())
return;
brushConfigDialog.setBrushColor(brushColor);
brushConfigDialog.setBrushOpacity(opacitySize);
brushConfigDialog.setBrushSize(brushSize);
brushConfigDialog.show(getParentFragmentManager(), tag);
onEditActions.paint();
updateBrushParams();
}
});
revertTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
textStickersParentView = viewHolders.get(viewHolderPostion).findViewById(R.id.textstickerView);
boolean revert = undo();
if (addedViews.get(viewHolderPostion).size() == 0) {
paintTextView.setBackground(null);
}
revertTextView.setVisibility(addedViews.get(viewHolderPostion).size() > 0 ? View.VISIBLE : View.GONE);
}
});
rippleView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
closeKeyboard();
if (getActivity() != null) {
new HelperFragment(getParentFragmentManager(), PhotoViewer.this).remove();
}
}
});
emoji.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showPopUPView(-1);
paintTextView.setBackground(null);
viewPager.setPagingEnabled(true);
textStickersParentView = viewHolders.get(viewHolderPostion).findViewById(R.id.textstickerView);
if (mode == StoryModes.PAINT) {
textStickersParentView.setPaintMode(false, "");
} else if (mode == StoryModes.ADD_TEXT) {
textStickersParentView.setPaintMode(false, "");
} else {
textStickersParentView.setPaintMode(false, "");
}
mode = StoryModes.EMOJI;
modes.put(viewHolderPostion, StoryModes.EMOJI);
EmojiDialogFrag emojiDialogFrag = new EmojiDialogFrag();
emojiDialogFrag.setEmojiListener(PhotoViewer.this::onEmojiClick);
emojiDialogFrag.show(getParentFragmentManager(), emojiDialogFrag.getTag());
onEditActions.emoji();
}
});
editTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showPopUPView(-1);
paintTextView.setBackground(null);
viewPager.setPagingEnabled(true);
mode = StoryModes.FILTER;
modes.put(viewHolderPostion, StoryModes.FILTER);
new HelperFragment(getActivity().getSupportFragmentManager(), FragmentFilterImage.newInstance(itemGalleryList.get(viewHolderPostion).getPath())).setReplace(false).load();
}
});
cropTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showPopUPView(-1);
paintTextView.setBackground(null);
viewPager.setPagingEnabled(true);
mode = StoryModes.CROP;
modes.put(viewHolderPostion, StoryModes.CROP);
goToCropPage(view);
}
});
updateImage = new UpdateImage() {
@Override
public void result(Bitmap finalBitmap) {
textStickersParentView = viewHolders.get(viewHolderPostion).findViewById(R.id.textstickerView);
textStickersParentView.updateImageBitmap(finalBitmap);
}
@Override
public void resultWithPath(String path) {
textStickersParentView = viewHolders.get(viewHolderPostion).findViewById(R.id.textstickerView);
serFilterImage(path);
}
};
pickerViewSendButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
HelperTracker.sendTracker(HelperTracker.TRACKER_MOMENTS_SUBMIT_PICTURE_PAGE);
pickerViewSendButton.setVisibility(View.GONE);
progressBar.setVisibility(VISIBLE);
for (int i = 0; i < itemGalleryList.size(); i++) {
if (viewHolders.get(i) != null) {
reservedView = viewHolders.get(i);
new SaveBitmapAsync(itemGalleryList.get(i).path, null, viewHolders.get(i).findViewById(R.id.textstickerView), modes.get(i)).execute();
} else {
zoomLayout = new ZoomLayout(context);
zoomLayout.measure(View.MeasureSpec.makeMeasureSpec(viewPager.getMeasuredWidth(), View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(viewPager.getMeasuredHeight(), View.MeasureSpec.EXACTLY));
zoomLayout.layout(0, 0, viewPager.getMeasuredWidth(), viewPager.getMeasuredHeight());
textStickersParentView = new TextStickerView(context, false);
textStickersParentView.setId(R.id.textstickerView);
zoomLayout.addView(textStickersParentView);
if (itemGalleryList.get(i).path != null && !viewHolders.containsKey(i)) {
String oldPath = itemGalleryList.get(i).path;
String finalPath = attachFile.saveGalleryPicToLocal(oldPath);
// check if old path available in selected list , replace new path with that
if (!oldPath.equals(finalPath)) {
StructBottomSheet item = textImageList.get(oldPath);
if (item != null) {
textImageList.remove(oldPath);
textImageList.put(finalPath, item);
}
}
itemGalleryList.get(i).path = finalPath;
textStickersParentView.measure(View.MeasureSpec.makeMeasureSpec(viewPager.getMeasuredWidth(), View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(viewPager.getMeasuredHeight(), View.MeasureSpec.EXACTLY));
textStickersParentView.layout(0, 0, viewPager.getMeasuredWidth(), viewPager.getMeasuredHeight());
Palette palette = Palette.from(BitmapFactory.decodeFile(finalPath)).generate();
GradientDrawable gd = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { palette.getLightMutedColor(0xFF616261), palette.getMutedColor(0xFF616261), palette.getDarkMutedColor(0xFF616261) });
textStickersParentView.setBackground(gd);
textStickersParentView.setPaintMode(false, finalPath);
Bitmap b = Bitmap.createBitmap(textStickersParentView.getMeasuredWidth(), textStickersParentView.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
Canvas mCanvas = new Canvas(b);
mCanvas.translate((-textStickersParentView.getScrollX()), (-textStickersParentView.getScrollY()));
textStickersParentView.draw(mCanvas);
new SaveBitmapAsync(itemGalleryList.get(i).path, b, textStickersParentView, modes.get(i)).execute();
}
}
}
}
});
captionEditText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (isPopupShowing()) {
keyboardEmoji.performClick();
}
}
});
keyboardEmoji.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!isPopupShowing()) {
showPopUPView(KeyboardView.MODE_EMOJI);
} else {
showPopUPView(KeyboardView.MODE_KEYBOARD);
}
}
});
captionEditText.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) {
StructBottomSheet item = new StructBottomSheet();
item.setText(s.toString());
item.setPath(itemGalleryList.get(viewHolderPostion).path);
item.setId(itemGalleryList.get(viewHolderPostion).getId());
itemGalleryList.get(viewHolderPostion).setText(s.toString());
textImageList.put(itemGalleryList.get(viewHolderPostion).path, item);
}
});
}
use of net.iGap.module.structs.StructBottomSheet in project iGap-Android by KianIranian-STDG.
the class FragmentEditImage method serCropAndFilterImage.
private void serCropAndFilterImage(String path) {
int po = (viewPager.getCurrentItem());
if (po < itemGalleryList.size() && textImageList.containsKey(itemGalleryList.get(po).getPath())) {
String message = textImageList.get(itemGalleryList.get(po).getPath()).getText();
int id = textImageList.get(itemGalleryList.get(po).getPath()).getId();
textImageList.remove(itemGalleryList.get(po).getPath());
StructBottomSheet item = new StructBottomSheet();
item.setPath(path);
item.setText(message);
item.setId(id);
textImageList.put(path, item);
}
itemGalleryList.get(po).setPath(path);
mAdapter.notifyDataSetChanged();
}
Aggregations