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

Cordova framework to build Android app #1946

Merged
merged 1 commit into from
Jul 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ debug/
release/
testresults/

# Cordova
cordova/www/
cordova/platforms/
cordova/plugins/
cordova/resources/
cordova/package-lock.json
McGiverGim marked this conversation as resolved.
Show resolved Hide resolved

# OSX
.DS_store

Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ Unstable testing versions of the lates builds of the configurator for most platf

**Be aware that these versions are intended for testing / feedback only, and may be buggy or broken, and can cause flight controller settings to be corrupted. Caution is advised when using these versions.**

## Native app build via NW.js
## Native app build via NW.js (windows/linux/macos) or Cordova (android)

### Development

1. Install node.js (version 10 required)
2. Install yarn: `npm install yarn -g`
3. Change to project folder and run `yarn install`.
4. Run `yarn start`.
3. (For Android platform only) Install Java JDK 8, Gradle and Android Studio (Android SDK at least level 19)
4. Change to project folder and run `yarn install`.
5. Run `yarn start`.

### Running tests

Expand All @@ -69,12 +70,14 @@ yarn gulp <taskname> [[platform] [platform] ...]
```

List of possible values of `<task-name>`:
* **dist** copies all the JS and CSS files in the `./dist` folder.
* **dist** copies all the JS and CSS files in the `./dist` folder [2].
* **apps** builds the apps in the `./apps` folder [1].
* **debug** builds debug version of the apps in the `./debug` folder [1].
* **debug** builds debug version of the apps in the `./debug` folder [1][3].
* **release** zips up the apps into individual archives in the `./release` folder [1].

[1] Running this task on macOS or Linux requires Wine, since it's needed to set the icon for the Windows app (build for specific platform to avoid errors).
[2] For Android platform, **dist** task will generate the `./cordova` folder
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick - this does not seem to be true any more - probably rather 'or Android platform, dist task will generate folders and files in the ./cordova folder'.

A cleaner way to do this would be to have these files generated under /dist or /cordova-dist, but not sure if this is possible in an easy way with Cordova.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can rename the cordova folder to cordova-dist. But I think, there is a risk of confusion, the equivalent of the dist folder in the cordova project is more cordova/src. Moreover, the cordova folder can not be deleted like the dist folder

Copy link
Member

Choose a reason for hiding this comment

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

Part of the problem is that the statement 'For Android platform, dist task will generate the ./cordova folder' will make people think that this directory can be deleted when cleaning up after a build. Another problem is that yarn gulp clean currently fails to remove build artefacts in /cordova - the easiest solution for this will be to separate the files that currently end up under /cordova into two different directories: One for the permanent files, another one (which can be a sub-directory) for the build artefacts. This will also make fixing yarn gulp clean a lot easier.
But this can all be done in a follow-up pull request.

Copy link
Member

Choose a reason for hiding this comment

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

@WalcoFPV: I think this needs to be fixed with some urgency, and it is a little bit more complex than previously thought:
Since a build of the Android app modifies some files that are under source control (cordova/config.xml, cordova/config.xml) these will appear as changed and sneak into subsequent commits for unrelated changes:

image

This is a hassle and will require a lot of manual cleanup in the future, so it should be fixed - probably best rename the files to ..._template or suchlike, and create a copy of them in the directory that is to contain the build artefacts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done ! #2109

[3] For Android platform, you need to configure an emulator or to plug an Android device with USB debugging enabled

#### Build or release app for one specific platform
To build or release only for one specific platform you can append the plaform after the `task-name`.
Expand All @@ -84,6 +87,7 @@ If no platform is provided, all the platforms will be done in sequence.
* **Linux** use `yarn gulp <task-name> --linux64`
* **Windows** use `yarn gulp <task-name> --win32`
* **ChromeOS** use `yarn gulp <task-name> --chromeos`
* **Android** use `yarn gulp <task-name> --android`

You can also use multiple platforms e.g. `yarn gulp <taskname> --osx64 --linux64`.

Expand Down
Binary file added assets/android/icon/drawable-hdpi-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/android/icon/drawable-ldpi-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/android/icon/drawable-mdpi-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/android/icon/drawable-xhdpi-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/android/icon/drawable-xxhdpi-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/android/icon/drawable-xxxhdpi-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions cordova/build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"android": {
"release": {
"keystore": "release.keystore",
"storePassword": "betaflight",
"alias": "betaflight",
"password" : "betaflight"
}
}
}
52 changes: 52 additions & 0 deletions cordova/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="com.betaflight.betaflightconfigurator" version="[INJECTED_BY_GULPFILE]">
<name>[INJECTED_BY_GULPFILE]</name>
<description>[INJECTED_BY_GULPFILE]</description>
<author href="https://betaflight.com">[INJECTED_BY_GULPFILE]</author>
<content src="main_cordova.html"/>
<access origin="*"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<allow-intent href="tel:*"/>
<allow-intent href="sms:*"/>
<allow-intent href="mailto:*"/>
<allow-intent href="geo:*"/>
<preference name="Orientation" value="default"/>
<preference name="ShowSplashScreenSpinner" value="false"/>
<preference name="AutoHideSplashScreen" value="false"/>
<platform name="android">
<allow-intent href="market:*"/>
<icon src="resources/android/icon/drawable-ldpi-icon.png" density="ldpi"/>
<icon src="resources/android/icon/drawable-mdpi-icon.png" density="mdpi"/>
<icon src="resources/android/icon/drawable-hdpi-icon.png" density="hdpi"/>
<icon src="resources/android/icon/drawable-xhdpi-icon.png" density="xhdpi"/>
<icon src="resources/android/icon/drawable-xxhdpi-icon.png" density="xxhdpi"/>
<icon src="resources/android/icon/drawable-xxxhdpi-icon.png" density="xxxhdpi"/>
<splash src="resources/android/splash/drawable-land-hdpi-screen.png" density="land-hdpi"/>
<splash src="resources/android/splash/drawable-land-ldpi-screen.png" density="land-ldpi"/>
<splash src="resources/android/splash/drawable-land-mdpi-screen.png" density="land-mdpi"/>
<splash src="resources/android/splash/drawable-land-xhdpi-screen.png" density="land-xhdpi"/>
<splash src="resources/android/splash/drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/>
<splash src="resources/android/splash/drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/>
<splash src="resources/android/splash/drawable-port-hdpi-screen.png" density="port-hdpi"/>
<splash src="resources/android/splash/drawable-port-ldpi-screen.png" density="port-ldpi"/>
<splash src="resources/android/splash/drawable-port-mdpi-screen.png" density="port-mdpi"/>
<splash src="resources/android/splash/drawable-port-xhdpi-screen.png" density="port-xhdpi"/>
<splash src="resources/android/splash/drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/>
<splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/>
<preference name="SplashMaintainAspectRatio" value="true"/>
<preference name="SplashShowOnlyFirstTime" value="true"/>
<preference name="android-minSdkVersion" value="19"/>
<config-file parent="/manifest/application/activity" target="AndroidManifest.xml">
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"/>
</intent-filter>
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/usb_device_filter"/>
</config-file>
<resource-file src="usb_device_filter.xml" target="app/src/main/res/xml/usb_device_filter.xml"/>
</platform>
<platform name="ios">
<allow-intent href="itms:*"/>
<allow-intent href="itms-apps:*"/>
</platform>
</widget>
54 changes: 54 additions & 0 deletions cordova/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "[INJECTED_BY_GULPFILE]",
"displayName": "Betaflight Configurator",
"version": "[INJECTED_BY_GULPFILE]",
"description": "[INJECTED_BY_GULPFILE]",
"main": "index.js",
"scripts": {},
"author": "[INJECTED_BY_GULPFILE]",
"license": "[INJECTED_BY_GULPFILE]",
"dependencies": {
"cordova": "^9.0.0",
"cordova-android": "^8.1.0",
"cordova-clipboard": "^1.3.0",
"bf-cordova-open-native-settings": "^2.0.4",
"bf-cordova-plugin-appavailability": "^1.0.3",
"cordova-plugin-chrome-apps-common": "^1.0.7",
"cordova-plugin-chrome-apps-runtime": "^2.0.0",
"cordova-plugin-chrome-apps-storage": "^1.0.4",
"bf-cordova-plugin-chrome-apps-usb": "^2.0.1",
"cordova-plugin-dialogs": "^2.0.2",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-filechooser": "^1.2.0",
"cordova-plugin-market": "^1.2.0",
"cordova-plugin-permission": "^0.1.0",
"cordova-plugin-splashscreen": "^5.0.3",
"cordova-plugin-usb-event": "^1.0.2",
"cordova-plugin-whitelist": "^1.3.4",
"bf-cordovarduino": "^1.0.0"
},
"cordova": {
"platforms": [
"android"
],
"plugins": {
"cordova-plugin-chrome-apps-common": {},
"cordova-plugin-chrome-apps-runtime": {},
"cordova-plugin-chrome-apps-storage": {},
"cordova-plugin-whitelist": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-permission": {},
"cordova-plugin-usb-event": {},
"cordova-plugin-dialogs": {},
"bf-cordovarduino": {},
"cordova-plugin-file": {},
"cordova-plugin-filechooser": {},
"bf-cordova-plugin-chrome-apps-usb": {},
"cordova-clipboard": {},
"cordova-plugin-screen-orientation": {},
"cordova-plugin-market": {},
"bf-cordova-open-native-settings": {},
"bf-cordova-plugin-appavailability": {}
}
}
}
Binary file added cordova/release.keystore
Binary file not shown.
4 changes: 4 additions & 0 deletions cordova/usb_device_filter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<usb-device vendor-id="1155" product-id="22336" /> <!--STMicroelectronics / Virtual COM Port -->
</resources>
Loading