├── .codeclimate.yml ├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── dictionaries │ └── carbonyl.xml ├── gradle.xml ├── markdown-navigator.xml ├── markdown-navigator │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── .travis.yml ├── LICENSE ├── README.md ├── README_CN.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── images ├── alwaysHint.png ├── basic_disabled.png ├── clearButton.png ├── customColor1.png ├── customColor2.png ├── darkTheme.gif ├── dense.png ├── denseSpacing.png ├── edittext.gif ├── error.png ├── helper.png ├── hint.png ├── icon1.png ├── icon2.png ├── input.png ├── label.png ├── lightTheme.gif ├── maxChar.gif ├── maxMinChar.gif ├── maxlines.gif ├── mic.png ├── prefix.png ├── singleline.gif ├── suffix.png └── tfb1.gif ├── sample ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── studio │ │ └── carbonylgroup │ │ └── textfieldboxestest │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── studio │ │ │ └── carbonylgroup │ │ │ └── textfieldboxestest │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-hdpi │ │ ├── ic_location_on_black_24dp.png │ │ └── ic_vpn_key_black_24dp.png │ │ ├── drawable-mdpi │ │ ├── ic_location_on_black_24dp.png │ │ └── ic_vpn_key_black_24dp.png │ │ ├── drawable-xhdpi │ │ ├── ic_location_on_black_24dp.png │ │ └── ic_vpn_key_black_24dp.png │ │ ├── drawable-xxhdpi │ │ ├── ic_location_on_black_24dp.png │ │ └── ic_vpn_key_black_24dp.png │ │ ├── drawable-xxxhdpi │ │ ├── ic_location_on_black_24dp.png │ │ └── ic_vpn_key_black_24dp.png │ │ ├── drawable │ │ └── ic_visibility_black_24dp.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── studio │ └── carbonylgroup │ └── textfieldboxestest │ └── ExampleUnitTest.java ├── settings.gradle └── textfieldboxes ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src ├── androidTest └── java │ └── studio │ └── carbonylgroup │ └── textfieldboxes │ └── ExampleInstrumentedTest.java ├── main ├── AndroidManifest.xml ├── java │ └── studio │ │ └── carbonylgroup │ │ └── textfieldboxes │ │ ├── ClipToBoundsView.java │ │ ├── CompositeListener.java │ │ ├── ExtendedEditText.java │ │ ├── SimpleTextChangedWatcher.java │ │ ├── TextFieldBoxes.java │ │ └── TextInputAutoCompleteTextView.java └── res │ ├── drawable-hdpi │ ├── ic_clear_circle_black_24dp.png │ └── ic_mic_black_24dp.png │ ├── drawable-mdpi │ ├── ic_clear_circle_black_24dp.png │ └── ic_mic_black_24dp.png │ ├── drawable-xhdpi │ ├── ic_clear_circle_black_24dp.png │ └── ic_mic_black_24dp.png │ ├── drawable-xxhdpi │ ├── ic_clear_circle_black_24dp.png │ └── ic_mic_black_24dp.png │ ├── drawable-xxxhdpi │ ├── ic_clear_circle_black_24dp.png │ └── ic_mic_black_24dp.png │ ├── drawable │ ├── bg.xml │ ├── box.png │ ├── ic_clear_circle_black_24dp.png │ └── ic_mic_black_24dp.png │ ├── layout │ ├── text_field_boxes_layout.xml │ └── text_field_boxes_layout_rtl.xml │ └── values │ ├── attrs.xml │ ├── colors.xml │ ├── dimen.xml │ └── strings.xml └── test └── java └── studio └── carbonylgroup └── textfieldboxes └── ExampleUnitTest.java /.codeclimate.yml: -------------------------------------------------------------------------------- 1 | engines: 2 | pmd: 3 | enabled: true 4 | channel: "beta" 5 | ratings: 6 | paths: 7 | - "**.java" 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | .idea/* 11 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/dictionaries/carbonyl.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | carbonylgroup 5 | edittext 6 | textfieldboxes 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | -------------------------------------------------------------------------------- /.idea/markdown-navigator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 36 | 37 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /.idea/markdown-navigator/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: oraclejdk8 3 | android: 4 | components: 5 | - tools 6 | - build-tools-28.0.3 7 | - android-27 8 | - extra-google-m2repository 9 | - extra-android-m2repository 10 | before_install: 11 | - chmod +x gradlew 12 | - yes | sdkmanager "platforms;android-28" 13 | before_cache: 14 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 15 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ 16 | cache: 17 | directories: 18 | - $HOME/.gradle/caches/ 19 | - $HOME/.gradle/wrapper/ 20 | - $HOME/.android/build-cache 21 | script: 22 | - ./gradlew build 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TextFieldBoxes 2 | 3 | [![Build Status](https://travis-ci.org/HITGIF/TextFieldBoxes.svg?branch=master)](https://travis-ci.org/HITGIF/TextFieldBoxes) 4 | [![JitPack](https://jitpack.io/v/HITGIF/TextFieldBoxes.svg)](https://jitpack.io/#HITGIF/TextFieldBoxes) 5 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-TextFieldBoxes-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/6158) 6 | [![API](https://img.shields.io/badge/API-15%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=15) 7 | [![GitHub issues](https://img.shields.io/github/issues/HITGIF/TextFieldBoxes.svg)](https://github.com/HITGIF/TextFieldBoxes/issues) 8 | [![GitHub forks](https://img.shields.io/github/forks/HITGIF/TextFieldBoxes.svg)](https://github.com/HITGIF/TextFieldBoxes/network) 9 | [![GitHub stars](https://img.shields.io/github/stars/HITGIF/TextFieldBoxes.svg)](https://github.com/HITGIF/TextFieldBoxes/stargazers) 10 | [![GitHub license](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/LICENSE) 11 | 12 | ![Animation](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/tfb1.gif) 13 | 14 | A new Material Design text field that comes in a box, based on [Google Material Design guidelines](https://material.io/guidelines/components/text-fields.html#text-fields-text-field-boxes). 15 | 16 | [🇨🇳 中文看这里](https://github.com/HITGIF/TextFieldBoxes/blob/master/README_CN.md) 17 | 18 | Buy Me a Coffee at ko-fi.com 19 | 20 | ​ 21 | ## ***UPDATE NOTICE*** 22 | 23 | #### 1.4.5 Release 24 | - Fix `attr/counterTextColor` name conflict (#97 #99 #105). The `counterTextColor` property is now renamed to `mCounterTextColor`. 25 | 26 | #### 1.4.4 Release 27 | - Layout updated to support bigger clear icon and end icons (#72). 28 | 29 | #### 1.4.3 Release 30 | - Add [`setSimpleTextChangeWatcher()`](#watcher) as a better way to listen the input (#69). 31 | - Add [`app:manualValidateError`](#validate) attribute to manually control error state validation (#70). 32 | - Bug fix (#71). 33 | 34 | ​ 35 | ## Requirements 36 | - Android 4.0.3 IceCreamSandwich (API lv 15) or greater 37 | - Your favorite IDE 38 | 39 | ​ 40 | ## Installation 41 | In order to use it, you need to include it in your project. 42 | 43 | #### Gradle: 44 | ```groovy 45 | allprojects { 46 | repositories { 47 | ... 48 | maven { url 'https://jitpack.io' } 49 | } 50 | } 51 | ``` 52 | ```groovy 53 | dependencies { 54 |    compile 'com.github.HITGIF:TextFieldBoxes:1.4.5' 55 | } 56 | ``` 57 | 58 | #### Maven: 59 | ```xml 60 | 61 | 62 | jitpack.io 63 | https://jitpack.io 64 | 65 | 66 | ``` 67 | ```xml 68 | 69 | com.github.HITGIF 70 | TextFieldBoxes 71 |    1.4.5 72 | 73 | ``` 74 | 75 | #### SBT: 76 | ```scala 77 | resolvers += "jitpack" at "https://jitpack.io" 78 | ``` 79 | ```scala 80 | libraryDependencies += "com.github.HITGIF" % "TextFieldBoxes" % "1.4.5" 81 | ``` 82 | 83 | 84 | #### Leiningen: 85 | ```scala 86 | :repositories [["jitpack" "https://jitpack.io"]] 87 | ``` 88 | ```scala 89 | :dependencies [[com.github.hitgif/textfieldboxes "1.4.5"]] 90 | ``` 91 | 92 | ​ 93 | ## Usage 94 | 95 | #### Table of Contents 96 | 1. [Basic](#basic) 97 | 2. [Enable / Disable](#enable) 98 | 3. [Helper Text & Error Text](#helper) 99 | 4. [Prefix & Suffix](#prefix) 100 | 5. [Max & Min Characters](#max) 101 | 6. [Icon Signifier](#icon) 102 | 7. [End Icon](#end) 103 | 8. [Clear Button](#clear) 104 | 9. [Custom Colors](#color) 105 | 10. [Dense Spacing](#dense) 106 | 11. [Always Show Hint](#hint) 107 | 12. [Text Change Watcher](#watcher) 108 | 13. [Dark Theme](#dark) 109 | 14. [Manual Validate Error](#validate) 110 | 111 | #### 1. Basic 112 | 113 | Add `studio.carbonylgroup.textfieldboxes.TextFieldBoxes` that contains a `studio.carbonylgroup.textfieldboxes.ExtendedEditText` to your layout: 114 | 115 | ```xml 116 | ... 117 | 123 | 124 | 129 | 130 | 131 | ... 132 | ``` 133 | 134 | *NOTE that `app:labelText` is optional from release 1.3.6.* 135 | 136 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/label.png)![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/input.png) 137 | 138 | #### 2. Enable / Disable 139 | 140 | `app:enabled` in xml or `setEnabled(boolean enabled)` in Java. 141 | 142 | ```xml 143 | 147 | ``` 148 | 149 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/basic_disabled.png) 150 | 151 | #### 3. Helper Text & Error Text 152 | 153 | _**NOTE:** setting helper or error text to anything **not empty** will make the bottom view (which contains the helper label) visible and increase the height of the TextFieldBoxes. So if you want to always keep the bottom view visible (height increased), set the helper text to `" "` when there should be nothing._ 154 | 155 | helper text: `app:helperText` in xml or `setHelperText(String helperText)` in Java. 156 | 157 | 158 | ```xml 159 | 163 | ``` 164 | 165 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/helper.png) 166 | 167 | error text: `setError(String errorText, boolean giveFocus)` in Java. 168 | 169 | Param `giveFocus` determines whether the field will gain focus when set error on. If `true`, the field gains focus immediately. 170 | 171 | *NOTE: Error will be removed when the text changes (input or delete).* 172 | 173 | ```java 174 | setError("Error message"); 175 | ``` 176 | 177 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/error.png) 178 | 179 | #### 4. Prefix & Suffix 180 | 181 | _**! NOTE:** Prifix and Suffix attributes should be set to `ExtendedEditText`._ 182 | 183 | Use `app:prefix` in xml or `setPrefix(String prefix)` in Java to set the unselectable prefix text at the start of the field. 184 | 185 | Use `app:suffix` in xml or `setSuffix(String suffix)` in Java to set the unselectable suffix text at the end of the field. 186 | 187 | ```xml 188 | 192 | ``` 193 | 194 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/prefix.png) 195 | 196 | 197 | ```xml 198 | 202 | ``` 203 | 204 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/suffix.png) 205 | 206 | #### 5. Max & Min Characters 207 | 208 | _**NOTE:** setting max or min character will make the bottom view (which contains the counter label) visible and increase the height of the TextFieldBoxes._ 209 | 210 | Use `app:maxCharacters` in xml or `setMaxCharacters(int maxCharacters)` in java code to set the max characters count. Use `removeMaxCharacters()` in java code to remove the limit. 211 | 212 | Use `app:minCharacters` in xml or `setMinCharacters(int minCharacters)` in java code to set the min characters count. Use `removeMinCharacters()` in java code to remove the limit. 213 | 214 | The color of the bottom line will turn to `errorColor` (red by default) when exceeding max or min characters limit. `0`, as default, means no max or min characters limit. 215 | 216 | *NOTE: Space and line feed will NOT count.* 217 | 218 | ```xml 219 | 224 | ``` 225 | 226 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/maxMinChar.gif) 227 | 228 | ```xml 229 | 233 | ``` 234 | 235 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/maxChar.gif) 236 | 237 | #### 6. Icon Signifier 238 | 239 | Use `app:iconSignifier` in xml or `setIconSignifier(Int resourceID)` to set the icon that is shown in front of the TextFieldBoxes if you want there to be one. 240 | 241 | You can use `setIsResponsiveIconColor(boolean isrResponsiveIconColor)` in Java code to set whether the icon will change its color when gaining or losing focus as the label text and the bottomLine do. 242 | _**NOTE that if `true`, the icon's color will always be `HighlightColor` (the same as the bottomLine) that will turn gray when losing focus. If `false`, the icon will always be in `primaryColor`.**_ 243 | 244 | ```xml 245 | 249 | ``` 250 | 251 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/icon1.png)![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/icon2.png) 252 | 253 | #### 7. End Icon 254 | 255 | Use `app:endIcon` in xml or `setEndIcon(Int resourceID)` to set the icon of the ImageButton that is shown at the end of the field if you want there to be one. 256 | 257 | ```xml 258 | 262 | ``` 263 | 264 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/mic.png) 265 | 266 | To make it useful (trigger voice input, dropdown event), you would like to use `getEndIconImageButton()` in Java code to set, for example, what will happen when it's clicked (with `.setOnClickListener()`), or anything else you want. 267 | 268 | ```java 269 | final TextFieldBoxes textFieldBoxes = findViewById(R.id.text_field_boxes); 270 | textFieldBoxes.getEndIconImageButton().setOnClickListener(new View.OnClickListener() { 271 | @Override 272 | public void onClick(View view) { 273 | // What you want to do when it's clicked 274 | } 275 | }); 276 | ``` 277 | 278 | #### 8. Clear Button 279 | 280 | Use `app:hasClearButton` in xml or `setHasClearButton(boolean hasClearButton)` to set whether to show the clear button. 281 | 282 | If `true`, a clear button will be shown at the end when there are characters (**ANY** character) entered in the field. 283 | 284 | ```xml 285 | 289 | ``` 290 | 291 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/clearButton.png) 292 | 293 | #### 9. Custom Colors 294 | 295 | *Primary Color* will be used for the color of the underline, the floating label text and the icon signifier **when HAVING focus**. You can use `app:primaryColor` in xml or `setPrimaryColor(int colorRes)` in Java. Current theme `Primary Color` by default. 296 | 297 | *Secondary Color* will be used for the color of the underline, the floating label text and the icon signifier **when NOT HAVING focus**. You can use `app:secondaryColor` in xml or `setSecondaryColor(int colorRes)` in Java. Current theme `textColorTertiary` by default. 298 | 299 | *Error Color* will be used for the color that indicates error (e.g. exceeding max characters, `setError()`). You can use `app:errorColor` in xml or `setErrorColor(int colorRes)` in Java. `A400 red` by default. 300 | 301 | *Helper Text Color* will be used for the color of the helper text. You can use `app:helperTextColor` in xml or `setHelperTextColor(int colorRes)` in Java. `54% black` by default. 302 | 303 | *Panel Background Color* will be used for the color of panel at the back. You can use `app:panelBackgroundColor` in xml or `setPanelBackgroundColor(int colorRes)` in Java. `6% black` by default. *NOTE that the default color, as in the guideline, is the black (`#000000`) color with the transparency of 6%, so when you're customizing and want it to still be transparent you have to set a color with transparency.* 304 | 305 | ```xml 306 | 313 | ``` 314 | 315 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/customColor1.png) ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/customColor2.png) 316 | 317 | *Ripple Color* will be used for the ripple effect when the view is clicked. You can customize it in your `styles.xml` by adding the following: 318 | 319 | ```xml 320 | 323 | ``` 324 | 325 | then set this as the theme for your TextFieldBoxes: 326 | ```xml 327 | 331 | ``` 332 | 333 | #### 10. Dense Spacing 334 | 335 | You can make the layout compact by using a dense verticle spacing to improve user experience in some cases. 336 | 337 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/denseSpacing.png) 338 | 339 | Use `app:useDenseSpacing` in xml or `setUseDenseSpacing(boolean useDenseSpacing)` to set whether the field uses a dense spacing between its elements. 340 | 341 | ```xml 342 | 346 | ``` 347 | 348 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/dense.png) 349 | 350 | #### 11. Always Show Hint 351 | 352 | Sometimes you may want the label and the hint to show different messages, but need the hint to always be shown (instead being blocked by the label when losing focus). 353 | 354 | Use `app:alwaysShowHint` in xml or `setAlwaysShowHint(boolean alwaysShowHint)` to set whether the label is fixed at top when there's a hint in the EditText. 355 | 356 | ```xml 357 | 361 | ``` 362 | 363 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/alwaysHint.png) 364 | 365 | #### 12. Text Change Watcher 366 | 367 | It is strongly recommanded to use `setSimpleTextChangeWatcher()` to listen the event of changing text instead of `addTextChangedListener()`. 368 | 369 | This has the following advantages: 370 | 1. You don't need to implement `beforeTextChanged()` and `onTextChanged()` method when unnecessary. 371 | 2. Avoids potential unexpected behavior, by guaranteeing your code to run after the default processes (remove error, update counter text, etc.) are finished. 372 | 3. When the view is recycled, no manual remove call is needed. 373 | 374 | e.g. 375 | ```java 376 | final TextFieldBoxes textFieldBoxes = findViewById(R.id.text_field_boxes); 377 | textFieldBoxes.setSimpleTextChangeWatcher(new SimpleTextChangedWatcher() { 378 | @Override 379 | public void onTextChanged(String theNewText, boolean isError) { 380 | // What you want to do when text changes 381 | } 382 | }); 383 | ``` 384 | 385 | #### 13. Dark Theme 386 | 387 | TextFieldBoxes use the color attributes within the current theme and will automatically change its color to fit the dark theme without additional settings. 388 | 389 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/lightTheme.gif) 390 | 391 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/darkTheme.gif) 392 | 393 | #### 14. Manual Validate Error 394 | 395 | By default, the error state of the field is validated each time the text changes and also at time of construction. This means a field with a minimum length requirement will start in the Error state. 396 | 397 | Setting `app:manualValidateError` to `true` will make the field validate error only when `validate()` is called. 398 | 399 | ```xml 400 | 404 | ``` 405 | ```Java 406 | final TextFieldBoxes textFieldBoxes = findViewById(R.id.text_field_boxes); 407 | // The error state will only be updated when this is called 408 | textFieldBoxes.validate() 409 | ``` 410 | ​ 411 | ## All Attributes 412 | 413 | ### ExtendedEditText 414 | 415 | ##### Texts 416 | 417 | | Attribute | Description | 418 | | --- | --- | 419 | | `app:prefix` | Prefix Text | 420 | | `app:suffix` | Suffix Text | 421 | 422 | ##### Colors 423 | 424 | | Attribute | Description | Default | 425 | | --- | --- | --- | 426 | | `app:prefixTextColor` | Prefix text color | Current theme `textColorTertiary` | 427 | | `app:suffixTextColor` | Suffix text color | Current theme `textColorTertiary` | 428 | 429 | ### TextFieldBoxes 430 | 431 | ##### Texts 432 | 433 | | Attribute | Description | 434 | | --- | --- | 435 | | `app:labelText` | Floating label text at the top | 436 | | `app:helperText` | Helper text at the bottom | 437 | 438 | ##### Colors 439 | 440 | | Attribute | Description | Default | 441 | | --- | --- | --- | 442 | | `app:helperTextColor` | Helper text color | Current theme `textColorTertiary` | 443 | | `app:mCounterTextColor` | Counter text color | Current theme `textColorTertiary` | 444 | | `app:errorColor` | The color that is used to indicate error (e.g. exceeding max characters, `setError()`) | `A400 red` | 445 | | `app:primaryColor` | The color for the underline, the floating label text and the icon signifier **when HAVING FOCUS** | Current theme `colorPrimary` | 446 | | `app:secondaryColor` | The color for the underline, the floating label text and the icon signifier **when NOT HAVING FOCUS** | Current theme `textColorTertiary` | 447 | | `app:panelBackgroundColor` | The color for the panel at the back | 6% Current theme `colorForeground` | 448 | 449 | ##### Icons 450 | 451 | | Attribute | Description | Default | 452 | | --- | --- | --- | 453 | | `app:iconSignifier` | The resource ID of the icon before the TextFieldBoxes | `0` | 454 | | `app:endIcon` | The resource ID of the icon at the end of the field | `0` | 455 | | `app:isResponsiveIconColor` | whether the icon signifier will change its color when gaining or losing focus as the label and the bottomLine do | `True` | 456 | 457 | ##### Characters counter 458 | 459 | | Attribute | Description | Default | 460 | | --- | --- | --- | 461 | | `app:maxCharacters` | Max characters count limit. `0` means no limit | `0` | 462 | | `app:minCharacters` | Min characters count limit. `0` means no limit | `0` | 463 | 464 | ##### Others 465 | 466 | | Attribute | Description | Default | 467 | | --- | --- | --- | 468 | | `app:enabled` | Whether the text field is enabled | `True` | 469 | | `app:hasClearButton` | Whether to show the clear button at the end of the EditText | `False` | 470 | | `app:hasFocus` | Whether the EditText is having the focus | `False` | 471 | | `app:alwaysShowHint` | Whether the label is fixed at top when there's a hint in the EditText | `False` | 472 | | `app:useDenseSpacing` | Whether the field uses a dense spacing between its elements | `False` | 473 | | `app:manualValidateError` | Whether to validate error state only when `validate()` is called | `False` | 474 | ​ 475 | 476 | ## License 477 | 478 | Copyright 2020 Mark Wang 479 | 480 | Licensed under the Apache License, Version 2.0 (the "License"); 481 | you may not use this file except in compliance with the License. 482 | You may obtain a copy of the License at 483 | 484 | http://www.apache.org/licenses/LICENSE-2.0 485 | 486 | Unless required by applicable law or agreed to in writing, software 487 | distributed under the License is distributed on an "AS IS" BASIS, 488 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 489 | See the License for the specific language governing permissions and 490 | limitations under the License. 491 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | # TextFieldBoxes 2 | 3 | [![Build Status](https://travis-ci.org/HITGIF/TextFieldBoxes.svg?branch=master)](https://travis-ci.org/HITGIF/TextFieldBoxes) 4 | [![JitPack](https://jitpack.io/v/HITGIF/TextFieldBoxes.svg)](https://jitpack.io/#HITGIF/TextFieldBoxes) 5 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-TextFieldBoxes-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/6158) 6 | [![API](https://img.shields.io/badge/API-15%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=15) 7 | [![GitHub issues](https://img.shields.io/github/issues/HITGIF/TextFieldBoxes.svg)](https://github.com/HITGIF/TextFieldBoxes/issues) 8 | [![GitHub forks](https://img.shields.io/github/forks/HITGIF/TextFieldBoxes.svg)](https://github.com/HITGIF/TextFieldBoxes/network) 9 | [![GitHub stars](https://img.shields.io/github/stars/HITGIF/TextFieldBoxes.svg)](https://github.com/HITGIF/TextFieldBoxes/stargazers) 10 | [![GitHub license](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/LICENSE) 11 | 12 | ![Animation](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/tfb1.gif) 13 | 14 | 新的 Material Design 文本框,遵循 [Google Material Design 规范](https://material.io/guidelines/components/text-fields.html#text-fields-text-field-boxes)。 15 | 16 | Buy Me a Coffee at ko-fi.com 17 | 18 | ​ 19 | ## ***更新注意*** 20 | 21 | #### 1.4.5 Release 22 | - 修复 `attr/counterTextColor` 命名冲突 (#97 #99 #105)。 `counterTextColor` 属性已更名为 `mCounterTextColor`。 23 | 24 | #### 1.4.4 Release 25 | - 更新布局以支持更大的清除按钮与末图标 (#72)。 26 | 27 | #### 1.4.3 Release 28 | - 增加 [`setSimpleTextChangeWatcher()`](#watcher) 以便更好地监听文字输入 (#69)。 29 | - 增加 [`app:manualValidateError`](#validate) 属性以手动刷新错误状态 (#70)。 30 | - Bug 修复 (#71)。 31 | 32 | ​ 33 | ## 要求 34 | - Android 4.0.3 IceCreamSandwich (API lv 15) 或更高 35 | - 你最喜欢的 IDE 36 | 37 | ​ 38 | ## 安装 39 | 在你的项目中加入以下依赖: 40 | 41 | #### Gradle: 42 | ```groovy 43 | allprojects { 44 | repositories { 45 | ... 46 | maven { url 'https://jitpack.io' } 47 | } 48 | } 49 | ``` 50 | ```groovy 51 | dependencies { 52 |    compile 'com.github.HITGIF:TextFieldBoxes:1.4.5' 53 | } 54 | ``` 55 | 56 | #### Maven: 57 | ```xml 58 | 59 | 60 | jitpack.io 61 | https://jitpack.io 62 | 63 | 64 | ``` 65 | ```xml 66 | 67 | com.github.HITGIF 68 | TextFieldBoxes 69 |    1.4.5 70 | 71 | ``` 72 | 73 | #### SBT: 74 | ```scala 75 | resolvers += "jitpack" at "https://jitpack.io" 76 | ``` 77 | ```scala 78 | libraryDependencies += "com.github.HITGIF" % "TextFieldBoxes" % "1.4.5" 79 | ``` 80 | 81 | 82 | #### Leiningen: 83 | ```scala 84 | :repositories [["jitpack" "https://jitpack.io"]] 85 | ``` 86 | ```scala 87 | :dependencies [[com.github.hitgif/textfieldboxes "1.4.5"]] 88 | ``` 89 | 90 | ​ 91 | ## 使用 92 | 93 | #### 目录 94 | 1. [基础](#basic) 95 | 2. [启用 / 禁用](#enable) 96 | 3. [帮助和错误信息](#helper) 97 | 4. [前缀 & 后缀](#prefix) 98 | 5. [最大和最小字符数](#max) 99 | 6. [首图标](#icon) 100 | 7. [末图标](#end) 101 | 8. [清除按钮](#clear) 102 | 9. [自定义颜色](#color) 103 | 10. [紧凑布局](#dense) 104 | 11. [不隐藏提示文本](#hint) 105 | 12. [监听文字输入](#watcher) 106 | 13. [暗主题](#dark) 107 | 14. [手动刷新错误状态](#validate) 108 | 109 | #### 1. 基础 110 | 111 | 将包含`studio.carbonylgroup.textfieldboxes.ExtendedEditText` 的 `studio.carbonylgroup.textfieldboxes.TextFieldBoxes` 加入你的布局文件: 112 | 113 | ```xml 114 | ... 115 | 121 | 122 | 127 | 128 | 129 | ... 130 | ``` 131 | 132 | *注意: 自 release 1.3.6 起,`app:labelText` 是可选项。* 133 | 134 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/label.png)![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/input.png) 135 | 136 | 137 | #### 2. 启用 / 禁用 138 | 139 | 在 xml 中加入 `app:enabled` 或在 Java 代码中使用 `setEnabled(boolean enabled)`。 140 | 141 | ```xml 142 | 146 | ``` 147 | 148 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/basic_disabled.png) 149 | 150 | #### 3. 帮助和错误信息 151 | 152 | _**注意:** 将帮助或错误信息设置为任何**不为空**的字符将会使底部 View (包含了帮助标签) 可见并增加 TextFieldBoxes 的高度。所以如果你想让底部 View 始终可见 (保持增加后的高度),则可在帮助标签应为空时将其设为 `" "` 。_ 153 | 154 | ##### 帮助信息: 155 | 在 xml 中加入 `app:helperText` 或在 Java 代码中使用 `setHelperText(String helperText)`。 156 | 157 | ```xml 158 | 162 | ``` 163 | 164 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/helper.png) 165 | 166 | ##### 错误信息: 167 | 在 Java 代码中使用 `setError(String errorText, boolean giveFocus)`。 168 | 169 | `giveFocus` 参数决定被设置错误的文本域是否获得焦点。如果为 `true`,则该文本域立即获得焦点。 170 | 171 | *注意: 文本改动 (输入或删除) 时会自动清除错误信息。* 172 | 173 | ```java 174 | setError("Error message"); 175 | ``` 176 | 177 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/error.png) 178 | 179 | #### 4. 前缀 & 后缀 180 | 181 | _**!注意:** 前缀与后缀应在 `ExtendedEditText` 中设置。_ 182 | 183 | 在 xml 中加入 `app:prefix` 或在 Java 代码中使用 `setPrefix(String prefix)` 以设置文本域前端的前缀。 184 | 185 | 在 xml 中加入 `app:suffix` 或在 Java 代码中使用 `setSuffix(String suffix)` 以设置文本域末端的后缀。 186 | 187 | ```xml 188 | 192 | ``` 193 | 194 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/prefix.png) 195 | 196 | 197 | ```xml 198 | 202 | ``` 203 | 204 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/suffix.png) 205 | 206 | #### 5. 最大和最小字符数 207 | 208 | _**注意:** 设置最大或最小字符数将会使底部 View (包含了计数标签) 可见并增加 TextFieldBoxes 的高度。_ 209 | 210 | 在 xml 中加入 `app:maxCharacters` 或在 Java 代码中使用 `setMaxCharacters(int maxCharacters)` 以设置最大字符数。在 Java 代码中使用 `removeMaxCharacters()` 以移除限制。 211 | 212 | 在 xml 中加入 `app:minCharacters` 或在 Java 代码中使用 `setMinCharacters(int minCharacters)` 以设置最小字符数。在 Java 代码中使用 `removeMinCharacters()` 以移除限制。 213 | 214 | 当超出字符数限制时底部的线会变成 `errorColor`(默认为红色)。默认值是 `0`, 表示没有限制。 215 | 216 | *注意: 空格和换行不计入字符数。* 217 | 218 | ```xml 219 | 224 | ``` 225 | 226 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/maxMinChar.gif) 227 | 228 | ```xml 229 | 233 | ``` 234 | 235 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/maxChar.gif) 236 | 237 | #### 6. 首图标 238 | 239 | 在 xml 中加入 `app:iconSignifier` 或在 Java 代码中使用 `setIconSignifier(Int resourceID)` 以设置 TextFieldBoxes 前边的图标(如果你想要有)。 240 | 241 | 你可以在 Java 代码中使用 `setIsResponsiveIconColor(boolean isrResponsiveIconColor)` 以设置首图标是否会和标签文本与底部的线一样在获得或失去焦点时改变颜色。 242 | _**注意:如果值为 `true`,图标颜色将始终为 `HighlightColor` (与底部的线一样),即在失去焦点时将会变灰。如果为 `false`,图标颜色将始终为 `primaryColor`。**_ 243 | 244 | ```xml 245 | 249 | ``` 250 | 251 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/icon1.png)![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/icon2.png) 252 | 253 | #### 7. 末图标 254 | 255 | 在 xml 中使用 `app:endIcon` 或在 Java 代码中使用 `setEndIcon(Int resourceID)` 以设置文本域末端的 ImageButton 的图标(如果你想要有)。 256 | 257 | ```xml 258 | 262 | ``` 263 | 264 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/mic.png) 265 | 266 | 为了让它有点用(触发语音输入、下拉事件), 你需要在 Java 代码中使用 `getEndIconImageButton()` 以设置, 举个例子, 点击时的事件 (`.setOnClickListener()`), 或者其他的需求。 267 | 268 | ```java 269 | final TextFieldBoxes textFieldBoxes = findViewById(R.id.text_field_boxes); 270 | textFieldBoxes.getEndIconImageButton().setOnClickListener(new View.OnClickListener() { 271 | @Override 272 | public void onClick(View view) { 273 | // 点击时的事件 274 | } 275 | }); 276 | ``` 277 | 278 | #### 8. 清除按钮 279 | 280 | 在 xml 中使用 `app:hasClearButton` 或在 Java 代码中使用 `setHasClearButton(boolean hasClearButton)` 以设置是否显示清除按钮。 281 | 282 | 如果为 `true`, 每当文本域中有字符输入时(**任何**字符)末端将会显示清除按钮。 283 | 284 | ```xml 285 | 289 | ``` 290 | 291 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/clearButton.png) 292 | 293 | #### 9. 自定义颜色 294 | 295 | *Primary Color* 是底部的线、标签文字和首图标在**获得焦点**时的颜色。在 xml 中加入 `app:primaryColor` 或在 Java 代码中使用 `setPrimaryColor(int colorRes)` 以设置。默认值为目前主题的 `Primary Color`。 296 | 297 | *Secondary Color* 是底部的线、标签文字和首图标在**失去焦点**时的颜色。在 xml 中加入 `app:secondaryColor` 或在 Java 代码中使用 `setSecondaryColor(int colorRes)` 以设置。默认值为目前主题的 `textColorTertiary`。 298 | 299 | *Error Color* 是出现错误时显示的颜色 (e.g. 超出字符数限制, `setError()`)。在 xml 中加入 `app:errorColor` 或在 Java 代码中使用 `setErrorColor(int colorRes)` 以设置。默认值是 `A400 red`。 300 | 301 | *Helper Text Color* 是帮助文本的颜色。在 xml 中加入 `app:helperTextColor` 或在 Java 代码中使用 `setHelperTextColor(int colorRes)` 以设置。默认值是 `54% black`。 302 | 303 | *Panel Background Color* 是文本框背板的颜色。在 xml 中加入 `app:panelBackgroundColor` 或在 Java 代码中使用 `setPanelBackgroundColor(int colorRes)` 以设置。默认值是 `6% black`。*需要注意的是根据规范,默认的颜色是 6% 透明度的黑色 (`#000000`),所以如果你要自定义颜色并且仍需让其保持透明,则应同样设置一个带透明度的颜色。* 304 | 305 | ```xml 306 | 313 | ``` 314 | 315 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/customColor1.png) ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/customColor2.png) 316 | 317 | *Ripple Color* 是当 View 被点击时波纹效果的颜色。 在 `styles.xml` 中加入以下代码: 318 | 319 | ```xml 320 | 323 | ``` 324 | 325 | 然后将此设为你 TextFieldBoxes 的 Theme: 326 | 327 | ```xml 328 | 332 | ``` 333 | 334 | #### 10. 紧凑布局 335 | 336 | 你可以使用更小的元素纵向间距,让文本框的布局更加紧凑,以在某些情况下改善用户体验。 337 | 338 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/denseSpacing.png) 339 | 340 | 在 xml 中加入 `app:useDenseSpacing` 或在 Java 代码中使用 `setUseDenseSpacing(boolean useDenseSpacing)`,以设置是否使用更小的间距。 341 | 342 | ```xml 343 | 347 | ``` 348 | 349 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/dense.png) 350 | 351 | #### 11. 不隐藏提示文本 352 | 353 | 有些时候,你可能需要在顶部标签与提示 (Hint) 文本中显示不同的内容, 并且不希望提示文本在失去焦点时被标签盖住。 354 | 355 | 你可以在 xml 中加入 `app:alwaysShowHint` 或在 Java 代码中使用 `setAlwaysShowHint(boolean alwaysShowHint)`,以设置当 EditText 中有提示文本时,是否将标签始终固定在顶部。 356 | 357 | ```xml 358 | 362 | ``` 363 | 364 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/alwaysHint.png) 365 | 366 | #### 12. 监听文字输入 367 | 368 | 强烈建议使用 `setSimpleTextChangeWatcher()` 来监听文字输入,而不是 `addTextChangedListener()`。 369 | 370 | 这有以下好处: 371 | 1. 不需要时,可以不用实现 `beforeTextChanged()` and `onTextChanged()` 方法。 372 | 2. 保证你的代码在默认进程结束(去除错误状态,更新计数文本等)后执行,从而避免可能的无法预料的问题。 373 | 3. 不需要在视图回收后手动调用移除函数。 374 | 375 | 比如: 376 | ```java 377 | final TextFieldBoxes textFieldBoxes = findViewById(R.id.text_field_boxes); 378 | textFieldBoxes.setSimpleTextChangeWatcher(new SimpleTextChangedWatcher() { 379 | @Override 380 | public void onTextChanged(String theNewText, boolean isError) { 381 | // What you want to do when text changes 382 | } 383 | }); 384 | ``` 385 | 386 | #### 13. 暗主题 387 | 388 | TextFieldBoxes 用目前主题中的颜色属性因此将自动改变颜色以适应暗主题而不需其他设置。 389 | 390 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/lightTheme.gif) 391 | 392 | ![](https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/master/images/darkTheme.gif) 393 | 394 | 395 | #### 14. 手动刷新错误状态 396 | 397 | 默认情况下,文本框的错误状态将在初始化和文本变化时更新。这将导致在设置了最小字符限制时,文本框将在初始化时处于错误状态。 398 | 399 | 将 `app:manualValidateError` 设置为 `true`,将使错误状态只在调用 `validate()` 时刷新。 400 | 401 | ```xml 402 | 406 | ``` 407 | ```Java 408 | final TextFieldBoxes textFieldBoxes = findViewById(R.id.text_field_boxes); 409 | // 错误状态只在调用这个时刷新 410 | textFieldBoxes.validate() 411 | ``` 412 | ​ 413 | ## 全部属性 414 | 415 | ### ExtendedEditText 416 | 417 | ##### 文本 418 | 419 | | 属性 | 描述 | 420 | | --- | --- | 421 | | `app:prefix` | 前缀文本 | 422 | | `app:suffix` | 后缀文本 | 423 | 424 | ##### 颜色 425 | 426 | | 属性 | 描述 | 默认值 | 427 | | --- | --- | --- | 428 | | `app:prefixTextColor` | 前缀文本颜色 | 目前主题 `textColorTertiary` | 429 | | `app:suffixTextColor` | 后缀文本颜色 | 目前主题 `textColorTertiary` | 430 | 431 | ### TextFieldBoxes 432 | 433 | ##### 文本 434 | 435 | | 属性 | 描述 | 436 | | --- | --- | 437 | | `app:label` | 顶部的标签文本 | 438 | | `app:helperText` | 底部的帮助文本 | 439 | 440 | ##### 颜色 441 | 442 | | 属性 | 描述 | 默认值 | 443 | | --- | --- | --- | 444 | | `app:helperTextColor` | 帮助文本颜色 | 目前主题 `textColorTertiary` | 445 | | `app:mCounterTextColor` | 计数文本颜色 | 目前主题 `textColorTertiary` | 446 | | `app:errorColor` | 错误时的显示颜色 (e.g. 超出字符限制, `setError()`) | `A400 red` | 447 | | `app:primaryColor` | 底部的线、标签文字和首图标在**获得焦点时**的颜色 | 目前主题 `colorPrimary` | 448 | | `app:secondaryColor` | 底部的线、标签文字和首图标在**失去焦点时**的颜色 | 目前主题 `textColorTertiary` | 449 | | `app:panelBackgroundColor` | 文本框背板的颜色 | 6% 目前主题 `colorForeground` | 450 | 451 | ##### 图标 452 | 453 | | 属性 | 描述 | 默认值 | 454 | | --- | --- | --- | 455 | | `app:iconSignifier` | TextFieldBoxes 前边的图标的资源 ID | `0` | 456 | | `app:endIcon` | 文本域末端的图标的资源 ID | `0` | 457 | | `app:isResponsiveIconColor` | 首图标是否会和标签文本与底部的线一样在获得或失去焦点时改变颜色 | `True` | 458 | 459 | ##### 字符统计 460 | 461 | | 属性 | 描述 | 默认值 | 462 | | --- | --- | --- | 463 | | `app:maxCharacters` | 最大字符数。`0` 表示没有限制 | `0` | 464 | | `app:minCharacters` | 最小字符数。`0` 表示没有限制 | `0` | 465 | 466 | #### 其他 467 | 468 | | 属性 | 描述 | 默认值 | 469 | | --- | --- | --- | 470 | | `app:enabled` | 文本框是否启用 | `True` | 471 | | `app:hasClearButton` | 是否在文本域末端显示清除按钮 | `False` | 472 | | `app:hasFocus` | 文本框是否获得焦点 | `False` | 473 | | `app:alwaysShowHint` | 当 EditText 中有提示文本时,是否将标签始终固定在顶部 | `False` | 474 | | `app:useDenseSpacing` | 是否使用紧凑的布局 | `False` | 475 | | `app:manualValidateError` | 错误状态是否只在调用 `validate()` 时刷新 | `False` | 476 | 477 | ​ 478 | ## 开源许可 479 | 480 | Copyright 2020 Mark Wang 481 | 482 | Licensed under the Apache License, Version 2.0 (the "License"); 483 | you may not use this file except in compliance with the License. 484 | You may obtain a copy of the License at 485 | 486 | http://www.apache.org/licenses/LICENSE-2.0 487 | 488 | Unless required by applicable law or agreed to in writing, software 489 | distributed under the License is distributed on an "AS IS" BASIS, 490 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 491 | See the License for the specific language governing permissions and 492 | limitations under the License. 493 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | google() 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.4.1' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | google() 19 | jcenter() 20 | maven { url 'https://jitpack.io' } 21 | } 22 | } 23 | 24 | task clean(type: Delete) { 25 | delete rootProject.buildDir 26 | } 27 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Jun 10 07:54:52 CST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /images/alwaysHint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/alwaysHint.png -------------------------------------------------------------------------------- /images/basic_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/basic_disabled.png -------------------------------------------------------------------------------- /images/clearButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/clearButton.png -------------------------------------------------------------------------------- /images/customColor1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/customColor1.png -------------------------------------------------------------------------------- /images/customColor2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/customColor2.png -------------------------------------------------------------------------------- /images/darkTheme.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/darkTheme.gif -------------------------------------------------------------------------------- /images/dense.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/dense.png -------------------------------------------------------------------------------- /images/denseSpacing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/denseSpacing.png -------------------------------------------------------------------------------- /images/edittext.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/edittext.gif -------------------------------------------------------------------------------- /images/error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/error.png -------------------------------------------------------------------------------- /images/helper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/helper.png -------------------------------------------------------------------------------- /images/hint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/hint.png -------------------------------------------------------------------------------- /images/icon1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/icon1.png -------------------------------------------------------------------------------- /images/icon2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/icon2.png -------------------------------------------------------------------------------- /images/input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/input.png -------------------------------------------------------------------------------- /images/label.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/label.png -------------------------------------------------------------------------------- /images/lightTheme.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/lightTheme.gif -------------------------------------------------------------------------------- /images/maxChar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/maxChar.gif -------------------------------------------------------------------------------- /images/maxMinChar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/maxMinChar.gif -------------------------------------------------------------------------------- /images/maxlines.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/maxlines.gif -------------------------------------------------------------------------------- /images/mic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/mic.png -------------------------------------------------------------------------------- /images/prefix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/prefix.png -------------------------------------------------------------------------------- /images/singleline.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/singleline.gif -------------------------------------------------------------------------------- /images/suffix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/suffix.png -------------------------------------------------------------------------------- /images/tfb1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/images/tfb1.gif -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | buildToolsVersion '28.0.3' 6 | defaultConfig { 7 | applicationId "studio.carbonylgroup.textfieldboxestest" 8 | minSdkVersion 15 9 | targetSdkVersion 28 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(include: ['*.jar'], dir: 'libs') 24 | androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | implementation 'com.android.support:appcompat-v7:28.0.0' 28 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 29 | implementation 'com.android.support:design:28.0.0' 30 | // compile 'com.github.HITGIF:TextFieldBoxes:1.4.1' 31 | implementation project(':textfieldboxes') 32 | testImplementation 'junit:junit:4.12' 33 | } 34 | -------------------------------------------------------------------------------- /sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/carbonyl/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /sample/src/androidTest/java/studio/carbonylgroup/textfieldboxestest/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package studio.carbonylgroup.textfieldboxestest; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("studio.carbonylgroup.textfieldboxestest", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sample/src/main/java/studio/carbonylgroup/textfieldboxestest/MainActivity.java: -------------------------------------------------------------------------------- 1 | package studio.carbonylgroup.textfieldboxestest; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.content.SharedPreferences; 6 | import android.os.Bundle; 7 | import android.support.design.widget.TextInputLayout; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.view.View; 10 | import android.widget.ArrayAdapter; 11 | import android.widget.Button; 12 | 13 | import studio.carbonylgroup.textfieldboxes.ExtendedEditText; 14 | import studio.carbonylgroup.textfieldboxes.TextFieldBoxes; 15 | 16 | 17 | public class MainActivity extends AppCompatActivity { 18 | 19 | private SharedPreferences sharedPreferences; 20 | 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState) { 23 | 24 | sharedPreferences = this.getSharedPreferences("theme", Context.MODE_PRIVATE); 25 | final boolean dark = sharedPreferences.getBoolean("dark", false); 26 | setTheme(dark ? R.style.AppThemeDark : R.style.AppTheme); 27 | 28 | super.onCreate(savedInstanceState); 29 | setContentView(R.layout.activity_main); 30 | 31 | // final TextFieldBoxes tfb = findViewById(R.id.text_field_boxes2); 32 | final ExtendedEditText t = findViewById(R.id.extendedEditText); 33 | 34 | final String[] aWords = {"Apple", "Android", "Alternative"}; 35 | final ArrayAdapter adapter = new ArrayAdapter<> 36 | (this, android.R.layout.select_dialog_item, aWords); 37 | t.setThreshold(1); 38 | t.setAdapter(adapter); 39 | 40 | setupDarkThemeButton(dark); 41 | setupErrorButton(); 42 | setupPasswordField(); 43 | } 44 | 45 | private void setupPasswordField() { 46 | final Button addClearIconButton = findViewById(R.id.clear_icon_button); 47 | final Button addEndIconButton = findViewById(R.id.end_icon_button); 48 | final TextFieldBoxes passwordField = findViewById(R.id.text_field_boxes6); 49 | 50 | addClearIconButton.setOnClickListener(new View.OnClickListener() { 51 | @Override 52 | public void onClick(View v) { 53 | passwordField.setHasClearButton(!passwordField.getHasClearButton()); 54 | } 55 | }); 56 | 57 | addEndIconButton.setOnClickListener(new View.OnClickListener() { 58 | @Override 59 | public void onClick(View v) { 60 | if (passwordField.getEndIconImageButton().getDrawable() == null) { 61 | passwordField.setEndIcon(R.drawable.ic_visibility_black_24dp); 62 | } else { 63 | passwordField.removeEndIcon(); 64 | } 65 | } 66 | }); 67 | } 68 | 69 | private void setupDarkThemeButton(final boolean dark) { 70 | 71 | final Button darkButton = findViewById(R.id.dark_button); 72 | 73 | darkButton.setText(dark ? "LIGHT SIDE" : "DARK SIDE"); 74 | darkButton.setOnClickListener(new View.OnClickListener() { 75 | @Override 76 | public void onClick(View view) { 77 | sharedPreferences.edit().putBoolean("dark", !dark).apply(); 78 | Intent i = getBaseContext().getPackageManager() 79 | .getLaunchIntentForPackage(getBaseContext().getPackageName()); 80 | i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 81 | startActivity(i); 82 | } 83 | }); 84 | } 85 | 86 | private void setupErrorButton() { 87 | final Button errorButton = findViewById(R.id.error_button); 88 | final TextFieldBoxes errorField = findViewById(R.id.text_field_boxes5); 89 | errorButton.setOnClickListener(new View.OnClickListener() { 90 | @Override 91 | public void onClick(View v) { 92 | errorField.setError("Invalid coupon code.", false); 93 | } 94 | }); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_location_on_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/sample/src/main/res/drawable-hdpi/ic_location_on_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_vpn_key_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/sample/src/main/res/drawable-hdpi/ic_vpn_key_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_location_on_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/sample/src/main/res/drawable-mdpi/ic_location_on_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_vpn_key_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/sample/src/main/res/drawable-mdpi/ic_vpn_key_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_location_on_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/sample/src/main/res/drawable-xhdpi/ic_location_on_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_vpn_key_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/sample/src/main/res/drawable-xhdpi/ic_vpn_key_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_location_on_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/sample/src/main/res/drawable-xxhdpi/ic_location_on_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_vpn_key_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/sample/src/main/res/drawable-xxhdpi/ic_vpn_key_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/ic_location_on_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/sample/src/main/res/drawable-xxxhdpi/ic_location_on_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/ic_vpn_key_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HITGIF/TextFieldBoxes/2f220b0f967005d373efe81c1a7df29978e3de7c/sample/src/main/res/drawable-xxxhdpi/ic_vpn_key_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable/ic_visibility_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 23 | 24 | 31 | 32 | 33 | 34 | 38 | 39 | 50 | 51 | 59 | 60 | 61 | 62 | 75 | 76 | 86 | 87 | 88 | 89 | 90 | 91 | 101 | 102 | 106 | 107 | 108 | 109 |