diff --git a/.gitignore b/.gitignore index 7c9c458c7..1c375d353 100644 --- a/.gitignore +++ b/.gitignore @@ -54,16 +54,8 @@ browser-extensions/firefox/copay.xpi version.js !js/controllers/version.js -android/package -android/*.apk -android/*.keystore - -mobile/*.keystore -mobile/assets/www -mobile/bin/* -mobile/gen/* -mobile/cordova/* -mobile/CordovaLib/* +cordova/project/* +cordova/*.keystore coverage/ diff --git a/android/build.sh b/android/build.sh deleted file mode 100644 index 313aa0320..000000000 --- a/android/build.sh +++ /dev/null @@ -1,71 +0,0 @@ -#! /bin/bash - -# Description: This script compiles and copy the needed files to later package the application for Android - -OpenColor="\033[" -Red="1;31m" -Yellow="1;33m" -Green="1;32m" -CloseColor="\033[0m" - -# Check function OK -checkOK() { - if [ $? != 0 ]; then - echo "${OpenColor}${Red}* ERROR. Exiting...${CloseColor}" - exit 1 - fi -} - -# Configs -BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -APPDIR="$BUILDDIR/package" -VERSION=`cut -d '"' -f2 $BUILDDIR/../version.js` -DEBUG="" -if [[ $1 = "-d" ]] -then - DEBUG="--enable-remote-debugging" -fi - -if [[ $# -eq 1 && ! $1 = "-d" ]] -then - if [ ! -f $BUILDDIR/copay.keystore ] - then - echo "${OpenColor}${Red}* Can't build production app without a keystore${CloseColor}" - exit 1 - fi - PRODUCTION="--keystore-path=$BUILDDIR/copay.keystore --keystore-alias=copay_play --keystore-passcode=$1" -fi - -# Move to the build directory -cd $BUILDDIR - -[ -z "$CROSSWALK" ] && { echo "${OpenColor}${Red}* Need to set CROSSWALK environment variable${CloseColor}"; exit 1; } - -# Create/Clean temp dir -echo "${OpenColor}${Green}* Checking temp dir...${CloseColor}" -if [ -d $APPDIR ]; then - rm -rf $APPDIR -fi - -mkdir -p $APPDIR - -# Re-compile copayBundle.js -echo "${OpenColor}${Green}* Generating copay bundle...${CloseColor}" -grunt --target=dev shell -checkOK - -# Copy all app files -echo "${OpenColor}${Green}* Copying all app files...${CloseColor}" -sed "s/APP_VERSION/$VERSION/g" manifest.json > $APPDIR/manifest.json -cd $BUILDDIR/.. -cp -af {css,font,img,js,lib,sound,config.js,version.js,index.html,./android/icon.png,./android/logo.png} $APPDIR -checkOK - -# Building the APK -echo "${OpenColor}${Green}* Building APK file...${CloseColor}" -cd $CROSSWALK -python make_apk.py --manifest=$APPDIR/manifest.json --package=com.bitpay.copay --arch=arm --target-dir=$BUILDDIR $DEBUG $PRODUCTION -checkOK -cd $BUILDDIR - -echo "${OpenColor}${Yellow}\nAwesome! We have a brand new APK, enjoy it!${CloseColor}" diff --git a/android/icon.png b/android/icon.png deleted file mode 100644 index 84f38c3b6..000000000 Binary files a/android/icon.png and /dev/null differ diff --git a/android/logo.png b/android/logo.png deleted file mode 100644 index 1a324a9af..000000000 Binary files a/android/logo.png and /dev/null differ diff --git a/android/manifest.json b/android/manifest.json deleted file mode 100644 index ff5336880..000000000 --- a/android/manifest.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "Copay", - "version": "APP_VERSION", - "start_url": "index.html", - "permissions": [ - "Vibration" - ], - "xwalk_launch_screen": { - "ready_when": "complete", - "default": { - "background_color": "#2C3E50", - "image": "logo.png" - } - }, - "icons": { - "128": "icon.png" - }, - "xwalk_hosts": [ - "https://*" - ] -} diff --git a/mobile/AndroidManifest.xml b/cordova/android/AndroidManifest.xml similarity index 78% rename from mobile/AndroidManifest.xml rename to cordova/android/AndroidManifest.xml index 55c598b74..cab29c6a8 100644 --- a/mobile/AndroidManifest.xml +++ b/cordova/android/AndroidManifest.xml @@ -1,23 +1,13 @@ - + - - - + - - - - - - - - @@ -40,7 +30,6 @@ - diff --git a/mobile/res/xml/config.xml b/cordova/android/config.xml similarity index 82% rename from mobile/res/xml/config.xml rename to cordova/android/config.xml index 1bef18ae5..c69016dfc 100644 --- a/mobile/res/xml/config.xml +++ b/cordova/android/config.xml @@ -2,39 +2,40 @@ Copay - A secure bitcoin wallet for friends and companies + A secure bitcoin wallet for friends and companies. - + Bitpay Inc. - + + - - + + - - - - - - + + + - - + + + + + diff --git a/cordova/build.sh b/cordova/build.sh new file mode 100644 index 000000000..53c59f38c --- /dev/null +++ b/cordova/build.sh @@ -0,0 +1,124 @@ +#! /bin/bash + +# Usage: +# sh ./build.sh --android --reload + +OpenColor="\033[" +Red="1;31m" +Yellow="1;33m" +Green="1;32m" +CloseColor="\033[0m" + +# Check function OK +checkOK() { + if [ $? != 0 ]; then + echo "${OpenColor}${Red}* ERROR. Exiting...${CloseColor}" + exit 1 + fi +} + +# Configs +BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +PROJECT="$BUILDDIR/project" +VERSION=`cut -d '"' -f2 $BUILDDIR/../version.js` + +SKIPIOS=false +CLEAR=false + +# Check Args +if [[ $1 = "--android" || $2 = "--android" ]] +then + SKIPIOS=true +fi + +if [[ $1 = "--clear" || $2 = "--clear" ]] +then + CLEAR=true +fi + + +echo "${OpenColor}${Green}* Checking dependencies...${CloseColor}" +command -v cordova >/dev/null 2>&1 || { echo >&2 "Cordova is not present, please install it: sudo npm -g cordova."; exit 1; } +command -v xcodebuild >/dev/null 2>&1 || { echo >&2 "XCode is not present, install it or use [--android]."; exit 1; } + + +# Create project dir +if [[ CLEAR ]] +then + if [ -d $PROJECT ]; then + rm -rf $PROJECT + fi +fi + +if [ ! -d $PROJECT ]; then + cd $BUILDDIR + echo "${OpenColor}${Green}* Creating project... ${CloseColor}" + cordova create project com.bitpay.copay Copay + checkOK + + cd $PROJECT + echo "${OpenColor}${Green}* Adding Android platform... ${CloseColor}" + cordova platforms add android + checkOK + + if [[ !SKIPIOS ]]; then + echo "${OpenColor}${Green}* Adding IOS platform... ${CloseColor}" + cordova platforms add ios + checkOK + fi + + echo "${OpenColor}${Green}* Installing plugins... ${CloseColor}" + cordova plugin add https://github.com/Initsogar/cordova-webintent.git + checkOK + + cordova plugin add https://github.com/wildabeast/BarcodeScanner.git + checkOK + + cordova plugin add https://github.com/VersoSolutions/CordovaClipboard + checkOK + + cordova plugin add de.appplant.cordova.plugin.email-composer && cordova prepare + checkOK + + cordova plugin add https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git && cordova prepare + checkOK + + cordova plugin add org.apache.cordova.splashscreen + checkOK + + cordova plugin add org.apache.cordova.statusbar + checkOK +fi + +echo "${OpenColor}${Green}* Generating copay bundle...${CloseColor}" +cd $BUILDDIR/.. +grunt +checkOK + +echo "${OpenColor}${Green}* Coping files...${CloseColor}" +cd $BUILDDIR/.. +cp -af {css,font,img,js,lib,sound,views,config.js,version.js} $PROJECT/www +checkOK + +sed "s/<\!-- PLACEHOLDER: CORDOVA SRIPT -->/