Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Gradle #452

Merged
merged 50 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
9a0ba70
Use Gradle
Aug 26, 2023
428d601
Added missing Gradle file
Aug 26, 2023
8a01ad1
Implemented translation synchronization script into Gradle
Aug 26, 2023
33aa5dc
Fixed custom font can't be loaded
Aug 26, 2023
437ede1
Don't use deprecated Gradle features
Aug 26, 2023
75d4f48
Remove packingOptions
Aug 26, 2023
3f27297
Remove Kotlin and AndroidX
Aug 27, 2023
c71b38a
Add default proguard config file
Aug 27, 2023
31889a3
Set minimum API level to 4
Aug 27, 2023
02ffb58
Update CI scripts
Aug 27, 2023
101f964
Remove old Makefile
Aug 27, 2023
eae3dbc
Merge remote-tracking branch 'Julow/master'
Aug 27, 2023
ba77fec
Allow specifying manual keystores for local build and CI
Aug 28, 2023
110da27
Fixed check_layout.py
Aug 28, 2023
2e60c69
Include special_font.ttf and don't automatically rebuild it all the time
Aug 28, 2023
bd12384
Merge .gitignore files
Aug 28, 2023
1ce0ff8
Be compatible with Java 7
Aug 28, 2023
7e8a417
Remove empty proguard configuration file
Aug 28, 2023
a4e17df
Don't print fake values when checking keyboard layouts
Aug 28, 2023
95692b9
Updated documentation
Aug 28, 2023
7319728
Remove automatic release singing in GitHub CI
Aug 29, 2023
b1a8fd4
Rename and reorganize Gradle build tasks
Aug 29, 2023
13c3658
Don't split translations between debug and release
Aug 29, 2023
9c1709c
Fix CI fail
Aug 29, 2023
44ea2ce
Update documentation
Aug 29, 2023
2f767ea
Run gradle layout tasks at test
Aug 31, 2023
e3599f3
Don't use Gradle submodule
Sep 3, 2023
fc7b76b
Remove Gradle submodule from documentation
Sep 3, 2023
02a273e
Removed reference to Gradle submodule
Sep 3, 2023
9556017
Revert changing CI name
Sep 4, 2023
adcef59
Remove reference to app directory
Sep 4, 2023
93f153d
Updated .gitignore
Sep 4, 2023
7a3089a
Update layouts.xml
Sep 4, 2023
d1ef52f
Cleanup gradle.properties
Sep 4, 2023
2efe490
Remove need for separate debug sourceSet
Sep 5, 2023
27bfee0
Don't print if no debug keystore needs to be initialized
Sep 5, 2023
8378e7c
Remove debug sourceSet and use old layout for main sourceSet
Sep 5, 2023
00784cc
Remove Jitpack dependency
Oct 10, 2023
5a5705c
More verbose error message in documentation
Oct 10, 2023
d3bcf25
Update build.gradle
Oct 10, 2023
b53e764
Add syncTranslations to Gradle test task
Oct 10, 2023
61fe67e
Don't redirect Gradle task output to stdout except for checkKeyboardL…
Oct 10, 2023
4c75d70
Merge branch 'MAIN' into pr/452
Julow Nov 25, 2023
64db698
Unindent workflow files
Julow Nov 25, 2023
6808a02
Update contribution guidelines
Julow Nov 25, 2023
d68cd86
2-based indentation
Julow Nov 25, 2023
c10c75c
CI: Restore make-apk name
Julow Nov 25, 2023
e3a813d
Tidy .gitignore
Julow Nov 25, 2023
67c49b2
Move special_font source back to srcs/
Julow Nov 25, 2023
2444731
Merge branch 'MAIN' into pr/452
Julow Nov 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions .github/workflows/make-apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,37 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '11'
java-version: '17'
- name: Checkout repo
uses: actions/checkout@v3
- name: Cache debug certificate
uses: actions/cache@v3
with:
path: _build/debug.keystore
key: debug-keystore
- name: Restore debug keystore from github Secrets
- name: Restore debug keystore from GitHub Secrets
run: |
mkdir -p _build
cd "_build"
# Check if exist and use the secret named DEBUG_KEYSTORE
# The contents of the secret can be obtained -
# from the debug.keystore.asc from you local _build folder
# from the debug.keystore.asc from you local folder (refer to CONTRIBUTING.md#Using the local debug.keystore on the Github CI actions)
if [[ ! "${{ secrets.DEBUG_KEYSTORE }}" = "" ]]; then
echo "${{ secrets.DEBUG_KEYSTORE }}" > "debug.keystore.asc"
if [[ -s "debug.keystore.asc" ]]; then
echo "Restoring debug keystore from GitHub secrets"
gpg -d --passphrase "debug0" --batch "debug.keystore.asc" > "debug.keystore"
fi
fi
- name: Build
run: make
- name: Build debug APK
uses: gradle/gradle-build-action@v2
env:
DEBUG_KEYSTORE: "debug.keystore"
DEBUG_KEYSTORE_PASSWORD: debug0
DEBUG_KEY_ALIAS: debug
DEBUG_KEY_PASSWORD: debug0
with:
arguments: assembleDebug
- name: Artifact naming
run: |
artifact="${{github.repository_owner}} ${{github.ref_name}}"
artifact="${artifact//\//-}" # replace slashes
echo "artifact=${artifact}" >> $GITHUB_ENV
- name: Save debug apk
- name: Upload debug APK
uses: actions/upload-artifact@v3
with:
name: "${{env.artifact}} debug_apk"
path: _build/*.apk
path: build/outputs/apk/debug/*.apk
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
*.keystore
*.keystore.asc
_build
/*-keystore.conf
*.iml
.gradle
/local.properties
/.idea
.DS_Store
/captures
/build
# Directory _build is not used anymore
/_build
3 changes: 1 addition & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="juloo.keyboard2" android:versionCode="36" android:versionName="1.24.0" android:hardwareAccelerated="false">
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="33"/>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="36" android:versionName="1.24.0" android:hardwareAccelerated="false">
<application android:label="@string/app_name" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:hardwareAccelerated="false">
<service android:name="juloo.keyboard2.Keyboard2" android:label="@string/app_name" android:permission="android.permission.BIND_INPUT_METHOD" android:exported="true" android:directBootAware="true">
<intent-filter>
Expand Down
84 changes: 47 additions & 37 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,58 @@ Thanks for contributing :)

## Building the app

The application doesn't use Gradle and it might be hard to use some features of
Android Studio.

Fortunately, there's not many dependencies:
- OpenJDK 8
The application uses Gradle and can be used with Android Studio, but using
Android Studio is not required. The build dependencies are:
- OpenJDK 17
- Android SDK: build tools (minimum `28.0.1`), platform `30`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the minimums still right ?

- Make sure to have the `$ANDROID_HOME` environment variable set.

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).
Python 3 is required to update generated files but not to build the app.

Building the debug apk:
For Android Studio users, no more setup is needed.

```sh
make
```

If the build succeed, the debug apk is located in `_build/juloo.keyboard2.debug.apk`.

## Using the local debug.keystore on the Github CI actions
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).

It's possible to save the local debug.keystore into a github secret, so the same keystore is utilized to build the debug apk in the CI github actions.
Doing this, they wil have the same signature, thus the debug apk can be updated without having to uninstall it first.
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.

After you sucessfully run `make`, (thus a debug.keystore exists) you can use this second command to generate a base64 stringified version of it
Building the debug apk:

```sh
cd _build
gpg -c --armor --pinentry-mode loopback --passphrase debug0 --yes "debug.keystore"
./gradlew assembleDebug
```

A file will be generated inside the local `_build/` folder, called `debug.keystore.asc`

You can copy the content of this file, and with that, paste it into a new github secret in your repo settings.

The secret must be named `DEBUG_KEYSTORE`
If the build succeeds, the debug apk is located in `build/outputs/apk/debug/app-debug.apk`.

## Debugging on your phone

First [Enable adb debugging on your device](https://developer.android.com/studio/command-line/adb#Enabling).
Then connect your phone to your computer using an USB cable or wireless
Then connect your phone to your computer using an USB cable or via wireless
debugging.

If you use Android Studio, this process will be automatic and you don't have to
follow this guide anymore.

And finally, install the application with:
```sh
make installd
./gradlew installDebug
```

The released version of the application won't be removed, both versions will
be installed at the same time.

## Debugging the application: INSTALL_FAILED_UPDATE_INCOMPATIBLE

`make installd` can fail with the following error message:
`./gradlew installDebug` can fail with the following error message:

```
adb: failed to install _build/juloo.keyboard2.debug.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package juloo.keyboard2.debug signatures do not match previously installed version; ignoring!]
make: *** [Makefile:20: installd] Error 1
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!
```

The application can't be "updated" because the temporary certificate has been
Expand All @@ -70,9 +64,24 @@ The application must be enabled again in the settings.

```sh
adb uninstall juloo.keyboard2.debug
make installd
./gradlew installDebug
```

## 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`.

## Guidelines

### Adding a layout
Expand All @@ -89,17 +98,18 @@ The layout file must be placed in the `res/xml/` directory and named according t
- layout name (eg. the name of a standard)
- country code (or language code if more adequate)

Then, run `make gen_layouts` to add the layout to the app.
Then, run `./gradlew genLayoutsList` to add the layout to the app.

The last step will update the file `res/values/layouts.xml`, that you should
not edit directly.

Run `make check_layouts` to check some properties about your layout. This will
change the file `check_layout.output`, which you should commit.
Run `./gradlew checkKeyboardLayouts` to check some properties about your
layout. This will change the file `check_layout.output`, which you should
commit.

#### Adding a programming layout

A programming layout must contains every ASCII characters.
A programming layout must contain all ASCII characters.
The current programming layouts are: QWERTY, Dvorak and Colemak.

See for example, Dvorak, added in https://github.com/Julow/Unexpected-Keyboard/pull/16
Expand Down Expand Up @@ -161,7 +171,7 @@ default translation in `res/values/strings.xml`, which contain the structure of
the file and the English strings.

To check that `strings.xml` is formatted correctly, run
`python sync_translations.py`. This will modify your files.
`./gradlew syncTranslations`. This will modify your files.

The store description is found in `metadata/android/<locale>/`,
`short_description.txt` and `full_description.txt`.
Expand Down
139 changes: 0 additions & 139 deletions Makefile

This file was deleted.

File renamed without changes.
Loading