mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Add in-chat payment messages.
This commit is contained in:
committed by
Greyson Parrelli
parent
28193c2f61
commit
1dc29fda12
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user