Skip to content
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

Add pseudo-fullscreen mode for OLED displays #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mihir-io
Copy link

@mihir-io mihir-io commented Dec 26, 2021

This PR addresses issue #8 and adds a popover pane that can essentially 'black out' the display, which for OLED-based iPhones means that the screen doesn't emit any light, and therefore saves battery life.

The way it works is to add a separate pane adjacent to the console window that has a single button to enable full-screen mode. Clicking that button will add a sub-view that opens the popover to black out the screen. By swiping down on the popover, you can close the popover and exit the pseudo-fullscreen mode while keeping the proxy server running. To enter full screen again, simply click the button from the side pane.

There are a couple caveats with this approach, that I'm planning to look into more for the future:

  • When the side pane that has the full screen button is open, as stuff is printed out in the console, the focus will shift over to the console. Once you enter full screen mode, this isn't an issue.
    • Changing logging from DEBUG to ERROR can reduce the rate that it changes focus over. And is probably very slightly better for performance/battery life anyways, if you don't need it to log every connection/request.
  • When charging, the battery icon in the top-right will still show. If the phone is horizontal, or if the phone isn't charging, it won't appear.
  • The home bar at the bottom still appears. As a workaround, you can enable "Guided Access" mode.
    • This hides the home bar but prevents you from exiting the app until you triple-click the power button again to disable it.

I think if I switched to the Scene library instead of the UI one, it might be possible to remove the battery charging icon in portrait mode. The home bar is probably there to stay outside of using guided access mode.

Photos:

The side pane with the "enter full screen" button, adjacent to the console
photo_2021-12-26_13-17-50

The fullscreen view in portrait mode while charging
photo_2021-12-26_13-18-02

Tested on iPhone 7 and 13 Pro.

Helps reduce battery drain and burn-in
fs_view = ui.View()
fs_view.name = "Full screen"
fs_view.background_color = 'black'
fs_view.present(style='popover', hide_title_bar=True)
Copy link
Author

@mihir-io mihir-io Dec 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also the option of adding orientations=['landscape'] as a parameter of fs_view.present() to force landscape mode, so that it always hides the battery indicator even while charging. Kinda hacky, but I've tested it and it does work.

@regulad
Copy link
Contributor

regulad commented Sep 16, 2024

I looked into playing a silent audio file for my use-case, but this seems a far more robust way to keep the app running. LGTM

@regulad
Copy link
Contributor

regulad commented Sep 16, 2024

I rebased these changes against the latest branch and added the landscape fix in my branch here: https://github.com/regulad/iOS-SOCKS-Server/tree/feature/fullscreen

I also applied Black since you had some single quoted strings.

@regulad
Copy link
Contributor

regulad commented Sep 16, 2024

Didn't want to clobber your PR or steal your thunder. Feel free force push your branch to mine!

@mihir-io
Copy link
Author

@regulad I won't have access to my usual machine with Git for a few days. If you want to, feel free to go ahead and force push the branch -- I'm not worried about credit or anything. Otherwise I'll try to get to it sometime next week.

@regulad
Copy link
Contributor

regulad commented Sep 20, 2024

@regulad I won't have access to my usual machine with Git for a few days. If you want to, feel free to go ahead and force push the branch -- I'm not worried about credit or anything. Otherwise I'll try to get to it sometime next week.

I don't have write access. I'll just open a new PR.

@regulad regulad mentioned this pull request Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants