Skip to content

Commit

Permalink
1.3.3
Browse files Browse the repository at this point in the history
- 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).
  • Loading branch information
HITGIF committed Sep 26, 2017
1 parent 38b0f36 commit 4205cdc
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 38 deletions.
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ A new Material Design text field that comes in a box, based on Google Material D
## ***UPDATE NOTICE***

#### 1.3.2 Release
- fix issues #9 #19 #21
#### 1.3.3 Release
- 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.3.0 Release
- 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`.
Expand Down Expand Up @@ -51,7 +53,7 @@ allprojects {
```
```groovy
dependencies {
   compile 'com.github.HITGIF:TextFieldBoxes:1.3.2'
   compile 'com.github.HITGIF:TextFieldBoxes:1.3.3'
}
```

Expand All @@ -68,7 +70,7 @@ dependencies {
<dependency>
<groupId>com.github.HITGIF</groupId>
<artifactId>TextFieldBoxes</artifactId>
   <version>1.3.2</version>
   <version>1.3.3</version>
</dependency>
```

Expand All @@ -77,7 +79,7 @@ dependencies {
resolvers += "jitpack" at "https://jitpack.io"
```
```scala
libraryDependencies += "com.github.HITGIF" % "TextFieldBoxes" % "1.3.2"
libraryDependencies += "com.github.HITGIF" % "TextFieldBoxes" % "1.3.3"
```


Expand All @@ -86,7 +88,7 @@ libraryDependencies += "com.github.HITGIF" % "TextFieldBoxes" % "1.3.2"
:repositories [["jitpack" "https://jitpack.io"]]
```
```scala
:dependencies [[com.github.hitgif/textfieldboxes "1.3.2"]]
:dependencies [[com.github.hitgif/textfieldboxes "1.3.3"]]
```

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

##### Icons

| Attribute | Description | Default |
| --- | --- | --- |
| `app:iconSignifier` | The resource ID of the icon before the TextFieldBoxes | `0` |
| `app:endIcon` | The resource ID of the icon at the end of the field | `0` |
| `app:isResponsiveIconColor` | whether the icon signifier will change its color when gaining or losing focus as the label and the bottomLine do. | `True` |

##### Characters counter

| Attribute | Description | Default |
Expand All @@ -363,8 +373,6 @@ TextFieldBoxes use the color attributes within the current theme and will automa
| Attribute | Description | Default |
| --- | --- | --- |
| `app:enabled` | Whether the text field is enabled | `True` |
| `app:iconSignifier` | The resource ID of the icon before the TextFieldBoxes | `0` |
| `app:endIcon` | The resource ID of the icon at the end of the field | `0` |
| `app:hasClearButton` | Whether to show the clear button at the end of the EditText | `False` |
| `app:hasFocus` | Whether the EditText is having the focus | `False` |
Expand Down
28 changes: 18 additions & 10 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
## ***更新注意***

#### 1.3.2 Release
- 修复 issues #9 #19 #21
#### 1.3.3 Release
- 增加 `app:isResponsiveIconColor` 属性以在 xml 中设置首图标是否会在获得或失去焦点时改变颜色。

- 可使用 Drawable 设置首/末图标 (PR #23)。

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

Expand All @@ -68,7 +70,7 @@ dependencies {
<dependency>
<groupId>com.github.HITGIF</groupId>
<artifactId>TextFieldBoxes</artifactId>
   <version>1.3.2</version>
   <version>1.3.3</version>
</dependency>
```

Expand All @@ -77,7 +79,7 @@ dependencies {
resolvers += "jitpack" at "https://jitpack.io"
```
```scala
libraryDependencies += "com.github.HITGIF" % "TextFieldBoxes" % "1.3.2"
libraryDependencies += "com.github.HITGIF" % "TextFieldBoxes" % "1.3.3"
```


Expand All @@ -86,7 +88,7 @@ libraryDependencies += "com.github.HITGIF" % "TextFieldBoxes" % "1.3.2"
:repositories [["jitpack" "https://jitpack.io"]]
```
```scala
:dependencies [[com.github.hitgif/textfieldboxes "1.3.2"]]
:dependencies [[com.github.hitgif/textfieldboxes "1.3.3"]]
```

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

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

#### 6. 图标
#### 6. 首图标

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

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

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

##### 图标

| 属性 | 描述 | 默认值 |
| --- | --- | --- |
| `app:iconSignifier` | TextFieldBoxes 前边的图标的资源 ID | `0` |
| `app:endIcon` | 文本域末端的图标的资源 ID | `0` |
| `app:isResponsiveIconColor` | 首图标是否会和标签文本与底部的线一样在获得或失去焦点时改变颜色 | `True` |

##### 字符统计

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

Expand Down
3 changes: 2 additions & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.0.1'
// compile 'com.github.HITGIF:TextFieldBoxes:1.0.1'
// compile 'com.github.HITGIF:TextFieldBoxes:1.3.3'
compile project(':textfieldboxes')
testCompile 'junit:junit:4.12'
}
3 changes: 2 additions & 1 deletion sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="2"
app:endIcon="@drawable/ic_mic_black_24dp"
app:hasFocus="true"
app:helperText=" "
app:endIcon="@drawable/ic_mic_black_24dp"
app:iconSignifier="@drawable/ic_location_on_black_24dp"
app:isResponsiveIconColor="true"
app:labelText="Location (optional)">

<studio.carbonylgroup.textfieldboxes.ExtendedEditText
Expand Down
2 changes: 0 additions & 2 deletions textfieldboxes/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ android {
targetSdkVersion 26

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
Expand All @@ -25,7 +24,6 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.0.1'
testCompile 'junit:junit:4.12'
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ public class TextFieldBoxes extends FrameLayout {
*/
protected int endIconResourceId;

/**
* whether the icon signifier will change its color when gaining or losing focus
* as the label and the bottomLine do. True by default.
*/
protected boolean isResponsiveIconColor;

/**
* whether to show the clear button at the end of the EditText. False by default.
*/
Expand Down Expand Up @@ -128,7 +134,6 @@ public class TextFieldBoxes extends FrameLayout {
protected int ANIMATION_DURATION = 100;
protected boolean onError = false;
protected boolean activated = false;
protected boolean isResponsiveIconColor = true;

public TextFieldBoxes(Context context) {

Expand Down Expand Up @@ -299,6 +304,7 @@ public void onClick(View view) {
setEnabled(this.enabled);
setIconSignifier(this.iconSignifierResourceId);
setEndIcon(this.endIconResourceId);
setIsResponsiveIconColor(this.isResponsiveIconColor);
setHasClearButton(this.hasClearButton);
setHasFocus(this.hasFocus);
updateCounterText();
Expand Down Expand Up @@ -448,7 +454,10 @@ protected void handleAttributes(Context context, AttributeSet attrs) {
getResourceId(R.styleable.TextFieldBoxes_iconSignifier, 0);
this.endIconResourceId = styledAttrs.
getResourceId(R.styleable.TextFieldBoxes_endIcon, 0);
this.hasClearButton = styledAttrs.getBoolean(R.styleable.TextFieldBoxes_hasClearButton, false);
this.isResponsiveIconColor = styledAttrs
.getBoolean(R.styleable.TextFieldBoxes_isResponsiveIconColor, true);
this.hasClearButton = styledAttrs
.getBoolean(R.styleable.TextFieldBoxes_hasClearButton, false);
this.hasFocus = styledAttrs.getBoolean(R.styleable.TextFieldBoxes_hasFocus, false);

styledAttrs.recycle();
Expand Down Expand Up @@ -809,6 +818,7 @@ public void setEndIcon(int resourceID) {
}

public void setEndIcon(Drawable drawable) {

removeEndIcon();
this.endIconImageButton.setImageDrawable(drawable);
this.endIconImageButton.setVisibility(View.VISIBLE);
Expand All @@ -823,10 +833,6 @@ public void removeEndIcon() {
this.endIconImageButton.setVisibility(View.GONE);
}

public void setHasClearButton(boolean hasClearButton) {
this.hasClearButton = hasClearButton;
}

/**
* set if the EditText is having focus
*
Expand All @@ -852,16 +858,16 @@ public void setHasFocus(boolean hasFocus) {
}

/**
* set whether the icon will change its color when gaining or losing focus
* set whether the icon signifier will change its color when gaining or losing focus
* as the label and the bottomLine do.
*
* @param isrResponsiveIconColor if true, the icon's color will always be HighlightColor
* @param isResponsiveIconColor if true, the icon's color will always be HighlightColor
* (the same as the bottomLine)
* if false, the icon will always be in primaryColor
*/
public void setIsResponsiveIconColor(boolean isrResponsiveIconColor) {
public void setIsResponsiveIconColor(boolean isResponsiveIconColor) {

this.isResponsiveIconColor = isrResponsiveIconColor;
this.isResponsiveIconColor = isResponsiveIconColor;
if (this.isResponsiveIconColor) {
if (this.hasFocus) {
this.iconImageButton.setColorFilter(primaryColor);
Expand All @@ -876,6 +882,10 @@ public void setIsResponsiveIconColor(boolean isrResponsiveIconColor) {
}
}

public void setHasClearButton(boolean hasClearButton) {
this.hasClearButton = hasClearButton;
}

/* Text Getters */
public String getLabelText() {
return this.labelText;
Expand Down Expand Up @@ -961,6 +971,10 @@ public int getEndIconResourceId() {
return this.endIconResourceId;
}

public boolean getIsResponsiveIconColor() {
return this.isResponsiveIconColor;
}

public boolean getHasClearButton() {
return this.hasClearButton;
}
Expand All @@ -969,10 +983,6 @@ public boolean getHasFocus() {
return this.hasFocus;
}

public boolean getIsResponsiveIconColor() {
return this.isResponsiveIconColor;
}

/**
* set EditText cursor color
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
android:layout_height="match_parent"
android:background="@drawable/bg"
android:clickable="true"
android:clipChildren="true"
android:clipToPadding="true"
android:foreground="?attr/selectableItemBackground"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
Expand Down
1 change: 1 addition & 0 deletions textfieldboxes/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<attr name="enabled" format="boolean" />
<attr name="iconSignifier" format="reference" />
<attr name="endIcon" format="reference" />
<attr name="isResponsiveIconColor" format="boolean" />
<attr name="hasClearButton" format="boolean" />
<attr name="hasFocus" format="boolean" />

Expand Down

0 comments on commit 4205cdc

Please sign in to comment.