gauthams
1db449c897
Refactor dpToPx method into ViewUtils
...
PiperOrigin-RevId: 235243747
2019-02-24 14:38:37 -05:00
connieshi
b641bf706f
Avoid infinite loop in Chip#SetLayoutDirection.
...
PiperOrigin-RevId: 234604880
2019-02-24 14:22:05 -05:00
Material Design Team
a0ab1c29a3
Update Chip padding on RTL properties change
...
Prior to this change, when setLayoutDirection is called on a parent/ancestor View of a Chip, the updated layout direction could be propagated to the Chip without updating its text padding. This change forces a padding update whenever layout direction changes.
PiperOrigin-RevId: 230933347
2019-01-25 15:22:40 -05:00
connieshi
50d133ef03
Update chip to support dynamically changing texts in RTL layout.
...
PiperOrigin-RevId: 226174458
2018-12-21 11:24:38 -05:00
connieshi
3d23dbeac2
Fix logic to delegate text rendering to ChipDrawable instead of Chip.
...
Delegating text rendering to ChipDrawable breaks the api contract so this is for testing purposes only.
PiperOrigin-RevId: 226001080
2018-12-21 11:15:02 -05:00
cketcham
dc72aaeed4
Migrate Gradle build and sources to androidx
...
PiperOrigin-RevId: 225551505
2018-12-21 11:07:45 -05:00
connieshi
9b1f8478e5
Remove chipTouchTargetDelegate attribute.
...
PiperOrigin-RevId: 222298640
2018-12-06 11:16:48 -05:00
connieshi
9fd32f61c3
Log warning instead of UnsupportedOperationException when chip#setBackground and related methods are called.
...
PiperOrigin-RevId: 221665841
2018-11-16 12:18:15 -05:00
connieshi
c13949593f
Add getter/setter for custom chip attribute "ensureMinTouchTargetSize".
...
PiperOrigin-RevId: 221145735
2018-11-16 11:28:10 -05:00
connieshi
60d1dfac70
Update chipDrawable to be wrapped by InsetDrawable (if needed) to ensure it meets Android's recommended minimum touch target size.
...
Update demo catalog app.
PiperOrigin-RevId: 220370443
2018-11-16 10:57:34 -05:00
connieshi
f219705bb6
Add javadoc to chip getters and setters.
...
PiperOrigin-RevId: 219793479
2018-11-16 10:37:15 -05:00
connieshi
b888d9620b
Support shape theming in Chip component.
...
PiperOrigin-RevId: 219373344
2018-11-01 16:16:14 -07:00
marianomartin
9e36c150c0
Fix most javadocs errors
...
PiperOrigin-RevId: 216697274
2018-10-11 18:24:53 -04:00
connieshi
f3a95d09fe
Avoid constantly invalidating ChipDrawable when used in standalone mode.
...
Created TextAppearanceFontCallback (a fork of FontCallback) in order to pass parameter indicating whether font was resolved synchronously.
PiperOrigin-RevId: 216566240
2018-10-11 18:21:33 -04:00
connieshi
b6e96bf4d0
To avoid extra memory allocation, only run workaround for a framework bug that doesn't support themed color referenced in ColorStateList for API level < 23 when the Android version is pre-API 23.
...
Add test for setting a chip's text color to a CSL that references a themed color.
PiperOrigin-RevId: 212871700
2018-09-14 11:03:34 -04:00
connieshi
f64b2fb3c7
Automated g4 rollback of changelist 212803097
...
PiperOrigin-RevId: 212821631
2018-09-14 11:02:38 -04:00
connieshi
5b701669ac
Reuse text color from ChipDrawable#getTextAppearance instead of using additional resources to refetch it.
...
PiperOrigin-RevId: 212803097
2018-09-14 11:02:17 -04:00
dniz
02382c612a
Update Chip to use compat setLayoutDirection() method
...
PiperOrigin-RevId: 212680124
2018-09-14 10:59:52 -04:00
connieshi
d796149d25
Update chip to use themed color attributes.
...
PiperOrigin-RevId: 212104772
2018-09-14 10:51:49 -04:00
connieshi
bf33b9e4e7
Override onInitializeAccessibilityNodeInfo to explicitly tell the AccessibilityInfoNode whether a chip is checkable or clickable.
...
Avoid setting custom ExploreByTouchHelper as delegate in pre-N unless there's a close/trailing icon. This is necessary to workaround a Talkback bug.
PiperOrigin-RevId: 211490101
2018-09-07 11:49:26 -04:00
Material Design Team
b0a9ff6658
Add an override to setLayoutDirection from the parent text view of chips.
...
Setting layoutDirection on TextViews to the direction of the View locale is necessary to ensure that text on chips is rendered correctly in RTL mode. Previously, it would default to LTR mode and then not get set with proper paddings until you interact with a chip to invalidate the layout.
Before (RTL): https://surbhimadan.users.x20web.corp.google.com/www/textrtl_before.mp4
After (RTL): https://surbhimadan.users.x20web.corp.google.com/www/textrtl_after.mp4
Verified no changes to LTR.
PiperOrigin-RevId: 210560864
2018-08-28 16:43:46 -04:00
connieshi
250a906620
Fix bug that ignored ripple colors set programmatically if device is running Api 21+ and framework ripple is used.
...
Update chip demo in catalog to have ripple color corresponding to the current theme's primary color.
PiperOrigin-RevId: 210142873
2018-08-28 16:40:45 -04:00
Material Design Team
a5c1ea2709
Fixes Chip text padding & drawing.
...
The previous code was setting total padding (both start & end) as just end padding of the parent TextView and relying on the invalidation phase drawing the text in the correct place by shifting canvas with computed offset of start padding. This is risky as Chip may be just re-laid without actually invalidating it and render wrong paddings. Also RTL layout direction is incorrectly identified as LTR during layout sometimes, which makes the text being rendered with incorrect offset.
This change sets the paddings correctly removing the need of manual offsetting during onDraw() and relies purely on TextView for its text rendering.
PiperOrigin-RevId: 210042249
2018-08-28 16:40:05 -04:00
Material Design Team
b65d0e3e57
TextAppearance typeface bug fix & refactoring of getFontAsync().
...
This is in preparation of larger change of moving CollapsingTextHelper onto TextAppearance to fix related bugs & avoid code duplication.
1. Introduces a version of getFontAsync() in TextAppearance that doesn't require TextPaint as an argument.
2. Refactors the existing getFontAsync to wrap the new implementation.
3. Fixes a bug - TextAppearance would not apply the correct typeface from a style when fontFamily was not present in the style def.
PiperOrigin-RevId: 209147825
2018-08-17 17:20:54 -04:00
connieshi
0ced1bcf8c
Return early from Chip#setupTouchTargetDelegate If the client didn't specify touchTargetDelegate attribute in xml.
...
PiperOrigin-RevId: 208717708
2018-08-17 17:13:05 -04:00
connieshi
82d02a1112
Call ViewObserver#RemoveOnGlobalLayoutListener to avoid memory leak in Chip.
...
PiperOrigin-RevId: 208114143
2018-08-17 17:07:33 -04:00
connieshi
0c8dd4f121
Stop unicode wrapping user input strings in Chip#setText.
...
Remove overridden getText method, and rely on the TextView's implementation.
This also fixes accessibility issues when Talkback granularity is set to "word" or "characters".
PiperOrigin-RevId: 207296625
2018-08-17 16:59:28 -04:00
connieshi
ffa7b10cae
Add null check in Chip#setupTouchTargetDelegate
...
PiperOrigin-RevId: 206215855
2018-08-02 18:00:36 -07:00
connieshi
516d00d8a6
Add attributes (chipTouchTargetDelegate, chipMinTouchTargetSize) to support chip meeting minimum accessible touch target size.
...
PiperOrigin-RevId: 206197663
2018-08-02 17:58:34 -07:00
connieshi
3705f84c2e
Stop explicitly setting ImportantForAccessibility to be true because:
...
1) It's no longer necessary because Chip extends AppCompatCheckbox and TextView sets this if it's not explicitly set by the user
2) This prevents developers from indicating that a chip should not be exposed to accessibility.
PiperOrigin-RevId: 204189419
2018-07-12 16:18:20 -04:00
Material Design Team
8624748ed8
Use getText() in ChipTouchHelper for consistency
...
PiperOrigin-RevId: 204138629
2018-07-11 15:21:45 -04:00
cketcham
ad1d5f2614
Use ViewCompat.getPaddingEnd() instead of getPaddingEnd for backwards compatibility in Chip
...
PiperOrigin-RevId: 203812719
2018-07-09 17:27:17 -04:00
connieshi
aedfc1cf7c
Prevent users from setting the gravity on chips, chip text must be vertically center and start aligned.
...
PiperOrigin-RevId: 203767756
2018-07-09 15:00:54 -04:00
connieshi
6020fcdbf1
Fix API issue with icon visibility.
...
Deprecate *iconEnabled methods to is*iconVisible and setIs*iconVisible methods.
PiperOrigin-RevId: 202658616
2018-07-02 09:50:53 -04:00
connieshi
608d2b2fd7
Add support for android:maxWidth to ChipDrawable. Restrict the intrinsic width of the ChipDrawable by the max width. Fixes bug that ignored maxWidth set in Chip.
...
PiperOrigin-RevId: 202048514
2018-07-02 09:40:13 -04:00
connieshi
d584f91ccc
Resolve fonts asynchronously to avoid ANR.
...
Added flag to specify that fonts should be resolved synchronously for instrumentation tests.
PiperOrigin-RevId: 202033678
2018-07-02 09:37:14 -04:00
connieshi
24bd4a9531
Remove Chip method.
...
PiperOrigin-RevId: 201199382
2018-06-20 17:30:21 -04:00
connieshi
00a132b6a0
Remove Chip method.
...
PiperOrigin-RevId: 200735866
2018-06-20 17:27:41 -04:00
connieshi
3f00c13ebe
Fix api issues, defer to TextView to render the chip text and ChipDrawable to render everything else.
...
List of text related attributes/methods supported with this approach:
android:autoLink
android:hint
android:text
android:textAllCaps
android:textAppearance
android:textColor
android:textColorHint
android:textColorLink
android:textIsSelectable
android:textScaleX
android:textSize
android:textStyle
android:typeface
android:fontFamily
Not supported:
android:textColorHighlight
android:textColorLink
PiperOrigin-RevId: 200578044
2018-06-20 17:27:20 -04:00
connieshi
649a13fa2e
Replace calls to deprecated method Chip#getChipText() with its replacement Chip#getText().
...
Replace calls to deprecated Chip#setChipText(...) methods with their replacement Chip#setText...).
PiperOrigin-RevId: 199663849
2018-06-20 17:26:38 -04:00
connieshi
412ee4c1f1
Add support for tinting the chip icon.
...
PiperOrigin-RevId: 199526967
2018-06-20 17:24:18 -04:00
connieshi
434be9ff15
Restores chip text after it's being cleared by TextView's onRestoreInstanceState, this was causing an clearing the chip text on config change for pre-L devices.
...
PiperOrigin-RevId: 199482051
2018-06-20 17:23:38 -04:00
connieshi
57aeb2b7f8
Android Studio is looking for a "Chip" declare-stylable when trying to determine what attributes are applicable for the "Chip" component. Android Studio doesn't know that "ChipDrawable" is used internally and all attributes to "ChipDrawable" applies.
...
This is preventing completions of attribute names for Chip and the attribute panels shows up empty for Chip.
Rename R.styleable.ChipDrawable to R.styleable.Chip and update ChipDrawable to use it.
AS 3.2 canary > 14 (currently 16) is required to see the attributes in the attribute panel.
PiperOrigin-RevId: 198909123
2018-06-04 10:49:01 -04:00
connieshi
4a7bd84360
Add null check to Chip#setText and ChipDrawable#setText. Set null text to empty string, this is done internally by TextView.
...
Changed Chip#getText and ChipDrawable#getText to be @NotNull
PiperOrigin-RevId: 198868472
2018-06-04 10:48:35 -04:00
connieshi
f35acd8660
Rolling back again because of bad interactions with espresso ViewMatchers.
...
PiperOrigin-RevId: 198709590
2018-05-31 16:31:26 -04:00
connieshi
200fdcb6a2
Rolling forward changes to override Chip#getText() and Chip#setText(CharSequence, BufferType) now that a bug in ChipDrawable#getText has been fixed and internal tests are passing again.
...
PiperOrigin-RevId: 198616302
2018-05-30 17:46:46 -04:00
connieshi
bb8f8388e7
Prevent users from setting the background attribute because Chip manages its own background drawable.
...
Allow setBackground to be called by Chip itself internally to set the background to be chipDrawable or ripple.
PiperOrigin-RevId: 198572908
2018-05-30 17:43:30 -04:00
connieshi
77f4a89f73
Automated g4 rollback of changelist 198434516
...
PiperOrigin-RevId: 198449773
2018-05-30 17:41:19 -04:00
connieshi
5acdd69431
Prevent users from setting the background attribute because Chip manages its own background drawable.
...
PiperOrigin-RevId: 198434516
2018-05-30 17:40:14 -04:00
connieshi
9492832207
Rolling back changes to override Chip#setText and Chip#getText because it broke some tests.
...
PiperOrigin-RevId: 197975319
2018-05-30 17:34:46 -04:00