Search in sources :

Example 1 with PaymentsValues

use of org.thoughtcrime.securesms.keyvalue.PaymentsValues in project Signal-Android by WhisperSystems.

the class Wallet method getFullLedger.

@WorkerThread
@NonNull
private MobileCoinLedgerWrapper getFullLedger(boolean retryOnAuthFailure) {
    PaymentsValues paymentsValues = SignalStore.paymentsValues();
    try {
        MobileCoinLedgerWrapper ledger = tryGetFullLedger(null);
        paymentsValues.setMobileCoinFullLedger(Objects.requireNonNull(ledger));
    } catch (IOException e) {
        if ((retryOnAuthFailure && e.getCause() instanceof NetworkException) && (((NetworkException) e.getCause()).statusCode == 401)) {
            Log.w(TAG, "Failed to get up to date ledger, due to temp auth failure, retrying", e);
            return getFullLedger(false);
        } else {
            Log.w(TAG, "Failed to get up to date ledger", e);
        }
    }
    return getCachedLedger();
}
Also used : PaymentsValues(org.thoughtcrime.securesms.keyvalue.PaymentsValues) IOException(java.io.IOException) NetworkException(com.mobilecoin.lib.exceptions.NetworkException) WorkerThread(androidx.annotation.WorkerThread) NonNull(androidx.annotation.NonNull)

Example 2 with PaymentsValues

use of org.thoughtcrime.securesms.keyvalue.PaymentsValues in project Signal-Android by signalapp.

the class Wallet method getFullLedger.

@WorkerThread
@NonNull
private MobileCoinLedgerWrapper getFullLedger(boolean retryOnAuthFailure) {
    PaymentsValues paymentsValues = SignalStore.paymentsValues();
    try {
        MobileCoinLedgerWrapper ledger = tryGetFullLedger(null);
        paymentsValues.setMobileCoinFullLedger(Objects.requireNonNull(ledger));
    } catch (IOException e) {
        if ((retryOnAuthFailure && e.getCause() instanceof NetworkException) && (((NetworkException) e.getCause()).statusCode == 401)) {
            Log.w(TAG, "Failed to get up to date ledger, due to temp auth failure, retrying", e);
            return getFullLedger(false);
        } else {
            Log.w(TAG, "Failed to get up to date ledger", e);
        }
    }
    return getCachedLedger();
}
Also used : PaymentsValues(org.thoughtcrime.securesms.keyvalue.PaymentsValues) IOException(java.io.IOException) NetworkException(com.mobilecoin.lib.exceptions.NetworkException) WorkerThread(androidx.annotation.WorkerThread) NonNull(androidx.annotation.NonNull)

Example 3 with PaymentsValues

use of org.thoughtcrime.securesms.keyvalue.PaymentsValues in project Signal-Android by signalapp.

the class PaymentsHomeViewModel method getPaymentsState.

private static PaymentsHomeState.PaymentsState getPaymentsState() {
    PaymentsValues paymentsValues = SignalStore.paymentsValues();
    PaymentsAvailability paymentsAvailability = paymentsValues.getPaymentsAvailability();
    if (paymentsAvailability.canRegister()) {
        return PaymentsHomeState.PaymentsState.NOT_ACTIVATED;
    } else if (paymentsAvailability.isEnabled()) {
        return PaymentsHomeState.PaymentsState.ACTIVATED;
    } else {
        return PaymentsHomeState.PaymentsState.ACTIVATE_NOT_ALLOWED;
    }
}
Also used : PaymentsValues(org.thoughtcrime.securesms.keyvalue.PaymentsValues) PaymentsAvailability(org.thoughtcrime.securesms.keyvalue.PaymentsAvailability)

Example 4 with PaymentsValues

use of org.thoughtcrime.securesms.keyvalue.PaymentsValues in project Signal-Android by WhisperSystems.

the class PaymentsHomeViewModel method getPaymentsState.

