13 Commits

Author SHA1 Message Date
markwei
237682de5b Create base Chip style.
PiperOrigin-RevId: 173970927
2017-11-14 14:20:58 -05:00
markwei
0949693095 Call Chip.requestlayout() when ChipDrawable's size changes.
PiperOrigin-RevId: 173751794
2017-11-14 14:19:47 -05:00
markwei
239f38d507 Make base Chip style Widget.MaterialComponents.Chip
PiperOrigin-RevId: 173561748
2017-11-14 14:09:15 -05:00
markwei
40c629dd95 Implement Chip ripples.
Because ChipDrawable is one drawable, the ripple is drawn over the text and icons.
It's possible to refactor this in the future so the ChipDrawable owns RippleDrawable, so that it can manage the drawing order.

Extract ripple subsystem to its own package.
Fix an issue with stateful ripple colors. Now all ripples are optimized for the pressed state, ignoring all other states.

Implement compat ripples for pre-21 Chips.

PiperOrigin-RevId: 173366665
2017-11-14 14:06:30 -05:00
markwei
382a9d305b Add closeIconTint attribute to Chip.
Previously, we can bake a tint colorstatelist directly into the closeIcon drawable, but that has issues pre-23.
Previous demos also set a vector drawablestatelist as closeIcon, which has issues pre-21.

PiperOrigin-RevId: 173364754
2017-11-14 14:05:57 -05:00
markwei
3255b78c13 Create Chip getters and setters that match ChipDrawable.
Rename android:minHeight attribute to chipMinHeight.
These two attributes mean different things (and can now both be used at the same time).

PiperOrigin-RevId: 173363570
2017-11-14 14:05:33 -05:00
markwei
e420c37a0e Create ChipDrawable from XML resource.
Add demo of using ChipDrawable in EditText.
Set the initial state of the chip and close icon to state_enabled. This is not done automatically if using ChipDrawable in a span.

PiperOrigin-RevId: 173362627
2017-11-14 14:02:28 -05:00
markwei
fe345e5611 Implement custom Chip keyboard focus support.
Left/right can move focus to the chip and close icon, after which focus jumps outside the chip.
Up/down/tab moves the focus outside the chip.

Whenever focus is newly gained, always focus the chip first. This is true even if focus is coming from the right.

We have to handle the keyboard focus explicitly, instead of relying on the ExploreByTouchHelper.
The reason is that one of our logical sub-views is the special identifier HOST_ID, which corresponds to the entire chip.
ExploreByTouchHelper seems to only work when all the sub-views are virtual views instead.

PiperOrigin-RevId: 173362171
2017-11-14 14:01:54 -05:00
markwei
927cc4edc8 Implement Chip touch and mouse support.
Distinguishes clicks on the chip vs the close icon.
Support pressed and hover states on chip and the close icon separately.

PiperOrigin-RevId: 173361065
2017-11-14 14:01:16 -05:00
markwei
8fcb7613ff Split Chip into two logical sub-views with an accessability delegate.
The main chip and close icon are virtual views denoted by HOST_ID and CLOSE_ICON_VIRTUAL_ID respectively.
They are each a node in the virtual view hierarchy, which a user can navigate through with TalkBack.

The spoken prompts for focusing the virtual views are:
Chip, checkable: "[Unchecked/checked] Chip. $chipText. Double tap to toggle."
Chip, uncheckable: "Chip. $chipText. Double tap to activate."
Close icon: "Close icon. Double tap to activate."

The spoke prompts for actions are:
Chip, checkable: "[Checked/not checked]"
Chip, uncheckable: ""
Close icon: ""

PiperOrigin-RevId: 173360466
2017-11-14 14:00:01 -05:00
markwei
365a895877 Chip now respects android:checkable.
PiperOrigin-RevId: 172684267
2017-11-14 13:55:46 -05:00
markwei
0ccc34dfa2 Implement Drawable.getOutline(). Enables shadows on elevated Chips.
Fix some misc API 16 crashes.

PiperOrigin-RevId: 172682894
2017-11-14 13:55:22 -05:00
markwei
86de4992d9 Chips file structure.
PiperOrigin-RevId: 172158943
2017-11-14 13:41:54 -05:00