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

Commit

Permalink
Swedish keyboard (#1996)
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo authored and bluemarvin committed Oct 18, 2019
1 parent 66414be commit d4cf2e9
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 2 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 SwedishKeyboard extends BaseKeyboard {
private CustomKeyboard mKeyboard;
private CustomKeyboard mSymbolsKeyboard;
private Locale mLocale;

public SwedishKeyboard(Context aContext) {
super(aContext);
mLocale = new Locale("sv", "SE");
}

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

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

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

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

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

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

@Override
public String getSpaceKeyText(String aComposingText) {
return StringUtils.getStringByLocale(mContext, R.string.settings_language_swedish, getLocale());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.mozilla.vrbrowser.ui.keyboards.RussianKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.KoreanKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.SpanishKeyboard;
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;
Expand Down Expand Up @@ -189,6 +190,7 @@ private void initialize(Context aContext) {
mKeyboards.add(new JapaneseKeyboard(aContext));
mKeyboards.add(new PolishKeyboard(aContext));
mKeyboards.add(new DanishKeyboard(aContext));
mKeyboards.add(new SwedishKeyboard(aContext));
mKeyboards.add(new FinnishKeyboard(aContext));
mKeyboards.add(new DutchKeyboard(aContext));

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/dimen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<dimen name="keyboard_height">188dp</dimen>
<dimen name="keyboard_alphabetic_width">526dp</dimen>
<dimen name="keyboard_alphabetic_width_danish">540dp</dimen>
<dimen name="keyboard_alphabetic_width_swedish">540dp</dimen>
<dimen name="keyboard_alphabetic_width_finnish">540dp</dimen>
<dimen name="keyboard_alphabetic_width_extra_column">564dp</dimen>
<dimen name="keyboard_numeric_width">144dp</dimen>
Expand Down
11 changes: 10 additions & 1 deletion 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_sv_SE" translatable="false">Svensk</string>
<string name="language_fi_FI" translatable="false">Suomea</string>
<string name="language_nl_NL" translatable="false">Nederlands</string>

Expand Down Expand Up @@ -151,7 +152,15 @@
<string name="keyboard_da_DK_popup_ø" translatable="false">øö</string>
<string name="keyboard_da_DK_popup_n" translatable="false">nñń</string>

<!-- Keyboard Finnish -->
<!-- Keyboard Swedish -->
<string name="keyboard_sv_SE_popup_a" translatable="false">aà</string>
<string name="keyboard_sv_SE_popup_e" translatable="false">eéèêëę</string>
<string name="keyboard_sv_SE_popup_u" translatable="false">ûuüùûū</string>
<string name="keyboard_sv_SE_popup_o" translatable="false">oœôóòõō</string>
<string name="keyboard_sv_SE_popup_ö" translatable="false">öø</string>
<string name="keyboard_sv_SE_popup_ä" translatable="false">äæ</string>

<!-- Keyboard Finnish -->
<string name="keyboard_fi_FI_popup_a" translatable="false">aæàáâãā</string>
<string name="keyboard_fi_FI_popup_d" translatable="false">dđ</string>
<string name="keyboard_fi_FI_popup_e" translatable="false">eéèëê</string>
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_sv_SE</item>
<item>@string/language_fi_FI</item>
<item>@string/language_nl_NL</item>
</string-array>
Expand All @@ -115,6 +116,7 @@
<item>it-IT</item>
<item>da-DK</item>
<item>pl-PL</item>
<item>sv-SE</item>
<item>fi-FI</item>
<item>nl-NL</item>
</string-array>
Expand All @@ -134,6 +136,7 @@
<item>@string/language_it_IT</item>
<item>@string/language_da_DK</item>
<item>@string/language_pl_PL</item>
<item>@string/language_sv_SE</item>
<item>@string/language_fi_FI</item>
<item>@string/language_nl_NL</item>
</string-array>
Expand All @@ -152,6 +155,7 @@
<item>it-IT</item>
<item>da-DK</item>
<item>pl-PL</item>
<item>sv-SE</item>
<item>fi-FI</item>
<item>nl-NL</item>
</string-array>
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,15 @@
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 'Danish'. -->
<string name="settings_language_swedish">Swedish</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 'Finnish'. -->
<string name="settings_language_finnish">Finnish</string>

<!-- This string is used to label a radio button in the settings language dialog that, when pressed,
<!-- 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>

Expand Down
62 changes: 62 additions & 0 deletions app/src/main/res/xml/keyboard_qwerty_swedish.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?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" android:horizontalGap="@dimen/keyboard_left_margin_half" />
<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_sv_SE_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_sv_SE_popup_u" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="105" android:keyLabel="i" android:popupCharacters="@string/keyboard_popup_i" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:codes="111" android:keyLabel="o" android:popupCharacters="@string/keyboard_sv_SE_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:keyOutputText="å" 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_sv_SE_popup_a" android:popupKeyboard="@xml/keyboard_popup" android:keyEdgeFlags="left" />
<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:keyOutputText="ö" android:keyLabel="ö" android:popupCharacters="@string/keyboard_sv_SE_popup_ö" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:keyOutputText="ä" android:keyLabel="ä" android:popupCharacters="@string/keyboard_sv_SE_popup_ä" android:popupKeyboard="@xml/keyboard_popup"/>
<Key android:codes="-4" android:keyLabel="@string/keyboard_enter_label" android:keyWidth="@dimen/keyboard_key_enter_width_small" />
</Row>

<Row>
<Key android:codes="-1" android:keyIcon="@drawable/ic_icon_keyboard_shift_off" android:keyEdgeFlags="left" android:horizontalGap="@dimen/keyboard_left_margin" />
<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="%&amp;=" android:keyEdgeFlags="left" android:horizontalGap="@dimen/keyboard_left_margin"/>
<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>
62 changes: 62 additions & 0 deletions app/src/main/res/xml/keyboard_symbols_swedish.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?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="8364" android:keyLabel="" android:keyEdgeFlags="left" android:horizontalGap="@dimen/keyboard_left_margin_half"/>
<Key android:codes="163" android:keyLabel="£"/>
<Key android:codes="165" android:keyLabel="¥"/>
<Key android:codes="36" android:keyLabel="$"/>
<Key android:codes="199" android:keyLabel="ç"/>
<Key android:codes="37" android:keyLabel="%"/>
<Key android:codes="38" android:keyLabel="&amp;"/>
<Key android:codes="40" android:keyLabel="("/>
<Key android:codes="41" android:keyLabel=")"/>
<Key android:codes="61" android:keyLabel="="/>
<Key android:codes="61" 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="186" android:keyLabel="º" android:keyEdgeFlags="left"/>
<Key android:codes="94" android:keyLabel="^" />
<Key android:codes="167" android:keyLabel="§" />
<Key android:codes="123" android:keyLabel="{"/>
<Key android:codes="125" android:keyLabel="}"/>
<Key android:codes="91" android:keyLabel="["/>
<Key android:codes="93" android:keyLabel="]"/>
<Key android:codes="124" android:keyLabel="|"/>
<Key android:codes="59" android:keyLabel=";"/>
<Key android:codes="58" android:keyLabel=":"/>
<Key android:codes="34" android:keyLabel=""/>
<Key android:codes="-4" android:keyLabel="@string/keyboard_enter_label" android:keyWidth="@dimen/keyboard_key_enter_width_small" />
</Row>

<Row>
<Key android:codes="-1" android:keyIcon="@drawable/ic_icon_keyboard_shift_on" android:keyEdgeFlags="left" android:horizontalGap="@dimen/keyboard_left_margin"/>
<Key android:codes="60" android:keyLabel="&lt;"/>
<Key android:codes="62" android:keyLabel="&gt;"/>
<Key android:codes="39" android:keyLabel="`"/>
<Key android:codes="126" android:keyLabel="~"/>
<Key android:codes="39" android:keyLabel="´"/>
<Key android:codes="34" android:keyLabel="&quot;"/>
<Key android:codes="58" android:keyLabel="\\"/>
<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_on" />
</Row>

<Row>
<Key android:codes="-2" android:keyLabel="@string/keyboard_mode_change" android:keyEdgeFlags="left" android:horizontalGap="@dimen/keyboard_left_margin" />
<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 d4cf2e9

Please sign in to comment.