Skip to content

Commit

Permalink
Merge branch 'master' into mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
dpad85 committed Jul 3, 2024
2 parents adc3c6d + feaef8a commit 0b6ab1e
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 50 deletions.
4 changes: 2 additions & 2 deletions phoenix-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ android {
applicationId = "fr.acinq.phoenix.mainnet"
minSdk = 26
targetSdk = 34
versionCode = 81
versionName = "2.3.0"
versionCode = 82
versionName = gitCommitHash()
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
resourceConfigurations.addAll(listOf("en", "fr", "de", "es", "b+es+419", "cs", "pt-rBR", "sk", "vi"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,10 @@ fun AppView(
val previousNav = navController.previousBackStackEntry
if (fromEvent && previousNav?.destination?.route == Screen.ScanData.route) {
popToHome(navController)
} else {
} else if (navController.previousBackStackEntry != null){
navController.popBackStack()
} else {
popToHome(navController)
}
},
fromEvent = fromEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ class AppViewModel(

override fun onCleared() {
super.onCleared()
service?.shutdown()
log.debug("AppViewModel has been cleared")
log.info("AppViewModel cleared")
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ fun PaymentLine(
|| (payment is SpliceCpfpOutgoingPayment && payment.confirmedAt == null)) {
Text(text = stringResource(id = R.string.paymentline_outgoing_unconfirmed), style = MaterialTheme.typography.caption.copy(fontSize = 12.sp))
} else {
Text(text = payment.createdAt.toRelativeDateString(), style = MaterialTheme.typography.caption.copy(fontSize = 12.sp))
Row {
Text(text = payment.createdAt.toRelativeDateString(), style = MaterialTheme.typography.caption.copy(fontSize = 12.sp), maxLines = 1)
PaymentContactInfo(paymentInfo = paymentInfo)
}
}
}
}
Expand All @@ -177,45 +180,19 @@ private fun PaymentDescription(paymentInfo: WalletPaymentInfo, modifier: Modifie
null -> stringResource(id = R.string.paymentdetails_desc_closing_channel) // not sure yet, but we still know it's a closing
true -> stringResource(id = R.string.paymentdetails_desc_legacy_migration)
false -> metadata.userDescription
?: metadata.lnurl?.pay?.metadata?.lnid?.takeIf { it.isNotBlank() }?.let {
stringResource(id = R.string.paymentdetails_desc_to, it)
}
?: metadata.lnurl?.description
?: payment.incomingOfferMetadata()?.let { offerMetadata ->
val contactsManager = business.contactsManager
val contactForKey = produceState<ContactInfo?>(initialValue = null, producer = {
value = contactsManager.getContactForPayerPubkey(offerMetadata.payerKey)
})

when (val contact = contactForKey.value) {
null -> when (val note = offerMetadata.payerNote) {
null -> null
else -> stringResource(id = R.string.paymentdetails_desc_from_unknown_with_note, note)
}
else -> when (val note = offerMetadata.payerNote) {
null -> stringResource(id = R.string.paymentdetails_desc_from, contact.name)
else -> stringResource(id = R.string.paymentdetails_desc_from_with_note, contact.name, note)
}
}
}
?: payment.outgoingInvoiceRequest()?.let { request ->
val offer = request.offer
val contactsManager = business.contactsManager
val contactForOffer = produceState<ContactInfo?>(initialValue = null, producer = {
value = contactsManager.getContactForOffer(offer)
})

when (val contact = contactForOffer.value) {
null -> when (val note = request.payerNote) {
null -> null
else -> stringResource(id = R.string.paymentdetails_desc_to_unknown_with_note, note)
}
else -> when (val note = request.payerNote) {
null -> stringResource(id = R.string.paymentdetails_desc_to, contact.name)
else -> stringResource(id = R.string.paymentdetails_desc_to_with_note, contact.name, note)
}
when (contactForKey.value) {
null -> null
else -> offerMetadata.payerNote
}
}
?: payment.outgoingInvoiceRequest()?.payerNote
?: payment.smartDescription(context)
}

Expand Down Expand Up @@ -310,3 +287,55 @@ private fun PaymentIconComponent(
}
}
}

@Composable
private fun PaymentContactInfo(
paymentInfo: WalletPaymentInfo
) {
val offerMetadata = paymentInfo.payment.incomingOfferMetadata()
if (offerMetadata != null) {
val contactsManager = business.contactsManager
val contactForKey = produceState<ContactInfo?>(initialValue = null, producer = {
value = contactsManager.getContactForPayerPubkey(offerMetadata.payerKey)
})

when (val contact = contactForKey.value) {
null -> Unit
else -> FromToNameView(isOutgoing = false, userName = contact.name)
}
return
}

val invoiceRequest = paymentInfo.payment.outgoingInvoiceRequest()
if (invoiceRequest != null) {
val offer = invoiceRequest.offer
val contactsManager = business.contactsManager
val contactForOffer = produceState<ContactInfo?>(initialValue = null, producer = {
value = contactsManager.getContactForOffer(offer)
})

when (val contact = contactForOffer.value) {
null -> Unit
else -> FromToNameView(isOutgoing = true, userName = contact.name)
}
return
}

val lnid = paymentInfo.metadata.lnurl?.pay?.metadata?.lnid?.takeIf { it.isNotBlank() }
if (!lnid.isNullOrBlank()) {
FromToNameView(isOutgoing = true, userName = lnid)
}
}

@Composable
private fun FromToNameView(isOutgoing: Boolean, userName: String) {
Spacer(modifier = Modifier.width(4.dp))
Text(text = "", style = MaterialTheme.typography.caption.copy(fontSize = 12.sp))
Spacer(modifier = Modifier.width(4.dp))
Text(
text = if (isOutgoing) stringResource(id = R.string.paymentdetails_desc_to, userName) else stringResource(id = R.string.paymentdetails_desc_from, userName),
style = MaterialTheme.typography.subtitle2.copy(fontSize = 12.sp),
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
4 changes: 3 additions & 1 deletion phoenix-android/src/main/res/values-b+es+419/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@
<string name="paymentdetails_desc_cpfp">Impulsar transacciones</string>
<string name="paymentdetails_desc_swapout">Intercambiar a %1$s</string>
<string name="paymentdetails_desc_swapin">Depósito en la cadena</string>
<string name="paymentdetails_desc_to">Pago a %1$s</string>

<string name="paymentdetails_desc_to">a %1$s</string>
<string name="paymentdetails_desc_from">de %1$s</string>

<string name="paymentdetails_edit_dialog_title">Agregar una descripción personalizada para este pago</string>
<string name="paymentdetails_edit_dialog_input_label">Descripción</string>
Expand Down
4 changes: 3 additions & 1 deletion phoenix-android/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@
<string name="paymentdetails_desc_cpfp">Postrčit transakci</string>
<string name="paymentdetails_desc_swapout">Swap-out do %1$s</string>
<string name="paymentdetails_desc_swapin">On-Chain vklad</string>
<string name="paymentdetails_desc_to">Platba pro %1$s</string>

<string name="paymentdetails_desc_to">pro %1$s</string>
<string name="paymentdetails_desc_from">od %1$s</string>

<string name="paymentdetails_edit_dialog_title">Přidat vlastní popis k této platbě</string>
<string name="paymentdetails_edit_dialog_input_label">Popis</string>
Expand Down
4 changes: 3 additions & 1 deletion phoenix-android/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,9 @@
<string name="paymentdetails_desc_inbound_liquidity">+%1$s eingehende Liquidität</string>
<string name="paymentdetails_desc_swapout">Swap-out an %1$s</string>
<string name="paymentdetails_desc_swapin">On-Chain Einzahlung</string>
<string name="paymentdetails_desc_to">Zahlung an %1$s</string>

<string name="paymentdetails_desc_to">an %1$s</string>
<string name="paymentdetails_desc_from">von %1$s</string>

<string name="paymentdetails_edit_dialog_title">Fügen Sie eine eigene Beschreibung zu dieser Zahlung hinzu</string>
<string name="paymentdetails_edit_dialog_input_label">Beschreibung</string>
Expand Down
4 changes: 3 additions & 1 deletion phoenix-android/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,9 @@
<string name="paymentdetails_desc_inbound_liquidity">+%1$s de liquidité entrante</string>
<string name="paymentdetails_desc_swapout">Swap-out vers %1$s</string>
<string name="paymentdetails_desc_swapin">Dépôt on-chain</string>
<string name="paymentdetails_desc_to">Paiement vers %1$s</string>

<string name="paymentdetails_desc_to">vers %1$s</string>
<string name="paymentdetails_desc_from">de %1$s</string>

<string name="paymentdetails_edit_dialog_title">Ajouter une description personnalisée à ce paiement</string>
<string name="paymentdetails_edit_dialog_input_label">Description</string>
Expand Down
4 changes: 3 additions & 1 deletion phoenix-android/src/main/res/values-sk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@
<string name="paymentdetails_desc_inbound_liquidity">+%1$s prichádzajúca likvidita</string>
<string name="paymentdetails_desc_swapout">Swap-out na %1$s</string>
<string name="paymentdetails_desc_swapin">On-chain vklad</string>
<string name="paymentdetails_desc_to">Platba pre %1$s</string>

<string name="paymentdetails_desc_to">pre %1$s</string>
<string name="paymentdetails_desc_from">od %1$s</string>

<string name="paymentdetails_edit_dialog_title">Pridať vlastný popis k tejto platbe</string>
<string name="paymentdetails_edit_dialog_input_label">Popis</string>
Expand Down
4 changes: 3 additions & 1 deletion phoenix-android/src/main/res/values-vi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@
<string name="paymentdetails_desc_inbound_liquidity">+%1$s thanh khoản đầu vào</string>
<string name="paymentdetails_desc_swapout">Swap-out thành %1$s</string>
<string name="paymentdetails_desc_swapin">Tiền cọc on-chain</string>
<string name="paymentdetails_desc_to">Khoản thanh toán cho %1$s</string>

<string name="paymentdetails_desc_to">đến %1$s</string>
<string name="paymentdetails_desc_from">từ %1$s</string>

<string name="paymentdetails_edit_dialog_title">Thêm mô tả tùy chọn cho khoản thanh toán này</string>
<string name="paymentdetails_edit_dialog_input_label">Mô tả</string>
Expand Down
9 changes: 2 additions & 7 deletions phoenix-android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,8 @@
<string name="paymentdetails_desc_swapout">Swap-out to %1$s</string>
<string name="paymentdetails_desc_swapin">On-chain deposit</string>

<string name="paymentdetails_desc_to">To %1$s</string>
<string name="paymentdetails_desc_to_with_note">To %1$s: %2$s</string>
<string name="paymentdetails_desc_to_unknown_with_note">To unknown: %1$s</string>
<string name="paymentdetails_desc_from">From %1$s</string>
<string name="paymentdetails_desc_from_with_note">From %1$s: %2$s</string>
<string name="paymentdetails_desc_from_unknown">From unknown</string>
<string name="paymentdetails_desc_from_unknown_with_note">From unknown: %1$s</string>
<string name="paymentdetails_desc_to">to %1$s</string>
<string name="paymentdetails_desc_from">from %1$s</string>

<string name="paymentdetails_edit_dialog_title">Add a custom description to this payment</string>
<string name="paymentdetails_edit_dialog_input_label">Description</string>
Expand Down
2 changes: 1 addition & 1 deletion phoenix-legacy/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
val libCode = 81
val libCode = 82
getByName("debug") {
resValue("string", "CHAIN", chain)
buildConfigField("String", "CHAIN", chain)
Expand Down

0 comments on commit 0b6ab1e

Please sign in to comment.