-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adds support for hidden input types (#58)
- Loading branch information
Showing
13 changed files
with
106 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
lib/src/main/java/com/basistheory/android/model/InputType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.basistheory.android.model | ||
|
||
import android.text.InputType as AndroidInputType | ||
|
||
enum class InputType(val androidInputType: Int, val isConcealed: Boolean = false) { | ||
TEXT(AndroidInputType.TYPE_CLASS_TEXT), | ||
NUMBER(AndroidInputType.TYPE_CLASS_NUMBER), | ||
TEXT_PASSWORD(AndroidInputType.TYPE_TEXT_VARIATION_PASSWORD, true), | ||
NUMBER_PASSWORD(AndroidInputType.TYPE_CLASS_NUMBER, true); | ||
} |
14 changes: 0 additions & 14 deletions
14
lib/src/main/java/com/basistheory/android/model/KeyboardType.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
lib/src/main/java/com/basistheory/android/view/method/FullyHiddenTransformationMethod.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.basistheory.android.view.method | ||
|
||
import android.text.method.PasswordTransformationMethod | ||
import android.view.View | ||
|
||
/** | ||
* Customizes PasswordTransformationMethod to also hide the current character while typing | ||
*/ | ||
internal class FullyHiddenTransformationMethod : PasswordTransformationMethod() { | ||
|
||
override fun getTransformation(charSequence: CharSequence, view: View): CharSequence { | ||
return FullyHiddenCharSequence(charSequence) | ||
} | ||
|
||
private inner class FullyHiddenCharSequence(private val charSequence: CharSequence) : CharSequence { | ||
private val dot = '\u2022' | ||
|
||
override val length: Int | ||
get() = charSequence.length | ||
|
||
override fun get(index: Int): Char = dot | ||
|
||
override fun subSequence(startIndex: Int, endIndex: Int): CharSequence = | ||
FullyHiddenCharSequence(charSequence.subSequence(startIndex, endIndex)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters