Skip to content
Merged
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
18 changes: 10 additions & 8 deletions lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,12 @@ function updateProjectSplashScreen (platformConfig, locations) {
'windowSplashScreenAnimatedIcon',
'windowSplashScreenAnimationDuration',
'windowSplashScreenBackground',
'windowSplashScreenBrandingImage',
'android:windowSplashScreenBrandingImage',
'windowSplashScreenIconBackgroundColor',
'postSplashScreenTheme'
].forEach(themeKey => {
const cdvConfigPrefKey = 'Android' + themeKey.charAt(0).toUpperCase() + themeKey.slice(1);
const index = themeKey.indexOf(':') + 1;
const cdvConfigPrefKey = 'Android' + themeKey.charAt(index).toUpperCase() + themeKey.slice(index + 1);
const cdvConfigPrefValue = platformConfig.getPreference(cdvConfigPrefKey, this.platform);
let themeTargetNode = splashScreenTheme.find(`item[@name="${themeKey}"]`);

Expand Down Expand Up @@ -411,7 +412,7 @@ function updateProjectSplashScreen (platformConfig, locations) {
updateProjectSplashScreenImage(locations, themeKey, cdvConfigPrefKey, cdvConfigPrefValue);
break;

case 'windowSplashScreenBrandingImage':
case 'android:windowSplashScreenBrandingImage':
// display warning only when set.
if (cdvConfigPrefValue) {
events.emit('warn', `"${themeKey}" is currently not supported by the splash screen compatibility library. https://issuetracker.google.com/issues/194301890`);
Expand All @@ -422,13 +423,14 @@ function updateProjectSplashScreen (platformConfig, locations) {
// force the themes value to `@color/cdv_splashscreen_icon_background`
if (!cdvConfigPrefValue && themeTargetNode) {
splashScreenTheme.remove(themeTargetNode);
delete themes.getroot().attrib['xmlns:tools'];
} else if (cdvConfigPrefValue) {
// if there is no current node, create a new node.
if (!themeTargetNode) {
themeTargetNode = themes.getroot().makeelement('item', { name: themeKey });
themeTargetNode = themes.getroot().makeelement('item', { name: themeKey, 'tools:targetApi': '31' });
splashScreenTheme.append(themeTargetNode);
themes.getroot().attrib['xmlns:tools'] = 'http://schemas.android.com/tools';
}

// set the user defined color.
themeTargetNode.text = '@drawable/ic_cdv_splashscreen_branding';
}
Expand Down Expand Up @@ -537,7 +539,7 @@ function cleanupAndSetProjectSplashScreenImage (srcFile, destFilePath, possibleP
function updateProjectSplashScreenImage (locations, themeKey, cdvConfigPrefKey, cdvConfigPrefValue = '') {
const SPLASH_SCREEN_IMAGE_BY_THEME_KEY = {
windowSplashScreenAnimatedIcon: 'ic_cdv_splashscreen',
windowSplashScreenBrandingImage: 'ic_cdv_splashscreen_branding'
'android:windowSplashScreenBrandingImage': 'ic_cdv_splashscreen_branding'
};

const destFileName = SPLASH_SCREEN_IMAGE_BY_THEME_KEY[themeKey] || null;
Expand All @@ -555,7 +557,7 @@ function updateProjectSplashScreenImage (locations, themeKey, cdvConfigPrefKey,
// Default Drawable Source File
let defaultSrcFilePath = null;

if (themeKey !== 'windowSplashScreenBrandingImage') {
if (themeKey !== 'android:windowSplashScreenBrandingImage') {
try {
// coming from user project
defaultSrcFilePath = require.resolve('cordova-android/templates/project/res/drawable/' + destFileNameExt);
Expand All @@ -575,7 +577,7 @@ function updateProjectSplashScreenImage (locations, themeKey, cdvConfigPrefKey,
}

events.emit(emitType, emmitMessage);
const cleanupOnly = themeKey === 'windowSplashScreenBrandingImage';
const cleanupOnly = themeKey === 'android:windowSplashScreenBrandingImage';
cleanupAndSetProjectSplashScreenImage(defaultSrcFilePath, destFilePath, possiblePreviousDestFilePath, cleanupOnly);
return;
}
Expand Down