diff --git a/app/build.gradle b/app/build.gradle
index e776223148..60c00ebb5f 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -52,8 +52,8 @@ android {
applicationId "io.stormbird.wallet"
minSdk 24
targetSdk 34
- versionCode 257
- versionName "3.78"
+ versionCode 261
+ versionName "3.79"
android.buildFeatures.buildConfig true
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 40117de5e5..5168d3b2d8 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -14,8 +14,7 @@
-
-
+
+ android:exported="false">
-
-
diff --git a/app/src/main/java/com/alphawallet/app/ui/BackupFlowActivity.java b/app/src/main/java/com/alphawallet/app/ui/BackupFlowActivity.java
index 1b7cb26d44..514775b54d 100644
--- a/app/src/main/java/com/alphawallet/app/ui/BackupFlowActivity.java
+++ b/app/src/main/java/com/alphawallet/app/ui/BackupFlowActivity.java
@@ -157,14 +157,13 @@ private void initViews() {
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home)
{
- onBackPressed();
+ backPressed();
return true;
}
return super.onOptionsItemSelected(item);
}
- @Override
- public void onBackPressed() {
+ public void backPressed() {
Intent intent = new Intent();
setResult(RESULT_CANCELED, intent);
intent.putExtra("Key", wallet.address);
diff --git a/app/src/main/java/com/alphawallet/app/ui/BackupKeyActivity.java b/app/src/main/java/com/alphawallet/app/ui/BackupKeyActivity.java
index 1657b91617..436c6dd689 100644
--- a/app/src/main/java/com/alphawallet/app/ui/BackupKeyActivity.java
+++ b/app/src/main/java/com/alphawallet/app/ui/BackupKeyActivity.java
@@ -391,15 +391,14 @@ public boolean onOptionsItemSelected(MenuItem item)
{
case android.R.id.home:
{
- onBackPressed();
+ backPressed();
return true;
}
}
return super.onOptionsItemSelected(item);
}
- @Override
- public void onBackPressed()
+ private void backPressed()
{
switch (state)
{
diff --git a/app/src/main/java/com/alphawallet/app/ui/Erc20DetailActivity.java b/app/src/main/java/com/alphawallet/app/ui/Erc20DetailActivity.java
index 4ca127cf11..1fc29bff23 100644
--- a/app/src/main/java/com/alphawallet/app/ui/Erc20DetailActivity.java
+++ b/app/src/main/java/com/alphawallet/app/ui/Erc20DetailActivity.java
@@ -325,7 +325,11 @@ private void setTokenListener()
realmTokenUpdates = realm.where(RealmToken.class).equalTo("address", dbKey)
.greaterThan("addedTime", System.currentTimeMillis() - 5 * DateUtils.MINUTE_IN_MILLIS).findAllAsync();
realmTokenUpdates.addChangeListener(realmTokens -> {
- if (realmTokens.size() == 0) return;
+ if (realmTokens.isEmpty())
+ {
+ return;
+ }
+
for (RealmToken t : realmTokens)
{
TokenCardMeta meta = new TokenCardMeta(t.getChainId(), t.getTokenAddress(), t.getBalance(),
@@ -363,7 +367,6 @@ private void playNotification()
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
-// getMenuInflater().inflate(R.menu.menu_show_contract, menu);
return super.onCreateOptionsMenu(menu);
}
diff --git a/app/src/main/java/com/alphawallet/app/ui/GasSettingsActivity.java b/app/src/main/java/com/alphawallet/app/ui/GasSettingsActivity.java
index f438da9de9..389aa68cbd 100644
--- a/app/src/main/java/com/alphawallet/app/ui/GasSettingsActivity.java
+++ b/app/src/main/java/com/alphawallet/app/ui/GasSettingsActivity.java
@@ -228,13 +228,12 @@ public boolean onOptionsItemSelected(MenuItem item)
{
if (item.getItemId() == android.R.id.home)
{
- onBackPressed();
+ backPressed();
}
return super.onOptionsItemSelected(item);
}
- @Override
- public void onBackPressed()
+ private void backPressed()
{
Intent result = new Intent();
GasSpeed gs = gasSpread.getSelectedGasFee(currentGasSpeedIndex);
diff --git a/app/src/main/java/com/alphawallet/app/ui/HomeActivity.java b/app/src/main/java/com/alphawallet/app/ui/HomeActivity.java
index b4fb77ee1e..11ac88cf91 100644
--- a/app/src/main/java/com/alphawallet/app/ui/HomeActivity.java
+++ b/app/src/main/java/com/alphawallet/app/ui/HomeActivity.java
@@ -102,7 +102,6 @@ public class HomeActivity extends BaseNavigationActivity implements View.OnClick
{
@Inject
AWWalletConnectClient awWalletConnectClient;
-
public static final int RC_ASSET_EXTERNAL_WRITE_PERM = 223;
public static final int RC_ASSET_NOTIFICATION_PERM = 224;
public static final int DAPP_BARCODE_READER_REQUEST_CODE = 1;
diff --git a/app/src/main/java/com/alphawallet/app/ui/NFTAssetDetailActivity.java b/app/src/main/java/com/alphawallet/app/ui/NFTAssetDetailActivity.java
index 58ff870fc2..58694e2645 100644
--- a/app/src/main/java/com/alphawallet/app/ui/NFTAssetDetailActivity.java
+++ b/app/src/main/java/com/alphawallet/app/ui/NFTAssetDetailActivity.java
@@ -131,6 +131,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState)
initIntents();
initViewModel();
+
+ usingNativeTokenScript = !viewModel.getUseTSViewer();
}
private void initIntents()
@@ -308,12 +310,6 @@ private void setup()
setTitle(token.tokenInfo.name);
updateDefaultTokenData();
- if (!viewModel.getUseTSViewer())
- {
- TokenDefinition td = viewModel.getAssetDefinitionService().getAssetDefinition(this.token);
- this.usingNativeTokenScript = (td != null && td.nameSpace != null);
- }
-
if (asset != null && asset.isAttestation())
{
setupAttestation(viewModel.getAssetDefinitionService().getAssetDefinition(token));
@@ -356,11 +352,6 @@ private void newScriptFound(TokenDefinition td)
setTitle(token.getTokenName(viewModel.getAssetDefinitionService(), 1));
- if (!viewModel.getUseTSViewer())
- {
- this.usingNativeTokenScript = td.nameSpace != null;
- }
-
//now re-load the verbs if already called. If wallet is null this won't complete
setupFunctionBar(viewModel.getWallet());
diff --git a/app/src/main/java/com/alphawallet/app/ui/NetworkBaseActivity.java b/app/src/main/java/com/alphawallet/app/ui/NetworkBaseActivity.java
index 1cdad28770..f16cbb4adc 100644
--- a/app/src/main/java/com/alphawallet/app/ui/NetworkBaseActivity.java
+++ b/app/src/main/java/com/alphawallet/app/ui/NetworkBaseActivity.java
@@ -66,12 +66,6 @@ else if (item.getItemId() == R.id.action_node_status)
return false;
}
- @Override
- public void onBackPressed()
- {
- handleSetNetworks();
- }
-
protected abstract void handleSetNetworks();
protected void initTestNetDialog(TestNetDialog.TestNetDialogCallback callback)
diff --git a/app/src/main/java/com/alphawallet/app/ui/WalletActionsActivity.java b/app/src/main/java/com/alphawallet/app/ui/WalletActionsActivity.java
index ce876bcde9..a3482d94e0 100644
--- a/app/src/main/java/com/alphawallet/app/ui/WalletActionsActivity.java
+++ b/app/src/main/java/com/alphawallet/app/ui/WalletActionsActivity.java
@@ -28,20 +28,26 @@
import com.alphawallet.app.R;
import com.alphawallet.app.entity.BackupOperationType;
import com.alphawallet.app.entity.ErrorEnvelope;
+import com.alphawallet.app.entity.StandardFunctionInterface;
import com.alphawallet.app.entity.Wallet;
import com.alphawallet.app.entity.WalletType;
import com.alphawallet.app.ui.widget.entity.AddressReadyCallback;
import com.alphawallet.app.util.Utils;
import com.alphawallet.app.viewmodel.WalletActionsViewModel;
import com.alphawallet.app.widget.AWalletAlertDialog;
+import com.alphawallet.app.widget.FunctionButtonBar;
import com.alphawallet.app.widget.InputAddress;
+import com.alphawallet.app.widget.InputView;
import com.alphawallet.app.widget.SettingsItemView;
import com.alphawallet.app.widget.UserAvatar;
+import java.util.ArrayList;
+import java.util.Collections;
+
import dagger.hilt.android.AndroidEntryPoint;
@AndroidEntryPoint
-public class WalletActionsActivity extends BaseActivity implements Runnable, View.OnClickListener, AddressReadyCallback
+public class WalletActionsActivity extends BaseActivity implements Runnable, View.OnClickListener, AddressReadyCallback, StandardFunctionInterface
{
WalletActionsViewModel viewModel;
@@ -55,12 +61,12 @@ public class WalletActionsActivity extends BaseActivity implements Runnable, Vie
private SettingsItemView deleteWalletSetting;
private SettingsItemView backUpSetting;
private InputAddress inputAddress;
+ private InputView inputName;
private LinearLayout successOverlay;
private AWalletAlertDialog aDialog;
private final Handler handler = new Handler();
private Wallet wallet;
- private int walletCount;
private boolean isNewWallet;
@Override
@@ -70,10 +76,12 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
toolbar();
setTitle(getString(R.string.manage_wallet));
+ FunctionButtonBar functionBar = findViewById(R.id.layoutButtons);
+ functionBar.setupFunctions(this, new ArrayList<>(Collections.singletonList(R.string.action_save_name)));
+ functionBar.revealButtons();
+
if (getIntent() != null) {
wallet = (Wallet) getIntent().getExtras().get("wallet");
- walletCount = getIntent().getIntExtra("walletCount", 0);
- walletCount++;
isNewWallet = getIntent().getBooleanExtra("isNewWallet", false);
initViews();
} else {
@@ -106,13 +114,36 @@ private void initViewModel() {
viewModel.exportWalletError().observe(this, this::onExportError);
viewModel.deleted().observe(this, this::onDeleteWallet);
viewModel.isTaskRunning().observe(this, this::onTaskStatusChanged);
+ viewModel.walletCount().observe(this, this::setWalletName);
+ viewModel.ensName().observe(this, this::fetchedENSName);
- if (isNewWallet) {
- wallet.name = getString(R.string.wallet_name_template, walletCount);
- viewModel.updateWallet(wallet);
+ if (isNewWallet)
+ {
+ viewModel.fetchWalletCount();
+ }
+
+ if (wallet != null && TextUtils.isEmpty(wallet.ENSname))
+ {
+ //scan for ENS name
+ viewModel.scanForENS(wallet, this);
}
}
+ private void fetchedENSName(String ensName)
+ {
+ if (!TextUtils.isEmpty(ensName))
+ {
+ inputAddress.setENSName(ensName);
+ }
+ }
+
+ private void setWalletName(int walletCount)
+ {
+ wallet.name = getString(R.string.wallet_name_template, walletCount + 1);
+ inputName.setText(wallet.name);
+ viewModel.updateWallet(wallet);
+ }
+
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
@@ -139,7 +170,11 @@ public boolean onOptionsItemSelected(MenuItem item)
{
if (item.getItemId() == android.R.id.home)
{
- onBackPressed();
+ if (isNewWallet)
+ {
+ preFinish(); //drop back to home screen, no need to recreate everything
+ }
+ finish();
return true;
}
else if (item.getItemId() == R.id.action_key_status)
@@ -153,18 +188,10 @@ else if (item.getItemId() == R.id.action_key_status)
return super.onOptionsItemSelected(item);
}
- @Override
- public void onBackPressed()
+ private void onDeleteWallet(Boolean isDeleted)
{
- super.onBackPressed();
- if (isNewWallet)
+ if (isDeleted)
{
- preFinish(); //drop back to home screen, no need to recreate everything
- }
- }
-
- private void onDeleteWallet(Boolean isDeleted) {
- if (isDeleted) {
showWalletsActivity();
}
}
@@ -193,7 +220,8 @@ private void onDeleteError(ErrorEnvelope errorEnvelope) {
aDialog.show();
}
- private void initViews() {
+ private void initViews()
+ {
walletIcon = findViewById(R.id.wallet_icon);
walletBalance = findViewById(R.id.wallet_balance);
walletBalanceCurrency = findViewById(R.id.wallet_currency);
@@ -204,6 +232,7 @@ private void initViews() {
backUpSetting = findViewById(R.id.setting_backup);
walletSelectedIcon = findViewById(R.id.selected_wallet_indicator);
inputAddress = findViewById(R.id.input_ens);
+ inputName = findViewById(R.id.input_name);
walletSelectedIcon.setOnClickListener(this);
walletIcon.bind(wallet);
@@ -230,22 +259,43 @@ else if (wallet.type == WalletType.WATCH || wallet.type == WalletType.HARDWARE)
findViewById(R.id.layout_backup_method).setVisibility(View.GONE);
}
- inputAddress.setAddress(wallet.ENSname);
- inputAddress.setAddressCallback(this);
+ setupWalletNames();
+ }
+
+ private void setupWalletNames()
+ {
+ if (!TextUtils.isEmpty(wallet.ENSname))
+ {
+ inputAddress.setAddress(wallet.ENSname);
+ }
+
+ if (!Utils.isDefaultName(wallet.name, this))
+ {
+ inputName.setText(wallet.name);
+ }
}
private void setENSText()
{
- if (wallet.ENSname != null && !wallet.ENSname.isEmpty()) {
+ if (!TextUtils.isEmpty(wallet.ENSname))
+ {
walletNameText.setText(wallet.ENSname);
walletNameText.setVisibility(View.VISIBLE);
walletAddressSeparator.setVisibility(View.VISIBLE);
- } else {
+ }
+ else
+ {
walletNameText.setVisibility(View.GONE);
walletAddressSeparator.setVisibility(View.GONE);
}
}
+ @Override
+ public void handleClick(String action, int actionId)
+ {
+ saveWalletName();
+ }
+
private void onDeleteWalletSettingClicked() {
confirmDelete(wallet);
}
@@ -254,13 +304,11 @@ private void onBackUpSettingClicked() {
doBackUp();
}
- private void saveWalletName() {
-// wallet.name = walletNameText.getText().toString();
+ private void saveWalletName()
+ {
+ wallet.name = inputName.getText().toString();
viewModel.updateWallet(wallet);
- if (isNewWallet) {
- viewModel.showHome(this);
- preFinish(); //drop back to home screen, no need to recreate everything
- }
+ finish();
}
private void doBackUp() {
diff --git a/app/src/main/java/com/alphawallet/app/ui/WalletDiagnosticActivity.java b/app/src/main/java/com/alphawallet/app/ui/WalletDiagnosticActivity.java
index 1704ba5f40..a4f6d72b6a 100644
--- a/app/src/main/java/com/alphawallet/app/ui/WalletDiagnosticActivity.java
+++ b/app/src/main/java/com/alphawallet/app/ui/WalletDiagnosticActivity.java
@@ -8,6 +8,7 @@
import android.os.Handler;
import android.os.Looper;
import android.util.Pair;
+import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
@@ -47,6 +48,7 @@
import dagger.hilt.android.AndroidEntryPoint;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
+import timber.log.Timber;
import wallet.core.jni.CoinType;
import wallet.core.jni.HDWallet;
import wallet.core.jni.PrivateKey;
@@ -151,13 +153,18 @@ private void startKeyDiagnostic()
}
}
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu)
+ {
+ return super.onCreateOptionsMenu(menu);
+ }
+
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
if (item.getItemId() == android.R.id.home)
{
- onBackPressed();
- return true;
+ finish();
}
return super.onOptionsItemSelected(item);
@@ -402,7 +409,7 @@ private boolean testKeyType(String keyData)
private int wordCount(String value)
{
- if (value == null || value.length() == 0) return 0;
+ if (value == null || value.isEmpty()) return 0;
String[] split = value.split("\\s+");
return split.length;
}
@@ -411,7 +418,7 @@ private int wordCount(String value)
// Always use the ActionSheet + implement ActionSheetCallback as per SendActivity, NFTAssetDetailActivity etc
private void doUnlock(UnlockCallback cb)
{
- if (BuildConfig.DEBUG /*&& Utils.isRunningTest()*/) //running tests in debug build mode, we don't use key unlock
+ if (BuildConfig.DEBUG && Utils.isRunningTest()) //running tests in debug build mode, we don't use key unlock
{
cb.carryOn(true);
return;
@@ -455,7 +462,7 @@ private String dumpKeystoreFromSeedPhrase(String seedPhrase, String keystorePass
}
catch (Exception e)
{
- e.printStackTrace();
+ Timber.e(e);
}
return "";
diff --git a/app/src/main/java/com/alphawallet/app/ui/WalletsActivity.java b/app/src/main/java/com/alphawallet/app/ui/WalletsActivity.java
index 00e8638361..bcd56587d9 100644
--- a/app/src/main/java/com/alphawallet/app/ui/WalletsActivity.java
+++ b/app/src/main/java/com/alphawallet/app/ui/WalletsActivity.java
@@ -30,7 +30,6 @@
import com.alphawallet.app.entity.Operation;
import com.alphawallet.app.entity.SyncCallback;
import com.alphawallet.app.entity.Wallet;
-import com.alphawallet.app.entity.WalletConnectActions;
import com.alphawallet.app.entity.tokens.Token;
import com.alphawallet.app.repository.EthereumNetworkRepository;
import com.alphawallet.app.repository.PreferenceRepositoryType;
@@ -77,7 +76,6 @@ public class WalletsActivity extends BaseActivity implements
private Dialog dialog;
private AWalletAlertDialog aDialog;
private WalletsSummaryAdapter adapter;
- private Wallet selectedWallet;
private ActivityResultLauncher editWalletDetails;
private AWalletAlertDialog cardReadDialog;
private String dialogError;
@@ -256,8 +254,7 @@ public void onDestroy()
if (viewModel != null) viewModel.onDestroy();
}
- @Override
- public void onBackPressed()
+ private void backPressed()
{
preFinish();
// User can't start work without wallet.
@@ -283,7 +280,7 @@ public boolean onOptionsItemSelected(MenuItem item)
}
else if (item.getItemId() == android.R.id.home)
{
- onBackPressed();
+ backPressed();
return true;
}
return super.onOptionsItemSelected(item);
@@ -387,7 +384,6 @@ private void setupWallet(Wallet wallet)
adapter.setDefaultWallet(wallet);
scrollToDefaultWallet();
}
- selectedWallet = wallet;
}
/**
@@ -429,13 +425,6 @@ private void updateCurrentWallet(Wallet wallet)
scrollToDefaultWallet();
viewModel.stopUpdates();
-
- /*Intent bIntent = new Intent(this, WalletConnectService.class);
- bIntent.setAction(String.valueOf(WalletConnectActions.DISCONNECT.ordinal()));
- bIntent.putExtra("wallet", selectedWallet);
- startService(bIntent);*/
-
- selectedWallet = wallet;
}
private void onFetchWallets(Wallet[] wallets)
@@ -461,7 +450,6 @@ private void callNewWalletPage(Wallet wallet)
Intent intent = new Intent(this, WalletActionsActivity.class);
intent.putExtra("wallet", wallet);
intent.putExtra("currency", viewModel.getNetwork().symbol);
- intent.putExtra("walletCount", adapter.getItemCount());
intent.putExtra("isNewWallet", true);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
diff --git a/app/src/main/java/com/alphawallet/app/ui/widget/adapter/WalletsSummaryAdapter.java b/app/src/main/java/com/alphawallet/app/ui/widget/adapter/WalletsSummaryAdapter.java
index 3b4c7ce90a..5b89d99fbb 100644
--- a/app/src/main/java/com/alphawallet/app/ui/widget/adapter/WalletsSummaryAdapter.java
+++ b/app/src/main/java/com/alphawallet/app/ui/widget/adapter/WalletsSummaryAdapter.java
@@ -56,9 +56,9 @@ public WalletsSummaryAdapter(Context ctx,
@NotNull
@Override
- public BinderViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType)
+ public BinderViewHolder> onCreateViewHolder(@NotNull ViewGroup parent, int viewType)
{
- BinderViewHolder binderViewHolder = null;
+ BinderViewHolder> binderViewHolder = null;
switch (viewType)
{
case WalletHolder.VIEW_TYPE:
@@ -80,10 +80,11 @@ public BinderViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewTy
public void onBindViewHolder(@NotNull BinderViewHolder holder, int position)
{
Bundle bundle;
+ Wallet wallet;
switch (getItemViewType(position))
{
case WalletHolder.VIEW_TYPE:
- Wallet wallet = wallets.get(position);
+ wallet = wallets.get(position);
bundle = new Bundle();
bundle.putBoolean(
WalletHolder.IS_DEFAULT_ADDITION,
diff --git a/app/src/main/java/com/alphawallet/app/ui/widget/holder/WalletSummaryHolder.java b/app/src/main/java/com/alphawallet/app/ui/widget/holder/WalletSummaryHolder.java
index d0e9f175b4..d7d7073e39 100644
--- a/app/src/main/java/com/alphawallet/app/ui/widget/holder/WalletSummaryHolder.java
+++ b/app/src/main/java/com/alphawallet/app/ui/widget/holder/WalletSummaryHolder.java
@@ -55,7 +55,6 @@ public class WalletSummaryHolder extends BinderViewHolder implements Vie
private final TextView wallet24hChange;
private final TokensBalanceView tokensBalanceView;
private final Realm realm;
- private RealmResults realmUpdate;
private final WalletClickCallback clickCallback;
private Wallet wallet = null;
protected Disposable disposable;
@@ -83,7 +82,6 @@ public WalletSummaryHolder(int resId, ViewGroup parent, WalletClickCallback call
public void bind(@Nullable Wallet data, @NonNull Bundle addition)
{
walletAddressText.setText(null);
- if (realmUpdate != null) realmUpdate.removeAllChangeListeners();
if (data != null)
{
@@ -103,54 +101,62 @@ public void bind(@Nullable Wallet data, @NonNull Bundle addition)
manageWalletBtn.setVisibility(View.VISIBLE);
- if (wallet.name != null && !wallet.name.isEmpty())
- {
- walletNameText.setText(wallet.name);
- walletAddressSeparator.setVisibility(View.VISIBLE);
- walletNameText.setVisibility(View.VISIBLE);
- }
- else if (wallet.ENSname != null && wallet.ENSname.length() > 0)
- {
- walletNameText.setText(wallet.ENSname);
- walletAddressSeparator.setVisibility(View.VISIBLE);
- walletNameText.setVisibility(View.VISIBLE);
- }
- else
- {
- walletAddressSeparator.setVisibility(View.GONE);
- walletNameText.setVisibility(View.GONE);
- }
+ setWalletName(wallet.name, wallet.ENSname);
walletIcon.bind(wallet, this);
- String walletBalance = wallet.balance;
- if (!TextUtils.isEmpty(walletBalance) && walletBalance.startsWith("*"))
- {
- walletBalance = walletBalance.substring(1);
- }
- walletBalanceText.setText(String.format("%s %s", walletBalance, wallet.balanceSymbol));
+ setWalletBalance(wallet.balance, addition);
- walletAddressText.setText(Utils.formatAddress(wallet.address));
+ checkLastBackUpTime();
+ }
+ }
- if (addition.getBoolean(IS_SYNCED, false))
- {
- walletIcon.finishWaiting();
- }
- else
- {
- walletIcon.setWaiting();
- }
+ private void setWalletBalance(String walletBalance, Bundle addition)
+ {
+ if (!TextUtils.isEmpty(walletBalance) && walletBalance.startsWith("*"))
+ {
+ walletBalance = walletBalance.substring(1);
+ }
+ walletBalanceText.setText(String.format("%s %s", walletBalance, wallet.balanceSymbol));
+
+ walletAddressText.setText(Utils.formatAddress(wallet.address));
- double fiatValue = addition.getDouble(FIAT_VALUE, 0.00);
- double oldFiatValue = addition.getDouble(FIAT_CHANGE, 0.00);
+ if (addition.getBoolean(IS_SYNCED, false))
+ {
+ walletIcon.finishWaiting();
+ }
+ else
+ {
+ walletIcon.setWaiting();
+ }
- String balanceTxt = TickerService.getCurrencyString(fiatValue);
- walletBalanceText.setVisibility(View.VISIBLE);
- walletBalanceText.setText(balanceTxt);
- setWalletChange(fiatValue != 0 ? ((fiatValue - oldFiatValue) / oldFiatValue) * 100.0 : 0.0);
+ double fiatValue = addition.getDouble(FIAT_VALUE, 0.00);
+ double oldFiatValue = addition.getDouble(FIAT_CHANGE, 0.00);
- checkLastBackUpTime();
- startRealmListener();
+ String balanceTxt = TickerService.getCurrencyString(fiatValue);
+ walletBalanceText.setVisibility(View.VISIBLE);
+ walletBalanceText.setText(balanceTxt);
+ setWalletChange(fiatValue != 0 ? ((fiatValue - oldFiatValue) / oldFiatValue) * 100.0 : 0.0);
+ }
+
+ private void setWalletName(String walletName, String ensName)
+ {
+ if (!TextUtils.isEmpty(ensName) && (TextUtils.isEmpty(walletName) || Utils.isDefaultName(walletName, getContext())))
+ {
+ walletNameText.setText(ensName);
+ walletAddressSeparator.setVisibility(View.VISIBLE);
+ walletNameText.setVisibility(View.VISIBLE);
+ }
+ else if (!TextUtils.isEmpty(walletName))
+ {
+ walletNameText.setText(walletName);
+ walletAddressSeparator.setVisibility(View.VISIBLE);
+ walletNameText.setVisibility(View.VISIBLE);
+ }
+ else
+ {
+ walletAddressSeparator.setVisibility(View.GONE);
+ walletNameText.setVisibility(View.GONE);
}
}
@@ -177,34 +183,6 @@ private void setWalletChange(double percentChange24h)
{ /* Quietly */ }
}
- private void startRealmListener()
- {
- realmUpdate = realm.where(RealmWalletData.class)
- .equalTo("address", wallet.address).findAllAsync();
- realmUpdate.addChangeListener(realmWallets ->
- {
- //update balance
- if (realmWallets.size() == 0) return;
- RealmWalletData realmWallet = realmWallets.first();
- //walletBalanceText.setTextColor(blackColor);
- //walletBalanceText.setText(realmWallet.getBalance());
- String ensName = realmWallet.getENSName();
- String name = realmWallet.getName();
- if (!TextUtils.isEmpty(name))
- {
- walletNameText.setText(name);
- walletAddressSeparator.setVisibility(View.VISIBLE);
- walletNameText.setVisibility(View.VISIBLE);
- }
- else if (!TextUtils.isEmpty(ensName))
- {
- walletNameText.setText(ensName);
- walletAddressSeparator.setVisibility(View.VISIBLE);
- walletNameText.setVisibility(View.VISIBLE);
- }
- });
- }
-
private Wallet fetchWallet(Wallet w)
{
RealmWalletData realmWallet = realm.where(RealmWalletData.class)
diff --git a/app/src/main/java/com/alphawallet/app/util/Utils.java b/app/src/main/java/com/alphawallet/app/util/Utils.java
index 5a136bcdcb..c808fe8ca8 100644
--- a/app/src/main/java/com/alphawallet/app/util/Utils.java
+++ b/app/src/main/java/com/alphawallet/app/util/Utils.java
@@ -1451,7 +1451,7 @@ public static boolean isDefaultName(String name, Context ctx)
{
//wallet.name = getString(R.string.wallet_name_template, walletCount);
String walletStr = ctx.getString(R.string.wallet_name_template, 1);
- String walletSplit[] = walletStr.split(" ");
+ String[] walletSplit = walletStr.split(" ");
walletStr = walletSplit[0];
if (!TextUtils.isEmpty(name) && name.startsWith(walletStr) && walletSplit.length == 2)
{
diff --git a/app/src/main/java/com/alphawallet/app/viewmodel/WalletActionsViewModel.java b/app/src/main/java/com/alphawallet/app/viewmodel/WalletActionsViewModel.java
index f27bc89e6d..fc45269cbf 100644
--- a/app/src/main/java/com/alphawallet/app/viewmodel/WalletActionsViewModel.java
+++ b/app/src/main/java/com/alphawallet/app/viewmodel/WalletActionsViewModel.java
@@ -1,5 +1,7 @@
package com.alphawallet.app.viewmodel;
+import static com.alphawallet.ethereum.EthereumNetworkBase.MAINNET_ID;
+
import android.content.Context;
import android.text.TextUtils;
@@ -12,8 +14,11 @@
import com.alphawallet.app.interact.DeleteWalletInteract;
import com.alphawallet.app.interact.ExportWalletInteract;
import com.alphawallet.app.interact.FetchWalletsInteract;
+import com.alphawallet.app.repository.TokenRepository;
import com.alphawallet.app.router.HomeRouter;
import com.alphawallet.app.service.AlphaWalletNotificationService;
+import com.alphawallet.app.util.Utils;
+import com.alphawallet.app.util.ens.AWEnsResolver;
import com.alphawallet.ethereum.EthereumNetworkBase;
import javax.inject.Inject;
@@ -35,7 +40,9 @@ public class WalletActionsViewModel extends BaseViewModel
private final FetchWalletsInteract fetchWalletsInteract;
private final AlphaWalletNotificationService alphaWalletNotificationService;
private final MutableLiveData saved = new MutableLiveData<>();
+ private final MutableLiveData walletCount = new MutableLiveData<>();
private final MutableLiveData deleted = new MutableLiveData<>();
+ private final MutableLiveData ensName = new MutableLiveData<>();
private final MutableLiveData exportWalletError = new MutableLiveData<>();
private final MutableLiveData deleteWalletError = new MutableLiveData<>();
private final MutableLiveData isTaskRunning = new MutableLiveData<>();
@@ -76,6 +83,14 @@ public LiveData saved()
{
return saved;
}
+ public LiveData walletCount()
+ {
+ return walletCount;
+ }
+ public LiveData ensName()
+ {
+ return ensName;
+ }
public LiveData isTaskRunning()
{
@@ -95,6 +110,16 @@ private void prepareForDeletion()
alphaWalletNotificationService.unsubscribeToTopic(EthereumNetworkBase.MAINNET_ID);
}
+ public void fetchWalletCount()
+ {
+ disposable = fetchWalletsInteract
+ .fetch()
+ .map(wallets -> wallets.length)
+ .observeOn(Schedulers.io())
+ .subscribeOn(Schedulers.io())
+ .subscribe(walletCount::postValue, this::onError);
+ }
+
public void deleteWallet(Wallet wallet)
{
isTaskRunning.postValue(true);
@@ -139,4 +164,19 @@ public void updateWallet(Wallet wallet)
saved.postValue(1);
});
}
+
+ public void scanForENS(Wallet wallet, Context ctx)
+ {
+ //check for ENS name
+ new AWEnsResolver(TokenRepository.getWeb3jService(MAINNET_ID), ctx)
+ .reverseResolveEns(wallet.address)
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribeOn(Schedulers.io())
+ .subscribe(ensName::postValue, this::onENSError).isDisposed();
+ }
+
+ private void onENSError(Throwable throwable)
+ {
+ //No Action
+ }
}
diff --git a/app/src/main/res/layout/activity_wallet_actions.xml b/app/src/main/res/layout/activity_wallet_actions.xml
index c8736de875..a719350f35 100644
--- a/app/src/main/res/layout/activity_wallet_actions.xml
+++ b/app/src/main/res/layout/activity_wallet_actions.xml
@@ -1,109 +1,136 @@
-
-
-
+
+
+
+
+
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+ android:id="@+id/layout_backup_method"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+ android:id="@+id/setting_backup"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:settingIcon="-1"
+ app:settingTitle="@string/show_seed_phrase"
+ app:settingType="default" />
+ android:id="@+id/backup_text"
+ style="@style/Aw.Typography.Sub"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/standard_16"
+ android:text="@string/seed_phrase_loss_warning" />
+ android:id="@+id/delete"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:settingIcon="-1"
+ app:settingTitle="@string/lose_this_wallet"
+ app:settingType="default" />
+ style="@style/Aw.Typography.Sub"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/standard_16"
+ android:text="@string/delete_lose_funds_warning" />
+ style="@style/Aw.Component.Separator"
+ android:layout_marginTop="@dimen/dp20" />
+
+
+ android:id="@+id/input_ens"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/standard_16"
+ tools:visible="true"
+ custom:ens="true"
+ custom:show_header="false"
+ custom:hint="@string/enter_ens"
+ custom:label="@string/ens_name"
+ custom:nocam="true" />
+
+
+ android:id="@+id/layout_success_overlay"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/translucent_dark"
+ android:gravity="center"
+ android:visibility="gone">
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center|center_horizontal|center_vertical"
+ android:background="@drawable/big_green_tick"
+ android:foregroundGravity="center" />
-
\ No newline at end of file
+
+
+
diff --git a/app/src/main/res/layout/activity_wallet_diagnostic.xml b/app/src/main/res/layout/activity_wallet_diagnostic.xml
index b668d0b21a..3eebf5cb22 100644
--- a/app/src/main/res/layout/activity_wallet_diagnostic.xml
+++ b/app/src/main/res/layout/activity_wallet_diagnostic.xml
@@ -145,4 +145,4 @@
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
-
\ No newline at end of file
+