Skip to content

Commit

Permalink
(android) Display a Bitcoin icon alongside the bip353 address
Browse files Browse the repository at this point in the history
  • Loading branch information
dpad85 committed Jul 16, 2024
1 parent c209e4f commit cb6ef79
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package fr.acinq.phoenix.android.payments.receive

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -26,6 +25,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.rememberScrollState
Expand All @@ -46,7 +46,6 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
Expand All @@ -55,6 +54,7 @@ import fr.acinq.phoenix.android.R
import fr.acinq.phoenix.android.components.BorderButton
import fr.acinq.phoenix.android.components.Button
import fr.acinq.phoenix.android.components.Clickable
import fr.acinq.phoenix.android.components.PhoenixIcon
import fr.acinq.phoenix.android.components.TextWithIcon
import fr.acinq.phoenix.android.components.openLink
import fr.acinq.phoenix.android.internalData
Expand Down Expand Up @@ -89,7 +89,7 @@ fun DisplayOfferDialog(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.verticalScroll(rememberScrollState())
.padding(top = 0.dp, start = 24.dp, end = 24.dp, bottom = 50.dp)
.padding(top = 0.dp, start = 12.dp, end = 12.dp, bottom = 50.dp)
) {
when (offerState) {
OfferState.Init -> {
Expand All @@ -98,7 +98,7 @@ fun DisplayOfferDialog(
is OfferState.Show -> {
HowToOffer()
Spacer(modifier = Modifier.height(6.dp))
Box(modifier = Modifier.widthIn(max = 400.dp)) {
Box(modifier = Modifier.widthIn(max = 350.dp)) {
QRCodeImage(bitmap = offerState.bitmap, onLongClick = { copyToClipboard(context, offerState.encoded) })
}
Bip353AddressDisplay(address)
Expand All @@ -117,7 +117,7 @@ fun DisplayOfferDialog(
BorderButton(
text = stringResource(id = R.string.btn_share),
icon = R.drawable.ic_share,
onClick = { share(context, "lightning:${offerState.encoded}", context.getString(R.string.receive_offer_share_subject), context.getString(R.string.receive_offer_share_title)) },
onClick = { share(context, "bitcoin:?lno=${offerState.encoded}", context.getString(R.string.receive_offer_share_subject), context.getString(R.string.receive_offer_share_title)) },
)
}
Spacer(modifier = Modifier.height(16.dp))
Expand All @@ -133,8 +133,26 @@ fun Bip353AddressDisplay(address: String?) {
when {
address.isNullOrBlank() -> {}
else -> {
SelectionContainer {
Text(text = stringResource(id = R.string.utils_bip353_with_prefix, address), style = MaterialTheme.typography.body2)
Spacer(modifier = Modifier.height(8.dp))
Row(verticalAlignment = Alignment.CenterVertically) {
Box(
modifier = Modifier
.border(1.dp, MaterialTheme.colors.primary, CircleShape)
.padding(3.dp)
) {
PhoenixIcon(
resourceId = R.drawable.ic_bitcoin_wire,
modifier = Modifier.size(18.dp),
tint = MaterialTheme.colors.primary,
)
}
Spacer(modifier = Modifier.width(5.dp))
SelectionContainer {
Text(
text = address,
style = MaterialTheme.typography.body2,
)
}
}
Spacer(modifier = Modifier.height(16.dp))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private fun ClaimAddressButton(
is ClaimAddressState.Done -> {
val context = LocalContext.current
Setting(
title = stringResource(id = R.string.utils_bip353_with_prefix, state.address),
title = state.address,
leadingIcon = { PhoenixIcon(R.drawable.ic_arobase) },
trailingIcon = {
Button(
Expand Down
29 changes: 29 additions & 0 deletions phoenix-android/src/main/res/drawable/ic_bitcoin_wire.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!--
~ Copyright 2024 ACINQ SAS
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="13.5dp"
android:height="24dp"
android:viewportWidth="13.5"
android:viewportHeight="24">
<path
android:fillColor="#00000000"
android:pathData="m7.5,19c6,0 6,-7 0,-7m0,7h-6m6,0v2m0,-9c4.5,0.11 4.5,-7 0,-7.1m0,7.1h-6m6,-7.1v-2m-4,2v-2m4,2h-6V19m1.8,2v-2"
android:strokeWidth="1.625"
android:strokeColor="?attr/colorPrimary"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
2 changes: 1 addition & 1 deletion phoenix-android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
<string name="scan_manual_input_title">Manual input</string>
<string name="scan_manual_input_instructions">Enter a Lightning invoice, an offer, a LNURL or a Lightning address you want to send money to.</string>
<string name="scan_manual_input_label">Invoice, LN address…</string>
<string name="scan_manual_input_hint" translatable="false">[email protected]</string>
<string name="scan_manual_input_hint" translatable="false">[email protected], bc1q..., lnbc...</string>

<!-- utils: misc strings -->

Expand Down

0 comments on commit cb6ef79

Please sign in to comment.