Android-RTEditor icon indicating copy to clipboard operation
Android-RTEditor copied to clipboard

Request: add TextView helper class which is used to convert from the generated Html

Open AndroidDeveloperLB opened this issue 6 years ago • 4 comments

If we wish to only view the content that was saved before on the RTEditText, into TextView, using the normal Html.fromHtml isn't enough, as it doesn't handle lists well, and a lot more tags.

Please add an option to somehow view such content on TextView.

AndroidDeveloperLB avatar Mar 06 '18 16:03 AndroidDeveloperLB

For now, the only workaround is to still use RTEditText, yet extend from it and have it disabled:

class ViewOnlyRtEditText @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : RTEditText(context, attrs, defStyleAttr) {

    init {
        isEnabled = false
        isFocusable = false
        isFocusableInTouchMode = false

    }

    override fun onTouchEvent(event: MotionEvent?): Boolean = false
}

AndroidDeveloperLB avatar Apr 08 '18 14:04 AndroidDeveloperLB

@AndroidDeveloperLB I am new to Kotlin. Would it be possible for you to provide a Java implementation of this if it's not too much trouble?

I have found a different workaround. Instead of extending from RTEditText, you can simply declare it in place of the TextView, set its android:editable="false" and use it as usual in the relevant view by called rtEditText.setRichTextEditing(true, value)

Saunved avatar Jul 25 '18 00:07 Saunved

@Saunved I've moved forward to other things. To learn Kotlin, I usually just converted Java and looked at the result.

What the above means, is:

  1. First line is the various CTORs of the class.
  2. the "init" part is shared between them, so it will run no matter which CTOR is used.
  3. the "onTouchEvent" just returns false.

AndroidDeveloperLB avatar Jul 25 '18 05:07 AndroidDeveloperLB

@AndroidDeveloperLB Thanks for the help :)

Saunved avatar Jul 25 '18 05:07 Saunved