mirror of
https://github.com/apache/cordova-android.git
synced 2025-03-03 16:03:08 +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',
|
||||
'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}"]`);
|
||||
|
||||
@ -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`);
|
||||
@ -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';
|
||||
}
|
||||
@ -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;
|
||||
@ -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);
|
||||
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user