private static PaymentsHomeState.PaymentsState getPaymentsState() {
    PaymentsValues paymentsValues = SignalStore.paymentsValues();
    PaymentsAvailability paymentsAvailability = paymentsValues.getPaymentsAvailability();
    if (paymentsAvailability.canRegister()) {
        return PaymentsHomeState.PaymentsState.NOT_ACTIVATED;
    } else if (paymentsAvailability.isEnabled()) {
        return PaymentsHomeState.PaymentsState.ACTIVATED;
    } else {
        return PaymentsHomeState.PaymentsState.ACTIVATE_NOT_ALLOWED;
    }
}
Also used : PaymentsValues(org.thoughtcrime.securesms.keyvalue.PaymentsValues) PaymentsAvailability(org.thoughtcrime.securesms.keyvalue.PaymentsAvailability)

Example 5 with PaymentsValues

use of org.thoughtcrime.securesms.keyvalue.PaymentsValues in project Signal-Android by WhisperSystems.

the class InfoCard method getInfoCards.

@NonNull
public static List<InfoCard> getInfoCards() {
    List<InfoCard> infoCards = new ArrayList<>(Type.values().length);
    PaymentsValues paymentsValues = SignalStore.paymentsValues();
    if (paymentsValues.showRecoveryPhraseInfoCard()) {
        infoCards.add(new InfoCard(R.string.payment_info_card_record_recovery_phrase, R.string.payment_info_card_your_recovery_phrase_gives_you, R.string.payment_info_card_record_your_phrase, R.drawable.ic_payments_info_card_restore_80, Type.RECORD_RECOVERY_PHASE, paymentsValues::dismissRecoveryPhraseInfoCard));
    }
    if (paymentsValues.showUpdatePinInfoCard()) {
        infoCards.add(new InfoCard(R.string.payment_info_card_update_your_pin, R.string.payment_info_card_with_a_high_balance, R.string.payment_info_card_update_pin, R.drawable.ic_payments_info_card_pin_80, Type.UPDATE_YOUR_PIN, paymentsValues::dismissUpdatePinInfoCard));
    }
    if (paymentsValues.showAboutMobileCoinInfoCard()) {
        infoCards.add(new InfoCard(R.string.payment_info_card_about_mobilecoin, R.string.payment_info_card_mobilecoin_is_a_new_privacy_focused_digital_currency, R.string.LearnMoreTextView_learn_more, R.drawable.ic_about_mc_80, Type.ABOUT_MOBILECOIN, paymentsValues::dismissAboutMobileCoinInfoCard));
    }
    if (paymentsValues.showAddingToYourWalletInfoCard()) {
        infoCards.add(new InfoCard(R.string.payment_info_card_adding_funds, R.string.payment_info_card_you_can_add_funds_for_use_in, R.string.LearnMoreTextView_learn_more, R.drawable.ic_add_money_80, Type.ADDING_TO_YOUR_WALLET, paymentsValues::dismissAddingToYourWalletInfoCard));
    }
    if (paymentsValues.showCashingOutInfoCard()) {
        infoCards.add(new InfoCard(R.string.payment_info_card_cashing_out, R.string.payment_info_card_you_can_cash_out_mobilecoin, R.string.LearnMoreTextView_learn_more, R.drawable.ic_cash_out_80, Type.CASHING_OUT, paymentsValues::dismissCashingOutInfoCard));
    }
    return infoCards;
}
Also used : PaymentsValues(org.thoughtcrime.securesms.keyvalue.PaymentsValues) ArrayList(java.util.ArrayList) NonNull(androidx.annotation.NonNull)

Aggregations

PaymentsValues (org.thoughtcrime.securesms.keyvalue.PaymentsValues)6 NonNull (androidx.annotation.NonNull)4 WorkerThread (androidx.annotation.WorkerThread)2 NetworkException (com.mobilecoin.lib.exceptions.NetworkException)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 PaymentsAvailability (org.thoughtcrime.securesms.keyvalue.PaymentsAvailability)2