├── .gitignore
├── .idea
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── runConfigurations.xml
└── vcs.xml
├── LICENSE
├── README.md
├── androidotpview2
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── poonam
│ │ └── androidotpview2
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── poonam
│ │ │ └── androidotpview2
│ │ │ ├── OtpView.kt
│ │ │ └── helpers
│ │ │ └── GeneralHelper.kt
│ └── res
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── poonam
│ └── androidotpview2
│ └── ExampleUnitTest.java
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── poonam
│ │ └── androidotpview
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── poonam
│ │ │ └── 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_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── poonam
│ └── androidotpview
│ └── ExampleUnitTest.kt
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── otpViewSpecSpaces.gif
├── otpViewWdDash.gif
├── otpVw.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | AccessibilityLintAndroid
12 |
13 |
14 | Android
15 |
16 |
17 | Chrome OSCorrectnessLintAndroid
18 |
19 |
20 | Concurrency annotation issuesJava
21 |
22 |
23 | CorrectnessLintAndroid
24 |
25 |
26 | Data flow issuesJava
27 |
28 |
29 | Groovy
30 |
31 |
32 | IconsUsabilityLintAndroid
33 |
34 |
35 | Initialization issuesJava
36 |
37 |
38 | InternationalizationLintAndroid
39 |
40 |
41 | Java
42 |
43 |
44 | LintAndroid
45 |
46 |
47 | MessagesCorrectnessLintAndroid
48 |
49 |
50 | PerformanceLintAndroid
51 |
52 |
53 | SecurityLintAndroid
54 |
55 |
56 | Serialization issuesJava
57 |
58 |
59 | Threading issuesGroovy
60 |
61 |
62 | Threading issuesJava
63 |
64 |
65 | TypographyUsabilityLintAndroid
66 |
67 |
68 | UsabilityLintAndroid
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Poonam Parth
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 | # AndroidOtpView (With gradient color in lines)
2 | [](https://jitpack.io/#chaya222/AndroidOtpView)
3 | []()
4 | [](https://android-arsenal.com/api?level=16)
5 |
6 | ## Preview
7 |
8 |
9 |
10 |
11 |
12 | Otp View library for Android
13 |
14 | ## Getting started
15 | Add it in your root build.gradle at the end of repositories:
16 |
17 | allprojects {
18 | repositories {
19 | ...
20 | maven { url 'https://jitpack.io' }
21 | }
22 | }
23 |
24 | Step 2. Add the dependency
25 |
26 | dependencies {
27 | implementation 'com.github.chaya222:AndroidOtpView:0.0.2'
28 | }
29 |
30 | ## How to use the library?
31 | Okay seems like you integrated the library in your project but **how do you use it**? Well its really easy just add the following to your xml design to show the otpview
32 |
33 | 1) With Dash between lines
34 |
35 | ```xml
36 | .....
37 |
46 | .....
47 | ```
48 |
49 | 2) Without Dash between lines
50 |
51 | ```xml
52 | .....
53 |
61 | .....
62 | ```
63 | 3) Specific length of spaces (if not provided by default space will be equal to line length)
64 |
65 | ```xml
66 | .....
67 |
76 | .....
77 | ```
78 |
79 |
80 |
81 |
82 | ## Contribution
83 |
84 | If you are interested to contribute, feel free to send pull requests or issues.
85 |
86 | **Note:** All your pull requests should be written in kotlin
87 |
88 | ## Questions?
89 | Hit me on twitter [](https://twitter.com/parth_poonam)
90 |
91 | ## License
92 |
93 | MIT License
94 |
95 | Copyright (c) 2019 Poonam Parth
96 |
97 | Permission is hereby granted, free of charge, to any person obtaining a copy
98 | of this software and associated documentation files (the "Software"), to deal
99 | in the Software without restriction, including without limitation the rights
100 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
101 | copies of the Software, and to permit persons to whom the Software is
102 | furnished to do so, subject to the following conditions:
103 |
104 | The above copyright notice and this permission notice shall be included in all
105 | copies or substantial portions of the Software.
106 |
107 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
108 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
109 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
110 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
111 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
112 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
113 | SOFTWARE.
114 |
--------------------------------------------------------------------------------
/androidotpview2/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/androidotpview2/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android-extensions'
3 | apply plugin: 'kotlin-android'
4 |
5 | android {
6 | compileSdkVersion 28
7 |
8 |
9 | defaultConfig {
10 | minSdkVersion 19
11 | targetSdkVersion 28
12 | versionCode 2
13 | versionName "0.0.2"
14 |
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 |
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | }
27 |
28 | dependencies {
29 | implementation fileTree(dir: 'libs', include: ['*.jar'])
30 |
31 | implementation 'androidx.appcompat:appcompat:1.0.2'
32 | testImplementation 'junit:junit:4.12'
33 | androidTestImplementation 'androidx.test:runner:1.1.1'
34 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
35 | implementation "androidx.core:core-ktx:+"
36 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
37 |
38 | }
39 | repositories {
40 | mavenCentral()
41 | }
42 |
--------------------------------------------------------------------------------
/androidotpview2/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 |
--------------------------------------------------------------------------------
/androidotpview2/src/androidTest/java/com/poonam/androidotpview2/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.poonam.androidotpview2;
2 |
3 | import android.content.Context;
4 | import androidx.test.InstrumentationRegistry;
5 | import androidx.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.poonam.androidotpview2.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/androidotpview2/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/androidotpview2/src/main/java/com/poonam/androidotpview2/OtpView.kt:
--------------------------------------------------------------------------------
1 | package com.poonam.androidotpview2
2 |
3 | import android.content.Context
4 | import android.graphics.*
5 | import android.text.Editable
6 | import android.text.TextWatcher
7 | import android.util.AttributeSet
8 | import android.view.ActionMode
9 | import android.view.Menu
10 | import android.view.MenuItem
11 | import android.view.View
12 | import android.view.inputmethod.InputMethodManager
13 | import androidx.appcompat.app.AppCompatActivity
14 | import androidx.appcompat.widget.AppCompatEditText
15 | import androidx.core.view.ViewCompat
16 | import com.poonam.androidotpview.helpers.fetchColor
17 |
18 |
19 | class OtpView : AppCompatEditText {
20 |
21 | private var mMaxLength = 4
22 | private var mClickListener: View.OnClickListener? = null
23 | private var mLineStroke = 3f
24 | private var mLineStrokeSelected = 4f
25 | private var mLinesPaint: Paint? = null
26 | private var isErrorShown: Boolean = false
27 | private var blink: Blink? = null
28 | private var mCharSize: Float = 0f
29 | private var drawCursor: Boolean = false
30 | private var mLineSpacing = 12f
31 | private var lineEndColor = Color.RED
32 | private var lineStartColor = Color.WHITE
33 | private var dashColor = Color.GRAY
34 | private var lineCountOtp = 4
35 | private var spaceLength = 0f
36 | private var dashLength = 0f
37 | private var showDash = true
38 |
39 | companion object {
40 |
41 | const val XML_NAMESPACE_ANDROID = "http://schemas.android.com/apk/res/android"
42 | }
43 |
44 | constructor(context: Context) : super(context)
45 |
46 | constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0)
47 |
48 |
49 | constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
50 |
51 | init(attrs, defStyleAttr)
52 | }
53 |
54 | private fun convertToPx(v: Float): Float {
55 |
56 | return context.resources.displayMetrics.density * v
57 | }
58 |
59 | private fun init(attrs: AttributeSet, defStyleAttr: Int) {
60 |
61 | initPaintVar()
62 | setAttributes(attrs, defStyleAttr)
63 | initVariousParam(attrs)
64 | disableCopyPaste()
65 |
66 | }
67 |
68 | private fun setAttributes(attrs: AttributeSet, defStyleAttr: Int) {
69 | val theme = context.theme
70 | val typedArray = theme?.obtainStyledAttributes(attrs, R.styleable.OtpView, defStyleAttr, 0)
71 | lineStartColor = typedArray!!.getInt(R.styleable.OtpView_lineStartColor, Color.BLACK)
72 | lineEndColor = typedArray.getInt(R.styleable.OtpView_lineEndColor, Color.RED)
73 | dashColor = typedArray.getInt(R.styleable.OtpView_dashColor, Color.GRAY)
74 | lineCountOtp = typedArray.getInt(R.styleable.OtpView_lineCount, 4)
75 | dashLength = typedArray.getFloat(R.styleable.OtpView_dashLength, 0f)
76 | spaceLength = typedArray.getFloat(R.styleable.OtpView_spaceLength, 0f)
77 | showDash = typedArray.getBoolean(R.styleable.OtpView_showDash, true)
78 | typedArray.recycle()
79 |
80 | }
81 |
82 |
83 | override fun setOnClickListener(l: View.OnClickListener?) {
84 |
85 | mClickListener = l
86 | }
87 |
88 | override fun setOnTouchListener(l: OnTouchListener?) {
89 | super.setOnTouchListener(l)
90 | clearError()
91 | }
92 |
93 | override fun setCustomSelectionActionModeCallback(actionModeCallback: ActionMode.Callback) {
94 |
95 | throw RuntimeException("setCustomSelectionActionModeCallback() not supported.")
96 | }
97 |
98 | override fun onDraw(canvas: Canvas) {
99 |
100 | drawLines(canvas)
101 | }
102 |
103 | private fun updateColorForLines(i: Int, next: Int, x1: Float, y1: Float, x2: Float, y2: Float) {
104 |
105 | if (isErrorShown) {
106 |
107 | mLinesPaint!!.strokeWidth = mLineStrokeSelected
108 | mLinesPaint!!.color = context.fetchColor(R.color.colorAccent)
109 | mLinesPaint!!.shader = null
110 |
111 | } else
112 |
113 | // if pos is selected or less then that
114 | if (next < 0 || i == 0) {
115 | mLinesPaint!!.strokeWidth = mLineStrokeSelected
116 | mLinesPaint!!.color = context.fetchColor(R.color.white)
117 | mLinesPaint!!.shader =
118 | LinearGradient(x1, y1, x2, y2, lineStartColor, lineEndColor, Shader.TileMode.MIRROR)
119 |
120 | } else {
121 | mLinesPaint!!.strokeWidth = mLineStroke
122 | mLinesPaint!!.shader = null
123 | mLinesPaint!!.color = context.fetchColor(R.color.grey)
124 | }
125 | }
126 |
127 | fun setError() {
128 |
129 | isErrorShown = true
130 | invalidate()
131 | }
132 |
133 | fun clearError() {
134 |
135 | isErrorShown = false
136 | invalidate()
137 | }
138 |
139 | private fun shouldBlink(): Boolean {
140 |
141 | return isFocused
142 | }
143 |
144 | private fun makeBlink() {
145 |
146 | if (shouldBlink()) {
147 | if (blink == null) {
148 | blink = Blink()
149 | }
150 | removeCallbacks(blink)
151 | drawCursor = false
152 | postDelayed(blink, 500)
153 | } else {
154 | if (blink != null) {
155 | removeCallbacks(blink)
156 | }
157 | }
158 | }
159 |
160 |
161 | private fun invalidateCursor(showCursor: Boolean) {
162 |
163 | if (drawCursor != showCursor) {
164 | drawCursor = showCursor
165 | invalidate()
166 | }
167 | }
168 |
169 | private fun drawCursor(canvas: Canvas, x1: Float, y1: Float) {
170 |
171 | if (drawCursor) {
172 | val fm = paint.fontMetrics
173 | val height = fm.descent - fm.ascent + fm.leading
174 | paint.color = context.fetchColor(R.color.black)
175 | paint.strokeWidth = 4f
176 | //canvas.drawLine(cx, cy, cx, cy - mCharSize / 2, paint)
177 | canvas.drawLine(x1, y1, x1, y1 - height, paint)
178 | }
179 | }
180 |
181 | override fun onTextChanged(text: CharSequence, start: Int, lengthBefore: Int, lengthAfter: Int) {
182 |
183 | if (start != text.length) {
184 | moveSelectionToEnd()
185 | }
186 | makeBlink()
187 |
188 | }
189 |
190 |
191 | override fun onSelectionChanged(selStart: Int, selEnd: Int) {
192 |
193 | super.onSelectionChanged(selStart, selEnd)
194 | if (text != null && selEnd != text!!.length) {
195 | moveSelectionToEnd()
196 | }
197 | }
198 |
199 | private fun moveSelectionToEnd() {
200 |
201 | if (text != null) {
202 | setSelection(text!!.length)
203 | }
204 | }
205 |
206 |
207 | override fun onFocusChanged(focused: Boolean, direction: Int, previouslyFocusedRect: Rect?) {
208 |
209 | super.onFocusChanged(focused, direction, previouslyFocusedRect)
210 | if (focused) {
211 | moveSelectionToEnd()
212 | makeBlink()
213 | }
214 | }
215 |
216 |
217 | private fun drawDash(canvas: Canvas, x: Float, y: Float, width: Float) {
218 | if (showDash) {
219 | mLinesPaint!!.strokeWidth = 5f
220 | mLinesPaint!!.color = dashColor
221 | mLinesPaint!!.shader = null
222 | val fm = paint.fontMetrics
223 | val height = fm.descent - fm.ascent + fm.leading
224 | if (dashLength == 0f)
225 | canvas.drawLine(x, y - height / 2, x + width / 2, y - height / 2, mLinesPaint)
226 | else
227 | canvas.drawLine(x, y - height / 2, x + dashLength, y - height / 2, mLinesPaint)
228 | }
229 | }
230 |
231 |
232 | private fun disableCopyPaste() {
233 |
234 | //Disable copy paste
235 | super.setCustomSelectionActionModeCallback(object : ActionMode.Callback {
236 | override fun onPrepareActionMode(mode: ActionMode, menu: Menu): Boolean {
237 | return false
238 | }
239 |
240 | override fun onDestroyActionMode(mode: ActionMode) {}
241 |
242 | override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
243 | return false
244 | }
245 |
246 | override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
247 | return false
248 | }
249 | })
250 |
251 | super.addTextChangedListener(object : TextWatcher {
252 | override fun afterTextChanged(s: Editable?) {
253 |
254 | }
255 |
256 | override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
257 |
258 | }
259 |
260 | override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
261 | if( s.toString().length == lineCountOtp ){
262 | (context.getSystemService(AppCompatActivity.INPUT_METHOD_SERVICE) as InputMethodManager)
263 | .hideSoftInputFromWindow(windowToken, 0)
264 | }
265 | }
266 | })
267 |
268 | // When tapped, move cursor to end
269 | super.setOnClickListener { v ->
270 | setSelection(text!!.length)
271 | if (mClickListener != null) {
272 | mClickListener!!.onClick(v)
273 | }
274 | }
275 |
276 | super.setCursorVisible(false)
277 | setTextIsSelectable(false)
278 |
279 | }
280 |
281 |
282 | private fun initPaintVar() {
283 |
284 | mLineStroke = convertToPx(mLineStroke)
285 | mLineStrokeSelected = convertToPx(mLineStrokeSelected)
286 | mLinesPaint = Paint(paint)
287 | mLinesPaint!!.strokeWidth = mLineStroke
288 | setHintTextColor(context.fetchColor(R.color.black))
289 | }
290 |
291 | private fun initVariousParam(attrs: AttributeSet) {
292 |
293 | setBackgroundResource(0)
294 | mLineSpacing = convertToPx(mLineSpacing)
295 | mMaxLength = attrs.getAttributeIntValue(XML_NAMESPACE_ANDROID, "maxLength", 4)
296 | }
297 |
298 | private fun drawLines(canvas: Canvas) {
299 |
300 | val availableWidth = width
301 |
302 | if (spaceLength <= 0) {
303 | mCharSize = availableWidth / (lineCountOtp.toFloat() * 2 - 1)
304 | } else {
305 | mCharSize = (availableWidth.minus(spaceLength * lineCountOtp.minus(1))) / lineCountOtp.toFloat()
306 | }
307 |
308 | var startX = paddingLeft
309 | val bottom = height
310 |
311 | //Text Width
312 | val text = text
313 | val textLength = text!!.length
314 | val textWidths = FloatArray(textLength)
315 | paint.getTextWidths(getText(), 0, textLength, textWidths)
316 | val fm = paint.fontMetrics
317 | val heightTxt = fm.descent - fm.ascent + fm.leading
318 |
319 | var i = 0
320 | while (i < lineCountOtp) {
321 | canvas.save()
322 | if (i == textLength) {
323 | drawCursor(canvas, startX.toFloat() + mCharSize / 2, bottom.toFloat() - mLineSpacing)
324 | }
325 |
326 | updateColorForLines(
327 | i,
328 | i.minus(textLength),
329 | startX.toFloat(),
330 | bottom.toFloat(),
331 | startX.toFloat() + mCharSize,
332 | bottom.toFloat()
333 | )
334 | canvas.drawLine(startX.toFloat(), bottom.toFloat(), startX + mCharSize, bottom.toFloat(), mLinesPaint!!)
335 |
336 | if (getText()!!.length > i) {
337 | val middle = startX + mCharSize / 2
338 | canvas.drawText(text, i, i + 1, middle - textWidths[0] / 2, bottom - mLineSpacing - heightTxt / 4, paint)
339 | }
340 |
341 | if (i + 1 <= lineCountOtp - 1) {
342 | if (spaceLength > 0)
343 | drawDash(canvas, startX + mCharSize + spaceLength / 2, bottom - mLineSpacing, mCharSize * 3 / 10)
344 | else
345 | drawDash(canvas, startX + mCharSize + mCharSize / 2, bottom - mLineSpacing, mCharSize * 3 / 10)
346 | startX += if (spaceLength <= 0f) {
347 | (mCharSize * 2).toInt()
348 | } else {
349 | (mCharSize + spaceLength).toInt()
350 | }
351 | }
352 | i++
353 | canvas.restore()
354 | }
355 | }
356 |
357 |
358 | private inner class Blink : Runnable {
359 |
360 | private var cancelled: Boolean = false
361 |
362 | override fun run() {
363 | if (cancelled) {
364 | return
365 | }
366 | removeCallbacks(this)
367 | if (shouldBlink()) {
368 | invalidateCursor(!drawCursor)
369 | postDelayed(this, 500)
370 | }
371 | }
372 | }
373 |
374 | override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
375 | val widthMode = View.MeasureSpec.getMode(widthMeasureSpec)
376 | val heightMode = View.MeasureSpec.getMode(heightMeasureSpec)
377 | val widthSize = View.MeasureSpec.getSize(widthMeasureSpec)
378 | val heightSize = View.MeasureSpec.getSize(heightMeasureSpec)
379 | val width: Int
380 | val height: Int
381 | val fm = paint.fontMetrics
382 |
383 | val boxHeight = fm.descent - fm.ascent + fm.leading + mLineSpacing
384 | if (widthMode == View.MeasureSpec.EXACTLY) {
385 | width = widthSize
386 | } else {
387 | var boxesWidth = 0
388 | if(spaceLength > 0)
389 | boxesWidth = ((lineCountOtp - 1) * spaceLength + lineCountOtp * 80).toInt()
390 | else
391 | boxesWidth = ((2*lineCountOtp - 1) * 80).toInt()
392 | width = boxesWidth + ViewCompat.getPaddingEnd(this) + ViewCompat.getPaddingStart(this)
393 | }
394 | height = if (heightMode == View.MeasureSpec.EXACTLY)
395 | heightSize
396 | else
397 | (boxHeight + paddingTop + paddingBottom).toInt()
398 | setMeasuredDimension(width, height)
399 | }
400 |
401 |
402 | }
403 |
--------------------------------------------------------------------------------
/androidotpview2/src/main/java/com/poonam/androidotpview2/helpers/GeneralHelper.kt:
--------------------------------------------------------------------------------
1 | package com.poonam.androidotpview.helpers
2 |
3 | import android.content.Context
4 | import androidx.core.content.ContextCompat
5 |
6 | fun Context.fetchColor(id : Int) : Int = ContextCompat.getColor(this,id)
--------------------------------------------------------------------------------
/androidotpview2/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/androidotpview2/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
8 | #66ff99
9 | #009933
10 | #FFFFFF
11 | #D3D3D3
12 | #d0021b
13 | #000000
14 | #80000000
15 |
16 |
17 |
--------------------------------------------------------------------------------
/androidotpview2/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AndroidOtpView
3 |
4 |
--------------------------------------------------------------------------------
/androidotpview2/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/androidotpview2/src/test/java/com/poonam/androidotpview2/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.poonam.androidotpview2;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 |
5 | apply plugin: 'kotlin-android-extensions'
6 |
7 | android {
8 | compileSdkVersion 28
9 | defaultConfig {
10 | applicationId "com.poonam.androidotpview"
11 | minSdkVersion 19
12 | targetSdkVersion 28
13 | versionCode 2
14 | versionName "0.0.2"
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(dir: 'libs', include: ['*.jar'])
27 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
28 | implementation 'androidx.appcompat:appcompat:1.0.2'
29 | implementation 'androidx.core:core-ktx:1.0.1'
30 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
31 | testImplementation 'junit:junit:4.12'
32 | androidTestImplementation 'androidx.test:runner:1.1.1'
33 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
34 | /*implementation "com.github.chaya222:AndroidOtpView:0.0.1"*/
35 |
36 | implementation project(':androidotpview2')
37 | }
38 |
--------------------------------------------------------------------------------
/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/poonam/androidotpview/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.poonam.androidotpview
2 |
3 | import androidx.test.InstrumentationRegistry
4 | import androidx.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("com.poonam.androidotpview", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/poonam/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.poonam
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 | import android.text.Editable
6 | import android.text.TextWatcher
7 | import android.widget.Toast
8 | import com.poonam.androidotpview.R
9 | import kotlinx.android.synthetic.main.activity_main.*
10 |
11 | class MainActivity : AppCompatActivity() {
12 |
13 | override fun onCreate(savedInstanceState: Bundle?) {
14 | super.onCreate(savedInstanceState)
15 | setContentView(R.layout.activity_main)
16 |
17 |
18 | // otpView.addTextChangedListener(object : TextWatcher {
19 | // override fun afterTextChanged(s: Editable?) {
20 | // }
21 | //
22 | // override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
23 | // }
24 | //
25 | // override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
26 | // otpView.clearError()
27 | // if(s.toString().length == 6){
28 | // Toast.makeText(this@MainActivity,"hey this is otp :"+s.toString(),Toast.LENGTH_SHORT).show()
29 | // }
30 | // }
31 | // })
32 | //
33 |
34 | }
35 |
36 |
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/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 |
8 |
10 |
12 |
14 |
16 |
18 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
75 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
20 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/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/poonam-parth-zz/AndroidOtpView/1eeedaae3152cb6e04603c866d182b8647e50fef/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/poonam-parth-zz/AndroidOtpView/1eeedaae3152cb6e04603c866d182b8647e50fef/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/poonam-parth-zz/AndroidOtpView/1eeedaae3152cb6e04603c866d182b8647e50fef/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/poonam-parth-zz/AndroidOtpView/1eeedaae3152cb6e04603c866d182b8647e50fef/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/poonam-parth-zz/AndroidOtpView/1eeedaae3152cb6e04603c866d182b8647e50fef/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/poonam-parth-zz/AndroidOtpView/1eeedaae3152cb6e04603c866d182b8647e50fef/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/poonam-parth-zz/AndroidOtpView/1eeedaae3152cb6e04603c866d182b8647e50fef/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/poonam-parth-zz/AndroidOtpView/1eeedaae3152cb6e04603c866d182b8647e50fef/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/poonam-parth-zz/AndroidOtpView/1eeedaae3152cb6e04603c866d182b8647e50fef/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/poonam-parth-zz/AndroidOtpView/1eeedaae3152cb6e04603c866d182b8647e50fef/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
8 | #66ff99
9 | #009933
10 | #FFFFFF
11 | #D3D3D3
12 | #d0021b
13 | #000000
14 | #80000000
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AndroidOtpView
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/poonam/androidotpview/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.poonam.androidotpview
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | ext {
2 | var = '0.0.1'
3 | }// Top-level build file where you can add configuration options common to all sub-projects/modules.
4 |
5 | buildscript {
6 | ext.kotlin_version = '1.3.31'
7 | ext.kotlin_version = '1.3.21'
8 | repositories {
9 | google()
10 | jcenter()
11 |
12 | }
13 | dependencies {
14 | classpath 'com.android.tools.build:gradle:3.4.0'
15 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
16 | // NOTE: Do not place your application dependencies here; they belong
17 | // in the individual module build.gradle files
18 | }
19 | }
20 |
21 | allprojects {
22 | repositories {
23 | google()
24 | jcenter()
25 |
26 | }
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/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 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
22 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/poonam-parth-zz/AndroidOtpView/1eeedaae3152cb6e04603c866d182b8647e50fef/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Apr 28 18:31:19 IST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env 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 |
--------------------------------------------------------------------------------
/otpViewSpecSpaces.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/poonam-parth-zz/AndroidOtpView/1eeedaae3152cb6e04603c866d182b8647e50fef/otpViewSpecSpaces.gif
--------------------------------------------------------------------------------
/otpViewWdDash.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/poonam-parth-zz/AndroidOtpView/1eeedaae3152cb6e04603c866d182b8647e50fef/otpViewWdDash.gif
--------------------------------------------------------------------------------
/otpVw.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/poonam-parth-zz/AndroidOtpView/1eeedaae3152cb6e04603c866d182b8647e50fef/otpVw.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':androidotpview2'
2 |
--------------------------------------------------------------------------------