109 Commits

Author SHA1 Message Date
Material Design Team
0b669dab7d [Slider] Adjust thumb-track gap only for the pressed thumb
The gap between the thumb and track is now calculated on the fly for each thumb, considering whether the thumb is currently pressed.

PiperOrigin-RevId: 839683792
2025-12-04 16:46:53 +00:00
Material Design Team
7fc1c4ff14 [Slider][A11y] Fix D-Pad focus trap on horizontal sliders.
On D-Pad controlled devices like Android TV, pressing up or down on a focused horizontal slider would change its value instead of moving focus to an adjacent UI element. This trapped users in the slider.

This CL fixes the focus trap by removing the key handlers for DPAD_UP and DPAD_DOWN, allowing the Android system to handle focus navigation as expected.

PiperOrigin-RevId: 837044072
2025-12-02 15:14:33 +00:00
leticiars
c4d19f6f7d [Slider] Fix ACTION_CANCEL motion touch event handling so that the slider resets its state if a cancel happens. Also don't let slider update incorrectly when a touch event may be overlapping with back gesture inset areas, as the back event takes precedence.
PiperOrigin-RevId: 828106972
2025-11-07 17:51:26 +00:00
leticiars
1bf522fbbf [Slider][a11y] Change thumb width when it's keyboard focused.
Refactored so that each thumb is an individual drawable, so that they can change width independently. Plus, with this change a custom thumb drawable no longer changes its width when pressed.

PiperOrigin-RevId: 822162251
2025-10-22 16:08:15 +00:00
Material Design Team
aa623f0fac [Slider][A11y] Fix slider D-Pad keys to modify value instead of focus
Previously, Up/Down arrow keys navigated focus instead of changing the slider value. This change updates keyboard handling so all D-Pad keys modify the slider value: Up/Down increment/decrement the value, and Left/Right increment/decrement based on layout direction.

PiperOrigin-RevId: 821593460
2025-10-20 14:53:21 +00:00
leticiars
ce092fa5dd [Slider] Only one value label should be shown at a time for the range slider (except for the mode where the labels are always visible).
PiperOrigin-RevId: 819785653
2025-10-20 14:51:18 +00:00
Material Design Team
3d8d23dadb [Slider][A11y] Use arrow keys for value adjustment and TAB for navigation
Refactors Slider/RangeSlider keyboard navigation for a more intuitive and accessible experience, removing the need to press ENTER to toggle between navigation and value adjustment modes.

With this change:

- Arrow keys (+/-/=/DPAD) always adjust the value of the focused thumb.
- TAB and Shift+TAB always navigate focus between thumbs.

This simplifies event handling by ensuring `activeThumbIdx` stays synchronized with `focusedThumbIdx` during keyboard input.

Also fixes regressions in `SliderTouchTest` by preventing `onFocusChanged` logic (now conditioned on `activeThumbIdx == -1`) from incorrectly overriding thumb selection during touch events.

PiperOrigin-RevId: 816168251
2025-10-07 19:55:02 +00:00
pubiqq
a17e208d45 [Internal] Restore binary compatibility (ViewOverlay)
Resolves https://github.com/material-components/material-components-android/issues/4821
Resolves https://github.com/material-components/material-components-android/pull/4822

  - 88fa6714b38456cd39e2104992034a99bab00fc7 by pubiqq <serj.ese@gmail.com>

PiperOrigin-RevId: 776589862
2025-06-27 16:31:41 +00:00
dsn5ft
e62e66d7bc [Slider] Add ability to specify purely visual tick count in continuous mode
PiperOrigin-RevId: 764271536
2025-05-28 22:49:09 +00:00
Material Design Team
ab52e6afc4 [Slider][A11y] Prevent duplicate accessibility announcements
PiperOrigin-RevId: 764175507
2025-05-28 13:32:21 +00:00
Material Design Team
5af24b321a Automated g4 rollback of changelist 762520075
PiperOrigin-RevId: 762603362
2025-05-27 18:46:28 +00:00
Material Design Team
917ce60aa5 [Slider][A11y] Prevent duplicate accessibility announcements
PiperOrigin-RevId: 762520075
2025-05-23 21:54:41 +00:00
pubiqq
9ae6b7f4b3 [Slider] Get default minTouchTargetSize from material attributes
Resolves https://github.com/material-components/material-components-android/pull/4546

  - ceb3c6e7ea0eb09e5020a928f9185f86a566c0dc by pubiqq <serj.ese@gmail.com>

