@@ -19,7 +19,8 @@ module.exports = function (grunt) {
19
19
var appConfig = {
20
20
app : require ( './bower.json' ) . appPath || 'app' ,
21
21
dist : 'dist' ,
22
- cordova : 'cordova'
22
+ cordova : 'cordova' ,
23
+ appName : 'YoAngularChrome'
23
24
} ;
24
25
25
26
// Define the configuration for all the tasks
@@ -363,7 +364,7 @@ module.exports = function (grunt) {
363
364
command : 'rm -Rf <%= yeoman.cordova %>'
364
365
} ,
365
366
cordovaCreate : {
366
- command : 'cordova create <%= yeoman.cordova %> com.sample.YoAngularCordova "YoAngularCordova " --copy-from=<%= yeoman.dist %>'
367
+ command : 'cordova create <%= yeoman.cordova %> com.sample.<%= yeoman.appName %> "<%= yeoman.appName %> " --copy-from=<%= yeoman.dist %>'
367
368
} ,
368
369
cordovaPrepare : {
369
370
command : 'cordova prepare' ,
@@ -395,6 +396,47 @@ module.exports = function (grunt) {
395
396
}
396
397
} ) ;
397
398
399
+ var xpath = require ( 'xpath' ) ;
400
+ var dom = require ( 'xmldom' ) . DOMParser ;
401
+ grunt . registerTask ( 'addCordovaPreferences' , function ( ) {
402
+ var cordovaConfig = appConfig . cordova + '/config.xml' ;
403
+ var xml = grunt . file . read ( cordovaConfig ) ;
404
+ var doc = new dom ( ) . parseFromString ( xml ) ;
405
+
406
+ var node = doc . getElementsByTagName ( 'widget' ) [ 0 ] ;
407
+
408
+ //var author = node.getElementsByTagName("author")[0];
409
+ //author.setAttribute('email','[email protected] ');
410
+ //author.setAttribute('href','http://example.com');
411
+ //author.nodeValue='[email protected] ';
412
+
413
+ // grunt.log.writeln('Adding to: ' + node);
414
+ var KeyboardShrinksView = doc . createElement ( 'preference' ) ;
415
+ KeyboardShrinksView . setAttribute ( 'name' , 'KeyboardShrinksView' ) ;
416
+ KeyboardShrinksView . setAttribute ( 'value' , true ) ;
417
+ grunt . log . writeln ( 'Adding: ' + KeyboardShrinksView ) ;
418
+ node . appendChild ( KeyboardShrinksView ) ;
419
+
420
+ var StatusBarOverlaysWebView = doc . createElement ( 'preference' ) ;
421
+ StatusBarOverlaysWebView . setAttribute ( 'name' , 'StatusBarOverlaysWebView' ) ;
422
+ StatusBarOverlaysWebView . setAttribute ( 'value' , false ) ;
423
+ grunt . log . writeln ( 'Adding: ' + StatusBarOverlaysWebView ) ;
424
+ node . appendChild ( StatusBarOverlaysWebView ) ;
425
+
426
+ var StatusBarBackgroundColor = doc . createElement ( 'preference' ) ;
427
+ StatusBarBackgroundColor . setAttribute ( 'name' , 'StatusBarBackgroundColor' ) ;
428
+ StatusBarBackgroundColor . setAttribute ( 'value' , '#388E3C' ) ; // Should be the 700 color for your main color http://www.google.com/design/spec/style/color.html#color-color-palette
429
+ grunt . log . writeln ( 'Adding: ' + StatusBarBackgroundColor ) ;
430
+ node . appendChild ( StatusBarBackgroundColor ) ;
431
+
432
+ var KeyboardDisplayRequiresUserAction = doc . createElement ( 'preference' ) ;
433
+ KeyboardDisplayRequiresUserAction . setAttribute ( 'name' , 'KeyboardDisplayRequiresUserAction' ) ;
434
+ KeyboardDisplayRequiresUserAction . setAttribute ( 'value' , false ) ;
435
+ grunt . log . writeln ( 'Adding: ' + KeyboardDisplayRequiresUserAction ) ;
436
+ node . appendChild ( KeyboardDisplayRequiresUserAction ) ;
437
+
438
+ grunt . file . write ( cordovaConfig , doc ) ;
439
+ } ) ;
398
440
399
441
grunt . registerTask ( 'serve' , 'Compile then start a connect web server' , function ( target ) {
400
442
if ( target === 'dist' ) {
@@ -452,6 +494,7 @@ module.exports = function (grunt) {
452
494
'build' ,
453
495
'shell:cordovaClean' ,
454
496
'shell:cordovaCreate' ,
497
+ 'addCordovaPreferences' ,
455
498
'shell:cordovaPlatformInstallAndroid' ,
456
499
'shell:cordovaPlatformInstallIos'
457
500
] ) ;
0 commit comments