- Now the bitcoin alike account are created using the interface in "seed settings" to choose them
- Now the balance list header shows the coin icon of its crypto net - Added icons to cryptoNet enum
This commit is contained in:
parent
043325b887
commit
e9f77c4981
10 changed files with 35 additions and 7 deletions
|
@ -4,6 +4,8 @@ import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import cy.agorise.crystalwallet.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CryptoNet Enumeration, a Crypto Net is define as the net where a CryptoCoin works, iniside the
|
* CryptoNet Enumeration, a Crypto Net is define as the net where a CryptoCoin works, iniside the
|
||||||
* CrypotNet is where the transaction and balance works, using the CryptoCoin Assets
|
* CrypotNet is where the transaction and balance works, using the CryptoCoin Assets
|
||||||
|
@ -11,7 +13,14 @@ import java.util.Map;
|
||||||
* Created by Henry Varona on 12/9/2017.
|
* Created by Henry Varona on 12/9/2017.
|
||||||
*/
|
*/
|
||||||
public enum CryptoNet implements Serializable {
|
public enum CryptoNet implements Serializable {
|
||||||
UNKNOWN("UNKNOWN",6,-1), BITCOIN("BITCOIN",6,1), BITCOIN_TEST("BITCOIN(TEST)",6,2), LITECOIN("LITECOIN",6,3), DASH("DASH",6,5), DOGECOIN("DOGECOIN",6,4), BITSHARES("BITSHARES",1,6), STEEM("STEEM",1,7);
|
UNKNOWN("UNKNOWN",6,-1,android.R.drawable .ic_menu_help),
|
||||||
|
BITCOIN("BITCOIN",6,1,R.drawable.coin_icon_bitcoin),
|
||||||
|
BITCOIN_TEST("BITCOIN(TEST)",6,2,R.drawable.coin_icon_bitcoin),
|
||||||
|
LITECOIN("LITECOIN",6,3,R.drawable.coin_icon_litecoin),
|
||||||
|
DASH("DASH",6,5,R.drawable.coin_icon_dash),
|
||||||
|
DOGECOIN("DOGECOIN",6,4,R.drawable.coin_icon_doge),
|
||||||
|
BITSHARES("BITSHARES",1,6,R.drawable.bts),
|
||||||
|
STEEM("STEEM",1,7,R.drawable.coin_icon_steem);
|
||||||
|
|
||||||
protected String label;
|
protected String label;
|
||||||
|
|
||||||
|
@ -19,6 +28,8 @@ public enum CryptoNet implements Serializable {
|
||||||
|
|
||||||
protected int bip44Index;
|
protected int bip44Index;
|
||||||
|
|
||||||
|
protected int iconImageResource;
|
||||||
|
|
||||||
private static Map<Integer, CryptoNet> bip44Map = new HashMap<Integer, CryptoNet>();
|
private static Map<Integer, CryptoNet> bip44Map = new HashMap<Integer, CryptoNet>();
|
||||||
static {
|
static {
|
||||||
for (CryptoNet cryptoNetEnum : CryptoNet.values()) {
|
for (CryptoNet cryptoNetEnum : CryptoNet.values()) {
|
||||||
|
@ -26,10 +37,11 @@ public enum CryptoNet implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CryptoNet(String label,int confirmationsNeeded, int bip44Index){
|
CryptoNet(String label,int confirmationsNeeded, int bip44Index, int iconImageResource){
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.confirmationsNeeded = confirmationsNeeded;
|
this.confirmationsNeeded = confirmationsNeeded;
|
||||||
this.bip44Index = bip44Index;
|
this.bip44Index = bip44Index;
|
||||||
|
this.iconImageResource = iconImageResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLabel(){
|
public String getLabel(){
|
||||||
|
@ -44,6 +56,10 @@ public enum CryptoNet implements Serializable {
|
||||||
return this.bip44Index;
|
return this.bip44Index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getIconImageResource() {
|
||||||
|
return this.iconImageResource;
|
||||||
|
}
|
||||||
|
|
||||||
public static CryptoNet fromBip44Index(int index){
|
public static CryptoNet fromBip44Index(int index){
|
||||||
if (bip44Map.containsKey(index)) {
|
if (bip44Map.containsKey(index)) {
|
||||||
return bip44Map.get(index);
|
return bip44Map.get(index);
|
||||||
|
|
|
@ -10,11 +10,13 @@ import android.view.ViewGroup;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import cy.agorise.crystalwallet.R;
|
import cy.agorise.crystalwallet.R;
|
||||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||||
|
import cy.agorise.crystalwallet.enums.CryptoCoin;
|
||||||
import cy.agorise.crystalwallet.enums.CryptoNet;
|
import cy.agorise.crystalwallet.enums.CryptoNet;
|
||||||
import cy.agorise.crystalwallet.models.AccountSeed;
|
import cy.agorise.crystalwallet.models.AccountSeed;
|
||||||
import cy.agorise.crystalwallet.models.CryptoNetSelection;
|
import cy.agorise.crystalwallet.models.CryptoNetSelection;
|
||||||
|
@ -98,7 +100,10 @@ public class GeneralAccountSeedCoinSettingsFragment extends Fragment implements
|
||||||
@Override
|
@Override
|
||||||
public void onCryptoNetSelectionChecked(CryptoNetSelection source) {
|
public void onCryptoNetSelectionChecked(CryptoNetSelection source) {
|
||||||
//Toast.makeText(this.getContext(),"the coin "+source.getCryptoNet().name()+" was "+(source.getSelected()?"selected":"unselected"),Toast.LENGTH_LONG).show();
|
//Toast.makeText(this.getContext(),"the coin "+source.getCryptoNet().name()+" was "+(source.getSelected()?"selected":"unselected"),Toast.LENGTH_LONG).show();
|
||||||
final CreateBitcoinAccountRequest request = new CreateBitcoinAccountRequest(this.accountSeed,this.getContext(),source.getCryptoNet());
|
List<CryptoCoin> cryptoCoins = CryptoCoin.getByCryptoNet(source.getCryptoNet());
|
||||||
|
|
||||||
|
|
||||||
|
final CreateBitcoinAccountRequest request = new CreateBitcoinAccountRequest(this.accountSeed,this.getContext(),cryptoCoins.get(0));
|
||||||
|
|
||||||
request.setListener(new CryptoNetInfoRequestListener() {
|
request.setListener(new CryptoNetInfoRequestListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,6 +2,8 @@ package cy.agorise.crystalwallet.requestmanagers;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import cy.agorise.crystalwallet.enums.CryptoCoin;
|
import cy.agorise.crystalwallet.enums.CryptoCoin;
|
||||||
import cy.agorise.crystalwallet.enums.CryptoNet;
|
import cy.agorise.crystalwallet.enums.CryptoNet;
|
||||||
import cy.agorise.crystalwallet.models.AccountSeed;
|
import cy.agorise.crystalwallet.models.AccountSeed;
|
||||||
|
@ -32,10 +34,10 @@ public class CreateBitcoinAccountRequest extends CryptoNetInfoRequest {
|
||||||
// The state of this request
|
// The state of this request
|
||||||
private StatusCode status = StatusCode.NOT_STARTED;
|
private StatusCode status = StatusCode.NOT_STARTED;
|
||||||
|
|
||||||
public CreateBitcoinAccountRequest(AccountSeed accountSeed, Context context, CryptoNet cryptoNet){
|
public CreateBitcoinAccountRequest(AccountSeed accountSeed, Context context, CryptoCoin cryptoCoin){
|
||||||
super(CryptoCoin.BITSHARES);
|
super(cryptoCoin);
|
||||||
this.accountSeed = accountSeed;
|
this.accountSeed = accountSeed;
|
||||||
this.accountCryptoNet = cryptoNet;
|
this.accountCryptoNet = cryptoCoin.getCryptoNet();
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,9 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cy.agorise.crystalwallet.apigenerator.GrapheneApiGenerator;
|
import cy.agorise.crystalwallet.apigenerator.GrapheneApiGenerator;
|
||||||
|
import cy.agorise.crystalwallet.enums.CryptoCoin;
|
||||||
import cy.agorise.crystalwallet.manager.FileBackupManager;
|
import cy.agorise.crystalwallet.manager.FileBackupManager;
|
||||||
|
import cy.agorise.crystalwallet.manager.GeneralAccountManager;
|
||||||
import cy.agorise.crystalwallet.models.BitsharesAccountNameCache;
|
import cy.agorise.crystalwallet.models.BitsharesAccountNameCache;
|
||||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
||||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||||
|
@ -43,6 +45,7 @@ public class CrystalWalletService extends LifecycleService {
|
||||||
private Looper mServiceLooper;
|
private Looper mServiceLooper;
|
||||||
private ServiceHandler mServiceHandler;
|
private ServiceHandler mServiceHandler;
|
||||||
private BitsharesAccountManager bitsharesAccountManager;
|
private BitsharesAccountManager bitsharesAccountManager;
|
||||||
|
private GeneralAccountManager generalAccountManager;
|
||||||
private Thread LoadAccountTransactionsThread;
|
private Thread LoadAccountTransactionsThread;
|
||||||
private Thread LoadBitsharesAccountNamesThread;
|
private Thread LoadBitsharesAccountNamesThread;
|
||||||
private EquivalencesThread LoadEquivalencesThread;
|
private EquivalencesThread LoadEquivalencesThread;
|
||||||
|
@ -188,11 +191,13 @@ public class CrystalWalletService extends LifecycleService {
|
||||||
this.cryptoNetInfoRequests = CryptoNetInfoRequests.getInstance();
|
this.cryptoNetInfoRequests = CryptoNetInfoRequests.getInstance();
|
||||||
this.fileServiceRequests = FileServiceRequests.getInstance();
|
this.fileServiceRequests = FileServiceRequests.getInstance();
|
||||||
this.bitsharesAccountManager = new BitsharesAccountManager();
|
this.bitsharesAccountManager = new BitsharesAccountManager();
|
||||||
|
this.generalAccountManager = new GeneralAccountManager(CryptoCoin.BITCOIN,this.getApplicationContext());
|
||||||
this.fileBackupManager = new FileBackupManager();
|
this.fileBackupManager = new FileBackupManager();
|
||||||
|
|
||||||
//Add the managers as listeners of the CryptoNetInfoRequest so
|
//Add the managers as listeners of the CryptoNetInfoRequest so
|
||||||
//they can carry out the info requests from the ui
|
//they can carry out the info requests from the ui
|
||||||
this.cryptoNetInfoRequests.addListener(this.bitsharesAccountManager);
|
this.cryptoNetInfoRequests.addListener(this.bitsharesAccountManager);
|
||||||
|
this.cryptoNetInfoRequests.addListener(this.generalAccountManager);
|
||||||
|
|
||||||
this.fileServiceRequests.addListener(this.fileBackupManager);
|
this.fileServiceRequests.addListener(this.fileBackupManager);
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,7 @@ public class CryptoNetBalanceViewHolder extends RecyclerView.ViewHolder {
|
||||||
} else {
|
} else {
|
||||||
final CryptoNetBalanceViewHolder thisViewHolder = this;
|
final CryptoNetBalanceViewHolder thisViewHolder = this;
|
||||||
this.cryptoNetAccountId = balance.getAccountId();
|
this.cryptoNetAccountId = balance.getAccountId();
|
||||||
|
this.cryptoNetIcon.setImageResource(balance.getCryptoNet().getIconImageResource());
|
||||||
/*
|
/*
|
||||||
* The first letter should be in Uppercase
|
* The first letter should be in Uppercase
|
||||||
* */
|
* */
|
||||||
|
|
BIN
app/src/main/res/drawable/coin_icon_bitcoin.png
Normal file
BIN
app/src/main/res/drawable/coin_icon_bitcoin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
app/src/main/res/drawable/coin_icon_dash.png
Normal file
BIN
app/src/main/res/drawable/coin_icon_dash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
BIN
app/src/main/res/drawable/coin_icon_doge.png
Normal file
BIN
app/src/main/res/drawable/coin_icon_doge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
BIN
app/src/main/res/drawable/coin_icon_litecoin.png
Normal file
BIN
app/src/main/res/drawable/coin_icon_litecoin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
BIN
app/src/main/res/drawable/coin_icon_steem.png
Normal file
BIN
app/src/main/res/drawable/coin_icon_steem.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 70 KiB |
Loading…
Reference in a new issue