Rename some view ids

This commit is contained in:
Benoit Marty 2020-12-16 11:10:49 +01:00
parent 9e3eb993ee
commit 018574a21e
11 changed files with 78 additions and 79 deletions

View File

@ -46,8 +46,8 @@ class KeysBackupRestoreFromKeyFragment @Inject constructor()
super.onViewCreated(view, savedInstanceState)
viewModel = fragmentViewModelProvider.get(KeysBackupRestoreFromKeyViewModel::class.java)
sharedViewModel = activityViewModelProvider.get(KeysBackupRestoreSharedViewModel::class.java)
views.mKeyTextEdit.setText(viewModel.recoveryCode.value)
views.mKeyTextEdit.setOnEditorActionListener { _, actionId, _ ->
views.keyTextEdit.setText(viewModel.recoveryCode.value)
views.keyTextEdit.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE) {
onRestoreFromKey()
return@setOnEditorActionListener true
@ -55,14 +55,14 @@ class KeysBackupRestoreFromKeyFragment @Inject constructor()
return@setOnEditorActionListener false
}
views.mKeyInputLayout.error = viewModel.recoveryCodeErrorText.value
views.keyInputLayout.error = viewModel.recoveryCodeErrorText.value
viewModel.recoveryCodeErrorText.observe(viewLifecycleOwner, Observer { newValue ->
views.mKeyInputLayout.error = newValue
views.keyInputLayout.error = newValue
})
views.keysRestoreButton.setOnClickListener { onRestoreFromKey() }
views.keysBackupImport.setOnClickListener { onImport() }
views.mKeyTextEdit.doOnTextChanged { text, _, _, _ -> onRestoreKeyTextEditChange(text) }
views.keyTextEdit.doOnTextChanged { text, _, _, _ -> onRestoreKeyTextEditChange(text) }
}
private fun onRestoreKeyTextEditChange(s: CharSequence?) {
@ -94,8 +94,8 @@ class KeysBackupRestoreFromKeyFragment @Inject constructor()
?.bufferedReader()
?.use { it.readText() }
?.let {
views.mKeyTextEdit.setText(it)
views.mKeyTextEdit.setSelection(it.length)
views.keyTextEdit.setText(it)
views.keyTextEdit.setSelection(it.length)
}
}
}

View File

@ -45,13 +45,13 @@ class KeysBackupRestoreSuccessFragment @Inject constructor() : VectorBaseFragmen
it.totalNumberOfKeys, it.totalNumberOfKeys)
val part2 = resources.getQuantityString(R.plurals.keys_backup_restore_success_description_part2,
it.successfullyNumberOfImportedKeys, it.successfullyNumberOfImportedKeys)
views.mSuccessDetailsText.text = String.format("%s\n%s", part1, part2)
views.successDetailsText.text = String.format("%s\n%s", part1, part2)
}
// We don't put emoji in string xml as it will crash on old devices
views.mSuccessText.text = context?.getString(R.string.keys_backup_restore_success_title, "🎉")
views.successText.text = context?.getString(R.string.keys_backup_restore_success_title, "🎉")
} else {
views.mSuccessText.text = context?.getString(R.string.keys_backup_restore_success_title_already_up_to_date)
views.mSuccessDetailsText.isVisible = false
views.successText.text = context?.getString(R.string.keys_backup_restore_success_title_already_up_to_date)
views.successDetailsText.isVisible = false
}
views.keysBackupSetupDoneButton.setOnClickListener { onDone() }
}

View File

