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
@@ -1343,13 +1343,6 @@ class MainActivity : AppCompatActivity() {
} }
val input = layout.findViewById(R.id.password) as EditText val input = layout.findViewById(R.id.password) as EditText
input.requestFocus() 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 context = this
val builder = AlertDialog.Builder(this, R.style.AlertDialog) val builder = AlertDialog.Builder(this, R.style.AlertDialog)
with(builder) { with(builder) {
@@ -1399,13 +1392,6 @@ class MainActivity : AppCompatActivity() {
messageView.text = message messageView.text = message
val input = layout.findViewById(R.id.password) as EditText val input = layout.findViewById(R.id.password) as EditText
input.requestFocus() 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 context = this
val builder = AlertDialog.Builder(this, R.style.AlertDialog) val builder = AlertDialog.Builder(this, R.style.AlertDialog)
with(builder) { with(builder) {
+41 -38
View File
@@ -1,50 +1,53 @@
<?xml version="1.0" encoding="utf-8"?> <?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_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent">
android:orientation="vertical" >
<TextView <LinearLayout
android:id="@+id/title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="?dialogPreferredPadding" android:gravity="center"
android:textSize="20sp" android:isScrollContainer="true"
android:textColor="@color/colorWhite" android:orientation="vertical" >
android:background="@color/colorPrimary" />
<TextView <TextView
android:id="@+id/message" android:id="@+id/title"
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"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:importantForAutofill="no" android:padding="?dialogPreferredPadding"
android:hint="@string/password" android:textSize="20sp"
android:imeOptions="actionDone" android:textColor="@color/colorWhite"
android:inputType="textPassword" /> android:background="@color/colorPrimary" />
<CheckBox <TextView
android:id="@+id/checkbox" android:id="@+id/message"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/show_password" android:paddingTop="15dp"
android:checked="false"/> 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>