feat(build): use cordova-custom-config, remove unnecessary hooks

This commit is contained in:
Jason Dreyzehner 2016-10-11 22:26:55 -04:00
commit 8035846faf
4 changed files with 17 additions and 65 deletions

View file

@ -16,11 +16,6 @@
<preference name="iosPersistentFileLocation" value="Library" /> <preference name="iosPersistentFileLocation" value="Library" />
<preference name="DisallowOverscroll" value="true"/> <preference name="DisallowOverscroll" value="true"/>
<preference name="HideKeyboardFormAccessoryBar" value="true"/> <preference name="HideKeyboardFormAccessoryBar" value="true"/>
<preference name="SplashScreen" value="copayscreen" />
<preference name="ShowSplashScreenSpinner" value="false" />
<preference name="AutoHideSplashScreen" value="false" />
<preference name="FadeSplashScreen" value="true" />
<preference name="FadeSplashScreenDuration" value="1" />
<preference name="KeyboardDisplayRequiresUserAction" value="false" /> <preference name="KeyboardDisplayRequiresUserAction" value="false" />
<preference name="StatusBarOverlaysWebView" value="true" /> <preference name="StatusBarOverlaysWebView" value="true" />
<preference name="StatusBarBackgroundColor" value="#1e3186" /> <preference name="StatusBarBackgroundColor" value="#1e3186" />
@ -28,6 +23,13 @@
<preference name="BackupWebStorage" value="none"/> <preference name="BackupWebStorage" value="none"/>
<preference name="windows-target-version" value="8.1"/> <preference name="windows-target-version" value="8.1"/>
<preference name="Orientation" value="default" /> <preference name="Orientation" value="default" />
<preference name="cordova-custom-config-stoponerror" value="true" />
<preference name="ShowSplashScreenSpinner" value="false" />
<preference name="AutoHideSplashScreen" value="false" />
<preference name="FadeSplashScreen" value="true" />
<preference name="FadeSplashScreenDuration" value="100" />
<preference name="SplashMaintainAspectRatio" value="true" />
<!-- Plugins --> <!-- Plugins -->
<plugin name="cordova-plugin-device" spec="~1.1.3"/> <plugin name="cordova-plugin-device" spec="~1.1.3"/>
@ -59,6 +61,7 @@
<plugin name="phonegap-plugin-push" spec="~1.8.2"> <plugin name="phonegap-plugin-push" spec="~1.8.2">
<variable name="SENDER_ID" value="*PUSHSENDERID*"/> <variable name="SENDER_ID" value="*PUSHSENDERID*"/>
</plugin> </plugin>
<plugin name="cordova-custom-config" spec="~3.0.5" />
<!-- Supported Platforms --> <!-- Supported Platforms -->
<engine name="ios" spec="~4.2.1" /> <engine name="ios" spec="~4.2.1" />
@ -67,9 +70,8 @@
<!-- Platform Specific Settings --> <!-- Platform Specific Settings -->
<platform name="ios"> <platform name="ios">
<!-- <hook type="after_prepare" src="util/hooks/ios/add-custom-urls-to-plist.js" /> <config-file platform="ios" target="*-Info.plist" parent="UIStatusBarHidden"><true/></config-file>
<hook type="after_prepare" src="util/hooks/ios/add-uistatusbarhidden-to-plist.js" /> --> <config-file platform="ios" target="*-Info.plist" parent="UIViewControllerBasedStatusBarAppearance"><false/></config-file>
<icon src="resources/*PACKAGENAME*/ios/icon/icon-60@3x.png" width="180" height="180" /> <icon src="resources/*PACKAGENAME*/ios/icon/icon-60@3x.png" width="180" height="180" />
<icon src="resources/*PACKAGENAME*/ios/icon/icon-60.png" width="60" height="60" /> <icon src="resources/*PACKAGENAME*/ios/icon/icon-60.png" width="60" height="60" />
<icon src="resources/*PACKAGENAME*/ios/icon/icon-60@2x.png" width="120" height="120" /> <icon src="resources/*PACKAGENAME*/ios/icon/icon-60@2x.png" width="120" height="120" />
@ -87,7 +89,6 @@
<icon src="resources/*PACKAGENAME*/ios/icon/icon-50.png" width="50" height="50" /> <icon src="resources/*PACKAGENAME*/ios/icon/icon-50.png" width="50" height="50" />
<icon src="resources/*PACKAGENAME*/ios/icon/icon-50@2x.png" width="100" height="100" /> <icon src="resources/*PACKAGENAME*/ios/icon/icon-50@2x.png" width="100" height="100" />
<splash src="resources/*PACKAGENAME*/ios/splash/Default~iphone.png" width="320" height="480"/> <splash src="resources/*PACKAGENAME*/ios/splash/Default~iphone.png" width="320" height="480"/>
<splash src="resources/*PACKAGENAME*/ios/splash/Default@2x~iphone.png" width="640" height="960"/> <splash src="resources/*PACKAGENAME*/ios/splash/Default@2x~iphone.png" width="640" height="960"/>
<splash src="resources/*PACKAGENAME*/ios/splash/Default-Portrait~ipad.png" width="768" height="1024"/> <splash src="resources/*PACKAGENAME*/ios/splash/Default-Portrait~ipad.png" width="768" height="1024"/>
@ -101,8 +102,7 @@
</platform> </platform>
<platform name="android"> <platform name="android">
<hook type="after_prepare" src="util/hooks/android/add-custom-urls-to-android-manifest.js" /> <preference name="android-manifest/application/@android:allowBackup" value="false" />
<hook type="after_prepare" src="util/hooks/android/prohibit-cloud-backups-in-android-manifest.js" />
<icon src="resources/*PACKAGENAME*/android/icon/drawable-ldpi-icon.png" density="ldpi" /> <icon src="resources/*PACKAGENAME*/android/icon/drawable-ldpi-icon.png" density="ldpi" />
<icon src="resources/*PACKAGENAME*/android/icon/drawable-mdpi-icon.png" density="mdpi" /> <icon src="resources/*PACKAGENAME*/android/icon/drawable-mdpi-icon.png" density="mdpi" />

