mirror of
https://codeberg.org/r4v3r23/mysu.git
synced 2024-11-09 20:53:47 +01:00
Add password confirm text field
This commit is contained in:
parent
b7470567da
commit
9c5f5b428a
@ -75,6 +75,16 @@ public class OnboardingFragment extends Fragment {
|
||||
};
|
||||
private EditText walletProxyAddressEditText;
|
||||
private EditText walletProxyPortEditText;
|
||||
private EditText walletPasswordEditText;
|
||||
private EditText walletPasswordConfirmEditText;
|
||||
private EditText walletSeedEditText;
|
||||
private EditText walletRestoreHeightEditText;
|
||||
private Button createWalletButton;
|
||||
private TextView moreOptionsDropdownTextView;
|
||||
private SwitchCompat torSwitch;
|
||||
private ConstraintLayout proxySettingsLayout;
|
||||
private ImageView moreOptionsChevronImageView;
|
||||
private CheckBox seedOffsetCheckbox;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@ -86,22 +96,41 @@ public class OnboardingFragment extends Fragment {
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mViewModel = new ViewModelProvider(this).get(OnboardingViewModel.class);
|
||||
EditText walletPasswordEditText = view.findViewById(R.id.wallet_password_edittext);
|
||||
EditText walletSeedEditText = view.findViewById(R.id.wallet_seed_edittext);
|
||||
EditText walletRestoreHeightEditText = view.findViewById(R.id.wallet_restore_height_edittext);
|
||||
Button createWalletButton = view.findViewById(R.id.create_wallet_button);
|
||||
TextView moreOptionsDropdownTextView = view.findViewById(R.id.advanced_settings_dropdown_textview);
|
||||
ImageView moreOptionsChevronImageView = view.findViewById(R.id.advanced_settings_chevron_imageview);
|
||||
SwitchCompat torSwitch = view.findViewById(R.id.tor_onboarding_switch);
|
||||
ConstraintLayout proxySettingsLayout = view.findViewById(R.id.wallet_proxy_settings_layout);
|
||||
CheckBox seedOffsetCheckbox = view.findViewById(R.id.seed_offset_checkbox);
|
||||
walletPasswordEditText = view.findViewById(R.id.wallet_password_edittext);
|
||||
walletPasswordConfirmEditText = view.findViewById(R.id.wallet_password_confirm_edittext);
|
||||
walletSeedEditText = view.findViewById(R.id.wallet_seed_edittext);
|
||||
walletRestoreHeightEditText = view.findViewById(R.id.wallet_restore_height_edittext);
|
||||
createWalletButton = view.findViewById(R.id.create_wallet_button);
|
||||
moreOptionsDropdownTextView = view.findViewById(R.id.advanced_settings_dropdown_textview);
|
||||
moreOptionsChevronImageView = view.findViewById(R.id.advanced_settings_chevron_imageview);
|
||||
torSwitch = view.findViewById(R.id.tor_onboarding_switch);
|
||||
proxySettingsLayout = view.findViewById(R.id.wallet_proxy_settings_layout);
|
||||
seedOffsetCheckbox = view.findViewById(R.id.seed_offset_checkbox);
|
||||
walletProxyAddressEditText = view.findViewById(R.id.wallet_proxy_address_edittext);
|
||||
walletProxyPortEditText = view.findViewById(R.id.wallet_proxy_port_edittext);
|
||||
seedOffsetCheckbox.setChecked(useOffset);
|
||||
|
||||
bindListeners();
|
||||
bindObservers();
|
||||
}
|
||||
|
||||
private void bindObservers() {
|
||||
mViewModel.showMoreOptions.observe(getViewLifecycleOwner(), show -> {
|
||||
if (show) {
|
||||
moreOptionsChevronImageView.setImageResource(R.drawable.ic_keyboard_arrow_up);
|
||||
walletSeedEditText.setVisibility(View.VISIBLE);
|
||||
walletRestoreHeightEditText.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
moreOptionsChevronImageView.setImageResource(R.drawable.ic_keyboard_arrow_down);
|
||||
walletSeedEditText.setVisibility(View.GONE);
|
||||
walletRestoreHeightEditText.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void bindListeners() {
|
||||
moreOptionsDropdownTextView.setOnClickListener(view12 -> mViewModel.onMoreOptionsClicked());
|
||||
moreOptionsChevronImageView.setOnClickListener(view12 -> mViewModel.onMoreOptionsClicked());
|
||||
|
||||
seedOffsetCheckbox.setOnCheckedChangeListener((compoundButton, b) -> useOffset = b);
|
||||
|
||||
createWalletButton.setOnClickListener(view1 -> {
|
||||
@ -109,11 +138,32 @@ public class OnboardingFragment extends Fragment {
|
||||
((MoneroApplication)getActivity().getApplication()).getExecutor().execute(() -> {
|
||||
createOrImportWallet(
|
||||
walletPasswordEditText.getText().toString(),
|
||||
walletPasswordConfirmEditText.getText().toString(),
|
||||
walletSeedEditText.getText().toString().trim(),
|
||||
walletRestoreHeightEditText.getText().toString().trim()
|
||||
);
|
||||
});
|
||||
});
|
||||
walletPasswordEditText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
String text = editable.toString();
|
||||
if (text.isEmpty()) {
|
||||
walletPasswordConfirmEditText.setText(null);
|
||||
walletPasswordConfirmEditText.setVisibility(View.GONE);
|
||||
} else {
|
||||
walletPasswordConfirmEditText.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
walletSeedEditText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
@ -155,29 +205,21 @@ public class OnboardingFragment extends Fragment {
|
||||
|
||||
mViewModel.updateProxy(((MoneroApplication)getActivity().getApplication()));
|
||||
});
|
||||
|
||||
mViewModel.showMoreOptions.observe(getViewLifecycleOwner(), show -> {
|
||||
if (show) {
|
||||
moreOptionsChevronImageView.setImageResource(R.drawable.ic_keyboard_arrow_up);
|
||||
walletSeedEditText.setVisibility(View.VISIBLE);
|
||||
walletRestoreHeightEditText.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
moreOptionsChevronImageView.setImageResource(R.drawable.ic_keyboard_arrow_down);
|
||||
walletSeedEditText.setVisibility(View.GONE);
|
||||
walletRestoreHeightEditText.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void prepareDefaultNode() {
|
||||
PrefService.getInstance().getNode();
|
||||
}
|
||||
|
||||
private void createOrImportWallet(String walletPassword, String walletSeed, String restoreHeightText) {
|
||||
private void createOrImportWallet(String walletPassword, String confirmedPassword, String walletSeed, String restoreHeightText) {
|
||||
String offset = useOffset ? walletPassword : "";
|
||||
MainActivity mainActivity = (MainActivity) getActivity();
|
||||
if (mainActivity != null) {
|
||||
if (!walletPassword.isEmpty()) {
|
||||
if(!walletPassword.equals(confirmedPassword)) {
|
||||
mainActivity.runOnUiThread(() -> Toast.makeText(mainActivity, getString(R.string.invalid_confirmed_password), Toast.LENGTH_SHORT).show());
|
||||
return;
|
||||
}
|
||||
PrefService.getInstance().edit().putBoolean(Constants.PREF_USES_PASSWORD, true).apply();
|
||||
}
|
||||
long restoreHeight = getNewRestoreHeight();
|
||||
|
@ -24,23 +24,38 @@
|
||||
android:id="@+id/wallet_password_edittext"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:background="@drawable/edittext_bg"
|
||||
android:hint="@string/password_optional"
|
||||
android:inputType="textPassword"
|
||||
app:layout_constraintBottom_toTopOf="@id/tor_onboarding_switch"
|
||||
app:layout_constraintBottom_toTopOf="@id/wallet_password_confirm_edittext"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/create_wallet_textview"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/wallet_password_confirm_edittext"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="@drawable/edittext_bg"
|
||||
android:hint="@string/password_confirm"
|
||||
android:inputType="textPassword"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toTopOf="@id/seed_offset_checkbox"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/wallet_password_edittext"
|
||||
tools:visibility="gone" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/seed_offset_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/use_password_as_seed_offset"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/wallet_password_edittext"/>
|
||||
app:layout_constraintTop_toBottomOf="@id/wallet_password_confirm_edittext"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tor_onboarding_switch_label"
|
||||
|
@ -37,6 +37,7 @@
|
||||
<string name="error_creating_tx">Error creating tx</string>
|
||||
<string name="create_wallet">Create wallet</string>
|
||||
<string name="invalid_mnemonic_code">Invalid mnemonic</string>
|
||||
<string name="invalid_confirmed_password">Passwords do not match</string>
|
||||
<string name="copied_to_clipboard">Copied to clipboard</string>
|
||||
<string name="night_mode">Night mode</string>
|
||||
<string name="display_recovery_phrase">Display wallet keys</string>
|
||||
@ -53,6 +54,7 @@
|
||||
<string name="recovery_phrase_optional">Recovery phrase (optional)</string>
|
||||
<string name="restore_height_optional">Restore height (optional)</string>
|
||||
<string name="password_optional">Password (optional)</string>
|
||||
<string name="password_confirm">Confirm password</string>
|
||||
<string name="password">Password</string>
|
||||
<string name="unlock">Unlock</string>
|
||||
<string name="enter_password">Enter password</string>
|
||||
|
Loading…
Reference in New Issue
Block a user