@@ -449,17 +449,16 @@ public void setDisplayOrientation(int p_orientation)
449449
450450////////////////////////////////////////////////////////////////////////////////
451451
452- protected CharSequence m_composing_text ;
453-
454452 @ Override
455453 public InputConnection onCreateInputConnection (EditorInfo outAttrs )
456454 {
457455 Log .i (TAG , "onCreateInputConnection()" );
458456 if (!m_text_editor_visible )
459457 return null ;
460458
461- m_composing_text = null ;
462- InputConnection t_connection = new BaseInputConnection (this , false ) {
459+ InputConnection t_connection = new BaseInputConnection (this , true ) {
460+ String m_current_text = "" ;
461+
463462 void handleKey (int keyCode , int charCode )
464463 {
465464 if (charCode == 0 )
@@ -533,25 +532,26 @@ else if (key.getAction() == KeyEvent.ACTION_MULTIPLE)
533532 return true ;
534533 }
535534
536- // IM-2013-02-25: [[ BZ 10684 ]] - updated to show text changes in the field
537- // as software keyboards modify the composing text.
538- void updateComposingText (CharSequence p_new )
535+ // Show text changes in the field as the composing text is modified.
536+ // We do this by removing edited text with fake backspace key events
537+ // and sending key events for each new character.
538+ void updateComposingText ()
539539 {
540+ String t_new = getEditable ().toString ();
541+
540542 // send changes to the engine as a sequence of key events.
541543 int t_match_length = 0 ;
542544 int t_current_length = 0 ;
543545 int t_new_length = 0 ;
544546 int t_max_length = 0 ;
545547
546- if (m_composing_text != null )
547- t_current_length = m_composing_text .length ();
548- if (p_new != null )
549- t_new_length = p_new .length ();
548+ t_current_length = m_current_text .length ();
549+ t_new_length = t_new .length ();
550550
551551 t_max_length = Math .min (t_current_length , t_new_length );
552552 for (int i = 0 ; i < t_max_length ; i ++)
553553 {
554- if (p_new .charAt (i ) != m_composing_text .charAt (i ))
554+ if (t_new .charAt (i ) != m_current_text .charAt (i ))
555555 break ;
556556 t_match_length += 1 ;
557557 }
@@ -561,9 +561,9 @@ void updateComposingText(CharSequence p_new)
561561 handleKey (KeyEvent .KEYCODE_DEL , 0 );
562562 // send new text
563563 for (int i = t_match_length ; i < t_new_length ; i ++)
564- handleKey (KeyEvent .KEYCODE_UNKNOWN , p_new .charAt (i ));
564+ handleKey (KeyEvent .KEYCODE_UNKNOWN , t_new .charAt (i ));
565565
566- m_composing_text = p_new ;
566+ m_current_text = t_new ;
567567
568568 if (m_wake_on_event )
569569 doProcess (false );
@@ -573,30 +573,38 @@ void updateComposingText(CharSequence p_new)
573573 @ Override
574574 public boolean commitText (CharSequence text , int newCursorPosition )
575575 {
576- updateComposingText (text );
577- m_composing_text = null ;
578- getEditable ().clear ();
579- return true ;
576+ boolean t_return_value = super .commitText (text , newCursorPosition );
577+ updateComposingText ();
578+ return t_return_value ;
580579 }
581580 @ Override
582581 public boolean finishComposingText ()
583582 {
584- m_composing_text = null ;
585- getEditable (). clear ();
586- return true ;
583+ boolean t_return_value = super . finishComposingText () ;
584+ updateComposingText ();
585+ return t_return_value ;
587586 }
588587 @ Override
589588 public boolean setComposingText (CharSequence text , int newCursorPosition )
590589 {
591- updateComposingText (text );
592- return super .setComposingText (text , newCursorPosition );
590+ boolean t_return_value = super .setComposingText (text , newCursorPosition );
591+ updateComposingText ();
592+ return t_return_value ;
593593 }
594594 @ Override
595595 public boolean performEditorAction (int editorAction )
596596 {
597597 handleKey (0 , 10 );
598598 return true ;
599599 }
600+
601+ @ Override
602+ public boolean deleteSurroundingText (int beforeLength , int afterLength )
603+ {
604+ boolean t_return_value = super .deleteSurroundingText (beforeLength , afterLength );
605+ updateComposingText ();
606+ return t_return_value ;
607+ }
600608 };
601609
602610 int t_type = getInputType (false );
0 commit comments