Search in sources :

Example 16 with HelperFragment

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

the class MyStatusStoryListFragment method onClick.

@Override
public void onClick(View view, int position) {
    StoryCell storyCell = (StoryCell) view;
    new HelperFragment(getActivity().getSupportFragmentManager(), new StoryViewFragment(storyCell.getUserId(), storyCell.getRoomId(), true, !storyCell.isRoom(), storyCell.isRoom(), false, storyCell.getStoryId() != 0 ? storyCell.getStoryId() : storyCell.getStoryIndex(), 0)).setReplace(false).load();
}
Also used : StoryCell(net.iGap.story.storyviews.StoryCell) StoryViewFragment(net.iGap.story.viewPager.StoryViewFragment) HelperFragment(net.iGap.helper.HelperFragment)

Example 17 with HelperFragment

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

the class MyStatusStoryListFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    getEventManager().addObserver(EventManager.STORY_LIST_FETCHED, this);
    getEventManager().addObserver(EventManager.STORY_USER_ADD_NEW, this);
    getEventManager().addObserver(EventManager.STORY_USER_ADD_VIEW, this);
    getEventManager().addObserver(EventManager.STORY_DELETED, this);
    getEventManager().addObserver(EventManager.STORY_UPLOADED_FAILED, this);
    getEventManager().addObserver(EventManager.STORY_UPLOAD, this);
    getEventManager().addObserver(EventManager.STORY_SENDING, this);
    getEventManager().addObserver(EventManager.STORY_USER_INFO, this);
    getEventManager().addObserver(EventManager.STORY_STATUS_UPLOAD, this);
    getEventManager().addObserver(EventManager.STORY_ROOM_IMAGE_UPLOAD, this);
    getEventManager().addObserver(EventManager.STORY_ROOM_UPLOAD, this);
    progressBar.setVisibility(View.VISIBLE);
    sendRoomStory();
    loadStories();
    AbstractObject req = null;
    IG_RPC.Story_Get_Own_Story_Views story_get_own_story_views = new IG_RPC.Story_Get_Own_Story_Views();
    story_get_own_story_views.offset = 0;
    story_get_own_story_views.limit = 50;
    req = story_get_own_story_views;
    getRequestManager().sendRequest(req, (response, error) -> {
        if (error == null) {
            IG_RPC.Res_Story_Get_Own_Story_Views res = (IG_RPC.Res_Story_Get_Own_Story_Views) response;
            getMessageDataStorage().updateOwnViews(res.groupedViews);
        // G.runOnUiThread(() -> loadStories());
        } else {
            progressBar.setVisibility(View.GONE);
        }
    });
    floatActionLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (listMode == 1) {
                new HelperFragment(getActivity().getSupportFragmentManager(), new StoryPagerFragment(true, roomId, 1, roomTitle)).setReplace(false).load();
            } else {
                new HelperFragment(getActivity().getSupportFragmentManager(), new StoryPagerFragment(false)).setReplace(false).load();
            }
        }
    });
    customStatusActionLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (listMode == 1) {
                new HelperFragment(getActivity().getSupportFragmentManager(), new StatusTextFragment(true, roomId, 1, roomTitle)).setReplace(false).load();
            } else {
                new HelperFragment(getActivity().getSupportFragmentManager(), new StatusTextFragment(false)).setReplace(false).load();
            }
        }
    });
    mOffset = 0;
    recyclerListView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        private boolean scrollUpdated;

        private boolean scrollingManually;

        private int prevTop;

        private int prevPosition;

        @Override
        public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            scrollingManually = newState == RecyclerView.SCROLL_STATE_DRAGGING;
        }

        @Override
        public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
            firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
            View view = layoutManager.getChildAt(0);
            if (firstVisibleItemPosition > 0 && view != null) {
                firstVisibleItemPositionOffset = view.getTop();
            }
            if (!storyListFetched) {
                if (mOffset > 0) {
                    int lastVisiblePosition = ((LinearLayoutManager) recyclerView.getLayoutManager()).findLastVisibleItemPosition();
                    if (lastVisiblePosition + 10 >= mOffset) {
                    // GetStoryList(mOffset, 50);
                    }
                }
            }
            int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
            if (firstVisibleItem != RecyclerView.NO_POSITION) {
                RecyclerView.ViewHolder holder = recyclerView.findViewHolderForAdapterPosition(firstVisibleItem);
                if (holder != null && holder.getAdapterPosition() != 0) {
                    int firstViewTop = holder.itemView.getTop();
                    boolean goingDown;
                    boolean changed = true;
                    if (prevPosition == firstVisibleItem) {
                        final int topDelta = prevTop - firstViewTop;
                        goingDown = firstViewTop < prevTop;
                        changed = Math.abs(topDelta) > 1;
                    } else {
                        goingDown = firstVisibleItem > prevPosition;
                    }
                    if (changed && scrollUpdated && (goingDown || scrollingManually)) {
                        hideFloatingButton(goingDown);
                    }
                    prevPosition = firstVisibleItem;
                    prevTop = firstViewTop;
                    scrollUpdated = true;
                }
            }
        }
    });
}
Also used : IG_RPC(net.iGap.network.IG_RPC) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RecyclerListView(net.iGap.module.customView.RecyclerListView) IconView(net.iGap.messenger.ui.components.IconView) StatusTextFragment(net.iGap.story.StatusTextFragment) AbstractObject(net.iGap.network.AbstractObject) RecyclerView(androidx.recyclerview.widget.RecyclerView) HelperFragment(net.iGap.helper.HelperFragment) StoryPagerFragment(net.iGap.story.StoryPagerFragment)

