forked from GitHub/gf-core
added Devanagari keyboard for Android
This commit is contained in:
67
src/ui/android/res/xml/devanagari_page1.xml
Normal file
67
src/ui/android/res/xml/devanagari_page1.xml
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:keyWidth="10%p"
|
||||||
|
android:horizontalGap="0px"
|
||||||
|
android:verticalGap="0px"
|
||||||
|
android:keyHeight="@dimen/key_height"
|
||||||
|
>
|
||||||
|
|
||||||
|
<Row>
|
||||||
|
<Key android:codes="2325" android:keyLabel="क" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="क़०" android:keyEdgeFlags="left"/>
|
||||||
|
<Key android:codes="2326" android:keyLabel="ख" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ख़१"/>
|
||||||
|
<Key android:codes="2327" android:keyLabel="ग" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ग़२"/>
|
||||||
|
<Key android:codes="2328" android:keyLabel="घ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="३"/>
|
||||||
|
<Key android:codes="2329" android:keyLabel="ङ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="४"/>
|
||||||
|
<Key android:codes="2330" android:keyLabel="च" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="५"/>
|
||||||
|
<Key android:codes="2331" android:keyLabel="छ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="६"/>
|
||||||
|
<Key android:codes="2332" android:keyLabel="ज" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ज़७"/>
|
||||||
|
<Key android:codes="2333" android:keyLabel="झ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="८"/>
|
||||||
|
<Key android:codes="2334" android:keyLabel="ञ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="९" android:keyEdgeFlags="right"/>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<Row>
|
||||||
|
<Key android:codes="2335" android:keyLabel="ट" android:keyEdgeFlags="left"/>
|
||||||
|
<Key android:codes="2336" android:keyLabel="ठ"/>
|
||||||
|
<Key android:codes="2337" android:keyLabel="ड" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ड़"/>
|
||||||
|
<Key android:codes="2338" android:keyLabel="ढ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ढ़"/>
|
||||||
|
<Key android:codes="2339" android:keyLabel="ण"/>
|
||||||
|
<Key android:codes="2340" android:keyLabel="त"/>
|
||||||
|
<Key android:codes="2341" android:keyLabel="थ"/>
|
||||||
|
<Key android:codes="2342" android:keyLabel="द"/>
|
||||||
|
<Key android:codes="2343" android:keyLabel="ध"/>
|
||||||
|
<Key android:codes="2344" android:keyLabel="न" android:keyEdgeFlags="right"/>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<Row>
|
||||||
|
<Key android:codes="-10" android:keyLabel="1/2" android:horizontalGap="3%p" android:keyEdgeFlags="left"/>
|
||||||
|
<Key android:codes="2309" android:keyLabel="अ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="आा"/>
|
||||||
|
<Key android:codes="2311" android:keyLabel="इ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ीईि"/>
|
||||||
|
<Key android:codes="2313" android:keyLabel="उ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ूऊु"/>
|
||||||
|
<Key android:codes="2319" android:keyLabel="ए" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ॅऐैेऍ"/>
|
||||||
|
<Key android:codes="2323" android:keyLabel="ओ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ॉौऔोऑ"/>
|
||||||
|
<Key android:codes="2315" android:keyLabel="ऋ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ॄॠृ"/>
|
||||||
|
<Key android:codes="2305" android:keyLabel="ँ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ंः"/>
|
||||||
|
<Key android:codes="-5" android:keyIcon="@drawable/sym_keyboard_delete"
|
||||||
|
android:keyWidth="15%p" android:keyEdgeFlags="right"
|
||||||
|
android:isRepeatable="true"/>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<Row android:rowEdgeFlags="bottom" android:keyboardMode="@string/normalKeyboardMode">
|
||||||
|
<Key android:codes="-100" android:keyLabel="Sr" android:keyWidth="13%p" android:horizontalGap="6%p" android:keyEdgeFlags="left"/>
|
||||||
|
<Key android:codes="-200" android:keyLabel="Tr" android:keyWidth="13%p"/>
|
||||||
|
<Key android:codes="-2" android:keyLabel="123" android:keyWidth="13%p"/>
|
||||||
|
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
|
||||||
|
android:keyWidth="29%p" android:isRepeatable="true"/>
|
||||||
|
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
|
||||||
|
android:keyWidth="19%p" android:keyEdgeFlags="right"/>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<Row android:rowEdgeFlags="bottom" android:keyboardMode="@string/internalKeyboardMode">
|
||||||
|
<Key android:codes="-2" android:keyLabel="123" android:keyWidth="18%p" android:horizontalGap="15%p" android:keyEdgeFlags="left"/>
|
||||||
|
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
|
||||||
|
android:keyWidth="30%p" android:isRepeatable="true"/>
|
||||||
|
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
|
||||||
|
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
|
||||||
|
</Row>
|
||||||
|
</Keyboard>
|
||||||
67
src/ui/android/res/xml/devanagari_page2.xml
Normal file
67
src/ui/android/res/xml/devanagari_page2.xml
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:keyWidth="10%p"
|
||||||
|
android:horizontalGap="0px"
|
||||||
|
android:verticalGap="0px"
|
||||||
|
android:keyHeight="@dimen/key_height"
|
||||||
|
>
|
||||||
|
|
||||||
|
<Row>
|
||||||
|
<Key android:codes="2346" android:keyLabel="प" android:keyEdgeFlags="left"/>
|
||||||
|
<Key android:codes="2347" android:keyLabel="फ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="फ़"/>
|
||||||
|
<Key android:codes="2348" android:keyLabel="ब"/>
|
||||||
|
<Key android:codes="2349" android:keyLabel="भ"/>
|
||||||
|
<Key android:codes="2350" android:keyLabel="म"/>
|
||||||
|
<Key android:codes="2351" android:keyLabel="य" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="य़"/>
|
||||||
|
<Key android:codes="2352" android:keyLabel="र" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ऱ"/>
|
||||||
|
<Key android:codes="2354" android:keyLabel="ल"/>
|
||||||
|
<Key android:codes="2355" android:keyLabel="ळ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ऴ"/>
|
||||||
|
<Key android:codes="2357" android:keyLabel="व" android:keyEdgeFlags="right"/>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<Row>
|
||||||
|
<Key android:codes="2358" android:keyLabel="श" android:keyEdgeFlags="left"/>
|
||||||
|
<Key android:codes="2359" android:keyLabel="ष"/>
|
||||||
|
<Key android:codes="2360" android:keyLabel="स"/>
|
||||||
|
<Key android:codes="2361" android:keyLabel="ह"/>
|
||||||
|
<Key android:codes="2325,2381,2359" android:keyLabel="क्ष"/>
|
||||||
|
<Key android:codes="2340,2381,2352" android:keyLabel="त्र"/>
|
||||||
|
<Key android:codes="2332,2381,2334" android:keyLabel="ज्ञ"/>
|
||||||
|
<Key android:codes="2358,2381,2352" android:keyLabel="श्र"/>
|
||||||
|
<Key android:codes="2364" android:keyLabel="़"/>
|
||||||
|
<Key android:codes="2381" android:keyLabel="्"/>"आ"
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<Row>
|
||||||
|
<Key android:codes="-10" android:keyLabel="2/2" android:horizontalGap="3%p" android:keyEdgeFlags="left"/>
|
||||||
|
<Key android:codes="2310" android:keyLabel="आ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="अा"/>
|
||||||
|
<Key android:codes="2312" android:keyLabel="ई" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ीइि"/>
|
||||||
|
<Key android:codes="2314" android:keyLabel="ऊ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ूउु"/>
|
||||||
|
<Key android:codes="2320" android:keyLabel="ऐ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ॅैएेऍ"/>
|
||||||
|
<Key android:codes="2324" android:keyLabel="औ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ॉौओोऑ"/>
|
||||||
|
<Key android:codes="2400" android:keyLabel="ॠ" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ॄऋृ"/>
|
||||||
|
<Key android:codes="2306" android:keyLabel="ं" android:popupKeyboard="@xml/popup_keyboard" android:popupCharacters="ँः"/>
|
||||||
|
<Key android:codes="-5" android:keyIcon="@drawable/sym_keyboard_delete"
|
||||||
|
android:keyWidth="15%p" android:keyEdgeFlags="right"
|
||||||
|
android:isRepeatable="true"/>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<Row android:rowEdgeFlags="bottom" android:keyboardMode="@string/normalKeyboardMode">
|
||||||
|
<Key android:codes="-100" android:keyLabel="Sr" android:keyWidth="13%p" android:horizontalGap="6%p" android:keyEdgeFlags="left"/>
|
||||||
|
<Key android:codes="-200" android:keyLabel="Tr" android:keyWidth="13%p"/>
|
||||||
|
<Key android:codes="-2" android:keyLabel="123" android:keyWidth="13%p"/>
|
||||||
|
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
|
||||||
|
android:keyWidth="29%p" android:isRepeatable="true"/>
|
||||||
|
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
|
||||||
|
android:keyWidth="19%p" android:keyEdgeFlags="right"/>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<Row android:rowEdgeFlags="bottom" android:keyboardMode="@string/internalKeyboardMode">
|
||||||
|
<Key android:codes="-2" android:keyLabel="123" android:keyWidth="18%p" android:horizontalGap="15%p" android:keyEdgeFlags="left"/>
|
||||||
|
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
|
||||||
|
android:keyWidth="30%p" android:isRepeatable="true"/>
|
||||||
|
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
|
||||||
|
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
|
||||||
|
</Row>
|
||||||
|
</Keyboard>
|
||||||
@@ -8,14 +8,25 @@ public class Language implements Serializable {
|
|||||||
private final String mLangCode;
|
private final String mLangCode;
|
||||||
private final String mLangName;
|
private final String mLangName;
|
||||||
private final String mConcrete;
|
private final String mConcrete;
|
||||||
private final int mKeyboardResource;
|
private final int mKeyboardPage1Resource;
|
||||||
|
private final int mKeyboardPage2Resource;
|
||||||
|
|
||||||
public Language(String langCode, String langName, String concrete,
|
public Language(String langCode, String langName, String concrete,
|
||||||
int keyboardResource) {
|
int keyboardResource) {
|
||||||
mLangCode = langCode;
|
mLangCode = langCode;
|
||||||
mLangName = langName;
|
mLangName = langName;
|
||||||
mConcrete = concrete;
|
mConcrete = concrete;
|
||||||
mKeyboardResource = keyboardResource;
|
mKeyboardPage1Resource = keyboardResource;
|
||||||
|
mKeyboardPage2Resource = keyboardResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Language(String langCode, String langName, String concrete,
|
||||||
|
int keyboardPage1Resource, int keyboardPage2Resource) {
|
||||||
|
mLangCode = langCode;
|
||||||
|
mLangName = langName;
|
||||||
|
mConcrete = concrete;
|
||||||
|
mKeyboardPage1Resource = keyboardPage1Resource;
|
||||||
|
mKeyboardPage2Resource = keyboardPage2Resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLangCode() {
|
public String getLangCode() {
|
||||||
@@ -26,8 +37,12 @@ public class Language implements Serializable {
|
|||||||
return mLangName;
|
return mLangName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getKeyboardResource() {
|
public int getKeyboardPage1Resource() {
|
||||||
return mKeyboardResource;
|
return mKeyboardPage1Resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getKeyboardPage2Resource() {
|
||||||
|
return mKeyboardPage2Resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getConcrete() {
|
String getConcrete() {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class Translator {
|
|||||||
new Language("cmn-Hans-CN", "Chinese", "ParseChi", R.xml.qwerty),
|
new Language("cmn-Hans-CN", "Chinese", "ParseChi", R.xml.qwerty),
|
||||||
new Language("fr-FR", "French", "ParseFre", R.xml.qwerty),
|
new Language("fr-FR", "French", "ParseFre", R.xml.qwerty),
|
||||||
new Language("de-DE", "German", "ParseGer", R.xml.qwerty),
|
new Language("de-DE", "German", "ParseGer", R.xml.qwerty),
|
||||||
new Language("hi-IN", "Hindi", "ParseHin", R.xml.qwerty), ///
|
new Language("hi-IN", "Hindi", "ParseHin", R.xml.devanagari_page1, R.xml.devanagari_page2),
|
||||||
new Language("sv-SE", "Swedish", "ParseSwe", R.xml.qwerty),
|
new Language("sv-SE", "Swedish", "ParseSwe", R.xml.qwerty),
|
||||||
new Language("fi-FI", "Finnish", "ParseFin", R.xml.qwerty),
|
new Language("fi-FI", "Finnish", "ParseFin", R.xml.qwerty),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,9 +29,10 @@ public class TranslatorInputMethodService extends InputMethodService
|
|||||||
private long mLastShiftTime;
|
private long mLastShiftTime;
|
||||||
private long mMetaState;
|
private long mMetaState;
|
||||||
|
|
||||||
private TranslatorKeyboard mSymbolsKeyboard;
|
private TranslatorKeyboard mSymbolsPage1Keyboard;
|
||||||
private TranslatorKeyboard mSymbolsShiftedKeyboard;
|
private TranslatorKeyboard mSymbolsPage2Keyboard;
|
||||||
private TranslatorKeyboard mLanguageKeyboard;
|
private TranslatorKeyboard mLanguagePage1Keyboard;
|
||||||
|
private TranslatorKeyboard mLanguagePage2Keyboard;
|
||||||
|
|
||||||
private TranslatorKeyboard mCurKeyboard;
|
private TranslatorKeyboard mCurKeyboard;
|
||||||
|
|
||||||
@@ -45,9 +46,10 @@ public class TranslatorInputMethodService extends InputMethodService
|
|||||||
|
|
||||||
mTranslator = ((GFTranslator) getApplicationContext()).getTranslator();
|
mTranslator = ((GFTranslator) getApplicationContext()).getTranslator();
|
||||||
|
|
||||||
mSymbolsKeyboard = null;
|
mSymbolsPage1Keyboard = null;
|
||||||
mSymbolsShiftedKeyboard = null;
|
mSymbolsPage2Keyboard = null;
|
||||||
mLanguageKeyboard = null;
|
mLanguagePage1Keyboard = null;
|
||||||
|
mLanguagePage2Keyboard = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -92,17 +94,20 @@ public class TranslatorInputMethodService extends InputMethodService
|
|||||||
mCompletionOn = false;
|
mCompletionOn = false;
|
||||||
mCompletions = null;
|
mCompletions = null;
|
||||||
|
|
||||||
int res =
|
int res1 =
|
||||||
mTranslator.getSourceLanguage().getKeyboardResource();
|
mTranslator.getSourceLanguage().getKeyboardPage1Resource();
|
||||||
|
int res2 =
|
||||||
|
mTranslator.getSourceLanguage().getKeyboardPage2Resource();
|
||||||
mModeId = R.string.normalKeyboardMode;
|
mModeId = R.string.normalKeyboardMode;
|
||||||
if (attribute.extras != null &&
|
if (attribute.extras != null &&
|
||||||
!attribute.extras.getBoolean("show_language_toggle", true)) {
|
!attribute.extras.getBoolean("show_language_toggle", true)) {
|
||||||
mModeId = R.string.internalKeyboardMode;
|
mModeId = R.string.internalKeyboardMode;
|
||||||
}
|
}
|
||||||
mAttribute = attribute;
|
mAttribute = attribute;
|
||||||
mLanguageKeyboard = new TranslatorKeyboard(this, res, mModeId);
|
mLanguagePage1Keyboard = new TranslatorKeyboard(this, res1, mModeId);
|
||||||
mSymbolsKeyboard = new TranslatorKeyboard(this, R.xml.symbols, mModeId);
|
mLanguagePage2Keyboard = new TranslatorKeyboard(this, res2, mModeId);
|
||||||
mSymbolsShiftedKeyboard = new TranslatorKeyboard(this, R.xml.symbols_shift, mModeId);
|
mSymbolsPage1Keyboard = new TranslatorKeyboard(this, R.xml.symbols_page1, mModeId);
|
||||||
|
mSymbolsPage2Keyboard = new TranslatorKeyboard(this, R.xml.symbols_page2, mModeId);
|
||||||
|
|
||||||
// We are now going to initialize our state based on the type of
|
// We are now going to initialize our state based on the type of
|
||||||
// text being edited.
|
// text being edited.
|
||||||
@@ -111,13 +116,13 @@ public class TranslatorInputMethodService extends InputMethodService
|
|||||||
case InputType.TYPE_CLASS_DATETIME:
|
case InputType.TYPE_CLASS_DATETIME:
|
||||||
// Numbers and dates default to the symbols keyboard, with
|
// Numbers and dates default to the symbols keyboard, with
|
||||||
// no extra features.
|
// no extra features.
|
||||||
mCurKeyboard = mSymbolsKeyboard;
|
mCurKeyboard = mSymbolsPage1Keyboard;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case InputType.TYPE_CLASS_PHONE:
|
case InputType.TYPE_CLASS_PHONE:
|
||||||
// Phones will also default to the symbols keyboard, though
|
// Phones will also default to the symbols keyboard, though
|
||||||
// often you will want to have a dedicated phone keyboard.
|
// often you will want to have a dedicated phone keyboard.
|
||||||
mCurKeyboard = mSymbolsKeyboard;
|
mCurKeyboard = mSymbolsPage1Keyboard;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case InputType.TYPE_CLASS_TEXT:
|
case InputType.TYPE_CLASS_TEXT:
|
||||||
@@ -125,7 +130,7 @@ public class TranslatorInputMethodService extends InputMethodService
|
|||||||
// normal alphabetic keyboard, and assume that we should
|
// normal alphabetic keyboard, and assume that we should
|
||||||
// be doing predictive text (showing candidates as the
|
// be doing predictive text (showing candidates as the
|
||||||
// user types).
|
// user types).
|
||||||
mCurKeyboard = mLanguageKeyboard;
|
mCurKeyboard = mLanguagePage1Keyboard;
|
||||||
mPredictionOn = true;
|
mPredictionOn = true;
|
||||||
|
|
||||||
// We now look for a few special variations of text that will
|
// We now look for a few special variations of text that will
|
||||||
@@ -165,12 +170,13 @@ public class TranslatorInputMethodService extends InputMethodService
|
|||||||
default:
|
default:
|
||||||
// For all unknown input types, default to the alphabetic
|
// For all unknown input types, default to the alphabetic
|
||||||
// keyboard with no special features.
|
// keyboard with no special features.
|
||||||
mCurKeyboard = mLanguageKeyboard;
|
mCurKeyboard = mLanguagePage1Keyboard;
|
||||||
updateShiftKeyState(attribute);
|
updateShiftKeyState(attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
mActionId = attribute.imeOptions & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION);
|
mActionId = attribute.imeOptions & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION);
|
||||||
mCurKeyboard.setImeOptions(getResources(), attribute.imeOptions);
|
mLanguagePage1Keyboard.setImeOptions(getResources(), attribute.imeOptions);
|
||||||
|
mLanguagePage2Keyboard.setImeOptions(getResources(), attribute.imeOptions);
|
||||||
|
|
||||||
mInstance = this;
|
mInstance = this;
|
||||||
}
|
}
|
||||||
@@ -189,7 +195,7 @@ public class TranslatorInputMethodService extends InputMethodService
|
|||||||
// its window.
|
// its window.
|
||||||
setCandidatesViewShown(false);
|
setCandidatesViewShown(false);
|
||||||
|
|
||||||
mCurKeyboard = mLanguageKeyboard;
|
mCurKeyboard = mLanguagePage1Keyboard;
|
||||||
if (mInputView != null) {
|
if (mInputView != null) {
|
||||||
mInputView.closing();
|
mInputView.closing();
|
||||||
}
|
}
|
||||||
@@ -332,8 +338,9 @@ public class TranslatorInputMethodService extends InputMethodService
|
|||||||
* editor state.
|
* editor state.
|
||||||
*/
|
*/
|
||||||
private void updateShiftKeyState(EditorInfo attr) {
|
private void updateShiftKeyState(EditorInfo attr) {
|
||||||
if (attr != null
|
if (attr != null && mInputView != null &&
|
||||||
&& mInputView != null && mLanguageKeyboard == mInputView.getKeyboard()) {
|
(mLanguagePage1Keyboard == mInputView.getKeyboard() ||
|
||||||
|
mLanguagePage2Keyboard == mInputView.getKeyboard())) {
|
||||||
int caps = 0;
|
int caps = 0;
|
||||||
EditorInfo ei = getCurrentInputEditorInfo();
|
EditorInfo ei = getCurrentInputEditorInfo();
|
||||||
if (ei != null && ei.inputType != InputType.TYPE_NULL) {
|
if (ei != null && ei.inputType != InputType.TYPE_NULL) {
|
||||||
@@ -379,19 +386,28 @@ public class TranslatorInputMethodService extends InputMethodService
|
|||||||
mTranslator.getAvailableLanguages().get(TranslatorKeyboard.KEYCODE_TARGET_LANGUAGE-primaryCode-1);
|
mTranslator.getAvailableLanguages().get(TranslatorKeyboard.KEYCODE_TARGET_LANGUAGE-primaryCode-1);
|
||||||
mTranslator.setTargetLanguage(newTarget);
|
mTranslator.setTargetLanguage(newTarget);
|
||||||
handleChangeTargetLanguage(newTarget);
|
handleChangeTargetLanguage(newTarget);
|
||||||
} else if (primaryCode == TranslatorKeyboard.KEYCODE_MODE_CHANGE
|
} else if (primaryCode == TranslatorKeyboard.KEYCODE_MODE_CHANGE &&
|
||||||
&& mInputView != null) {
|
mInputView != null) {
|
||||||
TranslatorKeyboard current = (TranslatorKeyboard) mInputView.getKeyboard();
|
TranslatorKeyboard current = (TranslatorKeyboard) mInputView.getKeyboard();
|
||||||
if (current == mSymbolsKeyboard || current == mSymbolsShiftedKeyboard) {
|
if (current == mSymbolsPage1Keyboard || current == mSymbolsPage2Keyboard) {
|
||||||
current = mLanguageKeyboard;
|
current = mLanguagePage1Keyboard;
|
||||||
} else {
|
} else {
|
||||||
current = mSymbolsKeyboard;
|
current = mSymbolsPage1Keyboard;
|
||||||
}
|
}
|
||||||
mInputView.setKeyboard(current);
|
mInputView.setKeyboard(current);
|
||||||
if (current == mSymbolsKeyboard) {
|
if (current == mSymbolsPage1Keyboard) {
|
||||||
current.setShifted(false);
|
current.setShifted(false);
|
||||||
}
|
}
|
||||||
} else if (primaryCode == 10) {
|
} else if (primaryCode == TranslatorKeyboard.KEYCODE_PAGE_CHANGE &&
|
||||||
|
mInputView != null) {
|
||||||
|
TranslatorKeyboard current = (TranslatorKeyboard) mInputView.getKeyboard();
|
||||||
|
if (current == mLanguagePage1Keyboard) {
|
||||||
|
current = mLanguagePage2Keyboard;
|
||||||
|
} else {
|
||||||
|
current = mLanguagePage1Keyboard;
|
||||||
|
}
|
||||||
|
mInputView.setKeyboard(current);
|
||||||
|
} else if (primaryCode == 10) {
|
||||||
if ((mActionId & EditorInfo.IME_FLAG_NO_ENTER_ACTION) == 0)
|
if ((mActionId & EditorInfo.IME_FLAG_NO_ENTER_ACTION) == 0)
|
||||||
getCurrentInputConnection().performEditorAction(mActionId & EditorInfo.IME_MASK_ACTION);
|
getCurrentInputConnection().performEditorAction(mActionId & EditorInfo.IME_MASK_ACTION);
|
||||||
else
|
else
|
||||||
@@ -469,18 +485,19 @@ public class TranslatorInputMethodService extends InputMethodService
|
|||||||
}
|
}
|
||||||
|
|
||||||
TranslatorKeyboard currentKeyboard = (TranslatorKeyboard) mInputView.getKeyboard();
|
TranslatorKeyboard currentKeyboard = (TranslatorKeyboard) mInputView.getKeyboard();
|
||||||
if (mLanguageKeyboard == currentKeyboard) {
|
if (mLanguagePage1Keyboard == currentKeyboard ||
|
||||||
|
mLanguagePage2Keyboard == currentKeyboard) {
|
||||||
// Alphabet keyboard
|
// Alphabet keyboard
|
||||||
checkToggleCapsLock();
|
checkToggleCapsLock();
|
||||||
mInputView.setShifted(mCapsLock || !mInputView.isShifted());
|
mInputView.setShifted(mCapsLock || !mInputView.isShifted());
|
||||||
} else if (currentKeyboard == mSymbolsKeyboard) {
|
} else if (currentKeyboard == mSymbolsPage1Keyboard) {
|
||||||
mSymbolsKeyboard.setShifted(true);
|
mSymbolsPage1Keyboard.setShifted(true);
|
||||||
mInputView.setKeyboard(mSymbolsShiftedKeyboard);
|
mInputView.setKeyboard(mSymbolsPage2Keyboard);
|
||||||
mSymbolsShiftedKeyboard.setShifted(true);
|
mSymbolsPage2Keyboard.setShifted(true);
|
||||||
} else if (currentKeyboard == mSymbolsShiftedKeyboard) {
|
} else if (currentKeyboard == mSymbolsPage2Keyboard) {
|
||||||
mSymbolsShiftedKeyboard.setShifted(false);
|
mSymbolsPage2Keyboard.setShifted(false);
|
||||||
mInputView.setKeyboard(mSymbolsKeyboard);
|
mInputView.setKeyboard(mSymbolsPage1Keyboard);
|
||||||
mSymbolsKeyboard.setShifted(false);
|
mSymbolsPage1Keyboard.setShifted(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,7 +508,9 @@ public class TranslatorInputMethodService extends InputMethodService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mComposing.append((char) primaryCode);
|
for (int i = 0; i < keyCodes.length && keyCodes[i] > 0; i++)
|
||||||
|
mComposing.append((char) keyCodes[i]);
|
||||||
|
|
||||||
if (primaryCode == 10)
|
if (primaryCode == 10)
|
||||||
commitTyped(getCurrentInputConnection());
|
commitTyped(getCurrentInputConnection());
|
||||||
else
|
else
|
||||||
@@ -511,17 +530,18 @@ public class TranslatorInputMethodService extends InputMethodService
|
|||||||
|
|
||||||
void handleChangeSourceLanguage(Language newSource) {
|
void handleChangeSourceLanguage(Language newSource) {
|
||||||
updateLanguageKeyboard(newSource);
|
updateLanguageKeyboard(newSource);
|
||||||
mSymbolsKeyboard.updateLanguageKeyLabels();
|
mSymbolsPage1Keyboard.updateLanguageKeyLabels();
|
||||||
mSymbolsShiftedKeyboard.updateLanguageKeyLabels();
|
mSymbolsPage2Keyboard.updateLanguageKeyLabels();
|
||||||
if (mInputView != null) {
|
if (mInputView != null) {
|
||||||
mInputView.setKeyboard(mCurKeyboard);
|
mInputView.setKeyboard(mCurKeyboard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleChangeTargetLanguage(Language newTarget) {
|
void handleChangeTargetLanguage(Language newTarget) {
|
||||||
mLanguageKeyboard.updateLanguageKeyLabels();
|
mLanguagePage1Keyboard.updateLanguageKeyLabels();
|
||||||
mSymbolsKeyboard.updateLanguageKeyLabels();
|
mLanguagePage2Keyboard.updateLanguageKeyLabels();
|
||||||
mSymbolsShiftedKeyboard.updateLanguageKeyLabels();
|
mSymbolsPage1Keyboard.updateLanguageKeyLabels();
|
||||||
|
mSymbolsPage2Keyboard.updateLanguageKeyLabels();
|
||||||
if (mInputView != null) {
|
if (mInputView != null) {
|
||||||
mInputView.invalidateAllKeys();
|
mInputView.invalidateAllKeys();
|
||||||
}
|
}
|
||||||
@@ -530,20 +550,26 @@ public class TranslatorInputMethodService extends InputMethodService
|
|||||||
void handleSwitchLanguages() {
|
void handleSwitchLanguages() {
|
||||||
Language newSource = mTranslator.getSourceLanguage();
|
Language newSource = mTranslator.getSourceLanguage();
|
||||||
updateLanguageKeyboard(newSource);
|
updateLanguageKeyboard(newSource);
|
||||||
mSymbolsKeyboard.updateLanguageKeyLabels();
|
mSymbolsPage1Keyboard.updateLanguageKeyLabels();
|
||||||
mSymbolsShiftedKeyboard.updateLanguageKeyLabels();
|
mSymbolsPage2Keyboard.updateLanguageKeyLabels();
|
||||||
if (mInputView != null)
|
if (mInputView != null)
|
||||||
mInputView.setKeyboard(mCurKeyboard);
|
mInputView.setKeyboard(mCurKeyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLanguageKeyboard(Language language) {
|
private void updateLanguageKeyboard(Language language) {
|
||||||
TranslatorKeyboard keyboard =
|
TranslatorKeyboard keyboard1 =
|
||||||
new TranslatorKeyboard(this, language.getKeyboardResource(), mModeId);
|
new TranslatorKeyboard(this, language.getKeyboardPage1Resource(), mModeId);
|
||||||
keyboard.setImeOptions(getResources(), mAttribute.imeOptions);
|
TranslatorKeyboard keyboard2 =
|
||||||
if (mCurKeyboard == mLanguageKeyboard) {
|
new TranslatorKeyboard(this, language.getKeyboardPage2Resource(), mModeId);
|
||||||
mCurKeyboard = keyboard;
|
keyboard1.setImeOptions(getResources(), mAttribute.imeOptions);
|
||||||
|
keyboard2.setImeOptions(getResources(), mAttribute.imeOptions);
|
||||||
|
if (mCurKeyboard == mLanguagePage1Keyboard) {
|
||||||
|
mCurKeyboard = keyboard1;
|
||||||
|
} else if (mCurKeyboard == mLanguagePage2Keyboard) {
|
||||||
|
mCurKeyboard = keyboard2;
|
||||||
}
|
}
|
||||||
mLanguageKeyboard = keyboard;
|
mLanguagePage1Keyboard = keyboard1;
|
||||||
|
mLanguagePage2Keyboard = keyboard2;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkToggleCapsLock() {
|
private void checkToggleCapsLock() {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public class TranslatorKeyboard extends Keyboard {
|
|||||||
private Key mSourceLanguageKey;
|
private Key mSourceLanguageKey;
|
||||||
private Key mTargetLanguageKey;
|
private Key mTargetLanguageKey;
|
||||||
|
|
||||||
|
static final int KEYCODE_PAGE_CHANGE = -10;
|
||||||
static final int KEYCODE_SOURCE_LANGUAGE = -100;
|
static final int KEYCODE_SOURCE_LANGUAGE = -100;
|
||||||
static final int KEYCODE_TARGET_LANGUAGE = -200;
|
static final int KEYCODE_TARGET_LANGUAGE = -200;
|
||||||
static final int MAX_LANGUAGE_KEYCODES = 99;
|
static final int MAX_LANGUAGE_KEYCODES = 99;
|
||||||
|
|||||||
Reference in New Issue
Block a user