mobile - What options are available for handling text input on Android using Adobe AIR? -
what options available handling text input on android using adobe air? advantages , drawbacks each option?
the current options available air developers on android handling text input are:
- stagetext native text (default)
- textinputskin (spark.skins.mobile)
- textinputskin (spark.skins.spark)
- stagetext + textinputskin (spark.skins.mobile) hybrid
- stagewebview (explained below)
- native view
i'll discuss of advantages , drawbacks of each approach below. if i've missed (or if have other ideas haven't thought about) please let me know!
stagetext
- handles input in cases? http://png-5.findicons.com/files/icons/1156/fugue/16/tick_small.png yes
- displays in cases? http://png-1.findicons.com/files/icons/2132/tiny/10/exclamation.png no
- vertical alignment problems when scrolling.
by default, textinputs running on mobile devices make use of stagetext (native text) input. stagetext offers several advantages, adobe outlines in online documentation, including auto-correct, customization of software keyboards, etc.
the biggest disadvantage using stagetext described in bugbase ticket 3302441. stagetext's positioning becomes broken when user scrolls. textfields appear outside of respective textinputs or, worse, inside of other textinputs. work-around defect design ui not allow scrolling. can difficult mobile phones , phablets.
textinputskin (spark.skins.mobile)
- handles input in cases? http://png-5.findicons.com/files/icons/1156/fugue/16/tick_small.png yes
- displays in cases? http://png-1.findicons.com/files/icons/2132/tiny/10/exclamation.png no
- inserts random characters on android versions (ex. nook running android 2.3).
this component uses styleabletextfield internally. optimized mobile use.
this component inserts additional, arbitrary characters textinput user typing on android versions (ex. nook running android 2.3, kindle hd running android 4.0). see bugbase ticket 3547601.
if application localized english (or latin-based languages) , not need support older android versions component may work you.
textinputskin (spark.skins.spark)
- handles input in cases? http://png-1.findicons.com/files/icons/2132/tiny/10/exclamation.png no
- does not accept double-byte characters (ex. korean).
- does not accept input on devices (ex. samsung galaxy 10.1 running android 4.0).
- displays in cases? http://png-5.findicons.com/files/icons/1156/fugue/16/tick_small.png yes
this component uses richeditabletext internally. not optimized mobile use. beyond demonstrates several defects (listed above) make unsuitable use.
this component not handle double-byte characters (in languages such korean). these characters seem inserted textinput (the cursor progresses, visibly) no text rendered user. (it possible issue resolved using embedded font.) see bugbase ticket 3547591.
while testing 3rd item mentioned above (input not being accepted on devices) interesting thing observed. after typing couple of characters, if user switches focus textinput uses default stagetext, @ least of missing characters automatically inserted new field.
stagetext + textinputskin (spark.skins.mobile) hybrid
- handles input in cases? http://png-5.findicons.com/files/icons/1156/fugue/16/tick_small.png yes
- displays in cases? http://png-1.findicons.com/files/icons/2132/tiny/10/exclamation.png no
- sometimes software keyboard's "show" animation triggered twice in row, creating undesirable visual effect.
- sometimes focus handling difficult , can result in stagetext-textinput showing without software keyboard until learner touches again.
this approach combines benefits of stagetext scrolling functionality of textinputskin (spark.skins.mobile). general idea create 1 textinput uses stagetext , assign fixed location on screen. textinput should hidden default. other textinputs (using textinputskin) can created , positioned needed on stage. when 1 of these textinputs gains focus, hidden surrogate textinput should shown , focus should shifted it. text entered surrogate, change-handler should copy text user-selected textinput. when user tabs or clicks set focus elsewhere surrogate textinput should hidden again.
i can provide code example of if desired. there couple of drawbacks approach (mentioned above) it's possible fault of implementation.
stagewebview
- handles input in cases? http://png-2.findicons.com/files/icons/1687/free_web_design/16/mini_warning.png yes/no
- depending on value of
<rendermode>
,<fullscreen>
component may work you. - is little tricky working.
- depending on value of
- displays in cases? http://png-5.findicons.com/files/icons/1156/fugue/16/tick_small.png yes
this approach involves displaying simple html page inside of air application using stagewebview. html page contains <input type="text">
objects make use of android's native text , software keyboard. communicating between html page , parent air app though bit tricky, since stagewebview not support flash-to-javascript communication in same externalinterface.
communicating javascript flash
communicating javascript (or html) actionscript difficult because stagewebview not allow actionscript add callbacks. stagewebviewbridge offers functionality has not been updated in time , when tried it, unable content display using flex 4.6 , air 3.5.
there still ways convey information actionscript using locationchangeevent. idea behind air app listen location changing events , parse incoming event.location
information. simple links works things more complicated when comes forms. tried following approaches before settling on one:
- http://png-1.findicons.com/files/icons/2132/tiny/10/exclamation.png add onclick handler form-submit button sets
window.location.href
string containing url-encoded key/value pairs. approach not work reasons described in bugbase ticket 3362483. - http://png-1.findicons.com/files/icons/2132/tiny/10/exclamation.png add onclick handler form-submit button dynamically modifies form-target contain url-encoded key/value pairs , submits form. approach not work because locationchangeevents not dispatched when form.submit() called.
- http://png-5.findicons.com/files/icons/1156/fugue/16/tick_small.png add onchange handlers
<input type="text">
tags , modifyhref
attribute of "submit" link contain url-encoded key/value pairs. when link clicked, actionscript locationchangeevent handler invoked , can parse incoming data using urlvariables class.
communicating flash javascript
to communicate javascript (call methods, pass parameters) use stagewebview's loadurl method this:
_stagewebview.loadurl( 'javascript:yourmethodname( "a string", true )' );
unfortunately loadurl method has void return type (meaning can't retrieve data way).
other difficulties
the biggest drawback approach described in bugbase ticket 3535948. if air application uses <rendermode>direct</rendermode>
or <fullscreen>true</fullscreen>
text input via stagewebview unusable. (response sluggish. users unable select or delete characters.) if app not require either of flags route may work you.
one workaround fullscreen limitation disable fullscreen mode when application needs make use of stagewebview. can done stagedisplaystate this:
// turn off fullscreen stage.displaystate = stagedisplaystate.normal; // turn on fullscreen stage.displaystate = stagedisplaystate.full_screen_interactive;
native view
- handles input in cases? http://png-5.findicons.com/files/icons/1156/fugue/16/tick_small.png yes
- displays in cases? http://png-5.findicons.com/files/icons/1156/fugue/16/tick_small.png yes
the last remaining option (that i'm aware of) write native extension displays text-inputs , returns data air application. safest (although disappointing) option of ones discussed in thread.
Comments
Post a Comment