Thursday, August 4, 2011

[android-developers] WebView TextSelection + JavaScript issue in 3.1+ - solution opinions?

Hello All,

Problem domain: WebView based ePub format reader
need text highlights which are accessible via JavaScript methods (ie
turn em on, turn em off, save them email them, etc)

Anyone in the know, please correct me if I'm wrong:
During text selection on a WebView --
Basically we are handed a TextView overlay (WebTextView) which is IN
NO WAY attached to the underlying html other than visually (nice job
on lining it all up and making it seamless, btw), on which we perform
the TextSelectionActionMode and the ClipboardManager is supplied with
the results...

So in order to make this behavior work in 3.1+, I have two possible
plans going forward to implement my own selection on a WebView --
this is the part where I'm wondering if I cannot see out of my
corner :) --
1) capture MOTION_DOWN of the long click which initiates selection
mode, override the built in TextSelection ActionMode( to provde the
clients branding -- the way I found to do so is so hackish it hurts)
watch the drag, capture MOTION_UP position, map these coords onto the
WebView, and make my selection based on the coords (while comparing
the text to that captured by the ClipboardManager)
2) create my own "WebTextView" (whole lotta work lol) and not-so-
hackishly create my own ActionMode and do all of the above

These are the options I see, hopefully my proximity and frustration
with this have blinded me to a simpler (read that as built-in)
solution or two.
Thanks again for your time.

Peace,
Dan

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment