Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 94c6cf3c authored by Jay Thomas Sullivan's avatar Jay Thomas Sullivan Committed by Yi-an Chen
Browse files

[XPD] Support DrawableStateLayout in SettingsPreferenceGroupAdapter

SettingsPreferenceGroupAdapter adds background images to Preferences:
to give the look of rounded corners. Currently the way this works is
by dynamically and conditionally adding one of several background
images to the preference (the condition being whether the preference is
top, middle, bottom, etc of a preference group), where the background
image presents rounded corners.

But this CL changes the approach: by leveraging StateListDrawable, we
can squash all of these images into a single background image, and what
the image will actually look like depends on a "state" that we also
apply to the preference.

The advantage of using a single image is that it makes it easier to
customize the background image: where before it was hardcoded to one of
several backgrounds, it's now a matter of changing the 'background'
attribute.

For 'background' to take effect, the root element of a layout must
implement the interface DrawableStateLayout (defined in this CL), which
represents a layout which accepts a state ("extraDrawableState"). Or,
use DrawableStateLinearLayout which already implements the interface.

Finally, if a preference doesn't impl DrawableStateLayout, then we'll
force a hardcoded background and padding on it. (Which is how we've
been handling this prior to this change.)

(Note: some of the code used here to SettingsPreferenceGroupAdapter
was originally copied from PermissionController's
SectionPreferenceGroupAdapter, which already had this solution.)

Test: manual
Relnote: N/A
Flag: com.android.settingslib.widget.theme.flags.is_expressive_design_enabled
Bug: 375480009
Change-Id: I059589aea414e7b7284a060badfc9e3ccf888ea6
parent 73e783d4
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment