Merge pull request #13687 from brave/android_dapps_full_address
Shows full addresses on Android wallet, adds an origin on a sign message screen
This commit is contained in:
+2
-1
@@ -370,7 +370,8 @@ public class ApproveTxBottomSheetDialogFragment extends BottomSheetDialogFragmen
|
||||
}
|
||||
TextView fromTo = view.findViewById(R.id.from_to);
|
||||
fromTo.setText(String.format(getResources().getString(R.string.crypto_wallet_from_to),
|
||||
mAccountName, Utils.stripAccountAddress(to)));
|
||||
mAccountName, Utils.stripAccountAddress(mTxInfo.fromAddress),
|
||||
Utils.stripAccountAddress(to)));
|
||||
TextView amountAsset = view.findViewById(R.id.amount_asset);
|
||||
amountAsset.setText(amountText);
|
||||
TextView amountFiat = view.findViewById(R.id.amount_fiat);
|
||||
|
||||
+15
-7
@@ -13,6 +13,7 @@ import android.text.style.ClickableSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.URLUtil;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
@@ -27,6 +28,7 @@ import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import org.chromium.brave_wallet.mojom.AddChainRequest;
|
||||
import org.chromium.brave_wallet.mojom.CoinType;
|
||||
import org.chromium.brave_wallet.mojom.NetworkInfo;
|
||||
import org.chromium.brave_wallet.mojom.OriginInfo;
|
||||
import org.chromium.brave_wallet.mojom.SwitchChainRequest;
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.app.BraveActivity;
|
||||
@@ -59,6 +61,7 @@ public class AddSwitchChainNetworkFragment extends BaseDAppsFragment {
|
||||
private List<TwoLineItemDataSource> networks;
|
||||
private List<TwoLineItemDataSource> details;
|
||||
private ImageView mFavicon;
|
||||
private TextView mSiteTv;
|
||||
private FaviconHelper mFaviconHelper;
|
||||
private DefaultFaviconHelper mDefaultFaviconHelper;
|
||||
|
||||
@@ -141,13 +144,8 @@ public class AddSwitchChainNetworkFragment extends BaseDAppsFragment {
|
||||
}
|
||||
});
|
||||
mFavicon = view.findViewById(R.id.fragment_add_token_iv_domain_icon);
|
||||
TextView siteTv = view.findViewById(R.id.fragment_add_token_tv_site);
|
||||
GURL siteUrl = Utils.getCurentTabUrl();
|
||||
if (siteUrl != null) {
|
||||
getBraveWalletService().geteTldPlusOneFromOrigin(Utils.getCurrentMojomOrigin(),
|
||||
origin -> { siteTv.setText(Utils.geteTLD(origin.eTldPlusOne)); });
|
||||
showFavIcon(siteUrl.getOrigin());
|
||||
}
|
||||
mSiteTv = view.findViewById(R.id.fragment_add_token_tv_site);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -189,6 +187,7 @@ public class AddSwitchChainNetworkFragment extends BaseDAppsFragment {
|
||||
mNetworkInfo = mAddChainRequest.networkInfo;
|
||||
hasMultipleAddSwitchChainRequest = addChainRequests.length > 1;
|
||||
updateState();
|
||||
fillOriginInfo(mAddChainRequest.originInfo);
|
||||
});
|
||||
} else if (mPanelType == SWITCH_ETHEREUM_CHAIN) {
|
||||
mBraveWalletBaseActivity.getJsonRpcService().getPendingSwitchChainRequests(
|
||||
@@ -205,10 +204,19 @@ public class AddSwitchChainNetworkFragment extends BaseDAppsFragment {
|
||||
}
|
||||
}
|
||||
});
|
||||
fillOriginInfo(mSwitchChainRequest.originInfo);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void fillOriginInfo(OriginInfo originInfo) {
|
||||
if (originInfo != null && URLUtil.isValidUrl(originInfo.originSpec)) {
|
||||
GURL url = new GURL(originInfo.originSpec);
|
||||
mSiteTv.setText(Utils.geteTLD(url, originInfo.eTldPlusOne));
|
||||
showFavIcon(url);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
if (getView() != null && mNetworkInfo != null) {
|
||||
addNetworkTabInfo(mNetworkInfo);
|
||||
|
||||
+10
-1
@@ -13,6 +13,7 @@ import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.URLUtil;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
@@ -25,6 +26,7 @@ import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.crypto_wallet.BlockchainRegistryFactory;
|
||||
import org.chromium.chrome.browser.crypto_wallet.activities.BraveWalletBaseActivity;
|
||||
import org.chromium.chrome.browser.crypto_wallet.util.Utils;
|
||||
import org.chromium.url.GURL;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -94,11 +96,18 @@ public class AddTokenFragment extends BaseDAppsFragment {
|
||||
}
|
||||
});
|
||||
}
|
||||
mWebSite.setText(mCurrentAddSuggestTokenRequest.origin.originSpec);
|
||||
fillOriginInfo(mCurrentAddSuggestTokenRequest.origin);
|
||||
initToken();
|
||||
});
|
||||
}
|
||||
|
||||
private void fillOriginInfo(OriginInfo originInfo) {
|
||||
if (originInfo != null && URLUtil.isValidUrl(originInfo.originSpec)) {
|
||||
GURL url = new GURL(originInfo.originSpec);
|
||||
mWebSite.setText(Utils.geteTLD(url, originInfo.eTldPlusOne));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateNetwork() {
|
||||
getJsonRpcService().getChainId(CoinType.ETH, chainId -> {
|
||||
getJsonRpcService().getAllNetworks(CoinType.ETH, chains -> {
|
||||
|
||||
+12
-1
@@ -13,6 +13,7 @@ import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.URLUtil;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
@@ -33,6 +34,7 @@ import org.chromium.brave_wallet.mojom.SignMessageRequest;
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.crypto_wallet.adapters.SignMessagePagerAdapter;
|
||||
import org.chromium.chrome.browser.crypto_wallet.util.Utils;
|
||||
import org.chromium.url.GURL;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -50,6 +52,7 @@ public class SignMessageFragment extends BaseDAppsBottomSheetDialogFragment {
|
||||
private TextView mNetworkName;
|
||||
private Button mBtCancel;
|
||||
private Button mBtSign;
|
||||
private TextView mWebSite;
|
||||
private ExecutorService mExecutor;
|
||||
private Handler mHandler;
|
||||
|
||||
@@ -75,6 +78,7 @@ public class SignMessageFragment extends BaseDAppsBottomSheetDialogFragment {
|
||||
|
||||
mBtCancel = view.findViewById(R.id.fragment_sign_msg_btn_cancel);
|
||||
mBtSign = view.findViewById(R.id.fragment_sign_msg_btn_sign);
|
||||
mWebSite = view.findViewById(R.id.domain);
|
||||
initComponents();
|
||||
|
||||
return view;
|
||||
@@ -113,6 +117,12 @@ public class SignMessageFragment extends BaseDAppsBottomSheetDialogFragment {
|
||||
mBtCancel.setOnClickListener(v -> { notifySignMessageRequestProcessed(false); });
|
||||
mBtSign.setOnClickListener(v -> { notifySignMessageRequestProcessed(true); });
|
||||
}
|
||||
if (mCurrentSignMessageRequest.originInfo != null
|
||||
&& URLUtil.isValidUrl(mCurrentSignMessageRequest.originInfo.originSpec)) {
|
||||
mWebSite.setText(
|
||||
Utils.geteTLD(new GURL(mCurrentSignMessageRequest.originInfo.originSpec),
|
||||
mCurrentSignMessageRequest.originInfo.eTldPlusOne));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -127,7 +137,8 @@ public class SignMessageFragment extends BaseDAppsBottomSheetDialogFragment {
|
||||
if (address.equals(accountInfo.address)) {
|
||||
Utils.setBlockiesBitmapResource(
|
||||
mExecutor, mHandler, mAccountImage, address, true);
|
||||
mAccountName.setText(accountInfo.name);
|
||||
String accountText = accountInfo.name + "\n" + address;
|
||||
mAccountName.setText(accountText);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-11
@@ -23,6 +23,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.chromium.brave_wallet.mojom.AccountInfo;
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.crypto_wallet.util.Blockies;
|
||||
import org.chromium.chrome.browser.crypto_wallet.util.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -95,7 +96,7 @@ public class BraveEthereumPermissionAccountsListAdapter
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
final int arrayPosition = position;
|
||||
holder.titleText.setText(mAccountInfo[arrayPosition].name);
|
||||
holder.subTitleText.setText(stripAccountAddress(mAccountInfo[arrayPosition].address));
|
||||
holder.subTitleText.setText(Utils.stripAccountAddress(mAccountInfo[arrayPosition].address));
|
||||
setBlockiesBitmapResource(holder.iconImg, mAccountInfo[arrayPosition].address);
|
||||
if (mCheckBoxStyle) {
|
||||
holder.accountCheck.setVisibility(View.VISIBLE);
|
||||
@@ -206,14 +207,4 @@ public class BraveEthereumPermissionAccountsListAdapter
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private String stripAccountAddress(String address) {
|
||||
String newAddress = "";
|
||||
|
||||
if (address.length() > 6) {
|
||||
newAddress = address.substring(0, 6) + "***" + address.substring(address.length() - 5);
|
||||
}
|
||||
|
||||
return newAddress;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -767,13 +767,17 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static String stripAccountAddress(String address) {
|
||||
String newAddress = "";
|
||||
return address;
|
||||
// TODO(serg): Let's leave it for now as it could be we still
|
||||
// want to show a short address
|
||||
// String newAddress = "";
|
||||
|
||||
if (address.length() > 6) {
|
||||
newAddress = address.substring(0, 6) + "***" + address.substring(address.length() - 5);
|
||||
}
|
||||
// if (address.length() > 6) {
|
||||
// newAddress = address.substring(0, 6) + "***" + address.substring(address.length() -
|
||||
// 5);
|
||||
// }
|
||||
|
||||
return newAddress;
|
||||
// return newAddress;
|
||||
}
|
||||
|
||||
public static boolean isJSONValid(String text) {
|
||||
|
||||
@@ -51,6 +51,19 @@
|
||||
tools:srcCompat="@drawable/ic_brave_logo" />
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/domain"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:gravity="center"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/fragment_sign_msg_cv_account_image_container"
|
||||
android:textColor="@color/wallet_text_color"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fragment_sign_msg_tv_account_name"
|
||||
android:layout_width="match_parent"
|
||||
@@ -63,7 +76,7 @@
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/fragment_sign_msg_cv_account_image_container"
|
||||
app:layout_constraintTop_toBottomOf="@id/domain"
|
||||
tools:text="Ledger Nano" />
|
||||
|
||||
<TextView
|
||||
|
||||
Reference in New Issue
Block a user