Search in sources :

Example 1 with QrView

use of org.thoughtcrime.securesms.components.qr.QrView in project Signal-Android by WhisperSystems.

the class PaymentsAddMoneyFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    PaymentsAddMoneyViewModel viewModel = ViewModelProviders.of(this, new PaymentsAddMoneyViewModel.Factory()).get(PaymentsAddMoneyViewModel.class);
    Toolbar toolbar = view.findViewById(R.id.payments_add_money_toolbar);
    QrView qrImageView = view.findViewById(R.id.payments_add_money_qr_image);
    TextView walletAddressAbbreviated = view.findViewById(R.id.payments_add_money_abbreviated_wallet_address);
    View copyAddress = view.findViewById(R.id.payments_add_money_copy_address_button);
    LearnMoreTextView info = view.findViewById(R.id.payments_add_money_info);
    info.setLearnMoreVisible(true);
    info.setLink(getString(R.string.PaymentsAddMoneyFragment__learn_more__information));
    toolbar.setNavigationOnClickListener(v -> Navigation.findNavController(v).popBackStack());
    viewModel.getSelfAddressAbbreviated().observe(getViewLifecycleOwner(), walletAddressAbbreviated::setText);
    viewModel.getSelfAddressB58().observe(getViewLifecycleOwner(), base58 -> copyAddress.setOnClickListener(v -> copyAddressToClipboard(base58)));
    // Note we are choosing to put Base58 directly into QR here
    viewModel.getSelfAddressB58().observe(getViewLifecycleOwner(), qrImageView::setQrText);
    viewModel.getErrors().observe(getViewLifecycleOwner(), error -> {
        switch(error) {
            case PAYMENTS_NOT_ENABLED:
                throw new AssertionError("Payments are not enabled");
            default:
                throw new AssertionError();
        }
    });
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) R(org.thoughtcrime.securesms.R) ClipData(android.content.ClipData) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Toast(android.widget.Toast) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) ClipboardManager(android.content.ClipboardManager) View(android.view.View) Toolbar(androidx.appcompat.widget.Toolbar) ViewModelProviders(androidx.lifecycle.ViewModelProviders) Navigation(androidx.navigation.Navigation) LoggingFragment(org.thoughtcrime.securesms.LoggingFragment) QrView(org.thoughtcrime.securesms.components.qr.QrView) QrView(org.thoughtcrime.securesms.components.qr.QrView) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) TextView(android.widget.TextView) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) TextView(android.widget.TextView) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) View(android.view.View) QrView(org.thoughtcrime.securesms.components.qr.QrView) Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

ClipData (android.content.ClipData)1 ClipboardManager (android.content.ClipboardManager)1 Context (android.content.Context)1 Bundle (android.os.Bundle)1 View (android.view.View)1 TextView (android.widget.TextView)1 Toast (android.widget.Toast)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 Toolbar (androidx.appcompat.widget.Toolbar)1 ViewModelProviders (androidx.lifecycle.ViewModelProviders)1 Navigation (androidx.navigation.Navigation)1 LoggingFragment (org.thoughtcrime.securesms.LoggingFragment)1 R (org.thoughtcrime.securesms.R)1 QrView (org.thoughtcrime.securesms.components.qr.QrView)1 LearnMoreTextView (org.thoughtcrime.securesms.util.views.LearnMoreTextView)1