Change in the request package
Put the File Service logic only for bin files
This commit is contained in:
parent
71c1df2306
commit
6999ad58a1
38 changed files with 331 additions and 174 deletions
|
@ -5,27 +5,16 @@ import android.arch.lifecycle.Observer;
|
|||
import android.arch.lifecycle.ViewModelProviders;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.Editable;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.OnTextChanged;
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateCreateBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.models.AccountSeed;
|
||||
import cy.agorise.crystalwallet.viewmodels.AccountSeedViewModel;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.CreateSeedValidator;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.UIValidatorListener;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.validationfields.ValidationField;
|
||||
|
||||
public class BackupSeedActivity extends AppCompatActivity {
|
||||
|
||||
|
|
|
@ -3,17 +3,13 @@ package cy.agorise.crystalwallet.activities;
|
|||
import android.arch.lifecycle.LiveData;
|
||||
import android.arch.lifecycle.Observer;
|
||||
import android.arch.lifecycle.ViewModelProviders;
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Editable;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
@ -26,21 +22,14 @@ import butterknife.ButterKnife;
|
|||
import butterknife.OnClick;
|
||||
import butterknife.OnTextChanged;
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateCreateBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.models.Contact;
|
||||
import cy.agorise.crystalwallet.models.ContactAddress;
|
||||
import cy.agorise.crystalwallet.models.GrapheneAccount;
|
||||
import cy.agorise.crystalwallet.viewmodels.ContactListViewModel;
|
||||
import cy.agorise.crystalwallet.viewmodels.ContactViewModel;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.CreateContactValidator;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.CreateSeedValidator;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.ModifyContactValidator;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.UIValidatorListener;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.validationfields.ValidationField;
|
||||
import cy.agorise.crystalwallet.views.ContactAddressListAdapter;
|
||||
import cy.agorise.crystalwallet.views.ContactViewHolder;
|
||||
|
||||
public class CreateContactActivity extends AppCompatActivity implements UIValidatorListener {
|
||||
|
||||
|
|
|
@ -10,32 +10,21 @@ import android.support.v7.app.AppCompatActivity;
|
|||
import android.text.Editable;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.OnTextChanged;
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateCreateBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.enums.SeedType;
|
||||
import cy.agorise.crystalwallet.models.AccountSeed;
|
||||
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.requestmanagers.ValidateCreateBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.models.GrapheneAccount;
|
||||
import cy.agorise.crystalwallet.models.GrapheneAccountInfo;
|
||||
import cy.agorise.crystalwallet.viewmodels.AccountSeedViewModel;
|
||||
import cy.agorise.crystalwallet.viewmodels.CryptoNetAccountViewModel;
|
||||
import cy.agorise.crystalwallet.viewmodels.GrapheneAccountInfoViewModel;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.CreateSeedValidator;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.ImportSeedValidator;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.UIValidatorListener;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.validationfields.ValidationField;
|
||||
|
||||
import static cy.agorise.crystalwallet.enums.SeedType.BIP39;
|
||||
|
||||
public class CreateSeedActivity extends AppCompatActivity implements UIValidatorListener {
|
||||
|
||||
AccountSeedViewModel accountSeedViewModel;
|
||||
|
|
|
@ -5,30 +5,18 @@ import android.arch.lifecycle.Observer;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.Editable;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.OnItemSelected;
|
||||
import butterknife.OnTextChanged;
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateBitsharesSendRequest;
|
||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
||||
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
||||
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||
import cy.agorise.crystalwallet.models.GrapheneAccount;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.SendTransactionValidator;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.UIValidatorListener;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.validationfields.ValidationField;
|
||||
import cy.agorise.crystalwallet.views.CryptoCurrencyAdapter;
|
||||
|
||||
public class ReceiveTransactionActivity extends AppCompatActivity {
|
||||
|
|
|
@ -2,15 +2,12 @@ package cy.agorise.crystalwallet.activities;
|
|||
|
||||
import android.arch.lifecycle.LiveData;
|
||||
import android.arch.lifecycle.Observer;
|
||||
import android.arch.lifecycle.ViewModelProviders;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.Editable;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -23,18 +20,12 @@ import butterknife.OnClick;
|
|||
import butterknife.OnItemSelected;
|
||||
import butterknife.OnTextChanged;
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateBitsharesSendRequest;
|
||||
import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesSendRequest;
|
||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||
import cy.agorise.crystalwallet.enums.CryptoNet;
|
||||
import cy.agorise.crystalwallet.enums.SeedType;
|
||||
import cy.agorise.crystalwallet.models.AccountSeed;
|
||||
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
||||
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
||||
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||
import cy.agorise.crystalwallet.models.GrapheneAccount;
|
||||
import cy.agorise.crystalwallet.models.GrapheneAccountInfo;
|
||||
import cy.agorise.crystalwallet.viewmodels.CryptoNetAccountViewModel;
|
||||
import cy.agorise.crystalwallet.viewmodels.GrapheneAccountInfoViewModel;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.SendTransactionValidator;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.UIValidatorListener;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.validationfields.ValidationField;
|
||||
|
|
|
@ -26,6 +26,9 @@ public interface CryptoNetAccountDao {
|
|||
@Query("SELECT cna.* FROM crypto_net_account cna")
|
||||
List<CryptoNetAccount> getAllCryptoNetAccount();
|
||||
|
||||
@Query("SELECT cna.* FROM crypto_net_account cna WHERE seed_id = :seedId")
|
||||
List<CryptoNetAccount> getAllCryptoNetAccountBySeed( long seedId);
|
||||
|
||||
@Query("SELECT * FROM crypto_net_account WHERE id = :accountId")
|
||||
LiveData<CryptoNetAccount> getByIdLiveData( long accountId);
|
||||
|
||||
|
|
|
@ -5,59 +5,25 @@ import android.arch.lifecycle.LiveData;
|
|||
import android.arch.lifecycle.Observer;
|
||||
import android.arch.lifecycle.ViewModelProviders;
|
||||
import android.arch.paging.PagedList;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Editable;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.OnItemSelected;
|
||||
import butterknife.OnTextChanged;
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateBitsharesSendRequest;
|
||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||
import cy.agorise.crystalwallet.enums.CryptoNet;
|
||||
import cy.agorise.crystalwallet.models.Contact;
|
||||
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
||||
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
||||
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||
import cy.agorise.crystalwallet.models.GrapheneAccount;
|
||||
import cy.agorise.crystalwallet.viewmodels.ContactListViewModel;
|
||||
import cy.agorise.crystalwallet.viewmodels.CryptoNetAccountListViewModel;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.SendTransactionValidator;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.UIValidatorListener;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.validationfields.ValidationField;
|
||||
import cy.agorise.crystalwallet.views.ContactSelectionListAdapter;
|
||||
import cy.agorise.crystalwallet.views.CryptoCurrencyAdapter;
|
||||
import cy.agorise.crystalwallet.views.CryptoNetAccountAdapter;
|
||||
import me.dm7.barcodescanner.zxing.ZXingScannerView;
|
||||
|
||||
public class ContactSelectionFragment extends DialogFragment implements ContactSelectionListAdapter.ContactSelectionListAdapterListener{
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package cy.agorise.crystalwallet.fragments;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.LauncherActivity;
|
||||
import android.arch.lifecycle.LiveData;
|
||||
import android.arch.lifecycle.Observer;
|
||||
import android.arch.lifecycle.ViewModelProviders;
|
||||
|
@ -43,14 +42,12 @@ import butterknife.ButterKnife;
|
|||
import butterknife.OnItemSelected;
|
||||
import butterknife.OnTextChanged;
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateBitsharesSendRequest;
|
||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
||||
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
||||
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||
import cy.agorise.crystalwallet.models.GrapheneAccount;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.ReceiveTransactionValidator;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.SendTransactionValidator;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.UIValidatorListener;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.validationfields.ValidationField;
|
||||
import cy.agorise.crystalwallet.views.CryptoCurrencyAdapter;
|
||||
|
|
|
@ -15,20 +15,17 @@ import android.support.v4.app.DialogFragment;
|
|||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.Editable;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
|
||||
|
@ -45,11 +42,10 @@ import butterknife.OnClick;
|
|||
import butterknife.OnItemSelected;
|
||||
import butterknife.OnTextChanged;
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateBitsharesSendRequest;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesSendRequest;
|
||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||
import cy.agorise.crystalwallet.models.Contact;
|
||||
import cy.agorise.crystalwallet.models.ContactAddress;
|
||||
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
||||
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
||||
|
@ -57,7 +53,6 @@ import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
|||
import cy.agorise.crystalwallet.models.GrapheneAccount;
|
||||
import cy.agorise.crystalwallet.viewmodels.ContactViewModel;
|
||||
import cy.agorise.crystalwallet.viewmodels.CryptoNetAccountListViewModel;
|
||||
import cy.agorise.crystalwallet.viewmodels.CryptoNetAccountViewModel;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.SendTransactionValidator;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.UIValidatorListener;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.validationfields.ValidationField;
|
||||
|
|
|
@ -18,13 +18,13 @@ import cy.agorise.crystalwallet.apigenerator.ApiRequestListener;
|
|||
import cy.agorise.crystalwallet.apigenerator.BitsharesFaucetApiGenerator;
|
||||
import cy.agorise.crystalwallet.apigenerator.GrapheneApiGenerator;
|
||||
import cy.agorise.crystalwallet.application.constant.BitsharesConstant;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetEquivalentRequest;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequest;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestsListener;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateBitsharesSendRequest;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateCreateBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateExistBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateImportBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetEquivalentRequest;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequest;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestsListener;
|
||||
import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesSendRequest;
|
||||
import cy.agorise.crystalwallet.requestmanagers.ValidateCreateBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.requestmanagers.ValidateExistBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.requestmanagers.ValidateImportBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||
import cy.agorise.crystalwallet.dao.TransactionDao;
|
||||
import cy.agorise.crystalwallet.enums.CryptoNet;
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
package cy.agorise.crystalwallet.manager;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cy.agorise.crystalwallet.application.CrystalApplication;
|
||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CreateBackupRequest;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequest;
|
||||
import cy.agorise.crystalwallet.requestmanagers.FileServiceRequest;
|
||||
import cy.agorise.crystalwallet.requestmanagers.FileServiceRequestsListener;
|
||||
import cy.agorise.graphenej.BrainKey;
|
||||
import cy.agorise.graphenej.Chains;
|
||||
import cy.agorise.graphenej.FileBin;
|
||||
import cy.agorise.graphenej.models.backup.LinkedAccount;
|
||||
import cy.agorise.graphenej.models.backup.PrivateKeyBackup;
|
||||
import cy.agorise.graphenej.models.backup.Wallet;
|
||||
import cy.agorise.graphenej.models.backup.WalletBackup;
|
||||
|
||||
/**
|
||||
* Created by henry on 21/3/2018.
|
||||
*/
|
||||
|
||||
public class FileBackupManager implements FileServiceRequestsListener {
|
||||
|
||||
@Override
|
||||
public void onNewRequest(FileServiceRequest request) {
|
||||
if(request instanceof CreateBackupRequest){
|
||||
createBackupBinFile((CreateBackupRequest) request);
|
||||
}
|
||||
}
|
||||
|
||||
public void createBackupBinFile(CreateBackupRequest request)
|
||||
{
|
||||
CrystalDatabase db = CrystalDatabase.getAppDatabase(request.getContext());
|
||||
db.cryptoNetAccountDao().getAllCryptoNetAccountBySeed(request.getSeed().getId());
|
||||
|
||||
/*TinyDB tinyDB = new TinyDB(myActivity);
|
||||
ArrayList<AccountDetails> accountDetails = tinyDB.getListObject(myActivity.getResources().getString(R.string.pref_wallet_accounts), AccountDetails.class);
|
||||
String _brnKey = getBrainKey(accountDetails);
|
||||
String _accountName = getAccountName(accountDetails);
|
||||
String _pinCode = getPin(accountDetails);
|
||||
|
||||
getBinBytesFromBrainkey(_pinCode, _brnKey, _accountName);*/
|
||||
}
|
||||
|
||||
public void getBinBytesFromBrainkey(String pin, String brnKey, String accountName, CreateBackupRequest request) {
|
||||
BrainKey brainKey = new BrainKey(brnKey, 0);
|
||||
try {
|
||||
ArrayList<Wallet> wallets = new ArrayList<>();
|
||||
ArrayList<LinkedAccount> accounts = new ArrayList<>();
|
||||
ArrayList<PrivateKeyBackup> keys = new ArrayList<>();
|
||||
|
||||
Wallet wallet = new Wallet(accountName, brainKey.getBrainKey(), brainKey.getSequenceNumber(), Chains.BITSHARES.CHAIN_ID, pin);
|
||||
wallets.add(wallet);
|
||||
|
||||
PrivateKeyBackup keyBackup = new PrivateKeyBackup(brainKey.getPrivateKey().getPrivKeyBytes(),
|
||||
brainKey.getSequenceNumber(), brainKey.getSequenceNumber(), wallet.getEncryptionKey(pin));
|
||||
keys.add(keyBackup);
|
||||
|
||||
LinkedAccount linkedAccount = new LinkedAccount(accountName, Chains.BITSHARES.CHAIN_ID);
|
||||
accounts.add(linkedAccount);
|
||||
|
||||
WalletBackup backup = new WalletBackup(wallets, keys, accounts);
|
||||
byte[] results = FileBin.serializeWalletBackup(backup, pin);
|
||||
List<Integer> resultFile = new ArrayList<>();
|
||||
for(byte result: results){
|
||||
resultFile.add(result & 0xff);
|
||||
}
|
||||
saveBinContentToFile(resultFile, accountName, request);
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
//TODO error exception
|
||||
|
||||
}
|
||||
}
|
||||
static void saveBinContentToFile(List<Integer> content, String _accountName, CreateBackupRequest request )
|
||||
{
|
||||
|
||||
String folder = Environment.getExternalStorageDirectory() + File.separator + "Crystal"; //TODO make constant
|
||||
String path = folder + File.separator + _accountName + ".bin";
|
||||
|
||||
boolean success = saveBinFile(path,content,request);
|
||||
//TODO handle sucess
|
||||
}
|
||||
|
||||
private static boolean saveBinFile (String filePath , List<Integer> content, CreateBackupRequest request)
|
||||
{
|
||||
boolean success = false;
|
||||
try
|
||||
{
|
||||
//TODO permissions
|
||||
// PermissionManager Manager = new PermissionManager();
|
||||
// Manager.verifyStoragePermissions(_activity);
|
||||
|
||||
File file = new File(filePath);
|
||||
byte[] fileData = new byte[content.size()];
|
||||
|
||||
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
|
||||
|
||||
for ( int i = 0 ; i < content.size() ; i++ )
|
||||
{
|
||||
fileData[i] = content.get(i).byteValue();
|
||||
}
|
||||
|
||||
bos.write(fileData);
|
||||
bos.flush();
|
||||
bos.close();
|
||||
|
||||
success = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//TODO handle error
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package cy.agorise.crystalwallet.requestmanagers;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
import cy.agorise.crystalwallet.models.AccountSeed;
|
||||
|
||||
/**
|
||||
* Created by henry on 26/3/2018.
|
||||
*/
|
||||
|
||||
public class CreateBackupRequest extends FileServiceRequest {
|
||||
|
||||
private AccountSeed seed;
|
||||
|
||||
enum StatusCode{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CreateBackupRequest(Context context, Activity activity, AccountSeed seed) {
|
||||
super(context, activity);
|
||||
this.seed = seed;
|
||||
}
|
||||
|
||||
public AccountSeed getSeed() {
|
||||
return seed;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package cy.agorise.crystalwallet.cryptonetinforequests;
|
||||
package cy.agorise.crystalwallet.requestmanagers;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cy.agorise.crystalwallet.cryptonetinforequests;
|
||||
package cy.agorise.crystalwallet.requestmanagers;
|
||||
|
||||
import cy.agorise.crystalwallet.enums.CryptoCoin;
|
||||
|
||||
|
@ -19,7 +19,7 @@ public abstract class CryptoNetInfoRequest {
|
|||
*/
|
||||
protected CryptoNetInfoRequestListener listener;
|
||||
|
||||
public CryptoNetInfoRequest(CryptoCoin coin){
|
||||
protected CryptoNetInfoRequest(CryptoCoin coin){
|
||||
this.coin = coin;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cy.agorise.crystalwallet.cryptonetinforequests;
|
||||
package cy.agorise.crystalwallet.requestmanagers;
|
||||
|
||||
/**
|
||||
* Listener for manager request
|
|
@ -1,4 +1,4 @@
|
|||
package cy.agorise.crystalwallet.cryptonetinforequests;
|
||||
package cy.agorise.crystalwallet.requestmanagers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package cy.agorise.crystalwallet.cryptonetinforequests;
|
||||
package cy.agorise.crystalwallet.requestmanagers;
|
||||
|
||||
/**
|
||||
* Listener extends for the manager classes
|
|
@ -0,0 +1,37 @@
|
|||
package cy.agorise.crystalwallet.requestmanagers;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* Created by henry on 26/3/2018.
|
||||
*/
|
||||
|
||||
public abstract class FileServiceRequest {
|
||||
|
||||
protected Context context;
|
||||
protected Activity activity;
|
||||
|
||||
protected FileServiceRequest(Context context, Activity activity) {
|
||||
this.context = context;
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
protected FileServiceRequestListener listener;
|
||||
|
||||
public void setListener(FileServiceRequestListener listener){
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public Activity getActivity() {
|
||||
return activity;
|
||||
}
|
||||
|
||||
protected void _fireOnCarryOutEvent(){
|
||||
listener.onCarryOut();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package cy.agorise.crystalwallet.requestmanagers;
|
||||
|
||||
/**
|
||||
* Created by henry on 26/3/2018.
|
||||
*/
|
||||
|
||||
public interface FileServiceRequestListener {
|
||||
|
||||
public void onCarryOut();
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package cy.agorise.crystalwallet.requestmanagers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by henry on 26/3/2018.
|
||||
*/
|
||||
|
||||
public class FileServiceRequests {
|
||||
|
||||
private List<FileServiceRequest> requests;
|
||||
private List<FileServiceRequestsListener> listeners;
|
||||
private static FileServiceRequests instance;
|
||||
|
||||
|
||||
/**
|
||||
* Private constructor for singleton pattern
|
||||
*/
|
||||
private FileServiceRequests() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an instance of this manager
|
||||
* @return the instance to manage the cryptonetinforequest
|
||||
*/
|
||||
public static FileServiceRequests getInstance(){
|
||||
if (FileServiceRequests.instance == null){
|
||||
FileServiceRequests.instance = new FileServiceRequests();
|
||||
FileServiceRequests.instance.requests = new ArrayList<>();
|
||||
FileServiceRequests.instance.listeners = new ArrayList<>();
|
||||
}
|
||||
|
||||
return FileServiceRequests.instance;
|
||||
}
|
||||
|
||||
public void addRequest(FileServiceRequest request){
|
||||
this.requests.add(request);
|
||||
|
||||
this._fireNewRequestEvent(request);
|
||||
}
|
||||
|
||||
public void removeRequest(FileServiceRequest request){
|
||||
this.requests.remove(request);
|
||||
}
|
||||
|
||||
public void addListener(FileServiceRequestsListener listener){
|
||||
this.listeners.add(listener);
|
||||
}
|
||||
|
||||
private void _fireNewRequestEvent(FileServiceRequest request){
|
||||
for (int i=0;i<this.listeners.size();i++){
|
||||
this.listeners.get(i).onNewRequest(request);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package cy.agorise.crystalwallet.requestmanagers;
|
||||
|
||||
/**
|
||||
* Created by henry on 26/3/2018.
|
||||
*/
|
||||
|
||||
public interface FileServiceRequestsListener {
|
||||
|
||||
public void onNewRequest(FileServiceRequest request);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package cy.agorise.crystalwallet.requestmanagers;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* Created by henry on 26/3/2018.
|
||||
*/
|
||||
|
||||
public class ImportBackupRequest extends FileServiceRequest {
|
||||
|
||||
public ImportBackupRequest(Context context, Activity activity) {
|
||||
super(context, activity);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package cy.agorise.crystalwallet.cryptonetinforequests;
|
||||
package cy.agorise.crystalwallet.requestmanagers;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cy.agorise.crystalwallet.cryptonetinforequests;
|
||||
package cy.agorise.crystalwallet.requestmanagers;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cy.agorise.crystalwallet.cryptonetinforequests;
|
||||
package cy.agorise.crystalwallet.requestmanagers;
|
||||
|
||||
import cy.agorise.crystalwallet.enums.CryptoCoin;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cy.agorise.crystalwallet.cryptonetinforequests;
|
||||
package cy.agorise.crystalwallet.requestmanagers;
|
||||
|
||||
import cy.agorise.crystalwallet.enums.CryptoCoin;
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
package cy.agorise.crystalwallet.service;
|
||||
|
||||
|
||||
import android.app.Service;
|
||||
import android.arch.lifecycle.LifecycleService;
|
||||
import android.arch.lifecycle.LiveData;
|
||||
import android.arch.lifecycle.Observer;
|
||||
|
@ -16,14 +15,12 @@ import android.util.Log;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cy.agorise.crystalwallet.apigenerator.GrapheneApiGenerator;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||
import cy.agorise.crystalwallet.enums.CryptoNet;
|
||||
import cy.agorise.crystalwallet.manager.BitsharesAccountManager;
|
||||
import cy.agorise.crystalwallet.models.BitsharesAsset;
|
||||
import cy.agorise.crystalwallet.models.BitsharesAssetInfo;
|
||||
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
||||
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
||||
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||
import cy.agorise.crystalwallet.models.GeneralSetting;
|
||||
|
|
|
@ -32,7 +32,7 @@ public class EquivalencesThread extends Thread{
|
|||
try {
|
||||
GrapheneApiGenerator.getEquivalenValue(fromAsset, bitsharesAssets, this.service);
|
||||
Log.i("Equivalences Thread", "In loop");
|
||||
Thread.sleep(60000);
|
||||
Thread.sleep(300000);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
|
|
@ -3,15 +3,9 @@ package cy.agorise.crystalwallet.viewmodels;
|
|||
import android.app.Application;
|
||||
import android.arch.lifecycle.AndroidViewModel;
|
||||
import android.arch.lifecycle.LiveData;
|
||||
import android.arch.lifecycle.MutableLiveData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||
import cy.agorise.crystalwallet.models.AccountSeed;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateImportBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.viewmodels.validators.ImportSeedValidator;
|
||||
|
||||
/**
|
||||
* Created by Henry Varona on 27/9/2017.
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
package cy.agorise.crystalwallet.viewmodels.validators.validationfields;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateExistBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
||||
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
package cy.agorise.crystalwallet.viewmodels.validators.validationfields;
|
||||
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateExistBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,9 +3,9 @@ package cy.agorise.crystalwallet.viewmodels.validators.validationfields;
|
|||
import android.widget.EditText;
|
||||
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateImportBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.requestmanagers.ValidateImportBitsharesAccountRequest;
|
||||
|
||||
/**
|
||||
* Created by Henry Varona on 7/10/2017.
|
||||
|
|
|
@ -3,9 +3,9 @@ package cy.agorise.crystalwallet.viewmodels.validators.validationfields;
|
|||
import android.widget.EditText;
|
||||
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateExistBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.requestmanagers.ValidateExistBitsharesAccountRequest;
|
||||
|
||||
/**
|
||||
* Created by Henry Varona on 7/10/2017.
|
||||
|
|
|
@ -3,9 +3,9 @@ package cy.agorise.crystalwallet.viewmodels.validators.validationfields;
|
|||
import android.widget.EditText;
|
||||
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateExistBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.requestmanagers.ValidateExistBitsharesAccountRequest;
|
||||
|
||||
/**
|
||||
* Created by Henry Varona on 7/10/2017.
|
||||
|
|
|
@ -1,24 +1,11 @@
|
|||
package cy.agorise.crystalwallet.viewmodels.validators.validationfields;
|
||||
|
||||
import android.arch.lifecycle.LifecycleOwner;
|
||||
import android.arch.lifecycle.LiveData;
|
||||
import android.arch.lifecycle.Observer;
|
||||
import android.arch.lifecycle.ViewModelProviders;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateExistBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.models.Contact;
|
||||
import cy.agorise.crystalwallet.models.GeneralSetting;
|
||||
import cy.agorise.crystalwallet.viewmodels.ContactListViewModel;
|
||||
import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel;
|
||||
|
||||
/**
|
||||
* Created by Henry Varona on 2/03/2017.
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package cy.agorise.crystalwallet.viewmodels.validators.validationfields;
|
||||
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateExistBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.requestmanagers.ValidateExistBitsharesAccountRequest;
|
||||
|
||||
/**
|
||||
* Created by Henry Varona on 7/10/2017.
|
||||
|
|
|
@ -2,11 +2,6 @@ package cy.agorise.crystalwallet.viewmodels.validators.validationfields;
|
|||
|
||||
import android.widget.EditText;
|
||||
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateExistBitsharesAccountRequest;
|
||||
|
||||
/**
|
||||
* Created by Henry Varona on 7/10/2017.
|
||||
*/
|
||||
|
|
|
@ -4,9 +4,9 @@ import android.widget.EditText;
|
|||
import android.widget.Spinner;
|
||||
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateExistBitsharesAccountRequest;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.requestmanagers.ValidateExistBitsharesAccountRequest;
|
||||
|
||||
/**
|
||||
* Created by Henry Varona on 7/10/2017.
|
||||
|
|
Loading…
Reference in a new issue