Search in sources :

Example 1 with Mnemonic

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);
}
Also used : View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) Mnemonic(org.thoughtcrime.securesms.payments.Mnemonic) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

View (android.view.View)1 TextView (android.widget.TextView)1 Toolbar (androidx.appcompat.widget.Toolbar)1 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 Mnemonic (org.thoughtcrime.securesms.payments.Mnemonic)1