From 76f93bbca69864ec08b05d0be2606499b9c8f457 Mon Sep 17 00:00:00 2001 From: Jonathan Tzeng Date: Sun, 26 Jul 2026 00:34:25 -0700 Subject: [PATCH] Keep Android phones locked to portrait Landscape is only supported on tablets, but the portrait lock was applied once at runtime in onCreate with no manifest declaration behind it, so the activity was declared rotatable and nothing re-applied the lock afterwards. A phone that got rotated by the system stayed rotated. Declare portrait on MainActivity in the manifest so it holds from the first frame, and re-apply the lock on configuration changes. The tablet exception now relaxes the orientation explicitly, which also re-evaluates correctly on a foldable that changes screen-size class at runtime. --- CHANGELOG.md | 3 +- android/app/src/main/AndroidManifest.xml | 1 + .../java/co/edgesecure/app/MainActivity.kt | 33 +++++++++++++++++-- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce62c949d06..10d4cc43a25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,9 @@ ## Unreleased (develop) -- fixed: NYM max swaps from EVM wallets now report the correct limit error instead of an unsupported-route error (edge-exchange-plugins 2.52.1). - changed: Sign MoonPay buy/sell widget URLs and bind them to the customer's IP via the info server, for MoonPay's on-ramp IP-matching security upgrade. +- fixed: NYM max swaps from EVM wallets now report the correct limit error instead of an unsupported-route error (edge-exchange-plugins 2.52.1). +- fixed: Android phones can no longer be rotated into the unsupported landscape layout. Landscape remains available on tablets. ## 4.50.0 (2026-07-21) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 790c2bd7231..e3a34875a34 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -46,6 +46,7 @@ android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:exported="true" android:launchMode="singleTask" + android:screenOrientation="portrait" android:windowSoftInputMode="adjustResize" android:theme="@style/BootTheme"> diff --git a/android/app/src/main/java/co/edgesecure/app/MainActivity.kt b/android/app/src/main/java/co/edgesecure/app/MainActivity.kt index f7ea6a3ac21..ce6e173845f 100644 --- a/android/app/src/main/java/co/edgesecure/app/MainActivity.kt +++ b/android/app/src/main/java/co/edgesecure/app/MainActivity.kt @@ -1,6 +1,7 @@ package co.edgesecure.app import android.content.pm.ActivityInfo +import android.content.res.Configuration import android.os.Build import android.os.Bundle import com.facebook.react.ReactActivity @@ -41,9 +42,35 @@ class MainActivity : ReactActivity() { setRecentsScreenshotEnabled(false) } - // Lock the app to portrait mode: - if (resources.getBoolean(R.bool.portrait_only)) { - requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT + applyOrientationLock() + } + + // Edge addition + override fun onConfigurationChanged(newConfig: Configuration) { + super.onConfigurationChanged(newConfig) + + // We handle orientation and screenSize config changes ourselves, so `onCreate` does not run + // again when the device rotates or changes size. Re-apply the lock here so that a rotation we + // did not ask for is corrected, and so that a device which genuinely changes screen-size class + // (a foldable being unfolded, or the user changing the display-size setting) is re-evaluated. + applyOrientationLock() + } + + /** + * Restricts the app to portrait, except on tablets. Landscape is only supported on a large + * screen, so phones stay locked no matter how the device is turned. This mirrors what iOS does + * with its `UISupportedInterfaceOrientations~ipad` keys. + * + * `portrait_only` is `true` by default and overridden to `false` for tablet-sized screens, so + * the manifest declares portrait and this relaxes it only where landscape is actually supported. + */ + private fun applyOrientationLock() { + val orientation = + if (resources.getBoolean(R.bool.portrait_only)) ActivityInfo.SCREEN_ORIENTATION_PORTRAIT + else ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED + + if (requestedOrientation != orientation) { + requestedOrientation = orientation } }