Skip to content

Commit

Permalink
prefs: Use QWERTY (US) as the default custom layout
Browse files Browse the repository at this point in the history
This layout definition contains some documentation and is a better
default than no text.
  • Loading branch information
Julow committed Dec 17, 2023
1 parent 478d808 commit d7c230e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
12 changes: 11 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}
}
Expand Down Expand Up @@ -134,6 +134,7 @@ tasks.register('syncTranslations') {

tasks.named("preBuild") {
dependsOn += "initDebugKeystore"
dependsOn += "copyRawQwertyUS"
}

tasks.register('initDebugKeystore') {
Expand All @@ -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"
}
}
18 changes: 17 additions & 1 deletion srcs/juloo.keyboard2/LayoutsPreference.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void onClick(DialogInterface _dialog, int which)
callback.select(new SystemLayout());
break;
case "custom":
select_custom(callback, "");
select_custom(callback, read_initial_custom_layout());
break;
default:
callback.select(new NamedLayout(name));
Expand Down Expand Up @@ -203,6 +203,22 @@ void select(final SelectionCallback callback, Layout prev_layout)
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)
Expand Down

0 comments on commit d7c230e

Please sign in to comment.