Utilize KeyboardSet XML definitions

This change introduces KeyboardSet and SubKeyboard XML definitions to
represent a set of keyboard layouts.

Bug: 5002108
Bug: 5679585
Change-Id: Ib6c8d5936187381bb6725c9fe574e93871c01a86
main
Tadashi G. Takaoka 2011-12-13 17:30:51 +09:00
parent cfe264bfee
commit f86109ca56
49 changed files with 1087 additions and 382 deletions

View File

@ -164,8 +164,6 @@
<attr name="verticalGap" format="dimension|fraction" /> <attr name="verticalGap" format="dimension|fraction" />
<!-- More keys keyboard layout template --> <!-- More keys keyboard layout template -->
<attr name="moreKeysTemplate" format="reference" /> <attr name="moreKeysTemplate" format="reference" />
<!-- Locale of the keyboard layout -->
<attr name="keyboardLocale" format="string" />
<!-- True if the keyboard is Right-To-Left --> <!-- True if the keyboard is Right-To-Left -->
<attr name="isRtlKeyboard" format="boolean" /> <attr name="isRtlKeyboard" format="boolean" />
<!-- Icon set for key top and key preview. --> <!-- Icon set for key top and key preview. -->
@ -328,4 +326,29 @@
<attr name="spacebarTextColor" format="color" /> <attr name="spacebarTextColor" format="color" />
<attr name="spacebarTextShadowColor" format="color" /> <attr name="spacebarTextShadowColor" format="color" />
</declare-styleable> </declare-styleable>
<declare-styleable name="KeyboardSet">
<!-- Locale of the keyboard layouts -->
<attr name="keyboardLocale" format="string" />
</declare-styleable>
<declare-styleable name="KeyboardSet_Element">
<!-- This should be aligned with KeyboardId.ELEMENT_* -->
<attr name="elementName" format="enum">
<enum name="alphabet" value="0" />
<!-- TODO: Implement alphabet variant shift keyboards
<enum name="alphabetManualTemporaryShift" value="1" />
<enum name="alphabetAutomaticTemporaryShift" value="2" />
<enum name="alphabetShiftLock" value="3" />
<enum name="alphabetShiftLockShift" value="4" />
-->
<enum name="symbols" value="5" />
<enum name="symbolsShift" value="6" />
<enum name="phone" value="7" />
<enum name="phoneShift" value="8" />
<enum name="number" value="9" />
</attr>
<attr name="elementKeyboard" format="reference" />
<!-- TODO: Add setShifted and setShiftLocked attribute. -->
</declare-styleable>
</resources> </resources>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="ar" >
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_arabic" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -18,10 +18,25 @@
*/ */
--> -->
<Keyboard <KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="de" latin:keyboardLocale="cs">
> <Element
<include latin:elementName="alphabet"
latin:keyboardLayout="@xml/kbd_rows_qwerty" /> latin:elementKeyboard="@xml/kbd_qwertz" />
</Keyboard> <Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2010, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="da"
>
<include
latin:keyboardLayout="@xml/kbd_rows_scandinavian" />
</Keyboard>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="da">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_scandinavian" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="de">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwerty" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="de"
>
<include
latin:keyboardLayout="@xml/kbd_rows_qwertz" />
</Keyboard>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="de">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwertz" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="es,es_US">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_spanish" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="fi">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_scandinavian" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="fr_CA"
>
<include
latin:keyboardLayout="@xml/kbd_rows_qwerty" />
</Keyboard>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="fr_CA">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwerty" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="fr_CH"
>
<include
latin:keyboardLayout="@xml/kbd_rows_qwertz" />
</Keyboard>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="fr_CH">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwertz" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="fr">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_azerty" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="hr"
>
<!-- TODO: Dedicated Croatian layout especially for tablet. -->
<include
latin:keyboardLayout="@xml/kbd_rows_qwertz" />
</Keyboard>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="hr">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwertz" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="hu"
>
<include
latin:keyboardLayout="@xml/kbd_rows_qwertz" />
</Keyboard>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="hu">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwertz" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="iw">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_hebrew" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2010, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="nb"
>
<include
latin:keyboardLayout="@xml/kbd_rows_scandinavian" />
</Keyboard>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="nb">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_scandinavian" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="pl">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwerty" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="pt"
>
<include
latin:keyboardLayout="@xml/kbd_rows_qwerty" />
</Keyboard>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="pt">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwerty" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="ru"
>
<include
latin:keyboardLayout="@xml/kbd_rows_russian" />
</Keyboard>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="ru">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_russian" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="sr">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_serbian" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="sv"
>
<include
latin:keyboardLayout="@xml/kbd_rows_scandinavian" />
</Keyboard>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="sv">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_scandinavian" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="tr"
>
<include
latin:keyboardLayout="@xml/kbd_rows_qwerty" />
</Keyboard>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="tr">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwerty" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -20,7 +20,6 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="ar"
latin:isRtlKeyboard="true" latin:isRtlKeyboard="true"
> >
<include <include

