├── .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 |
24 |
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 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
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 | [](https://travis-ci.org/AliAzaz/Edittext-Library) [](https://jitpack.io/#AliAzaz/Edittext-Library/2.1.1) [](https://android-arsenal.com/api?level=21) [](https://android-arsenal.com/details/1/7671) [](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 |
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 | [](https://www.linkedin.com/in/aliazazalam)
151 | [](https://twitter.com/AliAzazAlam1)
152 | [](https://medium.com/@ali.azaz.alam)
153 | [](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 |
197 |
198 |
199 |
200 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_fore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_fore.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_fore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_fore.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_fore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_fore.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_fore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_fore.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_fore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_fore.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | EditTextPicker
3 | Successfully submitted
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/edittext/aliazaz/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.edittextpicker.aliazaz.edittextpicker
2 |
3 | import org.junit.Assert
4 | import org.junit.Test
5 |
6 | /**
7 | * Example local unit test, which will execute on the development machine (host).
8 | *
9 | * @see [Testing documentation](http://d.android.com/tools/testing)
10 | */
11 | class ExampleUnitTest {
12 | @Test
13 | fun addition_isCorrect() {
14 | Assert.assertEquals(4, 2 + 2.toLong())
15 | }
16 | }
--------------------------------------------------------------------------------
/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 | mavenCentral()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:7.4.2'
10 | }
11 | }
12 |
13 | plugins {
14 | id 'com.android.application' version '7.4.2' apply false
15 | id 'com.android.library' version '7.4.2' apply false
16 | id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
17 | }
18 |
19 | tasks.register('clean', Delete) {
20 | delete rootProject.buildDir
21 | }
22 |
--------------------------------------------------------------------------------
/buildSrc/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `kotlin-dsl`
3 | }
4 |
5 | repositories {
6 | mavenCentral()
7 | }
--------------------------------------------------------------------------------
/buildSrc/src/main/java/ConfigurationData.kt:
--------------------------------------------------------------------------------
1 | object ConfigurationData {
2 | const val minSdkVersion = 21
3 | const val targetSdkVersion = 34
4 | const val compileSdkVersion = 34
5 | const val versionCode = 7
6 | const val versionName = "2.1.1"
7 | const val buildToolsVersion = "34.0.0"
8 | }
--------------------------------------------------------------------------------
/buildSrc/src/main/java/Dependencies.kt:
--------------------------------------------------------------------------------
1 | object Layouts {
2 | const val constraint =
3 | "androidx.constraintlayout:constraintlayout:${DependenciesVersions.constraintVersion}"
4 | }
5 |
6 | object AndroidApp {
7 | const val appCompat =
8 | "androidx.appcompat:appcompat:${DependenciesVersions.supportLibraryVersion}"
9 | const val coreKTX = "androidx.core:core-ktx:${DependenciesVersions.ktxVersion}"
10 | const val stringLANG =
11 | "org.apache.commons:commons-lang3:${DependenciesVersions.stringLangVersion}"
12 | }
13 |
14 | object Testing {
15 | const val junit = "junit:junit:${DependenciesVersions.junitVersion}"
16 | const val junitImpl = "androidx.test.ext:junit:${DependenciesVersions.junitImplVersion}"
17 | const val expresso =
18 | "androidx.test.espresso:espresso-core:${DependenciesVersions.espressoVersion}"
19 | }
--------------------------------------------------------------------------------
/buildSrc/src/main/java/DependenciesVersions.kt:
--------------------------------------------------------------------------------
1 | object DependenciesVersions {
2 | const val stringLangVersion = "3.12.0"
3 | const val constraintVersion = "2.1.4"
4 | const val junitImplVersion = "1.1.5"
5 | const val espressoVersion = "3.5.1"
6 | const val supportLibraryVersion = "1.6.1"
7 | const val ktxVersion = "1.12.0"
8 | const val junitVersion = "4.13.2"
9 | const val cardVersion = "1.0.0"
10 | }
--------------------------------------------------------------------------------
/demo/pic1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/demo/pic1.png
--------------------------------------------------------------------------------
/demo/pic2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/demo/pic2.png
--------------------------------------------------------------------------------
/demo/pic3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/demo/pic3.png
--------------------------------------------------------------------------------
/edittextpicker/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/edittextpicker/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'kotlin-android'
4 | id 'org.jetbrains.kotlin.android'
5 | }
6 |
7 | android {
8 | compileSdk ConfigurationData.compileSdkVersion
9 | buildToolsVersion = ConfigurationData.buildToolsVersion
10 | namespace 'com.edittextpicker.aliazaz'
11 |
12 | defaultConfig {
13 | minSdkVersion ConfigurationData.minSdkVersion
14 | targetSdkVersion ConfigurationData.targetSdkVersion
15 | versionCode ConfigurationData.versionCode
16 | versionName ConfigurationData.versionName
17 |
18 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
19 | }
20 |
21 | buildTypes {
22 | release {
23 | //To obfuscate the code and to remove unused code. This will improve code security and will reduce APK size.
24 | minifyEnabled true
25 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
26 | }
27 | }
28 |
29 |
30 | compileOptions {
31 | sourceCompatibility JavaVersion.VERSION_11
32 | targetCompatibility JavaVersion.VERSION_11
33 | }
34 |
35 | lint {
36 | abortOnError false
37 | }
38 |
39 | }
40 |
41 |
42 | dependencies {
43 | implementation fileTree(dir: 'libs', include: ['*.jar'])
44 | implementation AndroidApp.appCompat
45 | implementation AndroidApp.coreKTX
46 | implementation AndroidApp.stringLANG
47 |
48 | testImplementation Testing.junit
49 | androidTestImplementation Testing.junitImpl
50 | androidTestImplementation Testing.expresso
51 | }
52 |
--------------------------------------------------------------------------------
/edittextpicker/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 | # Ignore annotation used for build tooling.
16 | -dontwarn org.codehaus.mojo.animal_sniffer.*
17 |
18 | # Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
19 | -dontwarn kotlin.Unit
20 |
21 | -dontwarn javax.annotation.**
22 |
23 | -keepclasseswithmembernames class * {
24 | native ;
25 | }
26 |
27 | -keep class java.io.** { *; }
28 | -keep class android.support.** { *; }
29 | -keep interface android.support.** { *; }
30 |
31 | -keep class **$$ViewBinder { *; }
32 | -renamesourcefileattribute SourceFile
33 |
34 | -keep public class * extends java.lang.Exception
35 | -keepattributes SourceFile,LineNumberTable
36 |
37 | -keepnames class * implements android.os.Parcelable {
38 | public static final ** CREATOR;
39 | }
40 |
41 | # Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
42 | # EnclosingMethod is required to use InnerClasses.
43 | -keepattributes Exceptions, Signature, InnerClasses, EnclosingMethod
44 |
45 | # Retrofit does reflection on method and parameter annotations.
46 | -keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
47 |
48 | -keep,allowobfuscation interface <1>
49 |
50 | -keep class androidx.lifecycle.** { *; }
51 | -keep class androidx.arch.core.** { *; }
52 |
53 | -keepattributes Signature
54 | -keepattributes *Annotation*
55 |
56 | #Not show logs
57 | -assumenosideeffects class android.util.Log {
58 | public static boolean isLoggable(java.lang.String, int);
59 | public static int d(...);
60 | public static int w(...);
61 | public static int v(...);
62 | public static int i(...);
63 | public static int e(...);
64 | }
65 |
66 | #custom modules
67 | -keep class com.edittextpicker.aliazaz.model.EditTextPickerModel { *; }
68 | -keep class com.edittextpicker.aliazaz.EditTextPicker { *; }
69 | -keep class com.edittextpicker.aliazaz.repository.EditTextPickerBuilder { *; }
--------------------------------------------------------------------------------
/edittextpicker/src/androidTest/java/com/edittextpicker/aliazaz/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.edittextpicker.aliazaz
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.textpicker.test", appContext.packageName)
20 | }
21 | }
--------------------------------------------------------------------------------
/edittextpicker/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/edittextpicker/src/main/java/com/edittextpicker/aliazaz/EditTextPicker.kt:
--------------------------------------------------------------------------------
1 | package com.edittextpicker.aliazaz
2 |
3 | import android.content.Context
4 | import android.text.SpannableStringBuilder
5 | import android.util.AttributeSet
6 | import androidx.appcompat.widget.AppCompatEditText
7 | import com.edittextpicker.aliazaz.model.EditTextModel
8 | import com.edittextpicker.aliazaz.model.EditTextPickerModel
9 | import com.edittextpicker.aliazaz.repository.EditTextPickerWatcher
10 | import com.edittextpicker.aliazaz.utils.CONSTANTS
11 | import com.edittextpicker.aliazaz.utils.EditTextViews
12 | import com.edittextpicker.aliazaz.utils.clearError
13 | import com.edittextpicker.aliazaz.utils.setMaskEditTextLength
14 | import com.edittextpicker.aliazaz.utils.setMaskTextOnEditText
15 | import org.apache.commons.lang3.StringUtils
16 | import kotlin.math.roundToLong
17 |
18 | /*
19 | * @author Ali Azaz Alam
20 | * */
21 | class EditTextPicker : AppCompatEditText, EditTextViews {
22 |
23 | /*
24 | * Initializing TextWatcher
25 | * */
26 | private var editTextPickerWatcher: EditTextPickerWatcher? = null
27 |
28 | /*
29 | * Declaring editTextPickerModel data class, used to store EditTextPicker properties values
30 | * */
31 | private lateinit var editTextPickerModel: EditTextPickerModel
32 |
33 |
34 | /*
35 | * Initialize class with {@param context}, and {@param EditTextModel} pass as an argument. Used while creating EditTextPicker programmatically
36 | * */
37 | constructor(context: Context, editTextPickerModel: EditTextModel) : super(context) {
38 | this.editTextPickerModel = editTextPickerModel.editTextPickerModel!!
39 | maskingListener()
40 | }
41 |
42 |
43 | /*
44 | * Initialize class with {@param context}, {@param attributeSet} and {@param EditTextModel} pass as an argument. Used while creating EditTextPicker programmatically
45 | * */
46 | constructor(context: Context, defaultStyle: Int, editTextPickerModel: EditTextModel) : super(
47 | context,
48 | null,
49 | defaultStyle
50 | ) {
51 | this.editTextPickerModel = editTextPickerModel.editTextPickerModel!!
52 | maskingListener()
53 | }
54 |
55 |
56 | /*
57 | * Initialize class with {@param context}, and {@param attributeSet} pass as an argument
58 | * */
59 | constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
60 | initialize(context, attrs)
61 | }
62 |
63 |
64 | /*
65 | * Initialize class with {@param context}, {@param attributeSet} and {@param defaultStyle} pass as an argument
66 | * */
67 | constructor(context: Context, attrs: AttributeSet?, defaultStyle: Int) : super(
68 | context,
69 | attrs,
70 | defaultStyle
71 | ) {
72 | initialize(context, attrs)
73 | }
74 |
75 |
76 | /*
77 | * Get attribute setter properties from xml and set it to the specific variables
78 | * */
79 | private fun initialize(context: Context, attrs: AttributeSet?) {
80 | editTextPickerModel = EditTextPickerModel()
81 | attrs?.let { item ->
82 | val a = context.obtainStyledAttributes(
83 | item,
84 | R.styleable.EditTextPicker
85 | )
86 | try {
87 | a.run {
88 | /*
89 | * 1. Setting required attribute value
90 | * 2. Default value is 'true'
91 | * 3. Optional
92 | * */
93 | editTextPickerModel.required =
94 | getBoolean(R.styleable.EditTextPicker_required, true)
95 |
96 |
97 | /*
98 | * 1. Setting pattern attribute value
99 | * 2. Optional
100 | * */
101 | editTextPickerModel.pattern = getString(R.styleable.EditTextPicker_pattern)
102 |
103 |
104 | /*
105 | * 1. Setting mask attribute value
106 | * 2. Initializing TextWatcher -> if mask value is not null else remove initialized TextWatcher
107 | * */
108 | editTextPickerModel.mask = getString(R.styleable.EditTextPicker_mask)
109 | maskingListener()
110 |
111 |
112 | /*
113 | * 1. Setting type attribute value whether it's range and equal
114 | * 2. For range ->
115 | * i) Required min and max value (float)
116 | * ii) Define default value is Optional
117 | * 3. For equal ->
118 | * i) Required pattern value
119 | * ii) Define default value is Optional
120 | * */
121 | editTextPickerModel.type =
122 | getInteger(R.styleable.EditTextPicker_type, CONSTANTS.DEFAULT_VALUE_INT)
123 | if (editTextPickerModel.type == CONSTANTS.PICKER_TYPE.RANGE) {
124 | editTextPickerModel.minvalue =
125 | getFloat(
126 | R.styleable.EditTextPicker_minValue,
127 | CONSTANTS.DEFAULT_VALUE_FLOAT
128 | )
129 | editTextPickerModel.maxvalue =
130 | getFloat(
131 | R.styleable.EditTextPicker_maxValue,
132 | CONSTANTS.DEFAULT_VALUE_FLOAT
133 | )
134 | editTextPickerModel.rangedefaultvalue =
135 | getFloat(
136 | R.styleable.EditTextPicker_defaultValue,
137 | CONSTANTS.DEFAULT_VALUE_FLOAT
138 | )
139 | if (editTextPickerModel.minvalue == CONSTANTS.DEFAULT_VALUE_FLOAT) throw RuntimeException(
140 | resources.getString(R.string.error_minvalue)
141 | )
142 | if (editTextPickerModel.maxvalue == CONSTANTS.DEFAULT_VALUE_FLOAT) throw RuntimeException(
143 | resources.getString(R.string.error_maxvalue)
144 | )
145 | } else if (editTextPickerModel.type == CONSTANTS.PICKER_TYPE.EQUAL) {
146 | editTextPickerModel.pattern = getString(R.styleable.EditTextPicker_pattern)
147 | editTextPickerModel.defaultvalue =
148 | getString(R.styleable.EditTextPicker_defaultValue)
149 | ?: StringUtils.EMPTY
150 | if (editTextPickerModel.pattern == null) throw RuntimeException(
151 | resources.getString(
152 | R.string.error_patternvalue
153 | )
154 | )
155 | }
156 | }
157 | } catch (e: Exception) {
158 | throw e
159 | } finally {
160 | a.recycle()
161 | }
162 | }
163 | }
164 |
165 |
166 | /*
167 | * Validating EditText: Identifying it's empty or not
168 | * {@param customError} set custom error to EditText
169 | * */
170 | @JvmOverloads
171 | fun isEmptyTextBox(customError: String? = null): Boolean {
172 | clearError(this)
173 | if (!editTextPickerModel.required) return true
174 | if (super.getText().toString().isEmpty()) {
175 | super.setError(customError ?: resources.getString(R.string.error_required))
176 | super.setFocusableInTouchMode(true)
177 | super.requestFocus()
178 | return false
179 | }
180 | return true
181 | }
182 |
183 |
184 | /*
185 | * Access this functionality by setting type = range
186 | * This validation identifying whether EditText fulfilling specified min and max range or defaultValue or not.
187 | * {@param customError} set custom error to EditText
188 | * */
189 | @JvmOverloads
190 | fun isRangeTextValidate(customError: String? = null): Boolean {
191 | clearError(this)
192 | if (editTextPickerModel.type == CONSTANTS.PICKER_TYPE.EQUAL) return true
193 | if (!editTextPickerModel.required) return true
194 | if (!isEmptyTextBox()) return false
195 | if (!checkingTextPattern(null)) return false
196 | if (super.getText().toString().toFloat() < editTextPickerModel.minvalue || super.getText()
197 | .toString().toFloat() > editTextPickerModel.maxvalue
198 | ) {
199 | if (editTextPickerModel.rangedefaultvalue != CONSTANTS.DEFAULT_VALUE_FLOAT) {
200 | var dValue = super.getText().toString().toFloat()
201 | if (super.getText().toString().toFloat() == super.getText().toString().toFloat()
202 | .roundToLong().toFloat()
203 | )
204 | dValue = super.getText().toString().split(CONSTANTS.FULL_STOP_DELIMITER)
205 | .toTypedArray()[0].toFloat()
206 | if (dValue == editTextPickerModel.rangedefaultvalue) {
207 | return true
208 | }
209 | }
210 | var minVal = editTextPickerModel.minvalue.toString()
211 | var maxVal = editTextPickerModel.maxvalue.toString()
212 | if (editTextPickerModel.minvalue == editTextPickerModel.minvalue.roundToLong()
213 | .toFloat()
214 | ) minVal = minVal.split(CONSTANTS.FULL_STOP).toTypedArray()[0]
215 | if (editTextPickerModel.maxvalue == editTextPickerModel.maxvalue.roundToLong()
216 | .toFloat()
217 | ) maxVal = maxVal.split(CONSTANTS.FULL_STOP).toTypedArray()[0]
218 | super.setError(
219 | customError
220 | ?: "${resources.getString(R.string.error_range)} $minVal to $maxVal "
221 | )
222 | super.setFocusableInTouchMode(true)
223 | super.requestFocus()
224 | return false
225 | }
226 | return true
227 | }
228 |
229 |
230 | /*
231 | * Access this functionality by setting type = equal
232 | * This validation identifying whether EditText passing defined regex pattern or equal to default value.
233 | * {@param customError} set custom error to EditText
234 | * */
235 | @JvmOverloads
236 | fun isTextEqualToPattern(customError: String? = null): Boolean {
237 | clearError(this)
238 | if (!editTextPickerModel.required) return true
239 | if (!isEmptyTextBox()) return false
240 | if (!checkingTextPattern(customError))
241 | return when {
242 | editTextPickerModel.type == CONSTANTS.PICKER_TYPE.EQUAL && super.getText()
243 | .toString() == editTextPickerModel.defaultvalue -> {
244 | clearError(this)
245 | true
246 | }
247 | else -> false
248 | }
249 | return true
250 | }
251 |
252 |
253 | /*
254 | * Check EditText matches to pattern or not and return this flag
255 | * {@param customError} set custom error to EditText
256 | * */
257 | private fun checkingTextPattern(customError: String?): Boolean {
258 | editTextPickerModel.pattern?.let {
259 | return when {
260 | !super.getText().toString().matches(Regex(it)) -> {
261 | super.setError(customError ?: resources.getString(R.string.pattern_match))
262 | super.setFocusableInTouchMode(true)
263 | super.requestFocus()
264 | false
265 | }
266 | else -> {
267 | clearError(this)
268 | true
269 | }
270 | }
271 | } ?: return true
272 | }
273 |
274 |
275 | /*
276 | * [maskingListener] adding and removing TextChangedListener
277 | * Every time listener is first removed when [maskingListener] call then reset it
278 | * */
279 | private fun maskingListener() {
280 | removeTextChangedListener(editTextPickerWatcher)
281 | editTextPickerModel.mask?.let { mask ->
282 | editTextPickerWatcher = EditTextPickerWatcher(mask)
283 | addTextChangedListener(editTextPickerWatcher)
284 | if (mask.trim { it <= ' ' }.isNotEmpty()) {
285 | setMaskEditTextLength(this@EditTextPicker, mask)
286 | }
287 | }
288 | }
289 |
290 |
291 | /*
292 | * {@param mask} Set mask text to EditText
293 | * call [maskingListener] for performing masking
294 | * */
295 | override fun setMask(mask: String): EditTextPicker {
296 | editTextPickerModel.mask = mask
297 | maskingListener()
298 | return this
299 | }
300 |
301 |
302 | /*
303 | * {@param required} Set required text to EditText
304 | * */
305 | override fun setRequired(required: Boolean): EditTextPicker {
306 | editTextPickerModel.required = required
307 | return this
308 | }
309 |
310 |
311 | /*
312 | * {@param pattern} Set pattern to EditText
313 | * */
314 | override fun setPattern(pattern: String): EditTextPicker {
315 | editTextPickerModel.pattern = pattern
316 | return this
317 | }
318 |
319 |
320 | /*
321 | * {@param minValue} Set minValue to EditText
322 | * */
323 | override fun setMinValue(minValue: Float): EditTextPicker {
324 | editTextPickerModel.minvalue = minValue
325 | return this
326 | }
327 |
328 |
329 | /*
330 | * {@param maxValue} Set maxValue to EditText
331 | * */
332 | override fun setMaxValue(maxValue: Float): EditTextPicker {
333 | editTextPickerModel.maxvalue = maxValue
334 | return this
335 | }
336 |
337 |
338 | /*
339 | * {@param defaultValue} Set rangedefaultvalue to EditText
340 | * */
341 | override fun setRangeDefaultValue(defaultValue: Float): EditTextPicker {
342 | editTextPickerModel.rangedefaultvalue = defaultValue
343 | return this
344 | }
345 |
346 |
347 | /*
348 | * {@param defaultValue} Set equalDefaultValue to EditText
349 | * */
350 | override fun setEqualDefaultValue(defaultValue: String): EditTextPicker {
351 | editTextPickerModel.defaultvalue = defaultValue
352 | return this
353 | }
354 |
355 |
356 | /*
357 | * {@param mText} Predefined text set by user with mask attribute
358 | * */
359 | override fun setMaskText(text: String) {
360 | editTextPickerModel.mask?.let {
361 | this.text = SpannableStringBuilder(setMaskTextOnEditText(it, text))
362 | }
363 | }
364 | }
--------------------------------------------------------------------------------
/edittextpicker/src/main/java/com/edittextpicker/aliazaz/model/EditTextModel.kt:
--------------------------------------------------------------------------------
1 | package com.edittextpicker.aliazaz.model
2 |
3 | /*
4 | * @author Ali Azaz Alam
5 | * */
6 | object EditTextModel {
7 | internal var editTextPickerModel: EditTextPickerModel? = null
8 | }
--------------------------------------------------------------------------------
/edittextpicker/src/main/java/com/edittextpicker/aliazaz/model/EditTextPickerModel.kt:
--------------------------------------------------------------------------------
1 | package com.edittextpicker.aliazaz.model
2 |
3 | import org.apache.commons.lang3.StringUtils
4 |
5 | /*
6 | * @author Ali Azaz Alam
7 | * */
8 | internal data class EditTextPickerModel(
9 | var type: Int = 0,
10 |
11 | /*
12 | * For Type range: Required minvalue, maxvalue and its corresponding default value
13 | * */
14 | var minvalue: Float = -1f,
15 | var maxvalue: Float = -1f,
16 | var rangedefaultvalue: Float = -1f,
17 |
18 | /*
19 | * For Type equal: Required pattern and its corresponding default value
20 | * */
21 | var defaultvalue: String = StringUtils.EMPTY,
22 | var pattern: String? = null,
23 |
24 | /*
25 | * Mask and Required: Both are optional
26 | * */
27 | var mask: String? = null,
28 | var required: Boolean = true
29 |
30 | )
--------------------------------------------------------------------------------
/edittextpicker/src/main/java/com/edittextpicker/aliazaz/repository/EditTextPickerBuilder.kt:
--------------------------------------------------------------------------------
1 | package com.edittextpicker.aliazaz.repository
2 |
3 | import com.edittextpicker.aliazaz.model.EditTextModel
4 | import com.edittextpicker.aliazaz.model.EditTextPickerModel
5 | import com.edittextpicker.aliazaz.utils.CONSTANTS
6 | import org.apache.commons.lang3.StringUtils
7 |
8 | /*
9 | * @author Ali Azaz Alam
10 | * */
11 | class EditTextPickerBuilder {
12 |
13 | private val editTextPickerModel: EditTextPickerModel by lazy {
14 | EditTextPickerModel()
15 | }
16 |
17 | @JvmOverloads
18 | fun setRangeValues(
19 | minValue: Float,
20 | maxValue: Float,
21 | defaultValue: Float = -1f
22 | ): EditTextPickerBuilder {
23 | editTextPickerModel.type = CONSTANTS.PICKER_TYPE.RANGE
24 | editTextPickerModel.minvalue = minValue
25 | editTextPickerModel.maxvalue = maxValue
26 | editTextPickerModel.rangedefaultvalue = defaultValue
27 | return this
28 | }
29 |
30 | fun setMask(mask: String): EditTextPickerBuilder {
31 | editTextPickerModel.mask = mask
32 | return this
33 | }
34 |
35 | fun setRequired(required: Boolean): EditTextPickerBuilder {
36 | editTextPickerModel.required = required
37 | return this
38 | }
39 |
40 | fun setPattern(pattern: String): EditTextPickerBuilder {
41 | editTextPickerModel.pattern = pattern
42 | return this
43 | }
44 |
45 | @JvmOverloads
46 | fun setEqual(pattern: String, defaultValue: String = StringUtils.EMPTY): EditTextPickerBuilder {
47 | editTextPickerModel.type = CONSTANTS.PICKER_TYPE.EQUAL
48 | editTextPickerModel.pattern = pattern
49 | editTextPickerModel.defaultvalue = defaultValue
50 | return this
51 | }
52 |
53 | fun build(): EditTextModel {
54 | EditTextModel.editTextPickerModel = editTextPickerModel
55 | return EditTextModel
56 | }
57 |
58 |
59 | }
--------------------------------------------------------------------------------
/edittextpicker/src/main/java/com/edittextpicker/aliazaz/repository/EditTextPickerWatcher.kt:
--------------------------------------------------------------------------------
1 | package com.edittextpicker.aliazaz.repository
2 |
3 | import android.text.Editable
4 | import android.text.TextWatcher
5 | import com.edittextpicker.aliazaz.utils.editTextLoopToNextChar
6 |
7 | /*
8 | * @author Ali Azaz Alam
9 | * */
10 |
11 | /*
12 | * [EditTextPickerWatcher], implementing editTextPicker TextWatcher
13 | * */
14 | internal class EditTextPickerWatcher(private val mask: String?) : TextWatcher {
15 |
16 | private var maskCheckFlag = true
17 |
18 | override fun beforeTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) {}
19 |
20 | override fun onTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) {
21 | mask?.let { maskCheckFlag = i2 != 0 }
22 | }
23 |
24 | override fun afterTextChanged(editable: Editable) {
25 | mask?.apply {
26 | if (!maskCheckFlag) return
27 | val txt = editTextLoopToNextChar(this, editable.length - 1)
28 | if (txt.isEmpty()) return
29 | //Input Filter work
30 | val filters = editable.filters //get filter
31 | editable.filters = arrayOf() //reset filter
32 | editable.insert(editable.length - 1, txt)
33 | editable.filters = filters //restore filter
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/edittextpicker/src/main/java/com/edittextpicker/aliazaz/utils/CONSTANTS.kt:
--------------------------------------------------------------------------------
1 | package com.edittextpicker.aliazaz.utils
2 |
3 | internal object CONSTANTS {
4 | const val FULL_STOP = "."
5 | const val FULL_STOP_DELIMITER = "\\."
6 | const val MASK_HASH = '#'
7 | const val DEFAULT_VALUE_FLOAT = -1f
8 | const val DEFAULT_VALUE_INT = 0
9 |
10 | object PICKER_TYPE {
11 | const val RANGE = 1
12 | const val EQUAL = 2
13 | }
14 | }
--------------------------------------------------------------------------------
/edittextpicker/src/main/java/com/edittextpicker/aliazaz/utils/EditTextUtils.kt:
--------------------------------------------------------------------------------
1 | package com.edittextpicker.aliazaz.utils
2 |
3 | import android.text.InputFilter
4 | import android.text.InputFilter.LengthFilter
5 | import com.edittextpicker.aliazaz.EditTextPicker
6 | import org.apache.commons.lang3.StringUtils
7 |
8 | /*
9 | * @author Ali Azaz Alam
10 | * */
11 |
12 | /*
13 | * Masking procedure algorithm to create editTextPicker masked
14 | * */
15 | internal fun editTextLoopToNextChar(maskEdit: String, position: Int): StringBuilder {
16 | val finalResult = StringBuilder()
17 | loop@ for (i in position until maskEdit.length) {
18 | when {
19 | maskEdit[i] != '#' -> finalResult.append(maskEdit[i])
20 | else -> break@loop
21 | }
22 | }
23 | return finalResult
24 | }
25 |
26 |
27 | /*
28 | * Set maxLength of editTextPicker.
29 | * {@param maskText} get maskText length and set as a maxLength of editTextPicker
30 | * */
31 | internal fun setLengthEditText(maskText: String): Array =
32 | arrayOf(LengthFilter(maskText.length))
33 |
34 |
35 | /*
36 | * Clear error on editTextPicker
37 | * {@param editTextPicker} used as ref. argument to setError null
38 | * */
39 | internal fun clearError(editTextPicker: EditTextPicker) {
40 | editTextPicker.error = null
41 | }
42 |
43 |
44 | /*
45 | * Set filters on editTextPicker
46 | * {@param editTextPicker} as ref. and {@param mask} pass in [setLengthEditText]
47 | * */
48 | internal fun setMaskEditTextLength(editTextPicker: EditTextPicker, mask: String) {
49 | editTextPicker.filters = setLengthEditText(mask)
50 | }
51 |
52 |
53 | /*
54 | * Set predefined text on edittext who also having mask attribute
55 | * {@param mask} and {@param mtext} as predefined text in [setMaskTextOnEditText]
56 | * */
57 | internal fun setMaskTextOnEditText(mask: String, mText: String): String {
58 | var mTextIndex = CONSTANTS.DEFAULT_VALUE_INT
59 | var result = StringUtils.EMPTY
60 | var hashLength = mask.filter { it == CONSTANTS.MASK_HASH }.length
61 | mask.forEachIndexed { index, item ->
62 | if (item == CONSTANTS.MASK_HASH) {
63 | if (hashLength > mText.length) {
64 | result += CONSTANTS.DEFAULT_VALUE_INT.toString()
65 | } else {
66 | result += mText[mTextIndex]
67 | mTextIndex = mTextIndex.inc()
68 | }
69 | hashLength = hashLength.minus(1)
70 | } else result += item
71 | }
72 | return result
73 | }
74 |
75 |
--------------------------------------------------------------------------------
/edittextpicker/src/main/java/com/edittextpicker/aliazaz/utils/EditTextViews.kt:
--------------------------------------------------------------------------------
1 | package com.edittextpicker.aliazaz.utils
2 |
3 | import com.edittextpicker.aliazaz.EditTextPicker
4 |
5 |
6 | /*
7 | * @author Ali Azaz Alam
8 | * */
9 | internal interface EditTextViews {
10 |
11 | fun setMask(mask: String): EditTextPicker
12 |
13 | fun setRequired(required: Boolean): EditTextPicker
14 |
15 | fun setPattern(pattern: String): EditTextPicker
16 |
17 | fun setMinValue(minValue: Float): EditTextPicker
18 |
19 | fun setMaxValue(maxValue: Float): EditTextPicker
20 |
21 | fun setRangeDefaultValue(defaultValue: Float): EditTextPicker
22 |
23 | fun setEqualDefaultValue(defaultValue: String): EditTextPicker
24 |
25 | fun setMaskText(text: String)
26 |
27 | }
--------------------------------------------------------------------------------
/edittextpicker/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/edittextpicker/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | EditTextPicker
3 | Not match with the pattern.
4 | Min value attribute not provided in the layout.
5 | Max value attribute not provided in the layout.
6 | Pattern value attribute not provided in the layout.
7 | Required
8 | The range is from
9 |
10 |
--------------------------------------------------------------------------------
/edittextpicker/src/test/java/com/edittextpicker/aliazaz/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.edittextpicker.aliazaz.textpicker
2 |
3 | import org.junit.Assert
4 | import org.junit.Test
5 |
6 | /**
7 | * Example local unit test, which will execute on the development machine (host).
8 | *
9 | * @see [Testing documentation](http://d.android.com/tools/testing)
10 | */
11 | class ExampleUnitTest {
12 | @Test
13 | fun addition_isCorrect() {
14 | Assert.assertEquals(4, 2 + 2.toLong())
15 | }
16 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | android.enableJetifier=true
10 | android.useAndroidX=true
11 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
12 | # When configured, Gradle will run in incubating parallel mode.
13 | # This option should only be used with decoupled projects. More details, visit
14 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
15 | # org.gradle.parallel=true
16 | # Kotlin code style for this project: "official" or "obsolete":
17 | kotlin.code.style=official
18 |
19 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliAzaz/Edittext-Picker/a2d3232180c649e750326a77e57832f0e17df21c/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Oct 06 12:10:29 PKT 2023
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | gradlePluginPortal()
4 | google()
5 | mavenCentral()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | jcenter() // Warning: this repository is going to shut down soon
14 | maven { url 'https://jitpack.io' }
15 | }
16 | }
17 | include ':app', ':edittextpicker'
18 | rootProject.name = 'Edittext-Picker'
19 |
--------------------------------------------------------------------------------