UI improvements

pull/2/head
Marat Subkhankulov 7 years ago
parent 95615d34ca
commit 358a7fc667
  1. 42
      app/src/main/java/com/wallet/crypto/trust/controller/Controller.java
  2. 2
      app/src/main/res/layout/activity_account_list.xml
  3. 9
      app/src/main/res/menu/account_menu.xml
  4. 2
      app/src/main/res/menu/transaction_list_menu.xml
  5. 13
      app/src/main/res/values/strings.xml

@ -63,8 +63,7 @@ public class Controller {
// Services
private Context mAppContext;
private EtherStore mEtherStore;
private Retrofit mRetrofit;
private EtherscanService mEtherscanService;
private Map<String, EtherscanService> mEtherscanServices;
// State
private String mKeystoreBaseDir;
@ -100,26 +99,18 @@ public class Controller {
// Create networks list
mNetworks = new ArrayList<>();
mNetworks.add(new VMNetwork("kovan", "https://kovan.infura.io/llyrtzQ3YhkdESt2Fzrk", "https://kovan.etherscan.io", "ZVU87DFQYV2TPJQKRJDITS42MW58GUEZ4V", 42));
mNetworks.add(new VMNetwork("mainnet", "https://mainnet.infura.io/llyrtzQ3YhkdESt2Fzrk", "https://mainnet.etherscan.io", "?", 1));
setCurrentNetwork(mNetworks.get(0).getName());
// Setup service
mRetrofit = new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.baseUrl(mCurrentNetwork.getEtherscanUrl())
.build();
mNetworks.add(new VMNetwork("kovan", "https://kovan.infura.io/llyrtzQ3YhkdESt2Fzrk", "https://kovan.etherscan.io", "ZVU87DFQYV2TPJQKRJDITS42MW58GUEZ4V", 42));
mNetworks.add(new VMNetwork("ropstein", "https://ropstein.infura.io/llyrtzQ3YhkdESt2Fzrk", "https://ropstein.etherscan.io", "ZVU87DFQYV2TPJQKRJDITS42MW58GUEZ4V", 42));
mNetworks.add(new VMNetwork("rinkeby", "https://rinkeby.infura.io/llyrtzQ3YhkdESt2Fzrk", "https://rinkeby.etherscan.io", "ZVU87DFQYV2TPJQKRJDITS42MW58GUEZ4V", 42));
mNetworks.add(new VMNetwork("mainnet", "https://mainnet.infura.io/llyrtzQ3YhkdESt2Fzrk", "https://api.etherscan.io", "ZVU87DFQYV2TPJQKRJDITS42MW58GUEZ4V", 1));
mEtherscanService = mRetrofit.create(EtherscanService.class);
setCurrentNetwork(mNetworks.get(0).getName());
mAccounts = new ArrayList<>();
mTransactions = new HashMap<>();
mBalances = new HashMap<>();
// Dummy data TODO remove
//mAccounts.add(new VMAccount(getString(R.string.default_address), "0"));
//mAccounts.add(new VMAccount("0x5DD0b5D02cD574412Ad58dD84A2F402cc25e320a", "0"));
loadAccounts();
if (mAccounts.size() > 0) {
@ -131,6 +122,10 @@ public class Controller {
}
}
private EtherscanService getCurrentEtherscanService() {
return mEtherscanServices.get(mCurrentAddress);
}
private List<VMAccount> loadAccounts() {
mAccounts = new ArrayList<>();
try {
@ -279,6 +274,11 @@ public class Controller {
public void deleteAccount(String address, String password) throws Exception {
mEtherStore.deleteAccount(address, password);
loadAccounts();
if (address.equals(mCurrentAddress)) {
if (mAccounts.size() > 0) {
mCurrentAddress = mAccounts.get(0).getAddress();
}
}
}
public void navigateToExportAccount(Context context, String address) {
@ -500,8 +500,18 @@ public class Controller {
private void fetchTransactionsForAddress(VMAccount account) {
final String address = account.getAddress();
try {
Retrofit mRetrofit = new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.baseUrl(mCurrentNetwork.getEtherscanUrl())
.build();
EtherscanService service = mRetrofit.create(EtherscanService.class);
Log.d(TAG, "Using etherscan service: " + mCurrentNetwork.getName() + ", " + mCurrentNetwork.getEtherscanUrl() + ", " + mCurrentNetwork.getEtherscanApiKey());
Call<ESTransactionListResponse> call =
mEtherscanService.getTransactionList(
service.getTransactionList(
"account",
"txlist",
address,

@ -36,6 +36,6 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@drawable/ic_add_black_24dp" />
app:srcCompat="@drawable/ic_add_white_24dp" />
</android.support.design.widget.CoordinatorLayout>

@ -1,14 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/navigation_receive"
android:icon="@drawable/ic_add_circle_black_24dp"
android:title="@string/title_receive" />
<item
android:id="@+id/navigation_send"
android:icon="@drawable/ic_send_white_24dp"
android:title="@string/title_send" />
<item
android:id="@+id/navigation_receive"
android:icon="@drawable/ic_add_circle_black_24dp"
android:title="@string/title_request" />
</menu>

@ -5,7 +5,7 @@
<item
android:id="@+id/action_receive"
android:icon="@drawable/ic_swap_horiz_white_24dp"
android:title="@string/action_receive"
android:title="@string/action_request"
android:orderInCategory="80"
app:showAsAction="never"/>

@ -2,7 +2,7 @@
<string name="app_name">Trust</string>
<string name="balance">Balance</string>
<string name="title_send">Send</string>
<string name="title_receive">Receive</string>
<string name="title_request">Request</string>
<string name="title_import">Import</string>
<string name="title_create">Create</string>
<string name="title_account">Accounts</string>
@ -153,18 +153,9 @@
<string name="no_barcode_captured">no barcode captured</string>
<string name="scan_barcode_button">Scan</string>
<string name="barcode_error_format">Invalid barcode format: %s</string>
<string name="action_receive">Receive</string>
<string name="action_request">Request</string>
<string name="title_home">Home</string>
<string name="title_dashboard">Dashboard</string>
<string name="title_notifications">Notifications</string>
<!-- TODO remove -->
<!--<string name="infura_url">https://kovan.infura.io/llyrtzQ3YhkdESt2Fzrk</string>-->
<!-- <string name="default_network">https://infuranet.infura.io/llyrtzQ3YhkdESt2Fzrk</string> -->
<!-- <string name="default_network">https://ropsten.infura.io/llyrtzQ3YhkdESt2Fzrk</string>-->
<!--<string name="default_address">0x5DD0b5D02cD574412Ad58dD84A2F402cc25e320a</string>-->
<!--<string name="default_address">0x14385e875471d22b6ad8a91ccf0f3577335ee367</string>-->
<!--<string name="default_password">password</string>-->
<!--<string name="etherscan_api_key">ZVU87DFQYV2TPJQKRJDITS42MW58GUEZ4V</string>-->
<!--<string name="etherscan_url">https://kovan.etherscan.io</string>-->
</resources>

Loading…
Cancel
Save