PiperOrigin-RevId: 760682756
2025-05-21 17:54:26 +00:00
Ga\u00ebtan Muller
65e5f1aba1 [Internal] Remove the internal ViewOverlay compat layer
Resolves https://github.com/material-components/material-components-android/pull/4736

GIT_ORIGIN_REV_ID=9eced1439e9503f5cc88cc3f2834f55e5466448c
PiperOrigin-RevId: 756779136
2025-05-12 18:15:01 +00:00
pubiqq
23957e0d7f [Slider] Fix label bounds for vertical slider in RTL
Resolves https://github.com/material-components/material-components-android/pull/4760
Resolves https://github.com/material-components/material-components-android/issues/4759

GIT_ORIGIN_REV_ID=b7ca68735a77733f621c8be87b8e5e85a57ab325
PiperOrigin-RevId: 755915079
2025-05-07 19:32:14 +00:00
pfthomas
781d344142 [Slider] Centered Slider Expressive updates
- update the Centered Slider to show the track starting from the center

PiperOrigin-RevId: 750301810
2025-04-22 20:39:48 +00:00
pfthomas
efea65b0eb [Slider][a11y] Add state description to VirtualView node
PiperOrigin-RevId: 741685200
2025-03-31 14:48:57 +00:00
pfthomas
cd909c2b7d [Slider] Add centered configuration
- add attr `centered` to enable the new centered configuration, see https://m3.material.io/components/sliders/overview#227dd2d1-8be6-4646-b8e6-f05bbac583e5
- prevent drawing the ticks in the gap spaces around the thumb and under it for better visuals

PiperOrigin-RevId: 741161174
2025-03-27 15:42:51 +00:00
pubiqq
660423f5a2 [Slider] Add new tick visibility modes
Resolves https://github.com/material-components/material-components-android/pull/2897

GIT_ORIGIN_REV_ID=82e11301b0ecf48b7d8486e8b29954bd1c4aebe8
PiperOrigin-RevId: 720997942
2025-01-31 15:20:30 +00:00
manabu-nakamura
9302f54855 [Slider] Fixed behaviour when Slider is in a scrolling container
Resolves https://github.com/material-components/material-components-android/pull/4511

GIT_ORIGIN_REV_ID=58e771c48f0a4bf13f62a303a9495a73f414b73b
PiperOrigin-RevId: 720309810
2025-01-28 19:49:47 +00:00
pubiqq
54778a9ae4 [Slider] Improve track icon bounds calculation
Resolves https://github.com/material-components/material-components-android/pull/4535

GIT_ORIGIN_REV_ID=080a4db213a47dae1e65f6b4edb2235f183599bd
PiperOrigin-RevId: 716316682
2025-01-16 19:59:20 +00:00
manabu-nakamura
867fd010f8 [Slider] remove unnecessary code
Resolves https://github.com/material-components/material-components-android/pull/4537

GIT_ORIGIN_REV_ID=e508df4affbda49f20a64dba7502fb21d90f0a3a
PiperOrigin-RevId: 716261754
2025-01-16 19:58:37 +00:00
pubiqq
bc2fdeadaf [Internal] Prefer platform methods to compat ones
Resolves https://github.com/material-components/material-components-android/pull/4532

GIT_ORIGIN_REV_ID=180dec736f2521579e483317a4d537629d8f247b
PiperOrigin-RevId: 715494344
2025-01-15 18:06:07 +00:00
pubiqq
b31711cd9e [Slider] Slider, don't warn about track icons if you don't have any
Resolves https://github.com/material-components/material-components-android/pull/4531

