Skip to content

Commit 3bb026e

Browse files
dpad85robbiehanson
andauthored
(android) Support Lightning addresses in contacts (#699)
* Add sealed class grouping contacts payment codes Bolt12 and LN addresses are similar as both are static payment instructions. Representing that with a class allows us to factorise some code down the line. * Refresh payments flow when contacts change The payments flow need to be updated also when contacts change. To do that we combine the payments flow from the payments-db with the contacts list flow from the contacts-db. This lets us remove workarounds in the iOS apps that are no longer needed. * (android) Add UI for new contacts flow with LN address Contacts can now contain Bolt12 codes or Lightning addresses (based on LNURL or BIP353). The contact details screen can now handle the creation or the editing of a contact, so we don't need a dedicated component to create new contacts. The UI has also been streamlined. --------- Co-authored-by: Robbie Hanson <[email protected]>
1 parent afe8c08 commit 3bb026e

File tree

31 files changed

+733
-596
lines changed

31 files changed

+733
-596
lines changed

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/AppView.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,11 @@ fun AppView(
252252
)
253253
}
254254
composable(
255-
route = "${Screen.Send.route}?input={input}&openScanner={openScanner}",
255+
route = "${Screen.Send.route}?input={input}&openScanner={openScanner}&forceNavOnBack={forceNavOnBack}",
256256
arguments = listOf(
257257
navArgument("input") { type = NavType.StringType ; nullable = true },
258-
navArgument("openScanner") { type = NavType.BoolType ; defaultValue = false }
258+
navArgument("openScanner") { type = NavType.BoolType ; defaultValue = false },
259+
navArgument("forceNavOnBack") { type = NavType.BoolType ; defaultValue = false },
259260
),
260261
deepLinks = listOf(
261262
navDeepLink { uriPattern = "lightning:{data}" },
@@ -289,7 +290,8 @@ fun AppView(
289290
SendView(
290291
initialInput = input,
291292
fromDeepLink = !isIntentFromNavigation,
292-
immediatelyOpenScanner = it.arguments?.getBoolean("openScanner") ?: false
293+
immediatelyOpenScanner = it.arguments?.getBoolean("openScanner") ?: false,
294+
forceNavOnBack = it.arguments?.getBoolean("forceNavOnBack") ?: false,
293295
)
294296
}
295297
}

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/PaymentsViewModel.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class PaymentsViewModel(
5959
private val paymentsPageFetcher: PaymentsPageFetcher = paymentsManager.makePageFetcher()
6060
val paymentsPage = paymentsPageFetcher.paymentsPage
6161

62-
6362
init {
6463
paymentsPageFetcher.subscribeToAll(offset = 0, count = pageSize)
6564
homePageFetcher.subscribeToAll(offset = 0, count = paymentsCountInHome)

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/components/Inputs.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import androidx.compose.ui.text.TextStyle
4040
import androidx.compose.ui.text.input.ImeAction
4141
import androidx.compose.ui.text.input.KeyboardCapitalization
4242
import androidx.compose.ui.text.input.KeyboardType
43+
import androidx.compose.ui.text.style.TextOverflow
4344
import androidx.compose.ui.unit.dp
4445
import androidx.compose.ui.unit.sp
4546
import fr.acinq.phoenix.android.R
@@ -152,9 +153,10 @@ fun TextInput(
152153
!errorMessage.isNullOrBlank() -> MaterialTheme.typography.subtitle2.copy(color = MaterialTheme.colors.onPrimary, fontSize = 13.sp)
153154
else -> MaterialTheme.typography.subtitle2.copy(fontSize = 13.sp)
154155
},
156+
overflow = TextOverflow.Ellipsis,
155157
modifier = Modifier
156158
.align(Alignment.BottomStart)
157-
.padding(start = 10.dp)
159+
.padding(start = 10.dp, end = 32.dp)
158160
.clip(RoundedCornerShape(8.dp))
159161
.background(if (!errorMessage.isNullOrBlank()) negativeColor else MaterialTheme.colors.surface)
160162
.padding(horizontal = 8.dp, vertical = 2.dp)

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/components/contact/ContactCompactView.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import androidx.compose.ui.Alignment
2929
import androidx.compose.ui.Modifier
3030
import androidx.compose.ui.text.style.TextOverflow
3131
import androidx.compose.ui.unit.dp
32-
import fr.acinq.lightning.wire.OfferTypes
3332
import fr.acinq.phoenix.android.components.SplashClickableContent
3433
import fr.acinq.phoenix.data.ContactInfo
3534

@@ -44,7 +43,6 @@ import fr.acinq.phoenix.data.ContactInfo
4443
@Composable
4544
fun ContactCompactView(
4645
contact: ContactInfo,
47-
currentOffer: OfferTypes.Offer?,
4846
onContactChange: (ContactInfo?) -> Unit,
4947
) {
5048
var showSheet by remember { mutableStateOf(false) }
@@ -60,7 +58,6 @@ fun ContactCompactView(
6058
if (showSheet) {
6159
ContactDetailsView(
6260
contact = contact,
63-
currentOffer = currentOffer,
6461
onDismiss = { showSheet = false },
6562
onContactChange = onContactChange,
6663
)

0 commit comments

Comments
 (0)