Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup android editable to android inputType to use valid phone number #1002

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/src/main/java/com/hover/stax/views/StaxDropdownLayout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ open class StaxDropdownLayout(context: Context, attrs: AttributeSet) : AbstractS
lateinit var autoCompleteTextView: AutoCompleteTextView
private var hint: String? = null
private var defaultText: String? = null
private var editable = false
private var inputType:String? = null
private var imeOptions = 0

@CallSuper
Expand All @@ -43,7 +43,7 @@ open class StaxDropdownLayout(context: Context, attrs: AttributeSet) : AbstractS
try {
hint = a.getString(R.styleable.StaxDropdownLayout_android_hint)
defaultText = a.getString(R.styleable.StaxDropdownLayout_android_text)
editable = a.getBoolean(R.styleable.StaxDropdownLayout_android_editable, false)
inputType = a.getString(R.styleable.StaxDropdownLayout_android_inputType)
imeOptions = a.getInt(R.styleable.StaxDropdownLayout_android_imeOptions, 0)
} finally {
a.recycle()
Expand All @@ -67,7 +67,7 @@ open class StaxDropdownLayout(context: Context, attrs: AttributeSet) : AbstractS
private fun fillAttrs() {
if (hint != null) (findViewById<View>(R.id.inputLayout) as TextInputLayout).hint = hint
autoCompleteTextView.inputType =
if (editable) InputType.TYPE_TEXT_VARIATION_FILTER else InputType.TYPE_NULL
if (inputType !=null) InputType.TYPE_CLASS_PHONE else InputType.TYPE_NULL
if (!defaultText.isNullOrEmpty()) autoCompleteTextView.setText(
defaultText
)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/contact_input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:editable="true"
android:inputType="phone"
android:hint="@string/recipientphone_label"
tools:layout="@layout/stax_dropdown" />

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/stax_dropdown.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
android:dropDownWidth="wrap_content"
android:dropDownHeight="wrap_content"
android:drawablePadding="@dimen/margin_8"
android:inputType="phone"
android:imeOptions="actionDone"
android:textColor="@color/offWhite"
android:autofillHints="phone"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<declare-styleable name="StaxDropdownLayout">
<attr name="android:hint" />
<attr name="android:editable" />
<attr name="android:inputType" />
<attr name="android:text" />
<attr name="android:imeOptions" />
</declare-styleable>
Expand Down