Skip to content

Commit 4205cdc

Browse files
committed
1.3.3
- add `app:isResponsiveIconColor` attribute for setting, in xml, whether the icon signifier will change its color when gaining or losing focus in. - set icon signifier and end icon with drawable (PR #23).
1 parent 38b0f36 commit 4205cdc

File tree

8 files changed

+63
-38
lines changed

8 files changed

+63
-38
lines changed

README.md

+16-8
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ A new Material Design text field that comes in a box, based on Google Material D
1919
2020
## ***UPDATE NOTICE***
2121

22-
#### 1.3.2 Release
23-
- fix issues #9 #19 #21
22+
#### 1.3.3 Release
23+
- add `app:isResponsiveIconColor` attribute for setting, in xml, whether the icon signifier will change its color when gaining or losing focus in.
24+
25+
- set icon signifier and end icon with drawable (PR #23).
2426

2527
#### 1.3.0 Release
2628
- the "EditText" part is now **seperated** from the TextFieldBoxes. TextFieldBoxes is now a **container** (just like a `TextInputLayout`) that should and should only contain **one** `ExtendedEditText` that inherents the `TextInputEditText`.
@@ -51,7 +53,7 @@ allprojects {
5153
```
5254
```groovy
5355
dependencies {
54-
   compile 'com.github.HITGIF:TextFieldBoxes:1.3.2'
56+
   compile 'com.github.HITGIF:TextFieldBoxes:1.3.3'
5557
}
5658
```
5759

@@ -68,7 +70,7 @@ dependencies {
6870
<dependency>
6971
<groupId>com.github.HITGIF</groupId>
7072
<artifactId>TextFieldBoxes</artifactId>
71-
   <version>1.3.2</version>
73+
   <version>1.3.3</version>
7274
</dependency>
7375
```
7476

@@ -77,7 +79,7 @@ dependencies {
7779
resolvers += "jitpack" at "https://jitpack.io"
7880
```
7981
```scala
80-
libraryDependencies += "com.github.HITGIF" % "TextFieldBoxes" % "1.3.2"
82+
libraryDependencies += "com.github.HITGIF" % "TextFieldBoxes" % "1.3.3"
8183
```
8284

8385

@@ -86,7 +88,7 @@ libraryDependencies += "com.github.HITGIF" % "TextFieldBoxes" % "1.3.2"
8688
:repositories [["jitpack" "https://jitpack.io"]]
8789
```
8890
```scala
89-
:dependencies [[com.github.hitgif/textfieldboxes "1.3.2"]]
91+
:dependencies [[com.github.hitgif/textfieldboxes "1.3.3"]]
9092
```
9193

9294
@@ -351,6 +353,14 @@ TextFieldBoxes use the color attributes within the current theme and will automa
351353
| `app:primaryColor` | The color for the underline and the floating label text | Current theme `colorPrimary` |
352354
| `app:panelBackgroundColor` | The color for the panel at the back | 6% Current theme `colorForeground` |
353355

356+
##### Icons
357+
358+
| Attribute | Description | Default |
359+
| --- | --- | --- |
360+
| `app:iconSignifier` | The resource ID of the icon before the TextFieldBoxes | `0` |
361+
| `app:endIcon` | The resource ID of the icon at the end of the field | `0` |
362+
| `app:isResponsiveIconColor` | whether the icon signifier will change its color when gaining or losing focus as the label and the bottomLine do. | `True` |
363+
354364
##### Characters counter
355365

356366
| Attribute | Description | Default |
@@ -363,8 +373,6 @@ TextFieldBoxes use the color attributes within the current theme and will automa
363373
| Attribute | Description | Default |
364374
| --- | --- | --- |
365375
| `app:enabled` | Whether the text field is enabled | `True` |
366-
| `app:iconSignifier` | The resource ID of the icon before the TextFieldBoxes | `0` |
367-
| `app:endIcon` | The resource ID of the icon at the end of the field | `0` |
368376
| `app:hasClearButton` | Whether to show the clear button at the end of the EditText | `False` |
369377
| `app:hasFocus` | Whether the EditText is having the focus | `False` |
370378

README_CN.md

+18-10
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
2020
## ***更新注意***
2121

22-
#### 1.3.2 Release
23-
- 修复 issues #9 #19 #21
22+
#### 1.3.3 Release
23+
- 增加 `app:isResponsiveIconColor` 属性以在 xml 中设置首图标是否会在获得或失去焦点时改变颜色。
24+
25+
- 可使用 Drawable 设置首/末图标 (PR #23)。
2426

2527
#### 1.3.0 Release
2628
- "EditText" 部分现已与 TextFieldBoxes **分开**。 TextFieldBoxes 将作为一个**容器**(就像 `TextInputLayout`),应且只应包含**一个** `ExtendedEditText`(继承于 `TextInputEditText`)。
@@ -51,7 +53,7 @@ allprojects {
5153
```
5254
```groovy
5355
dependencies {
54-
   compile 'com.github.HITGIF:TextFieldBoxes:1.3.2'
56+
   compile 'com.github.HITGIF:TextFieldBoxes:1.3.3'
5557
}
5658
```
5759

@@ -68,7 +70,7 @@ dependencies {
6870
<dependency>
6971
<groupId>com.github.HITGIF</groupId>
7072
<artifactId>TextFieldBoxes</artifactId>
71-
   <version>1.3.2</version>
73+
   <version>1.3.3</version>
7274
</dependency>
7375
```
7476

@@ -77,7 +79,7 @@ dependencies {
7779
resolvers += "jitpack" at "https://jitpack.io"
7880
```
7981
```scala
80-
libraryDependencies += "com.github.HITGIF" % "TextFieldBoxes" % "1.3.2"
82+
libraryDependencies += "com.github.HITGIF" % "TextFieldBoxes" % "1.3.3"
8183
```
8284

8385

@@ -86,7 +88,7 @@ libraryDependencies += "com.github.HITGIF" % "TextFieldBoxes" % "1.3.2"
8688
:repositories [["jitpack" "https://jitpack.io"]]
8789
```
8890
```scala
89-
:dependencies [[com.github.hitgif/textfieldboxes "1.3.2"]]
91+
:dependencies [[com.github.hitgif/textfieldboxes "1.3.3"]]
9092
```
9193

9294
@@ -207,11 +209,11 @@ _**注意:** 设置最大或最小字符数将会使底部 View (包含了计数
207209

208210
![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/maxChar.gif)
209211

210-
#### 6. 图标
212+
#### 6. 首图标
211213

212214
在 xml 中加入 `app:iconSignifier` 或在 Java 代码中使用 `setIconSignifier(Int resourceID)` 以设置 TextFieldBoxes 前边的图标(如果你想要有)。
213215

214-
你可以在 Java 代码中使用 `setIsResponsiveIconColor(boolean isrResponsiveIconColor)` 以设置图标是否会和标签文本与底部的线一样在获得或失去焦点时改变颜色
216+
你可以在 Java 代码中使用 `setIsResponsiveIconColor(boolean isrResponsiveIconColor)` 以设置首图标是否会和标签文本与底部的线一样在获得或失去焦点时改变颜色
215217
_**注意:如果值为 `true`,图标颜色将始终为 `HighlightColor` (与底部的线一样),即在失去焦点时将会变灰。如果为 `false`,图标颜色将始终为 `primaryColor`**_
216218

217219
```xml
@@ -352,6 +354,14 @@ TextFieldBoxes 用目前主题中的颜色属性因此将自动改变颜色以
352354
| `app:primaryColor` | 底部的线和标签文字的颜色 | 目前主题 `colorPrimary` |
353355
| `app:panelBackgroundColor` | 文本框背板的颜色 | 6% 目前主题 `colorForeground` |
354356

357+
##### 图标
358+
359+
| 属性 | 描述 | 默认值 |
360+
| --- | --- | --- |
361+
| `app:iconSignifier` | TextFieldBoxes 前边的图标的资源 ID | `0` |
362+
| `app:endIcon` | 文本域末端的图标的资源 ID | `0` |
363+
| `app:isResponsiveIconColor` | 首图标是否会和标签文本与底部的线一样在获得或失去焦点时改变颜色 | `True` |
364+
355365
##### 字符统计
356366

357367
| 属性 | 描述 | 默认值 |
@@ -364,8 +374,6 @@ TextFieldBoxes 用目前主题中的颜色属性因此将自动改变颜色以
364374
| 属性 | 描述 | 默认值 |
365375
| --- | --- | --- |
366376
| `app:enabled` | 文本框是否启用 | `True` |
367-
| `app:iconSignifier` | TextFieldBoxes 前边的图标的资源 ID | `0` |
368-
| `app:endIcon` | 文本域末端的图标的资源 ID | `0` |
369377
| `app:hasClearButton` | 是否在文本域末端显示清除按钮 | `False` |
370378
| `app:hasFocus` | 文本框是否获得焦点 | `False` |
371379

sample/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ dependencies {
2525
exclude group: 'com.android.support', module: 'support-annotations'
2626
})
2727
compile 'com.android.support:appcompat-v7:26.0.1'
28+
compile 'com.android.support.constraint:constraint-layout:1.0.2'
2829
compile 'com.android.support:design:26.0.1'
29-
// compile 'com.github.HITGIF:TextFieldBoxes:1.0.1'
30+
// compile 'com.github.HITGIF:TextFieldBoxes:1.3.3'
3031
compile project(':textfieldboxes')
3132
testCompile 'junit:junit:4.12'
3233
}

sample/src/main/res/layout/activity_main.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,11 @@
101101
android:layout_height="wrap_content"
102102
android:layout_gravity="center_horizontal"
103103
android:layout_weight="2"
104+
app:endIcon="@drawable/ic_mic_black_24dp"
104105
app:hasFocus="true"
105106
app:helperText=" "
106-
app:endIcon="@drawable/ic_mic_black_24dp"
107107
app:iconSignifier="@drawable/ic_location_on_black_24dp"
108+
app:isResponsiveIconColor="true"
108109
app:labelText="Location (optional)">
109110

110111
<studio.carbonylgroup.textfieldboxes.ExtendedEditText

textfieldboxes/build.gradle

-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ android {
99
targetSdkVersion 26
1010

1111
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12-
1312
}
1413
buildTypes {
1514
release {
@@ -25,7 +24,6 @@ dependencies {
2524
exclude group: 'com.android.support', module: 'support-annotations'
2625
})
2726
compile 'com.android.support:appcompat-v7:26.0.1'
28-
compile 'com.android.support.constraint:constraint-layout:1.0.2'
2927
compile 'com.android.support:design:26.0.1'
3028
testCompile 'junit:junit:4.12'
3129
}

textfieldboxes/src/main/java/studio/carbonylgroup/textfieldboxes/TextFieldBoxes.java

+24-14
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ public class TextFieldBoxes extends FrameLayout {
9898
*/
9999
protected int endIconResourceId;
100100

101+
/**
102+
* whether the icon signifier will change its color when gaining or losing focus
103+
* as the label and the bottomLine do. True by default.
104+
*/
105+
protected boolean isResponsiveIconColor;
106+
101107
/**
102108
* whether to show the clear button at the end of the EditText. False by default.
103109
*/
@@ -128,7 +134,6 @@ public class TextFieldBoxes extends FrameLayout {
128134
protected int ANIMATION_DURATION = 100;
129135
protected boolean onError = false;
130136
protected boolean activated = false;
131-
protected boolean isResponsiveIconColor = true;
132137

133138
public TextFieldBoxes(Context context) {
134139

@@ -299,6 +304,7 @@ public void onClick(View view) {
299304
setEnabled(this.enabled);
300305
setIconSignifier(this.iconSignifierResourceId);
301306
setEndIcon(this.endIconResourceId);
307+
setIsResponsiveIconColor(this.isResponsiveIconColor);
302308
setHasClearButton(this.hasClearButton);
303309
setHasFocus(this.hasFocus);
304310
updateCounterText();
@@ -448,7 +454,10 @@ protected void handleAttributes(Context context, AttributeSet attrs) {
448454
getResourceId(R.styleable.TextFieldBoxes_iconSignifier, 0);
449455
this.endIconResourceId = styledAttrs.
450456
getResourceId(R.styleable.TextFieldBoxes_endIcon, 0);
451-
this.hasClearButton = styledAttrs.getBoolean(R.styleable.TextFieldBoxes_hasClearButton, false);
457+
this.isResponsiveIconColor = styledAttrs
458+
.getBoolean(R.styleable.TextFieldBoxes_isResponsiveIconColor, true);
459+
this.hasClearButton = styledAttrs
460+
.getBoolean(R.styleable.TextFieldBoxes_hasClearButton, false);
452461
this.hasFocus = styledAttrs.getBoolean(R.styleable.TextFieldBoxes_hasFocus, false);
453462

454463
styledAttrs.recycle();
@@ -809,6 +818,7 @@ public void setEndIcon(int resourceID) {
809818
}
810819

811820
public void setEndIcon(Drawable drawable) {
821+
812822
removeEndIcon();
813823
this.endIconImageButton.setImageDrawable(drawable);
814824
this.endIconImageButton.setVisibility(View.VISIBLE);
@@ -823,10 +833,6 @@ public void removeEndIcon() {
823833
this.endIconImageButton.setVisibility(View.GONE);
824834
}
825835

826-
public void setHasClearButton(boolean hasClearButton) {
827-
this.hasClearButton = hasClearButton;
828-
}
829-
830836
/**
831837
* set if the EditText is having focus
832838
*
@@ -852,16 +858,16 @@ public void setHasFocus(boolean hasFocus) {
852858
}
853859

854860
/**
855-
* set whether the icon will change its color when gaining or losing focus
861+
* set whether the icon signifier will change its color when gaining or losing focus
856862
* as the label and the bottomLine do.
857863
*
858-
* @param isrResponsiveIconColor if true, the icon's color will always be HighlightColor
864+
* @param isResponsiveIconColor if true, the icon's color will always be HighlightColor
859865
* (the same as the bottomLine)
860866
* if false, the icon will always be in primaryColor
861867
*/
862-
public void setIsResponsiveIconColor(boolean isrResponsiveIconColor) {
868+
public void setIsResponsiveIconColor(boolean isResponsiveIconColor) {
863869

864-
this.isResponsiveIconColor = isrResponsiveIconColor;
870+
this.isResponsiveIconColor = isResponsiveIconColor;
865871
if (this.isResponsiveIconColor) {
866872
if (this.hasFocus) {
867873
this.iconImageButton.setColorFilter(primaryColor);
@@ -876,6 +882,10 @@ public void setIsResponsiveIconColor(boolean isrResponsiveIconColor) {
876882
}
877883
}
878884

885+
public void setHasClearButton(boolean hasClearButton) {
886+
this.hasClearButton = hasClearButton;
887+
}
888+
879889
/* Text Getters */
880890
public String getLabelText() {
881891
return this.labelText;
@@ -961,6 +971,10 @@ public int getEndIconResourceId() {
961971
return this.endIconResourceId;
962972
}
963973

974+
public boolean getIsResponsiveIconColor() {
975+
return this.isResponsiveIconColor;
976+
}
977+
964978
public boolean getHasClearButton() {
965979
return this.hasClearButton;
966980
}
@@ -969,10 +983,6 @@ public boolean getHasFocus() {
969983
return this.hasFocus;
970984
}
971985

972-
public boolean getIsResponsiveIconColor() {
973-
return this.isResponsiveIconColor;
974-
}
975-
976986
/**
977987
* set EditText cursor color
978988
*/

textfieldboxes/src/main/res/layout/text_field_boxes_layout.xml

-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
android:layout_height="match_parent"
2929
android:background="@drawable/bg"
3030
android:clickable="true"
31-
android:clipChildren="true"
32-
android:clipToPadding="true"
3331
android:foreground="?attr/selectableItemBackground"
3432
android:layout_alignParentTop="true"
3533
android:layout_alignParentLeft="true"

textfieldboxes/src/main/res/values/attrs.xml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<attr name="enabled" format="boolean" />
2222
<attr name="iconSignifier" format="reference" />
2323
<attr name="endIcon" format="reference" />
24+
<attr name="isResponsiveIconColor" format="boolean" />
2425
<attr name="hasClearButton" format="boolean" />
2526
<attr name="hasFocus" format="boolean" />
2627

0 commit comments

Comments
 (0)