Example 18 with HelperFragment

use of net.iGap.helper.HelperFragment 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);
        }
    }
}
Also used : StructBottomSheet(net.iGap.module.structs.StructBottomSheet) HelperFragment(net.iGap.helper.HelperFragment) SuppressLint(android.annotation.SuppressLint) MyStatusStoryListFragment(net.iGap.story.liststories.MyStatusStoryListFragment)

Example 19 with HelperFragment

use of net.iGap.helper.HelperFragment 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);
        }
    });
}
Also used : Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) Drawable(android.graphics.drawable.Drawable) HelperPermission.showDeniedPermissionMessage(net.iGap.helper.HelperPermission.showDeniedPermissionMessage) SaveSettings(net.iGap.libs.photoEdit.SaveSettings) VISIBLE(android.view.View.VISIBLE) Canvas(android.graphics.Canvas) BrushDrawingView(net.iGap.libs.photoEdit.BrushDrawingView) ContextCompat(androidx.core.content.ContextCompat) HelperFragment(net.iGap.helper.HelperFragment) ViewCompat(androidx.core.view.ViewCompat) HelperTracker(net.iGap.helper.HelperTracker) BaseFragment(net.iGap.fragments.BaseFragment) BrushViewChangeListener(net.iGap.libs.photoEdit.BrushViewChangeListener) StringRes(androidx.annotation.StringRes) Nullable(androidx.annotation.Nullable) ConstraintLayout(androidx.constraintlayout.widget.ConstraintLayout) SHP_SETTING(net.iGap.module.SHP_SETTING) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) EventManager(net.iGap.observers.eventbus.EventManager) BitmapUtils(net.iGap.fragments.filterImage.BitmapUtils) TextWatcher(android.text.TextWatcher) EmojiManager(net.iGap.libs.emojiKeyboard.emoji.EmojiManager) FragmentEditImage(net.iGap.fragments.FragmentEditImage) RippleView(net.iGap.libs.rippleeffect.RippleView) Environment(android.os.Environment) AccountManager(net.iGap.module.accountManager.AccountManager) ViewPager(androidx.viewpager.widget.ViewPager) BitmapFactory(android.graphics.BitmapFactory) DrawableCompat(androidx.core.graphics.drawable.DrawableCompat) CropImageView(com.theartofdev.edmodo.cropper.CropImageView) Editable(android.text.Editable) UCrop(com.yalantis.ucrop.UCrop) ArrayList(java.util.ArrayList) CropImage(com.theartofdev.edmodo.cropper.CropImage) GradientDrawable(android.graphics.drawable.GradientDrawable) LayoutCreator(net.iGap.helper.LayoutCreator) FileOutputStream(java.io.FileOutputStream) TextUtils(android.text.TextUtils) IOException(java.io.IOException) File(java.io.File) Gravity(android.view.Gravity) StructIGSticker(net.iGap.fragments.emoji.struct.StructIGSticker) EventEditText(net.iGap.module.customView.EventEditText) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) OnRotateImage(net.iGap.observers.interfaces.OnRotateImage) NotifyFrameLayout(net.iGap.libs.emojiKeyboard.NotifyFrameLayout) TextViewCompat(androidx.core.widget.TextViewCompat) ImageHelper(net.iGap.helper.ImageHelper) LinearLayout(android.widget.LinearLayout) GalleryItemModel(net.iGap.model.GalleryItemModel) AttachFile(net.iGap.module.AttachFile) DrawableRes(androidx.annotation.DrawableRes) G(net.iGap.G) CheckBox(android.widget.CheckBox) HelperPermission(net.iGap.helper.HelperPermission) MyStatusStoryListFragment(net.iGap.story.liststories.MyStatusStoryListFragment) ActivityInfo(android.content.pm.ActivityInfo) ContextThemeWrapper(android.view.ContextThemeWrapper) View(android.view.View) KeyboardView(net.iGap.libs.emojiKeyboard.KeyboardView) RecyclerView(androidx.recyclerview.widget.RecyclerView) AsyncTask(android.os.AsyncTask) ViewGroup(android.view.ViewGroup) List(java.util.List) TextView(android.widget.TextView) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) RelativeLayout(android.widget.RelativeLayout) Toolbar(androidx.appcompat.widget.Toolbar) EditorInfo(android.view.inputmethod.EditorInfo) Typeface(android.graphics.Typeface) MutableLiveData(androidx.lifecycle.MutableLiveData) Context(android.content.Context) AndroidUtils(net.iGap.module.AndroidUtils) KeyEvent(android.view.KeyEvent) ResourcesCompat(androidx.core.content.res.ResourcesCompat) FragmentFilterImage(net.iGap.fragments.filterImage.FragmentFilterImage) RESULT_OK(android.app.Activity.RESULT_OK) PagerAdapter(androidx.viewpager.widget.PagerAdapter) Intent(android.content.Intent) HashMap(java.util.HashMap) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) MODE_PRIVATE(android.content.Context.MODE_PRIVATE) Build(android.os.Build) Palette(androidx.palette.graphics.Palette) EmojiView(net.iGap.libs.emojiKeyboard.EmojiView) LayoutInflater(android.view.LayoutInflater) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) Color(android.graphics.Color) Glide(com.bumptech.glide.Glide) Bitmap(android.graphics.Bitmap) StructBottomSheet(net.iGap.module.structs.StructBottomSheet) ViewTreeObserver(android.view.ViewTreeObserver) R(net.iGap.R) Collections(java.util.Collections) Palette(androidx.palette.graphics.Palette) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) Bitmap(android.graphics.Bitmap) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) GalleryItemModel(net.iGap.model.GalleryItemModel) EventEditText(net.iGap.module.customView.EventEditText) Canvas(android.graphics.Canvas) StructBottomSheet(net.iGap.module.structs.StructBottomSheet) IOException(java.io.IOException) ImageView(android.widget.ImageView) BrushDrawingView(net.iGap.libs.photoEdit.BrushDrawingView) RippleView(net.iGap.libs.rippleeffect.RippleView) CropImageView(com.theartofdev.edmodo.cropper.CropImageView) View(android.view.View) KeyboardView(net.iGap.libs.emojiKeyboard.KeyboardView) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) EmojiView(net.iGap.libs.emojiKeyboard.EmojiView) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) SuppressLint(android.annotation.SuppressLint) GradientDrawable(android.graphics.drawable.GradientDrawable) MotionEvent(android.view.MotionEvent) FrameLayout(android.widget.FrameLayout) NotifyFrameLayout(net.iGap.libs.emojiKeyboard.NotifyFrameLayout) HelperFragment(net.iGap.helper.HelperFragment)

