use of org.thoughtcrime.securesms.payments.Mnemonic in project Signal-Android by WhisperSystems.
the class PaymentsRecoveryPhraseFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
Toolbar toolbar = view.findViewById(R.id.payments_recovery_phrase_fragment_toolbar);
RecyclerView recyclerView = view.findViewById(R.id.payments_recovery_phrase_fragment_recycler);
TextView message = view.findViewById(R.id.payments_recovery_phrase_fragment_message);
View next = view.findViewById(R.id.payments_recovery_phrase_fragment_next);
View edit = view.findViewById(R.id.payments_recovery_phrase_fragment_edit);
View copy = view.findViewById(R.id.payments_recovery_phrase_fragment_copy);
GridLayoutManager gridLayoutManager = new GridLayoutManager(requireContext(), SPAN_COUNT);
PaymentsRecoveryPhraseFragmentArgs args = PaymentsRecoveryPhraseFragmentArgs.fromBundle(requireArguments());
final List<String> words;
if (args.getWords() != null) {
words = Arrays.asList(args.getWords());
setUpForConfirmation(message, next, edit, copy, words);
} else {
Mnemonic mnemonic = SignalStore.paymentsValues().getPaymentsMnemonic();
words = mnemonic.getWords();
setUpForDisplay(message, next, edit, copy, words, args);
}
List<MnemonicPart> parts = Stream.of(words).mapIndexed(MnemonicPart::new).sorted(new MnemonicPartComparator(words.size(), SPAN_COUNT)).toList();
MnemonicPartAdapter adapter = new MnemonicPartAdapter();
recyclerView.setLayoutManager(gridLayoutManager);
recyclerView.setAdapter(adapter);
recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
toolbar.setNavigationOnClickListener(v -> {
if (args.getFinishOnConfirm()) {
requireActivity().finish();
} else {
toolbar.setNavigationOnClickListener(t -> Navigation.findNavController(view).popBackStack(R.id.paymentsHome, false));
}
});
adapter.submitList(parts);
}
Aggregations