58
58
import org .mozilla .vrbrowser .ui .keyboards .RussianKeyboard ;
59
59
import org .mozilla .vrbrowser .ui .keyboards .SpanishKeyboard ;
60
60
import org .mozilla .vrbrowser .ui .keyboards .SwedishKeyboard ;
61
+ import org .mozilla .vrbrowser .ui .keyboards .ThaiKeyboard ;
61
62
import org .mozilla .vrbrowser .ui .views .AutoCompletionView ;
62
63
import org .mozilla .vrbrowser .ui .views .CustomKeyboardView ;
63
64
import org .mozilla .vrbrowser .ui .views .KeyboardSelectorView ;
@@ -294,6 +295,7 @@ private void initialize(Context aContext) {
294
295
mKeyboards .add (new SwedishKeyboard (aContext ));
295
296
mKeyboards .add (new FinnishKeyboard (aContext ));
296
297
mKeyboards .add (new DutchKeyboard (aContext ));
298
+ mKeyboards .add (new ThaiKeyboard (aContext ));
297
299
298
300
mDefaultKeyboardSymbols = new CustomKeyboard (aContext .getApplicationContext (), R .xml .keyboard_symbols );
299
301
mKeyboardNumeric = new CustomKeyboard (aContext .getApplicationContext (), R .xml .keyboard_numeric );
@@ -377,9 +379,7 @@ public void releaseWidget() {
377
379
protected void initializeWidgetPlacement (WidgetPlacement aPlacement ) {
378
380
Context context = getContext ();
379
381
aPlacement .width = getKeyboardWidth (WidgetPlacement .dpDimension (context , R .dimen .keyboard_alphabetic_width ));
380
- aPlacement .height = WidgetPlacement .dpDimension (context , R .dimen .keyboard_height );
381
- aPlacement .height += WidgetPlacement .dpDimension (context , R .dimen .autocompletion_widget_line_height );
382
- aPlacement .height += WidgetPlacement .dpDimension (context , R .dimen .keyboard_layout_padding );
382
+ aPlacement .height = getKeyboardHeight (WidgetPlacement .dpDimension (context , R .dimen .keyboard_height ));
383
383
aPlacement .anchorX = 0.5f ;
384
384
aPlacement .anchorY = 0.0f ;
385
385
aPlacement .parentAnchorY = 0.0f ;
@@ -429,6 +429,13 @@ private int getKeyboardWidth(float aAlphabeticWidth) {
429
429
return (int ) width ;
430
430
}
431
431
432
+ private int getKeyboardHeight (float aAlphabeticHeight ) {
433
+ float height = aAlphabeticHeight ;
434
+ height += WidgetPlacement .dpDimension (getContext (), R .dimen .autocompletion_widget_line_height );
435
+ height += WidgetPlacement .dpDimension (getContext (), R .dimen .keyboard_layout_padding );
436
+ return (int ) height ;
437
+ }
438
+
432
439
private void resetKeyboardLayout () {
433
440
if ((mEditorInfo .inputType & EditorInfo .TYPE_CLASS_NUMBER ) == EditorInfo .TYPE_CLASS_NUMBER ) {
434
441
mKeyboardView .setKeyboard (getSymbolsKeyboard ());
@@ -735,6 +742,16 @@ private void cleanComposingText() {
735
742
}
736
743
737
744
private void handleShift (boolean isShifted ) {
745
+ final boolean statusChanged = mKeyboardView .isShifted () != isShifted ;
746
+
747
+ if (mCurrentKeyboard .getAlphabeticCapKeyboard () != null ) {
748
+ if (isShifted || mIsCapsLock ) {
749
+ mKeyboardView .setKeyboard (mCurrentKeyboard .getAlphabeticCapKeyboard ());
750
+ } else {
751
+ mKeyboardView .setKeyboard (mCurrentKeyboard .getAlphabeticKeyboard ());
752
+ }
753
+ }
754
+
738
755
CustomKeyboard keyboard = (CustomKeyboard ) mKeyboardView .getKeyboard ();
739
756
int [] shiftIndices = keyboard .getShiftKeyIndices ();
740
757
for (int shiftIndex : shiftIndices ) {
@@ -760,7 +777,7 @@ private void handleShift(boolean isShifted) {
760
777
761
778
// setShifted trigger a full keyboard redraw.
762
779
// To avoid this we only call setShifted if it's state has changed.
763
- if (mKeyboardView . isShifted () != isShifted ) {
780
+ if (statusChanged ) {
764
781
mKeyboardView .setShifted (isShifted || mIsCapsLock );
765
782
}
766
783
}
@@ -859,18 +876,29 @@ private void handleLanguageChange(KeyboardInterface aKeyboard) {
859
876
860
877
mCurrentKeyboard = aKeyboard ;
861
878
final int width = getKeyboardWidth (mCurrentKeyboard .getAlphabeticKeyboardWidth ());
862
- if (width != mWidgetPlacement .width ) {
879
+ final int height = getKeyboardHeight (mCurrentKeyboard .getAlphabeticKeyboardHeight ());
880
+ if (width != mWidgetPlacement .width || height != mWidgetPlacement .height ) {
863
881
mWidgetPlacement .width = width ;
864
- float defaultWorldWidth = WidgetPlacement .floatDimension (getContext (), R .dimen .keyboard_world_width );
882
+ mWidgetPlacement .height = height ;
883
+ mWidgetPlacement .translationY = mCurrentKeyboard .getKeyboardTranslateYInWorld () -
884
+ WidgetPlacement .unitFromMeters (getContext (), R .dimen .window_world_y );
885
+ float defaultWorldWidth = mCurrentKeyboard .getKeyboardWorldWidth ();
865
886
int defaultKeyboardWidth = getKeyboardWidth (mKeyboards .get (0 ).getAlphabeticKeyboardWidth ());
866
887
mWidgetPlacement .worldWidth = defaultWorldWidth * ((float ) width / (float ) defaultKeyboardWidth );
867
888
mWidgetManager .updateWidget (this );
868
889
ViewGroup .LayoutParams params = mKeyboardContainer .getLayoutParams ();
869
890
params .width = WidgetPlacement .convertDpToPixel (getContext (), mCurrentKeyboard .getAlphabeticKeyboardWidth ());
891
+ params .height = WidgetPlacement .convertDpToPixel (getContext (), mCurrentKeyboard .getAlphabeticKeyboardHeight ());
870
892
mKeyboardContainer .setLayoutParams (params );
871
893
}
872
894
895
+ final int pixelHeight = WidgetPlacement .convertDpToPixel (getContext (), mCurrentKeyboard .getAlphabeticKeyboardHeight ());
873
896
RelativeLayout .LayoutParams params = (RelativeLayout .LayoutParams )mKeyboardLayout .getLayoutParams ();
897
+ if (pixelHeight != params .height ) {
898
+ // We can consider to make mKeyboardLayout height is the maximum of height value in the future
899
+ // then we can avoid resize.
900
+ params .height = pixelHeight ;
901
+ }
874
902
params .topMargin = mCurrentKeyboard .supportsAutoCompletion () ? WidgetPlacement .pixelDimension (getContext (), R .dimen .keyboard_margin_top_without_autocompletion ) : 0 ;
875
903
mKeyboardLayout .setLayoutParams (params );
876
904
@@ -933,7 +961,6 @@ private void handleDone() {
933
961
}
934
962
}
935
963
936
-
937
964
private void handleModeChange () {
938
965
Keyboard current = mKeyboardView .getKeyboard ();
939
966
Keyboard alphabetic = mCurrentKeyboard .getAlphabeticKeyboard ();
0 commit comments