(filename: string)
| 597 | } |
| 598 | |
| 599 | async function updateAndroidManifest(filename: string) { |
| 600 | const txt = readFile(filename); |
| 601 | if (!txt) { |
| 602 | return; |
| 603 | } |
| 604 | |
| 605 | if (txt.includes('|density') || txt.includes('density|')) { |
| 606 | return; // Probably already updated |
| 607 | } |
| 608 | // Since navigation was an optional change in Capacitor 7, attempting to add density and/or navigation |
| 609 | const replaced = txt |
| 610 | .replace( |
| 611 | 'android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation"', |
| 612 | 'android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation|density"', |
| 613 | ) |
| 614 | .replace( |
| 615 | 'android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"', |
| 616 | 'android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation|density"', |
| 617 | ); |
| 618 | |
| 619 | if (!replaced.includes('|density')) { |
| 620 | logger.error(`Unable to add 'density' to 'android:configChanges' in ${filename}. Try adding it manually`); |
| 621 | } else { |
| 622 | writeFileSync(filename, replaced, 'utf-8'); |
| 623 | } |
| 624 | } |
no test coverage detected