GIT_ORIGIN_REV_ID=4d23fdc773e9ba6fd4d1842be4590bb4417ff32f
PiperOrigin-RevId: 713752392
2025-01-10 15:31:44 +00:00
pubiqq
d28488d774 [Slider] Fix label pivots
Resolves https://github.com/material-components/material-components-android/pull/4509

GIT_ORIGIN_REV_ID=a26da16d8389df1de090c737c50c6c1e12f77df8
PiperOrigin-RevId: 713697809
2025-01-10 15:25:12 +00:00
pubiqq
e6e9385059 [Slider] Fix thumb visibility for vertical slider on API 23
Resolves https://github.com/material-components/material-components-android/pull/4505

GIT_ORIGIN_REV_ID=ed5a3af3ec63ea820651897eac2caa85ece13288
PiperOrigin-RevId: 712937074
2025-01-08 18:04:33 +00:00
pubiqq
9ce14ae3fd [Slider] Refactor track icon tinting
Resolves https://github.com/material-components/material-components-android/pull/4521

GIT_ORIGIN_REV_ID=674feb5f080ee2ea79245b17314d852893ece7d7
PiperOrigin-RevId: 712886599
2025-01-07 14:36:28 +00:00
pubiqq
ddda777dda [Slider] Always update track bounds before drawing icons
Resolves https://github.com/material-components/material-components-android/pull/4488

GIT_ORIGIN_REV_ID=0437dc5fd010715429822287ec12a8f77bffbe92
PiperOrigin-RevId: 712658525
2025-01-07 14:24:56 +00:00
pfthomas
63e1ec9a54 [Slider] a11y fixes
- demos are scrollable
- fix issue where increment is reversed when Slider is vertical

PiperOrigin-RevId: 703087896
2024-12-10 17:56:45 +00:00
pfthomas
35a82030f5 [Slider] a11y fixes
Resolves https://github.com/material-components/material-components-android/issues/2176

PiperOrigin-RevId: 702789538
2024-12-04 23:59:28 +00:00
pfthomas
05fa0ce58f [Slider] Update corner behavior
- add corner "squishy" effect as the thumb approaches the edges of the track.

PiperOrigin-RevId: 700775657
2024-12-02 20:06:28 +00:00
pfthomas
e1c83edbcb [Slider] Fix vertical slider broken with always visible labels
Resolves https://github.com/material-components/material-components-android/issues/4391

PiperOrigin-RevId: 700333450
2024-12-02 19:43:42 +00:00
pfthomas
60c09d98a1 [Slider] Add extra track icons support
- added support for start and end track icons
- removed the hide/show track icon logic to let the user implement it for more flexibility
- added demo
- updated tests + doc

PiperOrigin-RevId: 696960630
2024-11-21 17:25:26 +00:00
pfthomas
5bcda8a8d7 [Slider] Add vertical support
- added "orientation" attr allowing for vertical support
- updated tests and doc
- added demo

PiperOrigin-RevId: 695856298
2024-11-21 17:15:02 +00:00
pfthomas
2e95296eac [Slider] Add support for track icons
- added trackIconActive, trackIconActiveSize and trackIconActiveColor attrs
- added trackIconInactive, trackIconInactiveSize and trackIconInactiveColor attrs
- added tests and demos
- updated documentation

PiperOrigin-RevId: 689804000
2024-10-25 18:51:04 +00:00
pfthomas
7f4413dc4f [Slider] Make track corner size customizable
- add setTrackCornerSize/getTrackCornerSize to customize the track corners
- simplify track drawing logic for legacy Slider
- add demos

PiperOrigin-RevId: 688146199
2024-10-22 20:10:53 +00:00
manabu-nakamura
9bf5eddd8a [Slider] Make sure label is removed with slider is hidden
Resolves https://github.com/material-components/material-components-android/issues/4319
Resolves https://github.com/material-components/material-components-android/pull/4320

