Merge pull request #13660 from brave/android_dapps_origin

Adds origin info to the transaction approve/reject dialog
This commit is contained in:
Serg
2022-06-07 20:57:33 +01:00
committed by GitHub
3 changed files with 29 additions and 1 deletions
@@ -15,6 +15,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.webkit.URLUtil;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
@@ -47,6 +48,7 @@ import org.chromium.chrome.browser.crypto_wallet.listeners.TransactionConfirmati
import org.chromium.chrome.browser.crypto_wallet.observers.ApprovedTxObserver;
import org.chromium.chrome.browser.crypto_wallet.util.TokenUtils;
import org.chromium.chrome.browser.crypto_wallet.util.Utils;
import org.chromium.url.GURL;
import java.util.ArrayList;
import java.util.Collections;
@@ -321,6 +323,13 @@ public class ApproveTxBottomSheetDialogFragment extends BottomSheetDialogFragmen
});
refreshListContentUi();
}
if (mTxInfo.originInfo != null && URLUtil.isValidUrl(mTxInfo.originInfo.originSpec)) {
TextView domain = view.findViewById(R.id.domain);
domain.setVisibility(View.VISIBLE);
domain.setText(Utils.geteTLD(
new GURL(mTxInfo.originInfo.originSpec), mTxInfo.originInfo.eTldPlusOne));
}
}
public void setTxList(List<TransactionInfo> transactionInfos) {
@@ -1597,6 +1597,11 @@ public class Utils {
public static Spanned geteTLD(String etldPlusOne) {
GURL url = getCurentTabUrl();
return Utils.geteTLD(url, etldPlusOne);
}
public static Spanned geteTLD(GURL url, String etldPlusOne) {
StringBuilder builder = new StringBuilder();
builder.append(url.getScheme()).append("://").append(url.getHost());
int index = builder.indexOf(etldPlusOne);
@@ -64,6 +64,20 @@
app:layout_constraintTop_toBottomOf="@+id/network_name"
app:srcCompat="@drawable/ic_eth_24" />
<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/account_picture"
android:textColor="@color/wallet_text_color"
android:textSize="15sp"
android:visibility="gone" />
<TextView
android:id="@+id/from_to"
android:layout_width="match_parent"
@@ -75,7 +89,7 @@
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/account_picture" />
app:layout_constraintTop_toBottomOf="@+id/domain" />
<TextView
android:id="@+id/tx_type"