- 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:
Javier Varona 2018-11-03 21:01:00 -04:00
parent 043325b887
commit e9f77c4981
10 changed files with 35 additions and 7 deletions

View file

@ -4,6 +4,8 @@ import java.io.Serializable;
import java.util.HashMap;
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
* 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.
*/
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;
@ -19,6 +28,8 @@ public enum CryptoNet implements Serializable {
protected int bip44Index;
protected int iconImageResource;
private static Map<Integer, CryptoNet> bip44Map = new HashMap<Integer, CryptoNet>();
static {
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.confirmationsNeeded = confirmationsNeeded;
this.bip44Index = bip44Index;
this.iconImageResource = iconImageResource;
}
public String getLabel(){
@ -44,6 +56,10 @@ public enum CryptoNet implements Serializable {
return this.bip44Index;
}
public int getIconImageResource() {
return this.iconImageResource;
}
public static CryptoNet fromBip44Index(int index){
if (bip44Map.containsKey(index)) {
return bip44Map.get(index);

View file

@ -10,11 +10,13 @@ import android.view.ViewGroup;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.dao.CrystalDatabase;
import cy.agorise.crystalwallet.enums.CryptoCoin;
import cy.agorise.crystalwallet.enums.CryptoNet;
import cy.agorise.crystalwallet.models.AccountSeed;
import cy.agorise.crystalwallet.models.CryptoNetSelection;
@ -98,7 +100,10 @@ public class GeneralAccountSeedCoinSettingsFragment extends Fragment implements
@Override
public void onCryptoNetSelectionChecked(CryptoNetSelection source) {
//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() {
@Override

View file

@ -2,6 +2,8 @@ package cy.agorise.crystalwallet.requestmanagers;
import android.content.Context;
import java.util.List;
import cy.agorise.crystalwallet.enums.CryptoCoin;
import cy.agorise.crystalwallet.enums.CryptoNet;
import cy.agorise.crystalwallet.models.AccountSeed;
@ -32,10 +34,10 @@ public class CreateBitcoinAccountRequest extends CryptoNetInfoRequest {
// The state of this request
private StatusCode status = StatusCode.NOT_STARTED;
public CreateBitcoinAccountRequest(AccountSeed accountSeed, Context context, CryptoNet cryptoNet){
super(CryptoCoin.BITSHARES);
public CreateBitcoinAccountRequest(AccountSeed accountSeed, Context context, CryptoCoin cryptoCoin){
super(cryptoCoin);
this.accountSeed = accountSeed;
this.accountCryptoNet = cryptoNet;
this.accountCryptoNet = cryptoCoin.getCryptoNet();
this.context = context;
}

View file

@ -16,7 +16,9 @@ import java.util.ArrayList;
import java.util.List;
import cy.agorise.crystalwallet.apigenerator.GrapheneApiGenerator;
import cy.agorise.crystalwallet.enums.CryptoCoin;
import cy.agorise.crystalwallet.manager.FileBackupManager;
import cy.agorise.crystalwallet.manager.GeneralAccountManager;
import cy.agorise.crystalwallet.models.BitsharesAccountNameCache;
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
import cy.agorise.crystalwallet.dao.CrystalDatabase;
@ -43,6 +45,7 @@ public class CrystalWalletService extends LifecycleService {
private Looper mServiceLooper;
private ServiceHandler mServiceHandler;
private BitsharesAccountManager bitsharesAccountManager;
private GeneralAccountManager generalAccountManager;
private Thread LoadAccountTransactionsThread;
private Thread LoadBitsharesAccountNamesThread;
private EquivalencesThread LoadEquivalencesThread;
@ -188,11 +191,13 @@ public class CrystalWalletService extends LifecycleService {
this.cryptoNetInfoRequests = CryptoNetInfoRequests.getInstance();
this.fileServiceRequests = FileServiceRequests.getInstance();
this.bitsharesAccountManager = new BitsharesAccountManager();
this.generalAccountManager = new GeneralAccountManager(CryptoCoin.BITCOIN,this.getApplicationContext());
this.fileBackupManager = new FileBackupManager();
//Add the managers as listeners of the CryptoNetInfoRequest so
//they can carry out the info requests from the ui
this.cryptoNetInfoRequests.addListener(this.bitsharesAccountManager);
this.cryptoNetInfoRequests.addListener(this.generalAccountManager);
this.fileServiceRequests.addListener(this.fileBackupManager);
}

View file

@ -201,7 +201,7 @@ public class CryptoNetBalanceViewHolder extends RecyclerView.ViewHolder {
} else {
final CryptoNetBalanceViewHolder thisViewHolder = this;
this.cryptoNetAccountId = balance.getAccountId();
this.cryptoNetIcon.setImageResource(balance.getCryptoNet().getIconImageResource());
/*
* The first letter should be in Uppercase
* */

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB