-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lock screen rotation while in gameplay on android #10516
Lock screen rotation while in gameplay on android #10516
Conversation
I'm not sure we should be doing this. We already changed the activity to use |
For reference, this will fix #5331 for android. |
private void load(OsuGame game) | ||
{ | ||
localUserPlaying = game.LocalUserPlaying.GetBoundCopy(); | ||
localUserPlaying.BindValueChanged(userPlaying => updateLock(userPlaying)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to localUserPlaying.ValueChanged += updateLock;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method group would also work. I'd slightly prefer that to an event subscription actually but unsure if it matters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BindValueChanged
exists mostly to allow passing true
as the second argument to run it immediately.
The first line is literally ValueChanged += onChange;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I went with BindValueChanged
as I thought we might want to run callback immediately in this scenario but I'm not sure it is actually necessary anymore.
Would be nice to implement this for iOS too, even if it's a separate PR. |
As an android user, I'll have to delegate implementation of this for iDevices as I don't own any of these (and lack Xamarin.iOS knowledge as well) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me. @peppy could you test on your devices?
Works as expected |
Summary
This adds a
GameplayScreenRotationLocker
component which locks screen rotation on android devices while in gameplay.Unfortunately, android (same for Xamarin) doesn't expose a nice, non-hackish way to get the current activity from anywhere (which is required to lock the screen rotation) so I had to resort to storing the game activity inside a static field upon startup.
Testing
No automated testing for this altough from the testing I've done on 3 devices I own, this seems to work fine.