LibreShift / red-moon

Android screen filter app for night time phone use.
GNU General Public License v3.0
650 stars 81 forks source link

Time pickers are not displayed in landscape mode #143

Closed willemw12 closed 4 years ago

willemw12 commented 7 years ago

LineageOS 14.1. Android 7.1.2. Red Moon (F-Droid) 2.10.2.

Screen resolution: 720p.

When in landscape mode, the timer's time picker widgets are not visible. Only the dialog title ("Turn on at" and "Turn off at") are visible.

smichel17 commented 7 years ago

I can reproduce this on any size screen.

willemw12 commented 7 years ago

On a other device with a 1080p screen it does display the time picker widgets.

smichel17 commented 7 years ago

What device is it? I can reproduce it on an emulated Nexus 5 (1920x1080) and on my Galaxy S6 (2560x1440). I wonder if it has to do with aspect ratio rather than pixel count.

Right now we're just passing a time picker as the view for the dialog (subclassing DialogPreference and overriding onCreateDialogView). I think the "right" way to do it is providing a custom layout.

First I'll just try a layout with a timer picker; if that doesn't work I'll look at how etar does it, since they have a time picker that works on my device.

willemw12 commented 7 years ago

Both are 16:9 screens.

The 1080p screen: Nexus 7 2013 tablet, stock Android 6.0.1.

smichel17 commented 7 years ago

Found the cause. A normal dialog has limits on how big it'll get, but a time picker isn't happy when it's stuffed into too small of a space. There is a TimePickerDialog specifically for this, but not an easy way to use that with a DialogPreference.

So, instead, we should subclass Preference, copy over much of the DialogPreference code, replace their normal dialog with a TimePickerDialog.

willemw12 commented 7 years ago

Other examples/suggestions:

AntennaPod uses a time picker (Settings --> Update Interval or Time of Day --> Set Time of Day). Is has a small issue with the dialog layout when rotating to or from landscape mode (it does not adjusts its horizontal/vertical layout orientation).

There is also another (older) time picker, which is smaller, where you scroll the dials up and down.

smichel17 commented 7 years ago

I will need to make some changes to this dialog as part of #106, so I will tackle this, then.

smichel17 commented 4 years ago

This was fixed in ce79e22.

There is currently a limitation where the dialog disappears on screen rotation. We can fix that by replacing the TimePickerDialog we currently use with a TimePickerDialogFragment (we need to write this) that extends PreferenceDialogFragmentCompat. I would prefer to pull this out into a separate library (even if it's still inside the Red Moon code base).

In any case, this is a low priority limitation/bug for me to fix. I'm going to close this issue since the original one is fixed, and if it annoys anyone enough they can open a new issue (which I will mark as Patches welcome :wink: ).

smichel17 commented 4 years ago

Well, looks like the rotation bit will actually happen sooner than later, see #269 :P