Add in-chat payment messages.

This commit is contained in:
Cody Henthorne
2022-11-10 14:45:45 -05:00
committed by Greyson Parrelli
parent 28193c2f61
commit 1dc29fda12
43 changed files with 708 additions and 98 deletions

View File

@@ -89,6 +89,10 @@ public final class MoneyView extends AppCompatTextView {
}
public void setMoney(@NonNull Money money, boolean highlightCurrency, long timestamp) {
setMoney(money, timestamp, (highlightCurrency ? new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.payment_currency_code_foreground_color)) : null));
}
public void setMoney(@NonNull Money money, long timestamp, @Nullable Object currencySpan) {
String balance = money.toString(formatterOptions);
int currencyIndex = balance.indexOf(money.getCurrency().getCurrencyCode());
@@ -102,8 +106,8 @@ public final class MoneyView extends AppCompatTextView {
balanceSpan = new SpannableString(balance);
}
if (highlightCurrency) {
balanceSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.payment_currency_code_foreground_color)), currencyIndex, currencyIndex + money.getCurrency().getCurrencyCode().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
if (currencySpan != null) {
balanceSpan.setSpan(currencySpan, currencyIndex, currencyIndex + money.getCurrency().getCurrencyCode().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
setText(balanceSpan);

View File

@@ -1,7 +1,10 @@
package org.thoughtcrime.securesms.payments.preferences;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
@@ -10,10 +13,14 @@ import org.thoughtcrime.securesms.PassphraseRequiredActivity;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.jobs.PaymentLedgerUpdateJob;
import org.thoughtcrime.securesms.payments.preferences.details.PaymentDetailsFragmentArgs;
import org.thoughtcrime.securesms.payments.preferences.details.PaymentDetailsParcelable;
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.navigation.SafeNavigation;
import java.util.UUID;
public class PaymentsActivity extends PassphraseRequiredActivity {
public static final String EXTRA_PAYMENTS_STARTING_ACTION = "payments_starting_action";
@@ -21,6 +28,15 @@ public class PaymentsActivity extends PassphraseRequiredActivity {
private final DynamicTheme dynamicTheme = new DynamicNoActionBarTheme();
public static Intent navigateToPaymentDetails(@NonNull Context context, @NonNull UUID paymentId) {
Intent intent = new Intent(context, PaymentsActivity.class);
intent.putExtra(EXTRA_PAYMENTS_STARTING_ACTION, R.id.action_directly_to_paymentDetails);
intent.putExtra(EXTRA_STARTING_ARGUMENTS, new PaymentDetailsFragmentArgs.Builder(PaymentDetailsParcelable.forUuid(paymentId)).build().toBundle());
return intent;
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState, boolean ready) {
dynamicTheme.onCreate(this);