irshu355 / Android-WYSIWYG-Editor

:pager: A text editor written in Android using native components in the content tree. Integrate easily to work with web based WYSIWYG's.
http://irshulx.github.io/Android-WYSIWYG-Editor
Apache License 2.0
412 stars 116 forks source link

imagepicker wont work with fragment #11

Open abfist opened 7 years ago

abfist commented 7 years ago

the imagepicker uses startActivityForResult from editorCore which uses the context of the view and therefor the activity. when used inside a fragment the fragment wont recieve the onActivityResult call. i added 2 methods for this :

//my addition for fragment handle
        public void OpenFragmentImagePicker(Fragment fragment) {
            getImageExtensions().OpenFragmentImageGallery(fragment);
        }

/my extention for fragment handling
    public void OpenFragmentImageGallery(Fragment fragment) {
        int Index=this.editorCore.determineIndex(EditorType.none);
        EditorContent state= editorCore.getContent();
        Intent intent = new Intent();
// Show only images, no videos or anything else
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
    // Always show the chooser (if there are multiple options available)
        fragment.startActivityForResult(Intent.createChooser(intent, "Select an image"), editorCore.PICK_IMAGE_REQUEST);
    }

my method is crude and this probably needs to be handled in the project

irshu355 commented 7 years ago

noted @abfist , will release a patch for the Fragment compatibility ASAP.

lovish888 commented 5 years ago

Is it patched?