Retrieve profile using dependency injection in Wallet settings (#28608)
Retrieve profile using dependency injection rather than static method
This commit is contained in:
@@ -51,6 +51,8 @@ public class BraveWalletPreferences extends BravePreferenceFragment
|
||||
private static final String PREF_DEFAULT_ETHEREUM_WALLET = "default_ethereum_wallet";
|
||||
private static final String PREF_DEFAULT_SOLANA_WALLET = "default_solana_wallet";
|
||||
|
||||
private static final String PREF_BRAVE_WALLET_RESET = "pref_brave_wallet_reset";
|
||||
|
||||
private BraveDialogPreference mDefaultEthereumWallet;
|
||||
private BraveDialogPreference mDefaultSolanaWallet;
|
||||
private BraveWalletAutoLockPreferences mPrefAutolock;
|
||||
@@ -80,6 +82,12 @@ public class BraveWalletPreferences extends BravePreferenceFragment
|
||||
mPageTitle.set(getString(R.string.brave_ui_brave_wallet));
|
||||
SettingsUtils.addPreferencesFromResource(this, R.xml.brave_wallet_preferences);
|
||||
|
||||
BraveWalletResetPreference braveWalletResetPreference =
|
||||
findPreference(PREF_BRAVE_WALLET_RESET);
|
||||
if (braveWalletResetPreference != null) {
|
||||
braveWalletResetPreference.setProfile(getProfile());
|
||||
}
|
||||
|
||||
setUpNftDiscoveryPreference();
|
||||
mDefaultEthereumWallet = findPreference(PREF_DEFAULT_ETHEREUM_WALLET);
|
||||
if (mDefaultEthereumWallet != null) {
|
||||
|
||||
@@ -19,6 +19,7 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
@@ -33,6 +34,7 @@ import org.chromium.chrome.browser.crypto_wallet.util.WalletConstants;
|
||||
import org.chromium.chrome.browser.crypto_wallet.util.WalletNativeUtils;
|
||||
import org.chromium.chrome.browser.crypto_wallet.util.WalletUtils;
|
||||
import org.chromium.chrome.browser.preferences.ChromeSharedPreferences;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.ui.KeyboardVisibilityDelegate;
|
||||
|
||||
/**
|
||||
@@ -44,10 +46,9 @@ public class BraveWalletResetPreference
|
||||
|
||||
private int mPrefAccentColor;
|
||||
private final String mConfirmationPhrase;
|
||||
private Profile mProfile;
|
||||
|
||||
/**
|
||||
* Constructor for BraveWalletResetPreference.
|
||||
*/
|
||||
/** Constructor for BraveWalletResetPreference. */
|
||||
public BraveWalletResetPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
@@ -71,6 +72,10 @@ public class BraveWalletResetPreference
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setProfile(@NonNull final Profile profile) {
|
||||
mProfile = profile;
|
||||
}
|
||||
|
||||
private void showBraveWalletResetDialog() {
|
||||
LayoutInflater inflater =
|
||||
(LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
@@ -83,11 +88,12 @@ public class BraveWalletResetPreference
|
||||
|
||||
DialogInterface.OnClickListener onClickListener =
|
||||
(dialog, button) -> {
|
||||
assert mProfile != null;
|
||||
if (button == AlertDialog.BUTTON_POSITIVE) {
|
||||
String inputText = input.getText().toString().trim();
|
||||
if (TextUtils.equals(inputText, mConfirmationPhrase)) {
|
||||
Log.w(TAG, "Reset");
|
||||
WalletNativeUtils.resetWallet(Utils.getProfile(false));
|
||||
WalletNativeUtils.resetWallet(mProfile);
|
||||
KeystoreHelper.resetBiometric();
|
||||
Utils.setCryptoOnboarding(true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user