Keep Android phones locked to portrait - #6109
Open
j0ntz wants to merge 1 commit into
Open
Conversation
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.
There was a problem hiding this comment.
Claude Code Review
Claude Code Review is paused for this repository. To reconnect it, an admin of this repository's GitHub organization (or the account owner, for personal repositories) who can also manage your Claude organization's Code Review settings needs to re-link GitHub in Code Review settings. This is a one-time step.
Tip: disable this comment in your organization's Code Review settings.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.





Description
Asana task
Asana: https://app.asana.com/1/9976422036640/project/1215088146871429/task/1216901482732656
QA hit landscape mode on an Android phone (Xiaomi 13T Pro, Android 16). Landscape is not a
supported layout on phones: content overflows the screen and PIN-login gestures stop working. It is
only meant to work on tablets, which is what iOS already does via its
UISupportedInterfaceOrientations~ipadkeys.The phone/tablet split itself was already correct.
R.bool.portrait_onlyistrueby default andoverridden to
falseinvalues-sw600dpandvalues-xlarge, and the reported device is ~407dpwide, so it resolved to
trueas expected. What failed is the strength of the lock:MainActivityhad noandroid:screenOrientation, so the activity'sdeclared
ActivityInfosaid "unspecified" and the app was only portrait onceonCreatehad run.configChanges="...|orientation|screenSize|...", soit is not recreated on a configuration change and
onCreatedoes not run again. If the systemrotated the activity anyway, nothing ever put it back.
ifhad noelse, so the orientation was never explicitly relaxed.That meant the decision could not be safely re-evaluated later, and a device that changes
screen-size class at runtime (a foldable being unfolded, or a display-size change) kept whatever
it resolved to at launch.
This declares
android:screenOrientation="portrait"onMainActivityso portrait holds from thefirst frame, and moves the runtime decision into
applyOrientationLock(), called from bothonCreateandonConfigurationChanged. Tablets now explicitly relax toSCREEN_ORIENTATION_UNSPECIFIED, which overrides the manifest default, so tablet landscape ispreserved and the phone lock is re-applied whenever the configuration changes.
Also reorders two existing
## UnreleasedCHANGELOG entries. That section already hadfixedbefore
changedondevelop, which failsverify-repo.sh's CHANGELOG ordering check regardless ofwhere a new entry is placed. No entry text was altered.
CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
none
Requirements
If you have made any visual changes to the GUI. Make sure you have:
Verified on an Android 16 emulator built to the reported device's panel (1220x2712 @ 480dpi, so
sw407dp, the same resource bucket as the Xiaomi 13T Pro). Screenshots in the comment below.requestedOrientationsw407dpSCREEN_ORIENTATION_PORTRAITsw407dpsw800dpSCREEN_ORIENTATION_UNSPECIFIEDsw407dpSCREEN_ORIENTATION_PORTRAITThe last two rows exercise
onConfigurationChanged: the app re-evaluated across the tabletthreshold in both directions without being recreated, which is the foldable case the previous
one-shot
onCreatelock could not handle. Throughout the phone rows the system rotation preferencewas pinned to landscape (
user_rotation=1,accelerometer_rotation=0) and the app still heldROTATION_0.Not verified: the exact Xiaomi HyperOS force-rotate trigger. It does not reproduce on stock Android
(QA already confirmed a Pixel does not reproduce it), so this proves the intended contract on both
device classes rather than replaying the OEM-specific trigger. Not installed on the physical Android
device attached to this machine, to avoid replacing a real Edge install and its wallet data.
Note
Low Risk
Native Android orientation only; no auth, payments, or wallet logic. Tablet landscape path is explicitly preserved via resource qualifiers.
Overview
Android phones can no longer rotate into landscape (overflow and broken PIN gestures on devices like Xiaomi 13T Pro). Tablets still allow landscape, matching iOS iPad orientation behavior.
MainActivitynow declaresandroid:screenOrientation="portrait"in the manifest so portrait applies beforeonCreate, andapplyOrientationLock()sets portrait whenR.bool.portrait_onlyis true (phones) orSCREEN_ORIENTATION_UNSPECIFIEDon tablet buckets (values-sw600dp/values-xlarge). The lock runs fromonCreateandonConfigurationChangedso rotation or foldable/display-size changes re-apply without activity recreation (given existingconfigChangesfor orientation/screenSize).CHANGELOG Unreleased entries are reordered so
fixedfollowschangedfor the repo verify script; wording unchanged aside from the new Android portrait fix line.Reviewed by Cursor Bugbot for commit 76f93bb. Bugbot is set up for automated code reviews on this repo. Configure here.