Skip to content

Commit ad23f4b

Browse files
committed
Fix for white on white icons in status bars when running hybrid app on Android API 35
Overriding Cordova's default themes for API 35 NB: It looks like better E2E support is coming to Cordova Android 15 - see apache/cordova-android#1817
1 parent 0ff522e commit ad23f4b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

shared/createHelper.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,38 @@ function createHybridApp(config) {
109109
// Run cordova prepare
110110
utils.runProcessThrowError('cordova prepare', config.projectDir);
111111

112+
// Add theme for Android API 35
113+
if (config.platform.split(',').includes('android')) {
114+
createAndroidAPI35Theme(config.projectDir);
115+
}
116+
112117
// Done
113118
return prepareResult;
114119
}
115120

121+
//
122+
// Add Android API 35 theme file
123+
//
124+
function createAndroidAPI35Theme(projectDir) {
125+
const dirPath = path.join(projectDir, 'platforms', 'android', 'app', 'src', 'main', 'res', 'values-v35');
126+
const filePath = path.join(dirPath, 'themes.xml');
127+
const fileContents = `<?xml version='1.0' encoding='utf-8'?>
128+
<resources>
129+
<!-- Override for API 35+ to fix white status bar with white icons issue -->
130+
<style name="SalesforceSDK_SplashScreen" parent="Theme.SplashScreen.IconBackground">
131+
<item name="postSplashScreenTheme">@style/Theme.AppCompat.NoActionBar</item>
132+
<!-- Use dark icons on light status bar background -->
133+
<item name="android:windowLightStatusBar">true</item>
134+
</style>
135+
</resources>`
136+
137+
// Ensure the directory exists
138+
utils.mkDirIfNeeded(dirPath);
139+
140+
// Write the file
141+
fs.writeFileSync(filePath, fileContents, 'utf8');
142+
}
143+
116144
//
117145
// Print details
118146
//

0 commit comments

Comments
 (0)