3131import android .widget .RelativeLayout ;
3232import android .widget .TextView ;
3333
34+ import androidx .annotation .NonNull ;
35+ import androidx .annotation .Nullable ;
36+
3437import org .mozilla .geckoview .GeckoSession ;
3538import org .mozilla .vrbrowser .R ;
36- import org .mozilla .vrbrowser .browser .engine .Session ;
3739import org .mozilla .vrbrowser .browser .SettingsStore ;
40+ import org .mozilla .vrbrowser .browser .engine .Session ;
3841import org .mozilla .vrbrowser .input .CustomKeyboard ;
3942import org .mozilla .vrbrowser .telemetry .GleanMetricsService ;
4043import org .mozilla .vrbrowser .telemetry .TelemetryWrapper ;
44+ import org .mozilla .vrbrowser .ui .keyboards .ChinesePinyinKeyboard ;
45+ import org .mozilla .vrbrowser .ui .keyboards .ChineseZhuyinKeyboard ;
4146import org .mozilla .vrbrowser .ui .keyboards .DanishKeyboard ;
42- import org .mozilla .vrbrowser .ui .keyboards .FinnishKeyboard ;
4347import org .mozilla .vrbrowser .ui .keyboards .DutchKeyboard ;
44- import org .mozilla .vrbrowser .ui .keyboards .ItalianKeyboard ;
48+ import org .mozilla .vrbrowser .ui .keyboards .EnglishKeyboard ;
49+ import org .mozilla .vrbrowser .ui .keyboards .FinnishKeyboard ;
4550import org .mozilla .vrbrowser .ui .keyboards .FrenchKeyboard ;
4651import org .mozilla .vrbrowser .ui .keyboards .GermanKeyboard ;
47- import org .mozilla .vrbrowser .ui .keyboards .ChineseZhuyinKeyboard ;
52+ import org .mozilla .vrbrowser .ui .keyboards .ItalianKeyboard ;
4853import org .mozilla .vrbrowser .ui .keyboards .JapaneseKeyboard ;
4954import org .mozilla .vrbrowser .ui .keyboards .KeyboardInterface ;
55+ import org .mozilla .vrbrowser .ui .keyboards .KoreanKeyboard ;
5056import org .mozilla .vrbrowser .ui .keyboards .NorwegianKeyboard ;
5157import org .mozilla .vrbrowser .ui .keyboards .PolishKeyboard ;
5258import org .mozilla .vrbrowser .ui .keyboards .RussianKeyboard ;
53- import org .mozilla .vrbrowser .ui .keyboards .KoreanKeyboard ;
5459import org .mozilla .vrbrowser .ui .keyboards .SpanishKeyboard ;
5560import org .mozilla .vrbrowser .ui .keyboards .SwedishKeyboard ;
5661import org .mozilla .vrbrowser .ui .views .AutoCompletionView ;
5762import org .mozilla .vrbrowser .ui .views .CustomKeyboardView ;
5863import org .mozilla .vrbrowser .ui .views .KeyboardSelectorView ;
5964import org .mozilla .vrbrowser .ui .widgets .dialogs .VoiceSearchWidget ;
60- import org .mozilla .vrbrowser .ui .keyboards .ChinesePinyinKeyboard ;
61- import org .mozilla .vrbrowser .ui .keyboards .EnglishKeyboard ;
6265import org .mozilla .vrbrowser .utils .StringUtils ;
6366
6467import java .util .ArrayList ;
6568import java .util .Locale ;
6669
67- import androidx .annotation .NonNull ;
68- import androidx .annotation .Nullable ;
69-
7070
7171public class KeyboardWidget extends UIWidget implements CustomKeyboardView .OnKeyboardActionListener , AutoCompletionView .Delegate ,
7272 GeckoSession .TextInputDelegate , WidgetManagerDelegate .FocusChangeListener , VoiceSearchWidget .VoiceSearchDelegate , TextWatcher , WindowWidget .WindowListener {
@@ -619,7 +619,6 @@ private void cleanComposingText() {
619619
620620 private void handleShift (boolean isShifted ) {
621621 CustomKeyboard keyboard = (CustomKeyboard ) mKeyboardView .getKeyboard ();
622- boolean shifted = isShifted ;
623622 int [] shiftIndices = keyboard .getShiftKeyIndices ();
624623 for (int shiftIndex : shiftIndices ) {
625624 if (shiftIndex >= 0 ) {
@@ -635,13 +634,13 @@ private void handleShift(boolean isShifted) {
635634 key .pressed = true ;
636635
637636 } else {
638- key .icon = shifted ? mShiftOnIcon : mShiftOffIcon ;
637+ key .icon = isShifted ? mShiftOnIcon : mShiftOffIcon ;
639638 key .pressed = false ;
640639 }
641640 }
642641 }
643642 }
644- mKeyboardView .setShifted (shifted || mIsCapsLock );
643+ mKeyboardView .setShifted (isShifted || mIsCapsLock );
645644 }
646645
647646 private void handleBackspace () {
@@ -822,35 +821,40 @@ private void handleKey(int primaryCode, int[] keyCodes) {
822821 handleText (str );
823822 }
824823
825- private void handleText (final String aText ) {
824+ private void handleText (String aText ) {
826825 if (mFocusedView == null || mInputConnection == null ) {
827826 return ;
828827 }
829828
829+ if (mKeyboardView .isShifted ()) {
830+ aText = aText .toUpperCase ();
831+ }
832+
833+ final String text = aText ;
830834 if (mCurrentKeyboard .usesComposingText ()) {
831835 CharSequence seq = mInputConnection .getSelectedText (0 );
832836 String selected = seq != null ? seq .toString () : "" ;
833837 if (selected .length () > 0 && StringUtils .removeSpaces (selected ).contains (mComposingText )) {
834838 // Clean composing text if the text is selected.
835839 mComposingText = "" ;
836840 }
837- mComposingText += aText ;
841+ mComposingText += text ;
838842 } else if (mCurrentKeyboard .usesTextOverride ()) {
839843 String beforeText = getTextBeforeCursor (mInputConnection );
840- final String newBeforeText = mCurrentKeyboard .overrideAddText (beforeText , aText );
844+ final String newBeforeText = mCurrentKeyboard .overrideAddText (beforeText , text );
841845 final InputConnection connection = mInputConnection ;
842846 postInputCommand (() -> {
843847 if (newBeforeText != null ) {
844848 connection .deleteSurroundingText (beforeText .length (), 0 );
845849 connection .commitText (newBeforeText , 1 );
846850 } else {
847- connection .commitText (aText , 1 );
851+ connection .commitText (text , 1 );
848852 }
849853 });
850854
851855 } else {
852856 final InputConnection connection = mInputConnection ;
853- postInputCommand (() -> connection .commitText (aText , 1 ));
857+ postInputCommand (() -> connection .commitText (text , 1 ));
854858 }
855859 updateCandidates ();
856860 }
0 commit comments