Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Dutch keyboard (#1992)
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo authored and MortimerGoro committed Oct 18, 2019
1 parent df5b610 commit b7bc00a
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
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 DutchKeyboard extends BaseKeyboard {
private CustomKeyboard mKeyboard;
private CustomKeyboard mSymbolsKeyboard;
private Locale mLocale;

public DutchKeyboard(Context aContext) {
super(aContext);
mLocale = new Locale("nl", "NL");
}

@NonNull
@Override
public CustomKeyboard getAlphabeticKeyboard() {
if (mKeyboard == null) {
mKeyboard = new CustomKeyboard(mContext.getApplicationContext(), R.xml.keyboard_qwerty_dutch);
}
return mKeyboard;
}

@Nullable
@Override
public CustomKeyboard getSymbolsKeyboard() {
if (mSymbolsKeyboard == null) {
mSymbolsKeyboard = new CustomKeyboard(mContext.getApplicationContext(), R.xml.keyboard_symbols);
}
return mSymbolsKeyboard;
}

@Override
public float getAlphabeticKeyboardWidth() {
return WidgetPlacement.dpDimension(mContext, R.dimen.keyboard_alphabetic_width);
}

@Nullable
@Override
public CandidatesResult getCandidates(String aText) {
return null;
}

@Override
public String getKeyboardTitle() {
return StringUtils.getStringByLocale(mContext, R.string.settings_language_dutch, getLocale());
}

@Override
public Locale getLocale() {
return mLocale;
}

@Override
public String getSpaceKeyText(String aComposingText) {
return StringUtils.getStringByLocale(mContext, R.string.settings_language_dutch, getLocale());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.mozilla.vrbrowser.input.CustomKeyboard;
import org.mozilla.vrbrowser.telemetry.TelemetryWrapper;
import org.mozilla.vrbrowser.ui.keyboards.DanishKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.DutchKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.ItalianKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.FrenchKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.GermanKeyboard;
Expand Down Expand Up @@ -187,6 +188,7 @@ private void initialize(Context aContext) {
mKeyboards.add(new JapaneseKeyboard(aContext));
mKeyboards.add(new PolishKeyboard(aContext));
mKeyboards.add(new DanishKeyboard(aContext));
mKeyboards.add(new DutchKeyboard(aContext));

mDefaultKeyboardSymbols = new CustomKeyboard(aContext.getApplicationContext(), R.xml.keyboard_symbols);
mKeyboardNumeric = new CustomKeyboard(aContext.getApplicationContext(), R.xml.keyboard_numeric);
Expand Down Expand Up @@ -715,6 +717,9 @@ private void handleLanguageChange(KeyboardInterface aKeyboard) {
handleShift(false);
hideOverlays();
updateCandidates();

String spaceText = mCurrentKeyboard.getSpaceKeyText(mComposingText).toUpperCase();
mCurrentKeyboard.getAlphabeticKeyboard().setSpaceKeyLabel(spaceText);
}

private void disableShift(@NonNull CustomKeyboard keyboard) {
Expand Down Expand Up @@ -902,11 +907,9 @@ private void updateCandidates() {
}

private void updateSpecialKeyLabels() {
String spaceText = mCurrentKeyboard.getSpaceKeyText(mComposingText).toUpperCase();
String enterText = mCurrentKeyboard.getEnterKeyText(mEditorInfo.imeOptions, mComposingText);
String modeChangeText = mCurrentKeyboard.getModeChangeKeyText();
boolean changed = mCurrentKeyboard.getAlphabeticKeyboard().setSpaceKeyLabel(spaceText);
changed |= mCurrentKeyboard.getAlphabeticKeyboard().setEnterKeyLabel(enterText);
boolean changed = mCurrentKeyboard.getAlphabeticKeyboard().setEnterKeyLabel(enterText);
CustomKeyboard symbolsKeyboard = getSymbolsKeyboard();
changed |= symbolsKeyboard.setModeChangeKeyLabel(modeChangeText);
symbolsKeyboard.setEnterKeyLabel(enterText);
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/values/non_L10n.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<string name="language_it_IT" translatable="false">Italiano</string>
<string name="language_pl_PL" translatable="false">Polski</string>
<string name="language_da_DK" translatable="false">Dansk</string>
<string name="language_nl_NL" translatable="false">Nederlands</string>

<string name="pinyin_spacebar_selection" translatable="false">选定</string>
<string name="pinyin_spacebar_space" translatable="false">空格</string>
Expand Down Expand Up @@ -123,6 +124,7 @@
<string name="keyboard_popup_x" translatable="false">xẍẋ</string>
<string name="keyboard_popup_y" translatable="false">yýỳŷÿỹ</string>
<string name="keyboard_popup_z" translatable="false">zźẑžżẓ</string>
<string name="keyboard_popup_dot" translatable="false">. \.com \.net \.org</string>

<!-- Keyboard Polish -->
<string name="keyboard_pl_PL_popup_e" translatable="false">eęèéêëẽėē</string>
Expand All @@ -148,6 +150,13 @@
<string name="keyboard_da_DK_popup_ø" translatable="false">øö</string>
<string name="keyboard_da_DK_popup_n" translatable="false">nñń</string>

<!-- Keyboard Dutch -->
<string name="keyboard_nl_NL_popup_e" translatable="false">eéëêèęėēěĕə</string>
<string name="keyboard_nl_NL_popup_a" translatable="false">aáäâàæãåāăą</string>
<string name="keyboard_nl_NL_popup_o" translatable="false">oöôòõœøōóő</string>
<string name="keyboard_nl_NL_popup_u" translatable="false">uúüûùūůų</string>
<string name="keyboard_nl_NL_popup_i" translatable="false">ìíiïîįī</string>

<!-- SEARCH ENGINES -->
<string name="geolocation_api_url" translatable="false">https://location.services.mozilla.com/v1/country</string>
<!-- Google -->
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/options_values.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
<item>@string/language_it_IT</item>
<item>@string/language_da_DK</item>
<item>@string/language_pl_PL</item>
<item>@string/language_nl_NL</item>
</string-array>

<string-array name="developer_options_voice_search_languages_values" translatable="false">
Expand All @@ -113,6 +114,7 @@
<item>it-IT</item>
<item>da-DK</item>
<item>pl-PL</item>
<item>nl-NL</item>
</string-array>

<!-- Language Options -->
Expand All @@ -130,6 +132,7 @@
<item>@string/language_it_IT</item>
<item>@string/language_da_DK</item>
<item>@string/language_pl_PL</item>
<item>@string/language_nl_NL</item>
</string-array>

<string-array name="developer_options_display_languages_values" translatable="false">
Expand All @@ -146,6 +149,7 @@
<item>it-IT</item>
<item>da-DK</item>
<item>pl-PL</item>
<item>nl-NL</item>
</string-array>

<!-- Clear Cache Options -->
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@
changes the app and the language of the speech-recognition-based search to 'Danish'. -->
<string name="settings_language_danish">Danish</string>

<!-- This string is used to label a radio button in the settings language dialog that, when pressed,
changes the app and the language of the speech-recognition-based search to 'Dutch'. -->
<string name="settings_language_dutch">Dutch</string>

<!-- This string is used to label a button in the 'Settings' dialog window that, when pressed,
opens a dialog box that contains display-related settings: window size, pixel density, etc. -->
<string name="settings_display">Display</string>
Expand Down
61 changes: 61 additions & 0 deletions app/src/main/res/xml/keyboard_qwerty_dutch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:horizontalGap="@dimen/keyboard_horizontal_gap"
android:verticalGap="@dimen/keyboard_vertical_gap"
android:keyWidth="@dimen/keyboard_key_width"
android:keyHeight="@dimen/keyboard_key_height">
<Row>
<Key android:codes="113" android:keyLabel="q" android:keyEdgeFlags="left" android:popupKeyboard="@xml/keyboard_popup" android:popupCharacters="@string/keyboard_popup_q" />
<Key android:codes="119" android:keyLabel="w" android:popupCharacters="@string/keyboard_popup_w" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="101" android:keyLabel="e" android:popupCharacters="@string/keyboard_nl_NL_popup_e" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="114" android:keyLabel="r" android:popupCharacters="@string/keyboard_popup_r" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="116" android:keyLabel="t" android:popupCharacters="@string/keyboard_popup_t" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="121" android:keyLabel="y" android:popupCharacters="@string/keyboard_popup_y" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="117" android:keyLabel="u" android:popupCharacters="@string/keyboard_nl_NL_popup_u" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="105" android:keyLabel="i" android:popupCharacters="@string/keyboard_nl_NL_popup_i" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="111" android:keyLabel="o" android:popupCharacters="@string/keyboard_nl_NL_popup_o" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="112" android:keyLabel="p" android:popupCharacters="@string/keyboard_popup_p" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="95" android:keyLabel="_"/>
<Key android:codes="-5" android:keyIcon="@drawable/ic_icon_keyboard_backspace" android:isRepeatable="true" android:keyWidth="@dimen/keyboard_key_backspace_width" />
</Row>

<Row>
<Key android:codes="97" android:keyLabel="a" android:popupCharacters="@string/keyboard_nl_NL_popup_a" android:popupKeyboard="@xml/keyboard_popup" android:keyEdgeFlags="left" android:horizontalGap="@dimen/keyboard_left_margin" />
<Key android:codes="115" android:keyLabel="s" android:popupCharacters="@string/keyboard_popup_s" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="100" android:keyLabel="d" android:popupCharacters="@string/keyboard_popup_d" android:popupKeyboard="@xml/keyboard_popup"/>
<Key android:codes="102" android:keyLabel="f" android:popupCharacters="@string/keyboard_popup_f" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="103" android:keyLabel="g" android:popupCharacters="@string/keyboard_popup_g" android:popupKeyboard="@xml/keyboard_popup"/>
<Key android:codes="104" android:keyLabel="h" android:popupCharacters="@string/keyboard_popup_h" android:popupKeyboard="@xml/keyboard_popup"/>
<Key android:codes="106" android:keyLabel="j" android:popupCharacters="@string/keyboard_popup_j" android:popupKeyboard="@xml/keyboard_popup"/>
<Key android:codes="107" android:keyLabel="k" android:popupCharacters="@string/keyboard_popup_k" android:popupKeyboard="@xml/keyboard_popup"/>
<Key android:codes="108" android:keyLabel="l" android:popupCharacters="@string/keyboard_popup_l" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="58" android:keyLabel=":"/>
<Key android:codes="-4" android:keyLabel="@string/keyboard_enter_label" android:keyWidth="@dimen/keyboard_key_enter_width" />
</Row>

<Row>
<Key android:codes="-1" android:keyIcon="@drawable/ic_icon_keyboard_shift_off" android:keyEdgeFlags="left" />
<Key android:codes="122" android:keyLabel="z" android:popupCharacters="@string/keyboard_popup_z" android:popupKeyboard="@xml/keyboard_popup"/>
<Key android:codes="120" android:keyLabel="x" android:popupCharacters="@string/keyboard_popup_x" android:popupKeyboard="@xml/keyboard_popup"/>
<Key android:codes="99" android:keyLabel="c" android:popupCharacters="@string/keyboard_popup_c" android:popupKeyboard="@xml/keyboard_popup"/>
<Key android:codes="118" android:keyLabel="v" android:popupCharacters="@string/keyboard_popup_v" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="98" android:keyLabel="b" android:popupCharacters="@string/keyboard_popup_b" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="110" android:keyLabel="n" android:popupCharacters="@string/keyboard_popup_n" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="109" android:keyLabel="m" android:popupCharacters="@string/keyboard_popup_m" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="45" android:keyLabel="-" />
<Key android:codes="43" android:keyLabel="+" />
<Key android:codes="47" android:keyLabel="/" />
<Key android:codes="-1" android:keyIcon="@drawable/ic_icon_keyboard_shift_off"/>
</Row>

<Row>
<Key android:codes="-2" android:keyLabel="@string/keyboard_symbol" android:keyEdgeFlags="left" />
<Key android:codes="-12" android:keyIcon="@drawable/ic_icon_keyboard_globe" />
<Key android:codes="32" android:keyLabel="" android:keyWidth="@dimen/keyboard_key_space_width" android:isRepeatable="true"/>
<Key android:codes="44" android:keyLabel=","/>
<Key android:codes="46" android:keyLabel="."/>
<Key android:codes="33" android:keyLabel="!" android:popupCharacters="" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="63" android:keyLabel="\?" android:popupCharacters="\?¿" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="64" android:keyLabel="\@"/>
</Row>
</Keyboard>

0 comments on commit b7bc00a

Please sign in to comment.