2022-01-15 18:55:05 +01:00
# Contributing
Thanks for contributing :)
## Building the app
2023-11-25 20:11:12 +01:00
The application uses Gradle and can be used with Android Studio, but using
Android Studio is not required. The build dependencies are:
- OpenJDK 17
2022-02-07 01:11:55 +01:00
- Android SDK: build tools (minimum `28.0.1` ), platform `30`
2022-01-15 18:55:05 +01:00
2023-11-25 20:11:12 +01:00
Python 3 is required to update generated files but not to build the app.
2022-01-15 18:55:05 +01:00
2023-11-25 20:11:12 +01:00
For Android Studio users, no more setup is needed.
2022-01-15 18:55:05 +01:00
2023-11-25 20:11:12 +01:00
For Nix users, the right environment can be obtained with `nix-shell ./shell.nix` .
Instructions to install Nix are [here ](https://nixos.wiki/wiki/Nix_Installation_Guide ).
2022-04-02 16:33:12 +02:00
2023-11-25 20:11:12 +01:00
If you don't use Android Studio or Nix, you have to inform Gradle about the
location of your Android SDK by either:
- Setting the `ANDROID_HOME` environment variable to point to the android sdk or
- Creating the file `local.properties` and writing
`sdk.dir=<location_of_android_home>` into it.
2022-04-02 16:33:12 +02:00
2023-11-25 20:11:12 +01:00
Building the debug apk:
2022-04-02 16:33:12 +02:00
```sh
2023-11-25 20:11:12 +01:00
./gradlew assembleDebug
2022-04-02 16:33:12 +02:00
```
2023-09-09 16:44:04 +02:00
Nix users can call gradle directly: `gradle assembleDebug` .
2023-11-25 20:11:12 +01:00
If the build succeeds, the debug apk is located in `build/outputs/apk/debug/app-debug.apk` .
2022-04-02 16:33:12 +02:00
2022-01-15 18:55:05 +01:00
## Debugging on your phone
2022-01-20 21:21:07 +01:00
First [Enable adb debugging on your device ](https://developer.android.com/studio/command-line/adb#Enabling ).
2023-11-25 20:11:12 +01:00
Then connect your phone to your computer using an USB cable or via wireless
2022-01-20 21:21:07 +01:00
debugging.
2022-01-15 18:55:05 +01:00
2023-11-25 20:11:12 +01:00
If you use Android Studio, this process will be automatic and you don't have to
follow this guide anymore.
2022-01-20 21:21:07 +01:00
And finally, install the application with:
2022-01-15 18:55:05 +01:00
```sh
2023-11-25 20:11:12 +01:00
./gradlew installDebug
2022-01-15 18:55:05 +01:00
```
2023-04-15 16:11:23 +02:00
The released version of the application won't be removed, both versions will
be installed at the same time.
2022-01-15 19:51:40 +01:00
2022-01-15 19:03:53 +01:00
## Debugging the application: INSTALL_FAILED_UPDATE_INCOMPATIBLE
2023-11-25 20:11:12 +01:00
`./gradlew installDebug` can fail with the following error message:
2022-01-15 19:03:53 +01:00
```
2023-11-25 20:11:12 +01:00
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':installDebug'.
> java.util.concurrent.ExecutionException: com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: INSTALL_FAILED_UPDATE_INCOMPATIBLE: Existing package juloo.keyboard2.debug signatures do not match newer version; ignoring!
2022-01-15 19:03:53 +01:00
```
The application can't be "updated" because the temporary certificate has been
2022-01-15 19:51:40 +01:00
lost. The solution is to uninstall and install again.
The application must be enabled again in the settings.
2022-01-15 19:03:53 +01:00
```sh
adb uninstall juloo.keyboard2.debug
2023-11-25 20:11:12 +01:00
./gradlew installDebug
2022-01-15 19:03:53 +01:00
```
2022-01-30 13:10:37 +01:00
2023-11-25 20:11:12 +01:00
## Specifying a debug signing certificate on Github Actions
It's possible to specify the signing certificate that the automated build
should use.
After you successfully run `./gradlew asssembleDebug` , (thus a debug.keystore
exists) you can use this second command to generate a base64 stringified
version of it:
```sh
gpg -c --armor --pinentry-mode loopback --passphrase debug0 --yes "debug.keystore"
```
This will create the file `debug.keystore.asc` , paste its content into a new
Github secret named `DEBUG_KEYSTORE` .
2022-01-30 13:10:37 +01:00
## Guidelines
2022-10-04 09:49:26 +02:00
### Adding a layout
2022-01-30 13:10:37 +01:00
2024-01-21 16:34:49 +01:00
Layouts are defined in XML, see `srcs/layouts/latn_qwerty_us.xml` .
2023-05-28 22:57:54 +02:00
An online tool for editing layout files written by @Lixquid is available
[here ](https://unexpected-keyboard-layout-editor.lixquid.com/ ).
2022-10-04 09:49:26 +02:00
2023-06-25 16:48:18 +02:00
Makes sure to specify the `name` attribute like in `latn_qwerty_us.xml` ,
otherwise the layout won't be added to the app.
2022-04-23 23:39:53 +02:00
2024-01-21 16:34:49 +01:00
The layout file must be placed in the `srcs/layouts` directory and named
according to:
2023-06-25 16:48:18 +02:00
- script (`latn` for latin, etc..)
- layout name (eg. the name of a standard)
- country code (or language code if more adequate)
2023-11-25 20:11:12 +01:00
Then, run `./gradlew genLayoutsList` to add the layout to the app.
2023-06-25 16:48:18 +02:00
The last step will update the file `res/values/layouts.xml` , that you should
not edit directly.
2022-04-23 23:39:53 +02:00
2023-11-25 20:11:12 +01:00
Run `./gradlew checkKeyboardLayouts` to check some properties about your
layout. This will change the file `check_layout.output` , which you should
commit.
2023-06-03 21:03:05 +02:00
2022-10-04 09:49:26 +02:00
#### Adding a programming layout
2023-11-25 20:11:12 +01:00
A programming layout must contain all ASCII characters.
2022-10-04 09:49:26 +02:00
The current programming layouts are: QWERTY, Dvorak and Colemak.
2023-04-15 16:11:23 +02:00
See for example, Dvorak, added in https://github.com/Julow/Unexpected-Keyboard/pull/16
It's best to leave free spots on the layout for language-specific symbols that
are added automatically when necessary.
These symbols are defined in `res/xml/method.xml` (`extra_keys`).
It's possible to place extra keys with the `loc` prefix. These keys are
normally hidden unless they are needed.
2022-05-29 12:27:46 +02:00
2022-04-23 23:39:53 +02:00
Some users cannot easily type the characters close the the edges of the screen
due to a bulky phone case. It is best to avoid placing important characters
there (such as the digits or punctuation).
2022-10-04 09:49:26 +02:00
#### Adding a localized layout
2022-04-23 23:39:53 +02:00
Localized layouts (a layout specific to a language) are gladly accepted.
2022-01-30 13:10:37 +01:00
See for example: 4333575 (Bulgarian), 88e2175 (Latvian), 133b6ec (German).
2022-04-23 23:39:53 +02:00
They don't need to contain every ASCII characters (although it's useful in
passwords) and dead-keys.
### Adding support for a language
2022-01-30 13:10:37 +01:00
2022-04-23 23:39:53 +02:00
Supported locales are defined in `res/xml/method.xml` .
2022-01-30 13:10:37 +01:00
2022-04-23 23:39:53 +02:00
The attributes `languageTag` and `imeSubtypeLocale` define a locale, the
attribute `imeSubtypeExtraValue` defines the default layout and the dead-keys
2023-04-15 16:11:23 +02:00
and other extra keys to show.
The list of language tags (generally two letters)
and locales (generally of the form `xx_XX` )
2023-08-27 17:44:13 +02:00
can be found in this [stackoverflow answer ](https://stackoverflow.com/a/7989085 )
2022-01-30 13:10:37 +01:00
2023-08-27 17:44:13 +02:00
### Updating translations
2022-01-30 13:10:37 +01:00
2023-08-27 17:39:04 +02:00
The text used in the app is written in `res/values-<language_tag>/strings.xml` .
2022-04-23 23:39:53 +02:00
2023-08-27 17:44:13 +02:00
The list of language tags can be found in this
[stackoverflow answer ](https://stackoverflow.com/a/7989085 )
2023-08-27 17:39:04 +02:00
The first part before the `_` is used, for example,
`res/values-fr/strings.xml` for French,
`res/values-lv/strings.xml` for Latvian.
Commented-out lines indicate missing translations:
```xml
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
```
2023-08-27 17:44:13 +02:00
Remove the `<!--` and `-->` parts and change the text.
2023-08-27 17:39:04 +02:00
### Adding a translation
The `res/values-<language_tag>/strings.xml` file must be created by copying the
default translation in `res/values/strings.xml` , which contain the structure of
the file and the English strings.
2022-01-30 13:10:37 +01:00
2023-06-03 21:03:05 +02:00
To check that `strings.xml` is formatted correctly, run
2024-02-05 17:36:43 +01:00
`python sync_translations.py` . This will modify your files.
2023-06-03 21:03:05 +02:00
2024-02-05 17:36:43 +01:00
Store descriptions in `metedata/` are updated automatically.
2023-06-03 21:03:05 +02:00
Translating changelogs is not useful.
2022-01-30 13:10:37 +01:00
2023-08-27 17:39:04 +02:00
The app name might be partially translated, the "Unexpected" word should remain
2024-02-05 17:36:43 +01:00
untranslated if possible.
2023-04-15 16:11:23 +02:00
2023-06-03 19:38:42 +02:00
As translations need to be updated regularly, you can subscribe to this issue
to receive a notification when an update is needed:
https://github.com/Julow/Unexpected-Keyboard/issues/373
2023-04-15 16:11:23 +02:00
### Adding key combinations
Key combinations are defined in `srcs/juloo.keyboard2/KeyModifier.java` .
For example, keys modified by the `Fn` key are defined in method
`apply_fn_char` .
Keys with special meaning are defined in `KeyValue.java` in method
`getKeyByName` . Their special action are defined in `KeyEventHandler.java` in
method `key_up`