Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images deletion does not work on Android 4.4 #5

Open
sviatoslav opened this issue May 19, 2015 · 11 comments
Open

Images deletion does not work on Android 4.4 #5

sviatoslav opened this issue May 19, 2015 · 11 comments

Comments

@sviatoslav
Copy link

I have tested on Samsung Galaxy 4 and 5 on Android 4.4. And seems like images deletion does not work when you use software backspace button. When you connect hardware keyboard and use it everything works fine.

@tochange
Copy link

Same issue to me, i override onCreateInputConnection() in the RichEditor, it can delete image, but some character can not input from software keyboard.

@sviatoslav
Copy link
Author

@tochange yes, I did the same and had the same issue with characters. For now I added "remove" image to each photo, so user can delete it without backspace. That's not perfect solution but at least it works.

@tochange
Copy link

yeah, that maybe a solution, but i saved the html content in a html file then open it with my browser, i can delete image, is that something wrong in the editor.html or css file?

@sviatoslav
Copy link
Author

The reason is in default input connection of WebView

@senlinxuefeng
Copy link

Same issue to me,how to delete ?

@wujiankun
Copy link

有最新的解决方案了么?

@xiaokc
Copy link

xiaokc commented Oct 14, 2015

Yeah, it seems like images deletion does not work on Android 4.4 :(

How to solve this problem? Any one knows?

@xiaokc
Copy link

xiaokc commented Oct 15, 2015

@tochange Hi, I override onCreateInputConnection() in the RichEditor, too.And I meet the same issue, Chinese character can not be inputed, I do not know why. Have you solve this problem?

@konradrenner
Copy link

Hi, I am the maintainer of the Kolab Notes App. We are using this lib for richtest capabilities, so thank you very much for this project!

Users of our app also reported issues with the Richeditor and image deletion and text selection. It seems that this problems just occur on Cyanogenmod powered devices, as you can read in the issue comments here: konradrenner/kolabnotes-android#128

Maybe this information helps solving the issue. Keep the good work going ;-)

@jelver
Copy link

jelver commented May 24, 2016

FYI, with the follow code,it work for me ! you can have a try ,good luck !
`@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
CustomInputConnection connection = new CustomInputConnection(this, false);
outAttrs.inputType = InputType.TYPE_NULL;
outAttrs.imeOptions = EditorInfo.IME_ACTION_NONE;
outAttrs.initialSelStart = -1;
outAttrs.initialSelEnd = -1;

return connection;

}
public class CustomInputConnection extends BaseInputConnection {

public CustomInputConnection(View targetView, boolean fullEditor) {
    super(targetView, fullEditor);
}
@Override
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
    // magic: in latest Android, deleteSurroundingText(1, 0) will be called for backspace
    if (beforeLength == 1 && afterLength == 0) {
        // backspace
        return super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL))
                && super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DEL));
    }

    return super.deleteSurroundingText(beforeLength, afterLength);
}

}`

@gindoc
Copy link

gindoc commented Apr 22, 2017

i solve the problem like this:
`
@OverRide
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
outAttrs.actionLabel = null;
outAttrs.inputType = InputType.TYPE_NULL;
final InputConnection con = new BaseInputConnection(this, false);
InputConnectionWrapper public_con = new InputConnectionWrapper(
super.onCreateInputConnection(outAttrs), true) {
@OverRide
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
if (beforeLength == 1 && afterLength == 0) {
return this.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL))
&& this.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DEL));
}
return super.deleteSurroundingText(beforeLength, afterLength);
}

        @Override
        public boolean sendKeyEvent(KeyEvent event) {
            if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
                return con.sendKeyEvent(event);
            } else {
                return super.sendKeyEvent(event);
            }
        }
    };
    try {
        return public_con;
    } catch (Exception e) {
        return super.onCreateInputConnection(outAttrs);
    }
}

`

the answer is form stack overflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants