40 Commits

Author SHA1 Message Date
ldjcmu
b0af4f0fb6
Revert "[Chip] setShowMotionSpec and setHideMotionSpec take a MotionSpec args" 2019-05-03 12:34:37 -04:00
ldjcmu
ad16e04d7d
Merge pull request #336 from satoshun/fix/chip_document
[Chip] setShowMotionSpec and setHideMotionSpec take a MotionSpec args
2019-05-03 12:32:33 -04:00
connieshi
7a4ecb0392 Update TextDrawableHelper's constructor to take a delegate.
Update ChipDrawable and BadgeDrwable to pass a delegate when they instantiate TextDrawbleHelper.

PiperOrigin-RevId: 245469285
2019-04-29 15:56:31 -07:00
SatoShun
83a876ce3c setShowMotionSpec and setHideMotionSpec take a MotionSpec args 2019-04-29 08:20:55 +00:00
connieshi
574157e153 Fix chip background color state bug:
PiperOrigin-RevId: 243047644
2019-04-19 15:35:58 -04:00
connieshi
b544530ac0 Update Chip's background / surface color state lists to support state_checked as well.
PiperOrigin-RevId: 240128475
2019-03-26 17:33:09 -04:00
connieshi
6ebcd6416a Elevation overlay support for chip.
PiperOrigin-RevId: 239029411
2019-03-22 16:30:10 -04:00
connieshi
5a9e0d378d Update ChipDrawable to use TextDrawableHelper to handle logic related to text rendering. ChipDrawable is still responsible for drawing text.
PiperOrigin-RevId: 237257476
2019-03-08 10:08:59 -05:00
connieshi
3bd6fd4688 Composite chip surface and background color to reduce ovedraw.
PiperOrigin-RevId: 235979248
2019-03-08 09:39:53 -05:00
cketcham
dc72aaeed4 Migrate Gradle build and sources to androidx
PiperOrigin-RevId: 225551505
2018-12-21 11:07:45 -05:00
connieshi
c48d882994 Add javadoc to ChipDrawable's getters and setters.
PiperOrigin-RevId: 220301488
2018-11-16 10:51:06 -05:00
connieshi
b888d9620b Support shape theming in Chip component.
PiperOrigin-RevId: 219373344
2018-11-01 16:16:14 -07:00
connieshi
12b56e226a Make ChipSurfaceColor attribute private, remove its public getter/setters.
PiperOrigin-RevId: 218680794
2018-10-28 21:39:27 -04: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
fee1efe5c0 Migrate ChipDrawable to inherit from MaterialShapeDrawable instead of Drawable.
PiperOrigin-RevId: 213991051
2018-09-28 16:15:10 -04:00
dniz
02382c612a Update Chip to use compat setLayoutDirection() method
PiperOrigin-RevId: 212680124
2018-09-14 10:59:52 -04:00
connieshi
bca3dad666 Add surface layer to ChipDrawable.
PiperOrigin-RevId: 210727850
2018-08-31 11:11:01 -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
connieshi
1f98c64b66 Remove redundant call to onSizeChange() in ChipDrawable#setTextAppearance(). Always evoke callback in TextAppearance#getFontAsync
Switch to using TextUtils.equals for more robust string comparison.

PiperOrigin-RevId: 209764943
2018-08-28 16:36:00 -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
7449427d36 Each time a chip icon is updated, apply the current chip icon tint.
Fixes bug that only updated chip icon tint if tint is updated after an icon has been set.

PiperOrigin-RevId: 206838032
2018-08-02 18:06:05 -07:00
connieshi
662aa06b77 Add null check before access attribute set.
PiperOrigin-RevId: 203830200
2018-07-11 15:17:15 -04:00
connieshi
84c6020605 Check if a user explicitly set any of the deprecated xml attributes but not the updated counterparts:
chipIconEnabled vs. chipIconVisible
    closeIconEnabled vs. closeIconVisible
    checkedIconEnabled vs. checkedIconVisible

PiperOrigin-RevId: 203804667
2018-07-09 15:01:40 -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
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
860b04767b Unwrap mutated drawable (chipIcon and closeIcon) before returning it in the getter.
PiperOrigin-RevId: 199636765
2018-06-20 17:25:37 -04:00
connieshi
412ee4c1f1 Add support for tinting the chip icon.
PiperOrigin-RevId: 199526967
2018-06-20 17:24:18 -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
de67e0d8ea Keep reference to user provided value in ChipDrawable#setText and return it in ChipDrawable#getText.
Currently when a user specifies an instance of java.lang.String to ChipDrawable#setText, ChipDrawable#getText incorrectly returns an instance of android.text.SpannableStringBuilder.

PiperOrigin-RevId: 198393803
2018-05-30 17:37:23 -04:00
connieshi
2072f7af4d Rename ChipDrawable#getChipText to ChipDrawable#ChipDrawable#getText
Rename ChipDrawable#setChipTextResource to ChipDrawable#setTextResource
Rename ChipDrawable#setChipText to ChipDrawable#setText.

PiperOrigin-RevId: 197948000
2018-05-30 17:33:30 -04:00
connieshi
a71326896a Use the android:text attribute instead of chipText attribute to specify text label for ChipDrawable.
This is one in a series of planned changes that aim to delegate rendering a Chip's text to TextView instead of ChipDrawable.

PiperOrigin-RevId: 197780081
2018-05-30 17:19:38 -04:00
connieshi
8cd8c2ad80 Prevent callers from setting ellipsize to MARQUEE because chip text should not scroll.
If caller sets ellipsize to MARQUEE an UnsupportedOperstaionException will be thrown at runtime.
Override ellipsize getters / setters and pass the value to ChipDrawable.

PiperOrigin-RevId: 196813582
2018-05-16 11:50:05 -04:00
connieshi
56b6432e37 Add support to ellipsize chip text.
When converting float to int value for intrinsic width, round instead of cast.
Round float values When determining whether text needs to be clipped to avoid overly aggressive clipping (and ellipsizing).

Rewrote layout for the chip example in demo app due to a known GridLayout.

PiperOrigin-RevId: 195957006
2018-05-09 13:39:23 -04:00
Material Design Team
b63a63e853 Allow custom text to be set for a Chip's closeIcon's contentDescription.
PiperOrigin-RevId: 195410650
2018-05-04 12:26:52 -04:00
connieshi
0eb5c1ae75 Fix typo in ChipDrawable documentation s/getIntrinsicWidth/getIntrinsicHeight
PiperOrigin-RevId: 193965067
2018-04-30 11:56:45 -04:00
dniz
9ca33544ac Update package name to com.google.android.material
PiperOrigin-RevId: 193236235
2018-04-30 11:24:23 -04:00