diff --git a/android b/android index 1d442585b..24a5122a9 160000 --- a/android +++ b/android @@ -1 +1 @@ -Subproject commit 1d442585b5202fcb4424d41fa2597cc23f0a9b65 +Subproject commit 24a5122a96e9bdaa72c889b081832794fcee9e38 diff --git a/scripts/prepareAndroid.sh b/scripts/prepareAndroid.sh index c7e890dbb..ad26059d0 100755 --- a/scripts/prepareAndroid.sh +++ b/scripts/prepareAndroid.sh @@ -80,6 +80,13 @@ npx capacitor-assets generate npx cap sync npm run clean +# Monkey patch version numbers to make everything work +cd android +sed "s/\.\.\/node_modules//" -i capacitor.settings.gradle +cd capacitor +sed "s/'com.android.tools.build:gradle:8.2.1'/'com.android.tools.build:gradle:8.10'/" -i build.gradle + + tput bel tput bel # Note: tput doesn't work in the runners and may not be the last command, otherwise, it'll fail. echo "All done! Don't forget to click 'gradle sync files' in Android Studio" diff --git a/src/Logic/Osm/OsmConnection.ts b/src/Logic/Osm/OsmConnection.ts index c0c5b47f8..c0f473636 100644 --- a/src/Logic/Osm/OsmConnection.ts +++ b/src/Logic/Osm/OsmConnection.ts @@ -286,8 +286,9 @@ export class OsmConnection { public async AttemptLogin() { this.updateCapabilities() if (this.loadingStatus.data !== "logged-in") { - // Stay 'logged-in' if we are already logged in; this simply means we are checking for messages this.loadingStatus.setData("loading") + }else{ + // Stay 'logged-in' if we are already logged in; this simply means we are checking for messages } if (this.fakeUser) { this.loadingStatus.setData("logged-in") @@ -628,15 +629,18 @@ export class OsmConnection { return this._oauth_config.url + "oauth2_access_token" } - private async loginAndroidPolyfill() { + /** + * Sets up a callback to the Android App, in order to receive the + * token when it arrives. + * Note that this promise might never resolve and should thus not be awaited + */ + private async androidPolyfillCaptureLogincode() { const key = this.getLoginCookieName() if (localStorage.getItem(key)) { // We are probably already logged in return } const tokenPromise = AndroidPolyfill.requestLoginCodes() - console.trace("Opening login page for android") - await AndroidPolyfill.openLoginPage() const token = await tokenPromise console.log("Got login token!", token) localStorage.setItem(key, token) @@ -666,7 +670,11 @@ export class OsmConnection { apiUrl: this._oauth_config.api_url ?? this._oauth_config.url, }) if (AndroidPolyfill.inAndroid.data) { - this.loginAndroidPolyfill() // NO AWAIT! + this.androidPolyfillCaptureLogincode().then(() => {}) // NO AWAIT! + if(autoLogin){ + console.trace("Opening login page for android") + AndroidPolyfill.openLoginPage() + } } }