├── .gitignore ├── .idea ├── caches │ └── gradle_models.ser ├── codeStyles │ └── Project.xml ├── compiler.xml ├── encodings.xml ├── gradle.xml ├── jarRepositories.xml ├── misc.xml └── vcs.xml ├── .travis.yml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── edittext │ │ └── aliazaz │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── edittext │ │ │ └── aliazaz │ │ │ ├── BaseActivity.kt │ │ │ └── MainActivity.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_adaptive_back.png │ │ ├── ic_launcher_adaptive_fore.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_adaptive_back.png │ │ ├── ic_launcher_adaptive_fore.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_adaptive_back.png │ │ ├── ic_launcher_adaptive_fore.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_adaptive_back.png │ │ ├── ic_launcher_adaptive_fore.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_adaptive_back.png │ │ ├── ic_launcher_adaptive_fore.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── edittext │ └── aliazaz │ └── ExampleUnitTest.kt ├── build.gradle ├── buildSrc ├── build.gradle.kts └── src │ └── main │ └── java │ ├── ConfigurationData.kt │ ├── Dependencies.kt │ └── DependenciesVersions.kt ├── demo ├── pic1.png ├── pic2.png └── pic3.png ├── edittextpicker ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── edittextpicker │ │ └── aliazaz │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── edittextpicker │ │ │ └── aliazaz │ │ │ ├── EditTextPicker.kt │ │ │ ├── model │ │ │ ├── EditTextModel.kt │ │ │ └── EditTextPickerModel.kt │ │ │ ├── repository │ │ │ ├── EditTextPickerBuilder.kt │ │ │ └── EditTextPickerWatcher.kt │ │ │ └── utils │ │ │ ├── CONSTANTS.kt │ │ │ ├── EditTextUtils.kt │ │ │ └── EditTextViews.kt │ └── res │ │ └── values │ │ ├── attrs.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── edittextpicker │ └── aliazaz │ └── ExampleUnitTest.kt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches/build_file_checksums.ser 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | .DS_Store 9 | /build 10 | /captures 11 | .externalNativeBuild 12 | -------------------------------------------------------------------------------- /.idea/caches/gradle_models.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/.idea/caches/gradle_models.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 20 | 21 | 22 | 23 | 25 | 26 | 27 |
28 | 29 | 30 | 31 | xmlns:android 32 | 33 | ^$ 34 | 35 | 36 | 37 |
38 |
39 | 40 | 41 | 42 | xmlns:.* 43 | 44 | ^$ 45 | 46 | 47 | BY_NAME 48 | 49 |
50 |
51 | 52 | 53 | 54 | .*:id 55 | 56 | http://schemas.android.com/apk/res/android 57 | 58 | 59 | 60 |
61 |
62 | 63 | 64 | 65 | .*:name 66 | 67 | http://schemas.android.com/apk/res/android 68 | 69 | 70 | 71 |
72 |
73 | 74 | 75 | 76 | name 77 | 78 | ^$ 79 | 80 | 81 | 82 |
83 |
84 | 85 | 86 | 87 | style 88 | 89 | ^$ 90 | 91 | 92 | 93 |
94 |
95 | 96 | 97 | 98 | .* 99 | 100 | ^$ 101 | 102 | 103 | BY_NAME 104 | 105 |
106 |
107 | 108 | 109 | 110 | .* 111 | 112 | http://schemas.android.com/apk/res/android 113 | 114 | 115 | ANDROID_ATTRIBUTE_ORDER 116 | 117 |
118 |
119 | 120 | 121 | 122 | .* 123 | 124 | .* 125 | 126 | 127 | BY_NAME 128 | 129 |
130 |
131 |
132 |
133 |
134 |
-------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | 34 | 35 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 34 | 55 | 56 | 57 | 58 | 59 | 60 | 62 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | 3 | branches: 4 | only: 5 | - master 6 | 7 | android: 8 | components: 9 | - android-30 10 | - build-tools-30.0.3 11 | - tools 12 | - platform-tools 13 | - extra-android-m2repository 14 | 15 | before_install: 16 | - yes | sdkmanager "build-tools;33.0.0" 17 | - chmod +x gradlew 18 | 19 | script: 20 | - ./gradlew clean assembleDebug assembleRelease testDebug 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Ali Azaz Alam 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EditTextPicker/Masked-Edittext Library 2 | 3 | [![Build Status](https://travis-ci.com/AliAzaz/Edittext-Picker.svg?branch=master)](https://travis-ci.org/AliAzaz/Edittext-Library) [![](https://img.shields.io/badge/Jitpack-2.1.1-brightgreen.svg)](https://jitpack.io/#AliAzaz/Edittext-Library/2.1.1) [![API](https://img.shields.io/badge/API-21%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=21) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-EditTextPicker-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/7671) [![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT) 4 | 5 | Edittext library by which you can easily achieve a lot of functionalities by directly implementing some lines of code in XML and on the Java side. 6 | The following are the functions that EditTextPicker provides: 7 | 8 | - Empty checking 9 | - Masking Edittext 10 | - Pattern checking 11 | - Range checking 12 | 13 | ## Description: 14 | Please see the description of this library in my article ***[Edittext Picker Library](https://medium.com/@ali.azaz.alam/edittext-picker-library-4c71ae7d7863)*** 15 | 16 | ## Result 17 | 18 | pic-1   pic-2   pic-3 19 | 20 | 21 | ## Implementation 22 | In project.gradle add this code it in root build.gradle at the end of repositories: 23 | ```sh 24 | dependencyResolutionManagement { 25 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 26 | repositories { 27 | mavenCentral() 28 | maven { url 'https://jitpack.io' } 29 | } 30 | } 31 | ``` 32 | 33 | Now, add the dependency in app.gradle: 34 | ```sh 35 | dependencies { 36 | implementation 'com.github.AliAzaz:Edittext-Library:X.X.X' 37 | } 38 | ``` 39 | 40 | ## Quick Usage 41 | 42 | ### XML 43 | Note: By default required is true. But if you don't want to validate specific edittext then simply set it to false: 44 | ***app:required="false"*** 45 | 46 | -- Required Edittext 47 | ```sh 48 | 53 | ``` 54 | 55 | -- Range (5-10) with a default value of 999 56 | ```sh 57 | 67 | ``` 68 | 69 | -- Masking 70 | ```sh 71 | 78 | ``` 79 | 80 | -- Pattern with default value checking [Following pattern is: (2-4)Characters with (3-5)Digits ] 81 | ```sh 82 | 90 | ``` 91 | 92 | ### Java/Kotlin 93 | Implement this code in submit button click 94 | 95 | --- For Required component 96 | ```sh 97 | if (!txtBoxReq.isEmptyTextBox()) return; 98 | ``` 99 | 100 | -- For validating range component 101 | ```sh 102 | if (!txtBoxRange.isRangeTextValidate()) return; 103 | ``` 104 | 105 | -- For validating pattern component 106 | ```sh 107 | if (!txtBoxDefault.isTextEqualToPattern()) return; 108 | ``` 109 | 110 | ## Support Builder Pattern 111 | This library also support chain request 112 | 113 | ```sh 114 | txtPicker = EditTextPicker(this, 115 | EditTextPickerBuilder().apply { 116 | setRequired(true) 117 | setRangeValues(0.5f, 40.0f) 118 | setMask("##.##") 119 | setPattern("^(\\d{2,2}\\.\\d{2,2})$") 120 | }.build()) 121 | .apply { 122 | hint = "##.##" 123 | inputType = InputType.TYPE_CLASS_NUMBER 124 | } 125 | ``` 126 | 127 | ## Set values at Run time 128 | 129 | Users can easily set the attribute values at runtime. 130 | 131 | ```sh 132 | txtDate.setMask("##-##-####").setRequired(false) 133 | ``` 134 | 135 |
136 | 137 | ## EditText-Picker Gradle Configuration 138 | 139 | ``` 140 | edittextpicker = 2.1.1 141 | gradle = 7.4.2 142 | kotlin = 1.8.0 143 | build_version = 34.0.0 144 | min_api_level = 21 145 | max_api_level = 34 146 | ``` 147 | 148 | ## CONNECT👍 149 | 150 | [![LinkedIn Badge](https://img.shields.io/badge/-aliazazalam-blue?style=flat&logo=Linkedin&logoColor=white&link=https://www.linkedin.com/in/aliazazalam/)](https://www.linkedin.com/in/aliazazalam) 151 | [![Twitter Badge](https://img.shields.io/badge/-aliazaz-gray?style=flat&logo=twitter&logoColor=blue&link=https://twitter.com/AliAzazAlam1)](https://twitter.com/AliAzazAlam1) 152 | [![Medium Badge](https://img.shields.io/badge/-aliazazalam-black?style=flat&logo=Medium&logoColor=white&link=https://medium.com/@ali.azaz.alam)](https://medium.com/@ali.azaz.alam) 153 | [![Stackoverflow Badge](https://img.shields.io/badge/-aliazaz-gray?style=flat&logo=stackoverflow&logoColor=orange&link=https://stackoverflow.com/story/ali-azaz-alam)](https://stackoverflow.com/story/ali-azaz-alam) 154 | 155 | ## LICENSE 156 | 157 | Distributed under the MIT license. 158 | See [LICENSE](https://github.com/AliAzaz/Edittext-Library/blob/master/LICENSE) information. 159 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'kotlin-android' 4 | id 'org.jetbrains.kotlin.android' 5 | id 'kotlin-kapt' 6 | } 7 | 8 | android { 9 | compileSdk ConfigurationData.compileSdkVersion 10 | buildToolsVersion = ConfigurationData.buildToolsVersion 11 | namespace 'com.edittext.aliazaz' 12 | 13 | defaultConfig { 14 | applicationId "com.edittext.aliazaz" 15 | minSdkVersion ConfigurationData.minSdkVersion 16 | targetSdkVersion ConfigurationData.targetSdkVersion 17 | versionCode ConfigurationData.versionCode 18 | versionName ConfigurationData.versionName 19 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 20 | } 21 | buildTypes { 22 | release { 23 | // to remove unused resources. This will reduce APK size. 24 | shrinkResources true 25 | //To obfuscate the code and to remove unused code. This will improve code security and will reduce APK size. 26 | minifyEnabled true 27 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 28 | } 29 | } 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_11 32 | targetCompatibility JavaVersion.VERSION_11 33 | } 34 | buildFeatures { 35 | dataBinding true 36 | viewBinding true 37 | } 38 | } 39 | 40 | dependencies { 41 | implementation fileTree(dir: 'libs', include: ['*.jar']) 42 | implementation AndroidApp.appCompat 43 | implementation AndroidApp.coreKTX 44 | implementation AndroidApp.stringLANG 45 | 46 | implementation Layouts.constraint 47 | 48 | implementation project(':edittextpicker') 49 | 50 | testImplementation Testing.junit 51 | androidTestImplementation Testing.junitImpl 52 | androidTestImplementation Testing.expresso 53 | } 54 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/edittext/aliazaz/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.edittextpicker.aliazaz.edittextpicker 2 | 3 | import androidx.test.ext.junit.runners.AndroidJUnit4 4 | import androidx.test.platform.app.InstrumentationRegistry 5 | import org.junit.Assert 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | /** 10 | * Instrumented test, which will execute on an Android device. 11 | * 12 | * @see [Testing documentation](http://d.android.com/tools/testing) 13 | */ 14 | @RunWith(AndroidJUnit4::class) 15 | class ExampleInstrumentedTest { 16 | @Test 17 | fun useAppContext() { // Context of the app under test. 18 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 19 | Assert.assertEquals("com.edittextpicker.aliazaz.edittextpicker", appContext.packageName) 20 | } 21 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/edittext/aliazaz/BaseActivity.kt: -------------------------------------------------------------------------------- 1 | package com.edittext.aliazaz 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | import androidx.databinding.DataBindingUtil 6 | import androidx.viewbinding.ViewBinding 7 | 8 | abstract class BaseActivity : AppCompatActivity() { 9 | private lateinit var _binding: VB 10 | protected val binding get() = _binding 11 | abstract fun getLayout(): Int 12 | abstract fun init(): Unit 13 | 14 | override fun onCreate(savedInstanceState: Bundle?) { 15 | super.onCreate(savedInstanceState) 16 | _binding = DataBindingUtil.setContentView(this, getLayout()) 17 | init() 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /app/src/main/java/com/edittext/aliazaz/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.edittext.aliazaz 2 | 3 | import android.text.InputType 4 | import android.widget.Toast 5 | import com.edittext.aliazaz.databinding.ActivityMainBinding 6 | import com.edittextpicker.aliazaz.EditTextPicker 7 | import com.edittextpicker.aliazaz.repository.EditTextPickerBuilder 8 | 9 | /* 10 | * @author Ali Azaz Alam 11 | * */ 12 | class MainActivity : BaseActivity() { 13 | 14 | private var txtPicker: EditTextPicker? = null 15 | override fun getLayout(): Int = R.layout.activity_main 16 | 17 | override fun init() { 18 | settingListeners() 19 | } 20 | 21 | private fun settingListeners() { 22 | binding.btnSubmit.setOnClickListener { 23 | if (validateComponents()) { 24 | Toast.makeText( 25 | this@MainActivity, 26 | getString(R.string.form_submitted), 27 | Toast.LENGTH_SHORT 28 | ) 29 | .show() 30 | clearFields() 31 | } 32 | } 33 | 34 | /* 35 | * Setting date mask to txtDate 36 | * */ 37 | binding.txtDate.setMask("##-##-####").setRequired(false) 38 | 39 | binding.txtPhone.setMaskText("3453323212") 40 | 41 | // Create EditTextPicker programmatically 42 | txtPicker = EditTextPicker(this, EditTextPickerBuilder().apply { 43 | setRequired(true) 44 | setRangeValues(0.5f, 40.0f) 45 | setMask("##.##") 46 | setPattern("^(\\d{2,2}\\.\\d{2,2})$") 47 | }.build()).apply { 48 | hint = "##.##" 49 | inputType = InputType.TYPE_CLASS_NUMBER 50 | } 51 | binding.llLayout.addView(txtPicker) 52 | 53 | } 54 | 55 | private fun validateComponents(): Boolean { 56 | if (!binding.txtBoxRange.isRangeTextValidate()) return false 57 | else if (txtPicker?.isRangeTextValidate() == false) return false 58 | else if (!binding.txtBoxDefault.isTextEqualToPattern()) return false 59 | else if (!binding.txtDate.isEmptyTextBox()) return false 60 | return binding.txtPhone.isEmptyTextBox() 61 | } 62 | 63 | private fun clearFields() { 64 | binding.txtBoxRange.text = null 65 | txtPicker?.text?.clear() 66 | binding.txtBoxDefault.text = null 67 | binding.txtDate.text = null 68 | binding.txtPhone.text = null 69 | } 70 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 14 | 15 | 16 | 32 | 33 | 49 | 50 | 65 | 66 | 81 | 82 | 97 | 98 | 118 | 119 | 133 | 134 | 135 | 153 | 154 | 169 | 170 | 187 | 188 |