fix: hitting enter on password input continues
This commit is contained in:
parent
1e2a740dae
commit
0225b28fea
2 changed files with 28 additions and 11 deletions
|
@ -14,6 +14,7 @@ import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.view.inputmethod.EditorInfo
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
@ -873,11 +874,9 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
||||||
|
|
||||||
// Inflate the dialog layout
|
// Inflate the dialog layout
|
||||||
val dialogView = LayoutInflater.from(this).inflate(R.layout.dialog_user_agent, null)
|
val dialogView = LayoutInflater.from(this).inflate(R.layout.dialog_user_agent, null)
|
||||||
dialogView.findViewById<TextInputEditText>(R.id.userAgentTextBox)?.hint = "Password"
|
val box = dialogView.findViewById<TextInputEditText>(R.id.userAgentTextBox)
|
||||||
val subtitleTextView = dialogView.findViewById<TextView>(R.id.subtitle)
|
box?.hint = "Password"
|
||||||
subtitleTextView?.visibility = View.VISIBLE
|
box?.setSingleLine()
|
||||||
if (!isExporting)
|
|
||||||
subtitleTextView?.text = "Enter your password to decrypt the file"
|
|
||||||
|
|
||||||
val dialog = AlertDialog.Builder(this, R.style.MyPopup)
|
val dialog = AlertDialog.Builder(this, R.style.MyPopup)
|
||||||
.setTitle("Enter Password")
|
.setTitle("Enter Password")
|
||||||
|
@ -889,12 +888,7 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
||||||
callback(null)
|
callback(null)
|
||||||
}
|
}
|
||||||
.create()
|
.create()
|
||||||
|
fun handleOkAction() {
|
||||||
dialog.window?.setDimAmount(0.8f)
|
|
||||||
dialog.show()
|
|
||||||
|
|
||||||
// Override the positive button here
|
|
||||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
|
||||||
val editText = dialog.findViewById<TextInputEditText>(R.id.userAgentTextBox)
|
val editText = dialog.findViewById<TextInputEditText>(R.id.userAgentTextBox)
|
||||||
if (editText?.text?.isNotBlank() == true) {
|
if (editText?.text?.isNotBlank() == true) {
|
||||||
editText.text?.toString()?.trim()?.toCharArray(password)
|
editText.text?.toString()?.trim()?.toCharArray(password)
|
||||||
|
@ -904,6 +898,28 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
||||||
toast("Password cannot be empty")
|
toast("Password cannot be empty")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
box?.setOnEditorActionListener { _, actionId, _ ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||||
|
handleOkAction()
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val subtitleTextView = dialogView.findViewById<TextView>(R.id.subtitle)
|
||||||
|
subtitleTextView?.visibility = View.VISIBLE
|
||||||
|
if (!isExporting)
|
||||||
|
subtitleTextView?.text = "Enter your password to decrypt the file"
|
||||||
|
|
||||||
|
|
||||||
|
dialog.window?.setDimAmount(0.8f)
|
||||||
|
dialog.show()
|
||||||
|
|
||||||
|
// Override the positive button here
|
||||||
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
|
handleOkAction()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
app:boxCornerRadiusBottomStart="8dp"
|
app:boxCornerRadiusBottomStart="8dp"
|
||||||
app:boxCornerRadiusTopEnd="8dp"
|
app:boxCornerRadiusTopEnd="8dp"
|
||||||
app:boxCornerRadiusTopStart="8dp"
|
app:boxCornerRadiusTopStart="8dp"
|
||||||
|
android:imeOptions="actionDone"
|
||||||
app:hintAnimationEnabled="true" />
|
app:hintAnimationEnabled="true" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue