Skip to content

Commit

Permalink
add gujarati layout (likely needs improvement, see #417)
Browse files Browse the repository at this point in the history
  • Loading branch information
Helium314 committed Jan 21, 2024
1 parent c81f7fc commit 279c564
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 0 deletions.
132 changes: 132 additions & 0 deletions app/src/main/assets/layouts/gujarati.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
[
[
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "" }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "" }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "િ" }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "" }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "◌ુ" }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "◌ૂ" }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "◌ે" }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "◌ૈ" }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "" }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "" }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "" }
}
],
[
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "", "popup": { "main": { "label": "" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "", "popup": { "main": { "label": "" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "", "popup": { "main": { "label": "" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "", "popup": { "main": { "label": "" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "", "popup": { "main": { "label": "" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "ક્ષ" },
"default": { "label": "", "popup": { "main": { "label": "" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "જ્ઞ" },
"default": { "label": "", "popup": { "main": { "label": "" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "", "popup": { "main": { "label": "૿" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "", "popup": { "main": { "label": "ત્ર" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "", "popup": { "main": { "label": "શ્ર" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "", "popup": { "main": { "label": "શ્ર" } } }
}
],
[
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "", "popup": { "main": { "label": "શ્વ" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "", "popup": { "main": { "label": "ત્ત" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "", "popup": { "main": { "label": "દ્ર" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "", "popup": { "main": { "label": "દ્વ" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "", "popup": { "main": { "label": "દ્દ" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "અં" },
"default": { "label": "", "popup": { "main": { "label": "દ્ય" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "અઃ" },
"default": { "label": "", "popup": { "main": { "label": "" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "", "popup": { "main": { "label": "" } } }
},
{ "$": "shift_state_selector",
"manualOrLocked": { "label": "" },
"default": { "label": "", "popup": { "main": { "label": "" } } }
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class ScriptUtils {
public static final int SCRIPT_THAI = 17;
public static final int SCRIPT_BULGARIAN = 18; // todo: why is bulgarian a separate script?
public static final int SCRIPT_HANGUL = 19;
public static final int SCRIPT_GUJARATI = 20;

private static final TreeMap<String, Integer> mLanguageCodeToScriptCode;
private final static ArraySet<Integer> UPPERCASE_SCRIPTS = new ArraySet<>();
Expand Down Expand Up @@ -79,6 +80,7 @@ public class ScriptUtils {
mLanguageCodeToScriptCode.put("kk", SCRIPT_CYRILLIC);
mLanguageCodeToScriptCode.put("ky", SCRIPT_CYRILLIC);
mLanguageCodeToScriptCode.put("ne", SCRIPT_DEVANAGARI);
mLanguageCodeToScriptCode.put("gu", SCRIPT_GUJARATI);

// only Latin, Cyrillic, Greek and Armenian have upper/lower case
// https://unicode.org/faq/casemap_charprop.html#3
Expand Down Expand Up @@ -203,6 +205,9 @@ public static boolean isLetterPartOfScript(final int codePoint, final int script
|| codePoint >= 0xA960 && codePoint <= 0xA97C
|| codePoint >= 0xD7B0 && codePoint <= 0xD7C6
|| codePoint >= 0xD7CB && codePoint <= 0xD7FB);
case SCRIPT_GUJARATI:
// Gujarati unicode block is U+0A80..U+0AFF
return (codePoint >= 0xA80 && codePoint <= 0xAFF);
case SCRIPT_UNKNOWN:
return true;
default:
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/xml/method.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
fr_CA: French (Canada)/qwerty
fr_CH: French (Switzerland)/qwertz+
gl_ES: Galician (Spain)/qwerty+
gu: Gujarati/gujarati
hi: Hindi/hindi
hi: Hindi/hindi_compact
hi_ZZ: Hinglish/qwerty # This is a preliminary keyboard layout.
Expand Down Expand Up @@ -420,6 +421,15 @@
android:isAsciiCapable="true"
/>
<subtype android:icon="@drawable/ic_ime_switcher"
android:label="@string/subtype_generic"
android:subtypeId="0x39713b7f"
android:imeSubtypeLocale="gu"
android:languageTag="gu"
android:imeSubtypeMode="keyboard"
android:imeSubtypeExtraValue="KeyboardLayoutSet=gujarati,EmojiCapable"
android:isAsciiCapable="false"
/>
<subtype android:icon="@drawable/ic_ime_switcher"
android:label="@string/subtype_generic"
android:subtypeId="0x39753b7f"
android:imeSubtypeLocale="hi"
Expand Down

0 comments on commit 279c564

Please sign in to comment.