chinalwb / Android-Rich-text-Editor

Android Rich Text Editor With customized spans - 富文本编辑器 - Don't miss this one :)
Apache License 2.0
845 stars 166 forks source link

How to apply multiple style in one word without space? #96

Closed wangxianming315 closed 5 years ago

wangxianming315 commented 5 years ago

For example, I need to implement 2 styles(Bold, Underline) in one word 'HelloWorld' without space. Hello as Bold and World as Underline. Is this possible? I tested your demo app and when I try to click style button, it changes full word(without space) style. I hope to hear feedback from you. Thanks.

chinalwb commented 5 years ago

No problem, what your actions were like? Actually it’s easy. Just select BOLD style then type in HELLO, then unselect BOLD but select UNDERLINE then type in world.

Or you can type in helloworld first then select hello then hit on BOLD, do the same to world part, then I think you’ll get what you want to see.

Try and let me know if it works for you.

Thanks.

wangxianming315 commented 5 years ago

Hello, thanks for your help. The second one works. But the first one doesn't. This is my problem. When I select BOLD and type 'Hello', the 'Hello' is bold. And then unselect BOLD and select UNDERLINE, type 'w' then the 'Hello' is now UNDERLINE not BOLD. So the entire word is now UNDERLINE. I want to apply multiple style while typing without space. Regards.

chinalwb commented 5 years ago

Got it I’ll check and get back to you.

wangxianming315 commented 5 years ago

Were you able to check it?

wangxianming315 commented 5 years ago

Please let me know if you can help me on this. Thanks.

chinalwb commented 5 years ago

Apologize for my late reply

I was busy with working recently hope I can have some time for it tonight.

wangxianming315 commented 5 years ago

Thank you very much.

satapon148 commented 5 years ago

This problem is happen because the style is apply to the whole "word" as I can see it happen when there's any auto complete word when typing. Try separate the word or complete it and edit them later work just fine.

wangxianming315 commented 5 years ago

Hi @satapon148 . thanks for looking into this issue. You are right and the style is applied to whole word. But I need to apply multiple style in one word while typing. Is this not possible?

satapon148 commented 5 years ago

yes it is possible to do that

  1. type the thing you want and accept the auto complete in that onscreen keyboard
  2. now the device/app should see it as just a line of text go ahead and highlight where you need it to be style.
  3. repeat until you get your desire result I belive this issue is coming from android or it's keyboard want to get what you want to type then pass all off it to the app and the app just understand all of it as single text input so they just apply to the whole word. I didn't look into the source code but belive the owner might get an idea what's happening
wangxianming315 commented 5 years ago

Yes. I can get desired result by repeating to apply style to sub-selection of whole text after type full text. But this is not what I want. What I want is, for example in word 'ABC', I want to set 'A' as Bold and 'BC' as normal character. So first I will select Bold style and type 'A', it is ok now. Second I will unselect Bold and type 'B'. then the 'A' is changed to un-bold. This is my problem.

chinalwb commented 5 years ago

@wangxianming315 Sorry I tried but didn't reproduce. What's your phone? Can you try it on the android studio simulator to see if you can reproduce?

chinalwb commented 5 years ago

2019-09-16 21-23-00 2019-09-16 21_23_31

chinalwb commented 5 years ago

Here is another video for helloworld 2019-09-16 21-26-22 2019-09-16 21_26_50

wangxianming315 commented 5 years ago

Wow. This is what I want. My phone is HUAWEI. Let me test again.

chinalwb commented 5 years ago

I also tested on a Mi-5S, works like exactly the same.

chinalwb commented 5 years ago

FYI: I have such code in AREditText.java

this.setInputType(EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE
                | EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
chinalwb commented 5 years ago

@satapon148 Thanks for stepping in. :)

wangxianming315 commented 5 years ago

I have tested Nexus 5X and Pixel 2 simulator. It works on Nexus 5x but not Pixel 2. Do you have any idea about this?

chinalwb commented 5 years ago

Sorry no... I tried on Pixel 2 simulator just now, it works as well.

How about your HUAWEI?

wangxianming315 commented 5 years ago

Then I think this is because I am using old version. Are you testing latest commit?

chinalwb commented 5 years ago

I am testing based on the latest code of master.

wangxianming315 commented 5 years ago

What is the API version of your Pixel 2 simulator? Mine is Android 9, API 28 My HUAWEI phone is Android 8.0, API 26 Nexus 5 simulator is API 25.

chinalwb commented 5 years ago

Pixel 2: API 26 Nexus 5: API 26 MI-5s: API 24

wangxianming315 commented 5 years ago

To test the demo project, should I open the ARE root folder?

chinalwb commented 5 years ago
Screen Shot 2019-09-16 at 10 50 59 PM

Do you mean this?

chinalwb commented 5 years ago

Try using implementation project(':are') instead of implementation 'com.github.chinalwb:are:0.1.6'

chinalwb commented 5 years ago

Hitting the sack.. I'll try to response to you ASAP for your future comments.

Thanks a lot for your interests on ARE.

wangxianming315 commented 5 years ago

Now I am able to run the project.

Ok. thanks for your effort for me. Have a good dream :)

wangxianming315 commented 5 years ago

So in my experience, it works on Pixel 2 API 26 but not working on Pixel 2 API 28. Please check it on Pixel 2 API 28 simulator when you are available. Thanks.

chinalwb commented 5 years ago

Okay thanks for the debugging.

Btw what’s your time zone?

wangxianming315 commented 5 years ago

I am in Shenyang. :) GMT+8. I usually work late. lol.

chinalwb commented 5 years ago

Really! I saw your profile just now. I usually sleep early but wake up late :)

wangxianming315 commented 5 years ago

Please let me know when you have any good news. :)

chinalwb commented 5 years ago

I’ll try to reproduce on SDK 28 tonight.

wangxianming315 commented 5 years ago

Thank you.

chinalwb commented 5 years ago

Reproduced on SDK 28. I'll check and fix.

wangxianming315 commented 5 years ago

Thank you!

chinalwb commented 5 years ago

Do you mind the auto-complete feature of the keyboard?

I found I disabled that before so it works on pre 28 versions.

The disable setting doesn't work on Android P, thus you see the bug.

chinalwb commented 5 years ago

I think you have been able to run the ARE project on your local, right?

If yes, please try to add this to AREditText.java#init(), on line 97:

        this.setInputType(EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE
                | EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS | EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
        Typeface typeface = Typeface.DEFAULT;
        this.setTypeface(typeface);

With this setting, I am able to get the same behavior as the video of last night.

wangxianming315 commented 5 years ago

Yes. I am trying it now.

wangxianming315 commented 5 years ago

Wow. Now it works on both API 26 and 28. The auto-complete feature of the keyboard is now disabled on Android P too.

chinalwb commented 5 years ago

Yes, I believe I had tried to have that included but failed somehow, after that, I didn't get a chance to look into again ...

Hope it works for you.

wangxianming315 commented 5 years ago

Ok. Now I think everything works well as expected. I am going to close this issue now. Thank you very much for your effort. You are very smart guy. Have a good night. :)

chinalwb commented 5 years ago

Thanks for your kind words, I had tried hardly to find some guy as stupid as I, but now, I give up.

Good morning!