- Change the import bitshares account request to avoid using the name of the account
This commit is contained in:
parent
2027677956
commit
04d3a0d2e6
3 changed files with 132 additions and 12 deletions
|
@ -31,6 +31,7 @@ import cy.agorise.crystalwallet.dialogs.material.PositiveResponse;
|
||||||
import cy.agorise.crystalwallet.dialogs.material.QuestionDialog;
|
import cy.agorise.crystalwallet.dialogs.material.QuestionDialog;
|
||||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener;
|
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener;
|
||||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
||||||
|
import cy.agorise.crystalwallet.requestmanagers.ImportBitsharesAccountRequest;
|
||||||
import cy.agorise.crystalwallet.requestmanagers.ValidateImportBitsharesAccountRequest;
|
import cy.agorise.crystalwallet.requestmanagers.ValidateImportBitsharesAccountRequest;
|
||||||
import cy.agorise.crystalwallet.viewmodels.AccountSeedViewModel;
|
import cy.agorise.crystalwallet.viewmodels.AccountSeedViewModel;
|
||||||
import cy.agorise.crystalwallet.viewmodels.validators.ImportSeedValidator;
|
import cy.agorise.crystalwallet.viewmodels.validators.ImportSeedValidator;
|
||||||
|
@ -203,6 +204,7 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator
|
||||||
txtErrorAccount.setVisibility(View.INVISIBLE);
|
txtErrorAccount.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
/*
|
||||||
etAccountName.addTextChangedListener(new TextWatcher() {
|
etAccountName.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
@ -217,9 +219,9 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
|
|
||||||
/*
|
//
|
||||||
* If all is ready to continue enable the button, contrarie case disable it
|
// If all is ready to continue enable the button, contrarie case disable it
|
||||||
* */
|
//
|
||||||
if(allFieldsAreFill()){
|
if(allFieldsAreFill()){
|
||||||
enableCreate();
|
enableCreate();
|
||||||
}
|
}
|
||||||
|
@ -228,6 +230,7 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
accountSeedViewModel = ViewModelProviders.of(this).get(AccountSeedViewModel.class);
|
accountSeedViewModel = ViewModelProviders.of(this).get(AccountSeedViewModel.class);
|
||||||
importSeedValidator = new ImportSeedValidator(this.getApplicationContext(),etPin,etPinConfirmation,etAccountName,etSeedWords);
|
importSeedValidator = new ImportSeedValidator(this.getApplicationContext(),etPin,etPinConfirmation,etAccountName,etSeedWords);
|
||||||
|
@ -263,8 +266,8 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator
|
||||||
boolean complete = false;
|
boolean complete = false;
|
||||||
if( etPin.getText().toString().trim().compareTo("")!=0 &&
|
if( etPin.getText().toString().trim().compareTo("")!=0 &&
|
||||||
etPinConfirmation.getText().toString().trim().compareTo("")!=0 &&
|
etPinConfirmation.getText().toString().trim().compareTo("")!=0 &&
|
||||||
etSeedWords.getText().toString().trim().compareTo("")!=0 &&
|
etSeedWords.getText().toString().trim().compareTo("")!=0 /*&&
|
||||||
etAccountName.getText().toString().trim().compareTo("")!=0){
|
etAccountName.getText().toString().trim().compareTo("")!=0*/){
|
||||||
complete = true;
|
complete = true;
|
||||||
}
|
}
|
||||||
return complete;
|
return complete;
|
||||||
|
@ -287,11 +290,11 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator
|
||||||
void afterSeedWordsChanged(Editable editable) {
|
void afterSeedWordsChanged(Editable editable) {
|
||||||
this.importSeedValidator.validate();
|
this.importSeedValidator.validate();
|
||||||
}
|
}
|
||||||
@OnTextChanged(value = R.id.etAccountName,
|
/*@OnTextChanged(value = R.id.etAccountName,
|
||||||
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
|
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
|
||||||
void afterAccountNameChanged(Editable editable) {
|
void afterAccountNameChanged(Editable editable) {
|
||||||
this.importSeedValidator.validate();
|
this.importSeedValidator.validate();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@OnClick(R.id.btnCancel)
|
@OnClick(R.id.btnCancel)
|
||||||
public void cancel(){
|
public void cancel(){
|
||||||
|
@ -327,7 +330,7 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator
|
||||||
/*
|
/*
|
||||||
* Validate mnemonic with the server
|
* Validate mnemonic with the server
|
||||||
* */
|
* */
|
||||||
final ValidateImportBitsharesAccountRequest request = new ValidateImportBitsharesAccountRequest(etAccountName.getText().toString().trim(),etSeedWords.getText().toString().trim(),activity);
|
final ImportBitsharesAccountRequest request = new ImportBitsharesAccountRequest(etSeedWords.getText().toString().trim(),activity);
|
||||||
request.setListener(new CryptoNetInfoRequestListener() {
|
request.setListener(new CryptoNetInfoRequestListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCarryOut() {
|
public void onCarryOut() {
|
||||||
|
@ -365,8 +368,8 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator
|
||||||
|
|
||||||
final ImportSeedActivity thisActivity = this;
|
final ImportSeedActivity thisActivity = this;
|
||||||
|
|
||||||
final ValidateImportBitsharesAccountRequest validatorRequest =
|
final ImportBitsharesAccountRequest validatorRequest =
|
||||||
new ValidateImportBitsharesAccountRequest(etAccountName.getText().toString(), etSeedWords.getText().toString(), getApplicationContext(), true);
|
new ImportBitsharesAccountRequest(etSeedWords.getText().toString(), getApplicationContext(), true);
|
||||||
|
|
||||||
validatorRequest.setListener(new CryptoNetInfoRequestListener() {
|
validatorRequest.setListener(new CryptoNetInfoRequestListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,115 @@
|
||||||
|
package cy.agorise.crystalwallet.requestmanagers;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import cy.agorise.crystalwallet.enums.CryptoCoin;
|
||||||
|
import cy.agorise.crystalwallet.enums.SeedType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Imports a bitshares accounts,
|
||||||
|
*
|
||||||
|
* return true if the account exist, and the mnemonic (brainkey provide is for that account
|
||||||
|
* Created by Henry Varona on 10/24/2018.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ImportBitsharesAccountRequest extends CryptoNetInfoRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The status code of this request
|
||||||
|
*/
|
||||||
|
public enum StatusCode{
|
||||||
|
NOT_STARTED,
|
||||||
|
SUCCEEDED,
|
||||||
|
NO_INTERNET,
|
||||||
|
NO_SERVER_CONNECTION,
|
||||||
|
ACCOUNT_DOESNT_EXIST,
|
||||||
|
BAD_SEED,
|
||||||
|
NO_ACCOUNT_DATA,
|
||||||
|
PETITION_FAILED
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the account
|
||||||
|
*/
|
||||||
|
private String accountName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The mnemonic words
|
||||||
|
*/
|
||||||
|
private final String mnemonic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True - the account must be added if the accountName and mnemonic are correct
|
||||||
|
*/
|
||||||
|
private boolean addAccountIfValid = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this seed is BIP39 or Brainkey
|
||||||
|
*/
|
||||||
|
private SeedType seedType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The status of this request
|
||||||
|
*/
|
||||||
|
private StatusCode status = StatusCode.NOT_STARTED;
|
||||||
|
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
public ImportBitsharesAccountRequest(String mnemonic, Context context){
|
||||||
|
super(CryptoCoin.BITSHARES);
|
||||||
|
this.accountName = "";
|
||||||
|
this.mnemonic = mnemonic;
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImportBitsharesAccountRequest(String mnemonic, Context context, boolean addAccountIfValid){
|
||||||
|
super(CryptoCoin.BITSHARES);
|
||||||
|
this.accountName = "";
|
||||||
|
this.mnemonic = mnemonic;
|
||||||
|
this.addAccountIfValid = addAccountIfValid;
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validate(){
|
||||||
|
if (!(this.status.equals(StatusCode.NOT_STARTED))){
|
||||||
|
this._fireOnCarryOutEvent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccountName() {
|
||||||
|
return accountName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMnemonic() {
|
||||||
|
return mnemonic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SeedType getSeedType() {
|
||||||
|
return seedType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Context getContext() {
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addAccountIfValid(){
|
||||||
|
return this.addAccountIfValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountName(String accountName){
|
||||||
|
this.accountName = accountName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSeedType(SeedType seedType) {
|
||||||
|
this.seedType = seedType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(StatusCode status) {
|
||||||
|
this.status = status;
|
||||||
|
this._fireOnCarryOutEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public StatusCode getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
|
@ -84,8 +84,9 @@
|
||||||
android:layout_width="330dp"
|
android:layout_width="330dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/etSeedWordsLayout"
|
android:layout_below="@+id/etSeedWordsLayout"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_centerHorizontal="true">
|
android:visibility="gone">
|
||||||
|
|
||||||
<cy.agorise.crystalwallet.views.natives.CustomTextInputEditText
|
<cy.agorise.crystalwallet.views.natives.CustomTextInputEditText
|
||||||
android:id="@+id/etAccountName"
|
android:id="@+id/etAccountName"
|
||||||
|
@ -95,7 +96,8 @@
|
||||||
android:hint="@string/txt_account_name"
|
android:hint="@string/txt_account_name"
|
||||||
android:inputType="textMultiLine"
|
android:inputType="textMultiLine"
|
||||||
android:maxLength="255"
|
android:maxLength="255"
|
||||||
android:singleLine="true" />
|
android:singleLine="true"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue