Skip to content

Commit

Permalink
Show full address
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesSmartCell committed Aug 8, 2023
1 parent 7a57f67 commit 5e4c235
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private void showAddress()

displayAddress = Keys.toChecksumAddress(wallet.address);
setTitle(getString(R.string.my_wallet_address));
copyAddress.setText(displayAddress);
copyAddress.setFixedText(displayAddress);
currentMode = AddressMode.MODE_ADDRESS;
if (getCurrentFocus() != null) {
KeyboardUtils.hideKeyboard(getCurrentFocus());
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/java/com/alphawallet/app/util/Utils.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.alphawallet.app.util;

import static com.alphawallet.app.service.AssetDefinitionService.getEASContract;
import static com.alphawallet.ethereum.EthereumNetworkBase.AVALANCHE_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.BINANCE_MAIN_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.CLASSIC_ID;
Expand Down Expand Up @@ -37,9 +36,9 @@
import com.alphawallet.app.web3j.StructuredDataEncoder;
import com.alphawallet.token.entity.ProviderTypedData;
import com.alphawallet.token.entity.Signable;
import com.google.gson.Gson;
import com.google.zxing.client.android.Intents;
import com.journeyapps.barcodescanner.ScanOptions;
import com.google.gson.Gson;

import org.jetbrains.annotations.NotNull;
import org.json.JSONObject;
Expand All @@ -56,7 +55,6 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
Expand Down Expand Up @@ -583,6 +581,15 @@ public static String formatAddress(String address, int frontCharCount)
}
}

public static String splitAddress(String address)
{
address = Keys.toChecksumAddress(address);
int split = address.length()/2;
String front = address.substring(0, split);
String back = address.substring(split);
return front + " " + back;
}

public static String formatTxHash(String txHash)
{
if (isTxHashValid(txHash))
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/java/com/alphawallet/app/widget/CopyTextView.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,26 @@ public String getText()
return originalText;
}

public void setFixedText(CharSequence text)
{
originalText = text.toString();

setVisibility(TextUtils.isEmpty(originalText) ? View.GONE : View.VISIBLE);

if (Utils.isAddressValid(originalText))
{
button.setText(Utils.splitAddress(originalText));
}
else if (Utils.isTxHashValid(originalText))
{
button.setText(Utils.formatTxHash(originalText, 10));
}
else
{
button.setText(originalText);
}
}

public void setText(CharSequence text)
{
originalText = text.toString();
Expand Down

0 comments on commit 5e4c235

Please sign in to comment.