diff --git a/lib/Api.js b/lib/Api.js index f337fe57b6..2ab4083ae1 100644 --- a/lib/Api.js +++ b/lib/Api.js @@ -72,9 +72,9 @@ class Api { platformWww: path.join(this.root, 'platform_www'), configXml: path.join(appRes, 'xml', 'config.xml'), defaultConfigXml: path.join(this.root, 'cordova', 'defaults.xml'), - strings: path.join(appRes, 'values', 'strings.xml'), - themes: path.join(appRes, 'values', 'themes.xml'), - colors: path.join(appRes, 'values', 'colors.xml'), + strings: path.join(appRes, 'values', 'cdv_strings.xml'), + themes: path.join(appRes, 'values', 'cdv_themes.xml'), + colors: path.join(appRes, 'values', 'cdv_colors.xml'), manifest: path.join(appMain, 'AndroidManifest.xml'), build: path.join(this.root, 'build'), javaSrc: path.join(appMain, 'java') diff --git a/lib/create.js b/lib/create.js index 5bb5314ec1..6ac56522fc 100755 --- a/lib/create.js +++ b/lib/create.js @@ -264,7 +264,7 @@ exports.create = function (project_path, config, options, events) { fs.mkdirSync(activity_dir, { recursive: true }); fs.cpSync(path.join(project_template_dir, 'Activity.java'), activity_path); utils.replaceFileContents(activity_path, /__ACTIVITY__/, safe_activity_name); - utils.replaceFileContents(path.join(app_path, 'res', 'values', 'strings.xml'), /__NAME__/, utils.escape(project_name)); + utils.replaceFileContents(path.join(app_path, 'res', 'values', 'cdv_strings.xml'), /__NAME__/, utils.escape(project_name)); utils.replaceFileContents(activity_path, /__ID__/, package_name); const manifest = new AndroidManifest(path.join(project_template_dir, 'AndroidManifest.xml')); diff --git a/lib/prepare.js b/lib/prepare.js index aebadb4ae4..4a8bbd0522 100644 --- a/lib/prepare.js +++ b/lib/prepare.js @@ -346,7 +346,7 @@ function updateProjectAccordingTo (platformConfig, locations) { * @param {Object} locations A map of locations for this platform */ function updateProjectStrings (platformConfig, locations) { - // Update app name by editing res/values/strings.xml + // Update app name by editing res/values/cdv_strings.xml const strings = xmlHelpers.parseElementtreeSync(locations.strings); const name = platformConfig.name(); @@ -377,7 +377,7 @@ function warnForDeprecatedSplashScreen (cordovaProject) { * @param {Object} locations A map of locations for this platform */ function updateProjectTheme (platformConfig, locations) { - // res/values/themes.xml + // res/values/cdv_themes.xml const themes = xmlHelpers.parseElementtreeSync(locations.themes); const splashScreenTheme = themes.find('style[@name="Theme.App.SplashScreen"]'); @@ -408,13 +408,17 @@ function updateProjectTheme (platformConfig, locations) { if (!splashBg) { splashBg = platformConfig.getPreference('BackgroundColor', this.platform); } + if (!splashBg) { + splashBg = '@color/cdv_splashscreen_background'; + } - // use the user defined value for "colors.xml" - updateProjectSplashScreenBackgroundColor(splashBg, locations); + events.emit('verbose', 'The Android Splash Screen background color was set to: ' + + (splashBg === '@color/cdv_splashscreen_background' ? 'Default' : splashBg) + ); // force the themes value to `@color/cdv_splashscreen_background` const splashBgNode = splashScreenTheme.find('item[@name="windowSplashScreenBackground"]'); - splashBgNode.text = '@color/cdv_splashscreen_background'; + splashBgNode.text = splashBg; [ // Splash Screen @@ -471,7 +475,7 @@ function updateProjectTheme (platformConfig, locations) { break; case 'windowSplashScreenIconBackgroundColor': - // use the user defined value for "colors.xml" + // use the user defined value for "cdv_colors.xml" updateProjectSplashScreenIconBackgroundColor(cdvConfigPrefValue, locations); // force the themes value to `@color/cdv_splashscreen_icon_background` @@ -495,7 +499,7 @@ function updateProjectTheme (platformConfig, locations) { break; case 'postSplashScreenTheme': - themeTargetNode.text = cdvConfigPrefValue || '@style/Theme.AppCompat.NoActionBar'; + themeTargetNode.text = cdvConfigPrefValue || '@style/Theme.Cordova.App.DayNight'; break; default: @@ -507,29 +511,13 @@ function updateProjectTheme (platformConfig, locations) { events.emit('verbose', 'Wrote out Android application themes to ' + locations.themes); } -/** - * @param {String} splashBackgroundColor SplashScreen Background Color Hex Code - * be used to update project - * @param {Object} locations A map of locations for this platform - */ -function updateProjectSplashScreenBackgroundColor (splashBackgroundColor, locations) { - if (!splashBackgroundColor) { splashBackgroundColor = '#FFFFFF'; } - - // res/values/colors.xml - const colors = xmlHelpers.parseElementtreeSync(locations.colors); - colors.find('color[@name="cdv_splashscreen_background"]').text = splashBackgroundColor.replace(/'/g, '\\\''); - - fs.writeFileSync(locations.colors, colors.write({ indent: 4 }), 'utf-8'); - events.emit('verbose', 'Wrote out Android application SplashScreen Color to ' + locations.colors); -} - /** * @param {String} splashIconBackgroundColor SplashScreen Icon Background Color Hex Code * be used to update project * @param {Object} locations A map of locations for this platform */ function updateProjectSplashScreenIconBackgroundColor (splashIconBackgroundColor, locations) { - // res/values/colors.xml + // res/values/cdv_colors.xml const colors = xmlHelpers.parseElementtreeSync(locations.colors); // node name const name = 'cdv_splashscreen_icon_background'; @@ -627,12 +615,12 @@ function updateProjectSplashScreenImage (locations, themeKey, cdvConfigPrefKey, // copy the png to correct mipmap folder with name of ic_cdv_splashscreen.png // delete ic_cdv_splashscreen.xml from drawable folder - // update themes.xml windowSplashScreenAnimatedIcon value to @mipmap/ic_cdv_splashscreen + // update cdv_themes.xml windowSplashScreenAnimatedIcon value to @mipmap/ic_cdv_splashscreen cleanupAndSetProjectSplashScreenImage(cdvConfigPrefValue, destFilePath, possiblePreviousDestFilePath); } else if (iconExtension === '.xml') { // copy the xml to drawable folder with name of ic_cdv_splashscreen.xml // delete ic_cdv_splashscreen.png from mipmap folder - // update themes.xml windowSplashScreenAnimatedIcon value to @drawable/ic_cdv_splashscreen + // update cdv_themes.xml windowSplashScreenAnimatedIcon value to @drawable/ic_cdv_splashscreen cleanupAndSetProjectSplashScreenImage(cdvConfigPrefValue, destFilePath, possiblePreviousDestFilePath); } else { // use the default destFilePath & possiblePreviousDestFilePath, no update require. diff --git a/spec/unit/create.spec.js b/spec/unit/create.spec.js index f6be97569c..276529711a 100644 --- a/spec/unit/create.spec.js +++ b/spec/unit/create.spec.js @@ -276,17 +276,17 @@ describe('create', function () { }); }); - it('should interpolate the project name into strings.xml', () => { + it('should interpolate the project name into cdv_strings.xml', () => { config_mock.name.and.returnValue('IncredibleApp'); return create.create(project_path, config_mock, {}, events_mock).then(() => { - expect(utils.replaceFileContents).toHaveBeenCalledWith(path.join(app_path, 'res', 'values', 'strings.xml'), /__NAME__/, 'IncredibleApp'); + expect(utils.replaceFileContents).toHaveBeenCalledWith(path.join(app_path, 'res', 'values', 'cdv_strings.xml'), /__NAME__/, 'IncredibleApp'); }); }); - it('should interpolate the escaped project name into strings.xml', () => { + it('should interpolate the escaped project name into cdv_strings.xml', () => { config_mock.name.and.returnValue(''); return create.create(project_path, config_mock, {}, events_mock).then(() => { - expect(utils.replaceFileContents).toHaveBeenCalledWith(path.join(app_path, 'res', 'values', 'strings.xml'), /__NAME__/, '<Incredible&App>'); + expect(utils.replaceFileContents).toHaveBeenCalledWith(path.join(app_path, 'res', 'values', 'cdv_strings.xml'), /__NAME__/, '<Incredible&App>'); }); }); diff --git a/spec/unit/prepare.spec.js b/spec/unit/prepare.spec.js index c93f02a32f..53676f0c2b 100644 --- a/spec/unit/prepare.spec.js +++ b/spec/unit/prepare.spec.js @@ -930,7 +930,7 @@ describe('prepare', () => { locations: { plugins: '/mock/plugins', www: '/mock/www', - strings: '/mock/res/values/strings.xml' + strings: '/mock/res/values/cdv_strings.xml' } }; diff --git a/templates/project/res/values-night-v34/cdv_colors.xml b/templates/project/res/values-night-v34/cdv_colors.xml new file mode 100644 index 0000000000..9c428d87dc --- /dev/null +++ b/templates/project/res/values-night-v34/cdv_colors.xml @@ -0,0 +1,23 @@ + + + + @android:color/system_background_dark + @color/cdv_background_color + diff --git a/templates/project/res/values-night/cdv_colors.xml b/templates/project/res/values-night/cdv_colors.xml new file mode 100644 index 0000000000..96b2ca7e23 --- /dev/null +++ b/templates/project/res/values-night/cdv_colors.xml @@ -0,0 +1,23 @@ + + + + #121318 + @color/cdv_background_color + diff --git a/templates/project/res/values-v34/cdv_colors.xml b/templates/project/res/values-v34/cdv_colors.xml new file mode 100644 index 0000000000..b07be36943 --- /dev/null +++ b/templates/project/res/values-v34/cdv_colors.xml @@ -0,0 +1,23 @@ + + + + @android:color/system_background_light + @color/cdv_background_color + diff --git a/templates/project/res/values/colors.xml b/templates/project/res/values/cdv_colors.xml similarity index 86% rename from templates/project/res/values/colors.xml rename to templates/project/res/values/cdv_colors.xml index a207b621f8..e9155db118 100644 --- a/templates/project/res/values/colors.xml +++ b/templates/project/res/values/cdv_colors.xml @@ -18,5 +18,6 @@ under the License. --> - #FFFFFFFF + #FAF8FF + @color/cdv_background_color diff --git a/templates/project/res/values/strings.xml b/templates/project/res/values/cdv_strings.xml similarity index 100% rename from templates/project/res/values/strings.xml rename to templates/project/res/values/cdv_strings.xml diff --git a/templates/project/res/values/themes.xml b/templates/project/res/values/cdv_themes.xml similarity index 50% rename from templates/project/res/values/themes.xml rename to templates/project/res/values/cdv_themes.xml index 9465ca089e..9a7588abe6 100644 --- a/templates/project/res/values/themes.xml +++ b/templates/project/res/values/cdv_themes.xml @@ -19,19 +19,23 @@ --> + + diff --git a/templates/project/res/xml/config.xml b/templates/project/res/xml/config.xml index 0e76a732a3..638709d314 100644 --- a/templates/project/res/xml/config.xml +++ b/templates/project/res/xml/config.xml @@ -49,7 +49,6 @@