View file

@ -27,8 +27,8 @@
"bitcore-wallet-client": "4.2.1", "bitcore-wallet-client": "4.2.1",
"bower": "^1.7.9", "bower": "^1.7.9",
"chai": "^3.5.0", "chai": "^3.5.0",
"cordova": "5.4.1",
"cordova-android": "5.1.1", "cordova-android": "5.1.1",
"cordova-custom-config": "^3.0.5",
"cordova-plugin-qrscanner": "^2.3.1", "cordova-plugin-qrscanner": "^2.3.1",
"coveralls": "^2.11.9", "coveralls": "^2.11.9",
"express": "^4.11.2", "express": "^4.11.2",
@ -89,12 +89,9 @@
"clean-all": "git clean -dfx && npm install" "clean-all": "git clean -dfx && npm install"
}, },
"devDependencies": { "devDependencies": {
"androidmanifest": "^2.0.0", "cordova": "^6.3.1",
"cordova": "^5.4.1", "grunt": "^1.0.1",
"globby": "^6.0.0",
"ionic": "^2.1.0", "ionic": "^2.1.0",
"plist": "^2.0.1", "trash-cli": "^1.4.0"
"trash-cli": "^1.4.0",
"xcode": "^0.8.2"
} }
} }

View file

@ -1,27 +0,0 @@
'use strict';
var AndroidManifest = require('androidmanifest');
var FILEPATH = 'platforms/android/AndroidManifest.xml';
var manifest = new AndroidManifest().readFile(FILEPATH);
var mainActivity = manifest.activity('MainActivity');
var customUrls = ['copay', 'bitcoin', 'bitauth'];
customUrls.forEach(function(url){
var selector = 'intent-filter > data[android\\:scheme=' + url + ']';
if(mainActivity.find(selector).length > 0){
return;
}
var intentFilter = manifest.$('<intent-filter>');
intentFilter.append('<data android:scheme="' + url + '" />');
intentFilter.append('<action android:name="android.intent.action.VIEW" />');
intentFilter.append('<category android:name="android.intent.category.DEFAULT" />');
intentFilter.append('<category android:name="android.intent.category.BROWSABLE" />');
mainActivity.append(intentFilter);
});
manifest.writeFile(FILEPATH);
console.log('custome uri schemes written to AndroidManifest');

View file

@ -1,18 +0,0 @@
module.exports = function(ctx) {
var fs = ctx.requireCordovaModule('fs'),
path = ctx.requireCordovaModule('path'),
xml = ctx.requireCordovaModule('cordova-common').xmlHelpers;
var manifestPath = path.join(ctx.opts.projectRoot, '/platforms/android/AndroidManifest.xml');
var doc = xml.parseElementtreeSync(manifestPath);
if (doc.getroot().tag !== 'manifest') {
throw new Error(manifestPath + ' has incorrect root node name (expected "manifest")');
}
doc.getroot().find('./application').attrib['android:allowBackup'] = "false";
//write the manifest file
fs.writeFileSync(manifestPath, doc.write({
indent: 4
}), 'utf-8');
};