Example 20 with HelperFragment

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

the class StatusTextFragment method writeTextOnDrawable.

private Bitmap writeTextOnDrawable(String text) {
    Rect bounds = new Rect(textLayoutRoot.getLeft(), textLayoutRoot.getTop(), textLayoutRoot.getRight(), textLayoutRoot.getBottom());
    textLayoutRoot.setDrawingCacheEnabled(true);
    Bitmap b = Bitmap.createBitmap(textLayoutRoot.getDrawingCache());
    Bitmap alteredBitmap = b.copy(Bitmap.Config.ARGB_8888, true);
    try {
        String savedPath = G.DIR_TEMP + "/" + System.currentTimeMillis() + "_edited_image.jpg";
        File imageFile = new File(savedPath);
        imageFile.createNewFile();
        File file = new File(imageFile.getAbsolutePath());
        FileOutputStream out = new FileOutputStream(file, false);
        alteredBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
        alteredBitmap = BitmapFactory.decodeFile(imageFile.getAbsolutePath());
        if (getActivity() != null) {
            getActivity().onBackPressed();
        }
        if (isFromRoom && listMode == 0) {
            new HelperFragment(getActivity().getSupportFragmentManager(), new MyStatusStoryListFragment(isFromRoom, imageFile.getAbsolutePath(), roomId, roomTitle, 0)).setReplace(false).load();
        } else if (isFromRoom && listMode == 1) {
            EventManager.getInstance(AccountManager.selectedAccount).postEvent(EventManager.STORY_ROOM_UPLOAD, imageFile.getAbsolutePath(), roomId, roomTitle);
        } else {
            EventManager.getInstance(AccountManager.selectedAccount).postEvent(EventManager.STORY_STATUS_UPLOAD, imageFile.getAbsolutePath(), isFromRoom);
        }
    } catch (Exception e) {
    }
    return alteredBitmap;
}
Also used : Rect(android.graphics.Rect) Bitmap(android.graphics.Bitmap) FileOutputStream(java.io.FileOutputStream) HelperFragment(net.iGap.helper.HelperFragment) File(java.io.File) MyStatusStoryListFragment(net.iGap.story.liststories.MyStatusStoryListFragment)

Aggregations

HelperFragment (net.iGap.helper.HelperFragment)93 Bundle (android.os.Bundle)32 View (android.view.View)31 Fragment (androidx.fragment.app.Fragment)25 IOException (java.io.IOException)18 ArrayList (java.util.ArrayList)15 RecyclerView (androidx.recyclerview.widget.RecyclerView)14 ToolbarListener (net.iGap.observers.interfaces.ToolbarListener)14 ViewGroup (android.view.ViewGroup)13 NonNull (androidx.annotation.NonNull)13 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)13 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)13 Theme (net.iGap.module.Theme)13 R (net.iGap.R)12 OnGetPermission (net.iGap.observers.interfaces.OnGetPermission)12 LayoutInflater (android.view.LayoutInflater)11 TextView (android.widget.TextView)11 Nullable (androidx.annotation.Nullable)11 HelperString (net.iGap.helper.HelperString)10 BackDrawable (net.iGap.messenger.ui.toolBar.BackDrawable)10