skydoves / ColorPickerPreference

🎨 A library that lets you implement ColorPicker, ColorPickerDialog, ColorPickerPreference.
Apache License 2.0
477 stars 51 forks source link

Crashes when height is too small (landscape mode or split screen) #16

Closed tobiaswicker closed 2 years ago

tobiaswicker commented 5 years ago

Bug:

ColorPickerPreference crashes whenever there is not enough space in height (landscape mode or split screen).

Stacktrace from an Android 9 device:

    java.lang.IllegalArgumentException: width and height must be > 0
        at android.graphics.Bitmap.createBitmap(Bitmap.java:1033)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:1000)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:950)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:911)
        at com.skydoves.colorpickerview.sliders.AlphaSlideBar.onSizeChanged(AlphaSlideBar.java:74)
        at android.view.View.sizeChange(View.java:20875)
        at android.view.View.setFrame(View.java:20836)
        at android.view.View.layout(View.java:20696)
        at android.view.ViewGroup.layout(ViewGroup.java:6198)
        [...]

As far as I can tell, the bug sits in com.skydoves.colorpickerview.sliders.AlphaSlideBar.onSizeChanged(AlphaSlideBar.java:74) which is consistent across all devices.

Expected Behavior:

I expect ColorPickerPreference to work in landscape mode the same way it does in portrait mode. It should either show alpha and brightness sliders vertically next to the hue picker or display the whole dialog content in a ScrollView whenever height is too small.