Skip to content

Commit

Permalink
Create backup password copy fix #429. Wallet restore password entry C…
Browse files Browse the repository at this point in the history
…TA button enabled/disabled fix #474. Settings and backup settings screen backup state display fix #509.
  • Loading branch information
kukabi committed Jul 27, 2020
1 parent e39a42f commit f420008
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,16 @@ internal class BackupManager(
if (!backupStorage.hasBackupForDate(backupDate)) {
throw BackupStorageTamperedException("Backup storage is tampered.")
}
if (sharedPrefs.scheduledBackupDate?.isAfterNow == true) {
EventBus.postBackupState(BackupScheduled)
} else {
EventBus.postBackupState(BackupUpToDate)
when {
sharedPrefs.backupFailureDate != null -> {
EventBus.postBackupState(BackupOutOfDate())
}
sharedPrefs.scheduledBackupDate?.isAfterNow == true -> {
EventBus.postBackupState(BackupScheduled)
}
else -> {
EventBus.postBackupState(BackupUpToDate)
}
}
} catch (e: BackupStorageAuthRevokedException) {
sharedPrefs.lastSuccessfulBackupDate = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,8 @@ internal class HomeActivity : AppCompatActivity(),
*/
private fun onStoreButtonClicked(view: View) {
UiUtil.temporarilyDisableClick(view)
showTTLStoreDialog()
// showTTLStoreDialog()
backupManager.scheduleBackup(delayMs = 10000)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ framework for UI tree rebuild on configuration changes"""
private fun showAuthFailedDialog() {
ErrorDialog(
requireContext(),
title = string(back_up_wallet_storage_setup_error_title),
title = string(restore_wallet_error_title),
description = string(back_up_wallet_storage_setup_error_desc)
).show()
}

private fun showBackupFileNotFoundDialog() {
ErrorDialog(
requireContext(),
title = string(back_up_wallet_storage_setup_error_title),
title = string(restore_wallet_error_title),
description = string(restore_wallet_error_file_not_found),
onClose = {
requireActivity().onBackPressed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
package com.tari.android.wallet.ui.fragment.restore

import android.content.Context
import android.graphics.Color
import android.os.Bundle
import android.text.SpannableString
import android.text.SpannableStringBuilder
Expand Down Expand Up @@ -90,10 +91,10 @@ UI tree rebuild on configuration changes"""

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setupUi()
setupUI()
}

private fun setupUi() {
private fun setupUI() {
requireActivity().onBackPressedDispatcher
.addCallback(viewLifecycleOwner, blockingBackPressDispatcher)
setPageDescription()
Expand All @@ -108,19 +109,30 @@ UI tree rebuild on configuration changes"""
}
}
)
setRestoreWalletCTAState(isEnabled = false)
ui.restoreWalletCtaView.setOnClickListener {
showRestoringUI()
performRestoration(ui.passwordEditText.text!!.toString())
}
ui.passwordEditText.addTextChangedListener(
afterTextChanged = {
setRestoreWalletCTAState(it?.length ?: 0 != 0)
ui.enterPasswordLabelTextView.setTextColor(color(black))
ui.passwordEditText.setTextColor(color(black))
ui.wrongPasswordLabelView.gone()
}
)
}

private fun setRestoreWalletCTAState(isEnabled: Boolean) {
if (ui.restoreWalletCtaView.isEnabled == isEnabled) return
ui.restoreWalletCtaView.isEnabled = isEnabled
ui.restoreWalletTextView.setTextColor(
if (isEnabled) Color.WHITE
else color(seed_phrase_button_disabled_text_color)
)
}

private fun showRestoringUI() {
blockingBackPressDispatcher.isEnabled = true
ui.passwordEditText.isEnabled = false
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@
<string name="restore_with_cloud_page_title">Enter your backup password</string>

<!--Change password-->
<string name="change_password_enter_password_label">Create Password</string>
<string name="change_password_enter_password_label">Create a Password</string>
<string name="change_password_enter_password_hint">Make it a strong one!</string>
<string name="change_password_confirm_password_label">Confirm Password</string>
<string name="change_password_confirm_password_hint">Let’s see it again</string>
Expand Down

0 comments on commit f420008

Please sign in to comment.