Change Android's MainActivity launchMode to singleTop (#4255)

* Add build config plugin to set .MainActivity launchMode

* Change android:launchMode to standard

* Revert "Change android:launchMode to standard"

This reverts commit fddbc4e1b512ff9a55009e227f1f44e99ddabaf3.

* adjust

---------

Co-authored-by: Hailey <me@haileyok.com>
zio/stable
Nick Manos 2024-05-29 05:56:36 -04:00 committed by GitHub
parent 33de856c32
commit 65ad16e394
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 2 deletions

View File

@ -307,11 +307,11 @@ jobs:
- name: ⬇️ Restore Cache - name: ⬇️ Restore Cache
id: get-base-commit id: get-base-commit
uses: actions/cache@v4 uses: actions/cache@v4
if: ${{ inputs.channel == 'testflight' }} if: ${{ inputs.channel != 'testflight' && inputs.channel != 'production' }}
with: with:
path: most-recent-testflight-commit.txt path: most-recent-testflight-commit.txt
key: most-recent-testflight-commit key: most-recent-testflight-commit
- name: ✏️ Write commit hash to cache - name: ✏️ Write commit hash to cache
if: ${{ inputs.channel == 'testflight' }} if: ${{ inputs.channel != 'testflight' && inputs.channel != 'production' }}
run: echo ${{ github.sha }} > most-recent-testflight-commit.txt run: echo ${{ github.sha }} > most-recent-testflight-commit.txt

View File

@ -204,6 +204,7 @@ module.exports = function (config) {
], ],
'./plugins/withAndroidManifestPlugin.js', './plugins/withAndroidManifestPlugin.js',
'./plugins/withAndroidManifestFCMIconPlugin.js', './plugins/withAndroidManifestFCMIconPlugin.js',
'./plugins/withAndroidManifestLaunchModePlugin.js',
'./plugins/withAndroidStylesWindowBackgroundPlugin.js', './plugins/withAndroidStylesWindowBackgroundPlugin.js',
'./plugins/withAndroidStylesAccentColorPlugin.js', './plugins/withAndroidStylesAccentColorPlugin.js',
'./plugins/withAndroidSplashScreenStatusBarTranslucentPlugin.js', './plugins/withAndroidSplashScreenStatusBarTranslucentPlugin.js',

View File

@ -0,0 +1,17 @@
const {withAndroidManifest} = require('expo/config-plugins')
module.exports = function withAndroidManifestLaunchModePlugin(appConfig) {
return withAndroidManifest(appConfig, function (decoratedAppConfig) {
try {
const mainApplication =
decoratedAppConfig.modResults.manifest.application[0]
const mainActivity = mainApplication.activity.find(
elem => elem.$['android:name'] === '.MainActivity',
)
mainActivity.$['android:launchMode'] = 'singleTop'
} catch (e) {
console.error(`withAndroidManifestLaunchModePlugin failed`, e)
}
return decoratedAppConfig
})
}