prefs: Use QWERTY (US) as the default custom layout

This layout definition contains some documentation and is a better
default than no text.
This commit is contained in:
Jules Aguillon 2023-12-17 12:41:19 +01:00
parent 478d8082f4
commit d7c230e173
2 changed files with 28 additions and 2 deletions

View File

@ -18,7 +18,7 @@ android {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['srcs']
res.srcDirs = ['res']
res.srcDirs = ['res', 'build/generated-resources']
assets.srcDirs = ['assets']
}
}
@ -134,6 +134,7 @@ tasks.register('syncTranslations') {
tasks.named("preBuild") {
dependsOn += "initDebugKeystore"
dependsOn += "copyRawQwertyUS"
}
tasks.register('initDebugKeystore') {
@ -145,3 +146,12 @@ tasks.register('initDebugKeystore') {
}
}
}
// latn_qwerty_us is used as a raw resource by the custom layout option.
tasks.register('copyRawQwertyUS')
{
copy {
from "res/xml/latn_qwerty_us.xml"
into "build/generated-resources/raw"
}
}

View File

@ -151,7 +151,7 @@ public class LayoutsPreference extends ListGroupPreference<LayoutsPreference.Lay
callback.select(new SystemLayout());
break;
case "custom":
select_custom(callback, "");
select_custom(callback, read_initial_custom_layout());
break;
default:
callback.select(new NamedLayout(name));
@ -203,6 +203,22 @@ public class LayoutsPreference extends ListGroupPreference<LayoutsPreference.Lay
select(callback);
}
/** The initial text for the custom layout entry box. The qwerty_us layout is
a good default and contains a bit of documentation. */
String read_initial_custom_layout()
{
try
{
Resources res = getContext().getResources();
byte[] raw = res.openRawResource(R.raw.latn_qwerty_us).readAllBytes();
return new String(raw, "UTF-8");
}
catch (Exception _e)
{
return "";
}
}
class LayoutsAddButton extends AddButton
{
public LayoutsAddButton(Context ctx)