use of com.google.android.material.textfield.MaterialAutoCompleteTextView in project Signal-Android by WhisperSystems.
the class PaymentsRecoveryEntryFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
Toolbar toolbar = view.findViewById(R.id.payments_recovery_entry_fragment_toolbar);
TextView message = view.findViewById(R.id.payments_recovery_entry_fragment_message);
TextInputLayout wrapper = view.findViewById(R.id.payments_recovery_entry_fragment_word_wrapper);
MaterialAutoCompleteTextView word = view.findViewById(R.id.payments_recovery_entry_fragment_word);
View next = view.findViewById(R.id.payments_recovery_entry_fragment_next);
PaymentsRecoveryEntryViewModel viewModel = ViewModelProviders.of(this).get(PaymentsRecoveryEntryViewModel.class);
toolbar.setNavigationOnClickListener(t -> Navigation.findNavController(view).popBackStack(R.id.paymentsHome, false));
viewModel.getState().observe(getViewLifecycleOwner(), state -> {
message.setText(getString(R.string.PaymentsRecoveryEntryFragment__enter_word_d, state.getWordIndex() + 1));
word.setHint(getString(R.string.PaymentsRecoveryEntryFragment__word_d, state.getWordIndex() + 1));
wrapper.setError(state.canMoveToNext() || TextUtils.isEmpty(state.getCurrentEntry()) ? null : getString(R.string.PaymentsRecoveryEntryFragment__invalid_word));
next.setEnabled(state.canMoveToNext());
String inTextView = word.getText().toString();
String inState = Util.firstNonNull(state.getCurrentEntry(), "");
if (!inTextView.equals(inState)) {
word.setText(inState);
}
});
viewModel.getEvents().observe(getViewLifecycleOwner(), event -> {
if (event == PaymentsRecoveryEntryViewModel.Events.GO_TO_CONFIRM) {
SafeNavigation.safeNavigate(Navigation.findNavController(view), PaymentsRecoveryEntryFragmentDirections.actionPaymentsRecoveryEntryToPaymentsRecoveryPhrase(false).setWords(viewModel.getWords()));
}
});
ArrayAdapter<String> wordAdapter = new ArrayAdapter<>(requireContext(), R.layout.support_simple_spinner_dropdown_item, Mnemonic.BIP39_WORDS_ENGLISH);
word.setAdapter(wordAdapter);
word.addTextChangedListener(new AfterTextChanged(e -> viewModel.onWordChanged(e.toString())));
next.setOnClickListener(v -> viewModel.onNextClicked());
}
use of com.google.android.material.textfield.MaterialAutoCompleteTextView in project Signal-Android by signalapp.
the class PaymentsRecoveryEntryFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
Toolbar toolbar = view.findViewById(R.id.payments_recovery_entry_fragment_toolbar);
TextView message = view.findViewById(R.id.payments_recovery_entry_fragment_message);
TextInputLayout wrapper = view.findViewById(R.id.payments_recovery_entry_fragment_word_wrapper);
MaterialAutoCompleteTextView word = view.findViewById(R.id.payments_recovery_entry_fragment_word);
View next = view.findViewById(R.id.payments_recovery_entry_fragment_next);
PaymentsRecoveryEntryViewModel viewModel = ViewModelProviders.of(this).get(PaymentsRecoveryEntryViewModel.class);
toolbar.setNavigationOnClickListener(t -> Navigation.findNavController(view).popBackStack(R.id.paymentsHome, false));
viewModel.getState().observe(getViewLifecycleOwner(), state -> {
message.setText(getString(R.string.PaymentsRecoveryEntryFragment__enter_word_d, state.getWordIndex() + 1));
word.setHint(getString(R.string.PaymentsRecoveryEntryFragment__word_d, state.getWordIndex() + 1));
wrapper.setError(state.canMoveToNext() || TextUtils.isEmpty(state.getCurrentEntry()) ? null : getString(R.string.PaymentsRecoveryEntryFragment__invalid_word));
next.setEnabled(state.canMoveToNext());
String inTextView = word.getText().toString();
String inState = Util.firstNonNull(state.getCurrentEntry(), "");
if (!inTextView.equals(inState)) {
word.setText(inState);
}
});
viewModel.getEvents().observe(getViewLifecycleOwner(), event -> {
if (event == PaymentsRecoveryEntryViewModel.Events.GO_TO_CONFIRM) {
SafeNavigation.safeNavigate(Navigation.findNavController(view), PaymentsRecoveryEntryFragmentDirections.actionPaymentsRecoveryEntryToPaymentsRecoveryPhrase(false).setWords(viewModel.getWords()));
}
});
ArrayAdapter<String> wordAdapter = new ArrayAdapter<>(requireContext(), R.layout.support_simple_spinner_dropdown_item, Mnemonic.BIP39_WORDS_ENGLISH);
word.setAdapter(wordAdapter);
word.addTextChangedListener(new AfterTextChanged(e -> viewModel.onWordChanged(e.toString())));
next.setOnClickListener(v -> viewModel.onNextClicked());
}
Aggregations