aricneto / TwistyTimer

Twisty Timer is a material design twisty puzzle timer for Android. It uses the TNoodle library to generate scramble sequences for all current official speedsolving puzzles.
GNU General Public License v3.0
241 stars 53 forks source link

Don't keep the screen on when the timer is not running #56

Closed Avinash-Bhat closed 5 years ago

Avinash-Bhat commented 7 years ago

the line#8 in fragment_timer.xml causes the screen to keep powering down as the android:keepScreenOn flag is kept true throughout the fragment lifecycle.

The same can be done programatically using getWindow().addFlag(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) when the timer is started and clearing the flag later when the timer is stopped. This keeps the device from going to sleep only when the timer is running.

This behavior is consistent from other time keeping apps (e.g., the default alarm app on android)

Avinash-Bhat commented 7 years ago

@aricneto I've opened up a PR for this. Check and let me know.

aricneto commented 7 years ago

I will!

aricneto commented 7 years ago

This may not be the best solution since puzzles with long scramble sequences (like the 7x7) take some time to scramble, and if the user has the system sleep timer set too low the phone will likely turn off before he has finished scrambling. Ideally this should be a setting I think.