GIT_ORIGIN_REV_ID=6b96f2d40b77900b3479e3af61d3fa6f7c3e7c9d
PiperOrigin-RevId: 684473315
2024-10-14 16:33:10 +00:00
pekingme
237f5ec946 [Slider] Updated to show tooltips when focus by a11y.
PiperOrigin-RevId: 683257820
2024-10-09 16:36:10 +00:00
rightnao
1f56cd1783 [Slider] Fixes an exception caused by DecimalFormat not taking into account locale
PiperOrigin-RevId: 681165249
2024-10-07 14:17:23 +00:00
Material Design Team
59a753af24 Automated g4 rollback of changelist 676427467
PiperOrigin-RevId: 680642368
2024-10-01 19:04:24 +00:00
pfthomas
cebb0572a8 [Slider][a11y] Limit values to 2 decimals in the content description
PiperOrigin-RevId: 676427467
2024-09-20 19:45:27 +00:00
pubiqq
23aca03255 [Internal] Remove pre-Lollipop checks
Resolves https://github.com/material-components/material-components-android/pull/4266

GIT_ORIGIN_REV_ID=1de7808e66dd6666c893217c76c7499afe2df6a3
PiperOrigin-RevId: 669688797
2024-09-03 13:31:29 +00:00
manabu-nakamura
967dcd5e07 [Slider] Fix slider label not moving
Resolves https://github.com/material-components/material-components-android/pull/4104

GIT_ORIGIN_REV_ID=676308a77b429610192b1df80becb656e6053811
PiperOrigin-RevId: 666511279
2024-08-23 18:07:42 +00:00
pekingme
968a7ee02a [Slider] Updates tick marks color to fix the contrast in medium / high contrast modes.
Resolves https://github.com/material-components/material-components-android/issues/4204

PiperOrigin-RevId: 652895433
2024-07-22 18:24:33 +00:00
pubiqq
d85b73f952 [Slider] Fix the handle width when touched in a scrolling container and when more than one handle is in the touch position.
Resolves https://github.com/material-components/material-components-android/pull/4151
Resolves https://github.com/material-components/material-components-android/issues/4149
Resolves https://github.com/material-components/material-components-android/issues/4150

GIT_ORIGIN_REV_ID=d78e6e24416135fa1a21dc6e298902ab6b893490
PiperOrigin-RevId: 635894036
2024-05-23 14:51:32 +00:00
pubiqq
510881a469 [Internal] Stop using deprecated androidx.core.view.* methods
Resolves https://github.com/material-components/material-components-android/pull/4117

GIT_ORIGIN_REV_ID=dd157e8360c2511810496693cec1616fce578655
PiperOrigin-RevId: 632284856
2024-05-13 17:37:38 +00:00
pfthomas
f3a93d09a9 [NTC][Slider] Make tick size defaults to the stop indicator size if set
PiperOrigin-RevId: 617609939
2024-03-20 22:36:53 +00:00
pubiqq
bb646b68af [Slider] Fix incorrect style of stop indicators near handles
Resolves https://github.com/material-components/material-components-android/pull/4097

GIT_ORIGIN_REV_ID=927159e78777a16472d96b2740295bdbce6361ab
PiperOrigin-RevId: 615993493
2024-03-15 17:31:46 +00:00
pubiqq
3bc6612536 [Slider] Use a uniform way to update labels
Resolves https://github.com/material-components/material-components-android/pull/4093

GIT_ORIGIN_REV_ID=7db4936713bd31a070d4bb1d9743d99222840184
PiperOrigin-RevId: 614741678
2024-03-15 17:28:06 +00:00
Park-SM
ac77b4cfb5 [RangeSlider] Resolve issues that crash when assigning a large value to valueTo
Resolves https://github.com/material-components/material-components-android/pull/3979

GIT_ORIGIN_REV_ID=d09a42095cda8342b1f2a0fdf3a9ab9899cace45
PiperOrigin-RevId: 613196003
2024-03-06 11:47:24 -08:00