Remove synthetic view references from 'PasswordPromptDialogFragment'
@@ -6,13 +6,15 @@ import android.app.Dialog
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
+import android.widget.CheckBox
+import android.widget.TextView
import androidx.appcompat.app.AlertDialog
+import androidx.constraintlayout.widget.Group
import androidx.core.os.bundleOf
import androidx.core.view.isGone
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import com.fsck.k9.ui.R
-import kotlinx.android.synthetic.main.password_prompt_dialog.view.*
class PasswordPromptDialogFragment : DialogFragment() {
private lateinit var accountUuid: String
@@ -61,21 +63,25 @@ class PasswordPromptDialogFragment : DialogFragment() {
val layoutInflater = LayoutInflater.from(requireContext())
val view = layoutInflater.inflate(R.layout.password_prompt_dialog, null)
+ val passwordPromptIntro: TextView = view.findViewById(R.id.passwordPromptIntro)
+ val incomingServerNameView: TextView = view.findViewById(R.id.incomingServerName)
+ val outgoingServerNameView: TextView = view.findViewById(R.id.outgoingServerName)
+ val useSamePasswordCheckbox: CheckBox = view.findViewById(R.id.useSamePasswordCheckbox)
+ val incomingServerGroup: Group = view.findViewById(R.id.incomingServerGroup)
+ val outgoingServerGroup: Group = view.findViewById(R.id.outgoingServerGroup)
+
val quantity = if (inputIncomingServerPassword && inputOutgoingServerPassword) 2 else 1
- view.passwordPromptIntro.text = resources.getQuantityString(
+ passwordPromptIntro.text = resources.getQuantityString(
R.plurals.settings_import_password_prompt,
quantity,
accountName
)
- view.incomingServerName.text = getString(R.string.server_name_format, incomingServerName)
- view.outgoingServerName.text = getString(R.string.server_name_format, outgoingServerName)
+ incomingServerNameView.text = getString(R.string.server_name_format, incomingServerName)
+ outgoingServerNameView.text = getString(R.string.server_name_format, outgoingServerName)
- val incomingServerGroup = view.incomingServerGroup
- val outgoingServerGroup = view.outgoingServerGroup
incomingServerGroup.isGone = !inputIncomingServerPassword
outgoingServerGroup.isGone = !inputOutgoingServerPassword
- val useSamePasswordCheckbox = view.useSamePasswordCheckbox
if (inputIncomingServerPassword && inputOutgoingServerPassword) {
useSamePasswordCheckbox.isChecked = true
outgoingServerGroup.isGone = true
@@ -91,14 +97,18 @@ class PasswordPromptDialogFragment : DialogFragment() {
}
private fun deliverPasswordPromptResult() {
+ val incomingServerPasswordView: TextView = dialogView.findViewById(R.id.incomingServerPassword)
+ val outgoingServerPasswordView: TextView = dialogView.findViewById(R.id.outgoingServerPassword)
+ val useSamePasswordCheckbox: CheckBox = dialogView.findViewById(R.id.useSamePasswordCheckbox)
+
val incomingServerPassword = when {
!inputIncomingServerPassword -> null
- else -> dialogView.incomingServerPassword.text.toString()
+ else -> incomingServerPasswordView.text.toString()
}
val outgoingServerPassword = when {
!inputOutgoingServerPassword -> null
- dialogView.useSamePasswordCheckbox.isChecked -> incomingServerPassword
- else -> dialogView.outgoingServerPassword.text.toString()
+ useSamePasswordCheckbox.isChecked -> incomingServerPassword
+ else -> outgoingServerPasswordView.text.toString()
}
val resultIntent = PasswordPromptResult(accountUuid, incomingServerPassword, outgoingServerPassword).asIntent()
