mirror of
https://github.com/apache/cordova-android.git
synced 2025-03-04 00:13:20 +08:00
fix: Add android prefix to windowSplashScreenBrandingImage (#1487)
This commit is contained in:
parent
8a1ffeeafd
commit
954d3e0e75
@ -378,11 +378,12 @@ function updateProjectSplashScreen (platformConfig, locations) {
|
|||||||
'windowSplashScreenAnimatedIcon',
|
'windowSplashScreenAnimatedIcon',
|
||||||
'windowSplashScreenAnimationDuration',
|
'windowSplashScreenAnimationDuration',
|
||||||
'windowSplashScreenBackground',
|
'windowSplashScreenBackground',
|
||||||
'windowSplashScreenBrandingImage',
|
'android:windowSplashScreenBrandingImage',
|
||||||
'windowSplashScreenIconBackgroundColor',
|
'windowSplashScreenIconBackgroundColor',
|
||||||
'postSplashScreenTheme'
|
'postSplashScreenTheme'
|
||||||
].forEach(themeKey => {
|
].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);
|
const cdvConfigPrefValue = platformConfig.getPreference(cdvConfigPrefKey, this.platform);
|
||||||
let themeTargetNode = splashScreenTheme.find(`item[@name="${themeKey}"]`);
|
let themeTargetNode = splashScreenTheme.find(`item[@name="${themeKey}"]`);
|
||||||
|
|
||||||
@ -411,7 +412,7 @@ function updateProjectSplashScreen (platformConfig, locations) {
|
|||||||
updateProjectSplashScreenImage(locations, themeKey, cdvConfigPrefKey, cdvConfigPrefValue);
|
updateProjectSplashScreenImage(locations, themeKey, cdvConfigPrefKey, cdvConfigPrefValue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'windowSplashScreenBrandingImage':
|
case 'android:windowSplashScreenBrandingImage':
|
||||||
// display warning only when set.
|
// display warning only when set.
|
||||||
if (cdvConfigPrefValue) {
|
if (cdvConfigPrefValue) {
|
||||||
events.emit('warn', `"${themeKey}" is currently not supported by the splash screen compatibility library. https://issuetracker.google.com/issues/194301890`);
|
events.emit('warn', `"${themeKey}" is currently not supported by the splash screen compatibility library. https://issuetracker.google.com/issues/194301890`);
|
||||||
@ -422,13 +423,14 @@ function updateProjectSplashScreen (platformConfig, locations) {
|
|||||||
// force the themes value to `@color/cdv_splashscreen_icon_background`
|
// force the themes value to `@color/cdv_splashscreen_icon_background`
|
||||||
if (!cdvConfigPrefValue && themeTargetNode) {
|
if (!cdvConfigPrefValue && themeTargetNode) {
|
||||||
splashScreenTheme.remove(themeTargetNode);
|
splashScreenTheme.remove(themeTargetNode);
|
||||||
|
delete themes.getroot().attrib['xmlns:tools'];
|
||||||
} else if (cdvConfigPrefValue) {
|
} else if (cdvConfigPrefValue) {
|
||||||
// if there is no current node, create a new node.
|
// if there is no current node, create a new node.
|
||||||
if (!themeTargetNode) {
|
if (!themeTargetNode) {
|
||||||
themeTargetNode = themes.getroot().makeelement('item', { name: themeKey });
|
themeTargetNode = themes.getroot().makeelement('item', { name: themeKey, 'tools:targetApi': '31' });
|
||||||
splashScreenTheme.append(themeTargetNode);
|
splashScreenTheme.append(themeTargetNode);
|
||||||
|
themes.getroot().attrib['xmlns:tools'] = 'http://schemas.android.com/tools';
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the user defined color.
|
// set the user defined color.
|
||||||
themeTargetNode.text = '@drawable/ic_cdv_splashscreen_branding';
|
themeTargetNode.text = '@drawable/ic_cdv_splashscreen_branding';
|
||||||
}
|
}
|
||||||
@ -537,7 +539,7 @@ function cleanupAndSetProjectSplashScreenImage (srcFile, destFilePath, possibleP
|
|||||||
function updateProjectSplashScreenImage (locations, themeKey, cdvConfigPrefKey, cdvConfigPrefValue = '') {
|
function updateProjectSplashScreenImage (locations, themeKey, cdvConfigPrefKey, cdvConfigPrefValue = '') {
|
||||||
const SPLASH_SCREEN_IMAGE_BY_THEME_KEY = {
|
const SPLASH_SCREEN_IMAGE_BY_THEME_KEY = {
|
||||||
windowSplashScreenAnimatedIcon: 'ic_cdv_splashscreen',
|
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;
|
const destFileName = SPLASH_SCREEN_IMAGE_BY_THEME_KEY[themeKey] || null;
|
||||||
@ -555,7 +557,7 @@ function updateProjectSplashScreenImage (locations, themeKey, cdvConfigPrefKey,
|
|||||||
// Default Drawable Source File
|
// Default Drawable Source File
|
||||||
let defaultSrcFilePath = null;
|
let defaultSrcFilePath = null;
|
||||||
|
|
||||||
if (themeKey !== 'windowSplashScreenBrandingImage') {
|
if (themeKey !== 'android:windowSplashScreenBrandingImage') {
|
||||||
try {
|
try {
|
||||||
// coming from user project
|
// coming from user project
|
||||||
defaultSrcFilePath = require.resolve('cordova-android/templates/project/res/drawable/' + destFileNameExt);
|
defaultSrcFilePath = require.resolve('cordova-android/templates/project/res/drawable/' + destFileNameExt);
|
||||||
@ -575,7 +577,7 @@ function updateProjectSplashScreenImage (locations, themeKey, cdvConfigPrefKey,
|
|||||||
}
|
}
|
||||||
|
|
||||||
events.emit(emitType, emmitMessage);
|
events.emit(emitType, emmitMessage);
|
||||||
const cleanupOnly = themeKey === 'windowSplashScreenBrandingImage';
|
const cleanupOnly = themeKey === 'android:windowSplashScreenBrandingImage';
|
||||||
cleanupAndSetProjectSplashScreenImage(defaultSrcFilePath, destFilePath, possiblePreviousDestFilePath, cleanupOnly);
|
cleanupAndSetProjectSplashScreenImage(defaultSrcFilePath, destFilePath, possiblePreviousDestFilePath, cleanupOnly);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user