Skip to content
This repository was archived by the owner on Feb 20, 2020. It is now read-only.
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ phantomjsdriver.log
*.swp
/config
/app/assets/CNAME
mobile/platforms
4 changes: 2 additions & 2 deletions Gulpfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ browserify = require('browserify')
scripts = (isWatch) ->
->
setup = (bundler) ->
#if isDeploy(nodeEnv)
# bundler.transform(global: true, 'uglifyify')
if isDeploy(nodeEnv)
bundler.transform(global: true, 'uglifyify')
bundler

bundle = (bundler) ->
Expand Down
71 changes: 71 additions & 0 deletions MOBILE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
### Steps

#### Prerequisites
[Android Studio](https://developer.android.com/tools/studio/index.html) or Android SDK (``brew install android-sdk``) Please ensure to read the **Caveats** section.



npm install cordova cordova-icon -g
cd ~/src/cobudget-ui
npm build # must build the ui first

cordova create mobile co.cobudget.app Cobudget --link-to=build
cd ./mobile
cordova plugin add cordova-plugin-google-analytics
cordova platform add browser
cordova run browser

cordova platform add android
cordova build android
cordova emulate android

To rebuild:

cd .. ; rm -rf build/ ; NODE_ENV=development gulp build ; cd mobile
cd .. ; rm -rf build/ ; NODE_ENV=development AUTH_STORAGE=localStorage API_ENDPOINT="http://10.0.2.2:3000/api/v1" gulp build ; cd mobile

You must modify ``config/development.js`` to look like:

module.exports = {
apiPrefix: "http://10.0.2.2:3000/api/v1"
}

You must launch the cobudget-api server using

bundle exec rails s -b 0.0.0.0

### Deploy

#### Android

There is a bug in cordova android plugin version number generation. For more information please see:
https://stackoverflow.com/questions/32951375/why-does-cordova-phonegap-append-8-to-my-android-version-code
https://issues.apache.org/jira/browse/CB-8976?jql=text%20~%20%22versionCode%22

To work around this issue the please inspect ``mobile/platforms/android/build.gradle`` and update line ~165:

versionCode cdvVersionCode ?: Integer.parseInt("" + privateHelpers.extractIntFromManifest("versionCode")) + "0"

to be

versionCode cdvVersionCode ?: Integer.parseInt("" + privateHelpers.extractIntFromManifest("versionCode"))


##### Building Android

cd .. ; rm -rf build/ ; NODE_ENV=production AUTH_STORAGE=localStorage gulp build ; cd mobile

keytool -genkey -v -keystore cobudget.keystore -alias cobudget -keyalg RSA -keysize 2048 -validity 10000

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 \
-keystore ~/MEGA/projects/cobudget/cobudget.keystore \
platforms/android/build/outputs/apk/android-release-unsigned.apk cobudget

~/Library/Android/sdk/build-tools/21.1.2/zipalign -v 4 \
~/src/cobudget-ui/mobile/platforms/android/build/outputs/apk/android-release-unsigned.apk \
cobudget-release.apk

#### iOS
cd .. ; rm -rf build/ ; NODE_ENV=production AUTH_STORAGE=localStorage gulp build ; cd mobile
cordova build ios --release --device

3 changes: 2 additions & 1 deletion app/configs/auth.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
global.cobudgetApp.config ($authProvider, config) ->
$authProvider.configure
apiUrl: config.apiPrefix
validateOnPageLoad: false
validateOnPageLoad: false
storage: config.authStorage
3 changes: 2 additions & 1 deletion config/defaults.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
apiPrefix: "http://localhost:3000/api/v1"
apiPrefix: "http://localhost:3000/api/v1",
authStorage: process.env.AUTH_STORAGE || 'cookies'
}
2 changes: 1 addition & 1 deletion config/development.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
apiPrefix: "http://localhost:3000/api/v1"
apiPrefix: process.env.API_ENDPOINT || "http://127.0.0.1:3000/api/v1"
}
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.
Binary file added mobile/assets/cobudget_icon_1024px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions mobile/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash -ex

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# for gardner's dev machine
export PATH=$PATH:~/Library/Android/sdk/build-tools/21.1.2

function req() {
for cmd in "$@"; do
if ! which $cmd >/dev/null; then
echo "$cmd is required but not found in PATH";
exit 1
else
echo $cmd found
fi
done
}

echo "Checking for required tools..."
req cordova android zipalign xcodebuild cordova-icon
echo "System meets build requirements."

cordova platform add android || echo platform already added
cordova platform add ios || echo ios already added

echo ""
echo "Building web app."
cd $DIR/..
rm -rf build/
NODE_ENV=production AUTH_STORAGE=localStorage gulp build
cd mobile

echo "Building cordova wrapper app."
cordova build android --release --device

echo "Signing android APK."
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 \
-keystore cobudget.keystore \
platforms/android/build/outputs/apk/android-release-unsigned.apk \
cobudget

echo "Aligning APK file."
zipalign -v 4 \
~/src/cobudget-ui/mobile/platforms/android/build/outputs/apk/android-release-unsigned.apk \
cobudget-release.apk

echo -n "Done: "
ls -lah cobudget-release.apk

echo "Building cordova wrapper app for ios."
cordova build ios --release --device

26 changes: 26 additions & 0 deletions mobile/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="co.cobudget.app" version="0.0.1" android-versionCode="19" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Cobudget</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="[email protected]" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<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:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
23 changes: 23 additions & 0 deletions mobile/hooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
-->
# Cordova Hooks

Cordova Hooks represent special scripts which could be added by application and plugin developers or even by your own build system to customize cordova commands. See Hooks Guide for more details: http://cordova.apache.org/docs/en/edge/guide_appdev_hooks_index.md.html#Hooks%20Guide.
3 changes: 3 additions & 0 deletions mobile/hooks/after_prepare/cordova-icon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
cordova-icon

Binary file added mobile/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions mobile/plugins/android.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"prepare_queue": {
"installed": [],
"uninstalled": []
},
"config_munge": {
"files": {}
},
"installed_plugins": {
"cordova-plugin-whitelist": {
"PACKAGE_NAME": "co.cobudget.app"
}
},
"dependent_plugins": {}
}
15 changes: 15 additions & 0 deletions mobile/plugins/browser.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"prepare_queue": {
"installed": [],
"uninstalled": []
},
"config_munge": {
"files": {}
},
"installed_plugins": {
"cordova-plugin-whitelist": {
"PACKAGE_NAME": "co.cobudget.app"
}
},
"dependent_plugins": {}
}
37 changes: 37 additions & 0 deletions mobile/plugins/cordova-plugin-whitelist/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!--
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
-->

# Contributing to Apache Cordova

Anyone can contribute to Cordova. And we need your contributions.

There are multiple ways to contribute: report bugs, improve the docs, and
contribute code.

For instructions on this, start with the
[contribution overview](http://cordova.apache.org/contribute/).

The details are explained there, but the important items are:
- Sign and submit an Apache ICLA (Contributor License Agreement).
- Have a Jira issue open that corresponds to your contribution.
- Run the tests so your patch doesn't break existing functionality.

We look forward to your contributions!
Loading