Improved password dialog

This commit is contained in:
Juha Heinanen
2021-05-10 09:57:49 +03:00
parent 42f1ad42e8
commit f0a900af8b
2 changed files with 41 additions and 52 deletions

View File

@ -1343,13 +1343,6 @@ class MainActivity : AppCompatActivity() {
}
val input = layout.findViewById(R.id.password) as EditText
input.requestFocus()
val checkBox = layout.findViewById(R.id.checkbox) as CheckBox
checkBox.setOnCheckedChangeListener { _, isChecked ->
if (isChecked)
input.transformationMethod = HideReturnsTransformationMethod()
else
input.transformationMethod = PasswordTransformationMethod()
}
val context = this
val builder = AlertDialog.Builder(this, R.style.AlertDialog)
with(builder) {
@ -1399,13 +1392,6 @@ class MainActivity : AppCompatActivity() {
messageView.text = message
val input = layout.findViewById(R.id.password) as EditText
input.requestFocus()
val checkBox = layout.findViewById(R.id.checkbox) as CheckBox
checkBox.setOnCheckedChangeListener { _, isChecked ->
if (isChecked)
input.transformationMethod = HideReturnsTransformationMethod()
else
input.transformationMethod = PasswordTransformationMethod()
}
val context = this
val builder = AlertDialog.Builder(this, R.style.AlertDialog)
with(builder) {

View File

@ -1,50 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
android:layout_height="match_parent">
<TextView
android:id="@+id/title"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="?dialogPreferredPadding"
android:textSize="20sp"
android:textColor="@color/colorWhite"
android:background="@color/colorPrimary" />
android:gravity="center"
android:isScrollContainer="true"
android:orientation="vertical" >
<TextView
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:paddingTop="20dp"
android:paddingStart="?dialogPreferredPadding"
android:paddingEnd="?dialogPreferredPadding" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:paddingStart="?dialogPreferredPadding"
android:paddingEnd="?dialogPreferredPadding" >
<EditText
android:id="@+id/password"
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"
android:hint="@string/password"
android:imeOptions="actionDone"
android:inputType="textPassword" />
android:padding="?dialogPreferredPadding"
android:textSize="20sp"
android:textColor="@color/colorWhite"
android:background="@color/colorPrimary" />
<CheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
<TextView
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/show_password"
android:checked="false"/>
android:paddingTop="15dp"
android:textSize="15sp"
android:paddingStart="?dialogPreferredPadding"
android:paddingEnd="?dialogPreferredPadding" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="?dialogPreferredPadding"
android:paddingEnd="?dialogPreferredPadding"
app:hintEnabled="false"
app:endIconMode="password_toggle">
</LinearLayout>
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone|flagNoExtractUi"
android:inputType="textPassword"
android:maxLines="1">
</androidx.appcompat.widget.AppCompatEditText>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</ScrollView>