fix: Wallet qr address and link color per theme

- add lint warning details
This commit is contained in:
Pavneet-Sing
2022-10-03 23:00:40 +05:30
parent 4a041703ff
commit d92d4acf7c
9 changed files with 44 additions and 19 deletions
@@ -78,6 +78,7 @@ import org.chromium.chrome.browser.crypto_wallet.adapters.WalletCoinAdapter;
import org.chromium.chrome.browser.crypto_wallet.fragments.ApproveTxBottomSheetDialogFragment;
import org.chromium.chrome.browser.crypto_wallet.fragments.EditVisibleAssetsBottomSheetDialogFragment;
import org.chromium.chrome.browser.crypto_wallet.observers.ApprovedTxObserver;
import org.chromium.chrome.browser.crypto_wallet.util.AddressUtils;
import org.chromium.chrome.browser.crypto_wallet.util.TokenUtils;
import org.chromium.chrome.browser.crypto_wallet.util.Utils;
import org.chromium.chrome.browser.crypto_wallet.util.Validations;
@@ -1134,17 +1135,18 @@ public class BuySendSwapActivity extends BraveWalletBaseActivity
if (barcode == null) {
return;
}
final String barcodeValue = barcode.displayValue;
runOnUiThread(new Runnable() {
@Override
public void run() {
if (null != mCameraSourcePreview) {
mCameraSourcePreview.stop();
}
RelativeLayout relativeLayout = findViewById(R.id.camera_layout);
relativeLayout.setVisibility(View.GONE);
mSendToAddrText.setText(barcodeValue);
String barcodeValue = barcode.displayValue;
if (mSelectedNetwork.coin == CoinType.ETH) {
barcodeValue = AddressUtils.sanitizeEthAddress(barcodeValue);
}
final String finalBarcodeValue = barcodeValue;
runOnUiThread(() -> {
if (null != mCameraSourcePreview) {
mCameraSourcePreview.stop();
}
RelativeLayout relativeLayout = findViewById(R.id.camera_layout);
relativeLayout.setVisibility(View.GONE);
mSendToAddrText.setText(finalBarcodeValue);
});
}
@@ -95,8 +95,11 @@ public class BraveDappPermissionPromptDialog
}
}
// TODO: It is much more efficient to retrieve resources by identifier (e.g. R.foo.bar) than by
// name (e.g. getIdentifier("bar", "foo", null)).
// @SuppressLint("DiscouragedApi") is required to suppress "getIdentifier" usage
// The "container" view group is part of a dialog created by PropertyModel.Builder chromium API,
// to which we don't have any direct access so there is no direct way to access the positive
// button (as per my R&D) of the dialog created by PropertyModel.Builder. "getIdentifier" is the
// only option to get the exact positive button's identifier value to change its state.
@SuppressLint("DiscouragedApi")
@CalledByNative
void show() {
@@ -0,0 +1,18 @@
/* Copyright (c) 2022 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.chromium.chrome.browser.crypto_wallet.util;
import android.text.TextUtils;
public class AddressUtils {
public static String sanitizeEthAddress(String ethAddress) {
if (TextUtils.isEmpty(ethAddress)) return "";
if (ethAddress.matches(WalletConstants.REGX_ANY_ETH_ADDRESS)) {
return ethAddress.replaceAll(WalletConstants.REGX_ANY_ETH_ADDRESS, "$1");
}
return ethAddress;
}
}
@@ -16,6 +16,9 @@ public final class WalletConstants {
"https://doc.aurora.dev/bridge/bridge-overview/";
public static final String URL_RAINBOW_BRIDGE_RISKS = "https://rainbowbridge.app/approvals";
// Regex
public static final String REGX_ANY_ETH_ADDRESS = ".*(0x[a-fA-F0-9]{40}).*";
// Aurora
public static final String URL_RAINBOW_AURORA = "https://rainbowbridge.app";
@@ -9,11 +9,10 @@
<TextView
android:id="@+id/dialog_aurora_tv_title"
style="@style/BraveWalletTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/brave_wallet_aurora_modal_title"
android:textColor="@color/wallet_secondary_text_color"
android:textSize="16sp"
android:textStyle="bold" />
@@ -24,8 +23,7 @@
android:layout_marginStart="16dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="16dp"
android:text="@string/brave_wallet_aurora_modal_description"
android:textColor="@color/wallet_secondary_text_color" />
android:text="@string/brave_wallet_aurora_modal_description" />
<CheckBox
android:id="@+id/dialog_aurora_cb_dont_show"
@@ -15,7 +15,7 @@
<!-- Theme colors -->
<color name="brave_tab_view_card_selected_bg">@color/baseline_primary_200</color>
<color name="brave_link">#F35333</color>
<color name="brave_link">#A0A5EB</color>
<color name="onboarding_text_color">#F0F2FF</color>
<color name="onboarding_bg_color">#1E2029</color>
+1 -1
View File
@@ -9,7 +9,7 @@
<!-- Theme colors -->
<color name="brave_white">@android:color/white</color>
<color name="brave_link">#0000EE</color>
<color name="brave_link">#4C54D2</color>
<!-- Overriding chromium theme colors to brave theme colors -->
<color name="baseline_primary_100">#F9C3B6</color>
+1 -1
View File
@@ -58,7 +58,7 @@
<style name="BraveWalletTextView" parent="Widget.AppCompat.TextView">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">@color/wallet_text_color</item>
<item name="android:textColor">@color/brave_wallet_day_night_text_color</item>
<item name="android:textColorLink">@color/brave_link</item>
<item name="android:textSize">14sp</item>
</style>