View File

@ -2,7 +2,7 @@
<!-- <!--
/* /*
** **
** Copyright 2008, The Android Open Source Project ** Copyright 2011, The Android Open Source Project
** **
** Licensed under the Apache License, Version 2.0 (the "License"); ** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. ** you may not use this file except in compliance with the License.
@ -20,7 +20,6 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="fr"
> >
<include <include
latin:keyboardLayout="@xml/kbd_rows_azerty" /> latin:keyboardLayout="@xml/kbd_rows_azerty" />

View File

@ -2,7 +2,7 @@
<!-- <!--
/* /*
** **
** Copyright 2010, The Android Open Source Project ** Copyright 2011, The Android Open Source Project
** **
** Licensed under the Apache License, Version 2.0 (the "License"); ** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. ** you may not use this file except in compliance with the License.
@ -20,7 +20,6 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="iw"
latin:isRtlKeyboard="true" latin:isRtlKeyboard="true"
> >
<include <include

View File

@ -20,7 +20,6 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="en_GB,en_US"
> >
<include <include
latin:keyboardLayout="@xml/kbd_rows_qwerty" /> latin:keyboardLayout="@xml/kbd_rows_qwerty" />

View File

@ -20,7 +20,6 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="cs"
> >
<include <include
latin:keyboardLayout="@xml/kbd_rows_qwertz" /> latin:keyboardLayout="@xml/kbd_rows_qwertz" />

View File

@ -4,7 +4,7 @@
** **
** Copyright 2011, The Android Open Source Project ** Copyright 2011, The Android Open Source Project
** **
** Licensed under the Apache License, Version 2.0 (the "License"); ** Licensed under the Apache License, Version 2.0 (the "License"):
** you may not use this file except in compliance with the License. ** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at ** You may obtain a copy of the License at
** **
@ -20,8 +20,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="pl"
> >
<include <include
latin:keyboardLayout="@xml/kbd_rows_qwerty" /> latin:keyboardLayout="@xml/kbd_rows_russian" />
</Keyboard> </Keyboard>

View File

@ -20,7 +20,6 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="fi"
> >
<include <include
latin:keyboardLayout="@xml/kbd_rows_scandinavian" /> latin:keyboardLayout="@xml/kbd_rows_scandinavian" />

View File

@ -2,7 +2,7 @@
<!-- <!--
/* /*
** **
** Copyright 2008, The Android Open Source Project ** Copyright 2011, The Android Open Source Project
** **
** Licensed under the Apache License, Version 2.0 (the "License"); ** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. ** you may not use this file except in compliance with the License.
@ -20,7 +20,6 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="sr"
> >
<include <include
latin:keyboardLayout="@xml/kbd_rows_serbian" /> latin:keyboardLayout="@xml/kbd_rows_serbian" />

View File

@ -20,7 +20,6 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="es,es_US"
> >
<include <include
latin:keyboardLayout="@xml/kbd_rows_spanish" /> latin:keyboardLayout="@xml/kbd_rows_spanish" />

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardLocale="en_GB,en_US">
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwerty" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -17,7 +17,7 @@
package com.android.inputmethod.deprecated.languageswitcher; package com.android.inputmethod.deprecated.languageswitcher;
import com.android.inputmethod.compat.SharedPreferencesCompat; import com.android.inputmethod.compat.SharedPreferencesCompat;
import com.android.inputmethod.keyboard.internal.KeyboardBuilder; import com.android.inputmethod.keyboard.KeyboardSet;
import com.android.inputmethod.latin.DictionaryFactory; import com.android.inputmethod.latin.DictionaryFactory;
import com.android.inputmethod.latin.LocaleUtils; import com.android.inputmethod.latin.LocaleUtils;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
@ -162,8 +162,8 @@ public class InputLanguageSelection extends PreferenceActivity {
try { try {
final String localeStr = locale.toString(); final String localeStr = locale.toString();
final String[] layoutCountryCodes = KeyboardBuilder.parseKeyboardLocale( final String[] layoutCountryCodes = KeyboardSet.parseKeyboardLocale(
this, R.xml.kbd_qwerty).split(",", -1); getResources(), R.xml.keyboard_set).split(",", -1);
if (!TextUtils.isEmpty(localeStr) && layoutCountryCodes.length > 0) { if (!TextUtils.isEmpty(localeStr) && layoutCountryCodes.length > 0) {
for (String s : layoutCountryCodes) { for (String s : layoutCountryCodes) {
if (s.equals(localeStr)) { if (s.equals(localeStr)) {

View File

@ -21,11 +21,11 @@ import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.compat.EditorInfoCompatUtils; import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.compat.InputTypeCompatUtils; import com.android.inputmethod.compat.InputTypeCompatUtils;
import com.android.inputmethod.latin.R;
import java.util.Arrays; import java.util.Arrays;
import java.util.Locale; import java.util.Locale;
// TODO: Move to com.android.inputmethod.keyboard.internal package.
/** /**
* Represents the parameters necessary to construct a new LatinKeyboard, * Represents the parameters necessary to construct a new LatinKeyboard,
* which also serve as a unique identifier for each keyboard type. * which also serve as a unique identifier for each keyboard type.
@ -38,6 +38,20 @@ public class KeyboardId {
public static final int MODE_PHONE = 4; public static final int MODE_PHONE = 4;
public static final int MODE_NUMBER = 5; public static final int MODE_NUMBER = 5;
public static final int ELEMENT_ALPHABET = 0;
/* TODO: Implement alphabet variant shift keyboard.
public static final int ELEMENT_ALPHABET_MANUAL_TEMPORARY_SHIFT = 1;
public static final int ELEMENT_ALPHABET_AUTOMATIC_TEMPORARY_SHIFT = 2;
public static final int ELEMENT_ALPHABET_SHIFT_LOCK = 3;
public static final int ELEMENT_ALPHABET_SHIFT_LOCK_SHIFT = 4;
*/
public static final int ELEMENT_SYMBOLS = 5;
public static final int ELEMENT_SYMBOLS_SHIFT = 6;
public static final int ELEMENT_PHONE = 7;
public static final int ELEMENT_PHONE_SHIFT = 8;
public static final int ELEMENT_NUMBER = 9;
// TODO: These constants could be private.
public static final int F2KEY_MODE_NONE = 0; public static final int F2KEY_MODE_NONE = 0;
public static final int F2KEY_MODE_SETTINGS = 1; public static final int F2KEY_MODE_SETTINGS = 1;
public static final int F2KEY_MODE_SHORTCUT_IME = 2; public static final int F2KEY_MODE_SHORTCUT_IME = 2;
@ -47,7 +61,9 @@ public class KeyboardId {
public final int mOrientation; public final int mOrientation;
public final int mWidth; public final int mWidth;
public final int mMode; public final int mMode;
public final int mXmlId; // TODO: Remove this field.
private final int mXmlId;
public final int mElementState;
public final boolean mNavigateAction; public final boolean mNavigateAction;
public final boolean mPasswordInput; public final boolean mPasswordInput;
// TODO: Clean up these booleans and modes. // TODO: Clean up these booleans and modes.
@ -58,16 +74,18 @@ public class KeyboardId {
public final boolean mHasShortcutKey; public final boolean mHasShortcutKey;
public final int mImeAction; public final int mImeAction;
public final String mXmlName; // TODO: Remove this field.
public final EditorInfo mEditorInfo; private final EditorInfo mEditorInfo;
private final int mHashCode; private final int mHashCode;
public KeyboardId(String xmlName, int xmlId, Locale locale, int orientation, int width, // TODO: The hasSettings, f2KeyMode, and clobberSettingsKey arguments could be reduced.
public KeyboardId(int xmlId, int elementState, Locale locale, int orientation, int width,
int mode, EditorInfo editorInfo, boolean hasSettingsKey, int f2KeyMode, int mode, EditorInfo editorInfo, boolean hasSettingsKey, int f2KeyMode,
boolean clobberSettingsKey, boolean shortcutKeyEnabled, boolean hasShortcutKey) { boolean clobberSettingsKey, boolean shortcutKeyEnabled, boolean hasShortcutKey) {
final int inputType = (editorInfo != null) ? editorInfo.inputType : 0; final int inputType = (editorInfo != null) ? editorInfo.inputType : 0;
final int imeOptions = (editorInfo != null) ? editorInfo.imeOptions : 0; final int imeOptions = (editorInfo != null) ? editorInfo.imeOptions : 0;
this.mElementState = elementState;
this.mLocale = locale; this.mLocale = locale;
this.mOrientation = orientation; this.mOrientation = orientation;
this.mWidth = width; this.mWidth = width;
@ -89,7 +107,6 @@ public class KeyboardId {
this.mImeAction = imeOptions & ( this.mImeAction = imeOptions & (
EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION); EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION);
this.mXmlName = xmlName;
this.mEditorInfo = editorInfo; this.mEditorInfo = editorInfo;
this.mHashCode = Arrays.hashCode(new Object[] { this.mHashCode = Arrays.hashCode(new Object[] {
@ -98,6 +115,7 @@ public class KeyboardId {
width, width,
mode, mode,
xmlId, xmlId,
elementState,
mNavigateAction, mNavigateAction,
mPasswordInput, mPasswordInput,
hasSettingsKey, hasSettingsKey,
@ -109,29 +127,31 @@ public class KeyboardId {
}); });
} }
public KeyboardId cloneWithNewXml(String xmlName, int xmlId) { public KeyboardId cloneWithNewXml(int xmlId) {
return new KeyboardId(xmlName, xmlId, mLocale, mOrientation, mWidth, mMode, mEditorInfo, return new KeyboardId(xmlId, mElementState, mLocale,
false, F2KEY_MODE_NONE, false, false, false); mOrientation, mWidth, mMode, mEditorInfo, false, F2KEY_MODE_NONE, false, false,
false);
} }
// Remove this method.
public int getXmlId() { public int getXmlId() {
return mXmlId; return mXmlId;
} }
public boolean isAlphabetKeyboard() { public boolean isAlphabetKeyboard() {
return mXmlId == R.xml.kbd_qwerty; return mElementState < ELEMENT_SYMBOLS;
} }
public boolean isSymbolsKeyboard() { public boolean isSymbolsKeyboard() {
return mXmlId == R.xml.kbd_symbols || mXmlId == R.xml.kbd_symbols_shift; return mElementState == ELEMENT_SYMBOLS || mElementState == ELEMENT_SYMBOLS_SHIFT;
} }
public boolean isPhoneKeyboard() { public boolean isPhoneKeyboard() {
return mMode == MODE_PHONE; return mElementState == ELEMENT_PHONE || mElementState == ELEMENT_PHONE_SHIFT;
} }
public boolean isPhoneShiftKeyboard() { public boolean isPhoneShiftKeyboard() {
return mXmlId == R.xml.kbd_phone_shift; return mElementState == ELEMENT_PHONE_SHIFT;
} }
@Override @Override
@ -145,6 +165,7 @@ public class KeyboardId {
&& other.mWidth == this.mWidth && other.mWidth == this.mWidth
&& other.mMode == this.mMode && other.mMode == this.mMode
&& other.mXmlId == this.mXmlId && other.mXmlId == this.mXmlId
&& other.mElementState == this.mElementState
&& other.mNavigateAction == this.mNavigateAction && other.mNavigateAction == this.mNavigateAction
&& other.mPasswordInput == this.mPasswordInput && other.mPasswordInput == this.mPasswordInput
&& other.mHasSettingsKey == this.mHasSettingsKey && other.mHasSettingsKey == this.mHasSettingsKey
@ -162,8 +183,8 @@ public class KeyboardId {
@Override @Override
public String toString() { public String toString() {
return String.format("[%s.xml %s %s%d %s %s %s%s%s%s%s%s%s]", return String.format("[%s %s %s%d %s %s %s%s%s%s%s%s%s]",
mXmlName, elementStateToString(mElementState),
mLocale, mLocale,
(mOrientation == 1 ? "port" : "land"), mWidth, (mOrientation == 1 ? "port" : "land"), mWidth,
modeName(mMode), modeName(mMode),
@ -186,6 +207,24 @@ public class KeyboardId {
&& TextUtils.equals(a.privateImeOptions, b.privateImeOptions); && TextUtils.equals(a.privateImeOptions, b.privateImeOptions);
} }
public static String elementStateToString(int elementState) {
switch (elementState) {
case ELEMENT_ALPHABET: return "alphabet";
/* TODO: Implement alphabet variant shift keyboard.
case ELEMENT_ALPHABET_MANUAL_TEMPORARY_SHIFT: return "alphabetManualTemporaryShift";
case ELEMENT_ALPHABET_AUTOMATIC_TEMPORARY_SHIFT: return "alphabetAutomaticTemporaryShift";
case ELEMENT_ALPHABET_SHIFT_LOCK: return "alphabetShiftLock";
case ELEMENT_ALPHABET_SHIFT_LOCK_SHIFT: return "alphabetShiftLockShift";
*/
case ELEMENT_SYMBOLS: return "symbols";
case ELEMENT_SYMBOLS_SHIFT: return "symbolsShift";
case ELEMENT_PHONE: return "phone";
case ELEMENT_PHONE_SHIFT: return "phoneShift";
case ELEMENT_NUMBER: return "number";
default: return null;
}
}
public static String modeName(int mode) { public static String modeName(int mode) {
switch (mode) { switch (mode) {
case MODE_TEXT: return "text"; case MODE_TEXT: return "text";

View File

@ -19,15 +19,28 @@ package com.android.inputmethod.keyboard;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Xml;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
import com.android.inputmethod.keyboard.internal.KeyboardBuilder.IllegalEndTag;
import com.android.inputmethod.keyboard.internal.KeyboardBuilder.IllegalStartTag;
import com.android.inputmethod.keyboard.internal.KeyboardBuilder.ParseException;
import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LocaleUtils;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SettingsValues; import com.android.inputmethod.latin.SettingsValues;
import com.android.inputmethod.latin.SubtypeSwitcher; import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.Utils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
/** /**
@ -37,6 +50,9 @@ import java.util.Locale;
* A {@link KeyboardSet} needs to be created for each {@link android.view.inputmethod.EditorInfo}. * A {@link KeyboardSet} needs to be created for each {@link android.view.inputmethod.EditorInfo}.
*/ */
public class KeyboardSet { public class KeyboardSet {
private static final String TAG_KEYBOARD_SET = "KeyboardSet";
private static final String TAG_ELEMENT = "Element";
// TODO: Make these KeyboardId private. // TODO: Make these KeyboardId private.
public final KeyboardId mAlphabetId; public final KeyboardId mAlphabetId;
public final KeyboardId mSymbolsId; public final KeyboardId mSymbolsId;
@ -52,6 +68,9 @@ public class KeyboardSet {
private final Resources mResources; private final Resources mResources;
private final EditorInfo mEditorInfo; private final EditorInfo mEditorInfo;
private final HashMap<Integer, Integer> mElementKeyboards =
new HashMap<Integer, Integer>();
private final int mMode; private final int mMode;
private final boolean mVoiceKeyEnabled; private final boolean mVoiceKeyEnabled;
private final boolean mNoSettingsKey; private final boolean mNoSettingsKey;
@ -91,31 +110,42 @@ public class KeyboardSet {
} }
public KeyboardSet build() { public KeyboardSet build() {
final Locale savedLocale = LocaleUtils.setSystemLocale(mResources, mLocale);
try {
parseKeyboardSet(mResources, R.xml.keyboard_set);
} catch (Exception e) {
//
} finally {
LocaleUtils.setSystemLocale(mResources, savedLocale);
}
return new KeyboardSet(this); return new KeyboardSet(this);
} }
KeyboardId getKeyboardId(boolean isSymbols, boolean isShift) { KeyboardId getKeyboardId(boolean isSymbols, boolean isShift) {
final int xmlId = getXmlId(mMode, isSymbols, isShift); final int elementState = getElementState(mMode, isSymbols, isShift);
final boolean hasShortCutKey = mVoiceKeyEnabled && (isSymbols != mVoiceKeyOnMain); final int xmlId = mElementKeyboards.get(elementState);
return new KeyboardId(mResources.getResourceEntryName(xmlId), xmlId, mLocale, final boolean hasShortcutKey = mVoiceKeyEnabled && (isSymbols != mVoiceKeyOnMain);
mConf.orientation, mMetrics.widthPixels, mMode, mEditorInfo, mHasSettingsKey, return new KeyboardId(xmlId, elementState, mLocale, mConf.orientation,
mF2KeyMode, mNoSettingsKey, mVoiceKeyEnabled, hasShortCutKey); mMetrics.widthPixels, mMode, mEditorInfo, mHasSettingsKey, mF2KeyMode,
mNoSettingsKey, mVoiceKeyEnabled, hasShortcutKey);
} }
private static int getXmlId(int mode, boolean isSymbols, boolean isShift) { private static int getElementState(int mode, boolean isSymbols, boolean isShift) {
switch (mode) { switch (mode) {
case KeyboardId.MODE_PHONE: case KeyboardId.MODE_PHONE:
return (isSymbols && isShift) ? R.xml.kbd_phone_shift : R.xml.kbd_phone; return (isSymbols && isShift)
? KeyboardId.ELEMENT_PHONE_SHIFT : KeyboardId.ELEMENT_PHONE;
case KeyboardId.MODE_NUMBER: case KeyboardId.MODE_NUMBER:
return R.xml.kbd_number; return KeyboardId.ELEMENT_NUMBER;
default: default:
if (isSymbols) { if (isSymbols) {
return isShift ? R.xml.kbd_symbols_shift : R.xml.kbd_symbols; return isShift ? KeyboardId.ELEMENT_SYMBOLS_SHIFT : KeyboardId.ELEMENT_SYMBOLS;
} }
return R.xml.kbd_qwerty; return KeyboardId.ELEMENT_ALPHABET;
} }
} }
// TODO: Move to KeyboardId.
private static int getF2KeyMode(boolean settingsKeyEnabled, boolean noSettingsKey) { private static int getF2KeyMode(boolean settingsKeyEnabled, boolean noSettingsKey) {
if (noSettingsKey) { if (noSettingsKey) {
// Never shows the Settings key // Never shows the Settings key
@ -130,5 +160,95 @@ public class KeyboardSet {
return KeyboardId.F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS; return KeyboardId.F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS;
} }
} }
private void parseKeyboardSet(Resources res, int resId) throws XmlPullParserException,
IOException {
final XmlResourceParser parser = res.getXml(resId);
try {
int event;
while ((event = parser.next()) != XmlPullParser.END_DOCUMENT) {
if (event == XmlPullParser.START_TAG) {
final String tag = parser.getName();
if (TAG_KEYBOARD_SET.equals(tag)) {
parseKeyboardSetContent(parser);
} else {
throw new IllegalStartTag(parser, TAG_KEYBOARD_SET);
}
}
}
} finally {
parser.close();
}
}
private void parseKeyboardSetContent(XmlPullParser parser) throws XmlPullParserException,
IOException {
int event;
while ((event = parser.next()) != XmlPullParser.END_DOCUMENT) {
if (event == XmlPullParser.START_TAG) {
final String tag = parser.getName();
if (TAG_ELEMENT.equals(tag)) {
parseKeyboardSetElement(parser);
} else {
throw new IllegalStartTag(parser, TAG_KEYBOARD_SET);
}
} else if (event == XmlPullParser.END_TAG) {
final String tag = parser.getName();
if (TAG_KEYBOARD_SET.equals(tag)) {
break;
} else {
throw new IllegalEndTag(parser, TAG_KEYBOARD_SET);
}
}
}
}
private void parseKeyboardSetElement(XmlPullParser parser) throws XmlPullParserException,
IOException {
final TypedArray a = mResources.obtainAttributes(Xml.asAttributeSet(parser),
R.styleable.KeyboardSet_Element);
try {
if (!a.hasValue(R.styleable.KeyboardSet_Element_elementName)) {
throw new ParseException(
"No elementName attribute in <" + TAG_ELEMENT + "/>", parser);
}
if (!a.hasValue(R.styleable.KeyboardSet_Element_elementKeyboard)) {
throw new ParseException(
"No elementKeyboard attribute in <" + TAG_ELEMENT + "/>", parser);
}
KeyboardBuilder.checkEndTag(TAG_ELEMENT, parser);
final int elementName = a.getInt(
R.styleable.KeyboardSet_Element_elementName, 0);
final int elementKeyboard = a.getResourceId(
R.styleable.KeyboardSet_Element_elementKeyboard, 0);
mElementKeyboards.put(elementName, elementKeyboard);
} finally {
a.recycle();
}
}
}
public static String parseKeyboardLocale(Resources res, int resId)
throws XmlPullParserException, IOException {
final XmlPullParser parser = res.getXml(resId);
if (parser == null) return "";
int event;
while ((event = parser.next()) != XmlPullParser.END_DOCUMENT) {
if (event == XmlPullParser.START_TAG) {
final String tag = parser.getName();
if (TAG_KEYBOARD_SET.equals(tag)) {
final TypedArray keyboardSetAttr = res.obtainAttributes(
Xml.asAttributeSet(parser), R.styleable.KeyboardSet);
final String locale = keyboardSetAttr.getString(
R.styleable.KeyboardSet_keyboardLocale);
keyboardSetAttr.recycle();
return locale;
} else {
throw new IllegalStartTag(parser, TAG_KEYBOARD_SET);
}
}
}
return "";
} }
} }

View File

@ -207,7 +207,7 @@ public class MiniKeyboard extends Keyboard {
public Builder(KeyboardView view, int xmlId, Key parentKey, Keyboard parentKeyboard) { public Builder(KeyboardView view, int xmlId, Key parentKey, Keyboard parentKeyboard) {
super(view.getContext(), new MiniKeyboardParams()); super(view.getContext(), new MiniKeyboardParams());
load(parentKeyboard.mId.cloneWithNewXml(mResources.getResourceEntryName(xmlId), xmlId)); load(parentKeyboard.mId.cloneWithNewXml(xmlId));
// TODO: Mini keyboard's vertical gap is currently calculated heuristically. // TODO: Mini keyboard's vertical gap is currently calculated heuristically.
// Should revise the algorithm. // Should revise the algorithm.

View File

@ -292,7 +292,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
return new Keyboard(mParams); return new Keyboard(mParams);
} }
private void parseKeyboard(XmlResourceParser parser) private void parseKeyboard(XmlPullParser parser)
throws XmlPullParserException, IOException { throws XmlPullParserException, IOException {
if (DEBUG) Log.d(TAG, String.format("<%s> %s", TAG_KEYBOARD, mParams.mId)); if (DEBUG) Log.d(TAG, String.format("<%s> %s", TAG_KEYBOARD, mParams.mId));
int event; int event;
@ -311,30 +311,6 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
} }
} }
public static String parseKeyboardLocale(
Context context, int resId) throws XmlPullParserException, IOException {
final Resources res = context.getResources();
final XmlPullParser parser = res.getXml(resId);
if (parser == null) return "";
int event;
while ((event = parser.next()) != XmlPullParser.END_DOCUMENT) {
if (event == XmlPullParser.START_TAG) {
final String tag = parser.getName();
if (TAG_KEYBOARD.equals(tag)) {
final TypedArray keyboardAttr = res.obtainAttributes(Xml.asAttributeSet(parser),
R.styleable.Keyboard);
final String locale = keyboardAttr.getString(
R.styleable.Keyboard_keyboardLocale);
keyboardAttr.recycle();
return locale;
} else {
throw new IllegalStartTag(parser, TAG_KEYBOARD);
}
}
}
return "";
}
private void parseKeyboardAttributes(XmlPullParser parser) { private void parseKeyboardAttributes(XmlPullParser parser) {
final int displayWidth = mDisplayMetrics.widthPixels; final int displayWidth = mDisplayMetrics.widthPixels;
final TypedArray keyboardAttr = mContext.obtainStyledAttributes( final TypedArray keyboardAttr = mContext.obtainStyledAttributes(
@ -757,7 +733,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
} }
} }
private static void checkEndTag(String tag, XmlPullParser parser) public static void checkEndTag(String tag, XmlPullParser parser)
throws XmlPullParserException, IOException { throws XmlPullParserException, IOException {
if (parser.next() == XmlPullParser.END_TAG && tag.equals(parser.getName())) if (parser.next() == XmlPullParser.END_TAG && tag.equals(parser.getName()))
return; return;
@ -856,14 +832,14 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
} }
@SuppressWarnings("serial") @SuppressWarnings("serial")
private static class IllegalStartTag extends ParseException { public static class IllegalStartTag extends ParseException {
public IllegalStartTag(XmlPullParser parser, String parent) { public IllegalStartTag(XmlPullParser parser, String parent) {
super("Illegal start tag " + parser.getName() + " in " + parent, parser); super("Illegal start tag " + parser.getName() + " in " + parent, parser);
} }
} }
@SuppressWarnings("serial") @SuppressWarnings("serial")
private static class IllegalEndTag extends ParseException { public static class IllegalEndTag extends ParseException {
public IllegalEndTag(XmlPullParser parser, String parent) { public IllegalEndTag(XmlPullParser parser, String parent) {
super("Illegal end tag " + parser.getName() + " in " + parent, parser); super("Illegal end tag " + parser.getName() + " in " + parent, parser);
} }

View File

@ -178,7 +178,7 @@ public class MoreSuggestions extends Keyboard {
int minWidth, int maxRow) { int minWidth, int maxRow) {
final Keyboard keyboard = KeyboardSwitcher.getInstance().getLatinKeyboard(); final Keyboard keyboard = KeyboardSwitcher.getInstance().getLatinKeyboard();
final int xmlId = R.xml.kbd_suggestions_pane_template; final int xmlId = R.xml.kbd_suggestions_pane_template;
load(keyboard.mId.cloneWithNewXml(mResources.getResourceEntryName(xmlId), xmlId)); load(keyboard.mId.cloneWithNewXml(xmlId));
mParams.mVerticalGap = mParams.mTopPadding = keyboard.mVerticalGap / 2; mParams.mVerticalGap = mParams.mTopPadding = keyboard.mVerticalGap / 2;
final int count = mParams.layout(suggestions, fromPos, maxWidth, minWidth, maxRow, final int count = mParams.layout(suggestions, fromPos, maxWidth, minWidth, maxRow,

View File

@ -50,10 +50,9 @@ public class SuggestTestsBase extends AndroidTestCase {
+ "orientation=" + orientation); + "orientation=" + orientation);
return null; return null;
} }
return new KeyboardId(locale.toString() + " keyboard", return new KeyboardId(com.android.inputmethod.latin.R.xml.kbd_qwerty,
com.android.inputmethod.latin.R.xml.kbd_qwerty, locale, orientation, width, KeyboardId.ELEMENT_ALPHABET, locale, orientation, width, KeyboardId.MODE_TEXT,
KeyboardId.MODE_TEXT, new EditorInfo(), false, KeyboardId.F2KEY_MODE_NONE, new EditorInfo(), false, KeyboardId.F2KEY_MODE_NONE, false, false, false);
false, false, false);
} }
protected InputStream openTestRawResource(int resIdInTest) { protected InputStream openTestRawResource(int resIdInTest) {