Merge branch 'develop' of https://github.com/Agorise/crystal-wallet-android into develop-local
This commit is contained in:
commit
5b8d12f886
4 changed files with 142 additions and 111 deletions
|
@ -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'
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -542,7 +542,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){
|
||||||
|
|
|
@ -103,6 +103,8 @@
|
||||||
android:textColor="@color/red"
|
android:textColor="@color/red"
|
||||||
android:layout_below="@+id/spAsset"/>
|
android:layout_below="@+id/spAsset"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<cy.agorise.crystalwallet.util.SquaredImageView
|
<cy.agorise.crystalwallet.util.SquaredImageView
|
||||||
android:id="@+id/ivQrCode"
|
android:id="@+id/ivQrCode"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -116,6 +118,22 @@
|
||||||
android:layout_below="@+id/tvAmountError"
|
android:layout_below="@+id/tvAmountError"
|
||||||
android:layout_centerHorizontal="true"/>
|
android:layout_centerHorizontal="true"/>
|
||||||
|
|
||||||
|
<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