diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/BaseKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/BaseKeyboard.java index eaf3b89ff..97ccc476f 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/BaseKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/BaseKeyboard.java @@ -49,10 +49,24 @@ public String getModeChangeKeyText() { return mContext.getString(R.string.keyboard_mode_change); } + @Override + public float getKeyboardTranslateYInWorld() { + return WidgetPlacement.unitFromMeters(mContext, R.dimen.keyboard_y); + } + + @Override + public float getKeyboardWorldWidth() { + return WidgetPlacement.floatDimension(mContext, R.dimen.keyboard_world_width); + } + public float getAlphabeticKeyboardWidth() { return WidgetPlacement.dpDimension(mContext, R.dimen.keyboard_alphabetic_width); } + public float getAlphabeticKeyboardHeight() { + return WidgetPlacement.dpDimension(mContext, R.dimen.keyboard_height); + } + @Override public String[] getDomains(String... domains) { return Stream.of(new String[]{".com", ".net", ".org", ".co"}, domains).flatMap(Stream::of) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ChinesePinyinKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ChinesePinyinKeyboard.java index c73071d42..26a789ad6 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ChinesePinyinKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ChinesePinyinKeyboard.java @@ -484,4 +484,9 @@ public DBHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } } + + @Override + public String[] getDomains(String... domains) { + return super.getDomains(".cn"); + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ChineseZhuyinKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ChineseZhuyinKeyboard.java index 8613271cd..03631ffa5 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ChineseZhuyinKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ChineseZhuyinKeyboard.java @@ -480,4 +480,9 @@ public DBPhraseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } } + + @Override + public String[] getDomains(String... domains) { + return super.getDomains(".tw"); + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/KeyboardInterface.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/KeyboardInterface.java index 8af9cf0de..8f30fc2df 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/KeyboardInterface.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/KeyboardInterface.java @@ -30,6 +30,10 @@ public enum Action { } @NonNull CustomKeyboard getAlphabeticKeyboard(); float getAlphabeticKeyboardWidth(); + float getAlphabeticKeyboardHeight(); + float getKeyboardTranslateYInWorld(); + float getKeyboardWorldWidth(); + default @Nullable CustomKeyboard getAlphabeticCapKeyboard() { return null; } default @Nullable CustomKeyboard getSymbolsKeyboard() { return null; } default @Nullable CandidatesResult getCandidates(String aComposingText) { return null; } default @Nullable String overrideAddText(String aTextBeforeCursor, String aNextText) { return null; } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ThaiKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ThaiKeyboard.java new file mode 100644 index 000000000..cd4b1b141 --- /dev/null +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ThaiKeyboard.java @@ -0,0 +1,110 @@ +/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.vrbrowser.ui.keyboards; + +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import org.mozilla.vrbrowser.R; +import org.mozilla.vrbrowser.input.CustomKeyboard; +import org.mozilla.vrbrowser.ui.widgets.WidgetPlacement; +import org.mozilla.vrbrowser.utils.StringUtils; + +import java.util.Locale; + +public class ThaiKeyboard extends BaseKeyboard { + private Locale mLocale; + private CustomKeyboard mKeyboard; + private CustomKeyboard mCapKeyboard; + private CustomKeyboard mSymbolsKeyboard; + + public ThaiKeyboard(Context aContext) { + super(aContext); + mLocale = new Locale("th", "TH"); + } + + @NonNull + @Override + public CustomKeyboard getAlphabeticKeyboard() { + if (mKeyboard == null) { + mKeyboard = new CustomKeyboard(mContext.getApplicationContext(), R.xml.keyboard_qwerty_thai); + mKeyboard.setShifted(false); + } + return mKeyboard; + } + + @NonNull + @Override + public CustomKeyboard getAlphabeticCapKeyboard() { + if (mCapKeyboard == null) { + mCapKeyboard = new CustomKeyboard(mContext.getApplicationContext(), R.xml.keyboard_qwerty_thai_cap); + mCapKeyboard.setShifted(true); + } + return mCapKeyboard; + } + + @Nullable + @Override + public CustomKeyboard getSymbolsKeyboard() { + if (mSymbolsKeyboard == null) { + mSymbolsKeyboard = new CustomKeyboard(mContext.getApplicationContext(), R.xml.keyboard_symbols_thai); + } + return mSymbolsKeyboard; + } + + @Override + public float getKeyboardTranslateYInWorld() { + return WidgetPlacement.unitFromMeters(mContext, R.dimen.keyboard_y_extra_row); + } + + @Override + public float getKeyboardWorldWidth() { + return WidgetPlacement.floatDimension(mContext, R.dimen.keyboard_world_extra_row_width); + } + + @Override + public float getAlphabeticKeyboardWidth() { + return WidgetPlacement.dpDimension(mContext, R.dimen.keyboard_alphabetic_width_extra_column); + } + + @Override + public float getAlphabeticKeyboardHeight() { + return WidgetPlacement.dpDimension(mContext, R.dimen.keyboard_alphabetic_height_thai); + } + + @Nullable + @Override + public CandidatesResult getCandidates(String aText) { + return null; + } + + @Override + public String getKeyboardTitle() { + return StringUtils.getStringByLocale(mContext, R.string.settings_language_thai, getLocale()); + } + + @Override + public Locale getLocale() { + return mLocale; + } + + @Override + public String getSpaceKeyText(String aComposingText) { + return StringUtils.getStringByLocale(mContext, R.string.settings_language_thai, getLocale()); + } + + @Override + public String getModeChangeKeyText() { + return mContext.getString(R.string.thai_keyboard_mode_change); + } + + @Override + public String[] getDomains(String... domains) { + return super.getDomains(".th"); + } +} diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/KeyboardWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/KeyboardWidget.java index a002ef65a..84a35e150 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/KeyboardWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/KeyboardWidget.java @@ -58,6 +58,7 @@ import org.mozilla.vrbrowser.ui.keyboards.RussianKeyboard; import org.mozilla.vrbrowser.ui.keyboards.SpanishKeyboard; import org.mozilla.vrbrowser.ui.keyboards.SwedishKeyboard; +import org.mozilla.vrbrowser.ui.keyboards.ThaiKeyboard; import org.mozilla.vrbrowser.ui.views.AutoCompletionView; import org.mozilla.vrbrowser.ui.views.CustomKeyboardView; import org.mozilla.vrbrowser.ui.views.KeyboardSelectorView; @@ -294,6 +295,7 @@ private void initialize(Context aContext) { mKeyboards.add(new SwedishKeyboard(aContext)); mKeyboards.add(new FinnishKeyboard(aContext)); mKeyboards.add(new DutchKeyboard(aContext)); + mKeyboards.add(new ThaiKeyboard(aContext)); mDefaultKeyboardSymbols = new CustomKeyboard(aContext.getApplicationContext(), R.xml.keyboard_symbols); mKeyboardNumeric = new CustomKeyboard(aContext.getApplicationContext(), R.xml.keyboard_numeric); @@ -377,9 +379,7 @@ public void releaseWidget() { protected void initializeWidgetPlacement(WidgetPlacement aPlacement) { Context context = getContext(); aPlacement.width = getKeyboardWidth(WidgetPlacement.dpDimension(context, R.dimen.keyboard_alphabetic_width)); - aPlacement.height = WidgetPlacement.dpDimension(context, R.dimen.keyboard_height); - aPlacement.height += WidgetPlacement.dpDimension(context, R.dimen.autocompletion_widget_line_height); - aPlacement.height += WidgetPlacement.dpDimension(context, R.dimen.keyboard_layout_padding); + aPlacement.height = getKeyboardHeight(WidgetPlacement.dpDimension(context, R.dimen.keyboard_height)); aPlacement.anchorX = 0.5f; aPlacement.anchorY = 0.0f; aPlacement.parentAnchorY = 0.0f; @@ -429,6 +429,13 @@ private int getKeyboardWidth(float aAlphabeticWidth) { return (int) width; } + private int getKeyboardHeight(float aAlphabeticHeight) { + float height = aAlphabeticHeight; + height += WidgetPlacement.dpDimension(getContext(), R.dimen.autocompletion_widget_line_height); + height += WidgetPlacement.dpDimension(getContext(), R.dimen.keyboard_layout_padding); + return (int) height; + } + private void resetKeyboardLayout() { if ((mEditorInfo.inputType & EditorInfo.TYPE_CLASS_NUMBER) == EditorInfo.TYPE_CLASS_NUMBER) { mKeyboardView.setKeyboard(getSymbolsKeyboard()); @@ -735,6 +742,16 @@ private void cleanComposingText() { } private void handleShift(boolean isShifted) { + final boolean statusChanged = mKeyboardView.isShifted() != isShifted; + + if (mCurrentKeyboard.getAlphabeticCapKeyboard() != null) { + if (isShifted || mIsCapsLock) { + mKeyboardView.setKeyboard(mCurrentKeyboard.getAlphabeticCapKeyboard()); + } else { + mKeyboardView.setKeyboard(mCurrentKeyboard.getAlphabeticKeyboard()); + } + } + CustomKeyboard keyboard = (CustomKeyboard) mKeyboardView.getKeyboard(); int[] shiftIndices = keyboard.getShiftKeyIndices(); for (int shiftIndex: shiftIndices) { @@ -760,7 +777,7 @@ private void handleShift(boolean isShifted) { // setShifted trigger a full keyboard redraw. // To avoid this we only call setShifted if it's state has changed. - if (mKeyboardView.isShifted() != isShifted) { + if (statusChanged) { mKeyboardView.setShifted(isShifted || mIsCapsLock); } } @@ -859,18 +876,29 @@ private void handleLanguageChange(KeyboardInterface aKeyboard) { mCurrentKeyboard = aKeyboard; final int width = getKeyboardWidth(mCurrentKeyboard.getAlphabeticKeyboardWidth()); - if (width != mWidgetPlacement.width) { + final int height = getKeyboardHeight(mCurrentKeyboard.getAlphabeticKeyboardHeight()); + if (width != mWidgetPlacement.width || height != mWidgetPlacement.height) { mWidgetPlacement.width = width; - float defaultWorldWidth = WidgetPlacement.floatDimension(getContext(), R.dimen.keyboard_world_width); + mWidgetPlacement.height = height; + mWidgetPlacement.translationY = mCurrentKeyboard.getKeyboardTranslateYInWorld() - + WidgetPlacement.unitFromMeters(getContext(), R.dimen.window_world_y); + float defaultWorldWidth = mCurrentKeyboard.getKeyboardWorldWidth(); int defaultKeyboardWidth = getKeyboardWidth(mKeyboards.get(0).getAlphabeticKeyboardWidth()); mWidgetPlacement.worldWidth = defaultWorldWidth * ((float) width / (float) defaultKeyboardWidth); mWidgetManager.updateWidget(this); ViewGroup.LayoutParams params = mKeyboardContainer.getLayoutParams(); params.width = WidgetPlacement.convertDpToPixel(getContext(), mCurrentKeyboard.getAlphabeticKeyboardWidth()); + params.height = WidgetPlacement.convertDpToPixel(getContext(), mCurrentKeyboard.getAlphabeticKeyboardHeight()); mKeyboardContainer.setLayoutParams(params); } + final int pixelHeight = WidgetPlacement.convertDpToPixel(getContext(), mCurrentKeyboard.getAlphabeticKeyboardHeight()); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)mKeyboardLayout.getLayoutParams(); + if (pixelHeight != params.height) { + // We can consider to make mKeyboardLayout height is the maximum of height value in the future + // then we can avoid resize. + params.height = pixelHeight; + } params.topMargin = mCurrentKeyboard.supportsAutoCompletion() ? WidgetPlacement.pixelDimension(getContext(), R.dimen.keyboard_margin_top_without_autocompletion) : 0; mKeyboardLayout.setLayoutParams(params); @@ -933,7 +961,6 @@ private void handleDone() { } } - private void handleModeChange() { Keyboard current = mKeyboardView.getKeyboard(); Keyboard alphabetic = mCurrentKeyboard.getAlphabeticKeyboard(); diff --git a/app/src/main/res/layout/keyboard.xml b/app/src/main/res/layout/keyboard.xml index d155b2b3a..7ac6317d7 100644 --- a/app/src/main/res/layout/keyboard.xml +++ b/app/src/main/res/layout/keyboard.xml @@ -125,7 +125,7 @@ android:padding="15dp" android:layout_gravity="center" android:background="@drawable/dialog_background" - android:alpha="0.5" + android:alpha="0.0" android:visibility="gone"/> diff --git a/app/src/main/res/layout/navigation_url.xml b/app/src/main/res/layout/navigation_url.xml index ef2708a8f..1eceab84b 100644 --- a/app/src/main/res/layout/navigation_url.xml +++ b/app/src/main/res/layout/navigation_url.xml @@ -186,6 +186,8 @@ android:id="@+id/urlEditText" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_marginTop="5dp" + android:layout_marginBottom="5dp" android:paddingEnd="10dp" android:layout_toStartOf="@id/endButtonsLayout" android:layout_toEndOf="@id/icons" diff --git a/app/src/main/res/values/dimen.xml b/app/src/main/res/values/dimen.xml index 8b7207122..770140b94 100644 --- a/app/src/main/res/values/dimen.xml +++ b/app/src/main/res/values/dimen.xml @@ -23,21 +23,21 @@ 3.25 + 3.43 -0.15 -0.45 - -0.63 + -0.72 -2.5 -35.0 - 188dp + 186dp 526dp 540dp 540dp 540dp 540dp - 470dp 564dp + 226dp 144dp - 228dp 4dp 4dp 36dp @@ -49,6 +49,8 @@ 50dp 70dp 74dp + 50dp + 72dp 50dp 72dp 62dp diff --git a/app/src/main/res/values/non_L10n.xml b/app/src/main/res/values/non_L10n.xml index 5afc629b7..3a0a38fe6 100644 --- a/app/src/main/res/values/non_L10n.xml +++ b/app/src/main/res/values/non_L10n.xml @@ -101,6 +101,8 @@ 確定 かな + กขค + aáàäãåâąæā bƀḃḅḇ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 674169823..5da33ecd9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -300,6 +300,10 @@ changes the app and the language of the speech-recognition-based search to 'Dutch'. --> Dutch + + Thai + Display diff --git a/app/src/main/res/xml/keyboard_qwerty_thai.xml b/app/src/main/res/xml/keyboard_qwerty_thai.xml new file mode 100644 index 000000000..f142ca1b9 --- /dev/null +++ b/app/src/main/res/xml/keyboard_qwerty_thai.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/xml/keyboard_qwerty_thai_cap.xml b/app/src/main/res/xml/keyboard_qwerty_thai_cap.xml new file mode 100644 index 000000000..5220fdf61 --- /dev/null +++ b/app/src/main/res/xml/keyboard_qwerty_thai_cap.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + /> + + + + + + + + + + + + + + + + + + + + + + + + + /> + + + + + + + + + + + + /> + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/xml/keyboard_symbols_swedish.xml b/app/src/main/res/xml/keyboard_symbols_swedish.xml index 29071939f..d321c39ef 100644 --- a/app/src/main/res/xml/keyboard_symbols_swedish.xml +++ b/app/src/main/res/xml/keyboard_symbols_swedish.xml @@ -30,7 +30,7 @@ - + diff --git a/app/src/main/res/xml/keyboard_symbols_thai.xml b/app/src/main/res/xml/keyboard_symbols_thai.xml new file mode 100644 index 000000000..c2d240ffc --- /dev/null +++ b/app/src/main/res/xml/keyboard_symbols_thai.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +