Merge branch 'master' of https://github.com/Agorise/crystal-wallet-android
This commit is contained in:
commit
032cc6fae5
5 changed files with 64 additions and 45 deletions
|
@ -130,17 +130,14 @@ public class CreateSeedActivity extends AppCompatActivity implements UIValidator
|
||||||
@Override
|
@Override
|
||||||
public void onCarryOut() {
|
public void onCarryOut() {
|
||||||
processDialog.dismiss();
|
processDialog.dismiss();
|
||||||
|
if (request.getStatus().equals(ValidateCreateBitsharesAccountRequest.StatusCode.SUCCEEDED)) {
|
||||||
if (request.getAccount() != null){
|
|
||||||
GrapheneAccount accountSeed = request.getAccount();
|
GrapheneAccount accountSeed = request.getAccount();
|
||||||
Intent intent = new Intent(getApplicationContext(), BackupSeedActivity.class);
|
Intent intent = new Intent(getApplicationContext(), BackupSeedActivity.class);
|
||||||
intent.putExtra("SEED_ID",accountSeed.getId());
|
intent.putExtra("SEED_ID", accountSeed.getId());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
createSeedValidator.validate();
|
createSeedValidator.validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -301,7 +301,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
||||||
sendRequest.setListener(new CryptoNetInfoRequestListener() {
|
sendRequest.setListener(new CryptoNetInfoRequestListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCarryOut() {
|
public void onCarryOut() {
|
||||||
if (sendRequest.isSend()){
|
if (sendRequest.getStatus().equals(ValidateBitsharesSendRequest.StatusCode.SUCCEEDED)){
|
||||||
try {
|
try {
|
||||||
this.finalize();
|
this.finalize();
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
|
|
|
@ -289,6 +289,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateCreateAccount(final ValidateCreateBitsharesAccountRequest createRequest){
|
private void validateCreateAccount(final ValidateCreateBitsharesAccountRequest createRequest){
|
||||||
|
//TODO test for internet and server connection
|
||||||
// Generate seed or find key
|
// Generate seed or find key
|
||||||
Context context = createRequest.getContext();
|
Context context = createRequest.getContext();
|
||||||
AccountSeed seed = AccountSeed.getAccountSeed(SeedType.BIP39, context);
|
AccountSeed seed = AccountSeed.getAccountSeed(SeedType.BIP39, context);
|
||||||
|
@ -306,13 +307,13 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void success(Object answer) {
|
public void success(Object answer) {
|
||||||
createRequest.setAccountExists(false);
|
|
||||||
createRequest.setAccount((GrapheneAccount) answer);
|
createRequest.setAccount((GrapheneAccount) answer);
|
||||||
|
createRequest.setStatus(ValidateCreateBitsharesAccountRequest.StatusCode.SUCCEEDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fail() {
|
public void fail() {
|
||||||
createRequest.setAccountExists(true);
|
createRequest.setStatus(ValidateCreateBitsharesAccountRequest.StatusCode.ACCOUNT_EXIST);
|
||||||
}
|
}
|
||||||
}, context);
|
}, context);
|
||||||
|
|
||||||
|
@ -348,6 +349,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
* Broadcast a transaction request
|
* Broadcast a transaction request
|
||||||
*/
|
*/
|
||||||
private void validateSendRequest(final ValidateBitsharesSendRequest sendRequest) {
|
private void validateSendRequest(final ValidateBitsharesSendRequest sendRequest) {
|
||||||
|
//TODO check internet, server connection
|
||||||
//TODO feeAsset
|
//TODO feeAsset
|
||||||
CrystalDatabase db = CrystalDatabase.getAppDatabase(sendRequest.getContext());
|
CrystalDatabase db = CrystalDatabase.getAppDatabase(sendRequest.getContext());
|
||||||
CryptoCurrency currency = db.cryptoCurrencyDao().getByNameAndCryptoNet(sendRequest.getAsset(), CryptoNet.BITSHARES.name());
|
CryptoCurrency currency = db.cryptoCurrencyDao().getByNameAndCryptoNet(sendRequest.getAsset(), CryptoNet.BITSHARES.name());
|
||||||
|
@ -360,7 +362,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fail() {
|
public void fail() {
|
||||||
|
sendRequest.setStatus(ValidateBitsharesSendRequest.StatusCode.NO_ASSET_INFO_DB);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
|
@ -374,7 +376,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fail() {
|
public void fail() {
|
||||||
|
sendRequest.setStatus(ValidateBitsharesSendRequest.StatusCode.NO_ASSET_INFO);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else {
|
}else {
|
||||||
|
@ -415,12 +417,12 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
ApiRequest transactionRequest = new ApiRequest(0, new ApiRequestListener() {
|
ApiRequest transactionRequest = new ApiRequest(0, new ApiRequestListener() {
|
||||||
@Override
|
@Override
|
||||||
public void success(Object answer, int idPetition) {
|
public void success(Object answer, int idPetition) {
|
||||||
sendRequest.setSend(true);
|
sendRequest.setStatus(ValidateBitsharesSendRequest.StatusCode.SUCCEEDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fail(int idPetition) {
|
public void fail(int idPetition) {
|
||||||
sendRequest.setSend(false);
|
sendRequest.setStatus(ValidateBitsharesSendRequest.StatusCode.PETITION_FAILED);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -429,7 +431,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fail() {
|
public void fail() {
|
||||||
//TODO bad user to user account
|
sendRequest.setStatus(ValidateBitsharesSendRequest.StatusCode.NO_TO_USER_INFO);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,20 @@ import cy.agorise.crystalwallet.models.GrapheneAccount;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ValidateBitsharesSendRequest extends CryptoNetInfoRequest {
|
public class ValidateBitsharesSendRequest extends CryptoNetInfoRequest {
|
||||||
|
/**
|
||||||
|
* The status code of this request
|
||||||
|
*/
|
||||||
|
public enum StatusCode{
|
||||||
|
NOT_STARTED,
|
||||||
|
SUCCEEDED,
|
||||||
|
NO_INTERNET,
|
||||||
|
NO_SERVER_CONNECTION,
|
||||||
|
NO_ASSET_INFO_DB,
|
||||||
|
NO_ASSET_INFO,
|
||||||
|
NO_TO_USER_INFO,
|
||||||
|
PETITION_FAILED
|
||||||
|
}
|
||||||
|
|
||||||
// The app context
|
// The app context
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
// The source account used to transfer fund from
|
// The source account used to transfer fund from
|
||||||
|
@ -25,7 +39,7 @@ public class ValidateBitsharesSendRequest extends CryptoNetInfoRequest {
|
||||||
// The memo, can be null
|
// The memo, can be null
|
||||||
private String mMemo;
|
private String mMemo;
|
||||||
// The state of this request
|
// The state of this request
|
||||||
private Boolean isSend;
|
private StatusCode status = StatusCode.NOT_STARTED;
|
||||||
|
|
||||||
public ValidateBitsharesSendRequest(Context context, GrapheneAccount sourceAccount,
|
public ValidateBitsharesSendRequest(Context context, GrapheneAccount sourceAccount,
|
||||||
String toAccount, long amount, String asset, String memo) {
|
String toAccount, long amount, String asset, String memo) {
|
||||||
|
@ -68,18 +82,18 @@ public class ValidateBitsharesSendRequest extends CryptoNetInfoRequest {
|
||||||
return mMemo;
|
return mMemo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSend() {
|
|
||||||
return isSend;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSend(boolean send) {
|
|
||||||
isSend = send;
|
|
||||||
this.validate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void validate(){
|
public void validate(){
|
||||||
if ((this.isSend != null)){
|
if ((this.status != StatusCode.NOT_STARTED)){
|
||||||
this._fireOnCarryOutEvent();
|
this._fireOnCarryOutEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setStatus(StatusCode code){
|
||||||
|
this.status = code;
|
||||||
|
this._fireOnCarryOutEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public StatusCode getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,15 +14,27 @@ import cy.agorise.crystalwallet.models.GrapheneAccount;
|
||||||
|
|
||||||
public class ValidateCreateBitsharesAccountRequest extends CryptoNetInfoRequest {
|
public class ValidateCreateBitsharesAccountRequest extends CryptoNetInfoRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The status code of this request
|
||||||
|
*/
|
||||||
|
public enum StatusCode{
|
||||||
|
NOT_STARTED,
|
||||||
|
SUCCEEDED,
|
||||||
|
NO_INTERNET,
|
||||||
|
NO_SERVER_CONNECTION,
|
||||||
|
ACCOUNT_EXIST,
|
||||||
|
NO_ACCOUNT_DATA
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the account
|
* The name of the account
|
||||||
*/
|
*/
|
||||||
private String accountName;
|
private String accountName;
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if the account exist
|
// The state of this request
|
||||||
*/
|
private StatusCode status = StatusCode.NOT_STARTED;
|
||||||
private Boolean accountExists;
|
|
||||||
|
|
||||||
private GrapheneAccount account;
|
private GrapheneAccount account;
|
||||||
|
|
||||||
|
@ -34,34 +46,19 @@ public class ValidateCreateBitsharesAccountRequest extends CryptoNetInfoRequest
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAccountExists(boolean value){
|
|
||||||
this.accountExists = value;
|
|
||||||
this.validate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccount(GrapheneAccount account){
|
public void setAccount(GrapheneAccount account){
|
||||||
this.account = account;
|
this.account = account;
|
||||||
this.validate();
|
this.validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getAccountExists(){
|
|
||||||
return this.accountExists;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrapheneAccount getAccount() {
|
public GrapheneAccount getAccount() {
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void validate(){
|
public void validate(){
|
||||||
if ((this.accountExists != null)){// && (this.account != null)){
|
if(!status.equals(StatusCode.NOT_STARTED))
|
||||||
if (this.accountExists == true) {
|
|
||||||
this._fireOnCarryOutEvent();
|
this._fireOnCarryOutEvent();
|
||||||
} else {
|
|
||||||
if (this.account != null){
|
|
||||||
this._fireOnCarryOutEvent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAccountName() {
|
public String getAccountName() {
|
||||||
|
@ -75,4 +72,13 @@ public class ValidateCreateBitsharesAccountRequest extends CryptoNetInfoRequest
|
||||||
public Context getContext() {
|
public Context getContext() {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setStatus(StatusCode code){
|
||||||
|
this.status = code;
|
||||||
|
this.validate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public StatusCode getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue