mirror of
https://codeberg.org/r4v3r23/mysu.git
synced 2024-11-14 01:21:54 +00:00
Add password confirm text field
This commit is contained in:
parent
b7470567da
commit
9c5f5b428a
3 changed files with 85 additions and 26 deletions
|
@ -75,6 +75,16 @@ public class OnboardingFragment extends Fragment {
|
||||||
};
|
};
|
||||||
private EditText walletProxyAddressEditText;
|
private EditText walletProxyAddressEditText;
|
||||||
private EditText walletProxyPortEditText;
|
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
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
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) {
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
mViewModel = new ViewModelProvider(this).get(OnboardingViewModel.class);
|
mViewModel = new ViewModelProvider(this).get(OnboardingViewModel.class);
|
||||||
EditText walletPasswordEditText = view.findViewById(R.id.wallet_password_edittext);
|
walletPasswordEditText = view.findViewById(R.id.wallet_password_edittext);
|
||||||
EditText walletSeedEditText = view.findViewById(R.id.wallet_seed_edittext);
|
walletPasswordConfirmEditText = view.findViewById(R.id.wallet_password_confirm_edittext);
|
||||||
EditText walletRestoreHeightEditText = view.findViewById(R.id.wallet_restore_height_edittext);
|
walletSeedEditText = view.findViewById(R.id.wallet_seed_edittext);
|
||||||
Button createWalletButton = view.findViewById(R.id.create_wallet_button);
|
walletRestoreHeightEditText = view.findViewById(R.id.wallet_restore_height_edittext);
|
||||||
TextView moreOptionsDropdownTextView = view.findViewById(R.id.advanced_settings_dropdown_textview);
|
createWalletButton = view.findViewById(R.id.create_wallet_button);
|
||||||
ImageView moreOptionsChevronImageView = view.findViewById(R.id.advanced_settings_chevron_imageview);
|
moreOptionsDropdownTextView = view.findViewById(R.id.advanced_settings_dropdown_textview);
|
||||||
SwitchCompat torSwitch = view.findViewById(R.id.tor_onboarding_switch);
|
moreOptionsChevronImageView = view.findViewById(R.id.advanced_settings_chevron_imageview);
|
||||||
ConstraintLayout proxySettingsLayout = view.findViewById(R.id.wallet_proxy_settings_layout);
|
torSwitch = view.findViewById(R.id.tor_onboarding_switch);
|
||||||
CheckBox seedOffsetCheckbox = view.findViewById(R.id.seed_offset_checkbox);
|
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);
|
walletProxyAddressEditText = view.findViewById(R.id.wallet_proxy_address_edittext);
|
||||||
walletProxyPortEditText = view.findViewById(R.id.wallet_proxy_port_edittext);
|
walletProxyPortEditText = view.findViewById(R.id.wallet_proxy_port_edittext);
|
||||||
seedOffsetCheckbox.setChecked(useOffset);
|
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());
|
moreOptionsDropdownTextView.setOnClickListener(view12 -> mViewModel.onMoreOptionsClicked());
|
||||||
moreOptionsChevronImageView.setOnClickListener(view12 -> mViewModel.onMoreOptionsClicked());
|
moreOptionsChevronImageView.setOnClickListener(view12 -> mViewModel.onMoreOptionsClicked());
|
||||||
|
|
||||||
seedOffsetCheckbox.setOnCheckedChangeListener((compoundButton, b) -> useOffset = b);
|
seedOffsetCheckbox.setOnCheckedChangeListener((compoundButton, b) -> useOffset = b);
|
||||||
|
|
||||||
createWalletButton.setOnClickListener(view1 -> {
|
createWalletButton.setOnClickListener(view1 -> {
|
||||||
|
@ -109,11 +138,32 @@ public class OnboardingFragment extends Fragment {
|
||||||
((MoneroApplication)getActivity().getApplication()).getExecutor().execute(() -> {
|
((MoneroApplication)getActivity().getApplication()).getExecutor().execute(() -> {
|
||||||
createOrImportWallet(
|
createOrImportWallet(
|
||||||
walletPasswordEditText.getText().toString(),
|
walletPasswordEditText.getText().toString(),
|
||||||
|
walletPasswordConfirmEditText.getText().toString(),
|
||||||
walletSeedEditText.getText().toString().trim(),
|
walletSeedEditText.getText().toString().trim(),
|
||||||
walletRestoreHeightEditText.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() {
|
walletSeedEditText.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
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.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() {
|
private void prepareDefaultNode() {
|
||||||
PrefService.getInstance().getNode();
|
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 : "";
|
String offset = useOffset ? walletPassword : "";
|
||||||
MainActivity mainActivity = (MainActivity) getActivity();
|
MainActivity mainActivity = (MainActivity) getActivity();
|
||||||
if (mainActivity != null) {
|
if (mainActivity != null) {
|
||||||
if (!walletPassword.isEmpty()) {
|
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();
|
PrefService.getInstance().edit().putBoolean(Constants.PREF_USES_PASSWORD, true).apply();
|
||||||
}
|
}
|
||||||
long restoreHeight = getNewRestoreHeight();
|
long restoreHeight = getNewRestoreHeight();
|
||||||
|
|
|
@ -24,23 +24,38 @@
|
||||||
android:id="@+id/wallet_password_edittext"
|
android:id="@+id/wallet_password_edittext"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="32dp"
|
|
||||||
android:background="@drawable/edittext_bg"
|
android:background="@drawable/edittext_bg"
|
||||||
android:hint="@string/password_optional"
|
android:hint="@string/password_optional"
|
||||||
android:inputType="textPassword"
|
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_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/create_wallet_textview"
|
app:layout_constraintTop_toBottomOf="@id/create_wallet_textview"
|
||||||
tools:visibility="visible" />
|
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
|
<CheckBox
|
||||||
android:id="@+id/seed_offset_checkbox"
|
android:id="@+id/seed_offset_checkbox"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
android:text="@string/use_password_as_seed_offset"
|
android:text="@string/use_password_as_seed_offset"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/wallet_password_edittext"/>
|
app:layout_constraintTop_toBottomOf="@id/wallet_password_confirm_edittext"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tor_onboarding_switch_label"
|
android:id="@+id/tor_onboarding_switch_label"
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
<string name="error_creating_tx">Error creating tx</string>
|
<string name="error_creating_tx">Error creating tx</string>
|
||||||
<string name="create_wallet">Create wallet</string>
|
<string name="create_wallet">Create wallet</string>
|
||||||
<string name="invalid_mnemonic_code">Invalid mnemonic</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="copied_to_clipboard">Copied to clipboard</string>
|
||||||
<string name="night_mode">Night mode</string>
|
<string name="night_mode">Night mode</string>
|
||||||
<string name="display_recovery_phrase">Display wallet keys</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="recovery_phrase_optional">Recovery phrase (optional)</string>
|
||||||
<string name="restore_height_optional">Restore height (optional)</string>
|
<string name="restore_height_optional">Restore height (optional)</string>
|
||||||
<string name="password_optional">Password (optional)</string>
|
<string name="password_optional">Password (optional)</string>
|
||||||
|
<string name="password_confirm">Confirm password</string>
|
||||||
<string name="password">Password</string>
|
<string name="password">Password</string>
|
||||||
<string name="unlock">Unlock</string>
|
<string name="unlock">Unlock</string>
|
||||||
<string name="enter_password">Enter password</string>
|
<string name="enter_password">Enter password</string>
|
||||||
|
|
Loading…
Reference in a new issue