From 61e7f551060f0d5f69b35546c73fb4bb68ad72b8 Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Tue, 19 Nov 2019 00:33:19 +0100 Subject: [PATCH] Add support for keyboard domains (#2308) * Adds for keyboard domains Set column width as the max of each row Fix keyboard panels column width * Fix delegate name --- .../vrbrowser/input/CustomKeyboard.java | 7 ++- .../vrbrowser/ui/keyboards/BaseKeyboard.java | 7 +++ .../ui/keyboards/DanishKeyboard.java | 5 ++ .../vrbrowser/ui/keyboards/DutchKeyboard.java | 5 ++ .../ui/keyboards/EnglishKeyboard.java | 6 ++ .../ui/keyboards/FinnishKeyboard.java | 5 ++ .../ui/keyboards/FrenchKeyboard.java | 5 ++ .../ui/keyboards/GermanKeyboard.java | 5 ++ .../ui/keyboards/ItalianKeyboard.java | 5 ++ .../ui/keyboards/JapaneseKeyboard.java | 5 ++ .../ui/keyboards/KeyboardInterface.java | 1 + .../ui/keyboards/KoreanKeyboard.java | 5 ++ .../ui/keyboards/NorwegianKeyboard.java | 5 ++ .../ui/keyboards/PolishKeyboard.java | 5 ++ .../ui/keyboards/RussianKeyboard.java | 5 ++ .../ui/keyboards/SpanishKeyboard.java | 5 ++ .../ui/keyboards/SwedishKeyboard.java | 5 ++ ...torView.java => KeyboardSelectorView.java} | 55 +++++++++++++------ .../vrbrowser/ui/widgets/KeyboardWidget.java | 36 ++++++++++-- app/src/main/res/layout/keyboard.xml | 14 ++++- app/src/main/res/values/dimen.xml | 11 ++-- app/src/main/res/xml/keyboard_qwerty.xml | 1 + .../main/res/xml/keyboard_qwerty_danish.xml | 1 + .../main/res/xml/keyboard_qwerty_dutch.xml | 1 + .../main/res/xml/keyboard_qwerty_finnish.xml | 1 + .../main/res/xml/keyboard_qwerty_french.xml | 1 + .../main/res/xml/keyboard_qwerty_german.xml | 1 + .../main/res/xml/keyboard_qwerty_italian.xml | 1 + .../main/res/xml/keyboard_qwerty_japanese.xml | 1 + .../main/res/xml/keyboard_qwerty_korean.xml | 1 + .../res/xml/keyboard_qwerty_norwegian.xml | 1 + .../main/res/xml/keyboard_qwerty_pinyin.xml | 1 + .../main/res/xml/keyboard_qwerty_polish.xml | 1 + .../main/res/xml/keyboard_qwerty_russian.xml | 1 + .../main/res/xml/keyboard_qwerty_spanish.xml | 1 + .../main/res/xml/keyboard_qwerty_swedish.xml | 1 + app/src/main/res/xml/keyboard_symbols.xml | 1 + .../main/res/xml/keyboard_symbols_danish.xml | 1 + .../main/res/xml/keyboard_symbols_finnish.xml | 1 + .../main/res/xml/keyboard_symbols_german.xml | 1 + .../res/xml/keyboard_symbols_japanese.xml | 1 + .../res/xml/keyboard_symbols_norwegian.xml | 1 + .../main/res/xml/keyboard_symbols_polish.xml | 1 + .../main/res/xml/keyboard_symbols_russian.xml | 1 + .../main/res/xml/keyboard_symbols_swedish.xml | 1 + 45 files changed, 195 insertions(+), 31 deletions(-) rename app/src/common/shared/org/mozilla/vrbrowser/ui/views/{LanguageSelectorView.java => KeyboardSelectorView.java} (59%) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/input/CustomKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/input/CustomKeyboard.java index dff537c65..815433dc8 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/input/CustomKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/input/CustomKeyboard.java @@ -20,13 +20,14 @@ public class CustomKeyboard extends Keyboard { private Key mEnterKey; private Key mSpaceKey; private Key mModeChangeKey; - private int mMaxColums; + private int mMaxColumns; private int[] mDisabledKeysIndexes; public static final int KEYCODE_SYMBOLS_CHANGE = -10; public static final int KEYCODE_VOICE_INPUT = -11; public static final int KEYCODE_LANGUAGE_CHANGE = -12; public static final int KEYCODE_EMOJI = -13; + public static final int KEYCODE_DOMAIN = -14; public CustomKeyboard(Context context, int xmlLayoutResId) { super(context, xmlLayoutResId, 0); @@ -36,7 +37,7 @@ public CustomKeyboard(Context context, int xmlLayoutResId) { public CustomKeyboard (Context context, int layoutTemplateResId, CharSequence characters, int columns, int horizontalPadding, int verticalGap) { this(context, layoutTemplateResId); - mMaxColums = columns; + mMaxColumns = columns; int x = 0; int y = 0; @@ -236,7 +237,7 @@ public int[] getShiftKeyIndices() { } public int getMaxColumns() { - return mMaxColums; + return mMaxColumns; } public void disableKeys(int[] disabledKeyIndexes) { 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 4e75ec626..eaf3b89ff 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 @@ -9,6 +9,7 @@ import java.util.Locale; import java.util.regex.Pattern; +import java.util.stream.Stream; public abstract class BaseKeyboard implements KeyboardInterface { protected Context mContext; @@ -51,4 +52,10 @@ public String getModeChangeKeyText() { public float getAlphabeticKeyboardWidth() { return WidgetPlacement.dpDimension(mContext, R.dimen.keyboard_alphabetic_width); } + + @Override + public String[] getDomains(String... domains) { + return Stream.of(new String[]{".com", ".net", ".org", ".co"}, domains).flatMap(Stream::of) + .toArray(String[]::new); + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/DanishKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/DanishKeyboard.java index deac264e8..f3673c316 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/DanishKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/DanishKeyboard.java @@ -65,4 +65,9 @@ public Locale getLocale() { public String getSpaceKeyText(String aComposingText) { return StringUtils.getStringByLocale(mContext, R.string.settings_language_danish, getLocale()); } + + @Override + public String[] getDomains(String... domains) { + return super.getDomains(".dk"); + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/DutchKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/DutchKeyboard.java index a92124457..1b3bc0e9f 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/DutchKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/DutchKeyboard.java @@ -65,4 +65,9 @@ public Locale getLocale() { public String getSpaceKeyText(String aComposingText) { return StringUtils.getStringByLocale(mContext, R.string.settings_language_dutch, getLocale()); } + + @Override + public String[] getDomains(String... domains) { + return super.getDomains(".nl"); + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/EnglishKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/EnglishKeyboard.java index 41d9835da..9c753d853 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/EnglishKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/EnglishKeyboard.java @@ -10,6 +10,7 @@ import androidx.annotation.Nullable; import java.util.Locale; +import java.util.stream.Stream; public class EnglishKeyboard extends BaseKeyboard { private CustomKeyboard mKeyboard; @@ -47,4 +48,9 @@ public String getSpaceKeyText(String aComposingText) { return StringUtils.getStringByLocale(mContext, R.string.settings_language_english, getLocale()); } + + @Override + public String[] getDomains(String... domains) { + return super.getDomains(".uk", ".us"); + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/FinnishKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/FinnishKeyboard.java index 653cc9601..cdefee3bb 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/FinnishKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/FinnishKeyboard.java @@ -65,4 +65,9 @@ public Locale getLocale() { public String getSpaceKeyText(String aComposingText) { return StringUtils.getStringByLocale(mContext, R.string.settings_language_finnish, getLocale()); } + + @Override + public String[] getDomains(String... domains) { + return super.getDomains(".fi"); + } } \ No newline at end of file diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/FrenchKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/FrenchKeyboard.java index bfe133828..9a9d20b46 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/FrenchKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/FrenchKeyboard.java @@ -47,4 +47,9 @@ public Locale getLocale() { public String getSpaceKeyText(String aComposingText) { return StringUtils.getStringByLocale(mContext, R.string.settings_language_french, getLocale()); } + + @Override + public String[] getDomains(String... domains) { + return super.getDomains(".fr"); + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/GermanKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/GermanKeyboard.java index fde18ad97..9ef380c45 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/GermanKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/GermanKeyboard.java @@ -63,4 +63,9 @@ public Locale getLocale() { public String getSpaceKeyText(String aComposingText) { return StringUtils.getStringByLocale(mContext, R.string.settings_language_german, getLocale()); } + + @Override + public String[] getDomains(String... domains) { + return super.getDomains(".de"); + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ItalianKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ItalianKeyboard.java index 3b1e09003..9ff942c16 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ItalianKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ItalianKeyboard.java @@ -47,4 +47,9 @@ public Locale getLocale() { public String getSpaceKeyText(String aComposingText) { return StringUtils.getStringByLocale(mContext, R.string.settings_language_italian, getLocale()); } + + @Override + public String[] getDomains(String... domains) { + return super.getDomains(".it"); + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/JapaneseKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/JapaneseKeyboard.java index 72496abd7..41f279ebe 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/JapaneseKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/JapaneseKeyboard.java @@ -208,4 +208,9 @@ public void clear() { mConverter.init(); } + @Override + public String[] getDomains(String... domains) { + return super.getDomains(".jp"); + } + } 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 7f1a25063..8af9cf0de 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 @@ -40,6 +40,7 @@ public enum Action { default boolean usesTextOverride() { return false; } String getComposingText(String aComposing, String aCode); String getKeyboardTitle(); + default String[] getDomains(String... domains) { return null; } Locale getLocale(); String getSpaceKeyText(String aComposingText); String getEnterKeyText(int aIMEOptions, String aComposingText); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/KoreanKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/KoreanKeyboard.java index e6916bdc2..a18a119bd 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/KoreanKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/KoreanKeyboard.java @@ -405,4 +405,9 @@ public Locale getLocale() { public String getSpaceKeyText(String aComposingText) { return StringUtils.getStringByLocale(mContext, R.string.settings_language_korean, getLocale()); } + + @Override + public String[] getDomains(String... domains) { + return super.getDomains(".kr"); + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/NorwegianKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/NorwegianKeyboard.java index 601aa3bf6..3add97cc5 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/NorwegianKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/NorwegianKeyboard.java @@ -65,4 +65,9 @@ public Locale getLocale() { public String getSpaceKeyText(String aComposingText) { return StringUtils.getStringByLocale(mContext, R.string.settings_language_norwegian, getLocale()); } + + @Override + public String[] getDomains(String... domains) { + return super.getDomains(".no"); + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/PolishKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/PolishKeyboard.java index 241f98027..a548bc4a3 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/PolishKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/PolishKeyboard.java @@ -65,4 +65,9 @@ public Locale getLocale() { public String getSpaceKeyText(String aComposingText) { return StringUtils.getStringByLocale(mContext, R.string.settings_language_polish, getLocale()); } + + @Override + public String[] getDomains(String... domains) { + return super.getDomains(".po"); + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/RussianKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/RussianKeyboard.java index db3a465fb..32ac4ae41 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/RussianKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/RussianKeyboard.java @@ -65,4 +65,9 @@ public Locale getLocale() { public String getSpaceKeyText(String aComposingText) { return StringUtils.getStringByLocale(mContext, R.string.settings_language_russian, getLocale()); } + + @Override + public String[] getDomains(String... domains) { + return super.getDomains(".ru"); + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/SpanishKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/SpanishKeyboard.java index fae2f95b4..e813b5c8b 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/SpanishKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/SpanishKeyboard.java @@ -48,4 +48,9 @@ public Locale getLocale() { public String getSpaceKeyText(String aComposingText) { return StringUtils.getStringByLocale(mContext, R.string.settings_language_spanish, getLocale()); } + + @Override + public String[] getDomains(String... domains) { + return super.getDomains(".es"); + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/SwedishKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/SwedishKeyboard.java index f011de4bb..b3a9edbbc 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/SwedishKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/SwedishKeyboard.java @@ -65,4 +65,9 @@ public Locale getLocale() { public String getSpaceKeyText(String aComposingText) { return StringUtils.getStringByLocale(mContext, R.string.settings_language_swedish, getLocale()); } + + @Override + public String[] getDomains(String... domains) { + return super.getDomains(".se"); + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/LanguageSelectorView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/KeyboardSelectorView.java similarity index 59% rename from app/src/common/shared/org/mozilla/vrbrowser/ui/views/LanguageSelectorView.java rename to app/src/common/shared/org/mozilla/vrbrowser/ui/views/KeyboardSelectorView.java index 3f942ee78..ba399e545 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/LanguageSelectorView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/KeyboardSelectorView.java @@ -5,6 +5,7 @@ import android.util.TypedValue; import android.widget.FrameLayout; import android.widget.GridLayout; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -15,7 +16,7 @@ import java.util.List; -public class LanguageSelectorView extends FrameLayout { +public class KeyboardSelectorView extends FrameLayout { public static class Item { public final String title; public final Object tag; @@ -27,28 +28,29 @@ public Item(String aTitle, Object aTag) { } public interface Delegate { - void onLanguageClick(Item aItem); + void onItemClick(Item aItem); } private GridLayout mLangRowContainer; private Delegate mDelegate; private List mItems; private List mButtons = new ArrayList<>(); - private int mFirstColItemWidth; - private int mSecondColItemWidth; + private int mDomainColItemWidth; + private int mNarrowColItemWidth; + private int mWideColItemWidth; private static final int kMaxItemsPerColumn = 4; - public LanguageSelectorView(@NonNull Context context) { + public KeyboardSelectorView(@NonNull Context context) { super(context); initialize(); } - public LanguageSelectorView(@NonNull Context context, @Nullable AttributeSet attrs) { + public KeyboardSelectorView(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); initialize(); } - public LanguageSelectorView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + public KeyboardSelectorView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initialize(); } @@ -56,8 +58,9 @@ public LanguageSelectorView(@NonNull Context context, @Nullable AttributeSet att private void initialize() { inflate(getContext(), R.layout.language_selection, this); mLangRowContainer = findViewById(R.id.langRowContainer); - mFirstColItemWidth = WidgetPlacement.pixelDimension(getContext(), R.dimen.lang_selector_first_col_item_width); - mSecondColItemWidth = WidgetPlacement.pixelDimension(getContext(), R.dimen.lang_selector_second_col_item_width); + mDomainColItemWidth = WidgetPlacement.pixelDimension(getContext(), R.dimen.lang_selector_domain_col_item_width); + mNarrowColItemWidth = WidgetPlacement.pixelDimension(getContext(), R.dimen.lang_selector_narrow_col_item_width); + mWideColItemWidth = WidgetPlacement.pixelDimension(getContext(), R.dimen.lang_selector_wide_col_item_width); } public void setDelegate(Delegate aDelegate) { @@ -73,14 +76,34 @@ public void setItems(List aItems) { mLangRowContainer.setColumnCount(columns); mLangRowContainer.setRowCount(rows); - int index = 0; - for (Item item: aItems) { + int[] columnWidth = new int[columns]; + for (int i=0; i getItems() { private OnClickListener clickHandler = v -> { UITextButton button = (UITextButton) v; if (mDelegate != null) { - mDelegate.onLanguageClick((Item)button.getTag()); + mDelegate.onItemClick((Item)button.getTag()); } }; - private UITextButton createLangButton(Item aItem) { + private UITextButton createItemButton(Item aItem) { UITextButton button = new UITextButton(getContext()); button.setTintColorList(R.drawable.lang_selector_button_color); button.setBackground(getContext().getDrawable(R.drawable.lang_selector_button_background)); 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 223a5f3ce..d8d99c88a 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 @@ -54,7 +54,7 @@ import org.mozilla.vrbrowser.ui.keyboards.SwedishKeyboard; import org.mozilla.vrbrowser.ui.views.AutoCompletionView; import org.mozilla.vrbrowser.ui.views.CustomKeyboardView; -import org.mozilla.vrbrowser.ui.views.LanguageSelectorView; +import org.mozilla.vrbrowser.ui.views.KeyboardSelectorView; import org.mozilla.vrbrowser.ui.widgets.dialogs.VoiceSearchWidget; import org.mozilla.vrbrowser.ui.keyboards.ChinesePinyinKeyboard; import org.mozilla.vrbrowser.ui.keyboards.EnglishKeyboard; @@ -91,7 +91,8 @@ public class KeyboardWidget extends UIWidget implements CustomKeyboardView.OnKey private EditorInfo mEditorInfo = new EditorInfo(); private VoiceSearchWidget mVoiceSearchWidget; private AutoCompletionView mAutoCompletionView; - private LanguageSelectorView mLanguageSelectorView; + private KeyboardSelectorView mLanguageSelectorView; + private KeyboardSelectorView mDomainSelectorView; private int mKeyWidth; private int mKeyboardPopupTopMargin; @@ -178,6 +179,9 @@ private void initialize(Context aContext) { mAutoCompletionView.setExtendedHeight((int)(mWidgetPlacement.height * mWidgetPlacement.density)); mAutoCompletionView.setDelegate(this); + mDomainSelectorView = findViewById(R.id.domainSelectorView); + mDomainSelectorView.setDelegate(this::handleDomainChange); + mKeyboards = new ArrayList<>(); mKeyboards.add(new EnglishKeyboard(aContext)); mKeyboards.add(new ItalianKeyboard(aContext)); @@ -406,6 +410,7 @@ private void hideOverlays() { mPopupKeyboardView.setVisibility(View.GONE); mPopupKeyboardLayer.setVisibility(View.GONE); mLanguageSelectorView.setVisibility(View.GONE); + mDomainSelectorView.setVisibility(View.GONE); } protected void onDismiss() { @@ -498,6 +503,9 @@ public void onKey(int primaryCode, int[] keyCodes, boolean hasPopup) { case CustomKeyboard.KEYCODE_EMOJI: handleEmojiInput(); break; + case CustomKeyboard.KEYCODE_DOMAIN: + handleDomain(); + break; case ' ': handleSpace(); break; @@ -684,9 +692,9 @@ private void handleBackspace(final boolean isLongPress) { private void handleGlobeClick() { if (mLanguageSelectorView.getItems() == null || mLanguageSelectorView.getItems().size() == 0) { - ArrayList items = new ArrayList<>(); + ArrayList items = new ArrayList<>(); for (KeyboardInterface keyboard: mKeyboards) { - items.add(new LanguageSelectorView.Item(keyboard.getKeyboardTitle(), keyboard)); + items.add(new KeyboardSelectorView.Item(keyboard.getKeyboardTitle(), keyboard)); } mLanguageSelectorView.setItems(items); } @@ -701,6 +709,17 @@ private void handleEmojiInput() { mAutoCompletionView.setItems(candidates != null ? candidates.words : null); } + private void handleDomain() { + ArrayList items = new ArrayList<>(); + for (String item: mCurrentKeyboard.getDomains()) { + items.add(new KeyboardSelectorView.Item(item, item)); + } + mDomainSelectorView.setItems(items); + + mDomainSelectorView.setVisibility(View.VISIBLE); + mPopupKeyboardLayer.setVisibility(View.VISIBLE); + } + private void handleLanguageChange(KeyboardInterface aKeyboard) { cleanComposingText(); @@ -733,6 +752,15 @@ private void handleLanguageChange(KeyboardInterface aKeyboard) { mCurrentKeyboard.getAlphabeticKeyboard().setSpaceKeyLabel(spaceText); } + private void handleDomainChange(KeyboardSelectorView.Item aItem) { + handleText(aItem.title); + + disableShift(getSymbolsKeyboard()); + handleShift(false); + hideOverlays(); + updateCandidates(); + } + private void disableShift(@NonNull CustomKeyboard keyboard) { int[] shiftIndices = keyboard.getShiftKeyIndices(); for (int shiftIndex: shiftIndices) { diff --git a/app/src/main/res/layout/keyboard.xml b/app/src/main/res/layout/keyboard.xml index 325669625..2c3c1bf66 100644 --- a/app/src/main/res/layout/keyboard.xml +++ b/app/src/main/res/layout/keyboard.xml @@ -78,7 +78,7 @@ android:verticalCorrection="0dp" android:visibility="visible"/> - + android:visibility="gone"/> - + 36dp 18dp 8dp - 186dp - 198dp - 50dp + 166dp + 178dp + 30dp 36dp 8dp 28dp @@ -82,8 +82,9 @@ 125dp - 100dp - 130dp + 100dp + 130dp + 54dp 88dp diff --git a/app/src/main/res/xml/keyboard_qwerty.xml b/app/src/main/res/xml/keyboard_qwerty.xml index 36fdb2f3f..06e96bf37 100644 --- a/app/src/main/res/xml/keyboard_qwerty.xml +++ b/app/src/main/res/xml/keyboard_qwerty.xml @@ -56,6 +56,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_qwerty_danish.xml b/app/src/main/res/xml/keyboard_qwerty_danish.xml index d20b7a6ef..416f72001 100644 --- a/app/src/main/res/xml/keyboard_qwerty_danish.xml +++ b/app/src/main/res/xml/keyboard_qwerty_danish.xml @@ -57,6 +57,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_qwerty_dutch.xml b/app/src/main/res/xml/keyboard_qwerty_dutch.xml index 85526a8a6..ca93cbc2a 100644 --- a/app/src/main/res/xml/keyboard_qwerty_dutch.xml +++ b/app/src/main/res/xml/keyboard_qwerty_dutch.xml @@ -56,6 +56,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_qwerty_finnish.xml b/app/src/main/res/xml/keyboard_qwerty_finnish.xml index 3bb728780..3da0866f4 100644 --- a/app/src/main/res/xml/keyboard_qwerty_finnish.xml +++ b/app/src/main/res/xml/keyboard_qwerty_finnish.xml @@ -57,6 +57,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_qwerty_french.xml b/app/src/main/res/xml/keyboard_qwerty_french.xml index 81ecc5b81..860bed075 100644 --- a/app/src/main/res/xml/keyboard_qwerty_french.xml +++ b/app/src/main/res/xml/keyboard_qwerty_french.xml @@ -56,6 +56,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_qwerty_german.xml b/app/src/main/res/xml/keyboard_qwerty_german.xml index bff0c47ea..dda3d40b1 100644 --- a/app/src/main/res/xml/keyboard_qwerty_german.xml +++ b/app/src/main/res/xml/keyboard_qwerty_german.xml @@ -60,6 +60,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_qwerty_italian.xml b/app/src/main/res/xml/keyboard_qwerty_italian.xml index 8bd510bba..d7f037648 100644 --- a/app/src/main/res/xml/keyboard_qwerty_italian.xml +++ b/app/src/main/res/xml/keyboard_qwerty_italian.xml @@ -56,6 +56,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_qwerty_japanese.xml b/app/src/main/res/xml/keyboard_qwerty_japanese.xml index 42f5c0ebd..0031fca49 100644 --- a/app/src/main/res/xml/keyboard_qwerty_japanese.xml +++ b/app/src/main/res/xml/keyboard_qwerty_japanese.xml @@ -56,6 +56,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_qwerty_korean.xml b/app/src/main/res/xml/keyboard_qwerty_korean.xml index d0fe52727..7bc52be41 100644 --- a/app/src/main/res/xml/keyboard_qwerty_korean.xml +++ b/app/src/main/res/xml/keyboard_qwerty_korean.xml @@ -56,6 +56,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_qwerty_norwegian.xml b/app/src/main/res/xml/keyboard_qwerty_norwegian.xml index 90dd290e6..18a5bde41 100644 --- a/app/src/main/res/xml/keyboard_qwerty_norwegian.xml +++ b/app/src/main/res/xml/keyboard_qwerty_norwegian.xml @@ -57,6 +57,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_qwerty_pinyin.xml b/app/src/main/res/xml/keyboard_qwerty_pinyin.xml index e6afda83b..9c77973c4 100644 --- a/app/src/main/res/xml/keyboard_qwerty_pinyin.xml +++ b/app/src/main/res/xml/keyboard_qwerty_pinyin.xml @@ -56,6 +56,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_qwerty_polish.xml b/app/src/main/res/xml/keyboard_qwerty_polish.xml index ada313cb5..1f7f7a906 100644 --- a/app/src/main/res/xml/keyboard_qwerty_polish.xml +++ b/app/src/main/res/xml/keyboard_qwerty_polish.xml @@ -56,6 +56,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_qwerty_russian.xml b/app/src/main/res/xml/keyboard_qwerty_russian.xml index a000ec3c4..089ef5eed 100644 --- a/app/src/main/res/xml/keyboard_qwerty_russian.xml +++ b/app/src/main/res/xml/keyboard_qwerty_russian.xml @@ -60,6 +60,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_qwerty_spanish.xml b/app/src/main/res/xml/keyboard_qwerty_spanish.xml index f1277c77e..3328bf724 100644 --- a/app/src/main/res/xml/keyboard_qwerty_spanish.xml +++ b/app/src/main/res/xml/keyboard_qwerty_spanish.xml @@ -56,6 +56,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_qwerty_swedish.xml b/app/src/main/res/xml/keyboard_qwerty_swedish.xml index cc2041f69..a0f8fbc7c 100644 --- a/app/src/main/res/xml/keyboard_qwerty_swedish.xml +++ b/app/src/main/res/xml/keyboard_qwerty_swedish.xml @@ -57,6 +57,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_symbols.xml b/app/src/main/res/xml/keyboard_symbols.xml index b386f85d7..65b8db578 100644 --- a/app/src/main/res/xml/keyboard_symbols.xml +++ b/app/src/main/res/xml/keyboard_symbols.xml @@ -56,6 +56,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_symbols_danish.xml b/app/src/main/res/xml/keyboard_symbols_danish.xml index b7467c0cc..3b95a7de1 100644 --- a/app/src/main/res/xml/keyboard_symbols_danish.xml +++ b/app/src/main/res/xml/keyboard_symbols_danish.xml @@ -57,6 +57,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_symbols_finnish.xml b/app/src/main/res/xml/keyboard_symbols_finnish.xml index b7467c0cc..3b95a7de1 100644 --- a/app/src/main/res/xml/keyboard_symbols_finnish.xml +++ b/app/src/main/res/xml/keyboard_symbols_finnish.xml @@ -57,6 +57,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_symbols_german.xml b/app/src/main/res/xml/keyboard_symbols_german.xml index e85302ed4..4712691bd 100644 --- a/app/src/main/res/xml/keyboard_symbols_german.xml +++ b/app/src/main/res/xml/keyboard_symbols_german.xml @@ -60,6 +60,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_symbols_japanese.xml b/app/src/main/res/xml/keyboard_symbols_japanese.xml index 8f28c83e8..9c02e1a78 100644 --- a/app/src/main/res/xml/keyboard_symbols_japanese.xml +++ b/app/src/main/res/xml/keyboard_symbols_japanese.xml @@ -56,6 +56,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_symbols_norwegian.xml b/app/src/main/res/xml/keyboard_symbols_norwegian.xml index b7467c0cc..3b95a7de1 100644 --- a/app/src/main/res/xml/keyboard_symbols_norwegian.xml +++ b/app/src/main/res/xml/keyboard_symbols_norwegian.xml @@ -57,6 +57,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_symbols_polish.xml b/app/src/main/res/xml/keyboard_symbols_polish.xml index c74077ede..18372fdec 100644 --- a/app/src/main/res/xml/keyboard_symbols_polish.xml +++ b/app/src/main/res/xml/keyboard_symbols_polish.xml @@ -56,6 +56,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_symbols_russian.xml b/app/src/main/res/xml/keyboard_symbols_russian.xml index 72955ec1b..754a85ee2 100644 --- a/app/src/main/res/xml/keyboard_symbols_russian.xml +++ b/app/src/main/res/xml/keyboard_symbols_russian.xml @@ -60,6 +60,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard_symbols_swedish.xml b/app/src/main/res/xml/keyboard_symbols_swedish.xml index b7467c0cc..3b95a7de1 100644 --- a/app/src/main/res/xml/keyboard_symbols_swedish.xml +++ b/app/src/main/res/xml/keyboard_symbols_swedish.xml @@ -57,6 +57,7 @@ + \ No newline at end of file