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

Commit a2ce8ca

Browse files
MortimerGorokeianhzo
authored andcommitted
Implement Russian keyboard (#1292)
1 parent acbd7af commit a2ce8ca

File tree

7 files changed

+200
-2
lines changed

7 files changed

+200
-2
lines changed

app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/GermanKeyboard.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public CustomKeyboard getSymbolsKeyboard() {
4040

4141
@Override
4242
public float getAlphabeticKeyboardWidth() {
43-
return WidgetPlacement.dpDimension(mContext, R.dimen.keyboard_alphabetic_width_german);
43+
return WidgetPlacement.dpDimension(mContext, R.dimen.keyboard_alphabetic_width_extra_column);
4444
}
4545

4646
@Nullable
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package org.mozilla.vrbrowser.ui.keyboards;
2+
3+
import android.content.Context;
4+
5+
import androidx.annotation.NonNull;
6+
import androidx.annotation.Nullable;
7+
8+
import org.mozilla.vrbrowser.R;
9+
import org.mozilla.vrbrowser.input.CustomKeyboard;
10+
import org.mozilla.vrbrowser.ui.widgets.WidgetPlacement;
11+
import org.mozilla.vrbrowser.utils.StringUtils;
12+
13+
import java.util.Locale;
14+
15+
public class RussianKeyboard extends BaseKeyboard {
16+
private CustomKeyboard mKeyboard;
17+
private CustomKeyboard mSymbolsKeyboard;
18+
private Locale mLocale;
19+
20+
public RussianKeyboard(Context aContext) {
21+
super(aContext);
22+
mLocale = new Locale("ru", "RU");
23+
}
24+
25+
@NonNull
26+
@Override
27+
public CustomKeyboard getAlphabeticKeyboard() {
28+
if (mKeyboard == null) {
29+
mKeyboard = new CustomKeyboard(mContext.getApplicationContext(), R.xml.keyboard_qwerty_russian);
30+
}
31+
return mKeyboard;
32+
}
33+
34+
@Nullable
35+
@Override
36+
public CustomKeyboard getSymbolsKeyboard() {
37+
if (mSymbolsKeyboard == null) {
38+
mSymbolsKeyboard = new CustomKeyboard(mContext.getApplicationContext(), R.xml.keyboard_symbols_russian);
39+
}
40+
return mSymbolsKeyboard;
41+
}
42+
43+
@Override
44+
public float getAlphabeticKeyboardWidth() {
45+
return WidgetPlacement.dpDimension(mContext, R.dimen.keyboard_alphabetic_width_extra_column);
46+
}
47+
48+
@Nullable
49+
@Override
50+
public CandidatesResult getCandidates(String aText) {
51+
return null;
52+
}
53+
54+
@Override
55+
public String getKeyboardTitle() {
56+
return StringUtils.getStringByLocale(mContext, R.string.settings_language_italian, getLocale());
57+
}
58+
59+
@Override
60+
public Locale getLocale() {
61+
return mLocale;
62+
}
63+
}

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/KeyboardWidget.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.mozilla.vrbrowser.ui.keyboards.GermanKeyboard;
4040
import org.mozilla.vrbrowser.ui.keyboards.ChineseZhuyinKeyboard;
4141
import org.mozilla.vrbrowser.ui.keyboards.KeyboardInterface;
42+
import org.mozilla.vrbrowser.ui.keyboards.RussianKeyboard;
4243
import org.mozilla.vrbrowser.ui.keyboards.SpanishKeyboard;
4344
import org.mozilla.vrbrowser.ui.views.AutoCompletionView;
4445
import org.mozilla.vrbrowser.ui.views.CustomKeyboardView;
@@ -133,6 +134,7 @@ private void initialize(Context aContext) {
133134
mKeyboards.add(new FrenchKeyboard(aContext));
134135
mKeyboards.add(new GermanKeyboard(aContext));
135136
mKeyboards.add(new SpanishKeyboard(aContext));
137+
mKeyboards.add(new RussianKeyboard(aContext));
136138
mKeyboards.add(new ChinesePinyinKeyboard(aContext));
137139
mKeyboards.add(new ChineseZhuyinKeyboard(aContext));
138140

app/src/main/res/values/dimen.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<item name="keyboard_world_rotation" format="float" type="dimen">-35.0</item>
2424
<dimen name="keyboard_height">188dp</dimen>
2525
<dimen name="keyboard_alphabetic_width">526dp</dimen>
26-
<dimen name="keyboard_alphabetic_width_german">564dp</dimen>
26+
<dimen name="keyboard_alphabetic_width_extra_column">564dp</dimen>
2727
<dimen name="keyboard_numeric_width">144dp</dimen>
2828
<dimen name="keyboard_zhuyin_height">250dp</dimen>
2929
<dimen name="keyboard_horizontal_gap">4dp</dimen>

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@
168168
changes the app and the language of the speech-recognition-based search to 'Italian'. -->
169169
<string name="settings_language_italian">Italian</string>
170170

171+
<!-- This string is used to label a radio button in the settings language dialog that, when pressed,
172+
changes the app and the language of the speech-recognition-based search to 'Italian'. -->
173+
<string name="settings_language_russian">Russian</string>
174+
171175
<!-- This string is used to label a button in the 'Settings' dialog window that, when pressed,
172176
opens a dialog box that contains display-related settings: window size, pixel density, etc. -->
173177
<string name="settings_display">Display</string>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:horizontalGap="@dimen/keyboard_horizontal_gap"
4+
android:verticalGap="@dimen/keyboard_vertical_gap"
5+
android:keyWidth="@dimen/keyboard_key_width"
6+
android:keyHeight="@dimen/keyboard_key_height">
7+
<Row>
8+
<Key android:keyLabel="й" android:keyEdgeFlags="left" />
9+
<Key android:keyLabel="ц" />
10+
<Key android:keyLabel="у" />
11+
<Key android:keyLabel="к" />
12+
<Key android:keyLabel="е" android:popupCharacters="её" android:popupKeyboard="@xml/keyboard_popup" />
13+
<Key android:keyLabel="н" />
14+
<Key android:keyLabel="г" />
15+
<Key android:keyLabel="ш" />
16+
<Key android:keyLabel="щ" />
17+
<Key android:keyLabel="з" />
18+
<Key android:keyLabel="х" />
19+
<Key android:keyLabel="ъ" />
20+
<Key android:codes="-5" android:keyIcon="@drawable/ic_icon_keyboard_backspace" android:isRepeatable="true" android:keyWidth="@dimen/keyboard_key_backspace_width" />
21+
</Row>
22+
23+
<Row>
24+
<Key android:keyLabel="ф" android:keyEdgeFlags="left" android:horizontalGap="@dimen/keyboard_left_margin" />
25+
<Key android:keyLabel="ы" />
26+
<Key android:keyLabel="в" />
27+
<Key android:keyLabel="а" />
28+
<Key android:keyLabel="п" />
29+
<Key android:keyLabel="р" />
30+
<Key android:keyLabel="о" />
31+
<Key android:keyLabel="л" />
32+
<Key android:keyLabel="д" />
33+
<Key android:keyLabel="ж" />
34+
<Key android:keyLabel="э" />
35+
<Key android:codes="-4" android:keyLabel="@string/keyboard_enter_label" android:keyWidth="@dimen/keyboard_key_enter_width" />
36+
</Row>
37+
38+
<Row>
39+
<Key android:codes="-1" android:keyIcon="@drawable/ic_icon_keyboard_shift_off" android:keyEdgeFlags="left"/>
40+
<Key android:keyLabel="я" />
41+
<Key android:keyLabel="ч" />
42+
<Key android:keyLabel="с" />
43+
<Key android:keyLabel="м" />
44+
<Key android:keyLabel="и" />
45+
<Key android:keyLabel="т" />
46+
<Key android:keyLabel="ь" />
47+
<Key android:keyLabel="б" />
48+
<Key android:keyLabel="ю" />
49+
<Key android:keyLabel="ë" />
50+
<Key android:keyLabel="/" />
51+
<Key android:codes="-1" android:keyIcon="@drawable/ic_icon_keyboard_shift_off" />
52+
</Row>
53+
54+
<Row>
55+
<Key android:codes="-2" android:keyLabel="@string/keyboard_symbol" android:keyEdgeFlags="left"/>
56+
<Key android:codes="-12" android:keyIcon="@drawable/ic_icon_keyboard_globe" />
57+
<Key android:codes="32" android:keyLabel="" android:keyWidth="@dimen/keyboard_key_space_width" android:isRepeatable="true"/>
58+
<Key android:codes="58" android:keyLabel=":"/>
59+
<Key android:codes="44" android:keyLabel=","/>
60+
<Key android:codes="46" android:keyLabel="."/>
61+
<Key android:codes="33" android:keyLabel="!" android:popupCharacters="" android:popupKeyboard="@xml/keyboard_popup" />
62+
<Key android:codes="63" android:keyLabel="\?" android:popupCharacters="\?¿" android:popupKeyboard="@xml/keyboard_popup" />
63+
<Key android:codes="64" android:keyLabel="\@"/>
64+
</Row>
65+
</Keyboard>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:horizontalGap="@dimen/keyboard_horizontal_gap"
4+
android:verticalGap="@dimen/keyboard_vertical_gap"
5+
android:keyWidth="@dimen/keyboard_key_width"
6+
android:keyHeight="@dimen/keyboard_key_height">
7+
<Row>
8+
<Key android:codes="8364" android:keyLabel="" android:keyEdgeFlags="left"/>
9+
<Key android:codes="163" android:keyLabel="£"/>
10+
<Key android:codes="165" android:keyLabel="¥"/>
11+
<Key android:codes="36" android:keyLabel="$"/>
12+
<Key android:codes="199" android:keyLabel="ç"/>
13+
<Key android:codes="37" android:keyLabel="%"/>
14+
<Key android:codes="38" android:keyLabel="&amp;"/>
15+
<Key android:codes="40" android:keyLabel="("/>
16+
<Key android:codes="41" android:keyLabel=")"/>
17+
<Key android:codes="61" android:keyLabel="="/>
18+
<Key android:codes="95" android:keyLabel="_"/>
19+
<Key android:keyOutputText="±" android:keyLabel="±"/>
20+
<Key android:codes="-5" android:keyIcon="@drawable/ic_icon_keyboard_backspace" android:isRepeatable="true" android:keyWidth="@dimen/keyboard_key_backspace_width"/>
21+
</Row>
22+
23+
<Row>
24+
<Key android:codes="186" android:keyLabel="º" android:keyEdgeFlags="left" android:horizontalGap="@dimen/keyboard_left_margin"/>
25+
<Key android:codes="94" android:keyLabel="^" />
26+
<Key android:codes="167" android:keyLabel="§" />
27+
<Key android:codes="123" android:keyLabel="{"/>
28+
<Key android:codes="125" android:keyLabel="}"/>
29+
<Key android:codes="91" android:keyLabel="["/>
30+
<Key android:codes="93" android:keyLabel="]"/>
31+
<Key android:codes="124" android:keyLabel="|"/>
32+
<Key android:codes="39" android:keyLabel="'"/>
33+
<Key android:codes="59" android:keyLabel=";"/>
34+
<Key android:keyOutputText="º" android:keyLabel="º"/>
35+
<Key android:codes="-4" android:keyLabel="@string/keyboard_enter_label" android:keyWidth="@dimen/keyboard_key_enter_width" />
36+
</Row>
37+
38+
<Row>
39+
<Key android:codes="60" android:keyLabel="&lt;" android:keyEdgeFlags="left"/>
40+
<Key android:codes="62" android:keyLabel="&gt;"/>
41+
<Key android:codes="39" android:keyLabel="`"/>
42+
<Key android:codes="126" android:keyLabel="~"/>
43+
<Key android:codes="39" android:keyLabel="´"/>
44+
<Key android:codes="34" android:keyLabel="&quot;"/>
45+
<Key android:codes="92" android:keyLabel="\\" />
46+
<Key android:codes="39" android:keyLabel="'"/>
47+
<Key android:keyOutputText="" android:keyLabel="" />
48+
<Key android:codes="45" android:keyLabel="-" />
49+
<Key android:codes="43" android:keyLabel="+" />
50+
<Key android:codes="47" android:keyLabel="/" />
51+
</Row>
52+
53+
<Row>
54+
<Key android:codes="-2" android:keyLabel="@string/keyboard_mode_change" android:keyEdgeFlags="left" />
55+
<Key android:codes="-12" android:keyIcon="@drawable/ic_icon_keyboard_globe" />
56+
<Key android:codes="32" android:keyLabel="" android:keyWidth="@dimen/keyboard_key_german_space_width" android:isRepeatable="true"/>
57+
<Key android:codes="58" android:keyLabel=":"/>
58+
<Key android:codes="44" android:keyLabel=","/>
59+
<Key android:codes="46" android:keyLabel="."/>
60+
<Key android:codes="33" android:keyLabel="!" android:popupCharacters="" android:popupKeyboard="@xml/keyboard_popup" />
61+
<Key android:codes="63" android:keyLabel="\?" android:popupCharacters="\?¿" android:popupKeyboard="@xml/keyboard_popup" />
62+
<Key android:codes="64" android:keyLabel="\@"/>
63+
</Row>
64+
</Keyboard>

0 commit comments

Comments
 (0)