@ -43,12 +43,12 @@ class KeysBackupSetupStep1Fragment @Inject constructor() : VectorBaseFragment<Fr
viewModel.showManualExport.observe(viewLifecycleOwner, Observer {
val showOption = it ?: false
// Can't use isVisible because the kotlin compiler will crash with Back-end (JVM) Internal error: wrong code generated
views.advancedOptionText.visibility = if (showOption) View.VISIBLE else View.GONE
views.manualExportButton.visibility = if (showOption) View.VISIBLE else View.GONE
views.keysBackupSetupStep1AdvancedOptionText.visibility = if (showOption) View.VISIBLE else View.GONE
views.keysBackupSetupStep1ManualExportButton.visibility = if (showOption) View.VISIBLE else View.GONE
})
views.keysBackupSetupStep1Button.setOnClickListener { onButtonClick() }
views.manualExportButton.setOnClickListener { onManualExportClick() }
views.keysBackupSetupStep1ManualExportButton.setOnClickListener { onManualExportClick() }
}
private fun onButtonClick() {

View File

@ -44,12 +44,12 @@ class KeysBackupSetupStep2Fragment @Inject constructor() : VectorBaseFragment<Fr
private val zxcvbn = Zxcvbn()
private fun onPassphraseChanged() {
viewModel.passphrase.value = views.keysBackupPassphraseEnterEdittext.text.toString()
viewModel.passphrase.value = views.keysBackupSetupStep2PassphraseEnterEdittext.text.toString()
viewModel.confirmPassphraseError.value = null
}
private fun onConfirmPassphraseChanged() {
viewModel.confirmPassphrase.value = views.mPassphraseConfirmTextEdit.text.toString()
viewModel.confirmPassphrase.value = views.keysBackupSetupStep2PassphraseConfirmEditText.text.toString()
}
private lateinit var viewModel: KeysBackupSetupSharedViewModel
@ -71,24 +71,24 @@ class KeysBackupSetupStep2Fragment @Inject constructor() : VectorBaseFragment<Fr
private fun bindViewToViewModel() {
viewModel.passwordStrength.observe(viewLifecycleOwner, Observer { strength ->
if (strength == null) {
views.mPassphraseProgressLevel.strength = 0
views.keysBackupPassphraseEnterTil.error = null
views.keysBackupSetupStep2PassphraseStrengthLevel.strength = 0
views.keysBackupSetupStep2PassphraseEnterTil.error = null
} else {
val score = strength.score
views.mPassphraseProgressLevel.strength = score
views.keysBackupSetupStep2PassphraseStrengthLevel.strength = score
if (score in 1..3) {
val warning = strength.feedback?.getWarning(VectorLocale.applicationLocale)
if (warning != null) {
views.keysBackupPassphraseEnterTil.error = warning
views.keysBackupSetupStep2PassphraseEnterTil.error = warning
}
val suggestions = strength.feedback?.getSuggestions(VectorLocale.applicationLocale)
if (suggestions != null) {
views.keysBackupPassphraseEnterTil.error = suggestions.firstOrNull()
views.keysBackupSetupStep2PassphraseEnterTil.error = suggestions.firstOrNull()
}
} else {
views.keysBackupPassphraseEnterTil.error = null
views.keysBackupSetupStep2PassphraseEnterTil.error = null
}
}
})
@ -106,28 +106,28 @@ class KeysBackupSetupStep2Fragment @Inject constructor() : VectorBaseFragment<Fr
}
})
views.keysBackupPassphraseEnterEdittext.setText(viewModel.passphrase.value)
views.keysBackupSetupStep2PassphraseEnterEdittext.setText(viewModel.passphrase.value)
viewModel.passphraseError.observe(viewLifecycleOwner, Observer {
TransitionManager.beginDelayedTransition(views.keysBackupRoot)
views.keysBackupPassphraseEnterTil.error = it
views.keysBackupSetupStep2PassphraseEnterTil.error = it
})
views.mPassphraseConfirmTextEdit.setText(viewModel.confirmPassphrase.value)
views.keysBackupSetupStep2PassphraseConfirmEditText.setText(viewModel.confirmPassphrase.value)
viewModel.showPasswordMode.observe(viewLifecycleOwner, Observer {
val shouldBeVisible = it ?: false
views.keysBackupPassphraseEnterEdittext.showPassword(shouldBeVisible)
views.mPassphraseConfirmTextEdit.showPassword(shouldBeVisible)
views.keysBackupViewShowPassword.setImageResource(if (shouldBeVisible) R.drawable.ic_eye_closed else R.drawable.ic_eye)
views.keysBackupSetupStep2PassphraseEnterEdittext.showPassword(shouldBeVisible)
views.keysBackupSetupStep2PassphraseConfirmEditText.showPassword(shouldBeVisible)
views.keysBackupSetupStep2ShowPassword.setImageResource(if (shouldBeVisible) R.drawable.ic_eye_closed else R.drawable.ic_eye)
})
viewModel.confirmPassphraseError.observe(viewLifecycleOwner, Observer {
TransitionManager.beginDelayedTransition(views.keysBackupRoot)
views.mPassphraseConfirmInputLayout.error = it
views.keysBackupSetupStep2PassphraseConfirmTil.error = it
})
views.mPassphraseConfirmTextEdit.setOnEditorActionListener { _, actionId, _ ->
views.keysBackupSetupStep2PassphraseConfirmEditText.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE) {
doNext()
return@setOnEditorActionListener true
@ -137,12 +137,12 @@ class KeysBackupSetupStep2Fragment @Inject constructor() : VectorBaseFragment<Fr
}
private fun setupViews() {
views.keysBackupViewShowPassword.setOnClickListener { toggleVisibilityMode() }
views.keysBackupSetupStep2ShowPassword.setOnClickListener { toggleVisibilityMode() }
views.keysBackupSetupStep2Button.setOnClickListener { doNext() }
views.keysBackupSetupStep2SkipButton.setOnClickListener { skipPassphrase() }
views.keysBackupPassphraseEnterEdittext.doOnTextChanged { _, _, _, _ -> onPassphraseChanged() }
views.mPassphraseConfirmTextEdit.doOnTextChanged { _, _, _, _ -> onConfirmPassphraseChanged() }
views.keysBackupSetupStep2PassphraseEnterEdittext.doOnTextChanged { _, _, _, _ -> onPassphraseChanged() }
views.keysBackupSetupStep2PassphraseConfirmEditText.doOnTextChanged { _, _, _, _ -> onConfirmPassphraseChanged() }
}
private fun toggleVisibilityMode() {

View File

@ -64,10 +64,10 @@ class KeysBackupSetupStep3Fragment @Inject constructor() : VectorBaseFragment<Fr
viewModel.passphrase.observe(viewLifecycleOwner, Observer {
if (it.isNullOrBlank()) {
// Recovery was generated, so show key and options to save
views.mRecoveryKeyLabel2TextView.text = getString(R.string.keys_backup_setup_step3_text_line2_no_passphrase)
views.mFinishButton.text = getString(R.string.keys_backup_setup_step3_button_title_no_passphrase)
views.keysBackupSetupStep3Label2.text = getString(R.string.keys_backup_setup_step3_text_line2_no_passphrase)
views.keysBackupSetupStep3FinishButton.text = getString(R.string.keys_backup_setup_step3_button_title_no_passphrase)
views.keysBackupRecoveryKeyText.text = viewModel.recoveryKey.value!!
views.keysBackupSetupStep3RecoveryKeyText.text = viewModel.recoveryKey.value!!
.replace(" ", "")
.chunked(16)
.joinToString("\n") {
@ -75,11 +75,11 @@ class KeysBackupSetupStep3Fragment @Inject constructor() : VectorBaseFragment<Fr
.chunked(4)
.joinToString(" ")
}
views.keysBackupRecoveryKeyText.isVisible = true
views.keysBackupSetupStep3RecoveryKeyText.isVisible = true
} else {
views.mRecoveryKeyLabel2TextView.text = getString(R.string.keys_backup_setup_step3_text_line2)
views.mFinishButton.text = getString(R.string.keys_backup_setup_step3_button_title)
views.keysBackupRecoveryKeyText.isVisible = false
views.keysBackupSetupStep3Label2.text = getString(R.string.keys_backup_setup_step3_text_line2)
views.keysBackupSetupStep3FinishButton.text = getString(R.string.keys_backup_setup_step3_button_title)
views.keysBackupSetupStep3RecoveryKeyText.isVisible = false
}
})
@ -87,9 +87,9 @@ class KeysBackupSetupStep3Fragment @Inject constructor() : VectorBaseFragment<Fr
}
private fun setupViews() {
views.mFinishButton.setOnClickListener { onFinishButtonClicked() }
views.keysBackupSetupStep3FinishButton.setOnClickListener { onFinishButtonClicked() }
views.keysBackupSetupStep3CopyButton.setOnClickListener { onCopyButtonClicked() }
views.keysBackupRecoveryKeyText.setOnClickListener { onRecoveryKeyClicked() }
views.keysBackupSetupStep3RecoveryKeyText.setOnClickListener { onRecoveryKeyClicked() }
}
private fun onFinishButtonClicked() {

View File

@ -64,7 +64,7 @@ class ReactionButton @JvmOverloads constructor(context: Context,
@Inject lateinit var emojiCompatWrapper: EmojiCompatWrapper
private lateinit var views: ReactionButtonBinding
private val views: ReactionButtonBinding
var reactedListener: ReactedListener? = null
private var dotPrimaryColor: Int = 0

View File

@ -38,7 +38,7 @@
app:layout_constraintTop_toBottomOf="@+id/keys_backup_shield" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/mKeyInputLayout"
android:id="@+id/key_input_layout"
style="@style/VectorTextInputLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -50,7 +50,7 @@
app:layout_constraintTop_toBottomOf="@+id/keys_restore_with_key">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/mKeyTextEdit"
android:id="@+id/key_text_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/keys_backup_restore_key_enter_hint"
@ -70,8 +70,8 @@
android:scaleType="center"
android:src="@drawable/ic_import_black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/mKeyInputLayout"
app:layout_constraintTop_toTopOf="@id/mKeyInputLayout"
app:layout_constraintStart_toEndOf="@id/key_input_layout"
app:layout_constraintTop_toTopOf="@id/key_input_layout"
app:tint="?attr/colorAccent"
tools:ignore="MissingPrefix" />
@ -85,7 +85,7 @@
android:textColor="?riotx_text_secondary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/mKeyInputLayout" />
app:layout_constraintTop_toBottomOf="@+id/key_input_layout" />
<com.google.android.material.button.MaterialButton
android:id="@+id/keys_restore_button"

View File

@ -19,7 +19,7 @@
tools:ignore="MissingPrefix" />
<TextView
android:id="@+id/mSuccessText"
android:id="@+id/success_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
@ -33,7 +33,7 @@
tools:text="@string/keys_backup_restore_success_title" />
<TextView
android:id="@+id/mSuccessDetailsText"
android:id="@+id/success_details_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
@ -42,7 +42,7 @@
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/mSuccessText"
app:layout_constraintTop_toBottomOf="@+id/success_text"
tools:text="Restored a backup with 34 keys.\n22 new keys have been added to this session." />
<com.google.android.material.button.MaterialButton
@ -53,6 +53,6 @@
android:text="@string/done"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/mSuccessDetailsText" />
app:layout_constraintTop_toBottomOf="@+id/success_details_text" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -8,7 +8,7 @@
tools:context=".features.crypto.keysbackup.setup.KeysBackupSetupStep1Fragment">
<ImageView
android:id="@+id/keys_backup_setup_image"
android:id="@+id/keys_backup_setup_step1_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_vertical_margin"
@ -33,7 +33,7 @@
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/keys_backup_setup_step1_description"
app:layout_constraintTop_toBottomOf="@+id/keys_backup_setup_image"
app:layout_constraintTop_toBottomOf="@+id/keys_backup_setup_step1_image"
app:layout_constraintVertical_chainStyle="packed" />
<TextView
@ -63,7 +63,7 @@
app:layout_constraintTop_toBottomOf="@id/keys_backup_setup_step1_description" />
<TextView
android:id="@+id/advancedOptionText"
android:id="@+id/keys_backup_setup_step1_advanced_option_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/layout_horizontal_margin"
@ -79,7 +79,7 @@
tools:visibility="visible" />
<com.google.android.material.button.MaterialButton
android:id="@+id/manualExportButton"
android:id="@+id/keys_backup_setup_step1_manual_export_button"
style="@style/VectorButtonStyleText"
android:layout_margin="16dp"
android:layout_marginStart="@dimen/layout_horizontal_margin"
@ -91,9 +91,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/advancedOptionText"
app:layout_constraintTop_toBottomOf="@id/keys_backup_setup_step1_advanced_option_text"
app:layout_constraintVertical_bias="0"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -47,19 +47,19 @@
app:layout_constraintTop_toBottomOf="@+id/keys_backup_setup_step2_text_title" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/keys_backup_passphrase_enter_til"
android:id="@+id/keys_backup_setup_step2_passphrase_enter_til"
style="@style/VectorTextInputLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:errorEnabled="true"
app:layout_constraintEnd_toStartOf="@id/keys_backup_view_show_password"
app:layout_constraintEnd_toStartOf="@id/keys_backup_setup_step2_show_password"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/keys_backup_setup_step2_text_description">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/keys_backup_passphrase_enter_edittext"
android:id="@+id/keys_backup_setup_step2_passphrase_enter_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/passphrase_create_passphrase"
@ -69,7 +69,7 @@
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="@+id/keys_backup_view_show_password"
android:id="@+id/keys_backup_setup_step2_show_password"
android:layout_width="@dimen/layout_touch_size"
android:layout_height="@dimen/layout_touch_size"
android:layout_marginTop="8dp"
@ -77,22 +77,22 @@
android:scaleType="center"
android:src="@drawable/ic_eye"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/keys_backup_passphrase_enter_til"
app:layout_constraintTop_toTopOf="@id/keys_backup_passphrase_enter_til"
app:layout_constraintStart_toEndOf="@id/keys_backup_setup_step2_passphrase_enter_til"
app:layout_constraintTop_toTopOf="@id/keys_backup_setup_step2_passphrase_enter_til"
app:tint="?attr/colorAccent"
tools:ignore="MissingPrefix" />
<im.vector.app.core.ui.views.PasswordStrengthBar
android:id="@+id/mPassphraseProgressLevel"
android:id="@+id/keys_backup_setup_step2_passphrase_strength_level"
android:layout_width="0dp"
android:layout_height="4dp"
app:layout_constraintEnd_toEndOf="@id/keys_backup_passphrase_enter_til"
app:layout_constraintStart_toStartOf="@id/keys_backup_passphrase_enter_til"
app:layout_constraintTop_toBottomOf="@id/keys_backup_passphrase_enter_til" />
app:layout_constraintEnd_toEndOf="@id/keys_backup_setup_step2_passphrase_enter_til"
app:layout_constraintStart_toStartOf="@id/keys_backup_setup_step2_passphrase_enter_til"
app:layout_constraintTop_toBottomOf="@id/keys_backup_setup_step2_passphrase_enter_til" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/mPassphraseConfirmInputLayout"
android:id="@+id/keys_backup_setup_step2_passphrase_confirm_til"
style="@style/VectorTextInputLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -100,12 +100,12 @@
android:layout_marginTop="16dp"
android:layout_weight="1"
app:errorEnabled="true"
app:layout_constraintEnd_toStartOf="@id/keys_backup_view_show_password"
app:layout_constraintEnd_toStartOf="@id/keys_backup_setup_step2_show_password"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/mPassphraseProgressLevel">
app:layout_constraintTop_toBottomOf="@id/keys_backup_setup_step2_passphrase_strength_level">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/mPassphraseConfirmTextEdit"
android:id="@+id/keys_backup_setup_step2_passphrase_confirm_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/passphrase_confirm_passphrase"
@ -122,11 +122,11 @@
android:text="@string/keys_backup_setup_step2_button_title"
android:textColor="@android:color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/mPassphraseConfirmInputLayout" />
app:layout_constraintTop_toBottomOf="@id/keys_backup_setup_step2_passphrase_confirm_til" />
<TextView
android:id="@+id/keys_backup_setup_recovery_key_alternative"
android:id="@+id/keys_backup_setup_step2_recovery_key_alternative"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
@ -149,7 +149,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/keys_backup_setup_recovery_key_alternative" />
app:layout_constraintTop_toBottomOf="@id/keys_backup_setup_step2_recovery_key_alternative" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -16,7 +16,7 @@
android:orientation="vertical">
<ImageView
android:id="@+id/keys_backup_setup_image"
android:id="@+id/keys_backup_setup_step3_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
@ -53,7 +53,7 @@
android:textSize="15sp" />
<TextView
android:id="@+id/mRecoveryKeyLabel2TextView"
android:id="@+id/keys_backup_setup_step3_label2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/layout_horizontal_margin"
@ -66,7 +66,7 @@
<TextView
android:id="@+id/keys_backup_recovery_key_text"
android:id="@+id/keys_backup_setup_step3_recovery_key_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/layout_horizontal_margin"
@ -87,7 +87,7 @@
android:text="@string/keys_backup_setup_step3_copy_button_title" />
<com.google.android.material.button.MaterialButton
android:id="@+id/mFinishButton"
android:id="@+id/keys_backup_setup_step3_finish_button"
style="@style/VectorButtonStyle"
android:layout_gravity="center"
android:layout_marginTop="@dimen/layout_vertical_margin"