Merge branch 'develop' of github.com:Agorise/crystal-wallet-android into develop
This commit is contained in:
commit
0dd9aecbf3
22 changed files with 366 additions and 254 deletions
|
@ -22,8 +22,8 @@ android {
|
||||||
applicationId "cy.agorise.crystalwallet"
|
applicationId "cy.agorise.crystalwallet"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 27
|
targetSdkVersion 27
|
||||||
versionCode 4
|
versionCode 5
|
||||||
versionName "0.4M.alpha"
|
versionName "0.5M.alpha"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables {
|
vectorDrawables {
|
||||||
useSupportLibrary true
|
useSupportLibrary true
|
||||||
|
@ -87,6 +87,7 @@ dependencies {
|
||||||
implementation 'com.jakewharton:butterknife:8.8.1'
|
implementation 'com.jakewharton:butterknife:8.8.1'
|
||||||
implementation 'com.github.bilthon:graphenej:0.4.6'
|
implementation 'com.github.bilthon:graphenej:0.4.6'
|
||||||
implementation 'me.dm7.barcodescanner:zxing:1.9.8'
|
implementation 'me.dm7.barcodescanner:zxing:1.9.8'
|
||||||
|
|
||||||
implementation 'com.github.sjaramillo10:AnimatedTabLayout:1.0.3'
|
implementation 'com.github.sjaramillo10:AnimatedTabLayout:1.0.3'
|
||||||
|
|
||||||
implementation 'com.squareup.okhttp3:logging-interceptor:3.5.0'
|
implementation 'com.squareup.okhttp3:logging-interceptor:3.5.0'
|
||||||
|
@ -125,4 +126,7 @@ dependencies {
|
||||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
|
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
|
||||||
|
|
||||||
debugImplementation 'com.amitshekhar.android:debug-db:1.0.4'
|
debugImplementation 'com.amitshekhar.android:debug-db:1.0.4'
|
||||||
|
|
||||||
|
implementation 'com.google.zxing:core:3.2.1'
|
||||||
|
implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
import cy.agorise.crystalwallet.R;
|
import cy.agorise.crystalwallet.R;
|
||||||
|
import cy.agorise.crystalwallet.application.CrystalSecurityMonitor;
|
||||||
import cy.agorise.crystalwallet.fragments.ImportAccountOptionsFragment;
|
import cy.agorise.crystalwallet.fragments.ImportAccountOptionsFragment;
|
||||||
import cy.agorise.crystalwallet.viewmodels.AccountSeedListViewModel;
|
import cy.agorise.crystalwallet.viewmodels.AccountSeedListViewModel;
|
||||||
|
|
||||||
|
@ -69,6 +70,9 @@ public class IntroActivity extends CustomActivity {
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
this.getApplication().registerActivityLifecycleCallbacks(CrystalSecurityMonitor.getInstance(this));
|
||||||
|
|
||||||
//Checks if the user has any seed created
|
//Checks if the user has any seed created
|
||||||
AccountSeedListViewModel accountSeedListViewModel = ViewModelProviders.of(this).get(AccountSeedListViewModel.class);
|
AccountSeedListViewModel accountSeedListViewModel = ViewModelProviders.of(this).get(AccountSeedListViewModel.class);
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@ public abstract class BitsharesFaucetApiGenerator {
|
||||||
|
|
||||||
public interface IWebService {
|
public interface IWebService {
|
||||||
@Headers({"Content-Type: application/json"})
|
@Headers({"Content-Type: application/json"})
|
||||||
@POST("/api/v1/accounts")
|
@POST("/faucet/api/v1/accounts")
|
||||||
Call<RegisterAccountResponse> getReg(@Body Map<String, HashMap> params);
|
Call<RegisterAccountResponse> getReg(@Body Map<String, HashMap> params);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class InsightApiGenerator {
|
||||||
GetEstimateFee.getEstimateFee(CryptoNetManager.getURL(cryptoCoin.getCryptoNet()),
|
GetEstimateFee.getEstimateFee(CryptoNetManager.getURL(cryptoCoin.getCryptoNet()),
|
||||||
new GetEstimateFee.estimateFeeListener() {
|
new GetEstimateFee.estimateFeeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void estimateFee(long value) {
|
public void estimateFee(double value) {
|
||||||
request.listener.success(value,request.getId());
|
request.listener.success(value,request.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,9 +65,14 @@ public class BroadcastTransaction extends Thread implements Callback<Txi> {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
try {
|
||||||
|
|
||||||
InsightApiService service = this.mServiceGenerator.getService(InsightApiService.class);
|
InsightApiService service = this.mServiceGenerator.getService(InsightApiService.class);
|
||||||
Call<Txi> broadcastTransaction = service.broadcastTransaction(this.mPath, this.mRawTx);
|
Call<Txi> broadcastTransaction = service.broadcastTransaction(this.mPath, this.mRawTx);
|
||||||
broadcastTransaction.enqueue(this);
|
broadcastTransaction.enqueue(this);
|
||||||
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface BroadCastTransactionListener{
|
public interface BroadCastTransactionListener{
|
||||||
|
|
|
@ -35,7 +35,7 @@ public abstract class GetEstimateFee {
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
||||||
listener.estimateFee((long) (response.body().get("2").getAsDouble()));
|
listener.estimateFee((double) (response.body().get("2").getAsDouble()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,12 +46,13 @@ public abstract class GetEstimateFee {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
listener.fail();
|
listener.fail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface estimateFeeListener{
|
public static interface estimateFeeListener{
|
||||||
public void estimateFee(long value);
|
public void estimateFee(double value);
|
||||||
public void fail();
|
public void fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,10 @@ public class CrystalApplication extends Application {
|
||||||
|
|
||||||
|
|
||||||
public static final String BITCOIN_SERVER_URLS[] ={
|
public static final String BITCOIN_SERVER_URLS[] ={
|
||||||
"https://insight.bitpay.com/",
|
"https://test-insight.bitpay.com",
|
||||||
"https://testnet.blockexplorer.com/"
|
//"https://testnet.blockexplorer.com/",
|
||||||
|
//"https://insight.bitpay.com/"
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final CryptoCurrency BITCOIN_CURRENCY = new CryptoCurrency("BTC",CryptoNet.BITCOIN,8);
|
public static final CryptoCurrency BITCOIN_CURRENCY = new CryptoCurrency("BTC",CryptoNet.BITCOIN,8);
|
||||||
|
@ -135,6 +137,11 @@ public class CrystalApplication extends Application {
|
||||||
resources.updateConfiguration(configuration, dm);
|
resources.updateConfiguration(configuration, dm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
|
||||||
Intent intent = new Intent(getApplicationContext(), CrystalWalletService.class);
|
Intent intent = new Intent(getApplicationContext(), CrystalWalletService.class);
|
||||||
startService(intent);
|
startService(intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,6 +175,8 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall
|
||||||
if(onResponsePattern != null){
|
if(onResponsePattern != null){
|
||||||
PatternRequestActivity.setOnResponse(onResponsePattern);
|
PatternRequestActivity.setOnResponse(onResponsePattern);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
onResponsePattern.onSuccess();
|
||||||
}
|
}
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
intent.putExtra("ACTIVITY_TYPE", "PASSWORD_REQUEST");
|
intent.putExtra("ACTIVITY_TYPE", "PASSWORD_REQUEST");
|
||||||
|
|
|
@ -72,10 +72,10 @@ public abstract class CrystalDatabase extends RoomDatabase {
|
||||||
Room.databaseBuilder(context,
|
Room.databaseBuilder(context,
|
||||||
CrystalDatabase.class, "CrystalWallet.db")
|
CrystalDatabase.class, "CrystalWallet.db")
|
||||||
.allowMainThreadQueries()
|
.allowMainThreadQueries()
|
||||||
.addMigrations(MIGRATION_2_3)
|
//.addMigrations(MIGRATION_2_3)
|
||||||
.addMigrations(MIGRATION_3_4)
|
//.addMigrations(MIGRATION_3_4)
|
||||||
.addMigrations(MIGRATION_4_5)
|
//.addMigrations(MIGRATION_4_5)
|
||||||
.addMigrations(MIGRATION_5_6)
|
//.addMigrations(MIGRATION_5_6)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
|
|
|
@ -27,6 +27,7 @@ import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -35,6 +36,7 @@ import com.google.zxing.BarcodeFormat;
|
||||||
import com.google.zxing.MultiFormatWriter;
|
import com.google.zxing.MultiFormatWriter;
|
||||||
import com.google.zxing.WriterException;
|
import com.google.zxing.WriterException;
|
||||||
import com.google.zxing.common.BitMatrix;
|
import com.google.zxing.common.BitMatrix;
|
||||||
|
import com.journeyapps.barcodescanner.BarcodeEncoder;
|
||||||
|
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
import cy.agorise.crystalwallet.enums.CryptoCoin;
|
import cy.agorise.crystalwallet.enums.CryptoCoin;
|
||||||
|
@ -84,6 +86,8 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali
|
||||||
TextView tvAssetError;
|
TextView tvAssetError;
|
||||||
@BindView(R.id.ivQrCode)
|
@BindView(R.id.ivQrCode)
|
||||||
ImageView ivQrCode;
|
ImageView ivQrCode;
|
||||||
|
@BindView(R.id.pbQrCode)
|
||||||
|
ProgressBar pbQrCode;
|
||||||
@BindView(R.id.tvCancel)
|
@BindView(R.id.tvCancel)
|
||||||
TextView tvCancel;
|
TextView tvCancel;
|
||||||
|
|
||||||
|
@ -106,6 +110,8 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali
|
||||||
|
|
||||||
private AsyncTask qrCodeTask;
|
private AsyncTask qrCodeTask;
|
||||||
|
|
||||||
|
private Double lastAmount = -1.0;
|
||||||
|
|
||||||
public static ReceiveTransactionFragment newInstance(long cryptoNetAccountId) {
|
public static ReceiveTransactionFragment newInstance(long cryptoNetAccountId) {
|
||||||
ReceiveTransactionFragment f = new ReceiveTransactionFragment();
|
ReceiveTransactionFragment f = new ReceiveTransactionFragment();
|
||||||
|
|
||||||
|
@ -337,15 +343,25 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createQrCode(){
|
public void createQrCode(){
|
||||||
Double amount = 0.0;
|
final Double amount;
|
||||||
try{
|
try{
|
||||||
amount = Double.valueOf(this.etAmount.getText().toString());
|
amount = Double.valueOf(this.etAmount.getText().toString());
|
||||||
|
|
||||||
} catch(NumberFormatException e){
|
} catch(NumberFormatException e){
|
||||||
|
lastAmount = -1.0;
|
||||||
Log.e("ReceiveFragment","Amount casting error.");
|
Log.e("ReceiveFragment","Amount casting error.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!amount.equals(lastAmount)) {
|
||||||
|
pbQrCode.setVisibility(View.VISIBLE);
|
||||||
|
lastAmount = amount;
|
||||||
CryptoNetAccount toAccountSelected = (CryptoNetAccount) spTo.getSelectedItem();
|
CryptoNetAccount toAccountSelected = (CryptoNetAccount) spTo.getSelectedItem();
|
||||||
|
|
||||||
|
if (this.qrCodeTask != null) {
|
||||||
|
this.qrCodeTask.cancel(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.cryptoNetAccount.getCryptoNet() == CryptoNet.BITSHARES) {
|
if (this.cryptoNetAccount.getCryptoNet() == CryptoNet.BITSHARES) {
|
||||||
/*
|
/*
|
||||||
* this is only for graphene accounts.
|
* this is only for graphene accounts.
|
||||||
|
@ -366,9 +382,9 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali
|
||||||
this.invoice.setTo(grapheneAccountSelected.getName());
|
this.invoice.setTo(grapheneAccountSelected.getName());
|
||||||
this.invoice.setCurrency(this.cryptoCurrency.getName());
|
this.invoice.setCurrency(this.cryptoCurrency.getName());
|
||||||
|
|
||||||
if (this.qrCodeTask != null) {
|
//if (this.qrCodeTask != null) {
|
||||||
this.qrCodeTask.cancel(true);
|
// this.qrCodeTask.cancel(true);
|
||||||
}
|
//}
|
||||||
|
|
||||||
this.qrCodeTask = new AsyncTask<Object, Void, Void>() {
|
this.qrCodeTask = new AsyncTask<Object, Void, Void>() {
|
||||||
|
|
||||||
|
@ -382,12 +398,14 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ivQrCode.setImageBitmap(bitmap);
|
ivQrCode.setImageBitmap(bitmap);
|
||||||
|
pbQrCode.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (WriterException e) {
|
} catch (WriterException e) {
|
||||||
Log.e("ReceiveFragment", "Error creating QrCode");
|
Log.e("ReceiveFragment", "Error creating QrCode");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -396,12 +414,6 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali
|
||||||
} else {
|
} else {
|
||||||
final CryptoCoin cryptoCoin = CryptoCoin.getByCryptoNet(this.cryptoNetAccount.getCryptoNet()).get(0);
|
final CryptoCoin cryptoCoin = CryptoCoin.getByCryptoNet(this.cryptoNetAccount.getCryptoNet()).get(0);
|
||||||
|
|
||||||
//final NextBitcoinAccountAddressRequest addressRequest = new NextBitcoinAccountAddressRequest(this.cryptoNetAccount, cryptoCoin, getContext());
|
|
||||||
|
|
||||||
//addressRequest.setListener(new CryptoNetInfoRequestListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onCarryOut() {
|
|
||||||
// if (addressRequest.getStatus() == NextBitcoinAccountAddressRequest.StatusCode.SUCCEEDED){
|
|
||||||
final CalculateBitcoinUriRequest uriRequest = new CalculateBitcoinUriRequest(cryptoCoin, cryptoNetAccount, getContext(), amount);
|
final CalculateBitcoinUriRequest uriRequest = new CalculateBitcoinUriRequest(cryptoCoin, cryptoNetAccount, getContext(), amount);
|
||||||
|
|
||||||
uriRequest.setListener(new CryptoNetInfoRequestListener() {
|
uriRequest.setListener(new CryptoNetInfoRequestListener() {
|
||||||
|
@ -419,13 +431,26 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali
|
||||||
ReceiveTransactionFragment.this.getActivity().runOnUiThread(new Runnable() {
|
ReceiveTransactionFragment.this.getActivity().runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
//Double amountNow = -1.0;
|
||||||
|
//try{
|
||||||
|
// amountNow = Double.valueOf(etAmount.getText().toString());
|
||||||
|
//} catch(NumberFormatException e){
|
||||||
|
//}
|
||||||
|
//if (amountNow >= 0) {
|
||||||
|
if (amount.equals(lastAmount)) {
|
||||||
|
if (!isCancelled()) {
|
||||||
ivQrCode.setImageBitmap(bitmap);
|
ivQrCode.setImageBitmap(bitmap);
|
||||||
|
pbQrCode.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (WriterException e) {
|
} catch (WriterException e) {
|
||||||
Log.e("ReceiveFragment", "Error creating QrCode");
|
Log.e("ReceiveFragment", "Error creating QrCode");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -437,44 +462,28 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Thread thread = new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
CryptoNetInfoRequests.getInstance().addRequest(uriRequest);
|
CryptoNetInfoRequests.getInstance().addRequest(uriRequest);
|
||||||
// } else {
|
}
|
||||||
// Toast.makeText(getContext(),"Error creating address",Toast.LENGTH_SHORT);
|
});
|
||||||
// }
|
thread.start();
|
||||||
// }
|
}
|
||||||
//});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap textToImageEncode(String Value) throws WriterException {
|
Bitmap textToImageEncode(String Value) throws WriterException {
|
||||||
//TODO: do this in another thread
|
Bitmap bitmap = null;
|
||||||
|
MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
|
||||||
BitMatrix bitMatrix;
|
|
||||||
try {
|
try {
|
||||||
bitMatrix = new MultiFormatWriter().encode(
|
BitMatrix bitMatrix = multiFormatWriter.encode(Value, BarcodeFormat.QR_CODE, ivQrCode.getWidth(), ivQrCode.getHeight());
|
||||||
Value,
|
BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
|
||||||
BarcodeFormat.DATA_MATRIX.QR_CODE,
|
bitmap = barcodeEncoder.createBitmap(bitMatrix);
|
||||||
ivQrCode.getWidth(), ivQrCode.getHeight(), null
|
} catch (WriterException e) {
|
||||||
);
|
e.printStackTrace();
|
||||||
|
|
||||||
} catch (IllegalArgumentException Illegalargumentexception) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
int bitMatrixWidth = bitMatrix.getWidth();
|
|
||||||
int bitMatrixHeight = bitMatrix.getHeight();
|
|
||||||
int[] pixels = new int[bitMatrixWidth * bitMatrixHeight];
|
|
||||||
|
|
||||||
for (int y = 0; y < bitMatrixHeight; y++) {
|
|
||||||
int offset = y * bitMatrixWidth;
|
|
||||||
|
|
||||||
for (int x = 0; x < bitMatrixWidth; x++) {
|
|
||||||
pixels[offset + x] = bitMatrix.get(x, y) ?
|
|
||||||
getResources().getColor(R.color.QRCodeBlackColor):getResources().getColor(R.color.QRCodeWhiteColor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap bitmap = Bitmap.createBitmap(bitMatrixWidth, bitMatrixHeight, Bitmap.Config.ARGB_4444);
|
|
||||||
bitmap.setPixels(pixels, 0, ivQrCode.getWidth(), 0, 0, bitMatrixWidth, bitMatrixHeight);
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -591,7 +591,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
||||||
/*
|
/*
|
||||||
* If exists mode scurity show it and valide events in case of success or fail
|
* If exists mode scurity show it and valide events in case of success or fail
|
||||||
* */
|
* */
|
||||||
CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity(), new OnResponse() {
|
CrystalSecurityMonitor.getInstance(this.getActivity()).callPasswordRequest(this.getActivity(), new OnResponse() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
|
|
||||||
|
@ -611,6 +611,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
//CryptoNetInfoRequests.getInstance().addRequest(sendRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,11 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
long idAccount = db.cryptoNetAccountDao().insertCryptoNetAccount(fetch)[0];
|
long idAccount = db.cryptoNetAccountDao().insertCryptoNetAccount(fetch)[0];
|
||||||
fetch.setId(idAccount);
|
fetch.setId(idAccount);
|
||||||
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(fetch));
|
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(fetch));
|
||||||
|
AccountSeed seed = db.accountSeedDao().findById(grapheneAccount.getSeedId());
|
||||||
|
if(seed.getName() == null || seed.getName().isEmpty()){
|
||||||
|
seed.setName(grapheneAccount.getName());
|
||||||
|
db.accountSeedDao().insertAccountSeed(seed);
|
||||||
|
}
|
||||||
subscribeBitsharesAccount(fetch.getId(),fetch.getAccountId(),context);
|
subscribeBitsharesAccount(fetch.getId(),fetch.getAccountId(),context);
|
||||||
request.success(fetch);
|
request.success(fetch);
|
||||||
}
|
}
|
||||||
|
@ -130,6 +135,11 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
long[] idAccount = db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount);
|
long[] idAccount = db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount);
|
||||||
grapheneAccount.setId(idAccount[0]);
|
grapheneAccount.setId(idAccount[0]);
|
||||||
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount));
|
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount));
|
||||||
|
AccountSeed seed = db.accountSeedDao().findById(grapheneAccount.getSeedId());
|
||||||
|
if(seed.getName() == null || seed.getName().isEmpty()){
|
||||||
|
seed.setName(grapheneAccount.getName());
|
||||||
|
db.accountSeedDao().insertAccountSeed(seed);
|
||||||
|
}
|
||||||
subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context);
|
subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,6 +159,11 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
long idAccount = db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount)[0];
|
long idAccount = db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount)[0];
|
||||||
grapheneAccount.setId(idAccount);
|
grapheneAccount.setId(idAccount);
|
||||||
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount));
|
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount));
|
||||||
|
AccountSeed seed = db.accountSeedDao().findById(grapheneAccount.getSeedId());
|
||||||
|
if(seed.getName() == null || seed.getName().isEmpty()){
|
||||||
|
seed.setName(grapheneAccount.getName());
|
||||||
|
db.accountSeedDao().insertAccountSeed(seed);
|
||||||
|
}
|
||||||
subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context);
|
subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +177,11 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
long idAccount = db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount)[0];
|
long idAccount = db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount)[0];
|
||||||
grapheneAccount.setId(idAccount);
|
grapheneAccount.setId(idAccount);
|
||||||
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount));
|
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount));
|
||||||
|
AccountSeed seed = db.accountSeedDao().findById(grapheneAccount.getSeedId());
|
||||||
|
if(seed.getName() == null || seed.getName().isEmpty()){
|
||||||
|
seed.setName(grapheneAccount.getName());
|
||||||
|
db.accountSeedDao().insertAccountSeed(seed);
|
||||||
|
}
|
||||||
subscribeBitsharesAccount(grapheneAccount.getId(), grapheneAccount.getAccountId(), context);
|
subscribeBitsharesAccount(grapheneAccount.getId(), grapheneAccount.getAccountId(), context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,6 +202,11 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
info.setAccountId(fetch.getAccountId());
|
info.setAccountId(fetch.getAccountId());
|
||||||
grapheneAccount.setAccountId(fetch.getAccountId());
|
grapheneAccount.setAccountId(fetch.getAccountId());
|
||||||
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(info);
|
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(info);
|
||||||
|
AccountSeed seed = db.accountSeedDao().findById(grapheneAccount.getSeedId());
|
||||||
|
if(seed.getName() == null || seed.getName().isEmpty()){
|
||||||
|
seed.setName(grapheneAccount.getName());
|
||||||
|
db.accountSeedDao().insertAccountSeed(seed);
|
||||||
|
}
|
||||||
subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context);
|
subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,6 +237,11 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
|
AccountSeed seed = db.accountSeedDao().findById(grapheneAccount.getSeedId());
|
||||||
|
if(seed.getName() == null || seed.getName().isEmpty()){
|
||||||
|
seed.setName(grapheneAccount.getName());
|
||||||
|
db.accountSeedDao().insertAccountSeed(seed);
|
||||||
|
}
|
||||||
subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context);
|
subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -327,7 +327,6 @@ public class FileBackupManager implements FileServiceRequestsListener {
|
||||||
public static byte[] decompress(byte[] inputBytes, int which) {
|
public static byte[] decompress(byte[] inputBytes, int which) {
|
||||||
InputStream in = null;
|
InputStream in = null;
|
||||||
try {
|
try {
|
||||||
System.out.println("Bytes: "+Util.bytesToHex(inputBytes));
|
|
||||||
ByteArrayInputStream input = new ByteArrayInputStream(inputBytes);
|
ByteArrayInputStream input = new ByteArrayInputStream(inputBytes);
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream(16*2048);
|
ByteArrayOutputStream output = new ByteArrayOutputStream(16*2048);
|
||||||
if(which == Util.XZ) {
|
if(which == Util.XZ) {
|
||||||
|
|
|
@ -98,7 +98,19 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
|
||||||
new ChildNumber(1, false));
|
new ChildNumber(1, false));
|
||||||
|
|
||||||
CryptoCoinBalance balance = new CryptoCoinBalance();
|
CryptoCoinBalance balance = new CryptoCoinBalance();
|
||||||
balance.setBalance(0);
|
long amount = 0;
|
||||||
|
List<CryptoCoinTransaction> trransactions = db.transactionDao().getByIdAccount(account.getId());
|
||||||
|
for(CryptoCoinTransaction transaction : trransactions){
|
||||||
|
if(transaction.isConfirmed()){
|
||||||
|
if(transaction.getInput()){
|
||||||
|
amount += transaction.getAmount();
|
||||||
|
}else{
|
||||||
|
amount -= transaction.getAmount();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
balance.setBalance(amount);
|
||||||
balance.setCryptoCurrencyId(db.cryptoCurrencyDao().getByName(cryptoCoin.getLabel(),cryptoCoin.name()).getId());
|
balance.setCryptoCurrencyId(db.cryptoCurrencyDao().getByName(cryptoCoin.getLabel(),cryptoCoin.name()).getId());
|
||||||
balance.setAccountId(account.getId());
|
balance.setAccountId(account.getId());
|
||||||
db.cryptoCoinBalanceDao().insertCryptoCoinBalance(balance);
|
db.cryptoCoinBalanceDao().insertCryptoCoinBalance(balance);
|
||||||
|
@ -149,6 +161,7 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
|
||||||
//if(Arrays.asList(SUPPORTED_COINS).contains(request.getCoin())){
|
//if(Arrays.asList(SUPPORTED_COINS).contains(request.getCoin())){
|
||||||
if(request.getCoin().equals(this.cryptoCoin)){
|
if(request.getCoin().equals(this.cryptoCoin)){
|
||||||
if(request instanceof BitcoinSendRequest) {
|
if(request instanceof BitcoinSendRequest) {
|
||||||
|
this.send((BitcoinSendRequest) request);
|
||||||
}else if(request instanceof CreateBitcoinAccountRequest){
|
}else if(request instanceof CreateBitcoinAccountRequest){
|
||||||
this.createGeneralAccount((CreateBitcoinAccountRequest) request);
|
this.createGeneralAccount((CreateBitcoinAccountRequest) request);
|
||||||
}else if(request instanceof NextBitcoinAccountAddressRequest){
|
}else if(request instanceof NextBitcoinAccountAddressRequest){
|
||||||
|
@ -171,9 +184,12 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
|
||||||
* @param txi
|
* @param txi
|
||||||
*/
|
*/
|
||||||
public void processTxi(Txi txi){
|
public void processTxi(Txi txi){
|
||||||
|
try {
|
||||||
|
System.out.println("GeneralAccountManager processingTxi " + txi.txid);
|
||||||
CrystalDatabase db = CrystalDatabase.getAppDatabase(this.context);
|
CrystalDatabase db = CrystalDatabase.getAppDatabase(this.context);
|
||||||
List<BitcoinTransaction> btTransactions = db.bitcoinTransactionDao().getTransactionsByTxid(txi.txid);
|
List<BitcoinTransaction> btTransactions = db.bitcoinTransactionDao().getTransactionsByTxid(txi.txid);
|
||||||
if (!btTransactions.isEmpty()) {
|
if (!btTransactions.isEmpty()) {
|
||||||
|
System.out.println("GeneralAccountManager Transaction not null " + txi.txid);
|
||||||
for (BitcoinTransaction btTransaction : btTransactions) {
|
for (BitcoinTransaction btTransaction : btTransactions) {
|
||||||
btTransaction.setConfirmations(txi.confirmations);
|
btTransaction.setConfirmations(txi.confirmations);
|
||||||
CryptoCoinTransaction ccTransaction = db.transactionDao().getById(btTransaction.getCryptoCoinTransactionId());
|
CryptoCoinTransaction ccTransaction = db.transactionDao().getById(btTransaction.getCryptoCoinTransactionId());
|
||||||
|
@ -228,7 +244,7 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ccTransaction.getAccountId() == address.getAccountId()) {
|
if (ccTransaction.getAccountId() == address.getAccountId()) {
|
||||||
amount -= vin.value;
|
amount -= (long) (vin.value * Math.pow(10, cryptoCoin.getPrecision()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,6 +271,7 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
|
||||||
output.setOriginalTxId(txi.txid);
|
output.setOriginalTxId(txi.txid);
|
||||||
|
|
||||||
gtxios.add(output);
|
gtxios.add(output);
|
||||||
|
|
||||||
BitcoinAddress address = db.bitcoinAddressDao().getdadress(addr);
|
BitcoinAddress address = db.bitcoinAddressDao().getdadress(addr);
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
if (ccTransaction.getAccountId() < 0) {
|
if (ccTransaction.getAccountId() < 0) {
|
||||||
|
@ -264,7 +281,7 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ccTransaction.getAccountId() == address.getAccountId()) {
|
if (ccTransaction.getAccountId() == address.getAccountId()) {
|
||||||
amount += vout.value;
|
amount += (long) (vout.value * Math.pow(10, cryptoCoin.getPrecision()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//TOOD multiple send address
|
//TOOD multiple send address
|
||||||
|
@ -276,11 +293,11 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
|
||||||
}
|
}
|
||||||
|
|
||||||
ccTransaction.setAmount(amount);
|
ccTransaction.setAmount(amount);
|
||||||
CryptoCurrency currency = db.cryptoCurrencyDao().getByNameAndCryptoNet(this.cryptoCoin.name(), this.cryptoCoin.getCryptoNet().name());
|
CryptoCurrency currency = db.cryptoCurrencyDao().getByNameAndCryptoNet(this.cryptoCoin.getLabel(), this.cryptoCoin.getCryptoNet().name());
|
||||||
if (currency == null) {
|
if (currency == null) {
|
||||||
currency = new CryptoCurrency();
|
currency = new CryptoCurrency();
|
||||||
currency.setCryptoNet(this.cryptoCoin.getCryptoNet());
|
currency.setCryptoNet(this.cryptoCoin.getCryptoNet());
|
||||||
currency.setName(this.cryptoCoin.name());
|
currency.setName(this.cryptoCoin.getLabel());
|
||||||
currency.setPrecision(this.cryptoCoin.getPrecision());
|
currency.setPrecision(this.cryptoCoin.getPrecision());
|
||||||
long idCurrency = db.cryptoCurrencyDao().insertCryptoCurrency(currency)[0];
|
long idCurrency = db.cryptoCurrencyDao().insertCryptoCurrency(currency)[0];
|
||||||
currency.setId(idCurrency);
|
currency.setId(idCurrency);
|
||||||
|
@ -300,6 +317,9 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
|
||||||
updateBalance(ccTransaction, amount, db);
|
updateBalance(ccTransaction, amount, db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createGeneralAccount(CreateBitcoinAccountRequest request){
|
private void createGeneralAccount(CreateBitcoinAccountRequest request){
|
||||||
|
@ -318,11 +338,11 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBalance(CryptoCoinTransaction ccTransaction, long amount, CrystalDatabase db){
|
private void updateBalance(CryptoCoinTransaction ccTransaction, long amount, CrystalDatabase db){
|
||||||
CryptoCurrency currency = db.cryptoCurrencyDao().getByNameAndCryptoNet(this.cryptoCoin.name(), this.cryptoCoin.getCryptoNet().name());
|
CryptoCurrency currency = db.cryptoCurrencyDao().getByNameAndCryptoNet(this.cryptoCoin.getLabel(), this.cryptoCoin.getCryptoNet().name());
|
||||||
if (currency == null) {
|
if (currency == null) {
|
||||||
currency = new CryptoCurrency();
|
currency = new CryptoCurrency();
|
||||||
currency.setCryptoNet(this.cryptoCoin.getCryptoNet());
|
currency.setCryptoNet(this.cryptoCoin.getCryptoNet());
|
||||||
currency.setName(this.cryptoCoin.name());
|
currency.setName(this.cryptoCoin.getLabel());
|
||||||
currency.setPrecision(this.cryptoCoin.getPrecision());
|
currency.setPrecision(this.cryptoCoin.getPrecision());
|
||||||
long idCurrency = db.cryptoCurrencyDao().insertCryptoCurrency(currency)[0];
|
long idCurrency = db.cryptoCurrencyDao().insertCryptoCurrency(currency)[0];
|
||||||
currency.setId(idCurrency);
|
currency.setId(idCurrency);
|
||||||
|
@ -360,7 +380,7 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
|
||||||
Transaction tx = new Transaction(cryptoCoin.getParameters());
|
Transaction tx = new Transaction(cryptoCoin.getParameters());
|
||||||
long currentAmount = 0;
|
long currentAmount = 0;
|
||||||
long fee = -1;
|
long fee = -1;
|
||||||
long feeRate = (Long) answer;
|
long feeRate = (long)(((double)answer) * Math.pow(10,cryptoCoin.getPrecision()));
|
||||||
fee = 226 * feeRate;
|
fee = 226 * feeRate;
|
||||||
|
|
||||||
CrystalDatabase db = CrystalDatabase.getAppDatabase(request.getContext());
|
CrystalDatabase db = CrystalDatabase.getAppDatabase(request.getContext());
|
||||||
|
@ -535,7 +555,7 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
|
||||||
System.out.println("GeneralAccountMAnager uri calculated : " + uri.toString());
|
System.out.println("GeneralAccountMAnager uri calculated : " + uri.toString());
|
||||||
|
|
||||||
request.setUri(uri.toString());
|
request.setUri(uri.toString());
|
||||||
request.validate();
|
//request.validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseUri(BitcoinUriParseRequest request){
|
private void parseUri(BitcoinUriParseRequest request){
|
||||||
|
|
|
@ -20,9 +20,13 @@ import cy.agorise.crystalwallet.enums.CryptoCoin;
|
||||||
*/
|
*/
|
||||||
@Entity(
|
@Entity(
|
||||||
tableName="crypto_coin_transaction",
|
tableName="crypto_coin_transaction",
|
||||||
|
primaryKeys = {
|
||||||
|
|
||||||
|
},
|
||||||
indices={
|
indices={
|
||||||
@Index(value={"account_id"}),
|
@Index(value={"account_id"}),
|
||||||
@Index(value={"id_currency"})
|
@Index(value={"id_currency"}),
|
||||||
|
@Index(value={"date", "account_id", "id_currency", "from", "to"},unique=true)
|
||||||
},
|
},
|
||||||
foreignKeys = {
|
foreignKeys = {
|
||||||
@ForeignKey(
|
@ForeignKey(
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class BitcoinCryptoNetVerifier extends CryptoNetVerifier{
|
||||||
|
|
||||||
CryptoNetManager.verifiedCryptoNetURL(cryptoCoin.getCryptoNet(), url, System.currentTimeMillis() - startTime);
|
CryptoNetManager.verifiedCryptoNetURL(cryptoCoin.getCryptoNet(), url, System.currentTimeMillis() - startTime);
|
||||||
}else{
|
}else{
|
||||||
System.out.println("BitcoinCryptoNetVerifier bad genesis block " + value);
|
System.out.println("BitcoinCryptoNetVerifier bad genesis block " + value + " " + url);
|
||||||
}
|
}
|
||||||
//TODO bad genesis block
|
//TODO bad genesis block
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -32,7 +32,6 @@ public abstract class CryptoNetManager {
|
||||||
|
|
||||||
public static String getURL(CryptoNet crypto, int index){
|
public static String getURL(CryptoNet crypto, int index){
|
||||||
if(TestedURLs.containsKey(crypto) && TestedURLs.get(crypto).size()>index){
|
if(TestedURLs.containsKey(crypto) && TestedURLs.get(crypto).size()>index){
|
||||||
System.out.println("Servers url list " + Arrays.toString(TestedURLs.get(crypto).toArray()));
|
|
||||||
return TestedURLs.get(crypto).get(index).getUrl();
|
return TestedURLs.get(crypto).get(index).getUrl();
|
||||||
}
|
}
|
||||||
System.out.println("Servers " + crypto.getLabel()+" dioesn't have testedurl");
|
System.out.println("Servers " + crypto.getLabel()+" dioesn't have testedurl");
|
||||||
|
|
|
@ -38,7 +38,6 @@ public class GetChainId extends BaseGrapheneHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextFrame(WebSocket websocket, WebSocketFrame frame) throws Exception {
|
public void onTextFrame(WebSocket websocket, WebSocketFrame frame) throws Exception {
|
||||||
System.out.println("<<< "+frame.getPayloadText());
|
|
||||||
String response = frame.getPayloadText();
|
String response = frame.getPayloadText();
|
||||||
|
|
||||||
Type GetChainIdResponse = new TypeToken<WitnessResponse<String>>(){}.getType();
|
Type GetChainIdResponse = new TypeToken<WitnessResponse<String>>(){}.getType();
|
||||||
|
@ -55,7 +54,5 @@ public class GetChainId extends BaseGrapheneHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFrameSent(WebSocket websocket, WebSocketFrame frame) throws Exception {
|
public void onFrameSent(WebSocket websocket, WebSocketFrame frame) throws Exception {
|
||||||
if(frame.isTextFrame())
|
|
||||||
System.out.println(">>> "+frame.getPayloadText());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,6 @@ public class GetDatabaseVersion extends BaseGrapheneHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextFrame(WebSocket websocket, WebSocketFrame frame) throws Exception {
|
public void onTextFrame(WebSocket websocket, WebSocketFrame frame) throws Exception {
|
||||||
System.out.println("<<< "+frame.getPayloadText());
|
|
||||||
String response = frame.getPayloadText();
|
String response = frame.getPayloadText();
|
||||||
|
|
||||||
Type GetChainIdResponse = new TypeToken<WitnessResponse<String>>(){}.getType();
|
Type GetChainIdResponse = new TypeToken<WitnessResponse<String>>(){}.getType();
|
||||||
|
@ -55,8 +54,6 @@ public class GetDatabaseVersion extends BaseGrapheneHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFrameSent(WebSocket websocket, WebSocketFrame frame) throws Exception {
|
public void onFrameSent(WebSocket websocket, WebSocketFrame frame) throws Exception {
|
||||||
if(frame.isTextFrame())
|
|
||||||
System.out.println(">>> "+frame.getPayloadText());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class VersionResponse{
|
public class VersionResponse{
|
||||||
|
|
|
@ -5,6 +5,8 @@ import android.widget.Spinner;
|
||||||
|
|
||||||
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.models.CryptoCoinBalance;
|
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
||||||
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||||
|
@ -29,7 +31,12 @@ public class AmountValidationField extends ValidationField {
|
||||||
public void validate(){
|
public void validate(){
|
||||||
try {
|
try {
|
||||||
final float newAmountValue = Float.parseFloat(amountField.getText().toString());
|
final float newAmountValue = Float.parseFloat(amountField.getText().toString());
|
||||||
final CryptoCurrency cryptoCurrency = (CryptoCurrency)assetSpinner.getSelectedItem();
|
final CryptoCurrency cryptoCurrency;
|
||||||
|
if(this.account.getCryptoNet() == CryptoNet.BITSHARES) {
|
||||||
|
cryptoCurrency = (CryptoCurrency) assetSpinner.getSelectedItem();
|
||||||
|
}else{
|
||||||
|
cryptoCurrency = CrystalDatabase.getAppDatabase(amountField.getContext()).cryptoCurrencyDao().getByNameAndCryptoNet(CryptoCoin.getByCryptoNet(this.account.getCryptoNet()).get(0).getLabel(),this.account.getCryptoNet().name());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Validation for the money
|
* Validation for the money
|
||||||
|
@ -66,6 +73,8 @@ public class AmountValidationField extends ValidationField {
|
||||||
setLastValue("");
|
setLastValue("");
|
||||||
setMessageForValue("",validator.getContext().getResources().getString(R.string.please_enter_valid_amount));
|
setMessageForValue("",validator.getContext().getResources().getString(R.string.please_enter_valid_amount));
|
||||||
setValidForValue("", false);
|
setValidForValue("", false);
|
||||||
|
} catch (Exception e ){
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,10 @@ import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.apache.commons.codec.binary.StringUtils;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
@ -113,7 +116,12 @@ public class TransactionViewHolder extends RecyclerView.ViewHolder {
|
||||||
CryptoNetAccountViewModel cryptoNetAccountViewModel = ViewModelProviders.of(this.fragment).get(CryptoNetAccountViewModel.class);
|
CryptoNetAccountViewModel cryptoNetAccountViewModel = ViewModelProviders.of(this.fragment).get(CryptoNetAccountViewModel.class);
|
||||||
cryptoNetAccountViewModel.loadCryptoNetAccount(transaction.getAccountId());
|
cryptoNetAccountViewModel.loadCryptoNetAccount(transaction.getAccountId());
|
||||||
|
|
||||||
String amountString = String.format("%.2f",transaction.getAmount()/Math.pow(10,cryptoCurrency.getPrecision()));
|
String pattern = new String(new char[cryptoCurrency.getPrecision()]).replace('\0', '#');
|
||||||
|
pattern = "#."+pattern;
|
||||||
|
|
||||||
|
DecimalFormat df = new DecimalFormat(pattern);
|
||||||
|
//String amountString = String.format("%.2f",transaction.getAmount()/Math.pow(10,cryptoCurrency.getPrecision()));
|
||||||
|
String amountString = df.format(transaction.getAmount()/Math.pow(10,cryptoCurrency.getPrecision()));
|
||||||
|
|
||||||
GeneralSettingListViewModel generalSettingListViewModel = ViewModelProviders.of(this.fragment).get(GeneralSettingListViewModel.class);
|
GeneralSettingListViewModel generalSettingListViewModel = ViewModelProviders.of(this.fragment).get(GeneralSettingListViewModel.class);
|
||||||
GeneralSetting timeZoneSetting = generalSettingListViewModel.getGeneralSettingByName(GeneralSetting.SETTING_NAME_TIME_ZONE);
|
GeneralSetting timeZoneSetting = generalSettingListViewModel.getGeneralSettingByName(GeneralSetting.SETTING_NAME_TIME_ZONE);
|
||||||
|
|
|
@ -138,6 +138,22 @@
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tvAmountError" />
|
app:layout_constraintTop_toBottomOf="@+id/tvAmountError" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/pbQrCode"
|
||||||
|
style="?android:attr/progressBarStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/tvAmountError"
|
||||||
|
android:layout_alignBottom="@+id/ivQrCode"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginEnd="24dp"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:contentDescription="@string/qr_code"
|
||||||
|
android:src="@color/gray"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvShare"
|
android:id="@+id/tvShare"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
Loading…
Reference in a new issue