Comments (6)
I can't reproduce the issue, it works perfectly for me, mRTMessageField.getText(RTFormat.HTML) returns html for Italic and Bold. The rich text editor is used in thousands of installations, if there was indeed that issue, my users would have complained already.
You can save the text in the demo app and reload it which will show you that the formatting is indeed saved.
from android-rteditor.
The saved HTML file is completely empty, but that's another problem.
I tested on Nexus 5, Android 4.4.4.
I debugged the problem a little bit. In ConverterSpannedToHtml
class, the line 251:
List<CharacterStyle> spanList = Arrays.asList(text.getSpans(start, end, CharacterStyle.class));
returns a single element list with
0 = {StyleSpan@830046449792} mStyle = 1
.
I don't know why it's not the BoldSpan as it was initially inserted, but that's what's there.
I propose to fix the problem by generating a html tag both from the BoldSpan and StyleSpan. It not only fixes the problem I describe, but also make the ConverterSpannedToHtml
a better general purpose tool.
from android-rteditor.
My Nexus 5 (although running Android M) has no such issue. Also tested it on an S3 running KitKat.
I don't want a workaround for an issue if the root cause isn't known and might lead to other (yet unknown) issues. As I said thousands of users use this component and no one has ever reported anything like this so let's find out what's special about your device.
Anything out of the ordinary on your device? rooted? custom 4.4.4? any suspicious apps installed? do you use a custom font?
What happens if you rotate the screen to landscape, is the bold text still there?
BTW I suggest you contact me by email to solve this: [email protected]
from android-rteditor.
After some more tests I've found the proper scenario to reproduce the problem:
- Enable "don't keep activities" in the developer options
- Start demo activity
- Press "bold"
- Type "Hello"
- Press HOME
- Go back to the demo application
That should be it.
The problem is that the onSaveInstanceState method in TextView uses the TextUtils#writeToParcel method for saving text and this method can handle only built-in spans. I don't think that it's possible to extend this mechanism for custom spans.
I see two possible solutions for the problem of saving and restoring state:
- Copy the whole spans parcelling mechanism and modify the copied code to support custom spans
- Use the built-in mechanism, but after restoring text convert all the spans to custom versions (I know that we can easily convert a StyleSpan to BoldSpan, but I don't know if that's so easy for other spans in the library).
from android-rteditor.
I went for option 3 ;-).
The proper way to handle this is to save the view state in onSaveInstanceState and restore it in onRestoreInstanceState. By saving the text as html and restoring it from that html we can retain all custom span objects.
Fixed with 9ac8f6a
from android-rteditor.
Indeed, the third solution sounds better:)
It works great now. Thanks :)
from android-rteditor.
Related Issues (20)
- Trouble Applying the 1.6.7 version HOT 3
- How to add a blockquote an horizontal line?
- Photo Capture is not working in the latest version of this library (1.6.7 of RTEditor)
- Android 8.0 insert text crash
- Fatal Exception: java.lang.IllegalStateException: The RTMediaFactory is null. Please make sure to register the editor at the RTManager before using it. HOT 2
- Can we have support for Fonts? HOT 1
- android.view.InflateException while using RTEditor HOT 1
- No subscribers registered for event class com.onegravity.rteditor.media.choose.MediaEvent when picking an image
- 为啥如此设置字体恢复不了 HOT 2
- Installation Error HOT 5
- link error
- Heading1 and heading2 formatting required HOT 2
- is this support kotlin? HOT 1
- [BUG] numbering append with <ol> when the last item deleted HOT 2
- It is possible to add emoji and file uploading
- Insta bug 11.3.0 is not working after integrated rteditor:1.7.6" HOT 2
- [BUG] Indentation left does not work any more in latest version
- [BUG] Caused by: android.view.InflateException: Binary XML file line #36 HOT 1
- 向右一直缩进到最后不会变成竖直一列
- problem when using proguard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-rteditor.