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

Commit

Permalink
Implement Russian keyboard (#1292)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored and keianhzo committed Jun 7, 2019
1 parent acbd7af commit a2ce8ca
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public CustomKeyboard getSymbolsKeyboard() {

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

@Nullable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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 RussianKeyboard extends BaseKeyboard {
private CustomKeyboard mKeyboard;
private CustomKeyboard mSymbolsKeyboard;
private Locale mLocale;

public RussianKeyboard(Context aContext) {
super(aContext);
mLocale = new Locale("ru", "RU");
}

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

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

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

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

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

@Override
public Locale getLocale() {
return mLocale;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.mozilla.vrbrowser.ui.keyboards.GermanKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.ChineseZhuyinKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.KeyboardInterface;
import org.mozilla.vrbrowser.ui.keyboards.RussianKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.SpanishKeyboard;
import org.mozilla.vrbrowser.ui.views.AutoCompletionView;
import org.mozilla.vrbrowser.ui.views.CustomKeyboardView;
Expand Down Expand Up @@ -133,6 +134,7 @@ private void initialize(Context aContext) {
mKeyboards.add(new FrenchKeyboard(aContext));
mKeyboards.add(new GermanKeyboard(aContext));
mKeyboards.add(new SpanishKeyboard(aContext));
mKeyboards.add(new RussianKeyboard(aContext));
mKeyboards.add(new ChinesePinyinKeyboard(aContext));
mKeyboards.add(new ChineseZhuyinKeyboard(aContext));

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/dimen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<item name="keyboard_world_rotation" format="float" type="dimen">-35.0</item>
<dimen name="keyboard_height">188dp</dimen>
<dimen name="keyboard_alphabetic_width">526dp</dimen>
<dimen name="keyboard_alphabetic_width_german">564dp</dimen>
<dimen name="keyboard_alphabetic_width_extra_column">564dp</dimen>
<dimen name="keyboard_numeric_width">144dp</dimen>
<dimen name="keyboard_zhuyin_height">250dp</dimen>
<dimen name="keyboard_horizontal_gap">4dp</dimen>
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 @@ -168,6 +168,10 @@
changes the app and the language of the speech-recognition-based search to 'Italian'. -->
<string name="settings_language_italian">Italian</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 'Italian'. -->
<string name="settings_language_russian">Russian</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
65 changes: 65 additions & 0 deletions app/src/main/res/xml/keyboard_qwerty_russian.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?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:keyLabel="й" android:keyEdgeFlags="left" />
<Key android:keyLabel="ц" />
<Key android:keyLabel="у" />
<Key android:keyLabel="к" />
<Key android:keyLabel="е" android:popupCharacters="её" android:popupKeyboard="@xml/keyboard_popup" />
<Key android:keyLabel="н" />
<Key android:keyLabel="г" />
<Key android:keyLabel="ш" />
<Key android:keyLabel="щ" />
<Key android:keyLabel="з" />
<Key android:keyLabel="х" />
<Key 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:keyLabel="ф" android:keyEdgeFlags="left" android:horizontalGap="@dimen/keyboard_left_margin" />
<Key android:keyLabel="ы" />
<Key android:keyLabel="в" />
<Key android:keyLabel="а" />
<Key android:keyLabel="п" />
<Key android:keyLabel="р" />
<Key android:keyLabel="о" />
<Key android:keyLabel="л" />
<Key android:keyLabel="д" />
<Key android:keyLabel="ж" />
<Key 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:keyLabel="я" />
<Key android:keyLabel="ч" />
<Key android:keyLabel="с" />
<Key android:keyLabel="м" />
<Key android:keyLabel="и" />
<Key android:keyLabel="т" />
<Key android:keyLabel="ь" />
<Key android:keyLabel="б" />
<Key android:keyLabel="ю" />
<Key android:keyLabel="ë" />
<Key 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="58" android:keyLabel=":"/>
<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>
64 changes: 64 additions & 0 deletions app/src/main/res/xml/keyboard_symbols_russian.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?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"/>
<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="95" android:keyLabel="_"/>
<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="186" android:keyLabel="º" android:keyEdgeFlags="left" android:horizontalGap="@dimen/keyboard_left_margin"/>
<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="39" android:keyLabel="'"/>
<Key android:codes="59" android:keyLabel=";"/>
<Key android:keyOutputText="º" android:keyLabel="º"/>
<Key android:codes="-4" android:keyLabel="@string/keyboard_enter_label" android:keyWidth="@dimen/keyboard_key_enter_width" />
</Row>

<Row>
<Key android:codes="60" android:keyLabel="&lt;" android:keyEdgeFlags="left"/>
<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="92" android:keyLabel="\\" />
<Key android:codes="39" android:keyLabel="'"/>
<Key android:keyOutputText="" android:keyLabel="" />
<Key android:codes="45" android:keyLabel="-" />
<Key android:codes="43" android:keyLabel="+" />
<Key android:codes="47" android:keyLabel="/" />
</Row>

<Row>
<Key android:codes="-2" android:keyLabel="@string/keyboard_mode_change" 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_german_space_width" android:isRepeatable="true"/>
<Key android:codes="58" android:keyLabel=":"/>
<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 a2ce8ca

Please sign in to comment.